akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int i,n;
  scanf("%d",&n);
  long int a[n+100];
  for(i=0;i<n;i++) scanf("%ld",&a[i]);

  long int sum = a[0];
  for(i=1;i<n;i++)
    sum = sum^a[i];

  if(sum==0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

const int MaxN = 1e5;
int n, Ev, block, cnt;
int a[MaxN + 5];

int main()
{
	while (~scanf("%d", &n)) {
		for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
		sort(a + 1, a + n + 1); 
		Ev = block = 0; cnt = 1;
		for (int i = 2; i <= n; i++) {
			if (a[i] != a[i - 1]) Ev += (!(cnt & 1)), block++, cnt = 1;
				else cnt++;
		}
		Ev += (!(cnt & 1)); block++;
		if (Ev & 1) printf("%d\n", block - 1);
			else printf("%d\n", block);
	}
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};

struct Point {
	int h;
	int x, y;
	bool operator>(const Point &rhs) const {
		return h > rhs.h;
	}
};

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>> M(H, vector<int>(W));
	
	priority_queue<Point, vector<Point>, greater<Point>> Q;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> M[i][j];
			Q.push((Point){M[i][j], j, i});
		}
	}

	vector<vector<int>> type(H, vector<int>(W, 0));
	vector<vector<pii>> dst(H, vector<pii>(W));
	int ans = 0;
	while(!Q.empty()) {
		Point p = Q.top(); Q.pop();
		int cnt = 0;
		int tempx, tempy;
		set<pii> dests;
		bool found_type2 = false;
		for(int k = 0; k < 4; k++) {
			int tx = p.x + dx[k];
			int ty = p.y + dy[k];
			if (tx < 0 || tx >= W || ty < 0 || ty >= H) continue;
			if (type[ty][tx] == 1) {
				cnt++;
				tempx = tx, tempy = ty;
				dests.insert(dst[ty][tx]);
			} else if (type[ty][tx] == 2) {
				found_type2 = true;
			}
		}

		if (!found_type2 && (cnt == 0 || dests.size() == 1)) {
			type[p.y][p.x] = 1;
			if (cnt == 0) {
				dst[p.y][p.x] = mp(p.x, p.y);
			} else {
				dst[p.y][p.x] = dst[tempy][tempx];
			}
		} else {
			type[p.y][p.x] = 2;
			ans++;
		}
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 30388
#include <iostream>

using namespace std;

int main()
{
    int A, B, K;
    cin >> K >> A >> B;

    for (int i = A; i <= B; i++){
        if (i % K == 0){
            cout << "OK";
            goto Exit;
        }
    }
    cout << "NG";
    Exit: ;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a;
	cin >> n >> a;
	cout << n*n - a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

ll dp[200005];

ll pc(ll x)
{
    ll co=0;
    while(x>0)
    {
        if(x&1)
            co++;
        x=x/2;
    }
    return co;
}

int main() 
{
    FAST;
    for(int i=1;i<200005;i++)
        dp[i]=dp[i%pc(i)]+1;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll c=0;
    for(int i=0;i<n;i++)
        if(s[i]=='1')
            c++;
    if(c==0)
    {
        for(int i=0;i<n;i++)
            cout<<1<<'\n';
        return 0;
    }
    if(c==1)
    {
        if(s[n-1]=='1')
        {
            for(int i=0;i<n;i++)
            {
                if(s[i]=='1')
                    cout<<0<<"\n";
                else
                    cout<<2<<"\n";
            }
        }
        else
        {
            for(int i=0;i<n;i++)
            {
                if(s[i]!='1')
                {
                    if(i!=n-1)
                        cout<<1<<'\n';
                    else
                        cout<<2<<'\n';
                }
                else
                    cout<<0<<'\n';
            }
        }
        return 0;
    }
    ll x=0,y=0,z=0;
    ll te1[n],te2[n],te3[n];
    te1[n-1]=1;
    te2[n-1]=1;
    te3[n-1]=1;
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='1')
        {
            x=(x+te1[i])%(c-1);
            y=(y+te2[i])%c;
            z=(z+te3[i])%(c+1);
        }
        if(i!=0)
        {
            te1[i-1]=(te1[i]*2ll)%(c-1);
            te2[i-1]=(te2[i]*2ll)%(c);
            te3[i-1]=(te3[i]*2ll)%(c+1);
        }
    }
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            ll a=(x-te1[i]+c-1)%(c-1);
            cout<<dp[a]+1<<'\n';
        }
        else
        {
            ll a=(z+te3[i])%(c+1);
            cout<<dp[a]+1<<'\n';
        }
    }
    subt;
    return 0;
}

