akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    long a,b,k;
    cin>>a>>b>>k;
    for(int i=1; i<=k; ++i){
        if(i%2==1){
            a/=2;
            b+=a;
        }
        else{
            b/=2;
            a+=b;
        }
    }
    cout<<a<<" "<<b<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;
using ll = long long;
typedef pair<int, int> Pair;

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

ll cnt = 1;

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

  ll g = gcd(A, B);
  ll dv = 2;

  while (g > 1) {
    if (g % dv == 0) {
      while (g % dv == 0) {
        g /= dv;
      }
      cnt++;
    }
    dv++;
    if (dv > 1000000) break;
  }

  if (g > 1) cnt++;
  cout << cnt << endl;
  return 0;
}

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;
using P = pair<int, int>;

int main() {
    int a, b, cnt = 0;
  	cin >> a >> b;
  	for(int i = a; i <= b; i++){
    	int s = i % 10;
      	int t = (i / 10000) % 10;
      	int u = (i / 10) % 10;
      	int v = (i / 1000) % 10;
      	if(s == t && u == v) cnt++;
    }
  	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100010;
int a[maxn],n;
int gcd(int a,int b){return (b==0)?a:gcd(b,a%b);}
bool pd(){
	 ll sum=0;
	 int ex=0,tot=0;
	 for(int i=1;i<=n;++i){
			 sum+=a[i]-1;
			 if(a[i]&1)tot++;
			 if(a[i]==1)ex=1;
	 }
	 if(ex)return sum%2;
	 if((n-tot)%2)return 1;
	 if(tot==1){
				int g=0;
				for(int i=1;i<=n;++i)if(a[i]&1)a[i]--;
				for(int i=1;i<=n;++i)g=gcd(g,a[i]);
				for(int i=1;i<=n;++i)a[i]/=g;
				return pd()^1;
	 }
	 return 0;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
			scanf("%d",&a[i]);
	}
	if (pd()) printf("First");
 	else printf("Second");
 	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    set<int>s;
    s.insert(1);
    s.insert(2);
    s.insert(3);
    s.erase(a);
    s.erase(b);
    cout<<*s.begin()<<endl;
    return 0;

}


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

vector<ll> v;

void primefactorize(ll x){
    ll tmp = x;
    ll i = 2;
    while(i*i<=x){
        if(tmp%i==0){
            v.emplace_back(i);
            tmp /= i;
        }
        else{
            i++;
        }
    }
    if(tmp!=1) v.emplace_back(tmp);
}

void solve(){

    int n;
    cin >> n;
    primefactorize(n);
    cout << n << ": ";
    rep(i,v.size()){
        if(i!=v.size()-1){
            cout << v[i] << " ";
        }
        else{
            cout << v[i];
        }
    }
    cout << endl;
}


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



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

bool ans = true;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = -10000; i < (int)(n) && ans ; i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll x ;
  cin >> x ;
  intll ans1 = 0;
  intll ans2 = 0;
  rep(a,100000){
    rep(b,10000){
      intll k = (a-b)*(a*a*a*(a+b) + b*b*b*(a+b) +a*a*b*b);
      if( k == x ){
        ans1 = a ;
        ans2 = b;
        ans = false ;
        
      }
    }
  }
  
  ans = true ;
  
 rep(i,100){
   if( x == i*i*i*i*i){
     ans1 = i ;
     ans2 = 0;
   }
 }
  
  
  cout << ans1 << " " << ans2 ;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<cmath>
