akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/
int h,w,a,b,ans;
int meup,medown;
signed main() {
	cin>>h>>w>>a>>b;
	ans+=comb(h-a-1+b,b)*comb(a+w-b-2,a-1);
	meup=comb(h-a-1+b,b),medown=comb(a+w-b-2,a-1);
	ans%=moder;
	for(int i=b+2;i<=w;i++){
		meup=meup*(h-a+i-2)%moder*mod_pow((i-1),moder-2,moder)%moder;
		medown=medown*(w-i+1)%moder*mod_pow((w-i+a),moder-2,moder)%moder;
		ans+=meup*medown%moder;
		ans%=moder;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2688
n = int(input())
A = list(map(int, input().split()))

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))
print(ans)

Measured memory_bytes: 19092
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char str[10];
    while(scanf("%s",str)!=EOF)
    {
        switch(str[1])
        {
        case 'U':
            if(str[0]=='S')
            {
                printf("7\n");
            }
            else{
                printf("5\n");
            }
            break;
        case 'O':
            printf("6\n");
            break;
        case 'E':
            printf("4\n");
            break;
        case 'H':
            printf("3\n");
            break;
        case 'R':
            printf("2\n");
            break;
        case 'A':
            printf("1\n");
            break;
        }
    }
    return 0;
}

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

typedef long long ll;

ll N, M;
vector<vector<ll>> vec;

int main() {
  cin >> N >> M;
  vec.resize(N, vector<ll>(2));
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < 2; j++) {
      cin >> vec[i][j];
    }
  }


  sort(vec.begin(), vec.end());
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    if (vec[i][1] <= M) {
      ans += vec[i][0] * vec[i][1];
      M -= vec[i][1];
    } else {
      ans += vec[i][0] * M;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

#include <bitset>
const int PRIME_SIZE = 1000000;
int psize;
bitset<PRIME_SIZE + 1> bprime;
int prime[PRIME_SIZE / 10 + 1000];
int Eratosthenes(int n) {
  psize = 0;
  bprime.set();
  bprime[0] = bprime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (!bprime[i]) { continue; }
    prime[psize++] = i;
    if ((long long)i * i > n) { continue; }
    for (int j = i * i; j <= n; j += i) {
      bprime[j] = false;
    }
  }
  return psize;
}

ll naive(int v) {
  ll ret = 0;
  FOR(i, 1, v) {
    if (v % i == 0) { ret += i; }
  }
  return ret;
}

ll calc(int v, int depth) {
  if (depth == psize || v < prime[depth]) { return 0; }
  ll ret = calc(v, depth + 1);
  if (v % prime[depth] != 0) { return ret; }
  ret += calc(v / prime[depth], depth) + v / prime[depth];
  return ret;
}