Measured memory_bytes: 10108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI c;
    FOR(i, 0, n) {
        int x; cin >> x;
        if (!c.empty() && c.back() == x)continue;
        c.push_back(x);
    }
    n = c.size();

    VL cnt(200001), dp(n + 1);
    dp[0] = 1;

    FOR(i, 0, n) {
        (dp[i + 1] += dp[i]) %= mod;
        (dp[i + 1] += cnt[c[i]]) %= mod;
        (cnt[c[i]] += dp[i]) %= mod;
    }

    cout << dp[n] << "\n";
}


Measured memory_bytes: 4340
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long lli;
 
int main() {
  lli M, rd, rr, cd, cr;
  cin >> M >> rd >> rr >> cd >> cr;
  lli xd = cd*100/rd;
  while(xd*rd/100 < cd) ++xd;
  if(xd > M) {
    cout << -1 << endl;
    return 0;
  }
  M -= xd;
  lli remd = xd*rd/100 - cd;
 
  lli xr = cr*100/rr;
  while(xr*rr/100 < cr) ++xr;
  if(xr > M) {
    cout << -1 << endl;
    return 0;
  }
  M -= xr;
  lli remr = xr*rr/100 - cr;
 
  M += remd * 100 / rd;
  M += remr * 100 / rr;
 
  cout << M << endl;
  return 0;
}

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

int main() {
    int n,total=0;
    int a[200]={0};

    cin >> n;

    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    while(1){
        for(int i=0; i<n; i++){
            if(a[i]%2 == 0){
                a[i] = a[i]/2;
            }else{
                goto LABEL;
            }
        }
        total++;
    }
    LABEL:


    cout << total<< endl;

}


Measured memory_bytes: 256
N=int(input())
S=input().rstrip()
t=""
d=0
for i in range(N):
  if S[i]=="(":
    d+=1
    t+="("
  else:
    if d>0:
      t+=")"
      d-=1
    else:
      t="("+t+")"
if d>0: t+=")"*d
else: t="("*(-d)+t
print(t)

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

using namespace std;

int main()
{
    int N, T, L, B;
    double dp[128][128][2];
    
    while (scanf("%d %d %d %d", &N, &T, &L, &B) && N){
        int lose[128] = {0}, back[128] = {0};
        
        for (int i = 0; i < L; i++){
            int x; scanf("%d", &x); lose[x] = 1;
        }
        for (int i = 0; i < B; i++){
            int x; scanf("%d", &x); back[x] = 1;
        }
        
        for (int i = 0; i <= T; i++){
            for (int j = 0; j <= N; j++){
                dp[i][j][0] = dp[i][j][1] = 0;
            }
        }
        
        dp[0][0][0] = 1.0;
        
        for (int i = 1; i <= T; i++){
            for (int j = 0; j < N; j++){
                double p = dp[i - 1][j][0];
                for (int k = 1; k <= 6; k++){
                    int dst = (j + k <= N ? j + k : 2 * N - j - k);
                    if (lose[dst]) dp[i][dst][1] += p / 6;
                    else if (back[dst]) dp[i][0][0] += p / 6;
                    else dp[i][dst][0] += p / 6;
                }
                dp[i][j][0] += dp[i - 1][j][1];
            }
        }
        
        double ret = 0;
        for (int i = 0; i <= T; i++) ret += dp[i][N][0];
        
        printf("%.10f\n", ret);
    }
    
    return (0);
}

Measured memory_bytes: 1432
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))


N, M = rli()
ans = 1
mod = 1000000007
if(abs(N-M)>=2):
    ans = 0
else:
    for i in range(1, N+1):
        ans = (ans*i) % mod
    for i in range(1, M+1):
        ans = (ans*i) % mod
    if(N == M):
        ans = (ans*2) % mod

print(ans)



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

ll n,a[100005],duplikat,i1,i2,fakt[100005];
unordered_set<ll> s;

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

ll power(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}

ll modInverse(ll a, ll m)
{
    return power(a, m-2, m);
}

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

    cin>>n;
    for(ll i=1;i<=n+1;i++)
    {
        cin>>a[i];
        if(s.count(a[i]))
        {
            duplikat=a[i];
            i2=i;
        }
        s.insert(a[i]);
    }
    for(ll i=1;i<=n;i++)
        if(a[i]==duplikat)
        {
            i1=i;
            break;
        }
    fakt[0]=1;
    for(ll i=1;i<100005;i++)
    {
        fakt[i]=fakt[i-1]*i;
        fakt[i]%=1000000007;
    }
    ll d=i2-i1;
    //cout<<i1<<" "<<i2<<endl;

    for(ll i=1;i<=n+1;i++)
    {
        //cout<<fakt[n+1]<<" "<<fakt[i]<<" "<<fakt[n+1-i]<<endl;
        ll r=(((fakt[n+1]*modInverse(fakt[i],1000000007))%1000000007)*modInverse(fakt[n+1-i],1000000007))%1000000007;
        if(n-d>=i-1)
            r-=(((fakt[n-d]*modInverse(fakt[i-1],1000000007)%1000000007))*modInverse(fakt[n-d-i+1],1000000007))%1000000007;
        r%=1000000007;
        if(r<0)
            r+=1000000007;
        cout<<r<<endl;
    }

    return 0;
}


