akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <ctype.h>

int DAY(int y, int m, int d) {

  int day;
  int a,b;
  int x,z;

  a = y/3;
  b = y%3;

  if(b != 0){                           //普通の年
    day = a * 200;                      //生れるまで経過した閏年の日数を加算
    day = day + (((a*2) + (b-1)) * 195);//生れるまで経過した普通の年の日数を加算

    x = m/2;
    z = m%2;

    if(x != 0){                         //1月ではない場合
      if(z == 0){                       //誕生月は偶数の場合
	day = day +((x-1) * 20);        //経過した偶数月の日数を加算
	day = day + (x * 19) +1;        //経過した奇数月の日数を加算
      }else{
	day = day + (x * 20);           ///誕生月は奇数の場合の誕生月までの月数を加算
	day = day + (x * 19);
      }
    }	
    day = day + d;                  //誕生日までの日数を加算
  }else{                                //閏年
    day = day + ((a-1) * 200);          //生れるまで経過した閏年の日数を加算
    day = day + ((y - a) * 195);        //生れるまで経過した普通の年の日数を加算
    day = day + ((m-1) * 20);           //誕生月までの日数を加算
    day = day + d;                      //誕生日までの日数を加算
  }
return day;
}

int main(void) {
  int n,i;
  int burn_Y,burn_M,burn_D;
  int day[100];

  scanf("%d",&n);                     

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

    if(burn_Y >=1000 || burn_M > 10 || burn_D > 20){
      break;
    }                                    //不適切な数字が入力された場合ループ終了

    day[i] = 196471 - DAY(burn_Y,burn_M,burn_D);
  }                                      //1000年1月1日まで196471日を経過したので
                                         //引き算し　誕生してから今日までの日数を算出

  for(i=0;i<n;i++){                      //出力
    printf("%d\n", day[i]);
  }

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define INF 1e9

int X,Y;
vector<vector<int>> s;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
using P = pair<int,int>;

int solve(int y, int x, set<P> st){
    if((int)st.size() > 10) return INF;
    int res = INF;
    rep(k,4){
        int d = 1;
        while(true){
            int ny = y+d*dy[k], nx = x+d*dx[k];
            if(!(ny>=0 && nx>=0 && ny<Y && nx<X)) break;
            if(s[ny][nx] == 3) return st.size();
            if(s[ny][nx] == 1 && st.count({ny,nx})==0){
                if(d > 1){
                    st.insert({ny,nx});
                    res = min(solve(ny-dy[k],nx-dx[k],st),res);
                    st.erase({ny,nx});
                }
                break;
            }
            d++;
        }
    }
    return res;
}

int main(void){
    while(cin>>X>>Y, X|Y){
        s.clear(); s.resize(Y);
        int sy=0,sx=0;
        rep(y,Y){
            s[y].resize(X);
            rep(x,X){
                cin>>s[y][x];
                if(s[y][x] == 2) sy = y, sx = x;
            }
        }
        int res = solve(sy,sx,{{sy,sx}});
        cout<<(res>10 ? -1 : res)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b; cin >> a >> b;
    if(a>= 13)cout << b << endl;
    else if(a<=5)cout << 0 << endl;
    else cout << b/2 << endl; 
    return 0;
}

Measured memory_bytes: 256
t = list(map(str, input().split())) 
s=t[0]

s1=int(s[0]+s[1])
s2=int(s[2]+s[3])

b1 = (s1>=1 and s1<=12)
b2 = (s2>=1 and s2<=12)

if(b1 and b2):
    print("AMBIGUOUS")
elif(b1 and not b2):
    print("MMYY")
elif(not b1 and b2):
    print("YYMM")
else:
    print("NA")

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

struct DSU { vector<int> par; vector<int> sz; int n; DSU(int n) : par(n+1), sz(n+1), n(n) { for (int i = 0; i <= n; i++) sz[i] = 1, par[i] = i; }
int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); } void uni(int x, int y) { int px = find(x), py = find(y); if (px == py) return; if (sz[px] < sz[py]) return uni(py, px); par[py] = px, sz[px] += sz[py]; } };


struct subset
{
	int parent,sz;
};
vector< subset> subsets;
int Find( int i)
{
    if (subsets[i].parent != i)
        subsets[i].parent = Find(subsets[i].parent);

    return subsets[i].parent;
}