int main() {
  int n;
  Eratosthenes(1000000);
  while (scanf("%d", &n), n) {
    ll ans = calc(n, 0);
    //cout << n << " " << ans << " " << naive(n) << endl;
    if (ans > n) {
      puts("abundant number");
    } else if (ans == n) {
      puts("perfect number");
    } else {
      puts("deficient number");
    }
  }
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int h,w;
    cin >> h >> w;
    string s[h];
    rep(i,h)cin >> s[i];

    int ans = 0;

    rep(i,w-1){
        int c[h+1][h+1];
        int dp[h+1][h+1];
        rep(j,h+1){
            rep(k,h+1){
                c[j][k] = 0;
                dp[j][k] = 0;
            }
        }

        rep(j,h+1){
            c[0][j] = 0;
            int k = 1;
            while(j+k<=h){
                c[k][j+k] = c[k-1][j+k-1];
                if(s[k-1][i] == s[j+k-1][i+1])c[k][j+k]++;
                k++;
            }
        } 
        rep(j,h+1){
            c[j][0] = 0;
            int k = 1;
            while(j+k<=h){
                c[j+k][k] = c[j+k-1][k-1];
                if(s[j+k-1][i] == s[k-1][i+1])c[j+k][k]++;
                k++;
            }
        }
        drep(l,h*2+1){
            rep(j,l+1){
                int k = l - j;
                if(j > h)break;
                if(k < 0)break;
                if(k > h)continue;
                if(j == h && k == h){
                    dp[j][k] = 0;
                    continue;
                }
                dp[j][k] = 1001001001;
                if(j < h){
                    dp[j][k] = min(dp[j][k], dp[j+1][k] + c[j+1][k]);
                }
                if(k < h){
                    dp[j][k] = min(dp[j][k], dp[j][k+1] + c[j][k+1]);
                }
            }
        }
        ans += dp[0][0];
        /*
        drep(j,h+1){
            rep(k,h+1){
                cout << c[j][k] << ' ';
            }
            cout << endl;
        }
        cout << dp[0][0] << endl;
        */

    }

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


Measured memory_bytes: 1280
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vl;
 
const lint INF = 1e18;
const lint MOD = 1e9 + 7;
double EPS = 1e-8;

template <typename T>
struct SegTree{
    vector<T> dat;
    int n;
    const T Default;
    SegTree(int n_, const T& def) : Default(def){init(n_);}
    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n-1, Default);
    }
    T f(const T& a, const T& b) {
        return max(a, b);
    }
    void update(int k, const T& a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r ){
        if(r <= a || b <= l) return Default;
        if(a <= l && r <= b) return dat[k];
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};

int main(){
    lint n, c;
    cin >> n >> c;
    vector<lint> x(n), v(n);
    rep(i, n) cin >> x[i] >> v[i];
    vector<lint> r, l, ll, rr;
    l.pb(0);
    ll.pb(0);
    l.pb(v[0]-x[0]);
    ll.pb(v[0]-x[0]*2);
    REP(i, 1, n) {
        l.pb(l.back()+x[i-1]-x[i]+v[i]);
        ll.pb(ll.back()+x[i-1]*2-x[i]*2+v[i]);    
    }
    r.pb(0);
    rr.pb(0);
    r.pb(v.back() - (c - x.back()));
    rr.pb(v.back() - (c - x.back())*2);
    REPR(i, n-1, 0) {
        r.pb(r.back()+(c - x[i+1])-(c-x[i])+v[i]);
        rr.pb(rr.back()+(c-x[i+1])*2-(c-x[i])*2+v[i]);
    }
    SegTree<lint> L(n+10, -INF), LL(n+10, -INF), R(n+10, -INF), RR(n+10, -INF);
    rep(i, l.size()) {
        L.update(i, l[i]);
        LL.update(i, ll[i]);
        R.update(i, r[i]);
        RR.update(i, rr[i]);
    }
    lint ans = -INF;
    rep(i, n+1) {
        ans = max(ans, L.query(0, i+1) + RR.query(0, n - i+1));
        ans = max(ans, R.query(0, i+1) + LL.query(0, n - i+1));
    }
    cout << ans << endl;
    // rep(i, n+1) {
    //     cout << L.query(i, i+1) << " " << LL.query(i, i+1) << " " << R.query(i, i+1) << " " << RR.query(i, i+1) << endl;
    // } 
    return 0;
}

Measured memory_bytes: 15380
import sys

a = int(input())

cnt = 0

for i in range(1,10):
	cnt += 1
	if i == a :
		print (cnt)
		sys.exit()
if a < 100 :
	print (cnt)
	sys.exit()
for j in range(100,1000):
	cnt += 1
	if j == a :
		print (cnt)
		sys.exit()
        
if a < 10000 :
	print (cnt)
	sys.exit()
for k in range(10000,100000):
	cnt += 1
	if k == a :
		print (cnt)
		sys.exit()
if a == 100000 :
	print (cnt)
	sys.exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
    return 0;
}

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

