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

using namespace std;

typedef pair<int,int> P;

void addGame(int a1, const vector<queue<int>>& a, const int day, queue<tuple<int,int,int>>& q) {
  if (a[a1].empty()) return;
  int a2 = a[a1].front();
  if (a1 == a[a2].front()) q.push( make_tuple(a1,a2,day));
}

int main() {
  int n;
  int ans = 0;
  cin >> n;

  vector<queue<int>> a(n+1);

  for (int i=1; i<n+1; i++) {
    for (int j=0; j<n-1; j++) {
      int ai;
      cin >> ai;
      a[i].push(ai);
    }
  }

  queue<tuple<int,int,int>> games;

  vector<bool> used(n+1,false);
  for (int i=1; i<n+1; i++) {
    if (used[i]) continue;
    int j = a[i].front();
    if (i == a[j].front()) {
      used[i]=true; used[j]=true;
      games.push(make_tuple(i,j,1));
    }
  }

  while(!games.empty()) {
    int a1,a2,day;
    tie(a1,a2,day) = games.front();
    ans = max(ans, day);
    games.pop();

    a[a1].pop();
    a[a2].pop();

    addGame(a1,a,day+1,games);
    addGame(a2,a,day+1,games);
  }


  for (auto ai : a) {
    if (ai.size() > 0 ) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 5376
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long t[310];
long long ret=-inf;
int pr[320];
vector<int>P;
int lim[]={8,5,3,2,2,2,2};
int now[10];
long long tmp[310];
void dfs(int a){
	if(a==7){
		for(int i=0;i<310;i++)tmp[i]=0;
		long long val=0;
		for(int i=1;i<=300;i++){
			bool ok=true;
			int var=i;
			for(int j=0;j<7;j++){
				int cnt=0;
				while(var%P[j]==0){
					var/=P[j];
					cnt++;
				}
				if(cnt>now[j])ok=false;
			}
			if(!ok)continue;
			tmp[var]+=t[i];
			if(var==1)val+=t[i];
		}
		for(int i=2;i<300;i++){
			val+=max(0LL,tmp[i]);
		}
		ret=max(ret,val);
		return;
	}
	for(int i=0;i<=lim[a];i++){
		now[a]=i;
		dfs(a+1);
	}
}
int main(){
	int a;scanf("%d",&a);
	pr[0]=pr[1]=-1;
	for(int i=2;i<300;i++){
		if(pr[i]==0){
			pr[i]=1;
			P.push_back(i);
			for(int j=i+i;j<300;j+=i)pr[j]=-1;
		}
	}
	for(int i=0;i<a;i++){
		int p,q;scanf("%d%d",&p,&q);
		t[p]+=q;
	}
	dfs(0);
	printf("%lld\n",ret);
}

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

const int maxn=2e5+5;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin>>a>>b;
	if(b*2>=a) cout<<0<<endl;
	else cout<<a-b*2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007

int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        bool n;

        //cout<<~(1);
        //cout<<~n;
        cin>>n;

        if( n )
            cout<<0;
        else
            cout<<1;
    }
    return 0;
}












Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
string s;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	s="&"+s;
	for(int i=1;i<s.size();i++){
		if(i%2==1){
			if(s[i]=='L'){
				cout<<"No"<<endl;
				return 0;
			}
		}
		if(i%2==0){
			if(s[i]=='R'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	} 
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int n;
	long long int m;
	cin >> n;
	cin >> m;
	long long int k;
	k = m / n;
	long long int t = 0;
	if (n == 1)cout << m;
	else {
		for (int i = 1; i < k + 1; i++) {
			if (m%i == 0)t = i;
		}
		cout << t;
	}
}

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

int bfs(int start, int n, int m, int pass, vector<int> a, vector<int> b)
{
	bool all_visit = true;
	vector<bool> visited(n, false);
	queue<int> que;
	que.push(start);
	int i;
	while(!que.empty())
	{
		for(i = 0; i < m; i++)
		{
			if(a.at(i) == que.front() && visited.at(b.at(i)-1) == false && i != pass)
			{
				que.push(b.at(i));
			}
			if(b.at(i) == que.front() && visited.at(a.at(i)-1) == false && i != pass)
			{
				que.push(a.at(i));
			}
		}
		visited.at(que.front()-1) = true;
		que.pop();
	}
	for(i = 0; i < n; i++)
	{
		if(visited.at(i) == false)
		{
			all_visit = false;
		}
	}
	if(all_visit) return 0;
	else return 1;
}

int main(void)
{
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	int i;
	int ans = 0;
	for(i = 0; i < m; i++)
	{
		cin >> a.at(i) >> b.at(i);
	}
	for(i = 0; i < m; i++)
	{
		ans += bfs(1, n, m, i, a, b);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],x,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x>n) ans++;
        else a[x]++;
    }
    for(int i=1;i<=n;i++){
        if(a[i]==0) continue;
        if(a[i]<i) ans+=a[i];
        else if(a[i]>i) ans+=a[i]-i;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
ll dp[16][1<<16];
ll stt[1<<16];
ll a[16][16];
ll n;
ll fun(ll mask)
{
	ll ans=0;
	rep(i,0,n)
	{
		if(!(mask&(1<<i)))
			continue;
		rep(j,i+1,n)
		{
			if(mask&(1<<j))
				ans+=a[i][j];
		}
	}
	return ans;
}
void solve()
{
	cin>>n;
	rep(i,0,n)
	{
		rep(j,0,n)
		cin>>a[i][j];
	}
	rep(i,1,1<<n)
	{
		stt[i]=fun(i);
		dp[n-1][i]=stt[i];
	}
	// what_is(stt[5]);
	repr(i,0,n-1)
	{
		rep(mask,0,(1<<n))
		{
			if(mask==0)
			{
				dp[i][mask]=stt[mask];
				continue;
			}
			for(ll k = mask; k > 0; k = (k-1) & mask)
			{
		    	dp[i][mask] = max(dp[i][mask],dp[i+1][k]+stt[(k^mask)]);
		    }
		}
	}
	// rep(i,0,n)
	// {
	// 	rep(j,0,(1<<n))
	// 	cout<<dp[i][j]<<" ";
	// 	cout<<endl;
	// }
	ll num=(1<<(n));
	// cout<<num<<endl;
	cout<<dp[0][num-1]<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 8960
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    c = input()

    print('vowel') if c in list('aeiou') else print('consonant')

if __name__ == '__main__':
    main()

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

if 400<=n<=599:
    print(8)
elif 600<=n<=799:
    print(7)
elif 800<=n<=999:
    print(6)
elif 1000<=n<=1199:
    print(5)
elif 1200<=n<=1399:
    print(4)
elif 1400<=n<=1599:
    print(3)
elif 1600<=n<=1799:
    print(2)
elif 1800<=n<=1999:
    print(1)







Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int H, N; cin >> H >> N;

  vector<int> weight(N); // 攻撃力(A)
  vector<int> value(N);  // MP(B)
  rep(i, N) cin >> weight[i] >> value[i];

  vector<vector<ll>> dp(N + 1, vector<ll>(H + 1, INF));
  rep(i, N + 1) dp[i][0] = 0;
  for (int i = 0; i < N; ++i){
    //cout << "=======" << endl;
    for (int h = 0; h <= H; ++h){
      chmin(dp[i + 1][h], dp[i][h]);
      chmin(dp[i + 1][h], dp[i + 1][max(h - weight[i], 0)] + value[i]);
      //cout << "dp[" << i + 1 << "][" << h << "]:" << dp[i + 1][h] << endl;
    }
  }
  cout << dp[N][H] << endl;
}


Measured memory_bytes: 78592
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

LL mod_pow(LL a, LL p) {
	LL tmp = a;
	LL ret = 1LL;
	while (p) {
		if (p & 1) ret = (ret*tmp)%MOD;
		p >>= 1;
		tmp = (tmp*tmp) % MOD;
	}
	return ret;
}

struct node {
public:
	int h, w, parent;
	node(int _h, int _w, int _p) :h(_h), w(_w), parent(_p) {};
	vector<int> childs;
	void add_child(int idx) {
		childs.PB(idx);
	}
};

using graph = vector<node>;
int h[100];
graph g;
int n;
LL dp1[100], dp2[100];

int build_tree(int s, int e, int parent=-1, int offset=0) {
	if (s == e)return -1;
	int x = 1e9 + 5;
	FOR(i, s, e)x = min(x, h[i]-offset);
	g.PB(node(x, e - s, parent));
	int myIdx = g.size() - 1;
	if(parent!=-1)g[parent].w -= g[myIdx].w;
	int start = s;
	FOR(i, s, e) {
		if (h[i] == x + offset) {
			auto childIdx = build_tree(start, i, myIdx, x+offset);
			if (childIdx != -1) g[myIdx].add_child(childIdx);
			start = i + 1;
		}
	}
	auto childIdx = build_tree(start, e, myIdx, x + offset);
	if (childIdx != -1) g[myIdx].add_child(childIdx);
	return myIdx;
}

pair<LL, LL> calc(int idx = 0) {
	LL p1 = 1, p2 = 1;
	for (auto child : g[idx].childs) {
		auto tmp = calc(child);
		p1 = (p1*tmp.first) % MOD;
		p2 = (p2*(tmp.first+tmp.second)) % MOD;
	}
	return MP((p1*mod_pow(2, g[idx].h)) % MOD, (((p2*mod_pow(2, g[idx].w)) % MOD + (p1*mod_pow(2, g[idx].h)) % MOD) % MOD - p1 * 2 + 2 * MOD) % MOD);
}

int main() {
	scanf("%d", &n);
	REP(i, n)scanf("%d", &h[i]);
	build_tree(0, n);
	auto ans = calc();
	cout << ans.second << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> l(2*n);
    rep(i, 2*n)cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    rep(i, n){
        ans += l[2*i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
from math import gcd
#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
n = int(input())
A = list(map(int, input().split()))
ans = 0

x = [0]*n
y = [0]*n
for i in range(1, n):
    x[i] = gcd(x[i-1], A[i-1])
for i in reversed(range(n-1)):
    y[i] = gcd(y[i+1], A[i+1])

for i in range(n):
    tmp = gcd(x[i], y[i])
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 86312
N = int(input())
I = list(map(int, input().split()))

print(str(I).replace(',','').replace('[','').replace(']',''))
for i in range(1, N):
    v = I[i]
    j = i - 1 
    while (j >= 0 and I[j] > v):
        I[j+1] = I[j]
        j -= 1
    I[j+1] = v
    print(str(I).replace(',','').replace('[','').replace(']',''))




Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int n, v;
    cin >> n;
    queue<int> q;
    vector<int> V;
    rep(i,n) {
        cin >> v;
        V.pb(v);
    }
    sort(all(V));
    rep(i,V.size()) {
        q.push(V[i]);
    }
    double res = 0;
    int f = q.front();
    q.pop();
    int s = q.front();
    q.pop();
    res = (f+s)/2.0;
    while(q.size() > 0) {
        int qq = q.front();
        res = (qq+res)/2.0;
        q.pop();
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.next_usize();
    let mut a = Vec::with_capacity(n);
    for _ in 0..n {
        let ai = sc.next_usize();
        a.push(f(ai));
    }
    
    let a = a.into_iter().map(|m| if m > 2 { 2 } else { m }).collect_vec();
    let two = a.iter().filter(|j| **j == 2).count();
    let one = a.iter().filter(|j| **j == 1).count();
    let zero = a.iter().filter(|j| **j == 0).count();
    
    if zero == 0 {
        println!("Yes");
    } else {
        if zero <= two {
            println!("Yes");
        } else if zero - 1 == two && one == 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn f(u: usize) -> usize {
    if u % 2 != 0 {
        0
    } else {
        1 + f(u / 2)
    }
}

pub struct Scanner {
    buf: std::collections::VecDeque<String>,
}

impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: std::collections::VecDeque::new(),
        }
    }
    
    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }
            
            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }
    
    pub fn next<T: std::str::FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf.pop_front().unwrap().parse().unwrap_or_else(|_| panic!("Couldn't parse!"))
    }
    
    pub fn next_usize(&mut self) -> usize {
        self.next()
    }
    
    pub fn next_isize(&mut self) -> isize {
        self.next()
    }
    
    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
    
    pub fn next_string(&mut self) -> String {
        self.next()
    }
    
    pub fn next_char(&mut self) -> char {
        self.next()
    }
    
    pub fn next_float(&mut self) -> f64 {
        self.next()
    }
}


