akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	l := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}

	sort.Sort(sort.IntSlice(l))

	ans := 0

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if l[i] != l[j] && l[j] != l[k] && l[k] != l[i] {
					if l[i]+l[j] > l[k] {
						ans++
					}
				}
			}
		}
	}

	fmt.Println(ans)
}


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

typedef long long ll;

ll solve(int n, const vector<ll> & cost , const vector<ll> &dist ,
	  const vector<ll> &rev_max_cost){
  ll ret = 0;
  for(int i = 0;i < n;i++){
    ret = max(ret, cost[i]);
    if (i + 1 != n){
      ret = max(ret, cost[i] - dist[i] + rev_max_cost[i+1]);
    }
  }
  return ret;
}


ll compute(int n, const ll c, const vector<ll> & dist, const vector<ll> & cal){
  // forward
  vector<ll> cost(n);
  ll cal_sum = 0;
  cost[0] = cal[0] - dist[0];
  cal_sum = cal[0];
  for(int i = 1;i < n;i++){
    cost[i] = cal_sum + cal[i] - dist[i];
    cal_sum += cal[i];
  }

  // backward
  vector<ll> rev_cost(n);
  cal_sum = cal[n-1];
  rev_cost[n-1] = cal[n-1] - (c-dist[n-1]);
  for(int i = n-2;i >= 0;i--){
    rev_cost[i] = cal_sum + cal[i] - (c - dist[i]);
    cal_sum += cal[i];
  }

  vector<ll> rev_max_cost(n);
  rev_max_cost[n-1] = rev_cost[n-1];
  for(int i = n-2;i >= 0;i--){
    rev_max_cost[i] = max(rev_max_cost[i + 1], rev_cost[i]);
  }
  ll ret = solve(n, cost, dist, rev_max_cost);
  return ret;
}

int main(){
  int n;
  ll c;
  cin >> n >> c;
  vector<ll> dist(n), cal(n);
  for(int i = 0;i < n;i++){
    cin >> dist[i] >> cal[i];
  }

  vector<ll> rev_dist(n), rev_cal(n);
  for(int i = 0;i < n;i++){
    rev_dist[i] = c - dist[n-i-1];
    rev_cal[i] = cal[n-i-1];
  }

  ll a = compute(n, c, dist, cal);
  ll b = compute(n, c, rev_dist, rev_cal);

  cout << max(a, b) << endl;

  return 0;
}


Measured memory_bytes: 5760
from itertools import accumulate
from bisect import *

N, M, K = [int(n) for n in input().split()]
A = [0]+[x for x in accumulate([int(n) for n in input().split()])]
B = [0]+[x for x in accumulate([int(n) for n in input().split()])]
#print(A)
#print(B)
ans = 0
a = bisect_right(A, K)
#print(a)
for i in range(a):
  b = bisect_right(B, K-A[i])
  ans = max(ans, i+b)
#  print(ans, i, b)
print(ans-1)


