akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define zero(x) (((x)>0?(x):-(x))<eps)
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int>PII;
const double eps=1e-6;
const double pi=acos(-1.0);
const LL mod=1e18+7;
const int INF=0x3f3f3f3f;
//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;}
VI v[100010];
int a[100010];
int vis[100010];
int dfs(int x){
    vis[x]=1;
    if(SZ(v[x])==1) return a[x];
    int tmp,sum=a[x]*2;
    for(auto i:v[x]){
        if(!vis[i]){
            tmp=dfs(i);
            sum-=tmp;
            if(sum<0||tmp==-1||tmp>a[x]) return -1;
        }
    }
    if(sum>a[x]) return -1;
    return sum;
}
int main(){
//    freopen("in.in","r",stdin);
//    freopen("out.out",";w",stdout);
    int n,x,y;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<n;i++){
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    if(n==2) return 0*puts(a[1]==a[2]?"YES":"NO");
    int j=1;
    while(SZ(v[j])==1) j++;
    puts(dfs(j)?"NO":"YES");
    return 0;
}
/*

*/


Measured memory_bytes: 10496
#include<iostream>
using namespace std;
int main(){
	int  h , w;
	int length;
	while(cin >> h >> w){
		if(h == 0 && w == 0) break;
			length = h*h + w*w;
			int height ; int width;
			int ansh=150,answ=150,ansl = 150*150 *2;
			for(height = 1;height <=150;height++){
				for(width = 1;width<=150;width++){
					if(height < width){
					int len = height*height + width*width;
					if((length == len && h < height ) || length < len){

								if(((ansl == len) && (ansh > height) )|| ansl > len){
										ansh = height; answ = width; ansl = len;
									}
								}
						}
				}

			}
			cout << ansh<< " " << answ << endl;
	}
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    stack<int> S;
    char s[100];
    int a, b;

    while (cin >> s)
    {
        if (s[0] == '+')
        {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(b + a);
        }
        else if (s[0] == '-')
        {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(b - a);
        }
        else if (s[0] == '*')
        {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(b * a);
        }
        else
        {
            S.push(atoi(s));
        }        
    }
    
    cout << S.top() << "\n";

    return 0;
}


Measured memory_bytes: 3184
def main():
    n = int(input())
    *h, = map(int, input().split())

    if len(h) == 1:
        print(h[0])
        return

    # 0: total, 1: prev water
    dp = [[0, 0] for _ in range(n+1)]
    for i in range(n):
        n_prev = dp[i][1]
        if n_prev >= h[i]:
            dp[i+1][0] = dp[i][0]
            dp[i+1][1] = h[i]
        else:
            dp[i+1][0] = dp[i][0] + h[i] - n_prev
            dp[i+1][1] = dp[i][1] + h[i] - n_prev
    print(dp[n][0])


main()


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

class MainClass
{
    static void Main()
    {
        string s = Console.ReadLine();
        var ep = Console.ReadLine().Split().Select(_=>int.Parse(_)+8000).ToArray();

        var dpx = new HashSet<int>(16001);
        var dpy = new HashSet<int>(16001);

        int index = 0;
        int fx = 8000;
        while (index < s.Length && s[index] == 'F')
        {
            fx++;
            index++;
        }
        dpx.Add(fx);
        dpy.Add(8000);

        bool dir = false;

        while (index < s.Length)
        {
            while (index < s.Length && s[index] == 'T')
            {
                dir = !dir;
                index++;
            }

            int dist = 0;
            while (index < s.Length && s[index] == 'F')
            {
                dist++;
                index++;
            }

            if (dir)
            {
                var ny = new HashSet<int>(16001) ;
                foreach (var i in dpy)
                {
                    ny.Add(i - dist);
                    ny.Add(i + dist);
                }
                
                dpy = ny;
            }
            else
            {
                var nx = new HashSet<int>(16001);
                foreach (var i in dpx)
                {
                    nx.Add(i - dist);
                    nx.Add(i + dist);
                }
                dpx = nx;
            }
        }

        Console.WriteLine((dpx.Contains(ep[0]) && dpy.Contains(ep[1])) ? "Yes" : "No");
    }
}


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

