akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int gcd(int A,int B){
  if (B>A) {
    int T=B;
    B=A;
    A=T;
  }
  if(A%B==0) return B;
  else return gcd(A%B,B);
}
int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int count=0;
  for(int i=100;i>0;i--){
    if (A%i==0 && B%i==0) count++;
    if (count==K) {
      cout << i;
      break;
    }
  }
}


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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  100000000000007

ll dp[5001][5001];

int main(){
	int n;
	cin >> n;
	vector<ll> h(n+1),p(n+1);
	vector<pair<ll,pair<ll,ll> > > q;
	for(int i=1;i<=n;i++){
		cin >> h[i] >> p[i];
		q.push_back(MP(h[i]+p[i],MP(h[i],p[i]) ));
	}
	q.push_back(MP(0,MP(0,0)));
	sort(q.begin(),q.end());
	for(int i=0;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j] = inf;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			dp[i][j] = dp[i-1][j];
			if(dp[i-1][j-1]<=q[i].second.first){
				dp[i][j] = min(dp[i][j],dp[i-1][j-1]+q[i].second.second);
			}
		}
	}
	int ans=0;
	/*for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	for(int i=1;i<=n;i++){
		if(dp[n][i]!=inf){
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 195904
function main()
	H,W,K=map(x->parse(Int,x),split(readline()))
	sx,sy,gx,gy=map(x->parse(Int,x),split(readline()))
	S=String[]
	for _=1:H
		push!(S,chomp(readline()))
	end
	D=ones(Int,H,W)*10^9
	D[sx,sy]=1
	Q=Pair{Int,Int}[sx=>sy]
	while !isempty(Q)
		x,y=popfirst!(Q)
		for (dx,dy)=(0=>1,0=>-1,1=>0,-1=>0)
			tx,ty=x,y
			for _=1:K
				tx+=dx
				ty+=dy
				if tx<1||ty<1||H<tx||W<ty||S[tx][ty]=='@'||D[tx,ty]<=D[x,y]
					break
				end
				if D[tx,ty]>D[x,y]+1
					D[tx,ty]=D[x,y]+1
					push!(Q,tx=>ty)
				end
			end
		end
	end
	println((D[gx,gy]%10^9-1))
end
main()

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

const int N = 2e5 + 233;

int n, m, id[N];
long long A[N], B[N], C[N];
int vis[N], fa[N];
long long f[N], s[N];

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

std::vector<int> G[N], T[N];

void dfs(int x) {
  s[x] = B[x], f[x] = T[x].empty() ? std::max(A[x], B[x]) : 1e18;
  for (int y : T[x])
    dfs(y), s[x] += s[y];
  for (int y : T[x])
    f[x] = std::min(f[x], std::max(f[y], 1ll * C[x]) + s[x] - s[y]);
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%lld %lld", A + i, B + i), C[i] = A[i] - B[i], id[i] = i;
  for (int i = 1; i <= n; ++i)
    C[i] = C[i] < 0 ? 0 : C[i];
  for (int i = 1; i <= m; ++i) {
    int x, y; scanf("%d %d", &x, &y);
    G[x].push_back(y), G[y].push_back(x);
  }
  std::sort(id + 1, id + n + 1, [&](int x, int y)
    { return C[x] < C[y]; });
  for (int i = 1; i <= n; ++i) {
    int x = id[i]; vis[x] = 1;
    for (int y : G[x])
      if (vis[y] && find(y) != x) {
        T[x].push_back(find(y));
        fa[find(y)] = x;
      }
  }
  dfs(id[n]);
  std::cout << f[id[n]] << std::endl;
  return 0;
}



Measured memory_bytes: 29052
#include<bits/stdc++.h>
#define inf 999999999
using namespace std;
int n;
int a[25],b[25],c[25];
int ans=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i],ans+=b[i];
	for(int i=1;i<n;i++) cin>>c[i];
	for(int i=1;i<n;i++)
	if(a[i]+1==a[i+1]) ans+=c[a[i]];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n = 32, l, i, j, a[26], c;

  while(scanf("%d", &l) && l){
    for(i = 0; i < l; ++i) scanf("%d", a + i);
    c = 0;
    while(1){
      n -= (n - 1) % 5;
      printf("%d\n", n);
      n -= a[c++];
      if(c >= l) c = 0;
      if(n <= 0){ puts("0"); break;}
      printf("%d\n", n);
    }
    n = 32;
  }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<vector<int> > g;
vector<pair<int,int> > res;
vector<int> V;
int dfs(int a) {
	V[a] = 1;
	int c = 0;
	for (int i : g[a]) {
		if (V[i] == 0) {
			int t = dfs(i);
			if (t % 2 == 0) {
				res.emplace_back(a, i);
			}
			else {
				res.emplace_back(i, a);
			}
			c += t + 1;
		}
		else {
			if (V[i] == 2) {
				res.emplace_back(a, i);
				c++;
			}
		}
	}
	V[a] = 2;
	return c;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	g.resize(N);
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	if (M % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}
	V.resize(N, 0);
	dfs(0);


	for (int i = 0; i < res.size(); i++) {
		cout << res[i].first + 1 << " " << res[i].second + 1  << endl;
	}
}

Measured memory_bytes: 17136
a,b,k = map(int,input().split())

if k < a:
    c = a-k
    print(str(c) + " " + str(b))
elif a + b > k:
    d = b - (k - a)
    print(str(0) + " " + str(d))
else:
    print(str(0) + " " + str(0))

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

#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())

int main() {
    int x;
    rep(i,5) {
        cin>>x;
        if(x == 0) cout << i+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
data = [[int(i) for i in input().split()] for _ in range(N)]

dp = [[0] * 3 for _ in range(N)]
dp[0] = data[0]

for i in range(1, N):
    for j in range(3):
        dp[i][j] = data[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3])
print(max(dp[N-1]))

Measured memory_bytes: 74072
S = input()
a = int(S[:2])
b = int(S[2:])
ba = 1 <= a <= 12
bb = 1 <= b <= 12
if ba and bb:
    print('AMBIGUOUS')
elif ba and not bb:
    print('MMYY')
elif not ba and bb:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 38384
# S = input()
# print('Heisei' if S <= '2019/04/30' else 'TBD')

# n,m,c=map(int,input().split())
# b=list(map(int,input().split()))
# e = [[int(i) for i in input().split()] for i in range(n)]

# array=[None]*3
# print(array)

n=int(input())
total=0.0
i=n
while i>0:
	x,u=map(str,input().split())
	x=float(x)
	if u=="JPY":
		total+=x
	elif u=="BTC":
		total+=x*380000.0
	i-=1

print(total)

Measured memory_bytes: 3060
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

same = 0
for i, ei in enumerate(a):
    for j, ej in enumerate(a[i+1:], i + 1):
        if ei > ej:
            same += 1
            same %= mod

other = 0
for ei in a:
    for ej in a:
        if ei > ej:
            other += 1
            other %= mod

ans = same * k + other * k * (k - 1) // 2
ans %= mod
print(ans)


Measured memory_bytes: 3188
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k; cin >> n >> k;
	vector<int> a(n);
	vector<int> isvisit(n,0);
	int x = 0;
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	int cnt = 0;
	while (k > 0) {
		cnt++;
		k--;
		x = a[x];
		if (isvisit[x] == 0) {
			isvisit[x] = cnt;
		}
		else {
			k = k % (cnt - isvisit[x]);
		}
	}
	cout << x + 1 << endl;

}


Measured memory_bytes: 6332
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

a = I()

ans = a * (1 + a + a**2)

print(ans)

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine(N * 800 - (N / 15 * 200));

        }
    }
}


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

int main()
{
    int n, m, ans(0);

    cin >> n >> m;

    vector<int> h(n), y(n), a(m), b(m);
    for (int i = 0; i < n; i++)
    {
        cin >> h.at(i);
        y.at(i) = 1;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> a.at(i) >> b.at(i);
        if (h.at(a.at(i) - 1) > h.at(b.at(i) - 1))
        {
            y.at(b.at(i) - 1) = 0;
        }
        else if (h.at(a.at(i) - 1) < h.at(b.at(i) - 1))
        {
            y.at(a.at(i) - 1) = 0;
        }
        else
        {
            y.at(b.at(i) - 1) = 0;
            y.at(a.at(i) - 1) = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (y.at(i) != 0)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	if(k==1){
		cout<<0; return 0;
	}
	cout<<n-k;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  long long int i,j,n,x,y;
  scanf("%lld", &n);
  int flag = 0;
  for(i=1;i<=3500;i++)
    {
      for(j=1;j<=3500;j++)
	{
	  x= n*i*j;
	  y= 4*i*j-n*j-n*i;
	  if(y>0)
	    {
	      if(x%y==0)
		{
		  printf("%lld %lld %lld",i,j,x/y);
		  flag = 1;
		  break;
		}
	    }

	}
      if (flag == 1) break;
    }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
#define endl "\n";



void run_case() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> cost(n);
    for(int i = 0; i < n; ++i) {
        cin >> cost[i];
        for(int j = 0; j < m; ++j) cin >> a[i][j];
    }
    int ans = 0x3f3f3f3f;
    for(int i = 0; i < (1<<n); ++i) {
        int tmp = 0;
        vector<int> b(n, 0);
        for(int j = 0; j < n; ++j) {
            if(i&(1<<j)) {
                tmp += cost[j];
                for(int k = 0; k < m; ++k) b[k] += a[j][k];
            }
        }
        bool flag = true;
        for(int k = 0; k < m && flag; ++k) {
            if(b[k] < x) flag = false;
        }
        if(flag) {
            ans = min(ans, tmp);
        }
    }
    if(ans == 0x3f3f3f3f) cout << -1;
    else cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>
#include<string.h>
	int main(){
		int h,k,i,b[100];
		char a[100];
		while(scanf("%s",a)!=EOF){
			h=strlen(a);
			for(i=0;i<h;i++){
				if(a[i]=='I')
					b[i]=1;
				else if(a[i]=='V')
					b[i]=5;
				else if(a[i]=='X')
					b[i]=10;
				else if(a[i]=='L')
					b[i]=50;
				else if(a[i]=='C')
					b[i]=100;
				else if(a[i]=='D')
					b[i]=500;
				else if(a[i]=='M')
					b[i]=1000;
			}
			k=b[h-1];
			for(i=h-1;i>0;i--){
				if(b[i-1]<b[i])
					k-=b[i-1];
				else k+=b[i-1];
			}
			printf("%d\n",k);
		}
		return 0;
}

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

#define fastIO                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef long double ld;

unsigned long long power(unsigned long long x, unsigned long long y)
{
	unsigned long long res = 1;
	x = x % MOD;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % MOD;
		y = y >> 1;
		x = (x * x) % MOD;
	}
	return res;
}

int main()
{
	fastIO;
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 3; i <= n; i++)
	{
		a[i] = 1;
		for (int j = 3; j <= i - 3; j++)
			a[i] = (a[i] + a[j]) % MOD;
	}
	cout << a[n];
}

Measured memory_bytes: 3648
N, M = map(int, input().split())
min = N
max = 1
for i in range(M):
    L, R = map(int, input().split())
    if L > max:
        max = L
    if R < min:
        min = R
if min - max + 1 < 0:
    print(0)
else:
    print(min - max + 1)


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

int main() {
    string S;
    cin >> S;
    vector<char> v = {'Y','A','K','I'};
    vector<char> vec(4);
    rep(i,4) {
        vec[i] = S[i];
    }
    if (vec==v) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p.at(i);
    rep(i, n) cin >> q.at(i);
    vector<int> a(n);
    rep(i, n) a.at(i) = i + 1;

    map<vector<int>, int> mp;
    do {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;

    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    vector< P > red, blue;
    for( int i = 0; i < n; ++i ) {
        int x, y;
        cin >> x >> y;
        red.pb(MP(y, x));

    }

    for( int i = 0; i < n; ++i ) {
        int x, y;
        cin >> x >> y;
        blue.pb(MP(x, y));

    }
    sort(all(blue));

    int cnt = 0;
    for( int i = 0; i < n; ++i ) {
        int maxy = -1;
        int ppos;
        for( int j = 0; j < n; ++j ) {
            if( blue[i].F > red[j].S && blue[i].S > red[j].F ) {
                if( maxy < red[j].F ) {
                    maxy = red[j].F;
                    ppos = j;

                }
            }
        }
        if( maxy != -1 ) {
            ++cnt;
            red[ppos] = MP(INF, INF);

        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n, rel = 0; cin >> n;
    for(int i = 1;; i++){
        if(i * i > n){
            cout << (i-1) * (i-1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long g[20][20];
int perm[20];
int mag[]={1,2,4,7,12,20,29,38,52,73};
int main(){
	int a;scanf("%d",&a);
	g[0][1]=g[1][0]=1;
	for(int i=3;i<=a;i++){
		for(int j=0;j<i-1;j++)perm[j]=j;
		long long cur=0;
		do{
			long long tmp=0;
			for(int j=0;j<i-2;j++){
				tmp+=g[perm[j]][perm[j+1]];
			}
			cur=max(cur,tmp);
		}while(next_permutation(perm,perm+i-1));
		cur++;
		for(int j=0;j<i-1;j++){
	//		g[j][i-1]=g[i-1][j]=mag[i-2-j]*cur;
		g[j][i-1]=g[i-1][j]=mag[j]*cur;
		}
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(j)printf(" ");printf("%lld",g[i][j]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for(int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
    int n; cin >> n;
	if (400 <= n && n < 600) cout << 8;
	if (600 <= n && n < 800) cout << 7;
	if (800 <= n &&n< 1000) cout << 6;
	if (1000 <= n &&n< 1200) cout << 5;
	if (1200 <= n &&n< 1400) cout << 4;
	if (1400 <= n &&n< 1600) cout << 3;
	if (1600 <= n &&n< 1800) cout << 2;
	if (1800 <= n &&n< 2000) cout << 1;
	
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include<string.h>

int main(void){
  int N;
  scanf("%d",&N);
  int C0Count = 0, C1Count = 0, C2Count = 0, C3Count = 0;
      char s[5];
  for(int i = 0; i < N; i++){
  //  char s[5];
    scanf("%s", s);
    
    if(strcmp(s, "AC")==0){
      C0Count++;
    }else if(strcmp(s, "WA")==0){
      C1Count++;
    }else if(strcmp(s, "TLE")==0){
      C2Count++; 
    }else if(strcmp(s, "RE")==0){
      C3Count++;
    }
  }
  printf("AC x %d\n", C0Count);
  printf("WA x %d\n", C1Count);
  printf("TLE x %d\n", C2Count);
  printf("RE x %d\n", C3Count);
}

Measured memory_bytes: 1732
#[allow(dead_code)]
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
#[allow(dead_code)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(dead_code)]
use std::convert::TryInto;
#[allow(dead_code)]
use std::fmt;
#[allow(dead_code)]
use std::mem::swap;
#[allow(dead_code)]
use std::num::{NonZeroU32, ParseIntError};
#[allow(dead_code)]
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
#[allow(dead_code)]
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};
#[allow(dead_code)]
use proconio::input;
#[allow(dead_code)]
use proconio::marker::{Chars,Bytes};
#[allow(dead_code)]
type Pair<T> = (T,T);
#[allow(dead_code)]
type VVec<T> = Vec<Vec<T>>;
#[allow(dead_code)]
type Stack<T> = Vec<T>;
#[allow(dead_code)]
type Queue<T> = VecDeque<T>;


#[derive(Debug,Clone,Default)]
pub struct Graph<T>{
    nodes: VVec<T>,
    seen: Vec<bool>,
}

pub trait graph_base<T,G>{
    fn new() -> Self;
    fn see(&mut self,now: G);
    fn connected(&mut self,s: G,g: G) -> bool;
    fn refresh(&mut self);
    fn init(nodes: VVec<T>,size: G) -> Self;
}

impl graph_base<usize,usize> for Graph<usize>{
    fn new() -> Self{
        Graph::default()
    }

    fn see(&mut self,now: usize){
        self.seen[now] = true;

        for next in self.nodes[now].clone(){
            if self.seen[next]{
                continue;
            }
            self.see(next);
        }
    }

    fn connected(&mut self,s: usize,g: usize) -> bool{
        self.refresh();
        self.see(s);
        self.seen[g]
    }

    fn refresh(&mut self){
        self.seen.resize(self.seen.len(),false);
    }

    fn init(nodes: VVec<usize>,size: usize) -> Self{
        let mut tmp = Graph::new();
        tmp.nodes = nodes;
        tmp.seen.resize(size + 1,false);
        tmp
    }
}

impl Graph<usize>{

}



fn main() {
    input!{
        n: usize,
    }

    let res = {
        if n <= 599{
            8
        }else if n <= 799{
            7
        }else if n <= 999{
            6
        }else if n <= 1199{
            5
        }else if n <= 1399{
            4
        }else if n <= 1599{
            3
        }else if n <= 1799{
            2
        }else{1}
    };

    println!("{}",res);
}



#[allow(dead_code)]
fn exit(){
    std::process::exit(1);
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;

const int MN = 2e5+5;
const int MOD = 1e9+7;
const int INF = 1e9;


int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int N;
    cin >> N;
    ll S[MN];
    for(int i=0; i<N; i++){
    	cin >> S[i];
    }
    ll ans = 0;
    for(int d=1; d<=N-1; d++){
    	ll val = 0;
    	for(int k=1; k<=N; k++){
    		ll A = N-1-d*k;
    		ll B = A-d;
    		if(A<0||B<0||B>=A) break;
    		if((N-1)%d==0&&(N-1)/d<=2*k) break;
    		val += S[d*k];
    		val += S[N-1-d*k];
    		ans = max(ans,val);
    	}
    }
    cout << ans;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 12 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[200001], ne[200001], he[100001];
int kotae[100001];
char d[100001];
const int m = (1 << 20) - 1;
const int m2 = (1 << 30) - m - 1;
void sagasu(int P, int D, int C) {
	if (D == 0 && kotae[P] == 0) kotae[P] = C;
	else if (d[P] < D) {
		d[P] = D;
		if (kotae[P] == 0) kotae[P] = C;
		for (int p = he[P]; p; p = ne[p]) {
			sagasu(to[p], D - 1, C);
		}
	}
}

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


	int N, M, Q;
	N = getint();
	M = getint();
	int k = 1;
	rep(i, M) {
		int a = getint(), b = getint();
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
	}
	Q = getint();
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		v[i] = getint();
		d[i] = getint();
		c[i] = getint();
	}
	for (int i = Q - 1; i >= 0; i--) sagasu(v[i], d[i], c[i]);

	rep1(i, N) putint(kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4736
#include <stdio.h>
#define N 500000
typedef struct Node_tbl{
	int KK;
	int PP;
	int LL;
	int RR;
} Node;
const int nil=-1;
Node t[N];
int root;
int room;
int ix;
int tmin(int u){
  while (t[u].LL!=nil)u=t[u].LL;
	return u;
}
int find(int u, int k){
	while (u!=nil && k!=t[u].KK){
		if (k<t[u].KK)u=t[u].LL;
		else u=t[u].RR;
	}
	return u;
}
int tree(int u){
	if (t[u].RR!=nil){
		return tmin(t[u].RR);
  }
	int y=t[u].PP;
	while (y!=nil && u==t[y].RR){
		u=y;
		y=t[y].PP;
	}
	return y;
}
void del(int z){
	int y;
	int x;
	if (t[z].LL == nil || t[z].RR == nil)y = z;
	else y = tree(z);
	if (t[y].LL!=nil)x=t[y].LL;
	else{
		x=t[y].RR;
  }
	if (x!=nil) t[x].PP=t[y].PP;
	if (t[y].PP == nil)root=x;
	else{
		if (y==t[t[y].PP].LL){
			t[t[y].PP].LL=x;
    }
		else{
			t[t[y].PP].RR=x;
    }
	}
	if (y!=z)t[z].KK=t[y].KK;
	t[y].RR=room;
	room=y;
}
void ins(int k){
	int z;
	int y = nil;
	int x = root;
	if (room==nil) z=ix++;
	else{
		z=room;
		room=t[room].RR;
	}
	t[z].KK=k;
	t[z].LL=nil;
	t[z].RR=nil;
	while (x!=nil){
		y=x;
		if (t[z].KK<t[x].KK)x=t[x].LL;
		else x = t[x].RR;
	}
	t[z].PP=y;
	if (y==nil)root=z;
	else{
		if (t[z].KK<t[y].KK)t[y].LL=z;
		else t[y].RR = z;
	}
}
void ino(int u){
	if (u==nil)return;
	ino(t[u].LL);
	printf(" %d", t[u].KK);
	ino(t[u].RR);
}
void preo(int u){
	if (u == nil) return;
	printf(" %d", t[u].KK);
	preo(t[u].LL);
	preo(t[u].RR);
}
int main(int argc, char** argv){
	char com[8];
	int n;
	int x;
	int i;
	root=nil;
	room=-1;
	ix=0;
	scanf("%d", &n);
	for (i=0 ; i<n; i++){
		scanf("%s", com);
		switch (com[0]){
		case 'd':
			scanf("%d", &x);
			del(find(root, x));
			break;

		case 'f':
			scanf("%d", &x);
			printf("%s\n", find(root, x) != nil ? "yes" : "no");
			break;

		case 'i':
			scanf("%d", &x);
			ins(x);
			break;

		case 'p':
		default:
			ino(root);
			printf("\n");

			preo(root);
			printf("\n");
			break;
		}
	}
  return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> a(m);
  for(int i=0;i<m;i++){
    cin>>a.at(i).second;
    cin>>a.at(i).first;
  }
  sort(a.begin(),a.end());
  int t=0;
  int ans=0;
  for(int i=0;i<m;i++){
    if(t<=a.at(i).second){
      ans++;
      t=a.at(i).first;
    }
  }
  cout<<ans<<endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    N %= 12;
    for (int i = 0; i < N; i++) {
        if (i & 1) B = A + B;
        else A = A - B;
    }
    cout << A << " " << B << endl;
    return (0);
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 ;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'




int main()
{   
    flash;
   int n,x,t;
   cin >> n >> x >> t;
   int a=n/x;
   a=a*t;
   if(n%x!=0)a=a+t;;
   cout << a <<endl;
    
}





Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> S;
    auto dfs = [&](auto &&dfs, int now) {
        dump(now);
        if (now == S.size())
            return 1;
        int res = 0;
        if (S.substr(now, 5) == "dream") {
            res |= dfs(dfs, now + 5);
        }
        if (S.substr(now, 5) == "erase") {
            res |= dfs(dfs, now + 5);
        }
        if (S.substr(now, 6) == "eraser") {
            res |= dfs(dfs, now + 6);
        }
        if (S.substr(now, 7) == "dreamer") {
            res |= dfs(dfs, now + 7);
        }
        return res;
    };
    if (dfs(dfs, 0))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 5916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll b = 117;

vector<int> G[100000];
int used[100000];

ll hs[100000];

ll dfs(int n) {
	used[n] = 1;
	ll res = 1;
	for (auto v : G[n]) {
		if (!used[v]) {
			res = (res + dfs(v) * b) % mod;
		}
	}
	return hs[n] = res;
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0, a, b; i < N - 1; i++) {
		cin >> a >> b;
		G[a - 1].push_back(b - 1);
		G[b - 1].push_back(a - 1);
	}
	dfs(0);
	sort(hs, hs + N);
	ll res = 0;
	for (int i = 0; i < N; i++) {
		auto p = equal_range(hs, hs + N, hs[i]);
		res += p.second - p.first - 1;
	}
	cout << res / 2 << endl;
	return 0;
}

Measured memory_bytes: 14364
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int A, B; cin >> A >> B;
  int kuti = 1;
  int ans = 0;
  while(B > kuti){
    kuti += A-1;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define min(a,b) a>b?b:a
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll *A=new ll[n];
	for(ll i=0;i<n;i++)
	{
		cin>>A[i];
	}
	ll *dp=new ll[n];
	dp[0]=0;
	dp[1]=abs(A[0]-A[1]);
	for(ll i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i]));
	}
	cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

//#define PI 3.141592653589

using namespace std;


int m, d;
int nissuu[] = {31,29,31,30,31,30,31,31,30,31,30,31};
int sum;	//曜日を求める日までの通算日数

int main()
{
	while (1)
	{
		cin >> m >> d;
		if (m == 0) break;
		
		sum = 0;
		for (int i=0; i<m-1; i++)
		{
			sum += nissuu[i];
		}
		sum += d;
		//cout << "sum = " << sum << endl;
		if (sum % 7 == 1) cout << "Thursday" << endl;
		else if (sum % 7 == 2) cout << "Friday" << endl;
		else if (sum % 7 == 3) cout << "Saturday" << endl;
		else if (sum % 7 == 4) cout << "Sunday" << endl;
		else if (sum % 7 == 5) cout << "Monday" << endl;
		else if (sum % 7 == 6) cout << "Tuesday" << endl;
		else if (sum % 7 == 0) cout << "Wednesday" << endl;
	}
	
	return 0;
}

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

int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll dp[n+1];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;i++){
		dp[i]=LONG_MAX;
		for(ll j=1;j<=min(k,i);j++)
			dp[i]=min((dp[i-j]+abs(a[i]-a[i-j])),dp[i]);
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
mod=1000000007
n,k=map(int,input().split())
A=list(map(int,input().split()))
cnt1,cnt2=0,0
for i in range(n):
    for j in range(n):
        if A[i]>A[j]:
            if i<j:
                cnt1+=1
            if i>j:
                cnt2+=1
cnt1*=k*(k+1)//2
cnt2*=k*(k-1)//2
print((cnt1+cnt2)%mod)

Measured memory_bytes: 41964
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	while(true) {
    		int n = sc.nextInt();
    		if(n==0) break;
    		int count = 0;
    		for(int i=1;i<=n/2;i++) {
    			int sum = 0;
    			int a = i;
    			while(sum<n) {
    				sum += a++;
    			}
    			if(sum == n) count++;
    		}
    		System.out.println(count);
        }
    }
}


Measured memory_bytes: 26364
#include<stdio.h>
#include<math.h>
 
 
int main(){
 
  int n, i;
  double x[100], y[100],s[100], max=0, d1=0, d2=0, d3=0;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%lf", &x[i]);
  for(i=0;i<n;i++) scanf("%lf", &y[i]);
 
  for(i=0;i<n;i++){
    s[i]=fabs(x[i]-y[i]);

    d1+=s[i];
    d2+=pow(s[i], 2);
    d3+=pow(s[i], 3);
    if(max<s[i]) max=s[i];
  }
 
  printf("%f\n%f\n%f\n%f\n", d1, sqrt(d2), cbrt(d3), max);
 
  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e3+5,LG=19,SM=600+5,inf=1e18+1;
ll mod=1e9+7;

int main()
{
	ios::sync_with_stdio(0);
    ll a,b;
    cin >> a >> b;
    if (b==0) RET((a>0)+abs(a)); 
    ll res=abs(abs(a)-abs(b));
    if (a<b)
    {
        res+=(a<0 ^ b<0);
        RET(res);
    }
    if (b<0 ^ a<0) RET(res+1);
    RET(res+2);
}    

Measured memory_bytes: 256
/**
 * ??¨?????????????????¢?????????????????£?????????????????????????????´?????????
 */