Measured memory_bytes: 44708
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,f[3],g[3],a[300005],typ[300005],mod=998244353,ans;
char c;
int main()
{
	scanf("%d\n",&n);
	fz1(i,n*3){
		scanf("%c",&c);
		if(c=='R')a[i]=0;
		if(c=='G')a[i]=1;
		if(c=='B')a[i]=2;
	}
	fz1(i,n*3){
		if(g[a[i]]){
			typ[i]=2;
			g[a[i]]--;
			continue;
		}
		if(f[(a[i]+1)%3]||f[(a[i]+2)%3]){
			typ[i]=0;
			if(f[(a[i]+1)%3]){
				f[(a[i]+1)%3]--;
				g[(a[i]+2)%3]++;
			}
			else{
				f[(a[i]+2)%3]--;
				g[(a[i]+1)%3]++;
			}
			continue;
		}
		f[a[i]]++;
		typ[i]=-2;
	}
	ans=1;
	fz1(i,n)ans=1ll*ans*i%mod;
	fz1(i,n*3){
		if(typ[i]==-2){
			f[a[i]]++;
		}
		if(typ[i]==0){
			if(f[(a[i]+1)%3]){
				ans=1ll*ans*f[(a[i]+1)%3]%mod;
				f[(a[i]+1)%3]--;
				g[(a[i]+2)%3]++;
			}
			else{
				ans=1ll*ans*f[(a[i]+2)%3]%mod;
				f[(a[i]+2)%3]--;
				g[(a[i]+1)%3]++;
			}
		}
		if(typ[i]==2){
			ans=1ll*ans*g[a[i]]%mod;
			g[a[i]]--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    Fast;
    long long t,n,m,i,j,k,x=0,y=0,z,ans;
    cin>>n>>m>>k;
    if(n<m){
        cout<<n<<endl;
        return 0;
    }
    if(n<(m+k)){
        cout<<m<<endl;
        return 0;
    }
    if(m>0)
    {
        ans=(n/(m+k))*m;
        ans=ans+min((n%(m+k)),m);
    }
    else
    {
        cout<<0<<endl;
        return 0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define cri const int
#define ll long long
using namespace std;
int dp[502][502],ans;
pair<int,int>f[502];
inline int read(int x=0){ scanf("%d",&x);return x; }
int main(){
	cri n=read(),mod=read();
	for(int i=0;i<n+n;i++){
		if(i>=n) f[i]=make_pair((int)sqrt(4*n*n-i*i)+1,0);
		else f[i]=make_pair((int)(sqrt(n*n-i*i-1e-7))+1,(int)sqrt(4*n*n-i*i)+(i!=0));
	}
	sort(f,f+n+n);
	for(int k=0;k<=n;k++){
		int c1=0,c2=0;
		memset(dp,0,sizeof dp);
		dp[0][0]=1;
		for(int i=0;i<n+n;!f[i].second?c1++:c2++,i++)
			for(int j=0;j<=k;j++){
				if(!f[i].second) dp[i+1][j]=(dp[i+1][j]+1ll*dp[i][j]*(f[i].first-j-c1))%mod;
				else{
					if(j<k) dp[i+1][j+1]=(dp[i+1][j+1]+1ll*dp[i][j]*(f[i].first-j-c1))%mod;
					dp[i+1][j]=(dp[i+1][j]+1ll*dp[i][j]*(f[i].second-n-k-(c2-j)))%mod;
				}
			}
		if(k&1) ans=(ans-dp[n+n][k]+mod)%mod;
		else ans=(ans+dp[n+n][k])%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4212
import sys
sys.setrecursionlimit(10 ** 8)
INF = 10 ** 15

class edge:
    def __init__(self, fr, to, cost):
        self.fr, self.to, self.cost = fr, to, cost

def input(): return sys.stdin.readline().strip()
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M = ZZ()
    es = []
    for _ in range(M):
        a, b, c = ZZ()
        a -= 1
        b -= 1
        es.append(edge(a, b, -c))

    #負の閉路検出
    d = [0] * N
    for i in range(N):
        for e in es:
            if d[e.to] > d[e.fr] + e.cost:
                d[e.to] = d[e.fr] + e.cost
                if e.to == N-1 and i == N-1:
                    print('inf')
                    return
    #ベルマンフォードする
    d = [INF] * N
    d[0] = 0
    for _ in range(N-1):
        update = False
        for e in es:
            if d[e.fr] != INF and d[e.to] > d[e.fr] + e.cost:
                d[e.to] = d[e.fr] + e.cost
                update = True
        if not update: break
    print(-d[N-1])

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3516
card_n=[*1..13].map(&:to_s);kind={:S=>[],:H=>[],:C=>[],:D=>[]}
(gets.to_i).times{
    n=gets.chomp.split.map(&:to_s)
    kind[n[0].to_sym]<< n[1]
}
kind.each{|k,v|
(ans=card_n-v).each{|e|puts "#{k} #{e}" if ans.size!=0}
}




Measured memory_bytes: 6860
#include <stdio.h>

int main()
{
	long N,M;
	scanf("%ld%ld",&N, &M);
	long L[M+1],R[M+1];
	long j;
	long i = 1;
	long D[M+1];
	while (i <= M)
	{
		scanf("%ld%ld", &L[i], &R[i]);
		i++;
	}
	long min = R[1];
	long max = L[1];
	i = 1;
	while (i <= M)
	{
		if (max < L[i])
			max = L[i];
		if (min > R[i])
			min = R[i];
		i++;
	}
	long count = 0;
	long path;
	i = 1;
	if (min - max < 0)
	{
		printf("0");
		return 0;
	}
	count = min - max + 1;
	printf("%ld\n", count);
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
lired = [list(map(int,input().split())) for _ in range(n)]
liblue = [list(map(int,input().split())) for _ in range(n)]
lired = sorted(lired,key = lambda x:-x[1])
liblue = sorted(liblue,key = lambda x:x[0])
li = list(range(n))
cnt = 0
#print(lired)
#print(liblue)

for i in range(n):
  for j in li:
    if lired[j][0] < liblue[i][0] and lired[j][1] < liblue[i][1]:
      cnt += 1
      li.remove(j)
      break
print(cnt)

Measured memory_bytes: 3064
import math
import sys
def main():
    a = [[0 for i in range(3)] for j in range(3)]
    for i in range(3):
        a[i] = list(map(int, input().split()))

    n = int(input())

    for k in range(n):
        ball = int(input())
        for j, contents in enumerate(a):
            for i, num in enumerate(contents):
                if num == ball:
                    a[j][i] = 0
    
    for j, contents in enumerate(a):
        if sum(contents) == 0:
            print('Yes')
            sys.exit()
        if a[0][j] + a[1][j] + a[2][j] == 0:
            print('Yes')
            sys.exit()
    if a[0][0] + a[1][1] + a[2][2] == 0:
        print('Yes')
        sys.exit()
    if a[0][2] + a[1][1] + a[2][0] == 0:
        print('Yes')
        sys.exit()

    print('No')
    

if __name__ == '__main__' :
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const ll INF = 2e9+10;

struct edge{
    int to, next;
}G[maxn << 1];
int tot, head[maxn];
void addEdge(int u, int v){G[tot] = {v, head[u]};head[u] = tot++;};
int n, s, t, vis[2][maxn];
void dfs(int u, int fa, int x){
    for(int i = head[u];i != -1;i = G[i].next)
        if(G[i].to != fa)
            vis[x][G[i].to] = vis[x][u] + 1, dfs(G[i].to, u, x);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios_base::sync_with_stdio(false);

    cin >> n >> s >> t;
    int u, v;
    for(int i = 1;i <= n;i++)head[i] = -1;
    for(int i = 1;i < n;i++){
        cin >> u >> v;
        addEdge(u, v);
        addEdge(v, u);
    }
    dfs(s, -1, 0);
    dfs(t, -1, 1);
    //for(int i = 1;i <= n;i++)cout << vis[0][i] << " " << vis[1][i] << "\n";
    int ans = 0, mi = INF;
    for(int i = 1;i <= n;i++){
        if(vis[0][i] < vis[1][i])ans = max(ans, vis[1][i] - 1);
        else if(vis[0][i] == vis[1][i])mi = min(mi, vis[0][i]);
    }
    cout << max(ans, (mi==INF?0:mi)) << "\n";
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n]={};
    int m=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==n)m++;
    }
    while(k && m<n){
        m=0;
        k--;
        int x[n+1]={};//imos table
        for(int i=0;i<n;i++){
            x[max(i-a[i],0)]++;
            x[min(i+a[i],n-1)+1]--;
        }
        a[0]=x[0];
        for(int i=1;i<n;i++)a[i]=a[i-1]+x[i];
        for(int i=0;i<n;i++){
            if(a[i]==n)m++;
        }
    }
    for(int i=0;i<n;i++)cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 5180
dx = (-1, 0, 1, 0)
dy = (0, 1, 0, -1)

while True:
    n = int(input())
    if n == 0:
        break

    x = list()
    y = list()
    x.append(0)
    y.append(0)
    for i in range(n - 1):
        k, d = map(int, input().split())
        x.append(x[k] + dx[d])
        y.append(y[k] + dy[d])
    
    print(max(x) - min(x) + 1, max(y) - min(y) + 1)


Measured memory_bytes: 5620
/*
____    ____ .___________.
\   \  /   / |           |
 \   \/   /  `---|  |----`
  \      /       |  |     
   \    /        |  |     
    \__/         |__|     
                          
 */


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<iomanip>
#define ll long long
#define mod 1000000007
using namespace std;
const int INF = 2e9 + 1;


/*---------------Graph Class---------*/
class graph
{
private:
	ll novert;
	ll noedges;
	vector< vector<ll> > adjlist;
public:
	graph(ll n,ll m)
	{
		novert=n;
		noedges=m;
		adjlist.resize(n+1);	
	}
	
	void addedge(ll u,ll v)
	{
		//bidirectional
		adjlist[u].push_back(v);
		adjlist[v].push_back(u);	
	}
	
	void dfsutil(ll initvert,vector<bool>& visited,ll lastvert=-1)
	{
		if(lastvert==initvert)
		{
			//do something
		}
		visited[initvert]=true;
		for(auto itr:adjlist[initvert])
		{
			if(!visited[itr])
			{	
			}	
		}	
	}	
};
/*-----------------End of graph----------------*/





int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);


string s;

ll st,e;
cin>>s;
if(s.length()==2)
{
	if(s[0]==s[1])
	{
		cout<<1<<" "<<2;
		return 0;
	}
}
for(ll i=0;i<s.length()-2;i++)
{
	if(s[i]==s[i+1])
	{
		cout<<i+1<<" "<<(i+1+1);
		return 0;
	}

	if(s[i]==s[i+2])
	{
		cout<<i+1<<" "<<(i+3)<<endl;
		return 0;
	}

	if(s[i+1]==s[i+2])
	{
		cout<<(i+2)<<" "<<(i+3)<<endl;
		return 0;
	}
}

cout<<-1<<" "<<-1<<endl;

	return 0;
}


Measured memory_bytes: 3736
n, m, L = map(int, input().split())
  
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = [[sum(ak * bk for ak, bk in zip(ai,bj)) for bj in zip(*b)] for ai in a]
  
for ci in c:
    print(*ci)

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

int main(){
    int w , h , n ;
    cin >> w >> h >> n ;
    int a , b ;
    a = b = 0 ;
    for(int i=0;i<n;i++){
        int x , y , t ;
        cin >> x >> y >> t ;
        if ( t == 1 ){
            a = max(a,x);
        }
        else if ( t == 2 ){
            w = min(w,x);
        }
        else if ( t == 3 ){
            b = max(b,y);
        }
        else{
            h = min(h,y);
        }
    }
    if ( a >= w || b >= h ){
        cout << 0 << endl;
    }
    else{
        cout << (w-a)*(h-b) << endl;
    }
    return 0 ;
}


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

/////------------------------TYPEDEF--------------------------/////
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
#define prq priority_queue<ll>;

/////------------------------CONSTANTS--------------------------/////
ll MOD=1000000007;
#define PI 3.1415926535897932384626433832795

/////------------------------GENERAL--------------------------/////
#define forx(i,j,n) for(int i=j;i<n;i++)
#define fory(i,j,n) for(int i=j;i>=n;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false)
#define testcase int t; cin>>t
#define MEM(xx,yy) memset(xx,yy,sizeof(xx))
#define vbs(xx,x) binary_search(all(xx),x)
#define vlb(xx,x) lower_bound(all(xx),x)
#define vub(xx,x) upper_bound(all(xx),x)

/////------------------------IO--------------------------/////
#define inpi(xx) scanf("%d",&xx)
#define inpl(xx) scanf("%lld",&xx)
#define inpc(xx) scanf("%c",&xx)
#define inps(xx) scanf("%s",&xx)
#define pri(xx) printf("%d",xx)
#define prl(xx) printf("%lld",xx)
#define prls(xx) printf("%lld ",xx)
#define prle(xx) printf("%lld\n",xx)
#define prc(xx) printf("%c",xx)
#define prs printf(" ");
#define pre printf("\n")
ll n,k;
ll a[100005][3];
ll ans[100005][3];

ll fun(ll n,int g){
    if(n==1) return a[n][g];
    if(ans[n][g]!=-1) return ans[n][g];
    ans[n][g]=max(fun(n-1,(g+1)%3)+a[n][g],fun(n-1,(g+2)%3)+a[n][g]);
    return ans[n][g];
}

int main() {
	int t=1;
	while(t--){
	    cin>>n;
	    forx(i,0,n) cin>>a[i+1][0]>>a[i+1][1]>>a[i+1][2];
	    MEM(ans,-1);
	    cout<<max(max(fun(n,1),fun(n,2)),fun(n,0));
	}
	return 0;
}

Measured memory_bytes: 11136
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

void solve(int m, int n){
    vector<bool> s(8000000, false);
    int y = m;
    while(true){
        if(s[y]){
            y++;
            continue;
        }

        if(n == 0){
            cout << y << endl;
            return;
        }

        for(int i = y; i < (int)s.size(); i += y){
            s[i] = true;
        }
        n--;
    }
}

signed main(){
    while(true){
        int m, n;
        cin >> m >> n;

        if(m == 0 && n == 0){
            break;
        }

        solve(m, n);
    }

    return 0;
}



Measured memory_bytes: 4076
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	int w, h;
	while(scanf("%d%d", &w, &h), w){
		vvi field(h+1, vi(w, 0));
		rep(i, h) rep(j, w)
			scanf("%d", &field[i][j]);
		
		vvi dp(h+1, vi(w));
		rep(i, w)
			dp[0][i] = field[0][i] == 0;
		
		reep(i, 1, h+1){
			rep(j, w){
				if(field[i][j] == 1){
					dp[i][j] = 0;
				}
				else{
					if(i<h){
						const int dx[] = {-1, 0, 1};
						rep(k, 3){
							int px = j + dx[k];
							if(px<0 || w<=px || field[i-1][px] != 0 || (field[i][j]==2 && dx[k]!=0))
								continue;
							dp[i][j] += dp[i-1][px];
						}
					}
					if(i>=2 && field[i-2][j] == 2)
						dp[i][j] += dp[i-2][j];
				}
			}
		}

		int sum = 0;
		rep(i, 2) rep(j, w)
			sum += dp[h-i][j];
		printf("%d\n", sum);
	}
	return 0;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int ans[MAX] ;
int n ;
int Max = 0 ;
vector< vector<int> >adj(MAX) ;

map< pair<int , int> , int>id ;

void dfs(int node , int par , int col)
{
	int cnt = 0 ;
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		cnt++ ;
		if(cnt == col)
			cnt++ ;
		ans[id[{node , child}]] = cnt ;
		Max = max(Max , cnt) ;
		dfs(child , node , cnt) ;
	}
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
		id[{x , y}] = i ;
		id[{y , x}] = i ;
	}
	dfs(1 , -1 , -1) ;
	cout<<Max<<"\n" ;
	for(int i = 0 ; i < n-1 ; ++i)
		cout<<ans[i]<<"\n" ;
	return 0 ;
}		

Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n, x;
  cin >> n >> x;
  int ans = 0;
  int d = 0;
  rep(i,n) {
    if (d <= x) ans++;
    int l;
    cin >> l;
    d += l;
  }
  if (d <= x) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll MAX = 1e5 + 5;
ll a[MAX], dp[MAX][2], n;

ll game(ll k, ll player)
{
	if(k < 0)
		return 1 - player;

	if(dp[k][player] != -1)
		return dp[k][player];

	ll ans;
	for(int i = 0; i < n; i++)
	{
		if(k - a[i] >= 0)
			ans = game(k - a[i], 1 - player);
		else
			ans = game(k - a[i], player);
		if(ans == player)
			break;
	}

	return dp[k][player] = ans;
}

int main(void)
{
	ll k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];

	memset(dp, -1, sizeof(dp));

	if(!game(k, 0))
		cout << "First" << endl;
	else
		cout << "Second" << endl;




	return 0;
}