int main() {
	int N, M, D, ans = 0, k;
	cin >> N >> M >> D;
	vector<string> a(N);
	for (string& i : a) cin >> i;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= M - D; ++j) {
			for (k = 0; k < D; ++k) {
				if ('#' == a[i][j + k]) break;
			}
			if (D == k) ++ans;
		}
	}
	for (int i = 0; i <= N - D; ++i) {
		for (int j = 0; j < M; ++j) {
			for (k = 0; k < D; ++k) {
				if ('#' == a[i + k][j]) break;
			}
			if (D == k) ++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3144
raw_input = input()
l = raw_input.split()
A = int(l[0])
B = int(l[1])
C = int(l[2])

count = 0

if A == B:
    count = count + 1
if B == C:
    count = count + 1
if C == A:
    count = count + 1
    
if count == 1:
    print('Yes')
else:
   print('No') 

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    int N;
    cin>>N;
    if((N%10==9)||(N/10==9)){
       cout<<"Yes"<<endl;
    }else{
       cout<<"No"<<endl;
    }
	return(0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <memory.h>

char S[310];
int K;
int len;
int res;
int memo[310][310][310];

int srch(int ll, int rr, int kk)
{
	if(memo[ll][rr][kk] != -1)
		return memo[ll][rr][kk];
	if(ll==rr)
		return 1;
	if(ll+1==rr){
		if(S[ll]==S[rr] || kk>0)
			return 2;
		else
			return 1;
	}
	int tmp;
	int mx=0;
	tmp = srch(ll+1, rr, kk);
	if(tmp > mx)
		mx = tmp;
	tmp = srch(ll, rr-1, kk);
	if(tmp > mx)
		mx = tmp;
	if(S[ll]==S[rr]){
		tmp = srch(ll+1, rr-1, kk) + 2;
		if(tmp > mx)
			mx = tmp;
	}
	else if(kk>0){
		tmp = srch(ll+1, rr-1, kk-1) + 2; 
		if(tmp > mx)
			mx = tmp;
	}
	memo[ll][rr][kk] = mx;
	return mx;
}

void solve()
{
	len = strlen(S);
	memset(memo, -1, sizeof(memo) );
	res = srch(0, len-1, K);
	printf("%d\n", res);
}

int main()
{
	scanf("%s", S);
	scanf("%d", &K);
	solve();
	return 0;
}

Measured memory_bytes: 116608
import sys
S=input()
T=input()
if len(S)<len(T):
    print('UNRESTORABLE')
    sys.exit()
L=[]
for i in range(len(S)-len(T)+1):
    K=S[i:i+len(T)]
    flag=True
    #print(K)
    for j in range(len(T)):
        if T[j]!=K[j] and K[j]!='?':
            flag=False
    if flag:
        U=S[:i]+T+S[i+len(T):]
        L.append(U.replace('?','a'))
#print(L)
if len(L)!=0:
    print(min(L))
else:
    print('UNRESTORABLE')

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

int main(){
    int N, Y;
    cin >> N >> Y;
    
    int flag=0;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=N-i; j++){
            if(10000*i+5000*j+1000*(N-(i+j))==Y && (N-(i+j)>=0)){
                flag=1;
                cout << i <<" "<< j <<" "<< N-(i+j) << endl;
                break;
            }
        }
        if(flag) break;
    }
    if(flag==0) cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

ll compare_ll(const void *a, const void *b){
    return *(ll*)a - *(ll*)b;
}

int main(){
	int n;
	ll a[300001]={0}, ans=0;
	scanf("%d",&n);
	for(int i=0; i<3*n; i++){ scanf("%lld",&a[i]); }

    qsort( a, 3*n, sizeof(ll), compare_ll );
//	for(int i=0; i<3*n; i++){ ans += (a[1+i*3]); }
//	for(int i=n; i<2*n; i++){ ans += (a[i]);	 }
	for(int i=0; i<n;	i++){ ans += (a[n+i*2]); }
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) v.size()
#define all(x) x.begin(), x.end()
#define prec(x) fixed << setprecision(x)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)
#define speedup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve(){
	int N; cin >> N;
    int ans = 0;
    rep(i, 2, 1000009) {
        int cur = 0;
        while (N % i == 0) {
            cur++;
            N /= i;
        }
        rep(j, 1, 9999) {
            if (cur < j) break;
            ans++; cur -= j;
        }
    }
    if (N > 1) ans++;
    cout << ans;
}

int32_t main() {
    speedup;

    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    // test{
        solve();
    // }

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string x = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int f(char c){
  if('a' <= c && c <= 'z')return (int)(c - 'a');
  else return (int)(c - 'A' + 26);
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    int(n); if(!n)break;
    int k[n]; scn(n, k);
    string s; cin >> s;

    rep(i, s.size()){
      cout << x[(f(s[i]) - k[i % n] + 52) % 52];
    }
    kara;





//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1236
from functools import reduce

N = int(input())
Sn = [''.join(sorted(list(input()))) for _ in range(N)]
dic = {}
for k in range(len(Sn)):
  if Sn[k] in dic:
    dic[Sn[k]] += 1
  else:
    dic[Sn[k]] = 1

ans = list(map(lambda x:x*(x-1)//2, list(dic.values())))
ans = sum(ans)
print(ans)


Measured memory_bytes: 19996
#include <stdio.h>
#include <math.h>
#define input_int(a) scanf("%d", &a);
#define input_char(a) scanf("%s", a);

int min(int a, int b) {
	if(a > b) return b;
	return a;
}

int max(int a, int b) {
	if(a > b) return a;
	return b;
}

int main() {
	int a, b;
	input_int(a);
	input_int(b);
	int ans = max(a + b, max(a - b, a * b));
	printf("%d\n", ans);
	//char buffer[128];
	//scanf("%s", buffer);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(N+1, 1);
	vector<bool> b(N+1, false);
	b[1] = true;
	for (int i = 0; i < M; ++ i) {
		int x, y;
		cin >> x >> y;
		-- a[x];
		++ a[y];
		if (b[x]) {
			if (a[x] == 0) b[x] = false;
			b[y] = true;
		}
	}
	int r = 0;
	for (int i = 1; i <= N; ++ i) {
		if (b[i]) ++ r;
	}
	cout << r << endl;
}


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

int n, cnt, a[55];
int main() {
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		if(a[i] != i) cnt++;
	}
	if(cnt==0 || cnt==2) cout<<"YES";
	else cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int h,n;
  scanf("%d %d",&h,&n);
  for(int loop=0;loop<n;loop++){
    int a;
    scanf("%d",&a);
    h-=a;
  }
  if(h<=0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define bfl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i--)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


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

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

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

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

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

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

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

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

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

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


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


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    int n;
	    cin>>n;
	    n=n%10;
	    if(n==3)
	    cout<<"bon"<<bn;
	    else if(n==0 || n==1 || n==6 || n==8)
	    cout<<"pon"<<bn;
	    else cout<<"hon"<<bn;
	   
	   
	   
	    
	}
	
	return 0;
}


Measured memory_bytes: 3616
N, K = map(int, input().split())
sunuke = [0]*N
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        sunuke[a-1] += 1

ans = 0
for i in range(N):
    if sunuke[i-1] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 9184
def decode(s,a,b):
    result=""
    for c in s:
        if c.isalpha():
            result+=chr((a*(ord(c)-ord("a"))+b)%26+ord("a"))
        else:
            result+=c
    return result
for rep in xrange(input()):
    line=raw_input()
    for a in xrange(26):
        for b in xrange(26):
            d=decode(line,a,b)
            if "this" in d or "that" in d:
                print d
                break

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
signed main(){
    long long n , k , a , b , array[100005]={} , c=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        array[a]+=b;
    }
    
    int i=1;
    while(true){
        c+=array[i];
        if(c>=k){
            break;
        } else {
            i++;
        }    
    }
    cout<<i<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int  
#define lh long double
#define f(a,b,i) for(ll i=a;i<b;i++)

int main() {


  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   
   ll n,m;
   cin>>n>>m;
   cout<<(n*(n-1)+m*(m-1))/2;
    return 0;
}


   

    


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

Y = X.copy()
Y.sort()

Y[int(N/2)]


for i in range(N):
    if X[i] <= Y[int(N/2)-1]:
        print(Y[int(N/2)])
    else:
        print(Y[int(N/2)-1])


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

int n;
int arr[3001];
ll dp[3001][3001];

int main() {
    cin >> n;
    for (int i=0;i<n;i++) {cin >> arr[i];}

    for (int L=n-1;L>=0;L--) {
        for (int R=L;R<=n-1;R++) {
            if (L==R) {dp[L][R]=arr[L];}
            else {dp[L][R]=max(arr[L]-dp[L+1][R],arr[R]-dp[L][R-1]);}
        }
    }
    cout << dp[0][n-1] << endl;

}


Measured memory_bytes: 49720
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int s;
  cin >>s;
  vector<int>vec(1000000);
  vec.at(1)=s;
  repl(i,2,1000000) {
    if((vec.at(i-1))%2==0) {
      vec.at(i)=vec.at(i-1)/2;
    }
    else {
      vec.at(i)=3*vec.at(i-1)+1;
    }
  }
  
  //cout<<vec.at(7)<<vec.at(8)<<vec.at(3)<< endl;
  
  
  
  int count=0;
 repl(i,1,999999) {
   repl(j,2,1000000) {
     if((vec.at(j)==vec.at(i)) &&(i !=j)){
       cout << max(i,j)<< endl;
       count++;
       break;
 
       
     }
   }
 if(count==1) {
   break;
 }
 
 }
  
  
  
}
  
 

Measured memory_bytes: 4096
#include <stdio.h>
#include<math.h>
using namespace std;

bool rangeCheck(int x,int y){
	if(x >= 0 && x <= 9 && y>=0 && y <= 9)return true;
	else{
		return false;
	}
}

int main(){
	int paper[10][10],x,y,size;
	for(int i=0;i<10;i++){
		for(int k=0;k<10;k++){
			paper[i][k] = 0;
		}
	}

	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
		switch(size){
		case 1:
			paper[x][y]++;
			if(rangeCheck(x,y-1))paper[x][y-1]++;
			if(rangeCheck(x,y+1))paper[x][y+1]++;
			if(rangeCheck(x-1,y))paper[x-1][y]++;
			if(rangeCheck(x+1,y))paper[x+1][y]++;
			break;
		case 2:
			paper[x][y]++;
			if(rangeCheck(x-1,y-1))paper[x-1][y-1]++;
			if(rangeCheck(x,y-1))paper[x][y-1]++;
			if(rangeCheck(x+1,y-1))paper[x+1][y-1]++;
			if(rangeCheck(x-1,y))paper[x-1][y]++;
			if(rangeCheck(x+1,y))paper[x+1][y]++;
			if(rangeCheck(x-1,y+1))paper[x-1][y+1]++;
			if(rangeCheck(x,y+1))paper[x][y+1]++;
			if(rangeCheck(x+1,y+1))paper[x+1][y+1]++;
			break;
		case 3:
			paper[x][y]++;
			if(rangeCheck(x-1,y-1))paper[x-1][y-1]++;
			if(rangeCheck(x,y-1))paper[x][y-1]++;
			if(rangeCheck(x+1,y-1))paper[x+1][y-1]++;
			if(rangeCheck(x-1,y))paper[x-1][y]++;
			if(rangeCheck(x+1,y))paper[x+1][y]++;
			if(rangeCheck(x-1,y+1))paper[x-1][y+1]++;
			if(rangeCheck(x,y+1))paper[x][y+1]++;
			if(rangeCheck(x+1,y+1))paper[x+1][y+1]++;
			if(rangeCheck(x,y-2))paper[x][y-2]++;
			if(rangeCheck(x-2,y))paper[x-2][y]++;
			if(rangeCheck(x+2,y))paper[x+2][y]++;
			if(rangeCheck(x,y+2))paper[x][y+2]++;
			break;
		}
	}

	int count = 0,max = -1;
	for(int i=0; i< 10;i++){
		for(int k=0; k < 10; k++){
			if(paper[i][k] == 0)count++;
			max = (max >= paper[i][k])?max:paper[i][k];
		}
	}
	printf("%d\n%d\n",count,max);

    return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
// static const int MAX = 100005;
static const int NMAX = 5005;

// typedef priority_queue<int, greater<int>> RevQ;
int N, L;
string s;
vector<int> G[NMAX];


int main(){
  cin >> N;
  cin >> s;
  L = 0;
  rep(i, N) {
    if ( i >= N - L ) break; // added after TLE
    int p = max(1, L);
    if (i + p >= N) continue;
    REP(j, i+p, N) {
      if (s[i] == s[j]) G[i].push_back(j);
    }
    for (int j : G[i]) {
      // cout << "J ==== " << j << endl;
      if (N - L + 10 < j) continue; // added after TLE
      int k = 1;
      while (i + k < j) {
        if (s[i + k] != s[j + k]) break;
        // cout << "i: "<< i << " k: " << k << endl;
        k++;
      }
      L = max(L, k);
    }
  }

  cout << L << endl;
}


Measured memory_bytes: 56576
f=1;$<.map{|x|f>0||puts;a=x.chop.split("").map &:to_i;while a.size<5;a[0,0]=f=0;end;a.map!{|n|["* "," *"][n/5]+?=+?**(r=n%5)+" "+?**(4-r)};8.times{|i|puts a.map{|s|s[i]}.join}}

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

struct UnionFind
{
    vector<int> par;
    UnionFind(int n) : par(n, -1){ }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y){
        return root(x) == root(y);
    }
    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

struct Edge
{
    int a, b;
    double dist;
    bool operator<(const Edge& o) const{
        return dist < o.dist;
    }
};

struct Graph
{
    int n;
    vector<Edge> es;

    double kruskal(){
        sort(es.begin(), es.end());

        UnionFind uf(n);
        double min_dist = 0;
        for (int ei = 0; ei < es.size(); ei++)
        {
            Edge& e = es[ei];
            if(!uf.issame(e.a, e.b)){
                min_dist += e.dist;
                uf.merge(e.a, e.b);
            }
        }
        return min_dist;
    }
};

double d(double x, double y, double z, double u, double v, double w){
    double dx = x - u, dy = y - v, dz = z - w;
    return sqrt(dx * dx + dy * dy + dz * dz);
}

int N;
int main() {
    while (true)
    {
        cin >> N;
        double in[N][4];
        if(N == 0) break;
        for (int i = 0; i < N; i++)
        {
            cin >> in[i][0] >> in[i][1] >> in[i][2] >> in[i][3];
        }

        Graph g;
        g.n = N;
        for (int i = 0; i < N; i++)
        {
            for (int j = i+1; j < N; j++)
            {
                Edge e;
                e.a = i, e.b = j;
                e.dist = max((double)0, d(in[i][0], in[i][1], in[i][2], in[j][0], in[j][1], in[j][2]) - in[i][3] - in[j][3]);
                g.es.push_back(e);
            }
        }
        cout << fixed << setprecision(3) << g.kruskal() << endl;
    }

}


Measured memory_bytes: 3376
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

bool isPrime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }

  return true;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  string N;
  cin >> N;

  ll g = 0;
  ll p = 0;
  ll ans = 0;
  for (char s : N) {
    if (s == 'g') {
      if (g <= p) {
        g++;
        ans += 0;
      } else {
        p++;
        ans++;
      }
    } else {
      if (g <= p) {
        g++;
        ans--;
      } else {
        p++;
        ans += 0;
      }
    }

    // cout << "g: " << g << " p: " << p << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

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

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,k,ans=0;

vector<int> G[maxn];

int dep[maxn],fa[maxn];

void dfs(int u){
	dep[u]=1;
	for(auto v:G[u]){
		fa[v]=u;
		dfs(v);
		dep[u]=max(dep[u],dep[v]+1);
	}
	if(dep[u]==k&&fa[u]>1)dep[u]=0,ans++;
}

void Work(){
	dfs(1);
	iout(ans);
}

void Init(){
	read(n,k);
	REP(i,1,n){
		int x;read(x);
		if(i>1)G[x].PB(i);else ans+=x!=1;
	}
}

int main(){
	Init();
	Work();
	return 0;
}


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

class Main {
	static boolean[] isExist = new boolean[2001];
	static int[] A;
	static int n;
    public static void main( String[] args ) {
        try {
	      	BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
			n = Integer.parseInt( kb.readLine() );
			String[] buf = kb.readLine( ).split( " " );
			A = new int[n];
			int sum = 0;
			for( int i=0; i<n; i++ ) {
				A[i] = Integer.parseInt( buf[i] );
				sum += A[i];
			}
			solve( 0, sum );
			
			StringBuilder output = new  StringBuilder( );
			int q = Integer.parseInt( kb.readLine() );
			buf = kb.readLine( ).split( " " );
			for( int i=0; i<q; i++ ) {
				if( isExist[ Integer.parseInt( buf[i] ) ] ) {
					output.append( "yes" ).append( "\n" );			
				} else {
					output.append( "no" ).append( "\n" );
				}
			}
			System.out.print( output );            
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
	public static void solve( int p, int t )
	{
		isExist[t] = true;
		if( p < n ) {
			solve( p+1, t-A[p] );
			solve( p+1, t );
		}
		return;
	}
}

Measured memory_bytes: 19128
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


class BIT():
    def __init__(self,init_value):
        self.n = len(init_value)
        self.tree = [0]*(self.n+1)
        for i in range(1,self.n+1):
            x = init_value[i-1]
            while i <= self.n:
                self.tree[i] += x
                i += i & (-i)

    def update(self,i,x):  # i(1-index)番目の値を+x
        while i <= self.n:
            self.tree[i] += x
            i += i & (-i)
        return

    def query(self,i):  # 1番目からi(1-index)番目までの和を返す
        res = 0
        while i > 0:
            res += self.tree[i]
            i -= i & (-i)
        return res


N,Q = MI()

A,B = [0]*N,[0]*N
A[0],B[0] = N-2,N-2
A[N-1],B[N-1] = -(N-2),-(N-2)

I,J = BIT(A),BIT(B)
i_min,j_min = N,N
ans = (N-2)**2

for _ in range(Q):
    a,x = MI()
    if a == 1:
        ans -= I.query(x)
        if x < i_min:
            i_min = x
            y = J.tree[1]
            J.update(1,x-2-y)
            J.update(j_min,-(x-2-y))
    else:
        ans -= J.query(x)
        if x < j_min:
            j_min = x
            y = I.tree[1]
            I.update(1,x-2-y)
            I.update(i_min,-(x-2-y))

print(ans)


Measured memory_bytes: 74540
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	hh := make([]int, n)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		hh[i] = getNextInt(scanner)
	}

	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}

	seg := Segment{}

	seg.init(n + 1)

	for i := 0; i < n; i++ {
		mx := seg.max(0, hh[i])
		seg.maximize(hh[i], mx+aa[i])
	}

	fmt.Fprintln(writer, seg.bucket[seg.h-1][0])
	writer.Flush()
}

// Segment ...
type Segment struct {
	n, h, i, chunk int
	unit           []int
	bucket         [][]int64
}

func (seg *Segment) init(n int) {
	seg.n = n
	seg.unit = make([]int, 1)
	seg.unit[0] = 1
	seg.bucket = make([][]int64, 1)
	seg.bucket[0] = make([]int64, n)

	chunk := 8
	for i := 0; n > 1; i++ {
		n = (n-1)/chunk + 1
		seg.bucket = append(seg.bucket, make([]int64, n))
		seg.unit = append(seg.unit, seg.unit[i]*chunk)
	}
	seg.h = len(seg.unit)
	seg.chunk = chunk
}

func (seg *Segment) maximize(index int, value int64) {
	var max int64
	seg.bucket[0][index] = value
	for seg.i = 0; seg.i < seg.h-1; seg.i++ {
		s := index - index%seg.chunk
		t := s + seg.chunk
		if t > len(seg.bucket[seg.i]) {
			t = len(seg.bucket[seg.i])
		}
		parent := index / seg.chunk
		max = 0
		for i := s; i < t; i++ {
			if max < seg.bucket[seg.i][i] {
				max = seg.bucket[seg.i][i]
			}
		}
		seg.bucket[seg.i+1][parent] = max
		index /= seg.chunk
	}
}

func (seg *Segment) max(l, r int) int64 {
	var max int64
	if seg.n < r {
		r = seg.n
	}
	for index := l; index < r; index += seg.unit[seg.i] {
		for seg.i = 0; seg.i < seg.h-1 && index%seg.unit[seg.i+1] == 0; seg.i++ {
			if index+seg.unit[seg.i+1] >= r {
				break
			}
		}
		if max < seg.bucket[seg.i][index/seg.unit[seg.i]] {
			max = seg.bucket[seg.i][index/seg.unit[seg.i]]
		}
	}

	return max
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int _b=(b),i=(a);i<_b;++i)
#define ROF(i, b, a) for(int _a=(a),i=(b);i>_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long int ll; typedef pair<int,int> PII;typedef unsigned long long int ull;
typedef vector<int>VI; typedef vector<ll> VL; typedef vector<PII> VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}

