akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;

ll N;
vector<vector<ll>> G;
ll DP_W[(int)(1e5+5)];
ll DP_B[(int)(1e5+5)];

bool grid[(int)(1e5+5)];




int rec(ll x, bool color, ll prev){

    //white
    bool flg = true;
    if(color){ 
        if(DP_W[x] != -1) return DP_W[x];

        ll res = 1;
        for(auto v : G[x]){
            if(v != prev){
            //if(!grid[v]){
                grid[v] = true;
                ll temp = 0;
                temp += DP_W[v] = rec(v, true, x)%MOD;
                temp += DP_B[v] = rec(v, false, x)%MOD;
                res *= temp;
                flg = false;
                res %= MOD;
            }
        }
        if(flg) return DP_W[x] = 1;
        else return DP_W[x] = res%MOD;
    }

    // black
    else{
        if(DP_B[x] != -1) return DP_B[x];

        ll res = 1;
        for(auto v : G[x]){
            if(v != prev){
                ll temp = 0;
                temp += DP_W[v] = rec(v, true, x)%MOD;
                res *= temp;
                res %= MOD;
                flg = false;
            }
        }
        if(flg) return DP_B[x] = 1;
        else return DP_B[x] = res%MOD;
    }
}



int main() {
    cin >> N;
    G.resize(N);
    for(int i = 0; i < N-1; i++){
        ll a, b; cin >> a >> b; a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0; i < N; i++) DP_W[i] = DP_B[i] = -1;


    ll ans = 0;
    memset(grid, false, sizeof(grid)); grid[0] = true;
    ans += rec(0, true, -1);
    ans %= MOD;
    memset(grid, false, sizeof(grid)); grid[0] = true;
    cout << (ans + rec(0, false, -1))%MOD << endl;


}


Measured memory_bytes: 14336
#include <stdio.h>

int main(){
  int i=0,j=0;
  int s,t;
  int count=0,key;
  int left=0,right=0,mid=0;
  scanf("%d",&s);
  int S[s];
  for(i=0;i<s;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&t);
  int T[t];
  for(i=0;i<t;i++){
    scanf("%d",&T[i]);
  }

    for(i=0;i<t;i++){
      key = T[i];
      left=0;
      right=s;
      while(left < right){
	mid = (left + right) / 2;
	if(S[mid] == key){
	  count++;
	  break;
	}
	else if(key < S[mid]){
	  right = mid;
	}
	else{
	  left = mid + 1;
	}
      }
    }

      printf("%d\n",count);
      return 0;
}


  
		 
  



Measured memory_bytes: 2288
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,i,s=0;
        cin>>n;
        int a[n];
        for(i=0;i<n;i++){
                cin>>a[i];
                s+=a[i]-1;
        }
        cout<<s<<endl;
        return 0;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderBeginnerContest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // Ax - By = c
            // Ax % B = c
            // 0<=A<=100
            // 0<=B<=100
            // 0<=C<B
            var line = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
            int a = line[0];
            int b = line[1];
            int c = line[2];

            for (int x = 1; x < 100000; x++)
            {
                if(a*x % b == c)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13268
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, h] <- map read . words <$> getLine
  (a, b) <- unzip <$> replicateM n (do
      [ai, bi] <- map read . words <$> getLine
      return (ai, bi)
    )
  let
    ma = maximum a
    b' = sortBy (flip compare) $ filter (> ma) b
    l = b' ++ repeat ma
    ans = length $ takeWhile (< h) $ scanl (+) 0 l
  print ans