Measured memory_bytes: 8876
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   int i,j,k,l,m;
   char ch[1000]={0},ch1[1000]={0},tmp;
   cin>>k;
   cin>>ch;
   l=strlen(ch);
   //ch[l-1],ch1[l-1];
   //cout<<l<<endl;
   if(l<=k){
       for(i=0;i<l;i++){
        cout<<ch[i];

       }

   }
   else{
    for(i=0;i<k;i++){
        ch1[i]=ch[i];
    }
    ch1[k]='.';
    ch1[k+1]='.';
    ch1[k+2]='.';
    //ch1[k+3]='\0';
   }
    cout<<ch1<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int main(){
    int n;
    string str;
    cin >> n;
    for(int i=0;i<n;++i){
        set<string> s;
        string str1,str2;

        cin >> str;
        for(int j=1;j<str.size();++j){
            str1 = "";
            str2 = "";
            for(int k=0;k<str.size();++k){
                if(k<j){
                    str1 += str[k];
                }else{
                    str2 += str[k];
                }
            }
            string rstr1, rstr2;
            rstr1 = str1;
            rstr2 = str2;
            reverse(rstr1.begin(), rstr1.end());
            reverse(rstr2.begin(), rstr2.end());
            s.insert(str1+str2);
            s.insert(str2+str1);
            s.insert(rstr1+str2);
            s.insert(str2+rstr1);
            s.insert(str1+rstr2);
            s.insert(rstr2+str1);
            s.insert(rstr1+rstr2);
            s.insert(rstr2+rstr1);
        }
        cout << s.size() << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
int n, a[123123][3], dp[123123][3];
 
int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) 
	for(int j = 0; j < 3; j++) cin >> a[i][j];

	dp[1][0] = a[1][0];
	dp[1][1] = a[1][1];
	dp[1][2] = a[1][2];

	for(int i = 2; i <= n; i++) 
	for(int j = 0; j < 3; j++) 
	for(int k = 0; k < 3; k++) {
	if(j == k) continue;

	dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);

	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := scanInt(), scanInt()
	A := make([]int, N+1)
	for i := 1; i <= N; i++ {
		A[i] = scanInt()
		A[i] = (A[i] + A[i-1]) % M
	}
	sort.Ints(A)

	ans, cnt := 0, 1
	for i := 1; i <= N; i++ {
		if A[i] == A[i-1] {
			cnt++
		} else {
			ans += ((cnt) * (cnt - 1)) / 2
			cnt = 1
		}
	}
	ans += ((cnt) * (cnt - 1)) / 2
	fmt.Println(ans)
}


Measured memory_bytes: 4112
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1,i;rrp(i,n-r+1,n+1)ans*=i;return ans/=fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll a,b,c,d;
 cin>>a>>b>>c>>d;
 ll memo=0;
  
 if(c*d==1){
  puts("0");return 0;
 }
 
 ans=b-a+1-(b/c+(-a+1)/c+b/d+(-a+1)/d-b/lcm(c,d)-(-a+1)/lcm(c,d));
 pr(ans);