string w;
int main() {
	IO();
	cin >> w;
	int ans = 0;
	for (auto& ch : w) ans ^= (ch - 'a' + 1);
	if (ans) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop pop_back()
#define sz size()
using namespace std;
typedef long long ll;
bool isPrime(ll n)
{
    if(n==1)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
        return false;
    return true;
}
int lcm(ll a, ll b)
{
    ll temp = __gcd(a, b);

    return temp ? (a / temp * b) : 0;
}
unordered_map<char,ll>mapp;
ll ma=-999,mi=10000000000;
///////////////////////////////////////////
ll n,m,i,j,ii,in=-1,cnt,sum;
vector<ll>vi[27];
string s,t;
long double r;
ll a[40],b[40],x,y;
int main(){
    cin>>s;
    for(i=0;i<s.sz-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2;
            return 0;
        }
    }
    for(i=0;i<s.sz-2;i++){
        if(s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3;
            return 0;
        }
    }
    cout<<"-1 -1";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a,b,c;
	int sum=700;
	cin>>a>>b>>c;
	if(a=='o') sum+=100;
	if(b=='o') sum+=100;
	if(c=='o') sum+=100;
	cout<<sum;
	return 0; 
} 

Measured memory_bytes: 256
loop do
  ans,res=gets.split
  break if(ans.to_i | res.to_i)==0
  hit=0
  blow = 0
  ans.size.times do |i|
    hit+=1 if ans[i]==res[i]
  end
  ans.each_char do |c|
    blow+=1 if res.include? c
  end
  print hit," ",blow-hit,"\n"