void uniona(int x, int y){
    int xroot = Find( x);
    int yroot = Find( y);
    if (subsets[xroot].sz < subsets[yroot].sz){
        subsets[xroot].parent = yroot;
        subsets[yroot].sz += subsets[xroot].sz;
    }
    else{
        subsets[yroot].parent = xroot;
        subsets[xroot].sz += subsets[yroot].sz;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>v1,v2;
    int k=9;
    while(k<=100000){
        v1.push_back(k);
        k=k*9;
    }
    k=6;
    while(k<=100000){
        v2.push_back(k);
        k=k*6;
    }
    int res=1e9;
    v1.push_back(1);
    v2.push_back(1);
    sort(v1.rbegin(),v1.rend());

    sort(v2.rbegin(),v2.rend());

    for(int i=0;i<=n;i++){
        int ans=0;
        int a1=i;
        int a2=n-i;
        while(a1>0){
            for(int l=0;l<v2.size();l++){
                if(a1-v2[l]>=0){
                    ans++;
                    a1-=v2[l];
                    break;
                }
            }
        }
        while(a2>0){
            for(int l=0;l<v1.size();l++){
                if(a2-v1[l]>=0){
                    ans++;
                    a2-=v1[l];
                    break;
                }
            }
        }
        res=min(res,ans);
    }
    cout<<res<<endl;
    return 0;
    }


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmin(T &_a, T _b){
    if(_a > _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

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

    int k;
    cin >> k;

    vector<int> cost(k, IINF);
    deque< P > deq;
    deq.push_back({1 % k, 1});
    while(!deq.empty()){
        P now = deq.front();
        deq.pop_front();
        if(!chmin(cost[now.first], now.second)){
            continue;
        }
        if(cost[(now.first * 10) % k] > now.second){
            deq.push_front({(now.first * 10) % k, now.second});
        }
        if(cost[(now.first + 1) % k] > now.second + 1){
            deq.push_back({(now.first + 1) % k, now.second + 1});
        }
    }

    cout << cost[0] << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int M, N;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] * 4 * M >= sum) {
            cnt++;
        }
    }

    cout << (cnt >= M ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

i64 compute_cost(int col, vector<i64>& xs, i64 d)
{
	const int n = xs.size();
	i64 cost = d * (col + n);

	for(int i = n - 1; i >= 0; --i) {

		int k = (n - 1 - i) / col;
		i64 r = k * 2 + 3;
		if(k == 0)
			r += 2;

		cost += r * xs[i];
	}

	return cost;
}

int main()
{
	int n;
	i64 d;
	vector<i64> xs;

	scanf("%d%lld", &n, &d);
	xs.resize(n);
	for(int i = 0; i < n; ++i) {
		scanf("%lld", &xs[i]);
	}

	int l = 1, r = n;

	while(r - l > 20) {

		int m1 = l + (r - l) / 3;
		int m2 = l + (r - l) * 2 / 3;

		i64 c1 = compute_cost(m1, xs, d);
		i64 c2 = compute_cost(m2, xs, d);

		if(c1 < c2) {
			r = m2;
		} else if(c1 > c2) {
			l = m1;
		} else {
			l = m1;
			r = m2;
		}
	}

	i64 ans = 1e18;
	for(int i = l; i <= r; ++i) {
		i64 c = compute_cost(i, xs, d);
		ans = min(ans, c);
	}

	printf("%lld\n", ans);

	return 0;
}

/* waffle */


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

int main() {
  long a=0,b=0,ans=0;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++) {
    if(s.at(i)=='>') {
      if(i==0) {
        b=1;
      } else {
        if(s.at(i-1)=='<') b=0;
        else b++;
        if(a==b) b++;
      };
      ans+=b;
    } else {
      a++;
      if(i!=0){
        if(s.at(i-1)=='>') a=1,b=0;
      };
      b++;
      ans+=b;
    };
  };
  cout << ans << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	const ll total = accumulate(a.begin(), a.end(), 0ll);
	ll sum = 0, answer = 1000000000000000000ll;
	for(int i = 0; i + 1 < n; ++i){
		sum += a[i];
		const ll a = sum, b = total - sum;
		answer = min(answer, llabs(a - b));
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <sstream>

#define enp     puts("**chkchkchkchkchk**")
#define A       first
#define B       second
#define MP      make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;

const int INF = 0x60000000;
const int MINF = -1000000000;
const ll mod = 1000000007;
const ll cons = 100000000000;
const double pi = 3.141592653589793;

int dy1[9] = { 0, 0, 0, -1, -1, -1, -2, -2, -2 };
int dx1[9] = { 0, -1, -2, 0, -1, -2, 0, -1, -2 };

int dy2[9] = { 0,0,0,1,1,1,2,2,2 };
int dx2[9] = { 0,1,2,0,1,2,0,1,2 };

int main()
{
//	freopen("output.txt", "w", stdout);

/*	int testCases;
	scanf("%d\n", &testCases);
	
	for (int testNum = 1; testNum <= testCases; testNum++)
	{
	//	printf("Case %d: ", testNum);
		

	}*/

	int h, w, n;
	scanf("%d%d%d", &h, &w, &n);

	map < pair <int, int>, int> chk;

	vector < pair <int, int> > dat;

	vector <int> ys, xs;

	for (int i = 0; i < n; i++)
	{
		int y, x;
		scanf("%d%d", &y, &x);
		ys.push_back(y);
		xs.push_back(x);

		dat.push_back(MP(y, x));
	}

	sort(ys.begin(), ys.end());
	sort(xs.begin(), xs.end());

	ys.erase(unique(ys.begin(), ys.end()), ys.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	vector < vector <int> > Set;
	Set.resize(ys.size());

	for (int i = 0; i < dat.size(); i++)
	{
		int y = dat[i].A;
		int x = dat[i].B;

		int t1 = lower_bound(ys.begin(), ys.end(), y) - ys.begin();
		int t2 = lower_bound(xs.begin(), xs.end(), x) - xs.begin();

		Set[t1].push_back(t2);
	}

	for (int i = 0; i < ys.size(); i++)
	{
		sort(Set[i].begin(), Set[i].end());
	}

	ll ans[10] = { 0 };

	for (int i = 0; i < dat.size(); i++)
	{
		int y = dat[i].A;
		int x = dat[i].B;

		for (int j = 0; j < 9; j++)
		{
			int sty = y + dy1[j];
			int stx = x + dx1[j];

			if (sty < 1 || stx < 1 || sty + 2 > h || stx + 2 > w)continue;
			if (chk[MP(sty, stx)] == 1)continue;

			chk[MP(sty, stx)] = 1;

			int cnt = 0;
			for (int k = 0; k < 9; k++)
			{
				int ty = sty + dy2[k];
				int tx = stx + dx2[k];

				int t = lower_bound(ys.begin(), ys.end(), ty) - ys.begin();
				int t2 = lower_bound(xs.begin(), xs.end(), tx) - xs.begin();

				if (t == ys.size() || t2 == xs.size())continue;
				if (ys[t] != ty || xs[t2] != tx)continue;

				if (binary_search(Set[t].begin(),Set[t].end(), t2))cnt++;
			}

			ans[cnt]++;
		}
	}

	ans[0] = ((ll)h - 2)*((ll)w - 2);

	for (int i = 1; i < 10; i++)
	{
		ans[0] -= ans[i];
	}

	for (int i = 0; i < 10; i++)
	{
		printf("%lld\n", ans[i]);
	}

	return 0;
}

Measured memory_bytes: 63464
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{  	ios_base::sync_with_stdio(false); cin.tie(0);
    int n,a,temp;cin>>n;
    ll sum=0,dp[n+1][n+1]={},arr[n+1]={};
    for(int i=1;i<=n;i++){ cin>>arr[i]; sum+=arr[i]; }
    a=(1+n)%2;
    for(int i=n;i>=0;i--)
    { for(int j=i;j<=n;j++)
          { if((i+j)%2==a) { temp=1; } else { temp=0; }
            if(temp==1) {  if(i==j) { dp[i][j]=arr[i]; } else { dp[i][j]=max(arr[i]+dp[i+1][j],arr[j]+dp[i][j-1]); } }
       else if(temp==0) {  if(i==j) { dp[i][j]   =  0; } else { dp[i][j]=min(   dp[i+1][j]    ,  dp[i][j-1]     ); } }
          }
    }
    cout<<2*dp[1][n]-sum;
return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

	int N,D;
	cin>>N>>D;

	int cover = D*2 + 1;

	int count = 0;

	while(N - cover >= 0)
	{
		count++;
		N = N - cover;
		//cout<<N<<endl;
	}

	if(N != 0)
		cout<<count + 1<<endl;

	else
		cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

keta = [-1] * n
fl = 1
for i in range(m):
    a,b = map(int,input().split())
    if keta[a-1] == -1:
        keta[a-1] = b
        
    else:
        if keta[a-1] == b:
            continue
        else:
            fl = 0
            
for i in range(n):
    if i == 0:
        if keta[0] == -1:
            if n == 1:
                keta[0] = 0
            else:
                keta[0] = 1
    else:
        if keta[i] == -1:
            keta[i] = 0

if fl == 0:
    print(-1)
elif keta[0] == 0 and n == 1:
    print(0)
elif keta[0] == 0 and n != 1:
    print(-1)
else:
    a = 0
    for i in range(n):
        a = a *10 + keta[i]
    print(a)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=405,mod=998244353;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int Fac[N],Inv[N],Iv[N];
void prework(){
	int n=N-1;
	Fac[0]=1;
	For(i,1,n)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n]=Pow(Fac[n],mod-2);
	Fod(i,n,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
	For(i,1,n)
		Iv[i]=(LL)Inv[i]*Fac[i-1]%mod;
}
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int n,s=0,sb=0;
int a[N],b[N];
int f[N][N][N],g[N][N][N];
int main(){
	prework();
	n=read();
	For(i,1,n)
		a[i]=read(),b[i]=read(),s+=a[i],sb+=b[i];
	g[0][0][0]=1;
	For(i,1,n)
		For(j,0,s)
			For(k,0,sb){
				if (g[i-1][j][k]){
					int v=g[i-1][j][k];
					Add(g[i][j][k],v);
					int pw=1;
					For(t,0,b[i]-1){
						Del(g[i][j+a[i]][k+t],(LL)v*Inv[t]%mod*pw%mod);
						pw=(LL)pw*a[i]%mod;
					}
					Add(f[i][j+a[i]][k+b[i]-1],(LL)v*Inv[b[i]-1]%mod*pw%mod);
				}
				if (f[i-1][j][k]){
					int v=f[i-1][j][k];
					Add(f[i][j][k],v);
					int pw=1;
					For(t,0,b[i]-1){
						Del(f[i][j+a[i]][k+t],(LL)v*Inv[t]%mod*pw%mod);
						pw=(LL)pw*a[i]%mod;
					}
				}
			}
	int ans=0;
	For(i,1,s)
		For(j,0,sb){
			int v=f[n][i][j];
			if (!v)
				continue;
			int c=(LL)s*Iv[i]%mod*(j+1)%mod;
			Add(ans,(LL)v*Pow(i,mod-1-j-1)%mod*Fac[j]%mod*c%mod);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 495488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long b = sc.nextLong();
		long r = sc.nextLong();
		
		if(b == 0) {
			System.out.println(0);
			return;
		}
		
		long total = b+r;
		
		long num = n/total;
		
		long amari = n%total;
		
		long ans = num*b;
		
	
		if(amari >= b) {
			ans+=b;
		} else {
			ans+=amari;
		}
		
		System.out.println(ans);

	}
}


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

int main(){
    using namespace std;
    string S, T;
    cin >> S >> T;
    unsigned long ans{0};
    for(unsigned long i{0}; i < S.size(); ++i)ans += S[i] != T[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3920
def q2():
    from itertools import combinations
    N = int(input())
    D = [int(i) for i in input().split()]
    comb_d = combinations(D, 2)
    ans = 0
    for d in comb_d:
        ans += d[0] * d[1]
    print(ans)


if __name__ == '__main__':
    q2()


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


typedef long long ll;
typedef pair<ll,ll> P;
int N,M,L;

ll W[111][111];
const ll INF = 100000000000000LL;
P pt[1111];
vector<int> G[2111];


void init(){
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      W[i][j] = INF;
  for(int i=0;i<N;i++)
    W[i][i] = 0;
  for(int i=0;i<=2*L;i++)
    G[i].clear();
}

void add_edge(int from,int to){
  G[from].push_back( to );
  G[to].push_back( from );
}

void wsf(){
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++)
        W[j][k] = min( W[j][k], W[j][i] + W[i][k] );
}


bool used[2111];
int match[2111];
int V;

int dfs(int v){
  used[v] = true;
  for(int i=0;i<(int)G[v].size();i++){
    int u = G[v][i], w = match[u];
    if( w < 0 || (!used[w] && dfs(w)) ){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset( match, -1, sizeof(match) );
  for(int v=0;v<V;v++){
    if( match[v] < 0 ) {
      memset( used, 0, sizeof ( used ) );
      if( dfs( v ) ) res++;
    }
  }
  return res;
}

int solve(){
  return L - bipartite_matching();
}

int main(){
  while( cin >>N >> M >> L && ( N||M||L ) ){
    init();
    for(int i=0;i<M;i++){
      ll u,v,l; cin >> u >> v >> l;
      W[u][v] = l;
      W[v][u] = l;
    }
    wsf();
    for(int i=0;i<L;i++){
      int p,t; cin >> p >> t;
      pt[i] = P( t, p );
    }
    sort(pt,pt+L);

    for(int i=0;i<L;i++){
      for(int j=i+1;j<L;j++){
        ll len = W[pt[i].second][pt[j].second];
        ll lt = pt[j].first - pt[i].first;
        if( len <= lt )          
          add_edge( i, L+j );
      }
    }
    V = 2 * L;
    cout << solve() << endl;
    
  }
}

Measured memory_bytes: 8132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using vl = vector<long long>;
using P = pair<long long,long long>;

int main(){
	ll k; cin >> k;
	vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout << a[k-1] << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll X;
    cin >> X;

    ll ans = 0;
    for (ll i = 0; i <= A; i++) {
        for (ll j = 0; j <= B; j++) {
            for (ll k = 0; k <= C; k++) {
                ll t = 500 * i + 100 * j + 50 * k;
                if (t == X) {
                    ++ans;
                }
            }
        }
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

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

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = count = 0; pro = 1

n=int(input())
a=math.ceil(n/1.08)
if int(a*1.08)==n:
    print(a)
else:
    print(":(")

Measured memory_bytes: 38768
import java.util.Scanner;

public class Main {
	
	public static void main (String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int sum = 0, max = 0;
		
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			sum += p;
			max = Math.max(max, p);
		}
		
		System.out.println(sum - max / 2);
	}
	
}


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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();
    int a,b,c,k,cnt=0;
    cin >> a >> b >> c >> k;
    while(a >= b)b*=2,++cnt;
    while(b >= c)c*=2,++cnt;
    if(cnt > k)cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

constexpr int inf = (int)1e9;
constexpr double INF = 1e12, EPS = 1e-9;
constexpr int MX = 2010;
constexpr int mod = inf + 7;

int n, m, q, a[MX];
int L[MX][MX], R[MX][MX];
int memo[MX][MX];

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  ll min = inf;

  for (int ci = 0; ci <= max(X, Y) * 2; ci += 2) {
    int ai = max(0, X - ci / 2);
    int bi = max(0, Y - ci / 2);
    int sum = A * ai + B * bi + C * ci;
    if (sum < min) min = sum;
  }

  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int gcd(int x,int y){
	
	if(x%y==0){
		return y;
	}else{
		return gcd(y,x%y);
	}
	
}


int main() {
	
	int A,B,C;
	cin>>A>>B>>C;
	
	ce(min(B/A,C))
	
}

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

int main(){
  int A[3];
  for(int i=0;i<3;i++){
    cin >> A[i];
  }
  sort(A,A+3);
  cout << A[2]*10 + A[1] + A[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<bitset>
#include<queue>
using namespace std;

int main(){
	unsigned long long int a,b,c,x,y,ans=0;
	cin>>a>>b>>c>>x>>y;
	if(2*c<a+b){
		if(x>y){
		  ans = min(c*2*y + a*(x - y),c*2*x);
		}else if(x==y){
			ans = c*2*x;
		}else{
			ans = min(c*2*x + b*(y-x),c*2*y);
		}
	}else{
		ans =x*a+y*b;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std ;

int a , b ;
const int hell = 1e9 + 7 ;
int fact[1000001];

int binpower(int a, int b){
        int res = 1;
        while(b){
                if(b&1)
                        (res *= a)%=hell;
                b/=2;
                (a*=a)%=hell;
        }
        return res;
}

int modinverse(int n){
        return binpower(n,hell-2);
}

int ncr(int n , int r){
        if(r==0) return 1 ;
        fact[0] = 1;
        for(int i = 1 ; i <= n ; i++ ){
                fact[i] = fact[i-1]*i%hell;
        }
        return ((fact[n]*modinverse(fact[r]))%hell*modinverse(fact[n-r])%hell)%hell;       
}

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

        cin >> a >> b ;

        if((a+b)%3!=0){
                cout << 0 << endl; 
                return 0 ;
        }

        int n = (2*a-b)/3 , m = (2*b-a)/3;

        if(n < 0 or m < 0 ){
                cout << 0 << endl ;
                return 0;
        }
        //cout << n <<' ' << m << endl ;
        cout << ncr(n+m,m) << endl; 
        
        for(int i = 0 ; i < 1000000 ; i++ ){
                true;
        }
        return 0;
        
}

Measured memory_bytes: 6400
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int n,A,B,x[110000];
int main(){
	scanf("%d%d%d",&n,&A,&B);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	long long ans=0;
	for (int i=1;i<n;i++)
		ans+=min(1ll*(x[i+1]-x[i])*A,1ll*B);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
    SS(ll,n,m)
    vl x(n),y(n),X(m),Y(m);
    rep(i,n)cin>>x[i]>>y[i];
    rep(i,m)cin>>X[i]>>Y[i];
    rep(i,n){
        ll mi=MOD,ans=0;
        rep(j,m){
            if(mi>abs(x[i]-X[j])+abs(y[i]-Y[j])){
                mi=abs(x[i]-X[j])+abs(y[i]-Y[j]);
                ans=j+1;
            }
        }
        p(ans);
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int h = a/3600;
        int m = (a%3600)/60;
        int s = (a%3600)%60;
        System.out.println(h+":"+m+":"+s);
    }
}

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

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{
    string s;
    cin >> s;
    int count = 0;

    rep(i, s.size() + 1)
    {
        string left, right;
        left = s.substr(0, i);
        right = s.substr(i);
        int lnum = 0, rnum = 0;
        if (left.size() > 0)
            lnum = stoi(left);
        if (right.size() > 0)
            rnum = stoi(right);
        int x, y;
        x = (lnum + rnum) / 2;
        y = (-lnum + rnum) / 2;

        int qqqqq = x - y;
        int wwwww = x + y;
        string eeeee;
        if (qqqqq != 0)
        {
            eeeee = to_string(qqqqq);
        }
        if (wwwww != 0)
        {
            eeeee += to_string(wwwww);
        }

        if (x >= 0 && y >= 0 && s == eeeee)
        {
            //cout << lnum << " " << rnum << endl;
            //cout << x << " " << y << endl;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3288
object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val down = Array.tabulate(n){_ ⇒ Nil: List[Int]}
  val up = Array.tabulate(n){_ ⇒ Nil: List[Int]}
  val downCount = Array.tabulate(n){_ ⇒ 0}
  val upCount = Array.tabulate(n){_ ⇒ 0}
  val longestDownPath = Array.tabulate(n){i ⇒ Path(i, 0)}
  val longestUpPath = Array.tabulate(n){i ⇒ Path(i, 0)}
  val edges = Array.tabulate(m){_ ⇒
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    Edge(a, b)
  }
  for (Edge(a, b) ← edges){
    down(a) ::= b
    downCount(a) += 1
    up(b) ::= a
    upCount(b) += 1
  }
  var toUp: Seq[Int] = down.indices.filter(downCount(_) == 0)
  while(toUp.nonEmpty){
    var next = Nil: List[Int]
    toUp.foreach{ d ⇒
      for (u ← up(d)) {
        downCount(u) -= 1
        if (downCount(u) == 0) {
          longestDownPath(u).append(longestDownPath(d))
          next ::= u
        }
      }
    }
    toUp = next
  }
  var toDown: Seq[Int] = up.indices.filter(upCount(_) == 0)
  while(toDown.nonEmpty){
    var next = Nil: List[Int]
    toDown.foreach{u ⇒
      for (d ← down(u)){
        upCount(d) -= 1
        if (upCount(d) == 0){
          longestUpPath(d).append(longestUpPath(u))
          next ::= d
        }
      }
    }
    toDown = next
  }
  val currentMax = longestDownPath.maxBy(_.length).length
  val fromDownLength = Array.tabulate(currentMax + 1){_ ⇒ 0}
  for (p ← 0 until n if longestDownPath(p).length + longestUpPath(p).length == currentMax){
    fromDownLength(longestDownPath(p).length) += 1
  }
  val bottleNeck = edges.indices.filter{i ⇒
    val Edge(u, d) = edges(i)
    longestDownPath(u).length == longestDownPath(d).length + 1 &&
    longestDownPath(u).length + longestUpPath(u).length == currentMax &&
      longestDownPath(d).length + longestUpPath(d).length == currentMax &&
      fromDownLength(longestDownPath(u).length) == 1 &&
      fromDownLength(longestDownPath(d).length) == 1
  }
  if (bottleNeck.isEmpty) println(-1)
  else println(bottleNeck.map(_ + 1).mkString("\n"))



  case class Path(current: Int, var length: Int, var from: List[Int] = Nil) {
    def append(path: Path): Unit = {
      if (length < path.length + 1){
        length = path.length + 1
        from = List(path.current)
      }else if (length == path.length + 1){
        from ::= path.current
      }
    }
  }
  case class Edge(from: Int, to: Int)
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }

}


Measured memory_bytes: 298088
import sys

N = int(input())
c = list(input())

r = c.count("R")
if r == 0 :
    print(0)
    sys.exit()   
rs = c[:r]
rsw = rs.count("W")
a = rsw

w = list(reversed(c)).index("R")
w = (N - 1) - w
ws = c[:w]
b = ws.count("W")
print(min(a,b))




Measured memory_bytes: 13504
n = int(input())

num = n + (n % 2 == 0)
cnt, ans = 0, []
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        if i + j != num:
            cnt += 1
            ans.append((i, j))

print(cnt)
for i, j in ans:
    print(i, j)


Measured memory_bytes: 74400
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a+b<c+d){
		printf("Right\n");
	}
	else if(a+b>c+d){
		printf("Left\n");
	}
	else{
		printf("Balanced\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

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

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N, K;
    cin >> N >> K;

    u64 ans = 0;
    for (int b = K + 1; b <= N; ++b)
    {
        ans += (b - K) * ((N + 1) / b) + MAX((N + 1) % b - K, 0);
    }
    if (K == 0)
    {
        ans -= N;
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/ruby
n,m=gets.split.map(&:to_i)
a=n.times.map{
	h=Hash.new(0)
	gets.chomp.each_byte{|b|h[b]+=1}
	h
}
#87,66,82
x=Float::INFINITY
w=0
(0..n-3).each{|i|
	w+=m-a[i][87]
	b=0
	(i+1..n-2).each{|j|
		b+=m-a[j][66]
		r=0
		(j+1..n-1).each{|k|r+=m-a[k][82]}
		x=[x,w+b+r].min
	}
}
p x

Measured memory_bytes: 8828
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C;
    bool flag =false;
    cin>>A>>B>>C;
    for(int i=1;i<A*B+C;i++){
        if(i%A==0&&i%B==C)
            flag=true;
    }
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

def main():
    A,B=mi()
    print(max(A+B,A+A-1,B+B-1))

                





if __name__ == "__main__":
    main()

Measured memory_bytes: 61964
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
    string s;
    cin>>s;
    lli n = s.length();
    loop(i, 0, n)
        cout<<'x';
    cout<<"\n";
    return 0;
}   
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int n,now,ans = 0;
vector<pair<int,int>> v;

int main(){
 cin >> n;
 rep(i,n){
   ll x,l = 0; cin >> x >> l;
   v.push_back(make_pair(x+l,x-l));
 }

//  rep(i,n){
//   int a = v[i].first;
//   int b = v[i].second;
//   cout << a << b << endl;
// }
 sort(v.begin(),v.end());
 now = -2e9;
//  now = v[0].first;
 ans = 0;

// rep(i,n){
//   int a = v[i].first;
//   int b = v[i].second;
//   cout << a << b << endl;
// }
// rep(i,n-1){
//   if(now > v[i+1].second){
//     ans -= 1;
//   }
// }

	// cout<<ans;
  	for (int i=0;i<n;i++){
		if (v[i].second<now) continue;
		now=v[i].first,now=v[i].first,ans++;
	}
  cout << ans;


}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  string S; cin >> S;
  int cnt = 0;
  int ans = 0;
  rep(i, N - 1) {
    if (S[i] != S[i + 1]) {
      cnt++;
    } else {
      ans++;
    }
  }
  ans += min(cnt, K * 2);
  cout << ans << endl;
}

Measured memory_bytes: 512
n,q = map(int,input().split())
s = str(input())
s = "x" + s + "x" + "x"
n += 3
left = [0 for i in range(n-1)]
num = 0

for i in range(n-2):
    if s[i:i+2] == "AC":
        left[i] += 1
        num += 1
    left[i+1] = left[i]

right = [0 for i in range(n-1)]
for i in range(n-2):
    if s[-(2+i):-i] == "AC":
        right[-(1+i)] += 1
    right[-(2+i)] = right[-(1+i)]
for i in range(q):
    a,b = map(int,input().split())
    print(num-left[a-1]-right[b])


Measured memory_bytes: 8592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 3e5 + 5;
const long long mod = 1e9 + 7;
ll MODULAR_POWER(ll a , ll b , ll MOD) {
    if(b == 0) return 1LL;
    ll d = MODULAR_POWER(a , b / 2 , MOD);
    d *= d;
    d %= MOD;
    if(b % 2) d *= a;
    d %= MOD;
    return d;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(0);
    cout << fixed;
    int n;
    string s;
    cin >> n >> s;
    int l[n] , r[n];
    fill(l , l + n , 0);
    fill(r , r + n , 0);
    rep(i , 0 , n - 1) {
        if(i == 0) {
            if(s[i] == 'W') {
                l[i] = 1;
            }
        }
        else {
            l[i] = l[i - 1];
            if(s[i] == 'W') {
                l[i]++;
            }
        }
    }
    per(i , n - 1 , 0) {
        if(i == n - 1) {
            if(s[i] == 'E') {
                r[i] = 1;
            }
        }
        else {
            r[i] = r[i + 1];
            if(s[i] == 'E') {
                r[i]++;
            }
        }
    }
    if(n == 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = r[1];
    rep(i , 1 , n - 2) {
        ans = min(ans , l[i - 1] + r[i + 1]);
    }
    ans = min(ans , l[n - 2]);
    cout << ans << endl;
    return 0;
}


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

int main(){
  int A,B,C,X,Y,ans=0;
  cin >> A >> B >> C >> X >> Y;
  int min_c = min(X,Y);
  //X,Yうち小さい方の数まで買う。
  if((A + B) <= 2*C){
    ans += A * min_c + B * min_c;
  }else if((A + B) > 2*C){
    ans += 2 * min_c * C;
  }
  //足りない分は値段を見て決める。
  ans += A <= 2*C ? A * (X - min_c) : 2 * C * (X - min_c);
  ans += B <= 2*C ? B * (Y - min_c) : 2 * C * (Y - min_c);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int x[n];
  rep(i,n) cin>>x[i];
  int ans=INF;
  repi(i,1,101){
    int sum=0;
    rep(j,n){
      sum+=(i-x[j])*(i-x[j]);
    }
    ans=min(sum,ans);
  }
  cout<<ans<<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 all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int X;
  cin>>X;
  int Y=X,S=0;
  while(Y){
    S+=Y%10;
    Y/=10;
  }
  cout<<((X%S)?"No":"Yes")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 256
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

char  d[ N ][ N ];
int   n;

static
int scan (
  int x,
  int y,
  int sx,
  int sy,
  int res
  )
{
  int c;

  for ( c = 0; x >= 0 && y >= 0
            && x < n && y < n;
      x += sx, y += sy )
  {
    if ( d[ x ][ y ] == '0' )
    {
      res = MAX( res, c );
      c = 0;
      continue ;
    }

    ++c;
  }
  res = MAX( res, c );

  return ( res );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int res = 0;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      scanf ( "%s", d[ i ] );
    }

    for ( i = 0; i < n; ++i )
    {
      res = scan ( 0, i, 1, 0, res );
      res = scan ( i, 0, 0, 1, res );
      res = scan ( 0, i, 1, 1, res );
      res = scan ( 0, i, 1, -1, res );
    }
    for ( i = 1; i < n; ++i )
    {
      res = scan ( i, 0, 1, 1, res );
      res = scan ( i, n - 1, 1, -1, res );
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    ll n,ans=pow(10,9);
    cin >> n;
    vector<char> v(n);
    vector<ll> b(n+1),w(n+1);

        b.at(0)=0;

        w.at(0)=0;

    
    for(ll i=1;i < n+1;i++)
    {
        cin >> v.at(i-1);
        if(v.at(i-1)=='#'){
            b.at(i)=b.at(i-1)+1;
            w.at(i)=w.at(i-1);
        }else{
            w.at(i)=w.at(i-1)+1;
            b.at(i)=b.at(i-1);
        }
    }

    for(ll i=0;i < n+1;i++)
    {
        ans=min(ans,(ll)(b.at(i)+w.at(n)-w.at(i)));
    }
    cout << ans << endl;
}



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

int main(){
    string S;
    cin >> S;

    int cnt_C;
    cnt_C = 0;

    int L = S.size();

    string ans = "AC";
    if(S[0] != 'A') ans = "WA";

    for (int i = 1; i < L; i++){
        //大文字の場合
        if(!(S[i] >= 'a' && S[i] <= 'z')){
            //大文字が来うるのは2〜L-2文字目の間でありそれ以外は罰
            if(i == 1 || i == L-1 || S[i] != 'C'){
                ans = "WA";
            }
            cnt_C++;
        }
    }
    if(cnt_C != 1){
        ans = "WA";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256