namespace aizu1
{
    public class Solution
    {
        public static void Main(string[] args)
        {
             Console.ReadLine();
            int[] s = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), int.Parse);
            long comCount = mergeSort(s, 0, s.Length);
            Console.WriteLine(comCount);
        }


        public static long mergeSort(int[] list, int left, int right)
        {
            if (left == right - 1) return 0;

            return mergeSort(list, left, (right + left) / 2) + mergeSort(list, (right + left) / 2, right) + merge(list, left, (left + right) / 2, right);
        }

        public static long merge(int[] list, int left, int mid, int right)
        {
            int[] L = new int[mid - left + 1];
            int[] R = new int[right - mid + 1];
            long com = 0;

            for (int m = 0; m < mid - left; m++)
            {
                L[m] = list[m + left];
            }

            for (int i = 0; i < right - mid; i++)
            {
                R[i] = list[mid + i];
            }

            L[mid - left] = int.MaxValue;
            R[right - mid] = int.MaxValue;

            int j = 0, k = 0;
            for (int l = left; l < right; l++)
            {
                if (L[j] <= R[k])
                    list[l] = L[j++];
                else
                {
                    list[l] = R[k++];
                    com += mid - left - j;
                }
            }
            return com;
        }
    }
}

Measured memory_bytes: 35912
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

int c[3];
int n,p[N];
vector <int> g[N], rb[N];

void dfs(int v,int col, int p){
	rb[col].pb(v);
	for(int to : g[v]){
		if(to == p) continue;
		dfs(to, 3 - col, v);
	}
}

int main () {
	scanf("%d", &n);
	for(int i = 1,u,v; i < n; i++){
		scanf("%d%d",&u, &v);
		g[u].pb(v);
		g[v].pb(u);
	}
	c[0] = 3, c[1] = 1, c[2] = 2;
	dfs(1,1,-1);
	if(rb[1].size() > rb[2].size()) swap(rb[1], rb[2]);
	if(rb[1].size() <= int(n / 3)){
		for(int i : rb[1]){
		    p[i] = c[0];
		    c[0] += 3;
		}
		for(int i : rb[2]){
			if(c[0] <= n){
				p[i] = c[0];
			    c[0] += 3;
			}
			else if(c[1] <= n){
				p[i] = c[1];
			    c[1] += 3;
			}
			else if(c[2] <= n){
				p[i] = c[2];
			    c[2] += 3;
			}
		}
	}
	else{
		for(int i : rb[1]){
			if(c[1] <= n){
				p[i] = c[1];
				c[1] += 3;
			}
			else{
				p[i] = c[0];
				c[0] += 3;
			}
		}
		for(int i : rb[2]){
			if(c[2] <= n){
				p[i] = c[2];
				c[2] += 3;
			}
			else{
				p[i] = c[0];
				c[0] += 3;
			}
		}
	}
	for(int i = 1; i <= n; i++) printf("%d ", p[i]);

return 0;
}

Measured memory_bytes: 30964
#include <iostream>
#include <string>

using namespace std;
#define REP(i,n) for(int i = 0; i < n; i ++)
#define ctoi(c) ((c)-'0')

int calc(string s, int n)
{
    string ps;
    int v = ctoi(s[0]);
    ps = s[0];
    REP(j, (s.size()-1)) {
        if(n&(1<<j)) {
            v+=ctoi(s[j+1]);
            ps += "+";
        } else {
            v-=ctoi(s[j+1]);
            ps += "-";
        }
        ps += s[j+1];
    }
    if(v == 7) {
        cout << ps << "=" << v << endl;
        return 1;
    }
    return 0;

}