end

Measured memory_bytes: 2476
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int k;
    cin>>k;
    vec 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>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

int main(){
  int x;
  cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << endl;
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define mp(n, o) map<n, o>
#define so(n) sort(n.begin(), n.end())
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗

int main() {
  int N, p = 0, q = 0, a = 1000;
  ci(N);
  ve(int) W(N);
  rep(i, N) {
    ci(W.at(i));
    p += W.at(i);
  }
  rep(i, N) {
    q += W.at(i);
    a = min(a, abs(q - (p - q)));
  }
  co(a);
} 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const double Pi=acos(-1.0);
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    string a,b;
    cin>>a>>b;
    int flag=1;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i])flag=0;
    }
    if(flag)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  long long suma =0,sumb =0,sumc =0,sumd =0;
for (int i = 0; i <= N; i++) {
  suma += i;
}
 for (int i = 0; i <= N; i+=3) {
  sumb += i;
}
  for (int i = 0; i <= N; i+=5) {
  sumc += i;
}
   for (int i = 0; i <= N; i+=15) {
  sumd += i;
}
     cout<<suma +sumd-sumb-sumc<<endl;
  return 0; 
}


Measured memory_bytes: 3592
import scala.io.StdIn

object Main extends App {
  val Array(n, a, b, c, d) = StdIn.readLine().split(" ").map(_.toInt)
  val S  = StdIn.readLine()