Measured memory_bytes: 8496
d,n = map(int,input().split())
if d==0:
    if n==100:
        print(101)
    else:
        print(n)
elif d==1:
    if n==100:
        print(100*101)
    else:
        print(100*n)
else:
    if n==100:
        print(10000*101)
    else:
        print(10000*n)

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<int,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	VI ck(3);
	rep(i, n){
		if(a[i] %4==0) ck[0]++;
		else if(a[i] %2==0) ck[1]++;
		else ck[2]++;
	}
	bool ok=false;
	if(ck[1] == 0 && ck[0]>0 && ck[0] + 1 >= ck[2]) ok=true;
	if(ck[1] >0 && ck[0]>0 &&  ck[0] >= ck[2]) ok=true;
	if(ck[1] >1 && ck[2]==0) ok=true;
	//dbg(ck[0], ck[1],ck[2]);
	cout <<(ok? "Yes":"No")<<"\n";
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int> h(n);
	for (auto &v : h) {
		cin >> v;
	}

	int ans = 0;
	while (count(begin(h), end(h), 0) != n) {
		int maxH = 0, maxIdx = 0;
		for (int i = 0; i < n; i++) {
			if (maxH < h[i]) {
				maxH = h[i];
				maxIdx = i;
			}
		}

		for (int i = maxIdx; i >= 0; i--) {
			if (h[i] == 0) {
				break;
			}

			h[i]--;
		}

		for (int i = maxIdx + 1; i < n; i++) {
			if (h[i] == 0) {
				break;
			}

			h[i]--;
		}
		ans++;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# N人の参加者, 参加者iの身長はAi, 背番号の差の絶対値が身長の和に等しい組
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
memo = defaultdict(int)
ans = 0
for i, x in enumerate(A, 1):
    ans += memo[i-A[i-1]]
    memo[i+A[i-1]] += 1
print(ans)


Measured memory_bytes: 61544
S = input()
cnt_n = 0
cnt_w = 0
cnt_s = 0
cnt_e = 0

for i in S:
    if i == "N":
        cnt_n += 1
    elif i == "W":
        cnt_w += 1
    elif i == "S":
        cnt_s += 1
    else:
        cnt_e += 1

if cnt_n * cnt_w * cnt_s * cnt_e > 0:
    print("Yes")
elif (cnt_n == 0 and cnt_s == 0) and cnt_e * cnt_w > 0:
    print("Yes")
elif (cnt_n * cnt_s > 0) and (cnt_e == 0 and cnt_w == 0):
    print("Yes")
else:
    print("No")

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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    bool t = true;
    for(int i = 0; i < 1000; i++){
        if(i % 2 == 0){
            c -= b;
            if(c <= 0) break;
        }else{
            a -= d;
            if(a <= 0){
                t = false;
                break;
            }
        }
    }

    cout << (t ? "Yes" : "No") << endl;

    return 0;
}

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