Measured memory_bytes: 76156
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    if(a%100>12||a%100==0){
        if(a/100>12||a/100==0){
            cout << "NA";
        }else{
            cout << "MMYY";
        }
    }else{
        if(a/100>12||a/100==0){
            cout << "YYMM";
        }else{
            cout << "AMBIGUOUS";
        }
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, -1, 0, 1};
typedef pair<pll, ll> plll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, W;
    cin >> H >> W;
    bool visited[H][W];
    queue<plll> qu;
    string s;
    REP(i, H){
    	cin >> s;
    	REP(j, W){
    		if(s[j] == '#'){
    			qu.push({{i, j}, 0});
    			visited[i][j] = true;
    		}else{
    			visited[i][j] = false;
    		}
    	}
    }

    ll res = -1;
    while(!qu.empty()){
    	auto now = qu.front();qu.pop();
    	ll cx = now.first.first;
    	ll cy = now.first.second;
    	ll cd = now.second;
    	res = max(cd, res);
    	REP(i, 4){
    		ll nx = cx + dx[i];
    		ll ny = cy + dy[i];
    		ll nd = cd + 1;
    		if(nx < 0 || nx > H-1 || ny < 0 || ny > W-1) continue;
    		if(visited[nx][ny]) continue;
    		visited[nx][ny] = true;
    		qu.push({{nx, ny}, nd});
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 25396
import math
a,b,x = map(int,input().split())

if x <= a*a*b//2:
    theta = (math.pi/2) - math.atan((2*x)/(a*b*b))
else:
    theta = math.atan(2*(a*a*b-x)/(a*a*a))

degree = math.degrees(theta)
print(degree)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;

ll divisor=1e9+7;
int main(){
	string s,t;
	cin>>s>>t;
	rep(i,s.size()){
		if(s[i]!=t[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	
}

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

#define ll long long
#define endl "\n"

int main(){
	//
    //freopen("input.txt", "r", stdin);
    //
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n,a,b;
    cin>>n>>a>>b;
    cout<<(abs(a-b)&1 ? "Borys" : "Alice")<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <set>

int main() {
    std::set<int> tree;
    int q; std::cin >> q;
    while(q--) {
        int k, x; std::cin >> k >> x;
        if(k == 0) {
            tree.insert(x);
            std::cout << tree.size() << std::endl;
        } else if(k == 1) {
            std::cout << (tree.find(x) == tree.end() ? 0 : 1) << std::endl;
        }
    }
}


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

int main()
{
int h ,a ;
cin>>h>>a;


for(int  i=0; i<a; i++)
{
    int x;
    cin>>x;
    if((h-=x) <=0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
   
}
 cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}

int dif_pii(pii&p)
{
	return abs(p.first-p.second);
}

struct solve
{
	int w, h;

	solve(int w, int h):w(w),h(h){}
	ll operator()(vector<vpii>&f) {
		int d_max=0;
		int x, y;
		for(y=0;y<h;y++)
		{
			for(x=0;x<w;x++)
			{
				max_u(d_max, dif_pii(f[y][x]));
			}
		}
		int s_max=d_max*(w+h)+1;
		vector<vector<vector<bool> > > dp(h);
		for(auto&m:dp)
		{
			m.resize(w);
			for(auto&mm:m)
			{
				mm.assign(s_max, false);
			}
		}

		dp[0][0][dif_pii(f[0][0])]=true;
		for(y=0;y<h;y++)
		{
			for(x=0;x<w;x++)
			{
				int dx=(x+1<w)?dif_pii(f[y  ][x+1]):0;
				int dy=(y+1<h)?dif_pii(f[y+1][x  ]):0;
				for(int v=0;v<s_max;v++)
				{
					if(!dp[y][x][v]) continue;
					if(x+1<w)
					{
						if(abs(v+dx)<s_max) dp[y][x+1][abs(v+dx)]=true;
						dp[y][x+1][abs(v-dx)]=true;
					}
					if(y+1<h)
					{
						if(abs(v+dy)<s_max) dp[y+1][x][abs(v+dy)]=true;
						dp[y+1][x][abs(v-dy)]=true;
					}
				}
			}
		}

		for(int v=0;v<s_max;v++)
		{
			if(dp[h-1][w-1][v]) return v;
		}
		return -1;
	}
};

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	for(;;)
	{
		int h, w;
		cin >> h >> w;
		if(cin.fail()) break;

		vector<vpii> f(h);
		for(auto&m:f) m.resize(w);

		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				cin >> f[y][x].first;
			}
		}
		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				cin >> f[y][x].second;
			}
		}

		cout << solve(w, h)(f) << "\n";
	}
	return 0;
}


Measured memory_bytes: 10624
#include<iostream>
#include<vector>

using namespace std;

#define MOD 1000000007

int main(){
  int N;
  cin >> N;
  vector< vector< vector< vector<int> > > > dp(N, vector<vector< vector<int> > >(4, vector< vector<int> >(4, vector<int>(4, 0))));
  //0:a, 1:c, 2:G, 3:T
  long long ans = 0;

  for(int i = 2; i < N; i++){
    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 4; k++){
        for(int m = 0; m < 4; m++){
          for(int n = 0; n < 4; n++){
            if(j == 0 && m == 2 && n == 1) continue;
            if(j == 0 && k == 2 && n == 1) continue;
            if(k == 0 && m == 1 && n == 2) continue;
            if(k == 0 && m == 2 && n == 1) continue;
            if(k == 2 && m == 0 && n == 1) continue;
            if(i == 2){
              dp[i][k][m][n] = 1;
            }
            else{
              dp[i][k][m][n] += dp[i-1][j][k][m];
              dp[i][k][m][n] %= MOD;
            }
          }
        }
      }
    }
  }
  for(int k = 0; k < 4 ; k++){
    for(int m = 0; m < 4; m++){
      for(int n = 0; n < 4; n++){
        ans += dp[N-1][k][m][n];
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
     
int n,m,b[510][510];
string s[510];
int dp[2][1<<24];
     
void compute() {
  int maxi = 0;
  if( n <= m ) {
    for(int i=0;i<(1<<n);i++){
        bool ok=1;
        for(int j=0;j<m;j++){
          int cont=0;
          for(int k=0;k<n;k++){
            if((i>>k)&1 && b[k][j])++cont;
          }
          if(cont&1){
            ok=0;
            break;
          }
        }
        if(ok)maxi=max(maxi,__builtin_popcount(i));
      }
  } else { // n > m
   int list[501];
      fill(list,list+n,0);
      for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
          if(b[i][j]){
            list[i]=list[i]|(1<<j);
          }
        }
      }
      for(int i=0;i<2;i++)for(int j=0;j<(1<<m);j++)dp[i][j]=-1;
      dp[0][0]=0;
      for(int i=0;i<n;i++){
        for(int j=0;j<(1<<m);j++)dp[(i+1)&1][j]=-1;
        for(int j=0;j<(1<<m);j++){
          if(dp[i&1][j]==-1)continue;
          dp[(i+1)&1][j^list[i]]=max(dp[(i+1)&1][j^list[i]],dp[i&1][j]+1);
          dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
        }
      }
      if(dp[n&1][0]!=-1)maxi=dp[n&1][0];
  }
  cout << maxi << endl;
}
     
int main() {
  while( cin >> n >> m, n ) {
    for(int i=0;i<n;i++) {
      cin >> s[i];
      for(int j=0;j<m;j++)b[i][j] = ( s[i][j] == '1' );
    }
    compute();
  }
  return 0;
}


Measured memory_bytes: 20600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main(){
  int n;
  cin >> n;
  int a = n%10;
  if(a==3) cout << "bon" << endl;
  else if(a==0 || a==1 || a==6 || a==8) cout << "pon" << endl;
  else cout << "hon" << endl;
  
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> P(n);
    copy_n(istream_iterator<int>(cin), n, P.begin());

    for (auto &p: P) p--;
    int ans = 0;
    for (int i = 0; i < n - 1; i++){
        if (P[i] == i){
            swap(P[i], P[i + 1]);
            ans++;
        }
    }
    if (P[n - 1] == n - 1)
        ans++;
    
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
long long f[maxn],s[maxn];
long long ans;
int main()
{
    int n,x;
    scanf("%d",&n);
    f[0]=0,s[0]=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        f[i]=f[i-1]+x;
        s[i]=s[i-1]^x;
    }
    int L=1;
    ans=0;
    for(int R=1;R<=n;R++)
    {
        while((f[R]-f[L-1])!=(s[R]^s[L-1])) L++;
        ans+=R-L+1;
    }
    printf("%lld\n",ans);
}


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

int main() {
  int N;
  cin >> N;
  std::vector<int> X;
  std::vector<int> ans;
  int temp;
  for(int i = 0; i < N; ++i) {
    cin >> temp;
    X.push_back(temp);
    ans.push_back(temp);
  }

  sort(X.begin(),X.end());

  for(int i = 0; i < N; ++i) {
    int left = X[N/2 - 1];
    int right = X[N/2];

    if(ans[i] < right)
      cout << right << endl;
    else
      cout << left << endl;
  }
}


Measured memory_bytes: 3948
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
char c;
int t;
int ans;
int now;

bool check(char c)
{
    if (c=='A' || c=='C' || c=='G' || c=='T')
        return 1;
    return 0;
}

int main()
{
    while (scanf("%c",&c)!=EOF)
    {
        if (c=='\n') break;
        if (!(c>='A' && c<='Z')) continue;
        if (check(c))
        {
            now+=1;
        }else
        {
            now=0;
        }
        if (now>ans)
            ans=now;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
pair<int,int> a[200001];
int ans;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i].first;
    sort(a,a+n);
    for(int i=n;i--;){//好聪明啊 
        if(a[i].second)
            continue;
        int t=2<<__lg(a[i].first);//fantastic
        int k=upper_bound(a,a+i,make_pair(t-a[i].first,0))-a;//wonderful
        if(k>0 && k<=i && a[i].first+a[k-1].first==t){
            ans++;
            a[k-1].second=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int INF = 2e9;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
namespace NetworkFlow {
	const int INF = 2e9;
	const int MAXP = 5e5 + 5;
	struct edge {
		int dest, flow;
		unsigned pos;
	};
	vector <edge> a[MAXP];
	int tot, s, t, dist[MAXP];
	unsigned curr[MAXP];
	void addedge(int x, int y, int z) {
		a[x].push_back((edge) {y, z, a[y].size()});
		a[y].push_back((edge) {x, 0, a[x].size() - 1});
	}
	int dinic(int pos, int limit) {
		if (pos == t) return limit;
		int used = 0, tmp;
		for (unsigned &i = curr[pos]; i < a[pos].size(); i++)
			if (a[pos][i].flow != 0 && dist[pos] + 1 == dist[a[pos][i].dest] && (tmp = dinic(a[pos][i].dest, min(limit - used, a[pos][i].flow)))) {
				used += tmp;
				a[pos][i].flow -= tmp;
				a[a[pos][i].dest][a[pos][i].pos].flow += tmp;
				if (used == limit) return used;
			}
		return used;
	}
	bool bfs() {
		static int q[MAXP];
		int l = 0, r = 0;
		memset(dist, 0, sizeof(dist));
		dist[s] = 1, q[0] = s;
		while (l <= r) {
			int tmp = q[l];
			for (unsigned i = 0; i < a[tmp].size(); i++)
				if (dist[a[tmp][i].dest] == 0 && a[tmp][i].flow != 0) {
					q[++r] = a[tmp][i].dest;
					dist[q[r]] = dist[tmp] + 1;
				}
			l++;
		}
		return dist[t] != 0;
	}
	int flow() {
		int ans = 0;
		while (bfs()) {
			memset(curr, 0, sizeof(curr));
			ans += dinic(s, INF);
		}
		return ans;
	}
}
int n, a[MAXN], b[MAXN];
int va[MAXN], vb[MAXN];
int main() {
	int n; read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]), a[i]++;
	for (int i = 1; i <= n; i++)
		read(b[i]), b[i]++;
	for (int i = 1; i <= n; i++) {
		if (va[i]) continue;
		int pos = i;
		while (va[pos] == 0) {
			va[pos] = i;
			pos = a[pos];
		}
	}
	for (int i = 1; i <= n; i++) {
		if (vb[i]) continue;
		int pos = i;
		while (vb[pos] == 0) {
			vb[pos] = i + n;
			pos = b[pos];
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans += a[i] != b[i];
	int s = NetworkFlow :: s = 2 * n + 1;
	int t = NetworkFlow :: t = 2 * n + 2;
	for (int i = 1; i <= n; i++) {
		if (a[i] == b[i]) {
			if (a[i] == i) continue; ans += 1;
			NetworkFlow :: addedge(vb[i], va[i], 1);
			NetworkFlow :: addedge(va[i], vb[i], 1);
		} else {
			if (a[i] == i) NetworkFlow :: addedge(s, vb[i], 1);
			else if (b[i] == i) NetworkFlow :: addedge(va[i], t, 1);
			else NetworkFlow :: addedge(va[i], vb[i], 1);
		}
	}
	ans -= NetworkFlow :: flow();
	writeln(ans);
	return 0;
}

Measured memory_bytes: 27392
A, B = [int(_) for _ in input().split()]

patA, patB = "#."

if A > B:
    A, B = B, A
    patA, patB = patB, patA

h, w = 80, 100

rows = [[patB] * w for _ in range(h)]

for i in range(B):
    x = i % (w // 4) * 4
    y = i // (w // 4) * 4
    rows[y][x:x+3] = patA, patA, patA
    rows[y+1][x:x+3] = patA, patA, patA
    rows[y+2][x:x+3] = patA, patA, patA
    if i < A - 1:
        rows[y+1][x+1] = patB

print(h, w)
for row in rows:
    print("".join(row))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct yaml{
  bool obj;
  string key,value;
  vector<yaml> v;
  yaml(){}
};

vector<string> vs;
int p=0;
yaml dfs(){
  yaml tmp;
  //cout<<p<<endl;
  if((int)vs[p].find(": ")!=-1){
    tmp.obj=0;
    int i;
    for(i=0;i<(int)vs[p].size();i++){
      if(vs[p][i]==' ') continue;
      if(vs[p][i]==':') break;
      tmp.key+=vs[p][i];
    }
    for(i+=2;i<(int)vs[p].size();i++)
      tmp.value+=vs[p][i];
    p++;
  }else{
    tmp.obj=1;
    int i,d=0;
    for(i=0;i<(int)vs[p].size();i++){
      if(vs[p][i]==' '){
	d++;
	continue;
      }
      if(vs[p][i]==':') break;
      tmp.key+=vs[p][i];
    }
    p++;
    while(p<(int)vs.size()){
      int td=0;
      for(i=0;i<(int)vs[p].size();i++){
	if(vs[p][i]==' '){
	  td++;
	  continue;
	}
	break;
      }
      if(d<td){
	tmp.v.push_back(dfs());
      }else break;
    }
  }
  return tmp;
}
string key;
void dfs2(yaml p,string tmp){
  tmp+=".";
  tmp+=p.key;
  //cout<<tmp<<endl;
  if(p.obj){
    if(tmp==key){
      cout<<"object"<<endl;
      exit(0);
    }
    for(int i=0;i<(int)p.v.size();i++) dfs2(p.v[i],tmp);
  }else{
    if(tmp==key){
      cout<<"string \""<<p.value<<"\""<<endl;
      exit(0);
    }
  }
}
signed main(){
  string buf;
  getline(cin,key);
  key=".root"+key;
  while(getline(cin,buf)) vs.push_back(buf);
  yaml root;
  root.obj=1;
  root.key="root";
  while(p<(int)vs.size()) root.v.push_back(dfs());
  //cout<<(int)vs.size()<<" "<<p<<endl;
  dfs2(root,"");
  cout<<"no such property"<<endl;
  return 0;
}

Measured memory_bytes: 3516
#include<stdio.h>
#include<string.h>
int main(void){
	int i,j,x[100];
	char s[100],s1[100];
	for(i=97;i<=122;i++)s1[i-97]=i;
	for(i=0;i<26;i++) x[i]=0;
	scanf("%s",s);
	for(i=0;i<strlen(s);i++){
		for(j=0;j<26;j++){
			if(s[i]==s1[j]){
				x[j]++;
				break;
			}
		}
	}
	for(i=0;i<26;i++){
		// printf("x[%d]=%d\n",i,x[i]);
		if(x[i]>1) break;
	}
	// printf("%d\n",i);
	if(i==26) printf("yes\n");
	else printf("no\n");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = GetInt();
            var S = GetStr().ToCharArray().Select(s => s + N > 'Z' ? (char)(s + N - 26) : (char)(s + N)).ToArray();
            var ans = new string(S);

            Console.Write(S
                );
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13340
#include <cstdio>
#include <algorithm>

using namespace std;

#define rep(i,x) for(int i=0;i<(x);++i)

const int inf = 1e9;

int N, R;

int main()
{
    scanf("%d\n%d", &N, &R);

    int mi = R, ma = -inf;

    for (int i = 1; i < N; ++i) {
        scanf("%d", &R);
        ma = max(ma, R - mi);
        mi = min(mi, R);
    }

    printf("%d\n", ma);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>

using namespace std;
int main() {
	int n;
	for (;;) {
		cin >> n;
		if (n == 0)break;
		vector<pair<char, char>> v(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i].first >> v[i].second;
		}

		int m;
		char c;
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> c;
			for (int j = 0; j < v.size(); j++) {
				if (c == v[j].first) {
					c = v[j].second;
					break;
				}
			}
			cout << c;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3000
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

    dp = [[0] * (N + 1) for _ in range(N + 1)]
    for i in range(N - 1, -1, -1):
        for j in range(N - 1, i, -1):
            if S[i] == S[j]:
                dp[i][j] = dp[i + 1][j + 1] + 1

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if ans < min(dp[i][j], j - i):
                ans = min(dp[i][j], j - i)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 270088
#include<stdio.h>
int main(void){
	int d, m1=0, m2=0, m3=0, i;
	for(i=0;i<10;i++){
		scanf("%d",&d);
		if(d>m1){
			m3=m2;
			m2=m1;
			m1=d;
		}else if(d>m2){
			m3=m2;
			m2=d;
		}else if(d>m3){
			m3=d;
		}
	}
	printf("%d\n", m1);
	printf("%d\n", m2);
	printf("%d\n", m3);
	return 0;
}

Measured memory_bytes: 600
S = input()

judgeodd = True
judgeeven = True

for i,s in enumerate(S):
    if (i + 1) % 2 == 0:
        if s == "R":
            judgeeven = False
    else:
        if s == "L":
            judgeodd = False

if judgeeven and judgeodd:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

require("fs");

!function () {
  "use strict";

  !function () {
    function splitNum(line) {
      return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
        return parseInt(n);
      });
    }

    function* range(start, end) {
      for (var i = start; i < end; i++) {
        yield i;
      }
    }

    !function (input) {
      var lines = input.split("\n");

      var _splitNum = splitNum(lines[0]),
          _splitNum2 = _slicedToArray(_splitNum, 2),
          N = _splitNum2[0],
          L = _splitNum2[1];

      var sum = 0;
      var min = 1 / 0;
      var _iteratorNormalCompletion = true;
      var _didIteratorError = false;
      var _iteratorError = undefined;

      try {
        for (var _iterator = range(L, L + N)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
          var l = _step.value;
          if (Math.abs(l) < Math.abs(min)) min = l;
          sum += l;
        }
      } catch (err) {
        _didIteratorError = true;
        _iteratorError = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion && _iterator.return != null) {
            _iterator.return();
          }
        } finally {
          if (_didIteratorError) {
            throw _iteratorError;
          }
        }
      }

      console.log(sum - min);
    }(require("fs").readFileSync("/dev/stdin", "utf8"));
  }();
}();


Measured memory_bytes: 21956
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

A, B, C, X = [int(sys.stdin.readline()) for _ in range(4)]
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            ans += a*500+b*100+c*50 == X

print(ans)


Measured memory_bytes: 13652
function main(input) {
  const a = input[1].trim().split(" ").map(i => parseInt(i));

  const a_max = 10**6+1;

  const dp = new Array(a_max+1).fill(0);
  for(let i of a){
    dp[i]++;
  }

  for(let i=1;i<=a_max;i++){
    if(dp[i]===0){ 
      continue;
    }
    for(let j=i+i;j<=a_max;j=j+i){
      if(dp[j]!==0){
        dp[j]=0;
      }
    }
  }
  console.log(dp.filter(function(x){return x===1}).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 65828
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  
  int minus_cnt = 0;
  int minv = 1e9 + 7;
  ll sum = 0;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    if (vec[i] < 0) {
      minus_cnt++;
    }
    minv = min(minv, abs(vec[i]));
    sum += abs(vec[i]);
  }
  
  if (minus_cnt % 2 == 0) {
    cout << sum << endl;
  } else {
    cout << sum - minv * 2 << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

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

int main()
{
	int n;
	scanf("%d", &n);
	
	ll g = 0;
	ll inp[n];
	for(int i = 0; i < n; i++) {
		scanf("%lld", &inp[i]);

		g = gcd(g, inp[i]);
	}

	ll lcm = inp[0];
	for(int i = 1; i < n; i++) {
		ll gg = gcd(lcm, inp[i]);
		lcm = inp[i] / gg * lcm;
	}

	printf("%lld\n", lcm);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int f = 0, s = 0;
    for(int i = 0; i < 3; i++){
        int x; cin >> x;
        if(x == 5) f++;
        if(x == 7) s++;
    }
    cout << (f == 2 && s == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
	int s;
	int m;
	int h;
	scanf("%d", &s);
	h = s / 3600;
	m = (s % 3600) / 60;
	s = s - (h * 3600 + m * 60); 
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

int f(int ind, string s, string t){
    if(ind+t.size()-1<s.size()){
        int ans=0;
        for(int i=0;i<t.size();i++){
            if(s[ind+i]!=t[i]) ans++;
        }
        return ans;
    }
    return int(s.size());
}

void solve(){
    string s,t;
    cin>>s>>t;
    int ans=t.size();
    for(int i=0;i<s.size();i++) ans=min(ans,f(i,s,t));
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

const ll MOD = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


mint choose(int n, int r) {
  mint res = 1;
  for (int i = 1; i <= r; i++) {
    res *= (n - i + 1);
    res /= (i);
  }
  return res;
}

int main2() {
  int N = nextInt();
  int a = nextInt();
  int b = nextInt();
  mint ans = mint(2).pow(N);
  ans -= 1;
  ans -= choose(N, a);
  ans -= choose(N, b);
  cout << ans.x << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
#a.sort(reverse=True)
#b.sort(reverse=True)
#c.sort(reverse=True)
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
#print(ab)
ans = []
for i in range(min(k, x*y)):
    for j in range(z):
        ans.append(ab[i] + c[j])
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

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

int main(){
  int N;
  cin >> N;
  int A[N];
  bool flag=true;
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(A[i]%2!=0) flag=false;
  }
  cout << (flag?"second":"first") << endl;
}

Measured memory_bytes: 640
N = int(input())
D, X = map(int, input().split())
a_list = []
for i in range(N):
    a = int(input())
    a_list.append(a)

count = 0
for i in range(N):
    a = a_list[i]
    count += len([i +1 for i in range(D) if i % a == 0])
print(count + X)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    string S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S==U){
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " " << B-1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main(){
    ll n;
    cin >> n;
    ll a[n];
    for (ll i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    ll x=0;
    bool f=true;
    for (ll i=0;i<n;i++){
        if (a[n-1-i]==a[n-i-2] and a[n-i-2]==n-1-(x*2)){
            i++;
            x++;
            continue;
        }else if (i==n-1 and a[n-i-1]==0){
            break;
        }
        f=false;
    }
    if (!f){
        cout << 0 << endl;
        return 0;
    }
    if (n%2)n--;
    ll ans=1;
    for (ll i=0;i<n;i+=2){
        ans*=2;
        ans%=1000000007;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

int N;
long long a[100010][3];
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 8268
N = int(input())
L = [0,0] + [1]*55555
K = []
for i in range (len(L)):
  if L[i]:
    for j in range (2*i,len(L),i):
      L[j] = 0
    if i%5 == 1:
      K.append(i)
      if len(K) == N:
          break
print(*K)

Measured memory_bytes: 9836
xy = list(map(int, input().split()))
x = xy[2]
y = xy[3]
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
xn.append(x)
ym.append(y)
if max(xn) < min(ym):
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
x,y=map(int,input().split())
if x==1:
    X=300000
elif x==2:
    X=200000
elif x==3:
    X=100000
else:
    X=0
if y==1:
    Y=300000
elif y==2:
    Y=200000
elif y==3:
    Y=100000
else:
    Y=0
if x==1 and y==1:
    Add=400000
else:
    Add=0
ans=X+Y+Add
print(ans)


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> s;
	n = s.size();
	f = 0;
	x = 0;
	y = 0;
	rep(i, n){
		if(s[i] == 'A' && f == 0){
			f = 1;
			x = i;
		}
		if(s[i] == 'Z'){
			y = i - x + 1;
		}
	}

	cout << y << endl;
}

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

int main(){
  int H,W,K,ans=0;
  cin >> H >> W >> K;
  vector<vector<char>> C(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> C.at(i).at(j);
    }
  }
  for(int bitH=0;bitH<(1<<H);bitH++){
    for(int bitW=0;bitW<(1<<W);bitW++){
      int count=0;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          if(bitH & (1<<i)){
            continue;
          }
          if(bitW & (1<<j)){
            continue;
          }
          if(C.at(i).at(j)=='#'){
            count++;
          }
        }
      }
      if(count==K){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
using System;

namespace TestSpace
{
    class Test
    {
        static void Main(string[] args)
        {
            string[] arrRead;
            int a, b;
            string op;

            while (true)
            {
                arrRead = Console.ReadLine().Split(' ');
                a = int.Parse(arrRead[0]);
                b = int.Parse(arrRead[2]);
                op = arrRead[1];

                switch (op)
                {
                    case "+":
                        Console.WriteLine("{0}", a + b);
                        break;
                    case"-":
                        Console.WriteLine("{0}", a - b);
                        break;
                    case "*":
                        Console.WriteLine("{0}", a * b);
                        break;
                    case "/":
                        Console.WriteLine("{0}", a / b);
                        break;
                    default:
                        goto LOOPEND;
                }
            }
LOOPEND: ;
        }
    }
}



Measured memory_bytes: 19972
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        string s = to_string(i + 1);
        if(s.size() % 2 == 1) ans++;
    }
    
    cout << ans << endl;

    return 0;
}


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

long long dp[110][100100] = {0};

int main() {
  int n, w;
  cin >> n >> w;
  long long weight[110];
  long long value[110];
  for (int i = 0; i < n; i++) cin >> weight[i] >> value[i];

  for (int i = 0; i < n; i++) {
    for (int sum_w = 0; sum_w <= w; sum_w++) {
      if (sum_w-weight[i] >= 0) dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      else dp[i+1][sum_w] = dp[i][sum_w];
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 79360
import sys
from collections import deque
n,m = map(int, sys.stdin.readline().rstrip("\n").split())
edge = [[] for i in range(n)]
for i in range(m):
    a,b = map(int, sys.stdin.readline().rstrip("\n").split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
footprint = [10**9+7]*n
q = deque()
footprint[0] = 0
for i in edge[0]:
    q.append((i,0))
while q:
    nn,fn = q.popleft()
    if footprint[nn] == 10**9+7:
        footprint[nn] = fn
        for i in edge[nn]:
            if footprint[i] == 10**9+7:
                q.append((i,nn))
if 10**9+7 in footprint:
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(footprint[i]+1)

Measured memory_bytes: 97904
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Node {
  int v;
  int dist;

  Node(int v = -1, int dist = 0) {
    this->v = v;
    this->dist = dist;
  }
};


int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  map<int, int> ans;

  fprintf(stderr, "N: %d, X: %d, Y: %d\n", N, X, Y);

  int G[N + 1][N + 1];
  memset(G, -1, sizeof(G));

  queue<Node> que;

  for (int i = 1; i <= N; ++i) {
    que.push(Node(i, 0));

    while (!que.empty()) {
      Node node = que.front();
      que.pop();

      if (G[i][node.v] != -1) continue;
      G[i][node.v] = node.dist;

      if (node.v < N) {
        que.push(Node(node.v + 1, node.dist + 1));
      }

      if (node.v > 1) {
        que.push(Node(node.v - 1, node.dist + 1));
      }

      if (node.v == X) {
        que.push(Node(Y, node.dist + 1));
      }

      if (node.v == Y) {
        que.push(Node(X, node.dist + 1));
      }
    }
  }

  for (int i = 1; i < N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      int dist = G[i][j];
      ans[dist]++;
    }
  }

  for (int k = 1; k <= N - 1; ++k) {
    cout << ans[k] << endl;
  }

  return 0;
}


Measured memory_bytes: 16000
def sol():
    n,c=map(int,input().split())
    d=[[int(i) for i in input().split()] for i in range(c)]
    t=[[int(i) for i in input().split()] for i in range(n)]
    x0,x1,x2={},{},{}
    for p in range(n**2):
        h,w=p//n,p%n
        x=(h+w)%3
        o=t[h][w]-1
        if x==0:
            if o in x0: x0[o]+=1
            else: x0[o]=1
        if x==1:
            if o in x1: x1[o]+=1
            else: x1[o]=1
        if x==2:
            if o in x2: x2[o]+=1
            else: x2[o]=1
    ans=-1
    for a in range(c**2):
        for k in range(c):
            i,j=a//c,a%c
            q=[i,j,k]
            if len(set(q))<3: continue
            chk=0
            for p in x0:
                chk+=d[p][q[0]]*x0[p]
            for p in x1:
                chk+=d[p][q[1]]*x1[p]
            for p in x2:
                chk+=d[p][q[2]]*x2[p]
            if ans==-1: ans=chk
            ans=min(ans,chk)

    print(ans)

if __name__=="__main__":
    sol()

Measured memory_bytes: 45788
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
ans=0
def comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
        comb_ans=int(comb_ans)
    return comb_ans
S=[0]*N
S[0]=A[0]
for i in range(1,N):
    S[i]=S[i-1]+A[i]
cnt = Counter(S)
cnt.update([0])
counts = cnt.most_common()

for i in counts:
    if i[1]>=2:
        ans+=comb(i[1],2)
print(ans)

Measured memory_bytes: 48732
#include <bits/stdc++.h>
#include <iostream>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
 
int main(){
    int n,b;
    vector<int> a(9);
    rep(i,9)cin>>a.at(i);
    cin>>n;
    //vector<int> b(n);
    rep(i, n){
        cin>>b;
        rep(i,9){
            if(b==a.at(i))a.at(i)=0;
        }
    }
    if(a.at(0)==0&&a.at(1)==0&&a.at(2)==0)cout<<"Yes"<<endl;
    else if(a.at(3)==0&&a.at(4)==0&&a.at(5)==0)cout<<"Yes"<<endl;
    else if(a.at(6)==0&&a.at(7)==0&&a.at(8)==0)cout<<"Yes"<<endl;
     else if(a.at(0)==0&&a.at(3)==0&&a.at(6)==0)cout<<"Yes"<<endl;
      else if(a.at(1)==0&&a.at(4)==0&&a.at(7)==0)cout<<"Yes"<<endl;
       else if(a.at(2)==0&&a.at(5)==0&&a.at(8)==0)cout<<"Yes"<<endl;
        else if(a.at(0)==0&&a.at(4)==0&&a.at(8)==0)cout<<"Yes"<<endl;
         else if(a.at(2)==0&&a.at(4)==0&&a.at(6)==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
   

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,a,b,c,way;
int main()
{
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
     {for(int j=0;j<=b;j++)
       {
        for(int k=0;k<=c;k++)
     {
         if(x==((i*500)+(j*100)+(k*50))) way++;
     }
       }
     }
     cout<<way;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;
typedef pair<ll,ll> P;
#define fi first
#define se second

int main(){
ios::sync_with_stdio(false);
cin.tie(0);
string s,t;
cin>>s>>t;
bool flag=false;
for(int i=s.size();i>=0;i--){
    if(i+t.size()-1<s.size()&&(s.at(i)=='?'||s.at(i)==t.at(0))){
        int j=0;
        flag=true;
        while(i+j<s.size()&&j<t.size()){
            if(s.at(i+j)!='?'&&s.at(i+j)!=t.at(j)){flag=false;break;}
            j++;
        }
        if(j!=t.size())flag=false;
        if(flag){
            for(int k=i;k<i+j;k++){
                s.at(k)=t.at(k-i);
            }
            break;
        }
    }
}
if(flag){
   for(int i=0;i<s.size();i++){
       if(s.at(i)=='?')cout<<'a';
       else cout<<s.at(i);
   }
   cout<<endl;
}
else cout<<"UNRESTORABLE"<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
H = list(sorted([int(input()) for _ in range(N)]))

diff = [h - H[0] for h in H]

res = 10 ** 10
for i in range(N - (K - 1)):
    res = min(res, diff[i + (K - 1)] - diff[i])

print(res)

Measured memory_bytes: 56664