#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

enum class Grad {
    UP = 1, DOWN, FLAT,
};

struct Column {
    int height; // ???????????????
    Grad grad;
    Column(int h, Grad g) : height(h), grad(g) {}
};

void read_problem(vector<Column>& cols)
{
    int height = 30000; // ????????????

    int c;
    while((c = getchar()) != EOF) {
        if(c == '\n') break;

        if(c == '\\') {
            cols.push_back(Column(height, Grad::DOWN));
            --height;
        }
        else if(c == '/') {
            cols.push_back(Column(height, Grad::UP));
            ++height;
        }
        else if(c == '_') {
            cols.push_back(Column(height, Grad::FLAT));
        }
        else {
            assert(false);
        }
    }
}

// 1???????°´??????????????¢????????????(???????????????)
int area_pool(const vector<Column>& cols, int l, int r)
{
    int height_pool = cols[l].height;
    int area = 0;

    FOR(i, l, r+1) {
        Column col = cols[i];
        area += 2 * (height_pool - col.height);
        if(col.grad == Grad::DOWN)
            ++area;
        else if(col.grad == Grad::UP)
            --area;
    }

    return area;
}

vector<int> solve(const vector<Column>& cols)
{
    vector<int> pools;

    int width = cols.size();

    REP(i, width) {
        // ????????????????????¢?????????????????????
        Column left = cols[i];
        if(left.grad != Grad::DOWN) continue;

        // ?????????????????£??????????????¢?????¶????????£?????????????????????1???????°´?????????
        FOR(j, i+1, width) {
            Column right = cols[j];
            if(right.height == left.height-1 && right.grad == Grad::UP) {
                pools.push_back(area_pool(cols, i, j));
                i = j;
                break;
            }
        }
    }

    return pools;
}