static const int N = 100;

int main(){
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i - 1] >> p[i];
    }

    for (int i = 1; i <= n; i++) m[i][i] = 0;
    for (int l = 2; l <= n; l++){
        for (int i = 1; i <= n - l + 1; i++){
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j - 1; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

struct edge { ll from; ll to; ll cost; };

void dfs(vector<vector<edge>>& edges, vll& dist, ll ck, unordered_set<ll>& seen, ll cdist) {
  dist[ck] = cdist;
  for(auto ed : edges[ck]) {
    if(seen.find(ed.to) == seen.end()) {
      seen.emplace(ed.to);
      dfs(edges, dist, ed.to, seen, cdist + ed.cost);
    }
  }
}

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N;
  cin >> N;
  
  vector<vector<edge>> edges(N, vector<edge>());
  
  rep(i, N-1) {
    ll a; ll b; ll c;
    cin >> a >> b >> c;
    a--; b--;
    edges[a].push_back({a, b, c});
    edges[b].push_back({b, a, c});
  }
  
  ll Q; ll K;
  cin >> Q >> K;
  
  K--;
  //前計算
  vector<ll> dist(N);
  unordered_set<ll> seen;
  seen.emplace(K);
  dfs(edges, dist, K, seen, 0);
  
  rep(i, Q) {
    ll x; ll y;
    cin >> x >> y;
    x--; y--;
    ll r = dist[x] + dist[y];
    fin(r);
  }
}

Measured memory_bytes: 26276
from collections import deque
n,m=map(int,input().split())
graph=[[] for i in range(3*n)]
for i in range(m):
    s,e=map(int,input().split())
    graph[s-1].append(e+n-1)
    graph[s+n-1].append(e+2*n-1)
    graph[s+2*n-1].append(e-1)
s,t=map(int,input().split())
s-=1;t-=1
queue=deque([s])
length=0
dist=[-1]*(3*n)
dist[s]=0
while queue:
    v=queue.popleft()
    for i in graph[v]:
        if dist[i]!=-1:continue
        dist[i]=dist[v]+1
        queue.append(i)
print(dist[t] if dist[t]==1 else dist[t]//3)


Measured memory_bytes: 60124
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int d;
    cin >> d;
    double x = 0, y = 0, pi = acos(-1);
    for (int i = 0; i < 100000; ++i) {
        double dd = pi*d*i/180;
        x += cos(dd); y += sin(dd);
        if(hypot(x, y) <= 1e-10) {
            cout << i+1 << "\n";
            return 0;
        }
    }
    return 0;
}

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

char s[200001];

int main(){
	scanf("%s",s);
	int l,r;
	for(int i=0;;i++){
		if(s[i]=='A'){
			l=i;
			break;
		}
	}
	for(int i=strlen(s);;i--){
		if(s[i]=='Z'){
			r=i;
			break;
		}
	}
	printf("%d\n",r-l+1);
	return 0;
}

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

using namespace std;

int h, w;
vector<string> maze;

int dh[4] = {-1, 1, 0, 0};
int dw[4] = {0, 0, 1, -1};

int count(pair<int, int> start) {
    queue<pair<int, pair<int, int>>> q;
    int ret = 0;
    q.push(make_pair(0, start));
    vector<vector<int>> cur_maze(h, vector<int>(w, -1));
    while (!q.empty()) {
        auto front = q.front();
        q.pop();
        int cost = front.first;
        pair<int, int> cur = front.second;
        if (cur_maze[cur.first][cur.second] < 0 || cur_maze[cur.first][cur.second] > cost) {
            ret = max(ret, cost);
            cur_maze[cur.first][cur.second] = cost;
        } else {
            continue;
        }
        for (int i = 0; i < 4; i++) {
            int nh = cur.first + dh[i];
            int nw = cur.second + dw[i];
            if (nh >= 0 && nh < h && nw >= 0 && nw < w && maze[nh][nw] == '.' && cur_maze[nh][nw] < 0) {
                q.push(make_pair(cost + 1, make_pair(nh, nw)));
            }
        }
    }
    return ret;
}

int main() {
    cin >> h >> w;
    maze.resize(h);
    for (int i = 0; i < h; i++) {
        cin >> maze[i];
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int k = 0; k < w; k++) {
            if (maze[i][k] == '.') {
                pair<int, int> start = make_pair(i, k);
                ans = max(ans, count(start));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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


def nCr(n, r, mod):
    r = min(r, n-r)
    x = y = 1
    for i in range(r):
        x = (x * (n - i)) % mod
        y = (y * (i + 1)) % mod

    return (x * pow(y, mod - 2, mod)) % mod


ans = pow(2, n, mod) - nCr(n, a, mod) - nCr(n, b, mod) - 1
ans += mod if ans < 0 else 0
ans += mod if ans < 0 else 0
print(ans)


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

using namespace std;

int main()
{
  int N, K;
  vector<int> length;
  int sum = 0;
  cin >> N >> K;

  for (int i = 0; i < N; i++)
  {
    int temp;
    cin >> temp;
    length.push_back(temp);
  }

  sort(length.begin(), length.end(), greater<int>());

  for (int i = 0; i < K; i++)
  {
    sum += length[i];
  }

  std::cout << sum << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

// ?¨±?????????????????
#define EPS (1e-10)

int main(){
	int n;
	cin >> n;
	double x1,y1,x2,y2,x3,y3,x4,y4;
	for(int i = 0; i < n; ++i){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        if ( fabs( (y2-y1)*(x4-x3) - (y4-y3)*(x2-x1) ) < EPS) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
	}
    return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <ctype.h>

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


int main(int argc, const char * argv[])
{
    std::string a = "", b = "";
    cin >> a >> b;
    if (a.size() > b.size())
    {
      cout << "GREATER";
    }
    else if (a.size() < b.size())
    {
      cout << "LESS";
    }
    else
    {
        size_t i = 0;
        for (; i < a.size(); ++i)
        {
          if ((a[i] - '0') == (b[i] - '0'))
          {
            continue;
          }
          if ((a[i] - '0') > (b[i] - '0'))
          {
            cout << "GREATER";
            break;
          }
          else
          {
            cout << "LESS";
            break;
          }
        }
        if (i == a.size())
        {
          cout << "EQUAL";
        }
    }
}


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

using namespace std;

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

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

//==================================

int N;
Vl A;
Vl csum;
ll a;
Vl can;


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

    cin >> N;
    A.resize(N);
    csum.resize(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        csum[i + 1] = csum[i] + A[i];
    }

    int left = 0;
    int right = 0;
    ll ans = L_INF;
    Vl s(4);
    for (int i = 2; i <= N - 2; i++) {
        while (left < i - 1) {
            ll u = abs((csum[i] - csum[left]) - csum[left]);
            ll v = abs((csum[i] - csum[left + 1]) - csum[left + 1]);
            if (u > v) {
                ++left;
            }
            else {
                break;
            }
        }

        while (right < N - 1) {
            ll u = abs((csum[N] - csum[right]) - (csum[right] - csum[i]));
            ll v = abs((csum[N] - csum[right + 1]) - (csum[right + 1] - csum[i]));
            if (u > v) {
                ++right;
            }
            else {
                break;
            }
        }

        s[0] = csum[left];
        s[1] = csum[i] - csum[left];
        s[2] = csum[right] - csum[i];
        s[3] = csum[N] - csum[right];
        sort(s.begin(), s.end());
        ans = min(ans, abs(s[3] - s[0]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>

using namespace std;

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

    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<vector<int>> q(5003,vector<int>(5003,0)); 

    int maxlen=0;
    for(int j=0;j<n;j++)
    {
        for(int k=0;k<n;k++)
            if(s[j]==s[k] && q[j][k]<(k-j)) 
        {
            q[j+1][k+1]=q[j][k]+1;
            if(maxlen<q[j+1][k+1]) maxlen=q[j+1][k+1];
        }
    }
    cout<<maxlen;

    return 0;
}

Measured memory_bytes: 98432
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    ll A, D;
    string B, C;
    cin >> A >> B;
    C += B.at(0);
    C += B.at(2);
    C += B.at(3);
    D = stoi(C);
    cout << A * D /100 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,a[50]={},sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=2;i<=n-1;i++)
	{
		if(a[i]>min(a[i-1],a[i+1])&&a[i]<max(a[i-1],a[i+1]))sum++;
	}	
	cout<<sum<<endl;
	return 0;
}

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

int main() {
  int n;  cin >> n;
  
  int dm[n];
  for (int i = 0; i < n; i++)
    cin >> dm[i];
  
  sort(dm, dm + n, greater<int>());
  
  int score = 1;
  for (int i = 1, x = dm[0]; i < n; i++) {
    if (x > dm[i]) {
      score++;
      x = dm[i];
    }
  }
  
  cout << score << endl;
}


Measured memory_bytes: 256
def examD(mod):
    n, m = LI()
    x = LI()
    y = LI()
    ans = 0; ans1 = 0; ans2 = 0
    for i in range(n-1):
        surface = (x[i+1]-x[i])*(n-1-i)*(i+1)
        ans1 = (ans1+surface)%mod
    for i in range(m-1):
        surface = (y[i+1]-y[i])*(m-1-i)*(i+1)
        ans2 = (ans2+surface)%mod
    ans = ans1*ans2%mod
    print(ans)

import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD(mod)

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


#define ALL(a) 		(a.begin() , a.end())
#define ll 			long long int
#define ff          first
#define ss          second
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,a,b)   	for(ll i =a;i<=b;i++)
#define inf 		INT_MAX
#define pll 		pair<ll,ll>
#define mat 		vector<vector<ll>>

const ll INF = 1e18;
void init(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE 
		freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
}
 
bool checkp2(ll n){
	return n && !(n & (n-1));
}

ll numsetbit(ll n){
	ll count = 0;
	for(;n;count++){
		n = n & (n-1);
	}
	return count;
}
 
ll power(ll x , ll n , ll mod){
    x = x % mod;
	ll po = 1;
	while(n){
		if(n & 1){
			po = (po*x) % mod;
		}
		n = n>>1;
		x = ((x % mod) * (x % mod)) % mod;
	}
	return po;
}
 
bool isPrime(ll x){
	if(x < 2)
		return 0;
	for(ll y = 2; y * y <= x; y++){
		if(x % y == 0){
			return 0;
		}
	}
	return true;
}





void solve(){


	ll n;
	cin>>n;
	vector<ll> a(n);
	for(ll i = 0;i<n;i++){
		cin>>a[i];
	}
	ll count = 0;
	ll MAX = a[0];

	for(ll i = 1;i<n;i++){
		if(MAX > a[i])
			count+= MAX - a[i];
		MAX = max(MAX , a[i]);
	}

	cout<<count<<endl;
}

int main(){
	
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 4780
#include <iostream>
#include <vector>
using namespace std;
typedef long long int ll;

int h,w;
int field[550][550];

int main(){
	cin >> h >> w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> field[i][j];
		}
	}
	vector<pair<int,int> > p;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j==w-1){
				if(field[i][j]%2==1){
					if(i<h-1){
						field[i][j]--;
						field[i+1][j]++;
						p.push_back(make_pair(i+1,j+1));
						p.push_back(make_pair(i+2,j+1));
					}
				}
			}
			else{
				if(field[i][j]%2==1){
					field[i][j]--;
					field[i][j+1]++;
					p.push_back(make_pair(i+1,j+1));
					p.push_back(make_pair(i+1,j+2));
				}
			}
		}
	}
	cout << p.size()/2 << endl;
	for(int i=0;i<p.size()/2;i++){
		cout << p[2*i].first << " " << p[2*i].second << " " << p[i*2+1].first << " " << p[i*2+1].second << endl;
	}
}

Measured memory_bytes: 5232
while True:
    n,x = map(int,input().split())
    if n==x==0: break
    s = 0
    
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x: s+=1
    print(s)
 


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll X;
    cin >> X;
    ll ans = 0;
    ll mo = 100;
    while (mo < X) {
        ans++;
        mo += mo / 100;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=100010;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct edge{int to;ll cost;};
vector<edge> G[100010];
vector<ll> dijkstra(int s,vector<edge> g[]){
    vector<ll> d(MAX,LINF);
    priority_queue<P,vector<P>,greater<P>> q;
    d[s]=0;
    q.push(P(0,s));
    while(!q.empty()){
        P p=q.top();q.pop();
        int v=p.second;
        for(int i=0;i<(int)g[v].size();i++){
            edge e=g[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                q.push(P(d[e.to],e.to));
            }
        }
    }
    return d;
}
int main(){
	int n;cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		G[a].push_back({b,c});
		G[b].push_back({a,c});
	}
	int q,k;cin>>q>>k;k--;
	vector<ll> d=dijkstra(k,G);
	while(q--){
		int x,y;cin>>x>>y;x--;y--;
		cout<<d[x]+d[y]<<endl;
	}
	return 0;
}


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

int main() {
	// your code goes here
	int a,b,c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
	    cout << "YES\n";
	} else {
	    cout << "NO\n";
	}
	return 0;
}


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