Measured memory_bytes: 6528
n = int(input())
w = [input() for _ in range(n)]

if len(set(w)) is not n:
    print('No')
    exit()

for i in range(len(w) - 1):
    if not w[i][-1] == w[i + 1][0]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
    
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    char s;
    cin >> s;
    if(s == 'A') {
        cout << "T";
    } else if(s == 'T') {
        cout << "A";
    } else if(s == 'G') {
        cout << "C";
    } else {
        cout << "G";
    }


    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <list>

using namespace std;

int main(void) {
	int num, i, a, n;
	cin >> num;
	list<int> d, ans;
	for (i = 0; i < num; i++) {
		scanf("%d", &a);
		d.push_front(a);
	}
	n = num;
	for (auto itr = d.begin(); itr != d.end();) {
		if (*itr == n) {
			ans.push_front(n);
			d.erase(itr);
			itr = d.begin();
			n = d.size();
			continue;
		}
		n--;
		itr++;
	}
	if (d.size())
		printf("-1\n");
	else {
		for (auto itr = ans.begin(); itr != ans.end(); itr++)
			printf("%d\n", *itr);
	}
	return 0;
}

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

int main() {
  ll x;
  cin >> x;
  if(x%11==0)cout << x/11*2<<endl;
  else if(x%11>0&&x%11<=6)cout << x/11*2+1<<endl;
  else cout << x/11*2+2<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i,j,ans=0;
  scanf("%d %d",&n,&m);
  int A[n][m],b[m];
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      ans+=A[i][j]*b[j];
    }
    printf("%d\n",ans);
    ans=0;
  }
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int x3 = x2 - (y2-y1);
  int y3 = y2 + (x2-x1);
  int x4 = x3 - (y3-y2);
  int y4 = y3 + (x3-x2);
  printf("%d %d %d %d\n",x3,y3,x4,y4);
  return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    int h[100002];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int dp[100002];
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        dp[i] = 1000000000;
        for(int j = max(0, i - k); j < i; j++){
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1] << endl;
}

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

