akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main(){
    int n,b,f,r,v;
    int faculty[5][4][11];
     
    for(int i=1;i<=4;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                faculty[i][j][k]=0;
            }
        }
    }
     
    cin>>n;
     
    for(int i=0;i<n;i++ ){
        cin>>b>>f>>r>>v;
        faculty[b][f][r]+=v;
    }
     
    for(int i=1;i<=4;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                cout<<" "<<faculty[i][j][k];
            }
            cout<<endl;
        }
        if(i==4) continue;
        cout<<"####################"<<endl;
    }
     
    return 0;
}


Measured memory_bytes: 3124
# include <bits/stdc++.h>
using namespace std;

int ball[200005], cnt[200005];
int cover[200005];
int main(){

  ios_base :: sync_with_stdio(false);

  int n, q;
  cin >> n >> q;
  for(int i=1; i<=n; i++){
    cin >> ball[i];
    cnt[ball[i]]++;
  }

  for(int i=1; i<=n; i++){
    for(int j=max(0, i-cnt[i]+1); j<=i; j++){
      cover[j]++;
    }
  }

  int ans = 0;
  for(int i=1; i<=n; i++){
    ans += (cover[i] == 0);
  }

  while(q--){
    int idx, num;
    cin >> idx >> num;

    int b = ball[idx];
    
    int left = b - cnt[b] + 1;
    if(left > 0){
      cover[left]--;
      if(cover[left] == 0) ans++;
    }
    cnt[b]--;

    left = num - cnt[num];
    if(left > 0){
      cover[left]++;
      if(cover[left] == 1) ans--;
    }

    ball[idx] = num;
    cnt[num]++;
    cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 5960
#include<iostream>
using namespace std;
int main()
{
  long int h,a,n;
  cin>>h;
  cin>>a;
  if(h%a==0)
  {
    n=h/a;
  }
  else{
    n=h/a+1;
  }
  cout<<n;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc152/tasks/abc152_a

#include <bits/stdc++.h>
using namespace std;
#define out cout <<
#define in cin >>
#define Vi vector<int>

int main(void) {
    int N, M;
    in(N); in(M);
    if (N == M) out("Yes");
    else out("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  int w[n];
  rep(i,n)cin>>w[i];
  int t=0,a,b,ans=1e5;
  //i=$B4p=`(B
  rep(i,n){
    a=0,b=0;
    //cout<<"i:"<<i;
    rep(j,n){
      j>t ? a+=w[j] : b+=w[j];
    }
    //cout<<" a:"<<a<<" b:"<<b<<endl;
    ans=min(abs(a-b),ans);
    t++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x,ans;
  rep(i,5){
    cin>>x;
    if(x==0) ans=i+1;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>

int count753(long long int num753);
int is753(long long int num);
long long int n;


int main(void){

   	int i,j,k,ans=0;	
  
  	scanf("%lld",&n);
  
  	if(n < 357){
      	printf("0\n");
      	return 0;
    }
  
   	ans += count753(0);	    
   
  
    
  	printf("%d",ans);
  
  
	return 0;
}


int count753(long long int num753){
	
  	int ret=0;
  
	if(num753 <= n){
     	if(is753(num753)){
    		ret++;
        }
    	ret += count753(num753*10+3);
    	ret += count753(num753*10+5);
      	ret += count753(num753*10+7);
    }
	
  	return ret;
  
}

int is753(long long int num){

	int flag3=0,flag5=0,flag7=0,mod;
	
	while(num !=0){
      	mod = num%10;
      	num /=10;
    	if(mod == 3) flag3 = 1;
      	if(mod == 5) flag5 = 1;
      	if(mod == 7) flag7 = 1; 
    }
  	
  	if(flag3 && flag5 && flag7){
    	return 1;
    }
  
  	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N;cin >> N;
    vector <ll> A(N);
    rep(i,N) cin >> A[i];
    
    ll minA=3e9;
    ll sum1=0;
    ll SUM=0;
    rep(i,N) SUM+=A[i];
    
    ll sub;
    rep(i,N-1){
        sum1+=A[i];
        minA=min(minA,abs(SUM-2*sum1));
        //cout << minA << endl;
    }

    ll ans=0;
    ans+=minA;
    cout << ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int A,B;cin>>A>>B;
    if(A%3==0||B%3==0||(A+B)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int s[2];
  int count = 0;
  int i;
  scanf("%1d%1d%1d",&s[0],&s[1],&s[2]);
  for(i = 0; i <= 2; i++){
    if(s[i] == 1){
      count++;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
p_list = list(map(lambda x: (1 + int(x)) / 2, input().split()))
csum_list = [0]
sum = 0
for p in p_list:
    sum += p
    csum_list.append(sum)
now_max = 0
for i in range(n - k + 1):
    tmp = csum_list[i + k] - csum_list[i]
    if tmp > now_max:
        now_max = tmp
print(now_max)


Measured memory_bytes: 23588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
/*
*/
int main() {
	int N, D, X;
	cin >> N >> D>>X;
	vector<int> A(N);
	for (int a = 0; a < N; a++)
	{
		cin>>A[a];
	}
	for (int i = 1; i <= N; i++)
	{
		for (int a = 1; a <=D; a+=A[i-1])
		{
			X++;
		}
	}
	cout << X << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  int a,b,c; cin >> a >> b >> c;
  if (b+c==a || c+a==b || a+b==c){
    cout << "Yes";
  } else {
    cout << "No";
  }


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static final long MOD = 1000000007;

    private static long nume(long n, long a) {
        long x = 1;
        for (long i = n - a + 1; i <= n; i++) {
            x = (x * i) % MOD;
        }
        return x;
    }

    private static long deno(long a) {
        long y = 1;
        for (long i = 1; i <= a; i++) {
            y = (y * i) % MOD;
        }
        return y;
    }

    public static long modpow(long x, long n) {
        long res = 1;
        while (n > 0) {
            if ((n & 1) == 1) {
                res = (res * x) % MOD;
            }
            x = (x * x) % MOD;
            n >>= 1;
        }
        return res;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int a = sc.nextInt();
        int b = sc.nextInt();

        long total = modpow(2, n) % MOD;
        long ya = deno(a);
        long yb = deno(b);
        long nca = nume(n, a) * modpow(ya, MOD - 2) % MOD;
        long ncb = nume(n, b) * modpow(yb, MOD - 2) % MOD;

        long ans = (total - 1 - nca - ncb + 2 * MOD) % MOD;
        System.out.println(ans);
    }

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,i,now = 0;scanf("%lld",&n);
  pair<ll,ll> P[n];
  for(i=0;i<n;i++) scanf("%lld%lld",&P[i].second,&P[i].first);
  sort(P,P+n);
  for(i=0;i<n;i++){
    now += P[i].second;
    if(now>P[i].first){
      printf("No\n");return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
        
        int32_t main() {
            
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
           
            int n;
            cin>>n;
            vector<int > a(1000001);
            for(int i=0;i<n;i++){
                int y;cin>>y;
                a[y]++;
            }
            for(int i=1;i<=1000000;i++){
                if( a[i]){
                    for(int j=2*i;j<1000001;j+=i){
                        if( j%i==0 )
                            a[j] = 0;
                    }
                }
            }
            int ans=0;
            for(int i=1;i<1000001;i++){
                if( a[i]==1 ){
                    ans++;
                }
            }
            cout<<ans<<endl;
            return 0;
        }

 

Measured memory_bytes: 11116
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 1000;
int a[maxn], b[maxn], c[maxn];
int n;

int erfen1(int key)
{
	int left = 0, right = n - 1;
	while (left<=right)
	{
		int mid = (left + right) >> 1;
		if (c[mid] > key) right = mid - 1;
		else if (c[mid] <= key) left = mid + 1;
	}
	return left;
}

int erfen2(int key)
{
    int left=0,right=n-1;
    while(left<=right){
        int mid=(left+right)>>1;
        if(a[mid]>=key) right=mid-1;
        else if(a[mid]<key) left=mid+1;
    }
    return right;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) scanf("%d", &b[i]);
	for (int i = 0; i < n; i++) scanf("%d", &c[i]);
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	ll ans=0;
	for(int i=0;i<n;i++){
        ll p1=erfen2(b[i]);
        ll p2=erfen1(b[i]);
        ans+=(n-p2)*(p1+1);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}


int g[2][105];
int dp[2][105];
int n;
int ans = 0;

int go(int x, int y) {
  if(x == 1 and y == n - 1) {
    return g[x][y];
  }
  if(dp[x][y] != -1) return dp[x][y];
  int cur = 0;
  if(x + 1 < 2) {
    cur = g[x][y] + go(x + 1, y);
  }
  if(y + 1 < n) {
    cur = max(cur, g[x][y] + go(x, y + 1));
  }
  return dp[x][y] = cur;
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int need = 3 * max({a, b, c}) - (a + b + c);
  if(need % 2 == 0) {
    cout << (need / 2) << '\n';
  }
  else {
    cout << (need + 3) / 2 << '\n';
  }
}

Measured memory_bytes: 256
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;

vector<ll> v[N];
vector<ll> h(N);
ll ans;

void test_case()
{
    ll n,m,i,j;
    cin>>n>>m;
    f(i,1,n+1)
        cin>>h[i];
    f(i,0,m)
    {
        ll x,y;
        cin>>x>>y;
        v[x].pu(y);
        v[y].pu(x);
    }
    f(i,1,n+1)
    {
        bool zz=0;
        vector<bool> vis(n+1);
        for(auto u : v[i])
        {
            // cout<<i<<' '<<u<<'\n';
            if(h[u]>=h[i])
            {
                zz=1;
                break;
            }
        }
        if(!zz)
            ans++;
        // cout<<zz<<' '<<ans<<'\n';
    }
    cout<<ans<<'\n';
   
}

int32_t main()
{
    IOS();
  
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 9796
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<String>()
        .chars()
        .map(|x| x.to_digit(10).unwrap() as i64)
        .sum::<i64>();
    if n % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2392
#include<bits/stdc++.h>

using namespace std;

class UnionFind{
public:
  vector<int> par, rank;

  void init(int n){
    par.resize(n);
    rank.resize(n);
    for(int i = 0; i < n; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]) par[x] = par[y];
    else{
      par[y] = par[x];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }
};

typedef pair<int, int> P; // to, cost
const int MAX = 1005;
map<string, int> M;
UnionFind uf;
int cost[MAX],n;
vector<P> E[MAX];
bool used[MAX];

int get_index(const string& s){
  if(M.count(s)) return M[s];
  else return M[s] = M.size()-1;
}

void init(){
  uf.init(n);
  M.clear();
  for(int i = 0; i < MAX; i++) E[i].clear();
}

void input(){
  for(int i = 0; i < n; i++){
    string a,b;
    int c,d;
    cin >> a >> c >> b >> d;
    cost[get_index(a)] = c;
    get_index(b);
    if(a == b) continue;
    E[get_index(b)].push_back(P(get_index(a), d));
    //    cout << b << " -> " << a << endl;
    uf.unite(get_index(a), get_index(b));
  }
}

void dfs(int pos, P& p){ // vertex cost
  
  if(used[pos]) return;
  used[pos] = true;
  p.first++;

  for(int i = 0; i < (int)E[pos].size(); i++){
    if(!used[E[pos][i].first]){
      dfs(E[pos][i].first, p);
      p.second += E[pos][i].second;
    }
  }
}

void solve(){
  vector<int> v[MAX];
  for(int i = 0; i < n; i++) v[uf.find(i)].push_back(i);
 
  int ans = 0;

  for(int i = 0; i < MAX; i++){
    if(v[i].size() == 0) continue;
    int tmp = -1;
    for(int j = 0; j < (int)v[i].size(); j++){
      memset(used, false, sizeof(used));
      P p = P(0,0);
      dfs(v[i][j],p);
      p.second += cost[v[i][j]];
/*******      if(v[i][j] == 0){
        cout << p.first << " " << p.second << endl;
        }*/
      if((p.first == (int)v[i].size()) && (tmp == -1 || tmp > p.second)) tmp = p.second;
    }
    ans += tmp;
  }
  cout << ans << endl;
}

int main(){
  
  while(cin >> n && n){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1512
n = int(input())
l = list(map(int, input().split(' ')))
l.sort(reverse=True)
length = len(l)
ans = 0
for i in range(length-2):
    for j in range(i+1,length-1):
        if not l[i]==l[j]:
            for k in range(j+1,length):
                if not l[j]==l[k]:
                    if l[i]<l[j]+l[k]:
                        ans+=1
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    
    int ans = -1;
    int ansmin = B * 10;
    int ansmax;
    if(A % 2 == 0) ansmax = (A + 1) * 12.5;
    else ansmax = (A + 1) *12.5 -1;

    for(int i = ansmin; i <= ansmax; ++i){
        if( A * 12.5 <= i
         && i < (B + 1) * 10){
            ans = i;
            break;
        }
    }
    
    //if(floor(ans * 0.08) == A); // =ans
    //else if(floor(A * 12.5 / 10) == B) ans = A * 12.5;
    //else ans = -1;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int N,i; cin>>N>>i;
  cout<<N-i+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n, k;
		cin >> n >> k;
		ll arr[n];
		for (ll i = 0; i < n; i++) cin >> arr[i];
		ll i = 0, j = k;
		while (j < n)
		{
			if (arr[i] < arr[j])
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
			i++;
			j++;
		}
	}
	return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    ll N, M;
    cin >> N >> M;
    if(N == 1 && M == 1) {
        cout << 1 << endl;
        return 0;
    }
    if(N == 1) {
        cout << M-2 << endl;
        return 0;
    }
    if(M == 1) {
        cout << N-2 << endl;
        return 0;
    }
    ll ans = (N-2) * (M-2);
    cout << ans << endl;

}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <fstream>
#include <iostream>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define maxim INT_MAX
#define fi first
#define se second

/* 1. If you can't keep solution in mind, then visualize it on a paper.
 * 2. Try to identify the type of problem - DP, Greedy, Graph, Constructive,
 * 	  Prefix/Suffix, Difference Array, BIT/Segment Tree, etc.
 * 3. Look at the problems from different perspectives - reverse the problem,
 * 	  add instead of delete (maybe?)
 * 4. Divide difficult solutions into cases and/or sequences.
 * 5. Use math rules to solve Nested Summation.
 * 6. Optimisation problems are generally solved with DP, greedy, binary search or brute-force.
 * 7. Try fixing a solution then proving we can't do better or worse than that.
 * ------------------------------------------------------------------
 */

 ll dp[100005];
 ll ans=0;
 ll c=LONG_MAX;
 ll cost(ll ar[],ll i,ll n)
 {
     if(i>=n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll x=cost(ar,i+1,n)+abs(ar[i+1]-ar[i]);
    ll y=cost(ar,i+2,n)+abs(ar[i+2]-ar[i]);
    ans=min(x,y);
    dp[i]=ans;
    return dp[i];
 }
 int main()
 {
     ll n;
     cin>>n;
     ll ar[n+2];
     for(ll i=1;i<=n;i++)
        cin>>ar[i];
    ar[n+1]=ar[n];
     ar[0]=0;
     memset(dp,-1,sizeof(dp));
     ll ans=cost(ar,(ll)1,n);
     cout<<ans<<endl;

 }

Measured memory_bytes: 12948
s = input().strip()
q = int(input())
l, r = "", ""
rev = 0
for i in range(q):
    a = input().split()
    t = int(a[0])
    if t == 1:
        rev += 1
    else:
        f = int(a[1])
        c = a[2]
        if f == 1:
            if rev % 2 == 0:
                l = c+l
            else:
                r = r+c
        else:
            if rev % 2 == 0:
                r = r+c
            else:
                l = c+l

if rev % 2 == 0:
    print(l+s+r)
else:
    print(r[::-1]+s[::-1]+l[::-1])


Measured memory_bytes: 4408
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	int res = 0;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	int INF = (int)1 << 60;
	vector<vector<int> > X(H, vector<int>(W, INF));
	X[0][0] = 0;
	if (S[0][0] == '#') X[0][0] = 1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i > 0) {
				int a = 0;
				if (S[i - 1][j] == '.' && S[i][j] == '#') {
					a = 1;
				}
				X[i][j] = min(X[i][j], X[i - 1][j] + a);
			}
			if (j > 0) {
				int a = 0;
				if (S[i][j - 1] == '.' && S[i][j] == '#') {
					a = 1;
				}
				X[i][j] = min(X[i][j], X[i][j - 1] + a);
			}
		}
	}

	cout << X[H - 1][W - 1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#define llint long long

using namespace std;

llint N, M;
llint h[1505], w[1505];
llint sumh[1505], sumw[1505];
vector<llint> vec;

int main(void)
{
  while(1){
    cin >> N >> M;
    if(N == 0 && M == 0) break;
    for(int i = 1; i <= N; i++) cin >> h[i];
    for(int i = 1; i <= M; i++) cin >> w[i];

    for(int i = 1; i <= N; i++) sumh[i] = sumh[i-1] + h[i];
    for(int i = 1; i <= M; i++) sumw[i] = sumw[i-1] + w[i];

    vec.clear();
    for(int i = 1; i <= N; i++){
      for(int j = 1; j <= N; j++){
        if(i > j) continue;
        vec.push_back(sumh[j] - sumh[i-1]);
      }
    }
    sort(vec.begin(), vec.end());

    llint ans = 0;
    for(int i = 1; i <= M; i++){
      for(int j = 1; j <= M; j++){
        if(i > j) continue;
        llint w = sumw[j] - sumw[i-1];
        ans += upper_bound(vec.begin(), vec.end(), w) - lower_bound(vec.begin(), vec.end(), w);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 19356
dice = {'N':(2, 6, 3, 4, 1, 5),'E':(4, 2, 1, 6, 5, 3),'W':(3, 2, 6, 1, 5, 4),'S':(5, 1, 3, 4, 6, 2)}
num = input().split()
for alf in input():
    num = [num[i-1]for i in dice[alf]]
print(num[0])



Measured memory_bytes: 5568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1000000007;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  s[k - 1] = (char)(s[k - 1] + 32);
  cout << s << endl;
}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
long long a[51];
long long b[51];
long long solve(long long N, long long X) {
    X = min(X, a[N]);
    if (N == 0 && X == 1) return 1;
    if (X <= 1) return 0;
    if (X < 2+a[N-1]) {
        return solve(N-1, X-1);
    }
    else {
        return b[N-1] + 1 + solve(N-1, X-(2+a[N-1]));
    }
}
int main () {
    long long N, X;
    cin >> N >> X;
    a[0] = 1;
    b[0] = 1;
    for (int i = 1; i <= N; i++) {
        a[i] = a[i-1]*2+3;
        b[i] = b[i-1]*2+1;
    }
    cout << solve(N, X) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> s;
    ans = 0;
    REP(i, s.size()) {
        if (s.at(i) == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    MSG(ans)
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int N;
  scanf("%d",&N);
  char S[N], T[N];
  scanf("%s %s", S,T);
  int i;

  for(i=0;i<N;i++){
    printf("%c%c",S[i],T[i]);
  }

   return 0;
    
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen

using namespace std;
const double INF = (double)(1 << 20);
const int g[3] = { 200, 300, 500 };
const int t[3] = { 380, 550, 850 };
const int d[3] = { 5, 4, 3 };
const int r[3] = { 80, 85, 88 };

double dp[3][5001];			// gツづ個値ツ段ツ、
double minc[5001];

void calc (int gram )
{
	for (int i = 0; i <= 5000; i += g[0] ){
		for (int j = 0; j <= 5000; j += g[1] ) {
			for (int k = 0; k <= 5000; k += g[2] ){
				if (gram == i + j + k ){
					minc[gram] = min (minc[gram], dp[0][i] + dp[1][j] + dp[2][k] );
				} // end if
			} // end for
		} // end for
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.DB", "r", stdin );
	for (int i = 0; i <= 5000; i++ ){
		for (int j = 0; j < 3; j++ ){
			dp[j][i] = INF;
		} // end for
	} // end for
	for (int j = 0; j < 3; j++ )
		dp[j][0] = 0.;

	for (int j = 0; j < 3; j++ ){
		for (int i = g[j], k = 1; i <= 5000; i += g[j], k++ ){
			dp[j][i] = dp[j][i-g[j]] + (double)t[j];
			if (k % d[j] == 0 ){
				if (k/d[j] == 1 ){
					dp[j][i] *= (double)r[j];
					dp[j][i] /= 100.;
				}else{
					dp[j][i] = dp[j][d[j]*g[j]]*(double)k/d[j];
				} // end if
			} // end if 
		} // end for
	} // end for

	for (int i = 0; i <= 5000; i++ ){
		minc[i] = INF;
	} // end for
	for (int i = 500; i <= 5000; i += 100 ){
		calc (i );
	} // end for

//	for (int i = 500; i <= 5000; i += 100 ){
//		cout << setw(4) << i << ':' << setw(4) << minc[i] << endl;
//	} // end for

	int n;
	while (cin >> n, n ){
		int res = minc[n];
		cout << res << endl;
	} // end while

/*
	for (int i = 0; i < 3; i++ ){
//	int i = 0;
		for (int j = 0; j <= 5000; j++ ){
			if (dp[i][j] != INF ){
				cout << "i: " << i << " j: " << setw(4) << j << " price: " << dp[i][j] << endl;
			} // end if
		} // end for
	} // end for 
*/		
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
vector<ll> p;
struct edge{
	ll to,cost;
};
vector<vector<edge>> e;
bool dfs(ll now,ll par,ll now_cost){
	p[now] = now_cost;
	bool flag = true;
	for(edge& next:e[now]){
		ll to = next.to;
		ll cost = next.cost;
		if(to != par){
			if(p[to] != -1e18 && p[to] != now_cost + cost)return false;
			if(p[to] == -1e18)flag &= dfs(to,now,now_cost+cost);
		}
	}

	return flag;
}
int main(){
	ll n,m;
	cin >> n >> m;
	p.resize(n,-1e18);
	e.resize(n);
	for(ll i = 0;i < m;i++){
		ll l,r,d;
		cin >> l >> r >> d;
		l--,r--;
		e[l].push_back(edge{r,d});
		e[r].push_back(edge{l,-d});
	}

	bool flag = true;
	for(int i = 0;i < n;i++){
		if(p[i] == -1e18){
			flag &= dfs(i,-1,0);
		}
	}

	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 18304
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int L[] = new int[N];
		for (int i=0;i<N;i++) {
			L[i] = sc.nextInt();
		}
//		int a[][] = new int[N][N];
//		for (int i=0;i<N;i++) {
//			for (int j=i+1;j<N;j++) {
//				a[i][j] = L[i] +L[j];
//			}
//		}
		Arrays.sort(L);
		int count =0;
		for (int i=0;i<N;i++) {
			for (int j=i+1;j<N;j++) {
				for (int k=j+1;k<N;k++) {
					if (L[k]>=L[j]+L[i]) {
						break;
					}
					if (L[i]<L[j]+L[k]&&L[j]<L[i]+L[k]) {
						count ++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 28052
#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int Mod = 1e9 + 7;

const int maxn = 500100;

int n;
int a[maxn + 5];

int fac[maxn + 5];

bool appear[maxn + 5];
int suf[maxn + 5], pre[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	memset(appear, 0, sizeof appear);
	scanf("%d", &n);
	REP(i, 0, n) scanf("%d", a + i), --a[i], appear[a[i]] = 1;
	suf[n] = 0;
	for (int i = n - 1; i >= 0; --i) suf[i] = suf[i + 1] + (!appear[i]);
	pre[0] = 0;
	REP(i, 0, n) pre[i + 1] = pre[i] + (!appear[i]);
	fac[0] = 1;
	REP(i, 0, n) fac[i + 1] = (LL)fac[i] * (i + 1) % Mod;
	int cnt = 0;
	REP(i, 0, n) if (!~a[i]) ++cnt;
	int sum = 0;
	REP(i, 0, n) if (!appear[i]) (sum += i) %= Mod;
	int ret = fac[cnt];
	int res = 0;
	REP(i, 0, n) if (!~a[i]) (res += fac[n - i - 1]) %= Mod;
	int tmp = ((LL)cnt * (cnt - 1) >> 1) % Mod;
	int now = 0;
	static int fen[maxn + 5];
	memset(fen, 0, sizeof fen);
	REP(i, 0, n) 
	{
		if (!~a[i])
		{
			(ret += (LL)sum * fac[cnt - 1] % Mod * fac[n - i - 1] % Mod) %= Mod;
			if (cnt > 1) (ret -= (LL)now * tmp % Mod * fac[cnt - 2] % Mod * fac[n - i - 1] % Mod) %= Mod;
			++now;
			(res -= fac[n - i - 1]) %= Mod;
		}
		else
		{
			if (cnt) (ret -= (LL)res * suf[a[i]] % Mod * fac[cnt - 1] % Mod) %= Mod;
			int num = a[i];
			for (int k = a[i]; k > 0; k -= k & -k) num -= fen[k];
			(ret += (LL)num * fac[cnt] % Mod * fac[n - i - 1] % Mod) %= Mod;
			if (cnt) (ret -= ((LL)now * pre[a[i]] % Mod * fac[cnt - 1] % Mod * fac[n - i - 1] % Mod)) %= Mod;
			for (int k = a[i] + 1; k <= n; k += k & -k) ++fen[k];
		}
	}
	(ret += Mod) %= Mod;
	printf("%d\n", ret);
	return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
ll power(ll x,ll y,ll p){
ll res = 1;x = x % p;
while (y > 0){
if (y & 1){res = (res*x) % p;}
y = y>>1;
x = (x*x) % p;}
return res;}
ll mcd(ll a,ll b){
    if(b>a)swap(a,b);
    if(b==0)return a;
    else return mcd(b,a%b);
}
ll t,n;
bool esprimo(ll n){
ll s=0;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){s++;}}
if(s>=2){return false;}
return true;
}
int main(){
ll n;
cin>>n;
ll a[n+5][3];
for(int i=1;i<=n;i++){
    cin>>a[i][0]>>a[i][1]>>a[i][2];
}
ll b[n+5][3];
memset(b,0,sizeof b);
for(int i=1;i<=n;i++){
    b[i][0]=max(a[i][1]+b[i-1][1],a[i][2]+b[i-1][2]);
    b[i][1]=max(a[i][0]+b[i-1][0],a[i][2]+b[i-1][2]);
    b[i][2]=max(a[i][1]+b[i-1][1],a[i][0]+b[i-1][0]);
}
cout<<max(b[n][0],max(b[n][1],b[n][2]));
}



Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
  double d;
  int S;
  while(cin >> d){
    S = 0;
    for(int i = 1;d*i < 600;i++){
      S = S + (d*i*d*i)*d ;
    }
    cout << S << endl;
  }
}

Measured memory_bytes: 3176
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

sort = sorted(A, reverse=True)
mx = sort[0]
mxn = sort[1]

for i in range(N):
    if A[i] == mx:
        print(mxn)
    else:
        print(mx)


Measured memory_bytes: 14112
#include <stdio.h>
int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a*b>=c*d){printf("%d\n",a*b);}
  else{printf("%d\n",c*d);}
return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;

int main() {
	int H, W;
	for (;;) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;

	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===



int main() {
	int N;
	cin >> N;
	Vi a(N);
	int a_max = 0;
	for (int i = 0; i < N; ++i) {
		int tmp;
		cin >> tmp;
		a[i] = tmp;
		a_max = max(a_max, tmp);
	}

	if (a_max == 0) {
		cout << 0 << endl;
		return 0;
	}

	Vi ans(N);
	int M = 0;
	Vi ansV;
	for (int i = N - 1; i >= N / 2; --i) {
		if (a[i] == 1) {
			ans[i] = 1;
			++M;
			ansV.push_back(i + 1);
		}
	}

	for (int i = N / 2 - 1; i >= 0; --i) {
		int cnt = 0;
		for (int j = 2 * i + 1; j < N; j += i + 1) {
			cnt += ans[j];
		}
		if (cnt % 2 == a[i]) {
			ans[i] = 0;
		}
		else {
			ans[i] = 1;
			++M;
			ansV.push_back(i + 1);
		}
	}

	cout << M << endl;
	for (int i = 0; i < M - 1; ++i) {
		cout << ansV[i] << " ";
	}
	cout << ansV[M - 1] << endl;
}

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    if (A == B) {
      System.out.println(C);
    } else if (B == C) {
      System.out.println(A);
    } else if (C == A) {
      System.out.println(B);
    }
  }
}

Measured memory_bytes: 21076
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


#include <stdio.h>

#include<stdio.h>

int main(void)
{
	int  a,b,c,d,tc,ac;
	

	i_cin4(a,b,c,d);
	
	tc = (c % b) ? c / b+1 : c / b;
	ac = (a % d) ? a / d+1 : a / d;

	if (tc == ac || tc < ac) { S_RTN("Yes"); }
	S_RTN("No");
	
//	return 0;
}



Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int n, m; cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) cin >> a[i] >> b[i];
	int ans = 0;
	rep(i ,m)
	{
		vector<vector<bool>> d(n, vector<bool>(n, false));
		rep(j, m)if(i != j)
		{
			d[a[j]-1][b[j]-1] = true;
			d[b[j]-1][a[j]-1] = true;
		}
		rep(z,n)rep(x,n)rep(y,n)if(d[x][z]&&d[z][y])d[x][y]=true;
		rep(j ,n)
		{
			bool ok = true;
			rep(k, n)if(!d[j][k]) ok = false;
			if(!ok)
			{
				ans++;
				break;
			}
		}
	}	
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
S = input()
a=[""]*(len(S))
ans = 0
for n in range(len(S)):
  a[n] = S[n]
for n in range(2**(len(S)-1)):
  b=[""]*(len(S))
  c=""
  for m in range(len(S)-1):
    if n>>m & 1:
      b[m] = "+" #[]でくくらない
  for p in range(len(S)):
    c += a[p]+b[p]
  ans += eval(c)
print(ans)

Measured memory_bytes: 9144
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] != i + 1) {
                count += 1;
            }
        }
        if (count == 0 || count == 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21844
# coding: utf-8


def solve():
    N = int(input())
    al = list(map(lambda x:int(x)-1, input().split()))
    bl = list(map(int, input().split()))
    cl = list(map(int, input().split()))
    ans = 0
    
    for i in range(N):
        if i != N - 1:
            if al[i] + 1 == al[i+1]:
                ans += cl[al[i]]
        ans += bl[al[i]]
    
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;


template<class T>
T gcd(T a, T b)
{
  if(a && b) {
    return gcd(min(a, b), max(a, b) % min(a, b));
  } else {
    return a;
  }
}

template<class T>
T lcm(T a, T b)
{
  return a / gcd(a, b) * b;
}

ll power(ll base, ll exponent, ll module)
{
  if(exponent % 2) {
    return power(base, exponent - 1, module) * base % module;
  } else if(exponent) {
    ll root_ans = power(base, exponent / 2, module);
    return root_ans * root_ans % module;
  } else {
    return 1;
  }
}

struct combination
{
  vector<ll> fact, inv;
  combination(int sz) : fact(sz + 1), inv(sz + 1)
  {
    fact[0] = 1;
    for(int i = 1; i <= sz; i++) {
      fact[i] = fact[i - 1] * i % mod;
    }
    inv[sz] = power(fact[sz], mod - 2, mod);
    for(int i = sz - 1; i >= 0; i--) {
      inv[i] = inv[i + 1] * (i + 1) % mod;
    }
  }
  ll Pair(int n, int r)
  {
    if(r < 0 || n < r) return 0;
    return (fact[n] * inv[n - r] % mod);
  }
  ll C(int p, int q)
  {
    if(q < 0 || p < q) return 0;
    return (fact[p] * inv[q] % mod * inv[p - q] % mod);
  }
};

template<typename T>
void print_vec(vector<T>& v)
{
  for(const auto& e: v) {
    cout << e << " ";
  }
  cout << endl;
}
template<typename T>
void print_2dvec(vector<vector<T>>& m)
{
  for(const auto& v: m) {
    for(const auto& e: v) {
      cout << e << " ";
    }
    cout << endl;
  }
}


vector<pair<ll, ll>> ps;
ll dp[(int)1e4 + 1];

int rec(int n) {
  if (n == 0) return 0;
  if (dp[n] != -1) return dp[n];

  int res = INT_MAX;
  for (auto p: ps) {
    int tmp;
    if (n - p.first < 0) tmp = p.second;
    else tmp = rec(n - p.first) + p.second;
    res = min(res, tmp);
  }

  return dp[n] = res;
}

int main(int argc, char const* argv[])
{
  ll h, n;

  cin >> h >> n;

  for (ll i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;

    ps.emplace_back(a, b);
  }

  for (int i = 0; i < (int)1e4 + 1; i++) {
    dp[i] = -1;
  }
  dp[0] = 0;

  // rec(h);
  // for (int i = 0; i < (int)1e4 + 1; i++) {
  //   cout << dp[i] << " ";
  // }
  cout << rec(h) << endl;

  return 0;
}


Measured memory_bytes: 1024
N = int(input())
t = 0
ans = "Yes"
tasks = []
for i in range(N):
  tasks.append(list(map(int, input().split())))
tasks.sort(key=lambda task: task[1])
for task in tasks:
  t += task[0]
  if task[1] < t:
    ans = "No"
    break
print(ans)

Measured memory_bytes: 90116
#include<bits/stdc++.h>


#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
#define len(x) (int)(x).size()

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
const int N = 1e6 + 10 , MOD = (int)1e9 + 7;
inline int add(int a , int b){
    if(a+b>=MOD)return a+b-MOD;
    return a+b;
}
inline int mult(int a , int b){return (1ll*a*b)%MOD;}

int dp[N] , pref[N];
int pw(int a , int b){
    if(b == 0)return 1;
    int ans = pw(a , b >> 1);
    ans = (1ll * ans * ans) % MOD;
    if(b & 1)ans = (1ll * ans * a) % MOD;
    return ans;
}

signed main(){
    int n;cin >> n;

    dp[1] = n;
    pref[1] = dp[1];
    for(int i = 2; i <= n; ++i){
        dp[i] = mult(n-1,n-1);
        dp[i] = add(dp[i] , dp[i-1]);

        int mx = (i-2);
        if(mx > 1){
            int l = i - mx - 1;
            int r = i - 3;
            assert(l == 1);
            dp[i] = add(dp[i] , pref[i - 3]);
        }
        int another = n - max(2 , i-1) + 1;


        dp[i] = add(dp[i] , another);

        pref[i] = add(pref[i-1] , dp[i]);
    }
//    cout << dp[1] << ' ' << dp[2] << '\n';
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 11328
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N;
bool ok[105];
string in;

void solve(){
  memset(ok, false, sizeof ok);
  stack<int> indices;
  for(int idx = 0; idx < N; ++idx){
    if(in[idx] == '('){
      indices.push(idx); 
      continue;
    }else if(indices.empty()) continue;

    assert(!indices.empty());
    ok[indices.top()] = true;
    indices.pop();
    ok[idx] = true;
  }


  int op = 0, cl = 0;
  for(int idx = 0; idx < N; ++idx){
    if(ok[idx]) continue;
    if(in[idx] == '(') op++;
    else cl++;
  }


  while(cl--) cout << "(";
  cout << in;
  while(op--) cout << ")";

  return;
}



int main(){
  FAST_IO
  cin >> N >> in;
  solve();

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{
    string S;
    cin >> S;

    ll length = S.size();

    ll ans = 0;
    for (ll i = 0; i < pow(2, length - 1); i++)
    {
        ll sum = 0;
        ll index = 0;
        ll tmp = S[index] - '0';
        while (index < length - 1)
        {
            if (i & (ll)pow(2, index))
            {
                sum += tmp;
                tmp = S[index+1] - '0';
            }
            else
            {
                tmp *= 10;
                tmp += S[index+1] - '0';
            }
            index++;
        }
        sum += tmp;
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define REP_(i,x,y)	for ((i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

#define P 100
#define Q (P/2)

int A,B,C,D;


int main() {
	
	cin >> A >> B >> C >> D;

	cout << MIN(MIN(A+C,A+D),MIN(B+C,B+D));

	return 0;
}


Measured memory_bytes: 256
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        System.out.println(a / 3);
    }
}

Measured memory_bytes: 35800