return 0;}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int four = 0, two = 0, one = 0;
    REP(i, 0, N) {
        int a; cin >> a;
        if (a % 4 == 0) {
            four++;
        } else if (a % 2 == 0) {
            two++;
        } else {
            one++;
        }
    }
    
    if (two == 0) {
        if (one > four + 1) {
            cout << "No" << endl;
            return 0;
        }
    } else {
        if (one > four) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
from math import sqrt
N,M = map(int,input().split(" "))

div = []
l = int(sqrt(M))+1
ans = (1)
for j in range(1,l):
    if M % j == 0:
        if j * N <= M:
            ans = max(ans,j)
        if (M//j) * N <= M:
            ans = max(ans,(M//j))


print(ans)




Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define endl        '\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x)  for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define DEBUG       cerr<<"/n>>>I'm Here<<</n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  201
void solve()
{
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if (k>(a+b))
    {
        cout << ((a)-(k-(a+b))) << endl;
    }
    else if(k<a)
    {
        cout << k << endl;
    }
    else
    {
        cout << a << endl;
    }
    return;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("input.txt","r",stdin);
    #endif
    ll int TEST=1;
    //cin >> TEST;
    while(TEST--)
    {
        solve();
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef unsigned long long int ulli;
typedef long long int lli;

#define MAX(x, y) ((x) < (y) ? (y) : (x))

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

    int N;
    cin >> N;
    int *H = new int[N];

    for (int i = 0; i < N; ++i)
    {
        cin >> H[i];
    }

    int h = H[0];
    int ret = 1;

    for (int i = 1; i < N; ++i)
    {
        if (H[i] >= h)
        {
            ++ret;
            h = H[i];
        }
    }

    cout << ret << "\n";

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int N, M;
vector<vector<int>> G;
vector<int> color;
bool f(int p, int q, int c) {
	bool r = true;
	color[p] = c;
	for (int x : G[p]) if (x != q) {
		if (color[x] == 0) {
			if (!f(x, p, 3 - c)) r = false;
		} else {
			if (color[x] == color[p]) r = false;
		}
	}
	return r;
}
int main() {
	cin >> N >> M;
	G.resize(N);
	for (int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	long long x = 0, y = 0, z = 0;
	color.resize(N);
	for (int i = 0; i < N; ++i) {
		if (G[i].size() == 0) {
			++x;
		} else if (color[i] == 0) {
			if (f(i, -1, 1)) {
				++z;
			} else {
				++y;
			}
		}
	}
	long long r = 0;
	r += 2 * x * N - x * x;
	r += 2 * y * z + y * y;
	r += 2 * z * z;
	cout << r << endl;
}

// 連結な単純無向グラフAと連結な単純無向グラフBが与えられたとして
// 問題の規則によってC = A×Bを作り、その連結成分数を考える。
// 「Cで(a, b)と(a', b')が連結であること」と、「Aでaからa'に、Bでbからb'に同じ長さのパスが存在すること」は同値
// また、A,Bいずれも 頂点数 >= 2のとき、パスの長さは2伸ばすことができるので、「同じ長さのパスが存在する」は「偶奇が等しいパスが存在する」と言い換えられる
// - どちらかが頂点数 = 1のとき、連結成分の個数は |A| * |B| (*1)
// - 両方が頂点数 >= 2のとき
//   - どちらかが二部グラフでないとき : 連結成分の個数は 1 (*2)
//   - 両方が二部グラフであるとき : 連結成分の個数は 2 (*3)
// 各連結成分について上記を考える
// x = (頂点数 = 1)の数, y = (二部グラフでない)の数, z = (二部グラフである)の数
// (*1)の総和 = 2 * x * N - x * x
// (*2)の総和 = 2 * y * z + y * y
// (*3)の総和 = 2 * z * z


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

int main(){
    int n,m,l,i,j,k;
    int **A,**B;
    double **C;

    scanf("%d %d %d",&n,&m,&l);
    if(n<1||m<1||l<1 || 100<n||100<m||100<l)
    return -1;

    A=(int*)malloc(sizeof(int*)*n);
    for(i=0;i<n;i++)
        A[i]=(int*)malloc(sizeof(int)*m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++)
            A[i][j]=0;
    }


    B=(int*)malloc(sizeof(int*)*m);
    for(j=0;j<m;j++)
        B[j]=(int*)malloc(sizeof(int)*l);
    for(j=0;j<m;j++){
        for(k=0;k<l;k++)
            B[j][k]=0;
    }


    C=(double*)malloc(sizeof(double*)*n);
    for(i=0;i<n;i++)
        C[i]=(double*)malloc(sizeof(double)*l);
    for(i=0;i<n;i++){
        for(k=0;k<l;k++)
            C[i][k]=0;
    }


    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&A[i][j]);
            if(A[i][j]<0 ||10000<A[i][j]){
                return -1;
            }
        }
    }

    for(j=0;j<m;j++){
        for(k=0;k<l;k++){
            scanf("%d",&B[j][k]);
            if(B[j][k]<0 ||10000<B[j][k]){
                return -1;
            }
        }
    }


    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            for(k=0;k<l;k++)
                C[i][k]+=A[i][j]*B[j][k];
        }
    }

    for(i=0;i<n;i++){
        for(k=0;k<l;k++){
            printf("%.lf",C[i][k]);
            if(k!=l-1)printf(" ");
        }
        if(i!=n-1)printf("\n");
    }
    printf("\n");
    free(A);free(B);free(C);
 return 0;
}

Measured memory_bytes: 796
#include<bits/stdc++.h>
using namespace std;
const int mod = 924844033;
const int N = 2e5 + 11;
int f[N<<2], g[N<<2], fac[N], inv[N];
int n, sz[N], size, head[N], to[N<<1], nex[N<<1];
int lim, len = 1, rev[N<<2];
void add(int x, int y){
    to[++size] = y;
    nex[size] = head[x];
    head[x] = size;
}
int M(int x, int y){
    return x + y - (x + y >= mod ? mod : 0);
}
int C(int n, int m){
    if(n < m)return 0;
    return 1LL * fac[n] * inv[m] % mod * inv[n-m] % mod;
}
void get(){
    for(int i = 1;i < len; i++){
        rev[i] = (rev[i>>1] >> 1) | ((i & 1) << (lim - 1));
    }
}
int ksm(int base, int x){
    int ans = 1;
    while(x){
        if(x & 1)ans = 1LL * ans * base % mod;
        base = 1LL * base * base % mod;
        x >>= 1;
    }
    return ans;
}
void NTT(int *x, int fl){
    for(int i = 0;i < len; i++)if(rev[i] > i)swap(x[i], x[rev[i]]);
    for(int i = 1;i < len; i <<= 1){
        int g0 = ksm(5, (mod - 1) / (i << 1));
        if(fl == -1)g0 = ksm(g0, mod - 2);
        for(int j = 0;j < len; j += i << 1){
            for(int k = 0, gn = 1;k < i; k++){
                int x0 = x[j+k], x1 = 1LL * x[j+k+i] * gn % mod;
                x[j+k] = M(x0, x1);
                x[j+k+i] = M(x0, mod - x1);
                gn = 1LL * gn * g0 % mod;
            }
        }
    }
    if(fl == -1){
        int ni = ksm(len, mod - 2);
        for(int i = 0;i < len; i++)x[i] = 1LL * x[i] * ni % mod;
    }
}
void work(){
    while(len < 2 * n + 1)len <<= 1, lim++;
    get();
    //printf("len=%d lim=%d\n", len, lim);
    NTT(f, 1); NTT(g, 1);
    for(int i = 0;i < len; i++){
        f[i] = 1LL * f[i] * g[i] % mod;
    }
    NTT(f, -1);
    puts("");
    //for(int i = 0;i < len; i++)printf("i=%d f=%d\n", i, f[i]);
    for(int i = 1;i <= n; i++)f[i+n] = M(mod - 1LL * inv[i] * f[i+n] % mod , 1LL * n * C(n, i) % mod);
}
void dfs(int u, int fa){
    sz[u] = 1;
    //printf("u=%d fa=%d\n", u, fa);
    for(int i = head[u];i;i = nex[i]){
        int v = to[i];
        //printf("u=%d v=%d\n", u, v);
        if(v == fa)continue;
        dfs(v, u);
        sz[u] += sz[v];
    }
    if(u != fa)f[sz[u]]++, f[n-sz[u]]++;
    //printf("sz=%d n-sz=%d u=%d fa=%d\n", sz[u], n - sz[u], u, fa);
}
int main(){
    cin>>n;
    int u, v;
    for(int i = 1;i < n; i++){
        scanf("%d%d", &u, &v);
        add(v, u); add(u, v);
    }
    fac[0] = fac[1] = inv[1] = inv[0] = 1;
    for(int i = 2;i <= 2e5; i++){
        fac[i] = 1LL * fac[i-1] * i % mod;
        inv[i] = (mod - 1LL * mod / i * inv[mod%i] % mod) % mod;
    }
    g[0] = 1;
    for(int i = 1;i <= n; i++){
        inv[i] = 1LL * inv[i-1] * inv[i] % mod;
        g[i] = inv[i];
    }
    reverse(g, g + 1 + n);
    dfs(1, 1);
    for(int i = 0;i <= n; i++){
        f[i] = 1LL * f[i] * fac[i] % mod;
        //printf("i=%d f=%d g=%d\n", i, f[i], g[i]);
    }
    work();
    for(int i = 1;i <= n; i++)printf("%d\n", f[n+i]);
    return 0;
}



Measured memory_bytes: 24704
import javax.sound.midi.Soundbank;
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int l = s.nextInt();
        int r = s.nextInt();
        int d = s.nextInt();
        int c = 0;
        if(l%d==0)
            c++;
        if(r%d==0)
            c++;
        if(c==2)
            c--;
        c+=(r-l)/d;

        System.out.println(c);

    }
}