int main() {
    ios::sync_with_stdio(0);cin.tie(NULL); cout.tie(NULL);
    
    ll arr[6];
    for(ll i=1;i<=5;i++)cin>>arr[i];
    for(ll i=1;i<=5;i++){
        if(!arr[i])
            cout<<i;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200005;
int n,i,a[N],f,t,pt[N];
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		pt[a[i]]=i;
	}
	for(i=n-1;i>=1&&pt[i]<pt[i+1];--i);
	if(i<1)
	{
		printf("0");
		return 0;
	}
	t=1,f=i+1;
	for(--i;i>=1;--i)
	{
		if(pt[i]<pt[f]&&pt[f]<pt[i+1]||pt[i+1]<pt[i]&&pt[i]<pt[f]||pt[f]<pt[i+1]&&pt[i+1]<pt[i])
		{
			++t;
			f=i+1;
		}
	}
	printf("%d",t);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<pair<int, int>, int> mp;
  int ans = 0;
  rep2(i, 1, n+1){
    string s = to_string(i);
    int fr = s.front() - '0', re = s.back() - '0';
    mp[make_pair(fr, re)]++;
  }
  rep(i, 10){
    rep(j, 10){
      ans += mp[make_pair(i, j)] * mp[make_pair(j, i)];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a=1
    l=[int(x) for x in input().split()]
    if not(0 in l):
        for i in range(len(l)):
            a=a*l[i]
            if a>10**18:
                a=-1
                break
    else:
        a=0
    print(a)
main()

Measured memory_bytes: 21640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N, X;
    cin >> N >> X;
    int ans = 1;
    int L, d = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> L;
        d += L;
        if (d <= X)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  ll a,b,c;
  std::cin >> a>>b>>c;
  if(c<=a){
    std::cout << a-c<<" "<<b << std::endl;
  }
  else{
    std::cout << 0<<" "<<max(0ll,b-c+a) << std::endl;
  }
}

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

int main(){
  int n;
  while(cin >> n,n){
    int count = 0;
    for(int i=n+1; i <= 2*n; ++i){
      int tmp_c = 0;
      for(int j=1; j*j<= 2*n; ++j){
	if(i%j==0){++tmp_c;}
      }
      if(tmp_c==1){++count;/*cout << "sosuu is " << i << endl;*/}
    }
  
    cout << count << endl;
  }
  return 0;
}
      



Measured memory_bytes: 3080
import java.util.*;

public class Main{
        public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int nodesCount = sc.nextInt();;
        int edgeCount = 0;
        
        int[][] edgeArray = new int[nodesCount][nodesCount];
        
        Vertex[] nodes = new Vertex[nodesCount];
        
        //populate the graph
        for(int i = 0; i < nodesCount; i++){ //each node will have its own row
            int vertex = sc.nextInt();//first number on the row
            nodes[i] = new Vertex(vertex); //the index and the id will be shifted off by one, so be careful
            edgeCount = sc.nextInt();//second number on the row, also called degree
            for(int j = 0; j < edgeCount; j++){
                edgeArray[i][sc.nextInt() - 1] = 1;
            }
        }
        
        int time = 1;
        int j = 0;
        for(int i = 0; i < nodesCount; i++) {
        	//dfs, keep track of Vertex.d and Vertex.f
        	if(nodes[i].visited == false)
        		time = 1+ dfs(time,i,nodes,edgeArray);
        }
        
        //print time!
        for(int i = 0; i < nodesCount; i++) {
        	System.out.println(nodes[i].id + " " + nodes[i].d + " " + nodes[i].f);
        }
        sc.close();
    }
    
    public static int dfs(int time, int row, Vertex[] nodes, int[][]edgeArray) {
    	if(nodes[row].visited) {
    		return time-1;
    	}
    	else {
    		nodes[row].d = time;
    		nodes[row].visited = true;

    		//for(int i = nodes.length-1; i >= 0; i--) {
    		for(int i = 0; i < nodes.length; i++) {
    			if(edgeArray[row][i] > 0) {
    				time =  dfs(time+1, i, nodes, edgeArray);
    			}
    		}
    		nodes[row].f = time +1;
    		return time+1;
    	}
    }
}

class Vertex{
    int id;
    int d; //discover time
    int f; //finish time
    boolean visited;
    
    public Vertex(int id){
        this.id = id;
        visited = false;
    }
}


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


int main() {
ll n,k;
cin >> n >> k;
vector<double> vec(n);
double cnt = 0,ans = 0;
rep(i,n) {
  double a;
  cin >> a;
  double b;
  b = a * (a +1) / 2;
  b /= a;
  vec.at(i) = b;
}
rep(i,k) cnt += vec.at(i);
for (int i = k;i <= n;i++) {
  if (cnt > ans) {
    ans = cnt;
  }
  cnt -= vec.at(i-k);
  if (i != vec.size()) cnt += vec.at(i);
  }
  
printf("%.10f\n" ,ans);

return 0;
}



Measured memory_bytes: 4840
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

typedef long long ll;
const int maxn=2010;
const ll inf=1e18;
int n,x;
int f[maxn][maxn], a[maxn];
ll ans;

int main(){
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	ans=inf;
	for(int i=1;i<=n;i++){
		f[i][0]=a[i];
		for(int j=1;j<=n;j++) f[i][j]=min(f[i][j-1], a[(i+n-1-j)%n+1]);
	}
	for(int i=0;i<=n;i++){
		ll tot=0;
		for(int j=1;j<=n;j++) tot+=f[j][i];
		ans=min(ans, tot+1ll*i*x);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>

using namespace std;

int main(){
	int n,x;
	scanf("%d",&n);

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}


Measured memory_bytes: 2760