akhauriyash/Code-Regression huggingface dataset:
#                         author:  kagemeka 
#                         created: 2019-11-06 14:53:37(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    a, b, c, x = (int(i) for i in sys.stdin.read().split())

    combination = 0
    for i in range(a+1):
        ta = 500 * i
        if ta == x:
            combination += 1
            continue
        elif ta> x:
            continue
        for j in range(b+1):
            tb = 100 * j
            if ta + tb == x:
                combination += 1
                continue
            elif ta + tb > x:
                continue
            for k in range(c+1):
                total = ta + tb + 50 * k
                if total == x:
                    combination += 1
    
    print(combination)

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
V<int> v, ans;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    v.pb(a);
  }
  while(!v.empty()){
    bool z = false;
    FORR(i, sz(v)-1, 0) if(i+1 == v[i]){
      z = true;
      ans.pb(v[i]);
      v.erase(v.begin() + i);
      break;
    }
    if(!z){
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(all(ans));
  FOR(i, 0, n) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<climits>
#include<cmath>
#include<queue>
 
using namespace std;
 
struct edge {
  int to, cost;
};
 
struct state {
  int pos, cost;
 
  bool operator < (const state& s) const {
    return cost > s.cost;
  }
};
 
int main() {
  int n; cin >> n;
 
  vector< vector<edge> > edges(n, vector<edge>());
  for (int i = 0; i < n; i++) {
    int u, k; cin >> u >> k;
 
    while (k--) {
      int to, cost; cin >> to >> cost;
      edges[u].push_back((edge) { to, cost});
    }
  }
 
  priority_queue<state> queue;
  vector<int> costs(n, INT_MAX);
  costs[0] = 0;
  queue.push((state) {0, 0});
 
  while(!queue.empty()) {
    const state now = queue.top();
    queue.pop();
 
    
     
    for (int i = 0; i < edges[now.pos].size(); i++) {
      state nex = now;
      nex.pos = edges[now.pos][i].to;
      nex.cost += edges[now.pos][i].cost;
      if (costs[nex.pos] > nex.cost) {
        costs[nex.pos] = nex.cost;
        queue.push(nex);
      }
    }
  }
 
  for (int i = 0; i < n; i++)
    cout << i << " " << costs[i] << endl;
   
  return 0;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) x.begin(), x.end()
#define inf 1e9
#define INF 1e15
#define fastio ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
#define for(i,n) for(int i=0;i<n;i++)
////////////////////////////////////////////////////////////
using namespace std;
 
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<ii> vii;

int b[3][3];
int main() {
	int n;
	for(i,3) for(j,3) cin >> b[i][j];
	cin >> n;
	while(n--) {
		int k; cin >> k;
		for(i,3) for(j,3)
			if(b[i][j] == k) b[i][j] = -1;
	}
	bool bingo = false;
	for(i,3) if(b[i][0] + b[i][1] + b[i][2] == -3) bingo = true;
	for(i,3) if(b[0][i] + b[1][i] + b[2][i] == -3) bingo = true;
	if(b[0][0] + b[1][1] + b[2][2] == -3) bingo = true;
	if(b[2][0] + b[1][1] + b[0][2] == -3) bingo = true;
	if(bingo) cout << "Yes"; else cout << "No";
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws Exception{
    FastScanner sc = new FastScanner(System.in);
    int r = sc.nextInt();
    new Solution(r);
  }
}

class Solution {
  public Solution(int r) {
    System.out.println(r * 2 * Math.PI);
    // System.out.println(res);
  }
}

class FastScanner {
  private final InputStream in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  public FastScanner(InputStream source) {
    in = source;
  }

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) return buffer[ptr++];
    else return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext()) throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
      throw new NumberFormatException();
    return (int) nl;
  }

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


Measured memory_bytes: 33208
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 1e9+7;
struct UnionFind {
vector<int> d;
UnionFind(int n): d(n, -1) {}
int root(int x) {
if(d[x] < 0) return x;
return d[x] = root(d[x]);
}
bool unite(int x, int y) {
x = root(x); y = root(y);
if(x == y) return false;
if(d[x] > d[y]) swap(x, y);
d[x] += d[y];
d[y] = x;
return true;
}
bool same(int x, int y) {return (root(x) == root(y));}
int size(int x) {return -d[root(x)];}
};
signed main(){
    
    int n,m;
    cin >> n >> m;
    UnionFind uf = UnionFind(n);
    rep(i,m) {
        int x,y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x,y);
    }
    set<int> st;
    rep(i,n) {
        st.insert(uf.root(i));
    }
    cout << max((int)0,(int)st.size()-1) << endl;
    return 0;
}


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

