akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define bg begin

namespace IO{

cs int RLEN=1<<22|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=0;
	while(!isdigit(ch))f=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?-res:res;
}
inline ll readll(){
	char ch=gc();
	ll res=0;bool f=0;
	while(!isdigit(ch))f=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?-res:res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}

}
using IO::read;
using IO::readll;
using IO::readstring;

template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}

cs int N=205;
ll bs[66],a[N];
int n;
char str[N];

inline void insert(ll x){
	for(int i=60;~i;i--)if((x>>i)&1){
		if(bs[i])x^=bs[i];
		else {bs[i]=x;return;}
	}
}
inline bool find(ll x){
	for(int i=60;~i;i--)if((x>>i)&1){
		if(!bs[i])return 0;
		x^=bs[i];
	}return 1;
}
inline void solve(){
	memset(bs,0,sizeof(bs));
	n=read();
	for(int i=1;i<=n;i++)a[i]=readll();
	readstring(str);
	for(int i=n;i>=1;i--){
		if(str[i]=='0')insert(a[i]);
		else {
			if(find(a[i]))continue;
			else {puts("1");return;}
		}
	}puts("0");
}

int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	int T=read();
	while(T--)solve();
	return 0;
}

Measured memory_bytes: 3952
import javax.management.monitor.CounterMonitor;
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int answer=0;
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M =sc.nextInt();
        int L[]=new int[M];
        int R[]=new int[M];
        for(int i=0;i<M;i++)
        {
            L[i]=sc.nextInt();
            R[i]=sc.nextInt();
            if(i==0)
            {
                min=L[i];
                max=R[i];
            }else if(L[i]>min)
            {
                min=L[i];
            }
            if(R[i]<max)
            {
                max=R[i];
            }
        }
        //System.err.println("min"+min);
        //System.err.println("max"+max);
        answer=max-min+1;
        if(answer<0)
        {
            answer=0;
        }



        //出力
        //System.err.println();//標準エラー出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        System.out.println(answer);
    }
}

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

long long ret = -1;
long long k;
long long curk = 9;

void f(long long i, long long keta, long long to)
{
	keta /= 10;
	if (keta == 1) {
		if (i != 0) {
			++curk;
//			cout << to + i - 1 << endl;
			if (curk == k) {
				ret = to + i - 1;
				return;
			}
		}

		++curk;
//		cout << to + i << endl;
		if (curk == k) {
			ret = to + i;
			return;
		}

		if (i != 9) {
			++curk;
//			cout << to + i + 1 << endl;
			if (curk == k) {
				ret = to + i + 1;
				return;
			}
		}
		return;
	}

	if (i != 0) {
		f(i-1, keta, to + keta * (i-1));
		if (ret != -1) {
			return;
		}
	}

	f(i, keta, to + keta * i);
	if (ret != -1) {
		return;
	}

	if (i != 9) {
		f(i + 1, keta, to + keta * (i + 1));
		if (ret != -1) {
			return;
		}
	}
}

int main()
{
	cin >> k;

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

	long long keta = 10;
//	long long ketanum = 2;
	while (1)
	{
		for (long long i = 1; i <= 9; ++i)
		{
			f(i, keta, i*keta);
			if (ret != -1) {
				cout << ret << endl;

				return 0;
			}
		}
		keta *= 10;
//		++ketanum;
	}

	return 0;
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, k, x):
        while k <= self.n:
            self.bit[k] += x
            k += k & -k

    def sum(self, k):
        s = 0
        while k > 0:
            s += self.bit[k]
            k -= k & -k
        return s


n, m = map(int, input().split())
st = BIT(m)
L, R = [], []
d = [[] for i in range(m + 1)]
for i in range(n):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
    d[r - l + 1].append(i)

num = n
for i in range(1, m + 1):
    num -= len(d[i])
    for j in d[i]:
        st.add(L[j], 1)
        st.add(R[j] + 1, -1)

    tmp = 0
    k = i
    for j in range(k, m + 1, i):
        tmp += st.sum(j)

    print(num + tmp)