Measured memory_bytes: 35456
# -*- coding: utf-8 -*-
S = str(input())
K = int(input())

if len(set(S)) == 1:
    print(len(S) * K // 2)
else:
    before_s = ""
    dup_list = []
    dup_num = 0
#     文字列そのままの変換数
    for s in S:
        if s == before_s:
            dup_num += 1
            if dup_num == 1:
                dup_list.append(dup_num)
            else:
                dup_list[-1] = dup_num
        else:
            before_s = s
            dup_num = 0
    single_ans = 0
    for dnum in dup_list:
        single_ans += (dnum + 1) // 2
# 文字列2回重ねた変換数
    before_s = ""
    dup_list = []
    dup_num = 0
    for s in S * 2:
        if s == before_s:
            dup_num += 1
            if dup_num == 1:
                dup_list.append(dup_num)
            else:
                dup_list[-1] = dup_num
        else:
            before_s = s
            dup_num = 0
    double_ans = 0
    for dnum in dup_list:
        double_ans += (dnum + 1) // 2
    
    ans = single_ans * K + (double_ans - 2 * single_ans) * (K - 1)
    print(ans)

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

typedef long long ll;
using namespace std;

#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll n;	cin >> n;
	ll a[n];
	REP(i, n)	cin >> a[i];
	ll ans = 0;
	ll tmp = -1;

	REP(i, n){
		tmp = max(tmp, a[i]);
		if( tmp != a[i] ){
			ans += tmp - a[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		for (int i=1; i<=1000; i++){
			int tax8 = (int) (i * 0.08);
			int tax10 = (int) (i * 0.1);
			if (tax8 == A && tax10 == B){
				System.out.println(i);
				return;
			}
		}
		System.out.println("-1");
	}
}

Measured memory_bytes: 23764
//   ▄▄▄▄▄▄▄▄▄▄▄  ▄         ▄  ▄▄        ▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄         ▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄ 
//  ▐░░░░░░░░░░░▌▐░▌       ▐░▌▐░░▌      ▐░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌       ▐░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
//  ▐░█▀▀▀▀▀▀▀█░▌▐░▌       ▐░▌▐░▌░▌     ▐░▌ ▀▀▀▀█░█▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌       ▐░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌
//  ▐░▌       ▐░▌▐░▌       ▐░▌▐░▌▐░▌    ▐░▌     ▐░▌     ▐░▌          ▐░▌       ▐░▌▐░▌          ▐░▌       ▐░▌
//  ▐░█▄▄▄▄▄▄▄█░▌▐░▌       ▐░▌▐░▌ ▐░▌   ▐░▌     ▐░▌     ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌
//  ▐░░░░░░░░░░░▌▐░▌       ▐░▌▐░▌  ▐░▌  ▐░▌     ▐░▌     ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
//  ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌       ▐░▌▐░▌   ▐░▌ ▐░▌     ▐░▌      ▀▀▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀█░█▀▀ 
//  ▐░▌          ▐░▌       ▐░▌▐░▌    ▐░▌▐░▌     ▐░▌               ▐░▌▐░▌       ▐░▌▐░▌          ▐░▌     ▐░▌  
//  ▐░▌          ▐░█▄▄▄▄▄▄▄█░▌▐░▌     ▐░▐░▌ ▄▄▄▄█░█▄▄▄▄  ▄▄▄▄▄▄▄▄▄█░▌▐░▌       ▐░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▌      ▐░▌ 
//  ▐░▌          ▐░░░░░░░░░░░▌▐░▌      ▐░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌       ▐░▌▐░░░░░░░░░░░▌▐░▌       ▐░▌
//   ▀            ▀▀▀▀▀▀▀▀▀▀▀  ▀        ▀▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀         ▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀         ▀ 
//                                                                                                          
                                                                    
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define dep(i,a,b)    for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define inparr(a,n) rep(i,0,n)cin>>a[i];
#define strwspaces(s) getline(cin,s)
#define give(x,y) cout<<x<<" "<<y<<endl;
#define setp(n) cout<<fixed<<setprecision(n);
#define    endl '\n'
#define inp(n) int n;cin>>n;

using namespace std;

int i,j,k,l;

void solve()
{
    
    inp(n);
    if(n%1000!=0)
    cout<<1000-n%1000<<endl;
else
    cout<<0<<endl;
} 



signed main()
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	ll N, M;
	while(cin >> N >> M, N, M){
		vector<vector<int>> use(M);
		vector<int> cnt(M);
		int r;
		cin >> r;
		rep(i, r){
			int t, n, m, s;
			cin >> t >> n >> m >> s; m--;
			if(s == 0){//log out
				cnt[m]--;
				if(cnt[m] == 0) use[m].push_back(t);
				
			}else{//log in
				if(cnt[m] == 0) use[m].push_back(t);
				cnt[m]++;
			}
		}
		int q;
		cin >> q;
		rep(i, q){
			int ts, te, m;
			cin >> ts >> te >> m; m--;
			int ans = 0;
			for(int j = 0; j < use[m].size(); j += 2){
				if(ts <= use[m][j+1] && use[m][j] <= te) ans += (min(te, use[m][j+1]) -  max(ts, use[m][j]));
			}
			cout << ans << endl;
		}
		
	}
	
	
	return 0;
}


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

using namespace std;
using ll = int64_t;
using P = std::pair<int, int>;

// dp[carry][i] 

int dp[2][32];

int main() {
    string s;
    cin >> s;
    int ans = 0;
    reverse(s.begin(), s.end());

    for(int i = 0; i < s.size(); i++) {
        int up = s[i] - '0';

        for(int j = 0; j < up; j++) {
            dp[0][i+1] = max(dp[0][i+1], dp[1][i]+j);
        }

        dp[1][i+1] = max(dp[1][i+1], dp[1][i]+up);

        if(i != s.size() - 1) {
            for(int j = 0; j < 10; j++) {
                dp[0][i+1] = max(dp[0][i+1], dp[0][i]+j);
            }
        } else {
            for(int j = 0; j < up; j++) {
                dp[0][i+1] = max(dp[0][i+1], dp[0][i]+j);
            }
            dp[1][i+1] = max(dp[1][i+1], dp[1][i]+up);
        }

        ans = max(ans, dp[0][i+1]);
        ans = max(ans, dp[1][i+1]);
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
int a[35][35];
int h, w, k;
ll ans;
int pla[35][35];
char temp[35];

void perfall(void)
{
	int i, j;
	for(i=1 ; i<=w ; i++)
	{
		vector<int> non;
		for(j=1 ; j<=h ; j++)
		{
			if(pla[j][i]!=0)
			{
				non.push_back(pla[j][i]);
			}
		}
		for(j=1 ; j<=h ; j++)
		{
			if(j<=h-non.size())
			{
				pla[j][i]=0;
			}
			else
			{
				pla[j][i]=non[j-(h-non.size())-1];
			}
		}
	}
}

ll val(void)
{
	int i, cur;
	ll ret=0;
	for(i=1 ; i<=h ; i++)
	{
		for(cur=2 ; cur<=w ; cur++)
		{
			if(k==2)
			{
				if(pla[i][cur]==pla[i][cur-1] && pla[i][cur]!=0)
				{
					int vv=pla[i][cur];
					pla[i][cur-1]=0;
					ret+=vv;
					while(pla[i][cur]==vv && cur<=w)
					{
						pla[i][cur]=0;
						cur++;
						ret+=vv;
					}
				}
			}
			if(k==3)
			{
				if(cur>=3 && pla[i][cur-2]==pla[i][cur-1] && pla[i][cur]==pla[i][cur-1] && pla[i][cur]!=0)
				{
					int vv=pla[i][cur];
					pla[i][cur-2]=0;
					pla[i][cur-1]=0;
					ret+=2*vv;
					while(pla[i][cur]==vv && cur<=w)
					{
						pla[i][cur]=0;
						cur++;
						ret+=vv;
					}
				}
			}
		}
	}
	return ret;
}
ll call(int x, int y)
{
	ll ret=0;
	ll mul=1;
	int i, j;
	for(i=1 ; i<=h ; i++)
	{
		for(j=1 ; j<=w ; j++)
		{
			if(i!=x || j!=y)
			{
				pla[i][j]=a[i][j];
			}
			else
			{
				pla[i][j]=0;
			}
		}
	}

	bool cont=true;
	while(cont)
	{
		ll kil=0;
		
		perfall();
		
		kil=val();
		
		ret+=kil*mul;
		mul=mul*2;
		if(kil==0)
		{
			cont=false;
		}
	}

	return ret;
}

int main(void)
{
	cin>>h>>w>>k;
	int i, j;
	for(i=1 ; i<=h ; i++)
	{
		scanf("%s",&temp[1]);
		for(j=1 ; j<=w ; j++)
		{
			a[i][j]=temp[j]-'0';
		}
	}
	for(i=1 ; i<=h ; i++)
	{
		for(j=1 ; j<=w ; j++)
		{
			ans=max(ans,call(i,j));
		}
	}
	cout<<ans;
	cout<<endl;
}

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

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> v;
    for(int i = 0; i < k; i++){
        v.push_back(s);
    }
    int res = 1e9;
    if(res == s)    res--;
    for(int i = 0; i < n-k; i++){
        v.push_back(res);
    }
    for(int i = 0; i < n; i++){
        cout << v[i] << " \n"[i==n];
    }
    return 0;
}

Measured memory_bytes: 1784
#include <stdio.h>

int main(void) {
  int i, j, k, s[10000], t[10000], n, l1, l2, key, temp, count = 0;
  char buf[2];
  scanf("%d", &l1);
  for (n = 0; n < l1 && (j = scanf("%d%1[\n]", s+n, buf)) == 1; n++) ;
  if (j == 2)
  n++;
  scanf("%d", &l2);
  for (n = 0; n < l2 && (j = scanf("%d%1[\n]", t+n, buf)) == 1; n++) ;
  if (j == 2)
  n++;

  for (i = 0; i < l2; i++) {
    for (j = 0; j < l1; j++) {
      if (t[i] == s[j]) {
        count++;
        break;
      }
    }
  }

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



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

int n, a, b;
string s;

int main(void){
    cin >> n >> a >> b;
    cin >> s;
    int sum = 0;
    int rank = 1;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'a' && sum < a+b){
            cout << "Yes" << endl;
            sum++;
        }else if(s[i] == 'b' && sum < a+b && rank <= b){
            cout << "Yes" << endl;
            sum++;
            rank++;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  cin >> s;

  int kupc[4] = {0};
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'K')
      kupc[0]++;
    else if (s[i] == 'U')
      kupc[1]++;
    else if (s[i] == 'P')
      kupc[2]++;
    else if (s[i] == 'C')
      kupc[3]++;
  }
  sort(kupc + 0, kupc + 4);

  cout << kupc[0] << endl;
  return 0;
}

Measured memory_bytes: 1208
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int x = in.ni(), y = in.ni();
        int a = in.ni(), b = in.ni(), c = in.ni();
        int[] p = in.ni(a), q = in.ni(b), r = in.ni(c);
        Arrays.sort(p);
        Arrays.sort(q);
        PriorityQueue<Integer> que = new PriorityQueue<>();
        for (int i = 0; i < r.length; i++) {
            que.add(r[i]);
        }
        for (int i = 0; i < x; i++) {
            que.add(p[i]);
        }
        for (int i = 0; i < y; i++) {
            que.add(q[i]);
        }
        long ans = 0;
        for (int i = 0; i < x + y; i++) {
            ans -= que.poll();
        }
        out.println(ans);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = -ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 53600
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

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

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


void Main() {
  int N,Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> X;
  FOR(j, 0, N-1){
    if(S[j] =='A' && S[j+1]=='C') X.PB(j);
  }
  REP(i,Q){
    int b,e;
    cin >> b >> e;
    int cnt=0;
    auto x = lower_bound(ALL(X), b-1);
    auto x2 = lower_bound(ALL(X), e-1);
    OUT(x2 - x);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();

  return 0;
}

Measured memory_bytes: 1228
N, K = [int(i) for i in input().split()]
count = [0]*N

for _ in range(K):
  d = int(input())
  for v in input().split():
    j = int(v) - 1
    count[j] += 1
sunsuke = 0 
for i in count:
  if i == 0:
    sunsuke += 1
print(sunsuke)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;
#define MAXN   1000000000001
using namespace std;
int main()
{
   int n;
   cin>>n;
   int a[n],b[n];
   fr(i,0,n)
   cin>>a[i]>>b[i];
   sort(a,a+n);
   sort(b,b+n);
   int mn,mx;
   if(n%2)
   {
       mn=a[n/2];
       mx=b[n/2];
   }
   else
   {
       mn=a[n/2-1]+a[n/2];
       mx=b[n/2-1]+b[n/2];
   }
   cout<<mx-mn+1;
}

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

int main(){
  int N;
  cin >> N;
  int a[N]={};
  rep(i,N){
    rep(j,10){
      int t;
      cin >> t;
      a[i]+=(t<<j);
    }
  }
  
  int b[N][11];
  rep(i,N){
    rep(j,11){
      cin >> b[i][j];
    }
  }
  int ans=-(1<<30);
  for(int i=1;i<(1<<10);i++){
    int sum=0;
    rep(j,N){
      int c=0;
      int d=a[j]&i;
      while(d){
        c+=d&1;
        d=d>>1;
      }
      sum+=b[j][c];
    }
    ans=max(ans,sum);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(a!=c)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 1e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
void GG()
{
    cout<<-1<<endl;
    exit(0);
}
int n,sz[maxn];
ll dis[maxn];
struct node
{
    int id;
    ll d;
    bool operator < (const node e) const {
        return d>e.d;
    }
}tr[maxn];
vector<pii_> e;
vector<int> g[maxn];
void dfs(int u)
{
    for(int v:g[u]){
        dfs(v);
        dis[u] += dis[v]+sz[v];
    }
}
void dfs2(int u){
    for(int v:g[u]){
        dis[v] = dis[u]+n-2*sz[v];
        dfs2(v);
    }
}
int main()
{
    fastio();
    cin>>n;
    rep(i,1,n){
        cin>>tr[i].d; tr[i].id = i;
    }
    sort(tr+1,tr+n+1);
    rep(i,1,n) sz[i] = 1;
    rep(i,1,n-1){
        ll dfa = tr[i].d+2*sz[tr[i].id]-n;
        int pos = lower_bound(tr+1,tr+n+1,(node){0,dfa})-tr;
        if(pos<1 || pos>n) GG(); // 找不到父节点
        node fa = tr[pos];
        if(fa.d!=dfa || fa.id==tr[i].id) GG();    // 找不到父节点
        sz[fa.id] += sz[tr[i].id];
        if(fa.id!=tr[n].id && sz[fa.id]>n/2) GG();   // 以重心为根，其他节点的子树大小不能超过n的一半
        e.pb(mp_(tr[i].id,fa.id));
        g[fa.id].pb(tr[i].id);
    }
    if(e.size()!=n-1) GG();
    dfs(tr[n].id);
    dfs2(tr[n].id);
    rep(i,1,n){
        if(tr[i].d != dis[tr[i].id]) GG();
    }
    for(auto x:e){
        cout<<x.fi<<" "<<x.se<<endl;
    }
    return 0;
}


Measured memory_bytes: 12788
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<climits>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<stack>
#include<functional>
#include<queue>
using namespace std;

const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};
int H,W;
char fld[100][100];

void dfs(int y,int x,char kind){
    int ny,nx;
    for(int i=0;i<4;i++){
        ny = y+dy[i]; nx = x+dx[i];
        if(ny<0 || H<=ny || nx<0 || W<=nx || fld[ny][nx]!=kind) continue;
        fld[ny][nx] = 0; dfs(ny,nx,kind);
    }
}

int main(){
    while(cin>>H>>W,H||W){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                scanf(" %c",&fld[i][j]);
            }
        }
        int ans = 0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(fld[i][j]==0) continue;
                ans++; dfs(i,j,fld[i][j]);
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1648