akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>

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


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}




int main() {

	int n, k;
	cin >> n >> k;
	vector<int> treat(n,0);

	rep(i, 0, k) {
		int temp;
		cin >> temp;
		rep(i, 0, temp) {
			int p;
			cin >> p;
			treat[p - 1] = 1;
		}
	}
	int ans = 0;
	rep(i,0,n){
		if (treat[i] == 0) {
			ans += 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	
	int n, a;
	cin >> n >> a;
	cout << (n*n) - a << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    ll n, d;
    cin >> n >> d;
    cout << ((n % (d * 2 + 1) == 0)? n / (d * 2 + 1) : n / (d * 2 + 1) + 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int b[100000];
    for(int i=0;i<10000;i++) b[i]=0;
    for(int i=10000;i<100000;i++){
        b[i]=b[i-1];
        if(i%10==i/10000&&i/10%10==i/1000%10) b[i]+=1;
    }
    int a,c;
    cin>>a>>c;
    cout<<b[c]-b[a-1]<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
long long n,i,a,b,c,d,t,l,r;
int main()
{
	cin>>n>>a>>b>>c>>d;
	b-=a;n--;
	for(i=0;i<=n;i++)
	{
		t=c*i-c*(n-i);
		l=t-(d-c)*(n-i);
		r=t+(d-c)*i;
		if(l<=b&&b<=r)
		{
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

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

const int N = 300 + 10;
const int MOD = 1000000007;
const int LOG = 20;
const int INF = 1000000010;

int n, m, dp[N][N][N], mn[N][N][3], l[N], r[N], x[N];
vector<int> vr[N];

int CNT(int r, int g, int b, int L){
	int cnt = 0;
	cnt += (r >=L);
	cnt += (g >= L);
	cnt += (b >= L);
	return cnt;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		cin >> l[i] >> r[i] >> x[i];
		vr[r[i]].pb(i);
	}
	memset(mn, 31, sizeof mn);
	for (int i = 1; i <= n; i++){
		for (int j = i; j <= n; j++){
			for (int k = 1; k <= m; k++){
				if (l[k] >= i && r[k] >= j) mn[i][j][x[k]] = min(r[k], mn[i][j][x[k]]);
			}
		}
	}
	dp[0][0][0] = 1;
	for (int r = 0; r <= n; r++){
		for (int g = 0; g <= n; g++){
			for (int b = 0; b <= n; b++){
				int Mx = max(r, max(g, b));
				int Mn = min(r, min(g, b));
				for (auto u:vr[Mx]){
					int L = l[u];
					if (CNT(r, g, b, L) != x[u]) dp[r][g][b] = 0;
				}
				dp[Mx + 1][g][b] += dp[r][g][b], dp[Mx + 1][g][b] %= MOD;
				dp[r][Mx + 1][b] += dp[r][g][b], dp[r][Mx + 1][b] %= MOD;
				dp[r][g][Mx + 1] += dp[r][g][b], dp[r][g][Mx + 1] %= MOD;
			}
		}
	}
	ll ans = 0;
	for (int r = 0; r <= n; r++){
		for (int g = 0; g <= n; g++){
			for (int b = 0; b <= n; b++){
				int mx = max(r, max(g, b));
				if (mx == n) ans += dp[r][g][b], ans %= MOD;
			}
		}
	}
	cout<< ans;










	return 0;
}

Measured memory_bytes: 114944
x,y = map(int,input().split())

z = 0

if x == 1 and y == 1:
    print(1000000)
    exit()

if  x == 1:
    z += 300000
elif x == 2:
    z += 200000
elif x == 3:
    z += 100000

if  y == 1:
    z += 300000
elif y == 2:
    z += 200000
elif y == 3:
    z += 100000

print(z)


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

int main(){
int a,n,count=1;

  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  a=vec.at(0);
  while(a!=2){
    a=vec.at(a-1);
    count++;
    if(count>=n){
      cout<<-1<<endl;
      return 0;
    }
  }
    cout<<count;
}


Measured memory_bytes: 640
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    if i+1 <= N//2:
        if a:
            chk[N-i-1] = 1
    else:
        sum_chk = sum(chk[N-i-1::N-i])
        s2 = sum_chk%2
        if a:
            if s2 == 0:
                chk[N-i-1] = 1
        else:
            if s2 == 1:
                chk[N-i-1] = 1

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

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

ans = 1

for i in range(2,n):
    flag = 0
    num = n
    num2 = i
    while True:
        num = num/i
        if(num >= i):
            num2 = num2*i
            flag = 1
        else:
            break

    if(ans<num2 and flag == 1):
        ans=num2

print(ans)


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
using std::unique;
#include<iostream>
using std::cin;
#include<vector>
using std::vector;
#define reg register

int n;
vector<char> V;

int main(void){
	reg int i;
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		static char ch;
		cin>>ch;
		V.push_back(ch);
	}
	V.erase(unique(V.begin(),V.end()),V.end());
	printf("%d\n",(int)V.size());
	return 0;
}

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

int n;
vector<int> b;

int main(){

  cin >> n;
  b = vector<int>(n-1);
  rep(i,n-1) cin >> b[i];

  int sum = 0;
  rep(i,n){
    if(i == 0) sum += b[i];
    else if(i == n-1) sum += b[i-1];
    else sum += min(b[i], b[i-1]);
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;
int left(int i) { return i*2; }
int right(int i){ return i*2+1;}
int parent(int i){return i/2;}
int H;
void maxHeapify(int* A, int i) {
    int l = left(i);
    int r = right(i);
    int maxind = i;
    if(l <= H && A[l] > A[maxind]) {
        maxind = l;
    }
    if(r <= H && A[r] > A[maxind]) {
        maxind = r;
    }

    if(maxind != i) {
        swap(A[i], A[maxind]);
        maxHeapify(A, maxind);
    }
}
void buildMaxHeap(int* A) {
    for(int i = H/2; i >= 1; i--) {
        maxHeapify(A, i);
    }
}

int main() {
    cin >> H;
    int *A = new int[H+1];
    for(int i=1; i<=H; i++) {
        cin >> A[i];
    }
    buildMaxHeap(A);
    for(int i=1; i<=H; i++) {
        cout << " " << A[i];
    }
    cout << "\n";
}



Measured memory_bytes: 4964
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):
    B = deque(A[:K])
    S = sum(A[:K])
    ms = S
    mi = 0
    for i in range(K, N):
        S -= B.popleft()
        S += A[i]
        B.append(A[i])
        if S > ms:
            ms = S
            mi = i - K + 1

    ans = 0
    for i in range(mi, mi+K):
        ans += (A[i] + 1) / 2
    return ans


def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27452
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
int main()
{
  	//freopen(".in","r",stdin);
  	//freopen(".out","w",stdout);
  	int x=read(),y=read();
  	printf("%d\n",x+(y/2));
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    if ((B - A) % 2 == 0) {
        write((B - A) / 2);
    }
    else {
        if (A - 1 < N - B) {
            write(A - 1 + 1 + (B - (A - 1 + 1) - 1) / 2);
        }
        else {
            write(N - B + 1 + (N - (A + N - B + 1)) / 2);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int n;
    cin>>n;
    vi v1,v2;
    int a1,a2;
    loop(i,0,n)
    {
        cin>>a1>>a2;
        v1.pb(a1);
        v2.pb(a2);
    }
    double sum = 0;
    loop(i,0,n)
    {
        loop(j,0,n)
        {
            int p = v1[i]-v1[j];
            int q = v2[i]-v2[j];
            if(i!=j)
            {
                sum += sqrt((p*p) + (q*q));
            }
        }
    }
    printf("%.10lf\n",sum/n);
    return 0;
}



Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>

using namespace std;

typedef unsigned long long ull;
const ull B= 100000007;

void contain(string a, string b){
	int al=a.length();
	int bl=b.length();
	//B???al???????¨????
	ull t=1;
	for(int i=0;i<al;i++) t*=B;
	
	//a??¨b????????????al???????????¢?????????????????\???????¨????
	ull ah=0,bh=0;
	for(int i=0;i<al;i++) ah=ah*B+a[i];
	for(int i=0;i<al;i++) bh=bh*B+b[i];
	
	//b?????´????????????????????????????????????????????\???????????§??????
	for(int i=0;i+al<=bl;i++){
		if(ah==bh) printf("%d\n",i);
		if(i+al<bl) bh=bh*B+b[i+al]-b[i]*t;
	}
}

int main(){
	bool ans;
	string T,P;
	cin>>T;
	cin>>P;
	if(T.size()>=P.size()){
		contain(P,T); //P???T?????????????????????????
	}
}

Measured memory_bytes: 5028
#include<stdio.h>
#define INF 100
int p[100][100];
int bp[50][50];
int cbp[4][50][50];
int i,j;
int m,n;
int ax,ay;

int min(int a,int b){return a<b?a:b;}

int main(){
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)return 0;
		ax=INF;ay=INF;
		for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",&p[i][j]);
		for(i=0;i<m;i++)for(j=0;j<m;j++)scanf("%d",&bp[i][j]);
		for(i=0;i<m;i++)for(j=0;j<m;j++){			
			cbp[0][i][j]=bp[i][j];
			cbp[1][i][j]=bp[m-j-1][i];
			cbp[2][i][j]=bp[m-i-1][m-j-1];
			cbp[3][i][j]=bp[j][m-i-1];
		}
		bool f;
		bool up=false;
		for(i=0;i<n-m+1;i++)for(j=0;j<n-m+1;j++){
			for(int v=0;v<4;v++){
				f=true;
				for(int k=0;k<m;k++)for(int l=0;l<m;l++){
					if(cbp[v][k][l]!=-1&&cbp[v][k][l]!=p[i+k][j+l])f=false;
				}
				if(f){	
					for(int k=0;k<m;k++){
						for(int l=0;l<m;l++){
							if(cbp[v][k][l]==p[i+k][j+l]){
								if(i+k<ax||(i+k==ax&&j+l<ay)){
									ax=i+k;
									ay=j+l;
								}
								up=true;
							}
						}
					}
				}
			}
			if(up)goto end;
		}
end:
		if(ax==100)printf("NA\n");
		else printf("%d %d\n",ay+1,ax+1);
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  string s; cin >> s; sort(s.begin(), s.end());
  string t; cin >> t; sort(t.begin(), t.end()); reverse(t.begin(), t.end());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}




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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int maxn=2e5+5;
int freq[maxn];

int main()
{
    memset(freq,0,sizeof freq);
    int n;
    cin>>n;
    f(i,n-1){
        ll x;
        cin>>x;
        freq[x]++;
    } 

    for(int i=1;i<n+1;++i)
    {
        cout<<freq[i]<<endl;
    }
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    string n;
    cin >> n;
    ll id = n.length() - 1;
    char res = n[id];
    string ans;
    if (res == '3') ans = "bon";
    else if (res == '0' | res == '1' | res == '6' | res == '8') ans = "pon";
    else ans = "hon";
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    using plli=pair<ll,int>;
    vector<plli> costidx[n];
    vll a(n-1),b(n-1);
    vll c(n-1);
    rep(i,0,n-1){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--,b[i]--;
        plli first=make_pair(c[i],a[i]);
        plli second=make_pair(c[i],b[i]);
        costidx[b[i]].push_back(first);
        costidx[a[i]].push_back(second);
    }
    int Q,k;
    cin>>Q>>k;
    k--;
    vll dist(n,INF);
    vi color(n,0);
    priority_queue<plli,vector<plli>,greater<plli>> q;
    plli iniv=make_pair(0,k);
    q.push(iniv);
    while(!q.empty()){
        plli t=q.top();
        q.pop();
        ll cost=t.first;
        int idx=t.second;
        if(color[idx]==2)continue;
        chmin(dist[idx],cost);
        color[idx]=2;
        for(auto e:costidx[idx]){
            if(color[e.second]==2)continue;
            q.emplace(e.first+cost,e.second);
            color[e.second]=1;
        }
    }
    rep(i,0,Q){
        int x,y;
        cin>>x>>y;
        x--,y--;
        cout<<dist[x]+dist[y]<<endl;
    }
    return 0;
}




Measured memory_bytes: 13936
#include <bits/stdc++.h>
using namespace std;
#define N 100001
int t, a[N], n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    sort(a + 1, a + n + 1, greater<int>());
    int add = 1, adds = 1;
    while (add < n && a[add + 1] >= add + 1) add++;
    while (adds < n && a[adds + 1] >= add) adds++;
    int ans = ((a[add] - add) & 1) || ((adds - add) & 1);
    puts(ans ? "First" : "Second");

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
struct grid {ll to; ld cost;};
using Graph = vector<vector<grid>>;
using P = pair<ld, ll>;
constexpr ll INF = 1ll<<60;	   
ld distance(ll x1, ll y1, ll x2, ll y2)
{
	return sqrt(pow(x1-x2, 2)+pow(y1-y2, 2));
}

int main(int argc, char **argv)
{
	while (true)
	{
		ll N; cin >> N;
		if (N == 0)break;
		vector<pair<ll, ll>> coo(N);
		vector<ll> id(N);
		for (ll i = 0; i < N; ++i)
		{
			ll x, y; cin >> id[i] >> x >> y;
			coo[i] = P(x, y);
			--id[i];
		}
		
		Graph G(N);
		for (ll i = 0; i < N; ++i)
		{
			for (ll j = 0; j < N; ++j)
			{
				if (id[i] == id[j]) continue;
				ld d = distance(coo[i].first, coo[i].second, coo[j].first, coo[j].second);
				if (d <= 50.0)
				{
					G[id[i]].push_back(grid{id[j], d});
				}
			}
		}

		ll m; cin >> m;
		for (ll _ = 0; _ < m; ++_)
		{
			ll s, g; cin >> s >> g;
			--s, --g;
			priority_queue<P, vector<P>, greater<P>> que;
			que.push(P(0.0, s));
			vector<ld> dist(N, INF);
			dist[s] = 0.0;
			vector<ll> his(5010, -1);
			vector<ll> ans;
			
			while (!que.empty())
			{
				P p = que.top(); que.pop();
				ll now = p.second;
				if (dist[now] < p.first) continue;

				if (now == g)
				{
					ans.push_back(g);
					ll tmp = g;
					while (tmp != s)
					{
						tmp = his[tmp];
						ans.push_back(tmp);
					}
					break;
				}

				for (auto &nv : G[now])
				{
					ld nc = dist[now] + nv.cost;
					if (dist[nv.to] > nc)
					{
						dist[nv.to] = nc;
						que.push(P(dist[nv.to], nv.to));
						his[nv.to] = now;
					}
				}
			}

			// output
			if (ans.empty())
				std::cout << "NA" << std::endl;
			else
			{
				for (ll i = 0; i < ans.size(); ++i)
					std::cout << (i ? " " : "") << ans[ans.size()-1-i]+1;
				std::cout << std::endl;
			}
		}
			
	}
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
bool check(ll a,ll b,ll c)
{
    if(a==b||b==c||a==c)
        return 0;

    if(a+b<=c||a+c<=b||b+c<=a)
        return 0;

    return 1;
}
void code()
{
    ll n;
    cin>>n;
    ll A[n];
    for(ll i=0;i<n;i++)
    {
        cin>>A[i];
    }
    sort(A,A+n);
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            for(ll k=j+1;k<n;k++)
            {
                if(check(A[i],A[j],A[k]))
                    ans++;
            }
        }
    }   
    cout<<ans<<endl;
}

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

    ll t=1;
    // cin>>t;
    while(t--)
    {
        code();
    }
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << ((a + b) * h) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    string U;
    cin>>S>>T>>A>>B>>U;
    cout<<A - (S == U)<<' '<<B - (T == U)<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
keep = [0] * (n + 1)
kep = [-1] * (n + 1)

for i in range(m):
    a = int(input())
    kep[a] = 0
keep[0] = 1
keep[1] = 0 if kep[1] == 0 else 1
for j in range(0, n - 1):
    keep[j + 2] = [0, keep[j] + keep[j + 1]][kep[j + 2]] % 1000000007
print(keep[n])


Measured memory_bytes: 76328
/*
	ダイクストラ法(無向グラフ、優先度付きキュー)
												*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1L<<60;
struct edge {
	ll to;
	ll cost;
};
typedef pair<ll, ll> P;

ll V, E;
ll from;
vector<vector<edge> > G;
vector<ll> d;

void dijkstra(ll s){
	priority_queue<P, vector<P>, greater<P> > que;
	for(ll i = 0; i < V; i++) d[i] = INF;
	d[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		ll v = p.second;
		if(d[v] < p.first) continue;
		for(ll i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}


int solve() {
	cin >> V >> E;
	if(V == 1) {
		cout << 0 << endl;
		return 0;
	}
	cin >> from;
	d.resize(V);
	G.resize(V);
	for(ll i = 0; i < E; i++) {
		ll a, b, cost;
		cin >> a >> b >> cost;
		edge e = {b, cost};
		G[a].push_back(e);
	}
	dijkstra(from);
	for(ll i = 0; i < V; i++){
		if(d[i] == INF){
			cout << "INF" << endl;
		}else{
			cout << d[i] << endl;
		}
	}
	return 0;
}

int main() {
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	return solve();
}



Measured memory_bytes: 19428
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    char b;
    cin >> b;

    unordered_map<char, char> m{
        { 'A', 'T' },
        { 'T', 'A' },
        { 'C', 'G' },
        { 'G', 'C' },
    };

    cout << m[b] << endl;

    return 0;
}


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

ll c_table[52][52] = {0,};

void calculate_c_table(int n){
    for(int i = 0; i < n+1; i++){
        c_table[i][0] = 1;
        c_table[i][i] = 1;
    }
    for(int i = 2; i < n+1; i++){
        for(int j = 1; j < i; j++){
            c_table[i][j] = c_table[i-1][j-1]+c_table[i-1][j];
        }
    }
}


int main() {
    int n, a, b;
    cin >> n >> a >> b;

    vector<ll> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    ll asum = 0;
    for(int i = 0; i < a; i++){
        asum += v[i];
    }
    double ave = (double)asum / a;
	printf("%.12f\n",ave);

    calculate_c_table(n);

    int num_in_all = count(v.begin(),v.end(),v[a-1]);
    int num_in_part = count(v.begin(),v.begin()+a,v[a-1]);
    if(v[0] != v[a-1]){
        cout << c_table[num_in_all][num_in_part] << endl;
    }else{
        ll ans = 0;
        int upper = min(num_in_all,b);
        for(int i = a; i < upper+1; i++){
            ans += c_table[num_in_all][i];
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut xs = vec![];
    let mut ys = vec![];
    for i in 0..n {
    	let x = get!();
    	if i % 2 == 0 {
        	xs.push(x);
        } else {
        	ys.push(x);
        }
    }
    xs.sort();
    ys.sort();
    use std::cmp::{max,min};
    let mut xe = -xs[0];
    let mut cc = 0;
    let mut xxx = vec![];
    for &x in xs.iter() {
    	if x == xe {
        	cc += 1;
        } else {
        	if xe > 0 {
            	xxx.push((-cc,xe));
            }
        	xe = x;
            cc = 1;
        }
    }
    xxx.push((-cc, xe));
    let mut ye = -ys[0];
    let mut yc = 0;
    let mut cc = 0;
    let mut yyy = vec![];
    for &y in ys.iter() {
    	if y == ye {
        	cc += 1;
        } else {
        	if ye > 0 {
            	yyy.push((-cc,ye));
            }
        	ye = y;
            cc = 1;
        }
    }
    yyy.push((-cc,ye));
    xxx.sort();
    yyy.sort();
    let len = (xxx.len(),yyy.len());
    let same = xxx[0].1 == yyy[0].1;
    let ans = match len {
    (1,1) if same => n/2,
    (1,1) => 0,
    (1,_) if same => n / 2 + yyy[1].0,
    (1,_) => n / 2 + yyy[0].0,
    (_,1) if same => n / 2 + xxx[1].0,
    (_,1) => n / 2 + xxx[0].0,
    _ if same => n + min(xxx[0].0+yyy[1].0, xxx[1].0+yyy[0].0),
    _ => n + xxx[0].0 + yyy[0].0,
    };
    println!("{}", ans);
}


Measured memory_bytes: 10492
def abc(N, S):
    # 答えの準備
    ans = 0
    
    # 集合
    str_set = set(S)
    
    # 答え
    return(len(str_set))


# バッチスタート
if __name__ == "__main__":
    # 標準入力処理
    # 1行目の入力を数値として扱う
    N = int(input())
    
    # N回入力
    S = []
    for i in range(0, N):
        s = input()
        S.append(s)
    
    # 関数呼び出し
    f = abc(N, S)
    
    # 答えの出力
    print(f)


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

int main(){
  int a, b;
  cin >> a >> b;
  if ( a + b == 15 )
    cout << "+" << endl;
  else if ( a * b == 15 )
    cout << "*" << endl;
  else
    cout << "x" << endl;
}

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

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    int sum = 0;
    int min_ = 1001;
    rep(i, n){
        cin >> m.at(i);
        sum += m.at(i);
        min_ = min(m.at(i), min_);
    }
    int ans = n;
    x -= sum;
    ans += x/min_;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    ll n; cin >> n;
    vector<ll> a(n - 1);
    rep(i, n - 1){
        cin >> a[i];
        a[i]--;
    }
    vector<ll> count(n);

    rep(i, n - 1){
        count[a[i]]++;
    }
    rep(i, n){
        cout << count[i] << endl;
    }
}



Measured memory_bytes: 6360
def prime_gen():
    primes = []
    n = 2
    while True:
        is_prime = True
        for p in primes:
            if p * p > n:
                break
            if n % p == 0:
                is_prime = False
                break
        if is_prime:
            primes.append(n)
            yield n
        n += 1                

def lcm(numbers):
    result = 1
    for p in prime_gen():
        while True:
            if all(map(lambda n: n == 1, numbers)):
                return result
            if not any(map(lambda n: n % p == 0, numbers)):
                break
            result *= p
            numbers = [n if n % p != 0 else n / p for n in numbers]

def chain_len(a, m):
    count = 0
    n = 1
    while True:
        n = (a * n) % m
        count += 1
        if n == 1:
            return count

while True:
    fly = map(int, raw_input().split())
    if not any(fly): break

    counts = []
    for i in range(3):
        counts.append(chain_len(fly[2 * i], fly[2 * i + 1]))
    
    print lcm(counts)

Measured memory_bytes: 4328
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int

readIntArray ()
|> fun [| n; k |] ->
    [ 1 .. k ]
    |> List.map (fun _ ->
        readIntArray ()
        readIntArray ())
    |> List.reduce Array.append
    |> Array.groupBy id
    |> Array.length
    |> (-) n
    |> printfn "%d"


Measured memory_bytes: 32668
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b,c,d;
    Scd(a);
    d = a % 10;
    a /= 10;
    c = a % 10;
    a /= 10;
    b = a % 10;
    a /= 10;

    int bi = 1;
    int tmp;
    for( int i = 0; i < 1 << 3 ; i++ ){
        bi = 1;
        tmp = a;
        tmp += ( bi & i ) ? b : -b;
        bi <<= 1;
        tmp += ( bi & i ) ? c : -c;
        bi <<= 1;
        tmp += ( bi & i ) ? d : -d;
        if( tmp == 7 ){
            int e = 1;
            printf ("%d", a);
            printf ("%c", ( e & i ) ? '+' : '-' );
            printf ("%d", b);
            e <<= 1;
            printf ("%c", ( e & i ) ? '+' : '-' );
            printf ("%d", c);
            e <<= 1;
            printf ("%c", ( e & i ) ? '+' : '-' );
            printf ("%d=7\n", d);
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
 
int main(){
	string s;
	ll k;
	cin >> s >> k;
	
	if (s.size() == 1){
		cout << k / 2 << endl;
		return 0;
	}
 
	ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
	ll len = s.size();

	string s2 = s + s;
	ll len2 = s2.size();

	string s3 = s + s + s;
	ll len3 = s3.size();

	ll ans = 0;
	for (ll i = 0; i < len - 1; i++){
		if (s[i] == s[i+1]){
			cnt1++;
			i++;
		}
	}
	
	for (ll i = 0; i < len2 - 1; i++){
		if (s2[i] == s2[i+1]){
			cnt2++;
			i++;
		}
	}

	for (ll i = 0; i < len3 - 1; i++){
		if (s3[i] == s3[i+1]){
			cnt3++;
			i++;
		}
	}

	if (k % 2 == 0){
		ll dis = cnt2 - cnt1 * 2;
		ans = cnt1 * k + dis * (k - 1);
	}else{
		ll dis = cnt3 - cnt1 * 3;
		ans = cnt1 * k + dis * (k/2);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int a,b,c,buf;
	cin >> a >> b >> c;
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	if(b>c){
		buf=b;
		b=c;
		c=buf;
	}
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	cout << a << " "<< b << " " << c << endl;
	
	return 0;
}


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

int main(){
  int i,j,n,a[3][6];
  a[0][0] = 60;
  a[1][0] = 0;
  a[2][0] = 600;
  for(i=1;i<6;i++){
    a[0][i] = a[0][i-1] + 20;
    a[1][i] = a[1][i-1] + 5;
    a[2][i] = a[2][i-1] + 200;
  }
  a[1][0] = 2;

  while(1){
    cin >> n;
    if(n == 0) break;
    int x,y,h,w,sum=0;
    for(int t=0;t<n;t++){
      cin >> x >> y >> h >> w;
      for(i=0;i<6;i++){
	if(x + y + h <= a[0][i] && w <= a[1][i]){
	  sum += a[2][i];
	  break;
	}
      }
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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] % MOD * finv[n-k] % MOD;
}


ll N, M;
vector<ll> E[200010];
ll dist[200010];
void dijkstra(){
  rep(i, 200010) dist[i] = INFL;
  dist[0] = 0;
  typedef pair<ll, ll> P;
  priority_queue<P, vector<P>, greater<P>> pque;
  pque.push({0, 0});
  while(!pque.empty()){
    P p = pque.top();
    pque.pop();
    if(dist[p.s] < p.f) continue;
    for(ll to : E[p.s]){
      if(p.f + 1 < dist[to]){
        dist[to] = p.f + 1;
        pque.push({dist[to], to});
      }
    }
  }
}
int main(){
  cin >> N >> M;
  rep(i, M){
    ll a, b;
    cin >> a >> b;
    a--, b--;
    E[a].pb(b);
    E[b].pb(a);
  }
  dijkstra();
  if(dist[N-1] <= 2){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 18408
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const ll MAX = 1e18;
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    sort(RALL(A));

    ll ans = 1;
    if (A[N-1] == 0) ans = 0;
    else {
        REP(i,N) {
            if(log10(ans) + log10(A[i]) > 18.0) {
                ans = MAX + 1;
                break;
            } else {
                ans *= A[i];
            }
        }
    }

    if (ans>MAX) OUT(-1)
    else OUT(ans)

    return 0;
}

Measured memory_bytes: 3988
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

class ATenki {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s,t;

		in >> s >> t;
		int ans = 0;

		for (int i = 0; i < s.size(); i++)
			ans += (s[i] == t[i]);

		out << ans;

	}
};

int main() {
	ATenki solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
using namespace std;
typedef long long ll;
int n,tot,a[800001];
char s[500001];
void mul(int a[],int &n,int k){
    int p=0;
    tot=0;
    for(int i=1;i<=n;i++){
        p=a[i]*k+p;
        a[i]=p%10;
        tot+=a[i];
        p/=10;
    }
    if(p)a[++n]=p;
    tot+=p;
}
void add(int a[],int &n,int k){
    int p=0;
    tot-=a[1];
    a[1]+=k;
    p=a[1]/10;
    a[1]%=10;
    tot+=a[1];
    for(int i=2;i<=n;i++){
        tot-=a[i];
        a[i]+=p;
        p=a[i]/10;
        a[i]%=10;
        tot+=a[i];
        if(!p)break;
    }
    if(p)a[++n]=p;
    tot+=p;
}
int main(){
    scanf("%s",s);
//上电脑卡死
    n=strlen(s);
    for(int i=1;i<=n;i++){
        a[i]=s[n-i]-'0';
    }
    mul(a,n,9);
    for(int i=1;i<=n;i++){
        add(a,n,9);
        if(tot%9==0&&i*9>=tot)return printf("%d",i),0;
    }
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <unordered_set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int gcd_ = std::gcd(A[0], A[1]);
  rep(i, N)
  {
    gcd_ = std::gcd(gcd_, A[i]);
  }

  if (gcd_ != 1)
  {
    cout << "not coprime" << endl;
    return 0;
  }

  int MX = 1000000;

  vector<int> num(MX + 1, 0);
  for (int i = 2; i <= MX; i++)
  {
    if (num[i] != 0)
      continue;

    for (int j = 1; i * j <= MX; j++)
    {
      num[i * j] = i;
    }
  }

  std::unordered_set<int> p;
  rep(i, N)
  {
    int tmp = A[i];
    vector<int> v;
    while (tmp > 1)
    {
      if (p.find(num[tmp]) != p.end())
      {
        cout << "setwise coprime" << endl;
        return 0;
      }
      else
      {
        v.emplace_back(num[tmp]);
      }
      tmp /= num[tmp];
    }

    for (const auto e : v)
    {
      p.insert(e);
    }
  }

  cout << "pairwise coprime" << endl;

  return 0;
}


Measured memory_bytes: 11088
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define MOD 1000000007
template <typename Type>
istream &operator>>(istream &in, vector<Type> &vec) {
    ll n = vec.size();
    for (ll i = 0; i < n; i++)
        in >> vec[i];
    return in;
}
template <typename Type>
ostream &operator<<(ostream &out, vector<Type> &vec) {
    for (auto val : vec)
        out << val << " ";
    return out;
}
#define PI 3.14159265
void solve()
{
    string n;
    cin>>n;
    ll ans = 0;
    for(ll i=0;i<n.size();i++)
    {
        ans+=int(n[i])-48;
    }
    if(ans%9==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}
int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3720
# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input());
	tama = []

	for _ in range(N):
		tmp = input().split(" ")
		x, u = tmp[0], tmp[1]
		tama.append((x, u))

	ans = 0
	for i in tama:
		x, u = i
		if u == "BTC":
			ans += float(x) * 380000
		else:
			ans += int(x)
	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(N-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append(v)
    G[v].append(u)
lis = [float('inf')] * N
ans = [0] * N
visited = [False] * N

def dfs(v):
    visited[v] = True
    i = bisect_left(lis, a[v])
    tmp = lis[i]
    lis[i] = a[v]
    ans[v] = bisect_left(lis, float('inf'))
    for c in G[v]:
        if visited[c]:
            continue
        dfs(c)
    lis[i] = tmp

dfs(0)
print('\n'.join(map(str, ans)))

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

int main(){
  string s;
  cin >> s;
  int a, b;
  for (int i = 0; i < s.size(); i++) {
    if(s.at(i)=='A'){
      i++;
      a=i;
      break;
    }
  }
  for (int j = s.size()-1; j > -1; j--) {
    if(s.at(j)=='Z'){
      b=j;
      break;
    }
  }
  cout << b-a+2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<ll> a, sum;
vector<vector<ll> > memo;

ll rec(int left, int right){
	if(memo[left][right] != -1) return memo[left][right];
	if(left == right) return memo[left][right] = 0;
	ll s = sum[right + 1] - sum[left], l, r, ans = 1e18;
	for(int i = left; i < right; i++){
		l = rec(left, i);
		r = rec(i + 1, right);
		ans = min(ans, s + l + r);
	}	
	return memo[left][right] = ans;
}


signed main(){
	scanf("%d", &n);
	a.resize(n);
	sum.resize(n + 1, 0);
	memo.resize(n, vector<ll> (n, -1));
	for(int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
		sum[i + 1] = sum[i] + a[i];
	}
	cout << rec(0, n - 1) << endl;
}

Measured memory_bytes: 4964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long X = scan.nextLong();
		int count = 0;
		double current = 100;

		//while(current < X) {
			//current = (int)(current  * 1.01);
			//count++;
		//}


		while(current < X) {
			current = current * 1.01;
			current = Math.floor(current);
			count++;
		}

		System.out.println(count);

	}

}

Measured memory_bytes: 27096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    for (int i = min(a, b); i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
            if (k == 0) {
                cout << i << endl;
                exit(0);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let k: i64 = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();
    let b: Vec<i64> = (0..m).map(|_| read()).collect();

    let mut sum_a: Vec<i64> = Vec::with_capacity(n + 1);
    let mut sum_b: Vec<i64> = Vec::with_capacity(n + 1);
    sum_a.push(0);
    sum_b.push(0);

    for i in 0..n {
        sum_a.push(sum_a[i] + a[i]);
    }
    for i in 0..m {
        sum_b.push(sum_b[i] + b[i]);
    }

    let mut ans = 0;
    let mut t = m;
    for i in 0..n + 1 {
        if sum_a[i] > k {
            continue;
        }
        while sum_a[i] + sum_b[t] > k {
            t -= 1;
        }
        ans = std::cmp::max(ans, i + t);
    }
    print!("{}", ans);
}


Measured memory_bytes: 8284