  def solve(s : String, a: Int, b: Int, c: Int, d: Int ): String = {
    val s1 = s.slice(a, c)
    val s2 = s.slice(b, d)
    val s3 = s.slice(b - 2, d + 1)    

    if (s1.contains("##")) 
      return "No"

    if (s2.contains("##")) 
      return "No"

    if (d < c) {
      if (! s3.contains("...")) 
        return "No"
    }

    "Yes"
  }

  println(solve(S, a, b, c, d))
}
  



Measured memory_bytes: 31172
/* ex6_2 melo */
#include <stdio.h>
#include<string.h>
#define SIZE 101
int main(void){
    char sente[SIZE];
    int length;
    scanf("%s",sente);
    length=(int)strlen(sente);
    printf("%c%d%c\n",sente[0],length-2,sente[length-1]);
    return 0;
}

Measured memory_bytes: 128
H,W = [int(x) for x in input().split()]
a = [0]*H
ng_h = []
ng_w = []
for i in range(H):
    a[i] = [1 if x == '#' else 0 for x in input()]

for i in range(H):
    if(sum(a[i]) == 0):
        ng_h.append(i)
for j in range(W):
    sumw = 0
    for i in range(H):
        sumw += a[i][j]
    if(sumw == 0):
        ng_w.append(j)