Measured memory_bytes: 121504
#include<stdio.h>
#include <sysexits.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(void){
  int N,i;
  long H;
  char S[100];
 
  if(scanf("%s",S)>1){
   exit(0);
  }
  N=strlen(S);
  
  char ans[N+1];
  
  for(i=0;i<N;i++){
    ans[i]='x';
  }
  ans[N]='\0';
  printf("%s",ans);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

int main(void){
  int H,W;
  cin >> H >> W;
  int x = -1,y = 0;
  REP(i,0,H)
    {
      REP(j,0,W)
	{
	  char a;
	  cin >>a;
	  if (a == '#' && x == j-1 && y == i)
	    {
	      x++;
	    }
	  else if (a == '#' && y == i-1 && x == j)
	    {
	      y++;
	    }
	  else if (a == '.')
	    {
	      continue;
	    }
	  else 
	    {
	      cout << "Impossible"<<endl;
	      return 0;
	    }
	}
    }
  cout << "Possible" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
S = [input().rstrip() for _ in range(N)]
cnt = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for s in S:
    cnt[s] += 1
for s in ['AC', 'WA', 'TLE', 'RE']:
    print('{} x {}'.format(s, cnt[s]))

Measured memory_bytes: 73776
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;

  vector<char> s(n);
  for(int i = 0; i < n; i++) cin >> s[i];

  for(int i = 0; i < n; i++) {
    if(s[i] == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Function
main = do
  n <- readLn
  ms <- replicateM n $ do
    [a, b] <- map (read::String -> Int) . words <$> getLine
    return (a, b)
  print $ solve ms

solve :: [(Int, Int)] -> Int
solve = uncurry (+) . maximumBy (compare `on` fst)

Measured memory_bytes: 76156
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

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

    vector<vector<char>> grid(h+2, vector<char>(w+2, '#'));
    REP(i, h){
        REP(j, w){
            cin >> grid[i+1][j+1];
        }
    }

    vector<vector<ll>> dp(h+2, vector<ll>(w+2, 0));
    REP(i, h){
        REP(j, w){
            if(i == 0 && j == 0){
                dp[i+1][j+1] = 1;
                continue;
            }
            if(grid[i+1][j+1] == '#'){
                dp[i+1][j+1] = 0;
            }else{
                dp[i+1][j+1] += dp[i][j+1] + dp[i+1][j];
                dp[i+1][j+1] %= MOD;
            }
        }
    }

    cout << dp[h][w] << endl;

    return 0;
}

Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] p = sc.IntArray();
        bool[] b = new bool[n];
        for (int i = 0; i < n; i++)
        {
            if (p[i] == i + 1)
            {
                b[i] = true;
            }
        }

        int answer = 0;
        for (int i = 0; i < n; i++)
        {
            if (b[i])
            {
                if (i != n - 1 && b[i + 1] == true)
                {
                    b[i + 1] = false;
                }
                answer++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 20192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_151
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int acs = 0;
            int pens = 0;
            int[] penCnts = new int[n];
            bool[] solved = new bool[n];
            for(int i = 0; i < m; i++)
            {
                string[] val = Read().Split();
                int num = int.Parse(val[0]) - 1;
                string state = val[1];
                if (state.Equals("AC"))
                {
                    if (!solved[num])
                    {
                        acs++;
                        pens += penCnts[num];
                        solved[num] = true;
                    }
                }
                else
                {
                    penCnts[num]++;
                }
            }
            WriteLine(acs + " " + pens);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 15456
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t n,k;
    cin>>n>>k;
    int64_t test=n%k;
    if(test==0) cout<<0<<endl;
    else{
        if(k-test>test)cout<<test<<endl;
        else cout<<k-test<<endl;
    }
}


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

int main(){
  int N,ans=0;
  cin >> N;
  vector<int> vec1(20),vec2(20);
  for(int i=0;i<N;i++)
    cin >> vec1[i];
  for(int j=0;j<N;j++)
    cin >> vec2[j];
  for(int k=0;k<N;k++){
    if(vec1[k]>vec2[k]){
      ans+=vec1[k];
      ans-=vec2[k];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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 main(){
    ios::sync_with_stdio(false);
    int h,w,m;
    cin >> h >> w >> m;
    set<pair<int,int>> s;
    vector<pair<int,int>> bx(w), by(h);//数、座標
    rep(i,w) {
        bx[i] = make_pair(0,i);
    }
    rep(i,h) {
        by[i] = make_pair(0,i);
    }
    rep(i,m) {
        int x,y;
        cin >> y >> x;
        y--;x--;
        s.emplace(x,y);
        bx[x] = make_pair(bx[x].first+1,x);
        by[y] = make_pair(by[y].first+1,y);
    }
    sort(bx.begin(),bx.end(), greater<pair<int,int>>() );
    sort(by.begin(),by.end(), greater<pair<int,int>>() );
    for(int i = 0; bx[i].first == bx[0].first; i++) {
        for(int j = 0; by[j].first == by[0].first; j++) {
            if(s.find(make_pair(bx[i].second,by[j].second)) == s.end()) {
                cout << bx[0].first+by[0].first << endl;
                return 0;
            }
        }
    }
    cout << bx[0].first+by[0].first-1 << endl;
    return 0;
}

Measured memory_bytes: 21976
from itertools import product
n = int(input())
a = []
xy = []
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xy.append(list(map(int,input().split())) ) 

cnt = 0
for bit in product([0,1],repeat=n):
    fl = [1] * n #1が正直
    hantei = True
    for i,j in enumerate(bit):
        if j == 1:
            fl[i] = 0
    counter = 0
    for k in range(n):
        for l in range(a[k]):
            #証言が矛盾するか判定する #証言の回し方がおかしい
            if fl[k] == 1 and fl[xy[counter][0]-1] != xy[counter][1]:
                hantei = False
                break
            counter += 1
    if hantei:
        cnt = max(cnt,sum(fl))

print(cnt)                
  


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int n, y, i, j, a=-1, b=-1, c=-1;

	scanf("%d%d", &n, &y);
	

	for (i = 0; i <= n; i++) {
		for (j = 0; i+j <= n; j++) {
			
			int z = n - i - j;
			if ((i * 10000 + j * 5000 + z * 1000) == y) {
				a = i;
				b = j;
				c = z;
				break;
			}
			if (z < 0) {
				break;
			}

		}
	}

	printf("%d\n", a);
	printf("%d\n", b);
	printf("%d\n", c);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int sum1[200005],sum2[200005];
int main() {
	int n=_,ans=2e9;
	string s; cin>>s;
	for( int i=0;i<n;i++ ) {
		sum1[i+1]=sum1[i];
		sum2[i+1]=sum2[i];
		if(s[i]=='#') sum1[i+1]++; //黑色
		else sum2[i+1]++; //白色
	}
	for( int i=0;i<=n;i++ ) 
		ans=min(ans,sum1[i]+sum2[n]-sum2[i]); //1~i为白色，i+1~n为黑色
	cout<<ans;
}

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

using namespace std;

long long dp[51][51][2501];

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

  int n, a;
  cin >> n >> a;

  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];

  dp[0][0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      for (int k = 0; k <= 2500; ++k) {
        if (k < v[i - 1] || j == 0) {
          dp[i][j][k] = dp[i - 1][j][k];
        } else {
          dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - v[i - 1]];
        }
      }
    }
  }

  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    res += dp[n][i][i * a];
  }

  cout << res << "\n";
}
	