int main(void)
{
    int x, y;
    cin >> x >> y;
    int tartle_legs = x * 4;
    int tartle = x;
    while (tartle_legs >= 0){
        if ((y - tartle_legs >= 0) && (y - tartle_legs)%2==0 && (y - tartle_legs)/2+tartle == x){
            cout << "Yes" << endl;
            return 0;
        }
        tartle_legs -= 4;
        tartle--;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>

using namespace std;

struct input {
	long long int operator()() { return *istream_iterator<long long int>(cin); }
};
int main(void){
	long long int n;
	while(cin >> n && n) {
		vector<long long int> p(n), j(n-1);
		generate(p.begin(), p.end(), input());
		generate(j.begin(), j.end(), input());
		sort(j.begin(), j.end());

		long long int l = accumulate(p.begin(), p.end(), 0);

		while(!j.empty() && l * (j.size() + 1) < (l + j.back()) * j.size()) {
			l += j.back();
			j.pop_back();
		}
		cout << l * (j.size() + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 2060
li = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y = map(int,input().split())
for i in range(3):
    if x in li[i]:
        a = i
for i in range(3):
    if y in li[i]:
        b = i
if a == b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9092
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(int argc, char* argv[])
{

	int X;
	int a;
	int b;
	int y;
	scanf("%d", &X);

	a = (X - X%500) / 500;
	b = (X%500 - (X%500)%5) / 5;

	y = a * 1000 + b * 5;
	printf("%d\n", y);
	return 0;
}





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

int main() {
  int D,G; cin >> D >> G;
  int p[11],c[11];
  for ( int i = 0; i < D; i++ ) {
    cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for ( int bit = 0; bit < (1<<D); bit++ ) {
    int s = 0,rest_max = -1,num = 0;
    for ( int i = 0; i < D; i++ ) {
      if( bit & (1<<i) ) {
	s += p[i]*(i+1)*100+c[i];
	num += p[i];
      } else {
	rest_max = i;
      }
    }
    if ( s < G ) {
      int tmp = (rest_max+1)*100;
      int need = (G-s+tmp-1)/tmp;
      if ( need > p[rest_max]-1 ) {
	continue;
      }
      num += need;
    }
    ans = min(ans,num);
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<complex>
#include<algorithm>

#define mp       make_pair
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef complex<double> Point;

const double EPS=1e-9;

class Line:public vector<Point>{
public:
	Line(){}
	Line(const Point &a,const Point &b){ pb(a), pb(b); }
};

class Segment:public Line{
public:
	Segment(){}
	Segment(const Point &a,const Point &b):Line(a,b){}
};

double dot(const Point &a,const Point &b){
	return real(a)*real(b)+imag(a)*imag(b);
}

double cross(const Point &a,const Point &b){
	return real(a)*imag(b)-imag(a)*real(b);
}

enum {CCW=1,CW=-1,ON=0};
int ccw(const Point &a,Point b,Point c){
	b-=a,c-=a;
	double rotdir=cross(b,c);
	if(rotdir>EPS)  return CCW;
	if(rotdir<-EPS) return CW;
	return ON;
}

inline void calc_abc(const Line &l,double &a,double &b,double &c){
	a=imag(l[0])-imag(l[1]);
	b=real(l[1])-real(l[0]);
	c=cross(l[0],l[1]);
}

bool intersect(const Segment &s,const Segment &t,Point &p){
	if(max(real(s[0]),real(s[1]))<min(real(t[0]),real(t[1]))-EPS
	|| max(real(t[0]),real(t[1]))<min(real(s[0]),real(s[1]))-EPS
	|| max(imag(s[0]),imag(s[1]))<min(imag(t[0]),imag(t[1]))-EPS
	|| max(imag(t[0]),imag(t[1]))<min(imag(s[0]),imag(s[1]))-EPS) return false;

	if(ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0
	&& ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0){
		double a1,b1,c1,a2,b2,c2;
		calc_abc(s,a1,b1,c1);
		calc_abc(t,a2,b2,c2);
		double det=a1*b2-a2*b1;
		if(abs(det)<EPS){ // s is parallel to t
			Point q[3]={s[0],s[1],t[0]};
			rep(i,3){
				if(dot(q[i]-s[0],q[i]-s[1])<EPS && dot(q[i]-t[0],q[i]-t[1])<EPS){
					p=q[i];
					break;
				}
			}
		}
		else p=Point(b1*c2-b2*c1,a2*c1-a1*c2)/det;
		return true;
	}
	return false;
}

int n;
Point A,B;
Segment AB,S[100];
bool own[100],loc[100];

int solve(){
	vector< pair<double,int> > pts;
	rep(i,n){
		Point Q;
		if(intersect(AB,S[i],Q)) pts.pb(mp(abs(A-Q),i));
	}
	if(pts.size()==0) return 0;

	sort(pts.begin(),pts.end());

	int cnt=0,id=pts[0].second;
	bool now=(own[id]?loc[id]:!loc[id]);
	for(int i=1;i<pts.size();i++){
		id=pts[i].second;
		if(own[id]){
			if(now!=loc[id]){ cnt++; now=!now; }
		}
		else{
			if(now==loc[id]){ cnt++; now=!now; }
		}
	}
	return cnt;
}

int main(){
	int T;	scanf("%d",&T);
	while(T--){
		int xa,ya,xb,yb; scanf("%d%d%d%d%d",&xa,&ya,&xb,&yb,&n);
		A=Point(xa,ya);
		B=Point(xb,yb);
		AB=Segment(A,B);
		rep(i,n){
			int x1,y1,x2,y2,o,l; scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&o,&l);
			S[i]=Segment(Point(x1,y1),Point(x2,y2));
			own[i]=o;
			loc[i]=l;
		}
		printf("%d\n",solve());
	}

	return 0;
}

Measured memory_bytes: 840
N = int(input())
A = list(map(int, input().split()))

A.sort()

count = 0
ans = 0

for idx, a in enumerate(reversed(A)):
    count += 1
    ans += a
    if count == N - 1:
        break
    if idx != 0:
        count += 1
        ans += a
    if count == N - 1:
        break
print(ans)

Measured memory_bytes: 94184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5+10;
char s[N];
int main() {
    scanf("%s",s+1);
    int n = strlen(s+1)+1;
    ll ans = 0, lst = 0, cnt = 0;
    for (int i = 1; i < n; i++) {
        ++cnt;
        if (i < n-1 && s[i+1] == s[i]) {
            continue;
        }
        
        if (s[i] == '<') {
            ans += cnt*(cnt+1)/2;
            lst = cnt;
        } else {
            ans += cnt*(cnt-1)/2;
            if (cnt > lst) ans += cnt-lst;
        }
        cnt = 0;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 768
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10**9)

N = int(input())
# XY_L = [[int(_) for _ in input().split()] for __ in range(N)]
X_L = [None] * N
Y_L = [None] * N
for i in range(N):
    _x, _y = map(int, input().split())
    X_L[i] = [_x, i]
    Y_L[i] = [_y, i]

class UnionFind():
    def __init__(self, n):
        self.rank = [1] * n
        self.par = [int(_) for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)



X_L.sort()
Y_L.sort()
dx_l = [None] * (N-1)
dy_l = [None] * (N-1)
for i in range(N-1):
    dx_l[i] = [X_L[i+1][0] - X_L[i][0], X_L[i][1], X_L[i+1][1]]
    dy_l[i] = [Y_L[i+1][0] - Y_L[i][0], Y_L[i][1], Y_L[i+1][1]]

tmp_l = dx_l+dy_l
tmp_l.sort()

UF = UnionFind(N)
ans = 0

for _ in range(2*N-2):
    _d, _i, _j = tmp_l[_]
    if _i >= N or _j >= N:
        print(_i, _j)
    if UF.same(_i, _j):
        continue
    UF.unite(_i, _j)
    ans += _d

print(ans)



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

int main()
{
	string S,T;
	cin>>S>>T;
	int l1=S.length();
	int l2=T.length();
	int l=l1-l2+1;
	int Max=0;
	for(int i=0;i<l;i++)
	{
		int sum=0;
		for(int j=0;j<l2;j++)
			if(S[i+j]==T[j]) ++sum;
		Max=max(Max,sum);
	}
	printf("%d",l2-Max);
	return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n;
void GG()
{
    cout<<"No"<<endl;exit(0);
}
int main()
{
    fastio();
    cin>>n;
    rep(i,0,30) if((1<<i)==n) GG();
    cout<<"Yes"<<endl;
    rep(i,1,2) cout<<i<<" "<<i+1<<endl;
    cout<<3<<" "<<1+n<<endl;
    rep(i,1,2) cout<<i+n<<" "<<i+1+n<<endl;
    int t = (n&1)?n:n-1;
    for(int i=4;i<=t;i+=2){
        cout<<i<<" "<<1<<endl;
        cout<<i<<" "<<i+1<<endl;
        cout<<i+n+1<<" "<<1<<endl;
        cout<<i+n+1<<" "<<i+n<<endl;
    }
    if(t!=n){
        int a = n-1;
        int b = n^a^1;
        cout<<n<<" "<<a+n<<endl;
        cout<<n+n<<" "<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 2304
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val n = readLine()?.toInt() ?: return
    val c = 0.until(n).map {
        val (x, y) = longList()
        Pair(x, y)
    }
    val map = hashMapOf<Pair<Long, Long>, Int>()
    0.until(n).forEach { i ->
        val a = c[i]
        0.until(n).forEach { j ->
            if (i != j) {
                val b = c[j]
                val d = Pair(a.first - b.first, a.second - b.second)
                map[d] = map.getOrDefault(d, 0) + 1
            }
        }
    }
    println((n - (map.values.max() ?: 0)).toString())
}


Measured memory_bytes: 38588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim Semenov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        LunlunNumber solver = new LunlunNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static final class LunlunNumber {
        public void solve(int __, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            List<Long> queue = new ArrayList<>(n);
            for (long i = 1; i < 10; ++i) {
                queue.add(i);
            }
            for (int head = 0; queue.size() < n; ++head) {
                long current = queue.get(head);
                if (current % 10 != 0) {
                    queue.add(current * 10 + (current % 10 - 1));
                }
                queue.add(current * 10 + (current % 10));
                if (current % 10 != 9) {
                    queue.add(current * 10 + (current % 10 + 1));
                }
            }
            out.println(queue.get(n - 1));
        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}



Measured memory_bytes: 24916
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let s: String = read();
    let cv: Vec<char> = s.chars().collect();

    if cv[2] == cv[3] && cv[4] == cv[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll d;
	while(cin>>d){
		int n=600/d;
		ll sum=0;
		REP(i,n-1){
			sum += (i+1)*(i+1)*d*d*d;
		}
		out(sum);
	}

	return 0;
}


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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int x,a;
    cin>>x>>a;

    if(x < a) {
        cout<<0<<endl;
    } else {
        cout<<10<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
	int size = 0;
	int num = 0;
	int min = 200000;
	int count = 0;

	scanf("%d", &size);
	for(int i = 0; i < size; i++) {
		scanf("%d", &num);
		if (num <= min) {
			count++;
			min = num;
		}
	}
	printf("%d", count);
	return 0;
}

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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#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<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  int n;cin>>n;

  vector<pii> lr;
  rep(i, n){
    int x,L;cin>>x>>L;
    lr.pb(mp(x-L, x+L));
  }
  sort(all(lr));
  dump(lr);

  int pr = lr[0].second;
  int ans = 1;
  rep(i,1,n){
    dump(i, ans, pr);
    int l = lr[i].first;
    int r = lr[i].second;
    if (pr<=l){
      ans++;
      pr = r;
    }
    else{
      if (pr<=r){
      }
      else{
        pr = r;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
/*
 * https://arc090.contest.atcoder.jp/tasks/arc090_b
 */

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <list>

using namespace std;

vector<list<tuple<int,int> > > graph;
vector<int> position;

void dfs(int x) {
  if (position[x] != INT_MAX) {
    for (list<tuple<int,int> >::iterator i = graph[x].begin(); i != graph[x].end(); i++) {
      int node = std::get<0>(*i);
      if (position[node] == INT_MAX) {
        int dist = position[x] + std::get<1>(*i);
        position[node] = dist;
        dfs(node);
      }
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  graph.resize(n);
  position.resize(n, INT_MAX);
  vector<tuple<int,int,int> > condition(m);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    graph[l].push_back(make_tuple(r, d));
    graph[r].push_back(make_tuple(l,-d));
    tuple<int,int,int>& c = condition[i];
    get<0>(c) = l;
    get<1>(c) = r;
    get<2>(c) = d;
  }

  for (int i = 0; i < n; i++) {
    if (position[i] == INT_MAX) {
      position[i] = 0;
      dfs(i);
    }
  }

  bool ok = true;
  for (int i = 0; i < m; i++) {
    tuple<int,int,int> c = condition[i];
    if (position[get<1>(c)] - position[get<0>(c)] != get<2>(c)) {
      ok = false;
      break;
    }
  }
  if (ok) cout << "Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 19712
#include <iostream>
#include <math.h>
using namespace std;

bool prime(int num){
  if(num == 2)return true;
  else if (num < 2 or (num % 2) == 0)return false;

  double sqrtnum = sqrt(num);
  for(int i = 3; i <= sqrtnum; i += 2){
    if((num % i) == 0)return false;
  }

  return true;
}

int main(){
  int n;
  int count = 0;

  cin >> n;

  for(int i = 0;i < n; i++){
    int j;
    cin >> j;
    if(prime(j) == true)count++;
  }

  cout << count << endl;
}



Measured memory_bytes: 3092
perm = [[0,1,2], [0,2,1], [1,0,2], [1,2,0], [2,0,1], [2,1,0]]
res = float('inf')
a = list(map(int,input().split()))
for p in perm:
  tmp = 0
  for i in range(2):
  	tmp += abs(a[p[i]]-a[p[i+1]])
  res = min(res, tmp)
print(res)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ll taka, aoki, K;
    cin >> taka >> aoki >> K;
    if(taka >= K) {
        taka -= K;
    }
    else{
        K -= taka;
        taka = 0;
        aoki = aoki > K ? aoki - K : 0;
    }
    cout << taka << " " << aoki << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Problems 1325
Problem A: Ginkgo Numbers
"""
for _ in range(int(input())):
    m, n = map(int,input().split())
    count = 0
    for p in range(142):
        for q in range(142):
            if (p > 0 or q > 0) and ((m*q + n*p) % (p*p + q*q) == 0) and ((n*q - m*p) % (p*p + q*q) == 0):
                count += 1
    if count < 5:
        print('P')
    else:
        print('C')



Measured memory_bytes: 5608
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

const ll INF = 1LL<<62;
int dp[100100];
int N, M;
vector<vector<int>> G;

int rec(int v) {
  if (dp[v] != -1) {
    return dp[v];
  }
  int res = 0;
  for (int nv : G[v]) {
    res = max(res, rec(nv) + 1);
  }
  return dp[v] = res;
}

int main() {
  cin >> N >> M;
  G.assign(N, vector<int>());
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    G[x].push_back(y);
  }
  
  for (int i = 0; i < N; i++) {
    dp[i] = -1;
  }
  
  int res = 0;
  for (int v = 0; v < N; ++v) {
    res = max(res, rec(v));
  }
  cout << res << endl;
  return 0;
}


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int fac(int a){
    if (a==0){
        return 1;
    }
    else {
        return a*fac(a-1);
    }
}

int main() {
  int n;
  cin >> n;
  vector<pint> des(n);
  rep(i,n){
      cin >> des[i].first;
      cin >> des[i].second;
  }
  int cnt=n-1;
  double ans=0.0;
  cnt=fac(cnt);
  rep(i,n){
      for (int j=i+1; j < n; j++){
           ans+=sqrt((des[i].first-des[j].first)*
                     (des[i].first-des[j].first)
                     +(des[i].second-des[j].second)*
                     (des[i].second-des[j].second));
                     
        
        }
  }
  cout << fixed << setprecision(10) << ans*2/n << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

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

  rep(i, k) {
    if(i % 2 == 0) {
      a /= 2;
      b += a;
    } else {
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main() {
    int n,i;
    long long D1=0.0f,D2=0.0f,D3=0.0f,D=0.0f,d;
    cin >> n;
    int x[n],y[n];
    for (i=0;i<n;i++) cin >> x[i];
    for (i=0;i<n;i++) cin >> y[i];
    for (i=0;i<n;i++) {
        d = abs(x[i]-y[i]);
        D1 += d;
        D2 += d*d;
        D3 += d*d*d;
        if (D < d) D = d;
    }
    printf("%.8f\n%.8f\n%.8f\n%.8f\n", (double)D1, sqrt((double)D2), pow((double)D3,1.0/3.0), (double)D);
    return 0;
}

Measured memory_bytes: 3348
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std ;
map < string , int > mp ;
string a , b ;
int n ;
int main () 
{
	cin >> n ;
	bool ans = true ; 
	cin >> a ; 
	mp[a]++ ;
	for ( int i = 0 ; i < n-1 ; i++ ) 
	{	
		cin >> b ; 
		if ( mp[b] || a[a.size()-1] != b[0] ) 
			ans = false ;
		mp[b]++;	
		a = b ; 
	}
	if ( ans ) 
		cout <<"Yes" << endl;
	else
		cout << "No" << endl;
}

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

int main(){
  int64_t N,A0,M;
  cin >> N >> A0 >> M;

  unordered_map<int64_t, int> data;
  vector<int64_t> cumsum;
  int64_t cs= 0;
  cumsum.emplace_back(cs);

  int64_t Ai= A0 % M;
  int cnt= 1;
  while(!data.count(Ai)){
    data[Ai]= cnt;
    cs+= Ai;
    cumsum.emplace_back(cs);

    Ai= (Ai* Ai) % M;
    cnt++;
  }
  int s_loop= data.at(Ai); 
  int len_cycle= int(cumsum.size())- s_loop;
  int64_t Nloop= (N- (s_loop-1))/ len_cycle;
  int64_t Nrem = (N- (s_loop-1))% len_cycle;
  cs+= Ai;
  cumsum.emplace_back(cs);
  int64_t sum_cycle= cumsum.back()- cumsum.at(s_loop);
  int64_t sum_remain= cumsum.at(s_loop+ Nrem-1)- cumsum.at(s_loop-1);

  int64_t ans= (N < int(cumsum.size())) ? cumsum.at(N)
                                        : cumsum.at(s_loop-1)+ Nloop* sum_cycle+ sum_remain;
  
  cout << ans << endl;
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define l int
using namespace std;using v=vector<l>;l n;l h(v a,v b){l r=1;for(l i=0;i<n;i++)r&=a[i]!=b[i];return r;}l f(l g,v a){cout<<(g?"Yes\n":"No\n");if(g)for(l e:a)cout<<e<<'\n';exit(0);}l main(){cin>>n;v a(n),b(n),c;for(l&e:a)cin>>e;for(l&e:b)cin>>e;c=b;reverse(begin(b),end(b));rotate(begin(c),begin(c)+n/2,end(c));if(h(a,b))f(1,b);if(h(a,c))f(1,c);f(0,a);}

Measured memory_bytes: 7212