int main()
{
    vector<Column> cols;
    read_problem(cols);

    vector<int> pools = solve(cols);

    printf("%d\n", accumulate(pools.begin(), pools.end(), 0) / 2);
    if(!pools.empty()) {
        printf("%d ", pools.size());
        REP(i, pools.size()) {
            printf("%d%c", pools[i] / 2, i == pools.size()-1 ? '\n' : ' ');
        }
    }
    else {
        printf("0\n");
    }

    return 0;
}

Measured memory_bytes: 2880
import java.util.Arrays;
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());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());

    int[] list1 = {a,b,c};
    Arrays.sort(list1);

    System.out.println(list1[0] + list1[1]);

}
}


Measured memory_bytes: 21844
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n, x  = readline() |> split |> parseMap
    l = readline() |> split |> parseMap
    counter = 1
    場所 = 0
    for i in l
        場所 += i
        if 場所 > x
            break
        end
        counter += 1
    end
    println(counter)
end

main()

Measured memory_bytes: 167200
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define sz(x) (int) x.size()
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<str> vstr;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;

int mark[3][3];

bool chk() {
  rep(i, 3) {
    bool ok = true;
    rep(j, 3) {
      ok &= mark[i][j];
    }
    if (ok)
      rtn true;
  }
  rep(i, 3) {
    bool ok = true;
    rep(j, 3) {
      ok &= mark[j][i];
    }
    if (ok)
      rtn true;
  }
  bool ok = true;
  rep(i, 3) {
    ok &= mark[i][i];
  }
  if (ok)
    rtn true;
  ok = true;
  rep(i, 3) {
    ok &= mark[i][2 - i];
  }
  rtn ok;
}