int main(void)
{
    string s;
    cin >> s;

    REP(i, 1<<(s.size()-1)) {
        if(calc(s, i)!=0) {
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define rep(i,n) for(int64_t i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr int64_t INF=(1ll<<60);
constexpr int64_t mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s,t;cin>>s>>t;
    ll a,b;cin>>a>>b;
    string u;cin>>u;

    if(s==u) a--;
    else if(t==u) b--;

    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M), d(N);
  REP(i, M) {
    cin >> s[i] >> c[i];
  }
  REP(i, N) {
    d[i] = -1;
  }
  REP(i, M) {
    if (d[s[i]-1] == c[i] || d[s[i]-1] == -1) {
      d[s[i]-1] = c[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  REP(i, N) {
    if (d[i] == -1) {
      if (i == 0 && d.size() != 1) {
        d[i] = 1;
      } else {
        d[i] = 0;
      }
    }
  }
  if (d[0] == 0 && d.size() != 1) {
    cout << -1 << endl;
    return 0;
  }
  REP(i, N) {
    cout << d[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
//package atcoder.dpContest;

import java.io.*;
import java.util.*;

public class Main {
    private static List<Integer>[] g;
    private static int[] dp;
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));

        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

            solve(1, in, out);

//        } catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for (int qq = 0; qq < q; qq++) {
            int N = in.nextInt(), M = in.nextInt();
            g = new List[N];
            for(int i = 0; i < N; i++) {
                g[i] = new ArrayList<>();
            }
            for(int i = 0; i < M; i++) {
                g[in.nextInt() - 1].add(in.nextInt() - 1);
            }
            dp = new int[N];
            Arrays.fill(dp, -1);
            for(int i = 0; i < N; i++) {
                dfs(i);
            }
            int ans = 0;
            for(int i = 0; i < N; i++) {
                ans = Math.max(ans, dp[i]);
            }
            out.println(ans);
        }
        out.close();
    }

    private static int dfs(int curr) {
        if(dp[curr] < 0) {
            dp[curr] = 0;
            for(int neighbor : g[curr]) {
                dp[curr] = Math.max(dp[curr], dfs(neighbor) + 1);
            }
        }
        return dp[curr];
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




Measured memory_bytes: 56172
#include <iostream>
#include <string>

using namespace std;

int main () {

    string s;
    cin >> s;

    int n1, n2;
    n1 = n2 = 0;

    for (int i = 0; i < s.size(); i++) {
        int ans = (i%2) == 0 ? 1 : 0;
        if (stoi(s.substr(i,1)) != ans) {
            n1++;
        }
    }

    for (int i = 0; i < s.size(); i++) {
        int ans = (i%2) != 0 ? 1 : 0;
        if (stoi(s.substr(i,1)) != ans) {
            n2++;
        }
    }


    cout << min(n1, n2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  char S;
  cin >>S;
  if(S=='A') {
cout << 'T' << endl;
  }
  else if(S=='T') {
cout << 'A' << endl;
  }
   else if(S=='G') {
cout << 'C' << endl;
  }
  else if(S=='C') {
cout << 'G' << endl;
  }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  string S; cin >> S;
  string T;
  rep(i, S.size() - 1) {
    if (S[i] == 'B' && S[i + 1] == 'C') {
      T += 'D';
      i++;
    } else {
      T += S[i];
    }
  }
  int a_count = 0;
  ll ans = 0;
  rep(i, T.size()) {
    if (T[i] == 'A') {
      a_count++;
    }
    else if (T[i] == 'B' || T[i] == 'C') {
      a_count = 0;
    }
    else {
      ans += a_count;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str;
	int num = 0;
	int sum;
	int i;

	while (1)
	{
		sum = 0;
		getline(cin, str);
		if (str[0] == '0')
			break;
		else{
			for (i = 0; i < str.length(); i++)
			{
				num = str[i] - '0';
				sum += num;
			}

			cout << sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    ll aa = a;
    a-=min(a,k);
    k-=min(aa,k);
    if(k==0){
        cout<<a<<" "<<b<<endl;
    }else{
        b-=min(k,b);
        cout<<a<<" "<<b<<endl;
    }

    
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int v[505][505];
int s[505][505];
int main() {
  int n,m,q;
  cin >> n >> m >> q;
  rep(i,m){
    int l,r;
    cin >> l >> r;
    v[l][r]++;
  }
  rep(i,n)rep(j,n) s[i+1][j+1] = s[i+1][j] + v[i+1][j+1];
  
  rep(qi,q){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i=a; i<=b; ++i){
      ans += s[i][b] - s[i][a-1];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int main() {
	map<int, int> m;
	int v;
	while (cin >> v) {
		m[v]++;
	}
	vector<pair<int,int>> vec;
	for (auto p : m) {
		vec.push_back({ p.second, p.first });
	}
	sort(ALL(vec));
	rep(i,vec.size()) {
		if (vec[i].first == vec.back().first) {
			cout << vec[i].second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int a,b;
  cin >> a >> b;

    if (a <= b) {
        cout << a << endl;
    } else {
        cout << a - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    ll m=n;
    ll f=0;
    while(m){
        f+=(m%10);
        m/=10;
    }
    if(n%f==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>

typedef long long ll;

using namespace std;

int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  int left = 1;
  while (left < N && S[0] == S[left]) {
    ++left;
  }
  int right = 0;
  while (N - 1 - right && S[0] == S[N - 1 - right]) {
    ++right;
  }
  S = S + S;
  ll cnt = 0;
  for (int i = 0; i < S.size() - 1; ++i) {
    if (S[i + 1] == S[i]) {
      S[i + 1] = 'A';
      ++cnt;
    }
  }
  if (left + right < N && left % 2 != 0 && right % 2 != 0) {
    printf("%lld\n", max(0LL, (cnt + 1) * (K / 2) + ((cnt + 1) / 2) * (K % 2 != 0) - 1));
  } else {
    printf("%lld\n", cnt * (K / 2) + (cnt / 2) * (K % 2 != 0));
  }
}


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

using namespace std;

typedef long long llint;

// dp[決めた桁数][N未満][0でない数字が何個あるか]
llint dp[111][2][5];

int main() {
  string s;
  int k, n;
  cin >> s >> k;
  n = s.size();
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    int num = s[i] - '0';
    for (int j = 0; j < 2; j++) {     // N未満かどうか
      for (int z = 0; z <= k; z++) {  // 0でない数字が何個あるか
        for (int d = 0; d <= (j ? 9 : num); d++) {
          dp[i + 1][j || (d < num)][z + (d > 0)] += dp[i][j][z];
        }
      }
    }
  }
  cout << dp[n][0][k] + dp[n][1][k] << endl;

  return 0;
}

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

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> a(N);
    for (auto &i : a) cin >> i;

    int all = 0;
    for (auto &i : a) all ^= i;

    vector<int> ans(N);
    rep(i, N) ans[i] = all ^ a[i];

    rep(i, N) printf("%d%c", ans[i], i != N-1? ' ' : '\n');
}

Measured memory_bytes: 4836
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
*/

f([], Y, Y).
f([X|Xs], Y, -1) :- Y > 1000000000000000000 div X, !.
f([X|Xs], Y, Z) :- Y2 is X * Y, f(Xs, Y2, Z).

g([]).
g([X|Xs]) :- X \= 0, g(Xs).

main :-
    get_number(N),
    get_numbers(N, Xs),
    (\+ g(Xs) -> writeln("0") ; (f(Xs, 1, Z) , writeln(Z))).


Measured memory_bytes: 15208
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
#define rep(i, s, n) for(int i = s;i<n;i++)

int main(void) {
    int n;
    vector<int> l(101, 0);

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

    sort(l.begin(), l.end(), greater<int>());
    int max_l = l[0];
    int sum = 0;
    rep(i, 1, l.size()) {
        sum += l[i];
    }
    if (max_l < sum) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> Alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
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()
{
  cout << fixed << setprecision(10);
  int N,X,T;
  cin >> N >> X >> T;
  if(N%X!=0)
  {
    cout << (N/X+1)*T << endl;
    return 0;
  }
  cout << N/X*T << endl;
  return 0;
}


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

using namespace std;

const int MAXN = 1<<17;

bool bio[MAXN];
vector<int> edges[MAXN];
deque<int> sol;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m, a, b;
	
	cin>>n>>m;
	
	while (m--)
	{
		cin>>a>>b;
		--a, --b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	
	a = 0;
	prvi:
	bio[a] = true;
	sol.push_back(a);
	for (int b: edges[a]) if (!bio[b])
	{
		a = b;
		goto prvi;
	}
	
	a = 0;
	drugi:
	bio[a] = true;
	for (int b: edges[a]) if (!bio[b])
	{
		a = b;
		sol.push_front(b);
		goto drugi;
	}
	
	cout<<sol.size()<<'\n';
	for (int a: sol)
		cout<<a + 1<<' ';
	cout<<'\n';
}



Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<uint32_t> A(N);
  uint32_t B=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    B^=A[i];
  }
  for(int i=0;i<N;i++){
    cout<<(A[i]^B);
    if(i==N-1)
      cout<<endl;
    else
      cout<<' ';
  }
}

Measured memory_bytes: 4036
#include <iostream>
using namespace std;
int main(void){
    int x,y,z,tmp;
    cin >>x>>y>>z;
    if(y>z){
        tmp=y;
        y=z;
        z=tmp;
    }
    if(x>y){
        tmp=x;
        x=y;
        y=tmp;
    }
    if(y>z){
        tmp=y;
        y=z;
        z=tmp;
    }
    cout << x << " " << y << " " << z << endl;    
}

Measured memory_bytes: 1164
h,w,a,b=[int(x)for x in raw_input().split()]
m=1000000007
def f(*n):
 r=1
 for i in xrange(*n):r=r*(i+1)%m
 return r
def g(n):return pow(n,m-2,m)
c=s=f(w-b-1,h+w-b-2)*g(f(h-1))%m
for i in xrange(1,h-a):
 s=s*(b+i-1)%m*(h-i)%m*g(i*(h+w-b-1-i)%m)%m
 c=(c+s)%m
print c


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int main()
{
  int N, t[9999];
  int dp[5001][2];
  fill_n(*dp, 5001 * 2, INF);

  scanf("%d", &N);
  for(int i = 0; i < N - 1; i++) scanf("%d", &t[i]);

  dp[1][0] = 0;
  for(int i = 0; i < N - 1; i++) {
    for(int j = N / 2; j > 0; j--) {
      dp[j][1] = min(dp[j    ][1], dp[j    ][0] + t[i]);
      dp[j][0] = min(dp[j - 1][0], dp[j - 1][1] + t[i]);
    }
  }
  printf("%d\n", min(dp[N / 2][1], dp[N / 2][0]));
}

Measured memory_bytes: 1268
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    s = int(input())
    
    #三角形の面積を座標から求める公式を使う
    #x1=y1=0としたとき、abs(x2*y3-x3*y2)/2でsが求められる
    #x2=10**9,y2=1で固定し、10**9*y3-x3=sを満たすz3,y3を求める

    v = 10**9

    x = (v-s%v)%v
    y = (s+x)//v

    print(0,0,10**9,1,x,y)

if __name__=='__main__':
    main()

Measured memory_bytes: 9100
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i=1;
		while(true){
			int a = sc.nextInt();
			if(a==0)break;
			System.out.printf("Case %d: %d%n",i,a);
			i++;
		}
	}
}


Measured memory_bytes: 67860
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inv[201000],fac[201000],mod=1e9+7;
int n,x,y,w1=1999999999,c1,id1,w2=1999999999,c2,id2;
struct xxx{int w,c;}d[201000]; bool used[201000];int cnt[201000],sum=0;
int h[201000],nxt[5001000],K=0,to[5001000];
void ins(int u,int v){nxt[++K]=h[u];h[u]=K;to[K]=v;}
bool cmp(xxx a,xxx b){return a.c<b.c;}
ll ksm(ll k,int p)
{
	ll ans=1ll;while(p){if(p&1)ans=(ans*k)%mod;k=(k*k)%mod;p>>=1;}
	return ans;
}
void init()
{
	fac[0]=inv[0]=1ll;for(int i=1;i<=n;i++)fac[i]=(fac[i-1]*i)%mod;
	inv[n]=ksm(fac[n],mod-2);for(int i=n-1;i>=1;i--)inv[i]=(inv[i+1]*(i+1))%mod;
}
void dfs(int x)
{
	if(used[x])return;cnt[d[x].c]++;used[x]=1;sum++;
	for(int i=h[x];i;i=nxt[i])dfs(to[i]);
}
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++)scanf("%d%d",&d[i].c,&d[i].w);
	sort(d+1,d+n+1,cmp);//for(int i=1;i<=n;i++)cout<<d[i].c<<" "<<d[i].w<<endl<<endl;
	for(int i=1;i<=n;i++)
	if(d[i].w<=w1){if(d[i].c!=c1)swap(w1,w2),swap(c1,c2),swap(id1,id2);w1=d[i].w;c1=d[i].c;id1=i;}
	else if(d[i].w<=w2&&d[i].c!=c1){w2=d[i].w;c2=d[i].c;id2=i;}
	int k;
	for(int i=1;i<=n;)
	{
		int j=i,Min=d[i].w,col=d[i].c;k=i;
		while(d[i].c==col){if(Min>d[i].w)Min=d[i].w,k=i;i++;}i=j;//cout<<Min<<" "<<i<<endl;
		while(d[i].c==col){if(d[i].w+Min<=x)ins(i,k),ins(k,i);i++;}
	}
	for(int i=1;i<=n;i++)if(d[i].c!=c1&&d[i].w+w1<=y)ins(i,id1),ins(id1,i);
	if(c2!=0)for(int i=1;i<=n;i++)if(d[i].c==c1&&d[i].w+w2<=y)ins(i,id2),ins(id2,i);
//	for(int i=1;i<=n;i++,cout<<endl)for(int j=h[i];j;j=nxt[j])cout<<to[j]<<" ";
	dfs(id1);init();ll ans=fac[sum];
	for(int i=1;i<=n;i++)ans=(ans*inv[cnt[i]])%mod;
	printf("%lld",ans);return 0;
}
 //把能互相交换的处理出来，
 //1.同一种颜色：把每种颜色最小的与这种颜色其他球连边 (<=x)
 //2.不同种颜色：取所有球中的最小值（记颜色为c），与它不同颜色的球连边(<=y)，再取一个不同于c颜色的最小值，把它与c颜色的球连边(<=y) 
 //3.计算答案：从2的c开始跑dfs，有被遍历到的球就把它的颜色的出现次数++，设颜色为col的球的出现次数acol，总数为sum，
 //则答案可以看成从sum个位置中选a1个位置填颜色1，再从sum-a1个位置中选a2个位置填颜色2......，则ans=C(sum,a1)*C(sum-a1,a2)*C(sum-a1-a2,a3)...... =sum!/(a1!*a2!......)

Measured memory_bytes: 15104
S=input()
ab=int(S[0]+S[1])
cd=int(S[2]+S[3])
if ab==0:
  if cd==0:#0000
    print('NA')
  elif cd>=1 and cd<=12:
    #0001~0012
    print('YYMM')
  else: #0013~0099
    print('NA')
elif ab>=1 and ab<=12:
  if cd ==0:
    print('MMYY')
  elif cd>=1 and cd<=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if cd>=1 and cd<=12:
    print('YYMM')
  else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#define M_PI 3.1415926535897932384626433832795
using namespace std;

int main(){
	double r;
	cin >> r;
	cout << fixed << setprecision(6) << r*r*M_PI << " " << 2 * M_PI*r << endl;
}

Measured memory_bytes: 3236
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << endl;}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;

	rep(i, s.size()) s[i] = 'x';

	co(s);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

struct dice{
  int s1[6];
  int jmen[24],zmen[24];
};

int main(){
  struct dice D;
  int i,j,n;

  for(i=0;i<6;i++)
    scanf("%d",&D.s1[i]);

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d %d",&D.jmen[i],&D.zmen[i]);

  for(i=0;i<n;i++){
    if(D.jmen[i] == D.s1[0]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[1]){
      if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[2]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[0]);
    }
    else if(D.jmen[i] == D.s1[3]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[5]);
    }
    else if(D.jmen[i] == D.s1[4]){
      if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[5]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[3]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[2]);
    }
  }
  return 0;
}

Measured memory_bytes: 596
s = input()
while True:
    if s.endswith("dream"):
        s = s[:-5]
    elif s.endswith("dreamer"):
        s = s[:-7]
    elif s.endswith("erase"):
        s = s[:-5]
    elif s.endswith("eraser"):
        s = s[:-6]
    elif not s:
        print("YES")
        break
    else:
        print("NO")
        break


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	int n = s.size();
	for(int i = 0; i < n; ++i) {
		if( s[i] == '?' ) s[i] = 'D';
	}
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 3732
// F*** the exam

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 1000005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
ll fre[N];
void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++)   cin >> a[i],fre[a[i]]++;
    ll ans = 0;
    for(ll i=1;i<N;i++)
    {
        if(fre[i])
        {
            if(fre[i]==1)       ans += fre[i];
            for(ll j=i+i;j<N;j+=i)   fre[j] = 0;
        }
    }
    cout<<ans;
}

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

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        ArrayList<String> list = new ArrayList<String>();
        int N, L;
        String state = "";

        N = sc.nextInt();
        L = sc.nextInt();

        for (int i = 0; i < N; i++) {
            list.add(sc.next());
        }

        Collections.sort(list);
        
        for (int i = 0; i < N; i++) {
            state += list.get(i);
        }
        
        out.println(state);
        sc.close();
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

signed main() {
	int n, h, ans = 0;
	cin >> n >> h;
	int a[114514], b[114514];
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	reverse(a, a + n);
	reverse(b, b + n);
	rep(i, n) {
		if (b[i] <= a[0]) {
			break;
		}
		h -= b[i];
		ans++;
		if (h <= 0) {
			cout << ans << endl;
			END;
		}
	}
	if (h%a[0] == 0) cout << ans + h / a[0] << endl;
	else cout << ans + h / a[0] + 1 << endl;

	END;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)      type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int x,y;cin>>x>>y;
    for(int i=0;i<102;i++){
        for(int j=0;j<102;j++){
            if(2*i+4*j==y and (i+j==x)){
                flag=1;
            }
        }
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 3764
#include <iostream>

using namespace std;

int main()
{
    int num;
    long long result = 0;
    cin >> num;
    for(int i = 1;i <= num;i++){
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }
        result += i;
    }
    cout << result << endl;
    return 0;
}

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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var r = 0L;

            for (var i = 1; i < n; i++)
            {
                var a = (n - 1) / i;
                r += a;
            }

            Console.WriteLine(r);
        }
    }
}


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

int main(){
  long long X,K,D;
  cin >> X >> K >> D;
  X=abs(X);
  long long A=X/D;
  if(K<=A){
    cout << X-K*D << endl;
    return 0;
  }
  K-=A;
  X-=A*D;
  if(K%2==0){
    cout << X << endl;
  }
  else{
    cout << abs(X-D) << endl;
  }
}
  

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

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

Measured memory_bytes: 256
import math
D,G = map(int, input().split())
L=[[0,0] for i in range(D)]

for i in range(D):
    L[i][0],L[i][1]=map(int, input().split())
MAP=[0]*(D+1)
C=[[0,0] for i in range(D)]
for i in range(D):
    C[i][1]=(i+1)
    C[i][0]=L[i][0]*(i+1)*100
C=sorted(C,reverse=True)

a=10**10
while(MAP[-1]==0):
    for j in range(D):
        if MAP[j] > 1:
            MAP[j] -= 2
            MAP[j+1]+=1 
    s=0
    c=0
    for j in range(D):   
        if(MAP[j]!=0):
            s+=L[j][0]*(j+1)*100
            s+=L[j][1]
            c+=L[j][0]
    if(c<a):
        if(s<G):
            for i in range(D):
                if(MAP[C[i][1]-1]==0):
                    t=G-s
                    if(C[i][0]>t):
                        c+=math.ceil(t/(C[i][1]*100))
                        s+=C[i][1]*100*math.ceil(t/(C[i][1]*100))
                    break
        if(s>=G):
            a=min(a,c)
            #print(a,MAP)
    MAP[0]+=1
print(a)

Measured memory_bytes: 41456