#include<map>
using namespace std;
int main(){
	map<char , string> change;
	change[' ']  = "101";
	change['\''] = "000000";
	change[',']  = "000011";
	change['-']  = "10010001";
	change['.']  = "010001";
	change['?']  = "000001";
	change['A']  = "100101";
	change['B']  = "10011010";
	change['C']  = "0101";
	change['D']  = "0001";
	change['E']  = "110";
	change['F']  = "01001";
	change['G']  = "10011011";
	change['H']  = "010000";
	change['I']  = "0111";
	change['J']  = "10011000";
	change['K']  = "0110";
	change['L']  = "00100";
	change['M']  = "10011001";
	change['N']  = "10011110";
	change['O']  = "00101";
	change['P']  = "111";
	change['Q']  = "10011111";
	change['R']  = "1000";
	change['S']  = "00110";
	change['T']  = "00111";
	change['U']  = "10011100";
	change['V']  = "10011101";
	change['W']  = "000010";
	change['X']  = "10010010";
	change['Y']  = "10010011";
	change['Z']  = "10010000";
	
	string str;
	while(getline(cin , str)){
		string sum;
		for(int i = 0; i < str.size(); i++){
			sum += change[str[i]];
		}
		int s = sum.size()%5;
		if(s != 0){
			for(int i = 0; i < 5-s; i++)sum += '0';
		}
		string ans;
		string change2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
		for(int i = 0; i < sum.size(); i+=5){
			int x=0;
			for(int j = i+1; j <= i+5; j++){
				if(sum[j-1] == 49){
					x += (j%5==0) ? 1 : pow(2.0,5-(j%5));
				}
			}
			ans += change2[x];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct P{
    int l, r;
    P(int l, int r) : l(l), r(r){}
};

bool cmpl(const P &a, const P &b){
    if(a.l != b.l) return a.l < b.l;
    return a.r < b.r;
}
bool cmpr(const P &a, const P &b){
    if(a.r != b.r) return a.r < b.r;
    return a.l < b.l;
}

int main(void){
    int n;
    vector<P> p;
    int ans = 0;
    vector<int> v[4];
    cin >> n;
    for(int i=0;i<n;i++){
        int l, r;
        cin >> l >> r;
        p.push_back(P(l, r));
        ans = max(ans, r-l+1);
    }
    sort(p.begin(), p.end(), cmpl);
    for(int i=0;i<4;i++){
        v[i].assign(n, 0);
    }
    v[0][0] = p[0].l;
    v[1][0] = p[0].r;
    for(int i=1;i<n;i++){
        v[0][i] = max(v[0][i-1], p[i].l);
        v[1][i] = min(v[1][i-1], p[i].r);
    }
    v[2][n-1] = p[n-1].l;
    v[3][n-1] = p[n-1].r;
    for(int i=n-2;i>=0;i--){
        v[2][i] = max(v[2][i+1], p[i].l);
        v[3][i] = min(v[3][i+1], p[i].r);
    }
    for(int i=0;i<n-1;i++){
        int res = 0;
        if(v[0][i] <= v[1][i]) res += v[1][i] - v[0][i] + 1;
        if(v[2][i+1] <= v[3][i+1]) res += v[3][i+1] - v[2][i+1] + 1;
        ans = max(ans, res);
        //cout << i << " : " << res << endl;
        //cout << v[0][i] << " " << v[1][i] << " " << v[2][i] << " " << v[3][i] << endl;
    }

    sort(p.begin(), p.end(), cmpr);
    for(int i=0;i<4;i++){
        v[i].assign(n, 0);
    }
    v[0][0] = p[0].l;
    v[1][0] = p[0].r;
    for(int i=1;i<n;i++){
        v[0][i] = max(v[0][i-1], p[i].l);
        v[1][i] = min(v[1][i-1], p[i].r);
    }
    v[2][n-1] = p[n-1].l;
    v[3][n-1] = p[n-1].r;
    for(int i=n-2;i>=0;i--){
        v[2][i] = max(v[2][i+1], p[i].l);
        v[3][i] = min(v[3][i+1], p[i].r);
    }
    for(int i=0;i<n-1;i++){
        int res = 0;
        if(v[0][i] <= v[1][i]) res += v[1][i] - v[0][i] + 1;
        if(v[2][i+1] <= v[3][i+1]) res += v[3][i+1] - v[2][i+1] + 1;
        ans = max(ans, res);
        //cout << i << " : " << res << endl;
        //cout << v[0][i] << " " << v[1][i] << " " << v[2][i] << " " << v[3][i] << endl;
    }



    for(int i=1;i<n-1;i++){
        int res = p[i].r - p[i].l + 1;
        int lx = max(v[0][i-1], v[2][i+1]);
        int rn = min(v[1][i-1], v[3][i+1]);
        if(lx <= rn) res += rn - lx + 1;
        ans = max(ans, res);
    }


    cout << ans << endl;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define repr(i,a,n) for (int i=a;i<n;i++)
#define rrep(i,a,n) for (int i=n-1;i>=a;i--)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define fi first
#define se second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;

void solve() {
	string s;
	cin >> s;
	rep(i, 3) {
		if (s[i] == '7') {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

signed main()
{
	int tc;
	tc = 1;
	//	cin >> tc;
	while (tc--) {
		solve();
	}


}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int po[100002],mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n,l,r;
    cin>>n>>l>>r;
    bool ok=false;
    for(int i=l;i<=r;i++)if(i%n==0)ok=true;
   if(ok)cout<<"OK"<<endl;
   else cout<<"NG"<<endl;
}


Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split(" ")))

res = 0
asum = [0]
axor = [0]

for i in A:
    asum.append(asum[-1] + i)
    axor.append(axor[-1] ^ i)

for l in range(N):
    ok = l+1
    ng = N+1
    while(ng - ok > 1):
        r = (ok + ng) // 2
        s = (axor[r] ^ axor[l])
        t = (asum[r] - asum[l])
        if s == t:
            ok = r
        else:
            ng = r
    
    res += ok - l
         
print(res)

Measured memory_bytes: 99420
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())

    if N == 1 and M == 0:
        print(0)
        exit()

    ans = [None]*N
    for i in range(M):
        s, c = map(int, readline().split())
        if ans[s-1] is None:
            ans[s-1] = c
        elif c == ans[s-1]:
            continue        
        else:
            print(-1)
            exit()
    
    if ans[0] is None:
        ans[0] = 1
    
    for i in range(1,N):
        if ans[i] is None:
            ans[i] = 0

    if N >= 2 and ans[0] == 0:
        print(-1)
        exit()

    print("".join(map(str,ans)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int get(int n){
    if(n%2==0)return n/2;
    else return 3*n+1;
}
int main(){
    long long n,x;
    cin>>n>>x;
    long long arr[n],sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum=sum+arr[i];
    }
    ll temp=x;
    sort(arr,arr+n);
    int i=0;
    while(i<n&&x>0){
        if(arr[i]<=x){
            x=x-arr[i];
        }
        else break;
        i++;
    }
    if(sum==temp)cout<<n;
    else if(sum<temp)cout<<n-1;
    else
    cout<<i;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){
   
   string s;
   cin >> s;
 
   if(s == "SUN") cout << "7";
   else if(s == "SAT") cout << "1";
   else if(s == "FRI") cout << "2";
   else if(s == "THU") cout << "3";
   else if(s == "WED") cout << "4";
   else if(s == "TUE") cout << "5";
   else if(s == "MON") cout << "6";
 
    return 0;
}

Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 200005;
ll f[maxn << 2], fa[maxn << 2], fb[maxn << 2], tag;

void modify(int now, int L, int R, int p, ll x) {
	f[now] = std::min(f[now], x);
	fa[now] = std::min(fa[now], x + p);
	fb[now] = std::min(fb[now], x - p);
	if(L == R) return;
	int M = (L + R) >> 1;
	if(p <= M) modify(now << 1, L, M, p, x);
	else modify(now << 1 | 1, M + 1, R, p, x);
}

void build(int now, int L, int R) {
	f[now] = fa[now] = fb[now] = 1000000000000000000;
	if(L == R) return;
	int M = (L + R) >> 1;
	build(now << 1, L, M);
	build(now << 1 | 1, M + 1, R);
}

ll query(int now, int L, int R, int p) {
	if(R < p) return p + fb[now];
	if(L > p) return fa[now] - p;
	if(L == R) return f[now];
	int M = (L + R) >> 1;
	return std::min(query(now << 1, L, M, p), query(now << 1 | 1, M + 1, R, p));
}

void test(int now, int L, int R) {
	/* debug("%d-%d : %lld (+)%lld (-)%lld\n", */
	/* 		L, R, f[now] + tag, fa[now] + tag, fb[now] + tag); */
	if(L == R) {
		/* if(f[now] >= 1000000000) */
		/* 	debug(" inf"); */
		/* else */
		/* 	debug(" %lld", f[now] + tag); */
		return;
	}
	int M = (L + R) >> 1;
	test(now << 1, L, M);
	test(now << 1 | 1, M + 1, R);
}

int main() {
	int n = read, q = read, a = read, b = read;

	build(1, 1, n);
	modify(1, 1, n, a, 0);
	/* modify(1, 1, n, b, 0); */

	int last = b;
	while(q --) {
		int x = read;
		ll qu = query(1, 1, n, x) + tag;
		/* debug("qu = %lld\n", qu); */
		tag += std::abs(x - last);
		modify(1, 1, n, last, qu - tag);
		last = x;
		/* debug("tag=%lld\n", tag); */
		/* test(1, 1, n); debug("\n"); */
	}

	printf("%lld\n", f[1] + tag);
}


Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
    int main(){
        string s;
        cin >> s;
        string t;
        int x = s.size();
        for(int i = 1; i <= x; i++){
            if(i % 2 != 0){
                t += s.at(i - 1);
            }
        }
        cout << t;
    }


Measured memory_bytes: 512
N,M = list(map(int,input().split()))

ship={}
for n in range(N):
    n=n+1
    ship[n]=[]

for m in range(M):
    a,b=list(map(int,input().split()))
    if a == 1:
        ship[a].append(b)
    else :
        if b == N:
            ship[a].append(b)

ans='IMPOSSIBLE'
for i in ship[1]:
    if len(ship[i]) != 0:
        ans='POSSIBLE'
        break
print(ans)

Measured memory_bytes: 110376
#include<stdio.h>

int main(){
  int i,j,n,k,c,b;

  int a[124][124]={{}};

  scanf("%d",&n);
  for(i=0;i<n;i++){

    scanf("%d %d",&c,&b);
    for(j=0;j<b;j++){
      scanf("%d",&k);
      a[c-1][k-1]=1;

    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0){
	printf(" ");
      }
       printf("%d",a[i][j]);
    
    }
    
    puts("");
 
}
  return 0;
}

Measured memory_bytes: 2744
//aea ctmr
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//v.erase(unique(v.begin(),v.end()),v.end());
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) ll((a).size())
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
 
 
typedef long double ld;
typedef long long ll;
const ll N = 100500;
const ll mod = 1e+9 + 9;
const ld PI = acos(-1);
const ll INF = 1e+18;
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif

vector <ll> ro, ge, inc;
vector <pair <ll, ll>> uwu;
ll r_ac[N];
ll g_ac[N];
ll inc_ac[N];

void solve(){
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    
    for(ll i = 0; i < a; i++){
        ll u; cin >> u;
        ro.push_back(u);
        uwu.push_back({u, 1});
    }
    for(ll i = 0; i < b; i++){
        ll u; cin >> u;
        ge.push_back(u);
        uwu.push_back({u, 2});
    }
    for(ll i = 0; i < c; i++){
        ll u; cin >> u;
        inc.push_back(u);
    }
    sort(ro.rbegin(), ro.rend()); sort(ge.rbegin(), ge.rend()); sort(inc.rbegin(), inc.rend());
    sort(uwu.rbegin(), uwu.rend());
    for(ll i = 1; i <= a; i++) r_ac[i] = r_ac[i - 1] + ro[i - 1];
    for(ll i = 1; i <= b; i++) g_ac[i] = g_ac[i - 1] + ge[i - 1];
    for(ll i = 1; i <= c; i++) inc_ac[i] = inc_ac[i - 1] + inc[i - 1];
    ll r = 0, g = 0;
    ll ans = 0;
    if(x + y <= c) ans = max(ans, inc_ac[x + y]); 
    for(ll i = 1; i <= a + b; i++){
        //esto ocurre si hay i weadas comidas        
        if(uwu[i - 1].ss == 1) r++;
        else g++;
        
        ll g_tom = min(g, y);
        ll r_tom = min(r, x);
        ll un_tom = x - g_tom + y - r_tom;
        if(un_tom <= c and un_tom >= 0){
            ans = max(ans, r_ac[r_tom] + g_ac[g_tom] + inc_ac[un_tom]);
        }
    }
    
    cout << ans << endl;
}

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

Measured memory_bytes: 9956
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
char s[MAXN];
int a[MAXN];
int N;
int cnt[MAXN];

void work(){
    scanf("%s",s+1);
    N=strlen(s+1);
    int tmp=1;
    for(int i=N;i>=1;i--){
        a[i]=((s[i]-'0')*tmp+a[i+1])%2019;
        tmp=tmp*10%2019;
    }
    LL ans=0;
//    for(int i=1;i<=N;i++) printf("%d ",a[i]);
//    printf("\n");
    for(int i=1;i<=N+1;i++){
        ans+=cnt[a[i]];
        cnt[a[i]]++;
    }
    printf("%lld\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}










Measured memory_bytes: 4740
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    long long x = n / k;
    long long ans = x * x * x;
    if(k % 2 == 0){
        long long y = (n + k / 2) / k;
        ans += y * y * y;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
        	int[] a = new int[8];
        	int b = 0;
        	int c = 0;
        	for(int i = 0; i < a.length; i++)
        		a[i] = sc.nextInt();
        	
        	for(int i = 0; i < a.length/2; i++){
        		for(int u = 0; u < a.length/2; u++){
        			if(a[i] == a[u+4] && i == u)
        				b++;
        			else if(a[i] == a[u+4])
        				c++;
        		}
        	}
        	System.out.println(b + " " + c);
        }
    }
}

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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 2010;
int a[N], d[N], e[N][N], n;
bool vis[N];
vector<int> vec[N];
void dfs(int u) {
	vis[u] = 1;
	for (int i = 1; i <= n; i++)
		if (e[u][i] && !vis[i]) {
			d[i]++; vec[u].push_back(i); dfs(i);
		}
}
struct cmp {
	bool operator () (int x, int y) const {
		return a[x] < a[y];
	}
};
priority_queue<int, vector<int>, cmp> q;
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi<int>();
	for (int i = 1; i <= n; i++) a[i] = gi<int>();
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if (__gcd(a[i], a[j]) > 1)
				e[i][j] = e[j][i] = 1;
	for (int i = 1; i <= n; i++)
		if (!vis[i]) dfs(i);
	for (int i = 1; i <= n; i++)
		if (!d[i]) q.push(i);
	while (!q.empty()) {
		int u = q.top(); q.pop();
		printf("%d ", a[u]);
		for (int i = 0; i < (int) vec[u].size(); i++)
			q.push(vec[u][i]);
	}
	return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

const int INF = 1 << 30;

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

    vector<int> A(W);
    for (auto& a : A) cin >> a;

    vector<int> L(W);
    // 時刻L[i]未満に来た人は左に行くと助かる
    L[0] = (A[0] == 0 ? INF : -INF);
    for (int i = 1; i < W; ++i) {
        L[i] = L[i - 1] - 1;
        if (A[i] < 0) {
            L[i] = min(L[i], -A[i]);
        } else if (A[i] == 0) {
            L[i] = INF;
        }
    }

    vector<int> R(W);
    R[W - 1] = (A[W - 1] == 0 ? INF : -INF);
    for (int i = W - 2; i >= 0; --i) {
        R[i] = R[i + 1] - 1;
        if (A[i] < 0) {
            R[i] = min(R[i], -A[i]);
        } else if (A[i] == 0) {
            R[i] = INF;
        }
    }

    int ans = 0;
    for (int i = 0; i < W; ++i) {
        if (A[i] <= 0) continue;
        ans += max(0, min(A[i], max(L[i], R[i])));
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    int arr[s.size()+1][t.size()+1];
    int par[s.size()+1][t.size()+1][2];
    for (int i = 0; i < t.size()+1; ++i)
    {
        arr[0][i]=0;
    }
    for (int i = 0; i < s.size()+1; ++i)
    {
        arr[i][0]=0;
    }
    for (int i = 1; i <= s.size(); ++i)
    {
        for (int j = 1; j <= t.size(); ++j)
        {
            arr[i][j]=0;
            int m=0;
            if (arr[i-1][j]>m)
            {
                m=arr[i-1][j];
                par[i][j][0]=i-1;
                par[i][j][1]=j; 
            }
            if (arr[i][j-1]>m)
            {
                m=arr[i][j-1];
                par[i][j][0]=i;
                par[i][j][1]=j-1;
            }
            if (arr[i-1][j-1]+1>m && s[i-1]==t[j-1])
            {
                m=arr[i-1][j-1]+1;
                par[i][j][0]=i-1;
                par[i][j][1]=j-1;
            }
            arr[i][j]=m;
        }

    }
    //  for (int i = 0; i <= s.size(); ++i)
    // {
    //     for (int j = 0; j <= t.size(); ++j)
    //     {
    //         cout << arr[i][j];
    //     }
    //     cout << "\n";
    // }

    int x=par[s.size()][t.size()][0];
    int y=par[s.size()][t.size()][1];
    deque<char> q;
    if (arr[s.size()][t.size()]==0)
    {
        cout <<" ";
        return 0;
    }
    if (x==s.size()-1&&y==t.size()-1)
    {
        q.push_front(s[s.size()-1]);
        // cout << s[s.size()-1];
    }
    while(x!=0&& y!=0)
    {
        int tempx=x, tempy=y;
        x=par[tempx][tempy][0];
        y=par[tempx][tempy][1];
        if (tempx==x+1&&tempy==y+1)
        {
            q.push_front(s[x]);
            // cout << s[x];
        }
    }
    for(auto i : q)
    {
        cout << i;
    }
    return 0;
}

Measured memory_bytes: 105856
#include<iostream>
#include<cmath>
#include<set>
using namespace std;
set<int> s;
int main()
{
	int n,x,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		if(s.find(x)!=s.end())
		   s.erase(x);
		else
		  s.insert(x);
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>


using namespace std;

int main() {
  string s,t;
  cin >> t >> s;
  vector<vector<long>> tc(26);

  long n = t.size();
  for (long i=0; i<n; i++) {
    // cout << t[i] << " " << t[i] - 'a' << endl;
    tc[t[i]-'a'].push_back(i);
  }

  n = s.size();
  long cnt = 0;
  long m = -1;
  vector<vector<long>> ntc = tc;
  for (long i=0; i<n; i++) {

    if( tc[s[i]-'a'].size() <= 0 ) {
      cout << -1 << endl;
      return 0;
    }
    bool flag = false;
    int ind = s[i]-'a';
    auto it = upper_bound(tc[ind].begin(), tc[ind].end(), m);
    if (it != tc[ind].end() ){
      flag = true;
      m = *it;
    }

    if (!flag) {
      cnt++;
      m = tc[s[i]-'a'][0];
    }
  }
    
  // cout << cnt << " " << m << endl;
  cout << (long long)t.size()*cnt + m + 1 << endl;

}

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

    class Program
    {
        static void Main(string[] args)
        {
            string[] strInputArray = Console.ReadLine().Split(' ');
            int[] inputArray = Array.ConvertAll<string, int>(strInputArray, delegate(string value) { return int.Parse(value); });
            int cnt = 0;
            for (int i = inputArray[0]; i <= inputArray[1]; i++)
            {
                if (inputArray[2] % i == 0)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
            Console.ReadLine();
        }
    }


Measured memory_bytes: 16000
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll X, A;
    cin >> X >> A;
    if(X>=A){
        cout << 10 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, K;
  cin >> N >> K;
  vector<double> P(N + 1, 0.0);
  vector<double> S(N + 1, 0.0);
  REP(i, 1, N + 1) {
    ll p;
    cin >> p;
    P[i] = (1.0 + p) / 2.0;
    S[i] = S[i - 1] + P[i];
  }

  double ans = 0.0;
  for (ll i = 0; i + K <= N; i++) {
    ans = max(ans, S[i + K] - S[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>
#define NUMBER 100
int main(void)
{
    int n;
    int a[NUMBER];
    int i;
    int c = 0;
    
    scanf("%d",&n);
    for (i = 0;i < n;i++)
        scanf("%d",&a[i]);
    
    for (i = 0;i < n;i++){
        if (a[i]%2 == 0 && a[i]%3 != 0 && a[i]%5 != 0){
            c = 1;
            break;
        }
    }
    if (c == 1)
        printf("DENIED\n");
    else
        printf("APPROVED\n");
    return 0;
}


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

int main()
{
    int D;
    cin >> D;
    if (D == 22)
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    else if (D == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    else if (D == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    else if (D == 25)
    {
        cout << "Christmas" << endl;
    }

    return 0;
}

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

namespace ABC140A
{
	class Program
	{
		static void Main(string[] args)
		{
			int N;
			N = int.Parse(Console.ReadLine());

            Console.WriteLine(N * N * N);

            Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++)cin>>s[i];
  int a=0;
  int w=0;
  int t=0;
  int r=0;
  for(int i=0;i<n;i++){
    if(s[i]=="AC")a++;
    else if(s[i]=="WA")w++;
    else if(s[i]=="TLE")t++;
    else if(s[i]=="RE")r++;
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<w<<endl;
  cout<<"TLE x "<<t<<endl;
  cout<<"RE x "<<r<<endl;
}
    


  

Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

//----------------------------------------------------------------

int main()
{
    int n;
    int cnt = 0;
    cin >> n;
    vector<long long> ruiseki(n + 1);
    int a;
    map<long long, long long> b;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        ruiseki[i + 1] = ruiseki[i] + a;
    }
    for (int i = 0; i < n + 1; i++)
    {
        b[ruiseki[i]]++;
    }
    long long ans = 0;
    for (auto i : b)
    {
        long long cnt = i.second;
        ans += cnt * (cnt - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <ctime>
#include <cmath>
#include <cassert>
#include <limits>
#include <functional>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(int)(n);++(i))

int main() {
    stack<int> s;
    int n;
    while (cin >> n) {
        if (n)
            s.push(n);
        else {
            cout << s.top() << endl;
            s.pop();
        }
    }
}

Measured memory_bytes: 3088
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
    def find(self, x):
        """
        x が属するグループを探索して親を出す。
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)
    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

N,M,K = map(int,input().split())
uf = UnionFind(N)
f_num = [0 for _ in range(N)] #友達の人数
for i in range(M):
  a,b = map(int,input().split())
  a-=1;b-=1
  uf.union(a,b)
  f_num[a] += 1; f_num[b] += 1
ans = [-1 for _ in range(N)]
for i in range(N):
  temp = uf.get_size(i) - (1+f_num[i])
  ans[i] = temp
for i in range(K):  
  c,d = map(int,input().split())
  c-=1;d-=1
  if uf.is_same(c,d): #嫌いな人が同じグループなら引く。
    ans[c] -= 1
    ans[d] -= 1
print(*ans,sep="\n")
  
  

Measured memory_bytes: 97276
#include <stdio.h>

int main(void) {
  int i, n;
  scanf("%d", &n);
  int a[n];
  for(i = 0; i < n; ++i) scanf("%d", &a[i]);
  for(i = n - 1; i >= 0; --i) {
    if(i) printf("%d ", a[i]);
    else printf("%d\n", a[i]);
  }
  return 0;
}


Measured memory_bytes: 2752
#include <iostream>
#include <vector>
#define INF 0x3f3f3f3f

using namespace std;
typedef pair<int, int> pii;
int main() {
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (int i = 0; i < 3 * n; ++i)
    cin >> a[i];
  vector<vector<int>> f(n + 1, vector<int>(n + 1, -INF));
  vector<int> local_opt(n + 1, -INF);
  f[a[0]][a[1]] = f[a[1]][a[0]] = 0;
  local_opt[a[0]] = 0, local_opt[a[1]] = 0;
  vector<pair<pii, int>> updates;
  int triplets = 0, opt = 0;
  for (int i = 2; i < 3 * (n - 1); i += 3) {
    vector<int> b(3);
    for (int j = 0; j < 3; ++j)
      b[j] = a[i + j];
    if (b[0] == b[1] && b[0] == b[2]) {
      triplets++;
      continue;
    }
    updates.clear();
    for (int p = 0; p <= 2; ++p) {
      int q = (p + 1) % 3, s = (p + 2) % 3;
      updates.push_back({{b[p], b[q]}, opt});
      updates.push_back({{b[p], b[q]}, f[b[s]][b[s]] + 1});
      for (int x = 1; x <= n; ++x) {
        updates.push_back({{b[p], x}, local_opt[x]});
        if (b[q] == b[s])
          updates.push_back({{b[p], x}, f[x][b[q]] + 1});
      }
    }
    for (const auto &u : updates) {
      int x = u.first.first, y = u.first.second, val = u.second;
      if (f[x][y] < val) {
        f[x][y] = f[y][x] = val;
        opt = max(opt, val);
        local_opt[x] = max(local_opt[x], val);
        local_opt[y] = max(local_opt[y], val);
      }
    }
  }
  opt = triplets + max(opt, f[a.back()][a.back()] + 1);
  printf("%d", opt);
}

Measured memory_bytes: 19136
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(m,n,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
d = []
n.times do
  d.push(inps[0])
end
u = 0
a = 0
q = 0
del = []
t = inps[0]
t.size.times do |i|
  d.each.with_index do |s,j|
    if(s[i] == nil)
      a+=1
      del.push(j)
    elsif(s[i] == "?")
      if(t[i] == "a" or t[i] == "z")
        
      else
        del.push(j)
      end
    elsif(s[i] > t[i])
      u+=1
      del.push(j)
    elsif(s[i] < t[i])
      a+=1
      del.push(j)
      
    end
  end
  del.size.times do
    d.delete_at(del.pop)
  end
end
d.each do |s|
  if(s.size > t.size)
    u+=1
  end
end
((a+1)..(n-u)).each do |dd|
  print "#{dd} "
end
puts n+1-u


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

int graph[10][10];

int a = 0, x = 1, y = 2, z = 3, w = 4, b = 5;

int main(){
	memset(graph, -1, sizeof(graph));
	graph[a][0] = x;
	graph[a][1] = y;
	graph[x][1] = z;
	graph[y][0] = x;
	graph[z][0] = w;
	graph[z][1] = b;
	graph[w][0] = b;
	graph[w][1] = y;
	graph[b][0] = y;
	graph[b][1] = x;
	
	string p;
	while(cin >> p, p != "#"){
		bool f = true;
		int now = a;
		for(int i = 0;i < p.size();i++){
			if(graph[now][p[i]-'0'] == -1){
				f = false;
				break;
			}
			now = graph[now][p[i]-'0'];
		}
		if(f && now == b){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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 () {
  int d, g;
  cin >> d >> g;
  vi p(d), c(d);
  rep(i,d) cin >> p[i] >> c[i];

  int ans = INF;
  rep(b,1<<d) {
    int score = 0;
    int num = 0;
    rep(i,d) {
      if (b&(1<<i)) {
        score += 100*(i+1)*p[i] + c[i];
        num += p[i];
        if (score >= g) {
          ans = min(ans, num);
          break;
        }
      }
    }
    for (int i = d-1; i >= 0; --i) {
      if (!(b&(1<<i))) {
        rep(_,p[i]) {
          score += 100*(i+1);
          num++;
          if (score >= g) {
            ans = min(ans, num);
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
"use strict";

const main = arg => {
    const N = arg.split("\n")[0].split(" ")[0];
    const t = arg.split("\n")[0].split(" ")[1];
    console.log(N - t > 0 ? N - t : 0);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include <vector>
using namespace std;




int main(){
    vector<int> v(5);
    
    for(int i = 0; i < 5; i++)
    {
        /* code */
        cin >> v[i];
    }
    
    int minNum = 10;
    int minArray = 0;
    for(int i = 0; i < 5; i++)
    {
        /* code */        
        if(minNum > (v[i] % 10) && (v[i] % 10) != 0){
            minNum = v[i] % 10;
            minArray = i;
            //cout << "vi:" << v[i] << endl;
        }
    }
    
    int totalTime = 0;    
    for(int i = 0; i < 5; i++)
    {
        /* code */
        if(i == minArray){
            continue;
        }

        //cout << "vi:" << v[i] << endl;

        if((v[i] % 10) != 0){
            totalTime += v[i] + (10 - v[i] % 10);
            //cout << "tt:" << totalTime << endl;
        }else{
            totalTime += v[i];
        }
    } 
    totalTime += v[minArray];
    cout << totalTime << endl;


}

Measured memory_bytes: 256
import queue

N, M = map(int, input().split())
AB = {}
for i in range(N): AB[i] = set()
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    AB[A].add(B)
    AB[B].add(A)

finish = [False] * N
q = queue.Queue()
ans = 0
for i in range(N):
    if finish[i]: continue
    q.put(i)
    group = set()
    while not q.empty():
        x = q.get()
        group.add(x)
        finish[x] = True
        for friend in AB[x]:
            if finish[friend]: continue
            q.put(friend)
            finish[friend] = True
    tmp = len(group)
    if tmp >= N / 2:
        ans = tmp
        break
    ans = max(ans, len(group))
print(ans)


Measured memory_bytes: 172184
#include <iostream>

bool calc(int x) {
  if (x < 0)
    return false;
  if (x == 0)
    return true;
  return calc(x - 100) || calc(x - 101) || calc(x - 102) || calc(x - 103) ||
         calc(x - 104) || calc(x - 105);
}

int main(int argc, char *argv[]) {
  int x;
  std::cin >> x;
  x %= 10000;
  while (x % 100 > 5) {
    x -= 105;
    if (x == 0) {
      std::cout << 1 << std::endl;
      return 0;
    }
    if (x < 100) {
      std::cout << 0 << std::endl;
      return 0;
    }
  }
  std::cout << calc(x) << std::endl;
}


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

static const int MAX = 200005;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
vector<int> G[MAX], d(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること

void bfs(int s) {
  queue<int> q;
  q.push(s);
  d[s] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v = 0; v < G[u].size(); v++) {
      if (d[G[u][v]] == INF) {
        if (d[u] == 1) d[G[u][v]] = 2;
        else d[G[u][v]] = 1;
        q.push(G[u][v]);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接リスト
  int n; // n:頂点数 m:辺数
  cin >> n;
  
  // vector<int> G[n]; // G:頂点数がnのグラフを表す隣接リスト
  
  int u, v;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  bfs(0);
  
  int count1 = 0, count2 = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] == 1) count1++;
    else count2++;
  }
  
  int max1, max2, max3;
  if (n % 3 == 0) {
    max1 = n - 2;
    max2 = n - 1;
    max3 = n;
  }
  else if (n % 3 == 1) {
    max1 = n;
    max2 = n - 2;
    max3 = n - 1;
  }
  else {
    max1 = n - 1;
    max2 = n;
    max3 = n - 2;
  }
  
  int now1 = 1, now2 = 2, now3 = 3;
  vector<int> x(n, 0);
  if (count1 > n * 2 / 3) {
    for (int i = 0; i < n; i++) {
      if (d[i] == 2) {
        x[i] = now3;
        now3 += 3;
      }
      else {
        if (now1 <= max1) {
          x[i] = now1;
          now1 += 3;
        }
        else if (now2 <= max2) {
          x[i] = now2;
          now2 += 3;
        }
        else {
          x[i] = now3;
          now3 += 3;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (i) cout << " ";
      cout << x.at(i);
    }
    cout << '\n';
    return 0;
  }
  
  if (count2 > n * 2 / 3) {
    for (int i = 0; i < n; i++) {
      if (d[i] == 1) {
        x[i] = now3;
        now3 += 3;
      }
      else {
        if (now1 <= max1) {
          x[i] = now1;
          now1 += 3;
        }
        else if (now2 <= max2) {
          x[i] = now2;
          now2 += 3;
        }
        else {
          x[i] = now3;
          now3 += 3;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (i) cout << " ";
      cout << x.at(i);
    }
    cout << '\n';
    return 0;
  }
  
  for (int i = 0; i < n; i++) {
    if (d[i] == 1) {
      if (now1 <= max1) {
        x[i] = now1;
        now1 += 3;
      }
      else {
        x[i] = now3;
        now3 += 3;
      }
    }
    else {
      if (now2 <= max2) {
        x[i] = now2;
        now2 += 3;
      }
      else {
        x[i] = now3;
        now3 += 3;
      }
    }
  }
  
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << x.at(i);
  }
  cout << '\n';
}

Measured memory_bytes: 15344