using namespace std;
const int maxn = 4e5 + 100;
int s[maxn], vis[maxn], fa[maxn];
int cnt = 0;
struct node {
    int from, to, cost, pos;
} e[maxn], ss[maxn];

bool cmp1(node a, node b) {
    return a.from < b.from;
}

bool cmp2(node a, node b) {
    return a.to < b.to;
}

bool cmp3(node a, node b) {
    return a.cost < b.cost;
}

int findd(int x) {
    return x == fa[x] ? x : fa[x] = findd(fa[x]);
}

int uni(int x, int y) {
    int p1 = findd(x), p2 = findd(y);
    if (p1 == p2) return 1;
    fa[p2] = p1;
    return 0;
}

void init() {
    for (int i = 0; i < maxn; i++) {
        fa[i] = i;
    }
}

int main() {
    int n;
    cin >> n;
    init();
    for (int i = 0; i < n; i++) {
        cin >> ss[i].from >> ss[i].to;
        ss[i].pos = i;
    }

    sort(ss, ss + n, cmp1);
    for (int i = 1; i < n; i++) {
        e[cnt].from = ss[i].pos;
        e[cnt].to = ss[i - 1].pos;
        e[cnt++].cost = abs(ss[i].from - ss[i - 1].from);
    }
    sort(ss, ss + n, cmp2);
    for (int i = 1; i < n ; i++) {
        e[cnt].from = ss[i].pos;
        e[cnt].to = ss[i - 1].pos;
        e[cnt++].cost = abs(ss[i].to - ss[i - 1].to);
    }
    sort(e, e + cnt, cmp3);
    long long ans = 0;
    for (int i = 0; i < cnt; i++) {
        if (!uni(e[i].from, e[i].to)) {
            ans += e[i].cost;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,k;cin>>n>>k;
    int a[n];rep(i,n)cin>>a[i];
    int l[n][k+1],r[n][k+1];
    memset(l,0,sizeof(l));
    memset(r,0,sizeof(r));
    l[0][0]=1;
    r[0][0]=1;
    rep(i,n-1){
        rep(j,k+1){
            if(l[i][j]){
                l[i+1][j]=1;
                l[i+1][min(k,j+a[i])]=1;
            }
            if(r[i][j]){
                r[i+1][j]=1;
                r[i+1][min(k,j+a[n-1-i])]=1;
            }
        }
    }
    int ans=0;
    rep(i,n){
        int lsum[k+1]={};
        int rsum[k+1]={};
        rep(j,k){
            lsum[j+1]=lsum[j]+l[i][j];
            rsum[j+1]=rsum[j]+r[n-1-i][j];
        }
        rep(j,k){
            if(lsum[j+1]-lsum[j]){
                int L=max(0,k-a[i]-j);
                int R=k-1-j;
                if(rsum[R+1]-rsum[L])break;
            }
            if(j==k-1)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 195712
N,D = map(int,input().split())
xs = [list(map(int,input().split())) for _ in range(N)]

cnt = 0
zizyou = [x**2 for x in range(128)]

for i in range(len(xs)-1):
    for j in range(i+1,len(xs)):
        s = 0
        for d in range(D):
            s += (xs[i][d]-xs[j][d])**2
        
        if s in zizyou:
#             print(i,j,s)
            cnt+=1

print(cnt)

Measured memory_bytes: 38384
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

class Main {
	public static void main(String[] a) throws IOException {

		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		for (int i = 0; i < times; i++) {
			int aa = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();

			int twoa = aa * aa;
			int twob = b * b;
			int twoc = c * c;
			if (twoa == twoc + twob) {

				System.out.println("YES");
			} else if (twob == twoc + twoa) {
				System.out.println("YES");
			} else if (twoc == twob + twoa) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 32620
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 4e6;
bitset<N + 5> dp;

void hora(int tc) {
	int n;
	cin>>n;
	dp[0] = 1;
	int tot = 0;
	for(int i = 0;i < n;i++) {
		int x;
		cin>>x;
		dp |= (dp << x);
		tot += x;
	}
	for(int i = (tot + 1) / 2;i <= tot;i++) {
		if(dp[i] == 1) {
			cout<<i<<endl;
			return ;
		}
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner scan = new Scanner(System.in)) {
			int N = scan.nextInt();
			int P = scan.nextInt();
			int Q = scan.nextInt();
			int[] score = new int[N];
			
			for (int i = 0; i < N; i++) {
				score[i]=P-Q;
			}
			
			for (int i = 0; i < Q; i++) {
				int a = scan.nextInt();
				score[a-1]++;
			}

			for (int i = 0; i < N; i++) {
				if(score[i] > 0) {
					System.out.println("Yes");
				} else {
					System.out.println("No");					
				}
			}
			

		}
	}
}

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

using namespace std;
using ll = long long;



int n;


ll solve()
{
    int cnt = 0;
    ll  sum = 0;
    for (int i = 1; i <= n; i++)     
    {
        if(i % 3 != 0 && i % 5 != 0){
            
            cnt++;
            sum += i;
            
        }

    }
    return sum;
    
}

int main()
{
    cin >> n;
    
    cout << solve() << endl;


    return EXIT_SUCCESS;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] t = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++){
			t[i] = sc.nextInt();
			sum += t[i]; 
		}
		int m = sc.nextInt();
		for(int i = 0; i < m; i++){
			int p = sc.nextInt();
			int x = sc.nextInt();
			int goukei = sum - t[p-1] + x;
			System.out.println(goukei);
		}
	}
}


Measured memory_bytes: 21460
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(void)
{
	int i, j;
	int w, h;
	int x[10010];
	int y[10010];
	int xm, ym;
	int n;
	int ans;
	
	scanf("%d %d %d", &w, &h, &n);
	
	for (i = 0; i < n; i++){
		scanf("%d %d", &x[i], &y[i]);
	}
	ans = 0;
	for (i = 0; i < n - 1; i++){
		xm = x[i] - x[i + 1];
		ym = y[i] - y[i + 1];
		if (xm >= 0 && ym >= 0 || xm <= 0 && ym <= 0){
			ans += max(abs(xm), abs(ym));
		}
		else {
			ans += abs(xm) + abs(ym);
		}
	}
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 1044
N = int(input())
a = 0
w = 0
t = 0
r = 0
S = []
for _ in range(N):
    S.append(str(input()))

for s in S:
    if s == 'AC':
        a += 1
    elif s == 'WA':
        w += 1
    elif s == 'TLE':
        t += 1
    else:
        r += 1
print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(t))
print('RE x '+str(r))


Measured memory_bytes: 16176
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<deque>
#include<functional>
#include<ctime>
#include<cassert>
#include<cstring>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double ld;
typedef vector<int> vi;

template<class T> bool uin(T &a, T b){ return (a > b ? a = b, true : false); }
template<class T> bool uax(T &a, T b){ return (a < b ? a = b, true : false); }

/////////////////////////////////
int const S = 1e7;
int const MOD = 1e9 + 7;
int const N = 3e7 + 41;

int s, ans;
int len[N];

void add(int &a, int b){
	a += b;
	while(a >= MOD) a -= MOD;
	while(a < 0) a += MOD;
}

int mul(int a, int b){
	return (ll) a * b % MOD;
}

vi getdiv(int n){
	vi res;
	for(int i=1;i*i<=n;++i){
		if(n % i == 0){
			res.pb(i);
			if(n / i != i) res.pb(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

int bp(int x, int d){
	int res = 1;
	while(d){
		if(d&1) res = mul(res, x);
		x = mul(x, x);
		d >>= 1;
	}
	return res;
}

int f(int n){
	return mul(9, bp(10, n-1));
}

int calc(int n){
	int res = 0;
	fi(1, N){
		int a = s - i * n;
		if(a <= 0) break;
		if(a % (n + 1) == 0) ++res;		
	}
	return res;
}

void solve(){
	int m = 1;
	int q = 1;
	while(m < N){
		int n = min(N, m * 10);
		fi(m, n) len[i] = q;
		++q;
		m = n;
	} 	
	int l = 1;
	int r = 1;
	int x = 0;
	while(l < S){
		while(x < s){
			x += len[r];
			++r;
		}		
		if(x == s) ++ans;
		x -= len[l];
		++l;
	}
	vi d = getdiv(s);
	for(int x : d){
		if(x <= 7) continue;
		int a = s / x;
		int v0 = f(x);		
		add(ans, v0 - a + 1);
	}
	fi(8, (s+1)/2 + 1){
		int a = s % i;
		int b = s / i;
		if(a == 0) a = i + 1;
		b -= a;
		if(b <= 0) continue;
		int c = b / (i + 1) + 1;
		if(b % (i + 1) == 0) --c;
		add(ans, c);
//		cerr << i << " c = " << c << " ans = " << calc(i) << endl;
//		assert(calc(i) == c);
	}
}

int main(){
#ifdef LOCAL_DEFINE
	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
#endif
	scanf("%d",&s);	
	solve();		
	printf("%d\n",ans);

	
#ifdef LOCAL_DEFINE
	fprintf(stderr, "ELAPSED TIME: %.3lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 117504
sa = [i for i in input()]
sb = [i for i in input()]
sc = [i for i in input()]
d = {"a":sa, "b":sb, "c":sc}#おのおのの手札をdictで表す
turn = "a"
while(True):#breakするまで続く
    if len(d[turn]) == 0:
        break
    turn = d[turn].pop(0)#一枚減らしつつ，turn替え
print(turn.upper())#upperは大文字にするやつ

Measured memory_bytes: 3064
//! Framework <https://github.com/vain0x/procon>

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

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

// 解説AC

use std::cmp::Reverse;

/// カッコからなる文字列を解析した結果
struct Brackets {
    /// 文字列内に対応する '(' がない ')' の個数。(editorials の A(i))
    down: i64,
    /// 文字列内に対応する ')' がない '(' の個数。(B(i))
    up: i64,
}

fn calc(s: &str) -> Brackets {
    let mut left = 0;
    let mut right = 0;
    let mut down = 0;

    for c in s.chars() {
        match c {
            '(' => left += 1,
            ')' => right += 1,
            _ => unreachable!(),
        };

        down = down.max(right - left);
    }

    let up = left - (right - down);
    Brackets { down, up }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let S = scan.list::<String>(N);

    // '(' が多い、なるべく先に連結したいカッコ列
    let mut good = vec![];
    // ')' が多い、なるべく後まで連結したくないカッコ列
    let mut bad = vec![];

    for s in S {
        let b = calc(&s);
        if b.up > b.down {
            good.push(b);
        } else {
            bad.push(b);
        }
    }

    good.sort_by_key(|b| b.down);
    bad.sort_by_key(|b| Reverse(b.up));

    let mut balance = 0;
    let mut ok = true;
    for &Brackets { down, up } in good.iter().chain(&bad) {
        if balance < 0 || balance < down {
            ok = false;
            break;
        }

        balance -= down;
        balance += up;
    }
    ok = ok && balance == 0;

    println!("{}", if ok { "Yes" } else { "No" });
}


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

int main(){
    ios::sync_with_stdio(false);cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    const long long inf = 1e5+7;
    const long long INF  = 1e9+7;
    vector<long long> h(n+k-1);
    vector<long long> dp(n+k-1);
    for(int i = 0; i < k-1; i ++){
        dp[i] = inf;
        h[i] = inf;
    }
    for(int i = k-1; i < n+k-1; i++){
        cin >> h[i];
    }
    dp[k-1] = 0;;
    for(int i = k; i < n+k-1;i++){
        long long minq = INF;
        for(int j = 1; j <= k; j++){
            minq = min(minq,dp[i-j]+abs(h[i] - h[i-j]));
        }
        dp[i] = minq;
    }
    cout << dp[n+k-2];
    return 0;
}


Measured memory_bytes: 1792
/**
 *    author:  FromDihPout
 *    created: 2020-06-21
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, t;
    cin >> n >> t;
    if (t < 2) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<pair<int,int>>min_pref(n), max_suff(n);
    min_pref[0] = {a[0], 0};
    for (int i = 1; i < n; i++) {
        if (a[i] <= min_pref[i - 1].first) {
            min_pref[i] = {a[i], i};
        }
        else {
            min_pref[i] = min_pref[i - 1];
        }
    }
    max_suff[n - 1] = {a[n - 1], n - 1};
    for (int i = n - 2; i >= 0; i--) {
        if (a[i] >= max_suff[i + 1].first) {
            max_suff[i] = {a[i], i};
        }
        else {
            max_suff[i] = max_suff[i + 1];
        }
    }
    
    int max_diff = 0;
    for (int i = 0; i < n - 1; i++) {
        max_diff = max(max_diff, max_suff[i + 1].first - min_pref[i].first);
    }

    set<int> buy_index, sell_index;
    for (int i = 0; i < n - 1; i++) {
        if (max_suff[i + 1].first - min_pref[i].first == max_diff) {
            buy_index.insert(min_pref[i].first);
            sell_index.insert(max_suff[i + 1].first);
        }
    }
    cout << min(buy_index.size(), sell_index.size()) << endl;
}

Measured memory_bytes: 9768
#include <bits/stdc++.h>
using namespace std;
using node= pair<int, int>;
using edge= pair<int64_t, node>;
using Graph= vector<vector<vector<edge>>>;

void solve(const Graph &gph, node s, vector<vector<int64_t>> *dist){
  using path= edge;
  const int S_MAX= gph.at(0).size()- 1;

  priority_queue<path, vector<path>, greater<path>> pq;
  pq.push(make_pair(0, s));
  while(!pq.empty()){
    int64_t time; node n_from; int from,silver;
    tie(time, n_from)= pq.top();
    tie(from, silver)= n_from;
    pq.pop();

    if(dist->at(from).at(silver) <= time){ continue; }
    else{
      dist->at(from).at(silver)= time;
      for(auto e_to:gph.at(from).at(silver)){
        int64_t time_to; node n_to;
        tie(time_to, n_to)= e_to;
        pq.push(make_pair(time+ time_to, n_to));
      }
    }
  }
}

int main(){
  int N,M,S0;
  cin >> N >> M >> S0;

  const int FARE_MAX= 50;
  const int S_MAX= FARE_MAX* (N-1);

  Graph gph(N, vector<vector<edge>>(S_MAX+ 1));

  int v1,v2,fare; int64_t time;
  for(int j=0; j<M; j++){
    cin >> v1 >> v2 >> fare >> time;
    v1--; v2--; // 1-indexed -> 0-indexed
    for(int s=fare; s<= S_MAX; s++){
      gph.at(v1).at(s).emplace_back(make_pair(time, make_pair(v2, s-fare)));
      gph.at(v2).at(s).emplace_back(make_pair(time, make_pair(v1, s-fare)));
    }
  }
  int rate;
  for(int v=0; v<N; v++){
    cin >> rate >> time;
    for(int s=0; s<S_MAX; s++){
      gph.at(v).at(s).emplace_back(make_pair(time, make_pair(v, min(s+rate, S_MAX))));
    }
  }

  vector<vector<int64_t>> dist(N, vector<int64_t>(S_MAX+1, INT64_MAX));
  solve(gph, make_pair(0, min(S0, S_MAX)), &dist);

  vector<int64_t> ans(N, INT64_MAX);
  for(int v=0; v<N; v++){
    for(int s=0; s<= S_MAX; s++){
      ans.at(v)= min(ans.at(v), dist.at(v).at(s));
    }
  }

  for(int v=1; v<N; v++){
    cout << ans.at(v) << endl;
  }
}

Measured memory_bytes: 25668
/*
     ॐ त्र्यम्बकं यजामहे सुगन्धिं पुष्टिवर्धनम् |
     उर्वारुकमिव बन्धनान्मृत्योर्मुक्षीय माऽमृतात् ||
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

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...);
}

const int N = 200005;

void solve()
{
     double x;
     double pie = 4 * atan(1);
     cin >> x;
     double ans = 2 * pie * x;
     cout << ans;

}

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

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint c(n);
  rep(i, n) cin >> c[i];
  int q;
  cin >> q;
  vint box(n, 0);
  rep(i, q) {
    int t, x, d;
    cin >> t >> x >> d;
    --x;
    if(t == 1) {
      box[x] += d;
      if(box[x] > c[x]) {
	cout << x+1 << endl;
	return 0;
      }
    } else {
      box[x] -= d;
      if(box[x] < 0) {
	cout << x+1 << endl;
	return 0;
      }
    }
  }
  cout << 0 << endl;

  return 0;
}



Measured memory_bytes: 3240
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]

B = [list(bin(i)[2:].zfill(10)) for i in range(1, 1024)]

ans = - float("inf")
for i in range(1023):
    # joisinoお姉ちゃんの店の開店状況
    score = 0
    for j in range(N):
        # 商店街の各お店の開店状況
        open_store = 0
        for k in range(10):
            if B[i][k]=="1" and F[j][k]==1:
                open_store += 1
        score += P[j][open_store]
    if score > ans:
        ans = score
print(ans)

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

int A[200005];
int B[200005];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        B[i]=A[i];
    }
    sort(B,B+n);
    int b=B[n/2];
    int a=B[(n-1)/2];
    if(a==b)
    {
        for(int i=0;i<n;i++)
            cout<<a<<endl;
    }
    else
    {
        for(int i=0;i<n;i++)
        {
            //cout<<a<<" "<<b<<" : "<<A[i]<<endl;
            if(A[i]<b)
                cout<<b<<endl;
            else if(A[i]>a)
                cout<<a<<endl;
        }
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    string S1,S2;
    cin >> S1 >> S2;
    
    if(S1[0] == S2[2] && S1[1] == S2[1] && S1[2] == S2[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

void swap(int *, int *);

int main(void) {
    int i, n, x, y, z;
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d %d %d", &x, &y, &z);
        swap(&x, &y), swap(&y, &z), swap(&x, &y);
        printf("%s\n", x * x + y * y - z * z ? "NO" : "YES");
    }
    return 0;
}

void swap(int *a, int *b) {
    if(*a > *b) {
        *a ^= *b;
        *b ^= *a;
        *a ^= *b;
    }
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 5e18;
typedef pair<ll,ll> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

ll N, K;

ll solve(vector<PII> P)
{
    ll ans = INFLL;
    for (int i=0; i<=N-K; i++) {
        ll min_x = INFLL, max_x = -INFLL, min_y = INFLL, max_y = -INFLL;
        rep(j, K) {
            min_x = min(min_x, P[i + j].first);
            max_x = max(max_x, P[i + j].first);
            min_y = min(min_y, P[i + j].second);
            max_y = max(max_y, P[i + j].second);
        }
        ans = min(ans, (max_x - min_x) * (max_y - min_y));
    }
    return ans;
}

int compress(vector<ll> x, map<ll,ll> &zip, vector<ll> &unzip)
{
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    unzip.resize(x.size());
    
    for (int i=0; i<x.size(); i++) {
        zip[x[i]] = i;
        unzip[i] = x[i];
    }
    return x.size();
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> N >> K;
    vector<PII> P(N);
    vector<ll> X(N), Y(N);
    rep(i, N) {
        cin >> P[i].first >> P[i].second;
        X[i] = P[i].first;
        Y[i] = P[i].second;
    }

    map<ll, ll> zip_x, zip_y;
    vector<ll> unzip_x, unzip_y;

    int W = compress(X, zip_x, unzip_x);
    int H = compress(Y, zip_y, unzip_y);

    vector<vector<bool>> Q(H, vector<bool>(W));
    rep(i, N) {
        Q[zip_y[P[i].second]][zip_x[P[i].first]] = true;
    }

    vector<vector<int>> sum(H+1, vector<int>(W+1));
    rep(y, H) rep(x, W) {
        sum[y+1][x+1] = sum[y][x+1] + sum[y+1][x] - sum[y][x] + Q[y][x];
    }

    ll ans = INFLL;
    rep(ay, H) rep(by, H) rep(ax, W) rep(bx, W) {
        if (ax > bx || ay > by) continue;
        int num = sum[by+1][bx+1] - sum[ay][bx+1] - sum[by+1][ax] + sum[ay][ax];
        if (num >= K) ans = min(ans, ((ll)unzip_x[bx] - unzip_x[ax]) * ((ll)unzip_y[by] - unzip_y[ay]));
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = Integer.parseInt(scanner.nextLine());
		
		long num;
		int result = 0;

		for (int i = 0; i < n; i++) {
			num = Long.parseLong(scanner.nextLine());
			
			if (isPrime(num)) {
				result++;
			}
			
		}
		
		
		
		System.out.println(result);
	}
	
	static boolean isPrime(long x) {
		boolean result = true;
		
		if (x == 2) {
			return result;
		}

		for (long j = 2; j <= Math.ceil(Math.sqrt(x)) ; j++) {
			
			if (x % j == 0) {
				result = false;
				
				break;
			}
		}
		
		
		return result;
	}
}


Measured memory_bytes: 63528
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            StringBuilder stringBuilder = new StringBuilder();
            
            String line;
            int index = 1;
            while((line = br.readLine()) != null){
            	if(line.equals("0")) break;
            	stringBuilder.append("Case " + index + ": " + line + "\n");
            	++index;
            }
            System.out.print(stringBuilder);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int h,w,d;
  cin >> h >> w >> d;
  vector<P> v(h*w+1);
  REP(i,h){
    REP(j,w){
      int x;cin >> x;
      v[x] = make_pair(i,j);
    }
  }
  vector<ll> s(h*w+1);
  REP(i,d+1)s[i] = 0;
  for(int i = d+1;i <= h*w;i++){
    s[i] = s[i-d] + abs(v[i].first-v[i-d].first) + abs(v[i].second-v[i-d].second);
  }
  int Q;
  cin >> Q;
  REP(i,Q){
    int l,r;cin >> l >> r;
    cout << s[r]-s[l] << endl;
  }

  





  return 0;
}

Measured memory_bytes: 2560
c=[list(map(int,list(input().split()))) for _ in range(3)]
a=[0]*3
b=[0]*3

for i in range(3):
    b[i]=c[0][i]-a[0]
a[1]=c[1][0]-b[0]
a[2]=c[2][0]-b[0]

ans="Yes"
for i in range(3):
    for j in range(3):
        if c[i][j]!=a[i]+b[j]:
            ans="No"
            break
print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll r;cin>>r;
	cout<<3*r*r;
}


Measured memory_bytes: 256
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------
N, M = map(int, input().split())

G=[[] for _ in range(N+1) ]			#=> [[], [], [], [], [], [], [], []]
for _ in range(M):
	u,v = map(int, input().split())
	G[u].append(v)

S, T = map(int, input().split())

#p("N,M",N,M)
#p("G",G)
#p("S,T",S,T)


# 訪問済み＆移動数の記録用マップ、Visitedを作る。未訪問は-1
# 3倍になる頂点を抽出するために、3ヵ所の記録が出来るよう「-1」を3つ準備する
V=[ [-1,-1,-1] for _ in range(N+1) ]			#=> [ [-1,-1,-1], [-1,-1,-1], ... [-1,-1,-1] ]
V[S][0]=0

# キューに行き先候補を入れて、
from collections import deque
Q = deque()
Q.append([S,0])

while Q:
	sv = Q[0][0]
	sl = Q[0][1]
	Q.popleft()
	
	for tv in G[sv]:
		tl = (sl+1)%3
		b = (V[tv][tl]==-1)									# 未訪問である
		#b = b or (V[tv][tl]>V[sv][sl]+1)		# より短いステップ数である(＝既存の方が大きい)
		if b:
			V[tv][tl] = V[sv][sl]+1		# 訪問ステップ数の記録
			Q.append([tv,tl])					# 次の訪問先として、キューに追加

ans = V[T][0]
if ans > -1: ans //= 3
print(ans)


Measured memory_bytes: 38036
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int q = in.nextInt();
		while (q-- > 0) {
			String s = in.next();
			String t = in.next();
			int[] cnt = new int[4];
			int n = s.length();
			for (int i=0; i<n; i++) {
				if (s.charAt(i) == 'm') {
					if (i == 0 || !('2' <= s.charAt(i-1) && s.charAt(i-1) <= '9')) cnt[0]++;
					else cnt[0] += s.charAt(i-1) - '0';
				} else if (s.charAt(i) == 'c') {
					if (i == 0 || !('2' <= s.charAt(i-1) && s.charAt(i-1) <= '9')) cnt[1]++;
					else cnt[1] += s.charAt(i-1) - '0';
				} else if (s.charAt(i) == 'x') {
					if (i == 0 || !('2' <= s.charAt(i-1) && s.charAt(i-1) <= '9')) cnt[2]++;
					else cnt[2] += s.charAt(i-1) - '0';
				} else if (s.charAt(i) == 'i') {
					if (i == 0 || !('2' <= s.charAt(i-1) && s.charAt(i-1) <= '9')) cnt[3]++;
					else cnt[3] += s.charAt(i-1) - '0';
				}
			}

			dump(cnt);

			int m = t.length();
			for (int i=0; i<m; i++) {
				if (t.charAt(i) == 'm') {
					if (i == 0 || !('2' <= t.charAt(i-1) && t.charAt(i-1) <= '9')) cnt[0]++;
					else cnt[0] += t.charAt(i-1) - '0';
				} else if (t.charAt(i) == 'c') {
					if (i == 0 || !('2' <= t.charAt(i-1) && t.charAt(i-1) <= '9')) cnt[1]++;
					else cnt[1] += t.charAt(i-1) - '0';
				} else if (t.charAt(i) == 'x') {
					if (i == 0 || !('2' <= t.charAt(i-1) && t.charAt(i-1) <= '9')) cnt[2]++;
					else cnt[2] += t.charAt(i-1) - '0';
				} else if (t.charAt(i) == 'i') {
					if (i == 0 || !('2' <= t.charAt(i-1) && t.charAt(i-1) <= '9')) cnt[3]++;
					else cnt[3] += t.charAt(i-1) - '0';
				}
			}

			dump(cnt);

			for (int i=3; i>0; i--) {
				while (cnt[i] >= 10) {
					cnt[i-1] += cnt[i]/10;
					cnt[i] = cnt[i]%10;
				}
			}

			dump(cnt);

			StringBuilder ans = new StringBuilder();
			if (cnt[0] != 0) {
				ans.append((cnt[0] == 1 ? "" : cnt[0]) + "m");
			}
			if (cnt[1] != 0) {
				ans.append((cnt[1] == 1 ? "" : cnt[1]) + "c");
			}
			if (cnt[2] != 0) {
				ans.append((cnt[2] == 1 ? "" : cnt[2]) + "x");
			}
			if (cnt[3] != 0) {
				ans.append((cnt[3] == 1 ? "" : cnt[3]) + "i");
			}
			out.println(ans);
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 36772
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 入力
        int a = Integer.parseInt(sc.next()); // +1
        int b = Integer.parseInt(sc.next()); // 0
        int c = Integer.parseInt(sc.next()); // -1
        int k = Integer.parseInt(sc.next());

        // 出力
        int num = 0;
        int count = 0;
        outside: {
            for (int i = 0; i < a; i++) {
                if (count == k) {
                    break outside;
                }
                num++;
                count++;
            }
            for (int i = 0; i < b; i++) {
                if (count == k) {
                    break outside;
                }
                count++;
            }
            for (int i = 0; i < c; i++) {
                if (count == k) {
                    break outside;
                }
                num--;
                count++;
            }
        }
        System.out.println(num);
    }
}


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

using namespace std;

int sumOfDigits(int n){
    int sum = 0;
    while(n > 0){
        sum += n %10;
        n /= 10;
    }
    return sum;
}


int main(){
    int N, A, B;

    cin >> N >> A >> B;

    int res = 0;
    for(int i = 1; i <= N; i++){
        int sum = sumOfDigits(i);
        if (sum >= A && sum <= B)
            res += i;
    }

    cout << res << endl;

    return 0;

}



Measured memory_bytes: 256
from collections import defaultdict
mod = 10**9 + 7
n, k = map(int, input().split())
l = defaultdict(int)
for i in reversed(range(1, k+1)):
    l[i] = pow(k//i, n, mod)
    a = 2
    while a*i<=k:
        l[i] -= l[a*i]
        l[i] %= mod
        a += 1
ans = 0
for j in l:
    ans += j*l[j] % mod
    ans %= mod
print(ans)

Measured memory_bytes: 82656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int[] A = new int[N];
			for(int i = 0; i < A.length; i++) {
				A[i] = in.nextInt();
			}
			Arrays.sort(A);
			int tmp;
			for(int i = A.length - 1; i > 0; i--) {
				while((tmp = A[i] % A[i - 1]) != 0) {
					A[i] = A[i - 1];
					A[i - 1] = tmp;
				}	
			}
			
			out.println(A[0]);
		}
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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


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

int main(void){
  int N,Q;
  string S;
  vector<int> AC(N);
  cin>>N>>Q>>S;
  AC.at(0)=0;
  for(int i=0;i<N-1;i++){
    if(S.at(i)=='A' && S.at(i+1)=='C'){
      AC.at(i+1)=AC.at(i)+1;
    }
    else AC.at(i+1)=AC.at(i);
  }
 
  for(int q=0;q<Q;q++){
    int l,r;
    cin >> l >> r;
    cout<<AC.at(r-1)-AC.at(l-1)<<endl;
  }
}
    

Measured memory_bytes: 25728
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int num[100]={};
    int N,K;
    cin >> N >> K;
    for(int i=0; i<K; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >>a;
            a--;
            if(num[a]==0){
                N--;
            }
            num[a]++;
        }
    }
    cout<<N<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
using namespace std;
int a[200005],b[200005];
int main()
{
    int n;
    scanf("%d",&n);
    memset(b,0,sizeof(b));
    for(int i=2; i<=n; i++)
    {
        scanf("%d",&a[i]);
        b[a[i]]++;
    }
    for(int i=1; i<=n; i++)
    {
        printf("%d\n",b[i]);
    }
    return 0;
}


Measured memory_bytes: 5312
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
int fact[10000];
int power(int a,int b)
{
	if(b==0)
	   return 1;
	else
	{
		int r=power(a,b/2);
		if(b%2==0)
		{
			return (r*r)%mod;
		}
		else
		{
			int x=(r*r)%mod;
			return (a*x)%mod;
		}
	}
}
void function2()
{
	fact[0]=1;
	int j;
	for(j=1;j<10000;j++)
	{
		fact[j]=(j*fact[j-1])%mod;
	}
}
int ncr(int n,int r)
{
	if(n<0||r<0||n<r)
	   return 0;
    int answer=1;
    answer=fact[n];
    answer*=power(fact[r],mod-2);
    answer=answer%mod;
    answer*=power(fact[n-r],mod-2);
    answer=answer%mod;
    return answer;
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     function2();
     int n,k;
     cin>>n>>k;
     int i;
     for(i=1;i<=k;i++)
     {
		 int here=ncr(k-1,i-1);
		 here*=ncr(n-k+1,i);
		 here%=mod;
		 cout<<here<<endl;
	 }
}


Measured memory_bytes: 3688
#include <iostream>

using namespace std;

int main(void){
    int N, Ar[200002], a[200002], count, total=0, displayed=0;
    cin >> N;
    for(int i = 1; i <= N; i++){
        Ar[i]=0;
        cin >> a[i];
    }
    for(int i = N; i > 0; i--){
        count = 0;
        for(int j = N/i; j>1; j--) count+=Ar[i*j];
        if(count%2!=a[i]){
            Ar[i] = 1;
            total++;
        }
    }
    cout << total <<endl;
    for(int i = 1; i <= N; i++){
        displayed++;
        if(Ar[i] ==1){
            if(displayed==total) cout << i << endl;
            else cout << i << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin>>N;
  int64_t sum=0;
  for(int i=0;i<N.length();i++){
    sum+=N.at(i)-'0';
  }
  if(sum%9==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

string a,b="CF"; 
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){ 
            bl++;
            if(bl==2)   
                break;
        }
    if(bl==2) cout<<"Yes"; 
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256