Measured memory_bytes: 29752
#include<bits/stdc++.h>
using namespace std;
int main()
{
     string s[100];
     int h,w,i,j;
      cin>>h>>w;
      for(i=0;i<h;i++)
      {
          cin>>s[i];
      }
      for(i=1;i<=w+2;i++)
      {
          cout<<"#";
      }
      cout<<endl;
      for(i=0;i<h;i++)
      {
          cout<<"#"<<s[i]<<"#"<<endl;
      }
      for(i=1;i<=w+2;i++)
      {
          cout<<"#";
      }

     //  cout<<s[4]<<endl;


      return 0;
      }


Measured memory_bytes: 256
#include<stdio.h>
#define M 10001
int main(){
  char p[M]={1,1};
  int i,j,n;
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d",&n),n++){
    while(n--){
      if(p[n]+p[n-2]==0)break;
    }
    printf("%d %d\n",n-2,n);
  }
  return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
int n,k;
struct node
{
	int val,id;
	inline bool operator<(const node &rhs){return val<rhs.val;}
}a[233333];
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i].val,a[i].id=i;
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++)if(i%2!=a[i].id%2)ans++;
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{
int n;
cin>>n;
vector<int>dp(n),arr(n);
for(int i=0;i<n;i++) cin>>arr[i];
dp[0]=0; if(n>1) dp[1]=abs(arr[1]-arr[0]);
for(int i=2;i<n;i++) dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
cout<<dp[n-1];
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl



signed main(){
  int N; cin >> N;
  REP(x, N) {
    int inp = 0;
    cin >> inp;

    if (inp % 2 == 0 and !(inp % 3 == 0 or inp % 5 == 0)){
      cout << "DENIED" << endl;
      return 0;
    } 
  }

  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector

int dp[22][22];
int dx[4] = {1, -1, 0,  0};
int dy[4] = {0,  0, 1, -1};
int ans;
vec<string> a;

void solve(int p, int q)
{
    if (dp[p + 1][q + 1]) return;
    dp[p + 1][q + 1] = 1;
    if (a[p][q] != '#') {
        ans++;
    } else return;
    rep(i, 4) solve(p + dx[i], q + dy[i]);
}

int main(void)
{
    while(1) {
        int w, h;
        cin >> w >> h;
        if (w == 0) break;
        rep(i, h + 2) rep(j, w + 2) dp[i][j] = 0;
        rep(i, w + 2) {
            dp[0][i] = -1;
            dp[h + 1][i] = -1;
        }
        rep(i, h + 2) {
            dp[i][0] = -1;
            dp[i][w + 1] = -1;
        }
        a.clear();
        a.resize(h);
        pair<int, int> start;
        rep(i, h) {
            cin >> a[i];
            rep(j, w) if (a[i][j] == '@') start = make_pair(i, j);
        }
        //dp[start.first + 1][start.second + 1] = 1;
        ans = 0;
        solve(start.first, start.second);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  for (int i = 0; i < n - 1; i++) {
    if (s.substr(i, 2) == "AC") return cout << "Yes" << '\n', 0;
  }
  cout << "No" << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin >> h[i];
    bool cheak[n];
    for(int i=0;i<n;i++)cheak[i]=true;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        if(h[a-1]<h[b-1])cheak[a-1]=false;
        else if(h[a-1]>h[b-1]) cheak[b-1]=false;
        else{
            cheak[b-1]=false;
            cheak[a-1]=false;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(cheak[i])ans++;
    }
    cout << ans;
}



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

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

    vector<int> l(n);

    rep(0,n) cin >> l[i];

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

    int c = 0;

    rep(0,n-1) c += l[i];

    if(l.back() < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   if(n%2==1)
   {
       cout<<"No"<<endl;
       return 0;
   }
   else
    {
        int len=n/2;
        int flag=1;
        for(int i=0;i<len;i++)
        {
            if(s[i]!=s[i+len])
            {
                flag=0;
                break;
            }
        }
        if(!flag)
        {
            cout<<"No"<<endl;
        }
        else cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long dp[10][1001],n,s;
int main(){
	
	for(int i=0;i<10;i++){
		for(int j=0;j<1001;j++)dp[i][j]=0;
	}
	
	for(int i=0;i<1001;i++){
		if(i<=100)dp[1][i]=1;
		else dp[1][i]=0;
	}

	for(int i=2;i<10;i++){
		for(int j=1;j<1001;j++){
			if(j-i>=0)dp[i][j]+=dp[i][j-i];
			if(j-(i-1)>=0)dp[i][j]+=dp[i-1][j-(i-1)];
			if(j-101>=0)dp[i][j]-=dp[i-1][j-101];
		}
	}
	
	while(1){
		cin>>n>>s;
		if(n==0&&s==0)break;
		cout<<dp[n][s]<<endl;
	}
	

	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
int main(){
    int x;
    scanf("%d",&x);
    if((x>=400)&&(599>=x)){
        printf("8\n");
    }else if((x>=600)&&(799>=x)){
        printf("7\n");
    }else if((x>=800)&&(999>=x)){
        printf("6\n");
    }else if((x>=1000)&&(1199>=x)){
        printf("5\n");
    }else if((x>=1200)&&(1399>=x)){
        printf("4\n");
    }else if((x>=1400)&&(1599>=x)){
        printf("3\n");
    }else if((x>=1600)&&(1799>=x)){
        printf("2\n");
    }else if((x>=1800)&&(1999>=x)){
        printf("1\n");
    }
}

Measured memory_bytes: 1664
n,a = gets.split(" ").map!{|i| i.to_i}
min = 1000
frag = true
n.times do 
  c, t = gets.split(" ").map{|i| i.to_i}
  if t <= a 
    frag = false
    if min > c
      min = c
    end
  end
end
if frag == true
  puts "TLE"
else puts min
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string str;
	cin >> str;
	if (str.at(0) == str.at(1) && str.at(1) == str.at(2) && str.at(2) == str.at(0)) {
		No;
	}
	Yes;
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (auto i = 0; i < N; ++i) {
    READ(A[i]);
  }
  // main procedure
  vector<int> left_Aplusi(N);
  map<int, int> right_Aminusi;
  
  for (auto i = 0; i < N; ++i) {
    left_Aplusi[i] = A[i] + i;
    right_Aminusi[i-A[i]]++;
  }

  ll ans = 0;

  for (auto i = 0; i < N; ++i) {
    right_Aminusi[i-A[i]]--;
    ans += right_Aminusi[left_Aplusi[i]];
  }
  // output
  WRITE_N(ans);

  return 0;
}


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

using namespace std;

using ll = long long;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,m) for(int i=(n);i<(m);++i)
#define ALL(v) (v).begin(),(v).end()


int main() {
	while(1) {
	ll n,m;
	cin>>n>>m;
	if(n==0&&m==0) break;
	vector<ll> s(n);
	vector<ll> d(m);
	REP(i,n) cin>>s[i];
	REP(i,m) cin>>d[i];
	ll dp[(1ll<<n)];
	REP(i,(1ll<<n)) dp[i]=1000000000;
	dp[0]=0;
	REP(i,m) dp[0]+=d[i];
	for(ll bit=0; bit<(1ll<<n); bit++) {
		bitset<15> bi(bit);
		for(ll top=0; top<n; top++) {
			if(bi[top]==0) continue;
			ll top_cost=s[top];
			ll other_cost=0;
			for(ll i=0; i<n; i++) if(bi[i]&&i!=top) other_cost+=s[i];
			bi[top]=0;
			ll buf=dp[bi.to_ullong()];
			bi[top]=1;
			for(ll i=0; i<m; i++) {
				if(d[i]<=other_cost) continue;
				else if(d[i]>other_cost&&d[i]<=other_cost+top_cost) {
					if(abs(top_cost+other_cost-d[i])<abs(other_cost-d[i])) {
						buf-=abs(other_cost-d[i]);
						buf+=abs(top_cost+other_cost-d[i]);	
					}
				} else {
					buf-=abs(other_cost-d[i]);
					buf+=abs(top_cost+other_cost-d[i]);
				}
			}
			dp[bit]=min(dp[bit],buf);
		}
	}
	cout<<dp[(1ll<<n)-1]<<endl;
	}
}


Measured memory_bytes: 3344
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""

def sign(x):
    return x//abs(x)

def f(n, a0, s):
    cnt = 0
    cum = 0
    for i, ai in enumerate(a):
        cum += ai
        if cum == 0:
            cnt += 1
            cum = (-1)**i*s
        elif sign(cum) == (-1)**i*s:
            continue
        else:
            cnt += abs(cum)+1
            cum = (-1)**i*s
    return cnt

n = int(input())
a = list(map(int, input().split()))

cnt = 0
cnt0 = f(n, a, -1)
cnt1 = f(n, a, 1)
cnt = min([cnt0,cnt1])
print(cnt)
    

Measured memory_bytes: 14468
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll res = 0, sub = 0;
    ll r = 0, b = 0, g = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
        for(int j = i + 1; j < n; j++){
            if(s[i] == s[j]) continue;
            int k = j + j - i;
            if(k >= n) continue;
            if(s[i] == s[k] || s[j] == s[k]) continue;
            sub++;
        }
    }
    res = (r * b * g);
    //cout << res << " " << sub << "\n";
    res -= sub;
    cout << res << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3656
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let S = (0..N).map(|_| rl()).collect::<Vec<_>>();

    let mut a = 0;
    let mut b = 0;
    let mut ba = 0;
    let mut k = 0;

    for s in S {
        let s = s.as_bytes();
        match (s[0], s[s.len() - 1]) {
            (b'B', b'A') => {
                ba += 1;
            }
            (b'B', _) => {
                b += 1;
            }
            (_, b'A') => {
                a += 1;
            }
            _ => {}
        }

        for i in 0..s.len() - 1 {
            if s[i..].starts_with(b"AB") {
                k += 1;
            }
        }
    }
    debug!((a, b, ba, k));

    if a == 0 && ba >= 1 {
        a += 1;
        ba -= 1;
    }
    if b == 0 && ba >= 1 {
        b += 1;
        ba -= 1;
    }

    // xA BA BA BA xB
    if a >= 1 && b >= 1 {
        k += ba + 1;
        a -= 1;
        b -= 1;
    }

    // xA Bx
    k += min(a, b);

    println!("{}", k)
}


Measured memory_bytes: 4352
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=[]
  l2=[]
  for _ in range(n):
    a,b=LI()
    l1.append(a+b)
    l2.append(a-b)

  return max(max(l1)-min(l1),max(l2)-min(l2))

# main()
print(main())


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

int f(int n){
    if (n%2==0) {
        return n/2;
    } else {
        return 3 * n + 1;
    }
}

int main() {

    int s, m;
    int a[10000000];
    cin >> s;
    a[0] = s;


    bool flag = false;
    for (int i = 1; i < 10000000; ++i) {
        a[i] = f(a[i-1]);
        for (int j = 0; j < i; ++j) {
            if (a[i] == a[j]) {
                m = i + 1;
                flag = true;
                break;
            }
        }
        if(flag) break;
    }
    cout << m;

    return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=100*1007;

int n, k;
char wcz[nax];

string wyn;

void cons(string s)
{
	if (wyn.empty() || s<wyn)
		wyn=s;
}

int main()
{
	scanf("%d%d", &n, &k);
	scanf("%s", wcz+1);
	for (int i=1; i<=n; i++)
		wcz[n+i]=wcz[n+1-i];
	if (k==1)
	{
		for (int i=1; i<=n+1; i++)
		{
			string w="";
			for (int j=1; j<=n; j++)
				w.push_back(wcz[i-1+j]);
			cons(w);
		}
	}
	else
	{
		for (int i=n; i<=2*n; i++)
		{
			int ile=(k-(i>n));
			int tak=1;
			while(wcz[i]==wcz[i-tak])
				tak++;
			ile=1<<min(20, ile);
			ile=min(ile, n);
			string w="";
			if (tak*ile>=n)
			{
				for (int j=1; j<=n; j++)
					w.push_back(wcz[i]);
			}
			else
			{
				int resz=n-(tak*ile);
				for (int j=1; j<=n; j++)
					w.push_back(wcz[min(i-resz-tak+j, i)]);
				//~ debug() << i << " " << tak << " " << ile << " " << resz;
			}
			reverse(w.begin(), w.end());
			cons(w);
		}
	}
	
	cout << wyn << endl;
	return 0;
}


Measured memory_bytes: 256
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

vector<vi> g;
vi mx;

vb vis;
void dfs(int u)
{
  vis[u]=true;
  for(auto v:g[u])
  {
    if(!vis[v])
      dfs(v);
    mx[u]=max(mx[u],1+mx[v]);
  }

  if(g[u].size()==0)
    mx[u]=0;
}

void solve()
{
  int n,m;
  cin>>n>>m;
  g=vector<vi>(n+1);
  vis=vb(n+1,false);

  mx=vi(n+1,0);
  rep(i,m)
  {
    int u,v;
    cin>>u>>v;
    g[u].pb(v);
  }

  loop(i,1,n)
  {
    if(!vis[i])
      dfs(i);
  }

  cout<<*max_element(all(mx));

  
} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 12296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,n,a,b,c,d,max_dis=0;
    cin>>k>>n;
    int i,x[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i];
    }
    max_dis=x[n-1]-x[0];
    int min_dis=k;
    for(i=1;i<n;i++)
    {
        int dis=(k-x[i])+x[i-1];
        if(dis<min_dis) min_dis=dis;
    }
    a=min(max_dis,min_dis);
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<pair<ll,ll>> prime_factrize(ll N){
    vector<pair<ll,ll>> res;
    for(int a = 2; a * a <= N; a++){
        ll ex = 0;
        while(N % a == 0){
            ex++;
            N /= a;
        }
        res.push_back({a,ex});
    }
    if(N != 1) res.push_back({N,1});
    return res;
}
int main()
{
    int n;
    cin >> n;
    vector<ll> ex(n + 1, 0);
    for(int N = 2; N <= n; N++){
        const auto &res = prime_factrize(N);
        for(auto p : res) ex[p.first] += p.second;
    }
    ll res = 1;
    for(int p = 2; p <= n; p++){
        res *= ex[p] + 1;
        res %= (ll)(1e9 + 7);
    }
    cout << res << endl;
}

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

int compint(const void *a, const void *b) {
    int an = *(int*) a;
    int bn = *(int*) b;
    
    return an - bn;
}

int main () {
    int n, k;
    int p[1003];
    int ans = 0;
    scanf("%d %d", &n, &k);
    for (int i=0; i<n; i++) {
        scanf("%d", &p[i]);
    }
    qsort(p, n, sizeof(int), compint);

    for (int i = 0; i < k; i++) {
        ans += p[i];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define F first
#define S second
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define debug(x) cout << " > " << #x << ':' << x << endl;
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using Prior = priority_queue<T>;
template<typename T> using prior = priority_queue<T, vec<T>, greater<T>>;

const int INF = 1e9;
const ll LLINF = (ll)4*1e18;
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0,1,0,-1,1,1,-1,-1};
const int yy[8] = {1,0,-1,0,1,-1,-1,1};

void pmod(ll &a, ll b) {a = (a+b)%MOD;}
void mmod(ll &a, ll b) {a = (a-b+MOD)%MOD;}
void tmod(ll &a, ll b) {a = (a*b)%MOD;}
ll POW(ll a, ll b) {ll res=1; do{if(b%2)tmod(res,a);tmod(a,a);}while(b>>=1); return res;}
template<typename T> void amax(T &a, T b) {if(a < b) a = b;}
template<typename T> void amin(T &a, T b) {if(a > b) a = b;}

#define N 100010

vec<int> v[N], ord, par(N);

void dfs(int x, int p){
    par[x] = p;
    for(auto i:v[x])
        if(i != p)
            dfs(i, x);
    ord.EB(x);
}

void solve(){
    int n, ipa, ipb;
    
    cin >> n;
    rep(i, n-1){
        cin >> ipa >> ipb;
        v[ipa].EB(ipb);
        v[ipb].EB(ipa);
    }
    
    dfs(1, 0);
    
    ll dp[N][2] = {}, sum;
    for(auto i:ord){
        dp[i][0] = dp[i][1] = sum = 1;
        for(auto j:v[i])
            if(j != par[i]){
                tmod(sum, dp[j][0]);
                tmod(dp[i][0], dp[j][0] + dp[j][1]);
            }
        tmod(dp[i][1], sum);
    }
    
    cout << (dp[1][0] + dp[1][1]) % MOD << endl;
}

int main(){
//    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}


Measured memory_bytes: 15200
n,t=map(int,input().split())
ct=[]
ans=1001
for i in range(n):
    ct.append(list(map(int,input().split())))
    if t>=ct[i][1] and ans>ct[i][0]:
        ans=ct[i][0]
print(ans if ans<1001 else 'TLE')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)

int main() {
    // your code goes here
    ll n,m,ans[200005]={0};
    cin >> n;
    rep(i,2,n){
        cin >> m;
        ans[m]++;
    }
    rep(i,1,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
    pair<pair<string, int>, int> p[110];

    long long N;
    cin >> N;
    vector<string> S(N);
    vector<long long> P(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        cin >> P[i];
        p[i] = make_pair(make_pair(S[i], -P[i]), i);
    }
    sort(p, p+N);

    for (int i = 0; i < N; i++) {
        printf("%d\n", p[i].second+1);
    }

    return 0;
}


Measured memory_bytes: 3748
/** author: __nishad__ **/

#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    string ff, ss, tt;
    cin>>ff>>ss;
    int n = ff.size();
    tt = ss;

    for(int i=0; i<n; i++){
        tt.at(0) = ss[n-1];
        for(int j=0; j<n-1; j++){
            tt.at(j+1) = ss[j];
        }
        if(tt == ff){
            cout<<"Yes";
            return 0;
        }
        ss = tt;


    }
    cout<<"No";



}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
      	String a, b;
      
        a = sc.next();
        b = sc.next();

        if (a.equals(b)) 
        {
            out.println("H");
        } else {
            out.println("D");
        }

        sc.close();
    }
}

Measured memory_bytes: 21716
n,c = map(int, input().split())

stc = [list(map(int, input().split())) for i in range(n)]

stc2 = sorted(stc)

ans = []

for i in range(n):
    ans2 = [list(ans[i]) for i in range(len(ans))]
    time = [stc2[i][0],0,0]
    for j in range(len(ans2)):
        if stc2[i][2] != ans2[j][1]:
            ans2[j][0]+=1
        if ans2[j][0]<time[0]:
            time[0] = ans2[j][0]
            time[1] = ans2[j][1]
            time[2] = j
        elif ans2[j][0]==time[0] and time[1]!=stc2[i][2]:
            time[0] = ans2[j][0]
            time[1] = ans2[j][1]
            time[2] = j
    if time[1] == 0:
        ans.append([0,0])
        time[2]=-1
    ans[time[2]][0]=stc2[i][1]
    ans[time[2]][1]=stc2[i][2]

print(len(ans))

Measured memory_bytes: 64984
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll A,B,K;
	cin>>A>>B>>K;
	rep(i,K){
		if(i%2==0){
			if(A%2==1)A--;
			B=B+A/2;
			A=A-A/2;
		}
		else{
			if(B%2==1)B--;
			A=A+B/2;
			B=B-B/2;
		}
	}
	cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 384
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	ll cnt = 0;
	for (int i = k + 1; i <= n; ++i)
	{
		cnt += (i - k)*(n / i);
		if (k == 0) cnt += (n%i) - k;
		else cnt += max(0, (n%i) - k + 1);

	}
	cout << cnt << endl;
}

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

int n;
int a[100];

int main () {
  scanf("%d", &n);
  rep(i,n) scanf("%d", &a[i]);

  int c = 0;

  rep(i,n) for(int j = n - 1; j > i; j--) {
    if(a[j] < a[j-1]) {
      swap(a[j], a[j-1]);
      c++;
    }
  }

  rep(i,n) {
    if(i > 0) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  ll a, b;
  cin >> a >> b;

  ll c = b - a - 1;
  ll ans = c * (c + 1) / 2 - a;

  cout << ans << endl;
}


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

int main( void )
{
    int a,b;
    cin >> a >> b;
    
    if ( a <= 8 && b <= 8 )
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
}


Measured memory_bytes: 256