for i in range(H):
    flag = False
    for j in range(W):
        if((not i in ng_h) and (not j in ng_w)):
            flag = True
            print('#' if a[i][j] == 1 else '.',end = '')
    if(flag):
        print()

Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <set>
#include <cstring>
using namespace std;
typedef long long ll;
int x,y;
int main(void){
   scanf("%d%d",&x,&y);
   int ans=2000000001;
   if(x<=y)ans=min(ans,y-x);
   if(-x<=y)ans=min(y+x+1,ans);
   if(-x<=-y)ans=min(ans,x-y+2);
   if(x<=-y)ans=min(ans,-y-x+1);
   printf("%d\n",ans);
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	string s,t="",u="",v="";cin>>s;
	int n=s.size();
	rep(i,n-1){
		if(s[i]=='A')t.PB('Y');
		else if(s[i]=='B'&&s[i+1]=='C'){
			t.PB('X');
			i++;
		}
        else t.PB(s[i]);
	}
	n=t.size();
	ll sumy[n+1];
	sumy[0]=0;
	if(t[0]=='Y')sumy[0]=1;
	for(int i=1;i<n;++i){
		if(t[i]=='Y'){
			sumy[i]=sumy[i-1]+1;
		}
		else if(t[i]=='X'){
			sumy[i]=sumy[i-1];
		}
		else{
			sumy[i]=0;
		}
	}
	ll ans=0;
	rep(i,n){
		if(t[i]=='X')ans+=sumy[i];
	}
	cout<<ans<<endl;
}


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