int32_t main() {
  FAST_IO;
  int a[3][3];
  rep(i, 3)
    rep(j, 3)
      cin >> a[i][j];
  int m;
  cin >> m;
  while (m--) {
    int x;
    cin >> x;
    rep(i, 3) {
      rep(j, 3) {
        if (a[i][j] == x) {
          mark[i][j] = 1;
        }
      }
    }
  }
  cout << (chk() ? "Yes" : "No") << '\n';
  rtn 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
int main() {
    int H, W, N;
    int sum = 0;
    int count = 0;
    cin >> H >> W >> N;
    int bi;
    if(H > W) {
        bi = H;
    } else {
        bi = W;
    }
    while(sum < N) {
        sum += bi;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import sys

N,Y = map(int,input().split())

for i in range(N+1):
    if Y < i * 10000:
        continue
    for j in range(N+1):
        if N < i + j or Y < i * 10000 + j * 5000:
            break
        k = N - i - j
        if k >= 0 and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")


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

int main () {
    int a, b;
    cin >> a >> b;
    int j = (a * b) % 2;

    if (j == 1) {
        cout << "Odd" << endl;
    }

    else {
        cout << "Even" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define endl '\n'
#define fori(s,n) for(int i=s;i<n;i++) 
#define forj(s,n) for(int j=s;j<n;j++) 
#define vii vector<int>
int n, m;
vii w, v;
int dp[101][100001];
int solve(int x,int rest) {
	if (x == n + 1) return 0;
	int& ret = dp[x][rest];
	if (~ret) return ret;
	int r1 = 0, r2 = 0;
	 if(rest>=w[x])
	 r1 = v[x] + solve(x + 1,rest-w[x]);
	 r2 = solve(x + 1,rest);
	return ret=max(r1, r2);
}
signed main()
{
	fast;
	memset(dp, -1, sizeof dp);
	cin >> n >> m;
	v = vii(n+1); w = vii(n+1);
	fori(1,n+1)
	{
		cin >> w[i] >> v[i];
	}
	cout << solve(1,m) << endl;
}

Measured memory_bytes: 82532
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	ll H;
	cin >> H;
	int shift = 0;
	while (1LL << (shift + 1) <= H) ++shift;
	
	ll dp[65];
	dp[0] = 1;
	for (int i = 1;i <= shift;++i) {
		dp[i] = 2 * dp[i - 1] + 1;
	}
	cout << dp[shift] << endl;

	return 0;
}


Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._

  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  val a = readLine.trim.split(' ').map(_.toInt)
  val isWinLast = Array.tabulate(k + 1){_ ⇒ true}
  for (i ← 0 to k){
    if (isWinLast(i)){
      for (j ← 0 until upperBound(a, k - i)) {
        isWinLast(i + a(j)) = false
      }
    }
  }
  println(
    if (isWinLast.last) "Second"
    else "First"
  )
  def upperBound(array: Array[Int], target: Int): Int = {
    var left = 0
    var right = array.length
    while(left < right){
      val mid = (left + right) / 2
      if (array(mid) <= target){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}

Measured memory_bytes: 28996