using namespace std;
							// Typedef's  start //
typedef long long   ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

							//	Typedef's end //
							//	Define's start //
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'

							// Define's end //
int dp[110];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	memset(dp,0,sizeof dp);
	dp[0] = 1;
	vi doces = {4,7};
	for(auto atual : doces){
		REP(i,atual,105){
			dp[i] |= dp[i-atual];
		}
	}
	cin >> n;
	if(dp[n])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	basicIO "io"
	"os"
	"sort"
	"strconv"
)

func main() {
	protagonist(os.Stdin, os.Stdout)
}

type Restaurant struct {
	num   int
	city  string
	point int
}

type RS []Restaurant

func (rs RS) Swap(i, j int) { rs[i], rs[j] = rs[j], rs[i] }
func (rs RS) Len() int      { return len(rs) }
func (rs RS) Less(i, j int) bool {
	if rs[i].city < rs[j].city {
		return true
	}
	if rs[i].city == rs[j].city {
		if rs[i].point < rs[j].point {
			return false
		} else {
			return true
		}
	}
	return false
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	N, _ := io.nextInt()
	rs := make(RS, N)

	for i := 0; i < N; i++ {
		num := i + 1
		city := io.nextString()
		point, _ := io.nextInt()

		rs[i] = Restaurant{num, city, point}
	}
	sort.Sort(rs)
	for _, v := range rs {
		io.PutInt(v.num)
	}
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


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

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

using namespace std;

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

    int min_value = min(N * A, B);

    cout << min_value << endl;

    return 0;
}


Measured memory_bytes: 256