akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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


  for(int q=0; q<n;q++) {
    
    vector <int> ball;
    
    ball.resize(10);
    for(int i=0;i<10;i++) cin >> ball[i];
    reverse(ball.begin(),ball.end());
    
    int a[10] = {0},b[11] = {0};
    a[0] = ball.back();
    ball.pop_back();
   int ac = 1;
   int bc = 1;
   int t,flg = 0;
   
   //    cout << "t:a:b" << endl;
   for(int i=0;i<9;i++) {
     
     t = ball.back();
     ball.pop_back();
     // cout << t <<":"<< a[ac-1]<<":" << b[bc-1]<<endl;
     
     if(t > a[ac-1] && a[ac-1] >= b[bc-1]) {
       a[ac] = t;
       ac++;
     }
     else if(t > b[bc-1]) {
       b[bc] = t;
       bc++;
     } else {
       flg = 1;
	break;
     }
    }
   
   if(flg == 0) cout << "YES" <<  endl;
   else cout << "NO" << endl;
   
   ball.clear();
   
  }

  return 0;

}

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

typedef pair<int,int> P;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
#define MP make_pair
const P pINF=MP(-INF,INF);
const P fail=MP(INF,-INF);

vector<P> range;
vector<int> graph[100001];
bool visited[100001];

P dfs(int v){
    if(visited[v])	
        return pINF;
    visited[v]=true;
    for(int i=0;i<graph[v].size();i++){
        int to=graph[v][i];
        P result=dfs(to);
        if(result==MP(pINF.first-1,pINF.second+1))	result=pINF;
        if(result==fail){
            return fail;
        }
        else if(range[v]==pINF){
            range[v]=result;
        }else if(result==pINF){
            continue;
        }else if(range[v].first%2!=result.first%2){
            return fail;
        }else if(range[v].second<result.first) {
            return fail;
        }else if(result.second<range[v].first){
            return fail;
        }else{
            range[v].second=min(range[v].second,result.second);
            range[v].first=max(range[v].first,result.first);
        }
    }
    if(range[v].second<range[v].first)
        return fail;
    return MP(range[v].first-1,range[v].second+1);
}

void decide(int v){
    if(visited[v])	return;
    visited[v]=true;
    range[v]=MP(range[v].first,range[v].first);
    for(int i=0;i<graph[v].size();i++){
        int to=graph[v][i];
        if(visited[to])	continue;
        range[to]=MP(max(range[to].first,range[v].first-1),
                            min(range[to].second,range[v].second+1));
        decide(to);
    }
    return;
}

int main(){
    int n;	cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;	
        cin>>a>>b;	a--;	b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for(int i=0;i<n;i++)	visited[i]=false;
    range=vector<P>(n,pINF);
    int k;	cin>>k;
    for(int i=0;i<k;i++){
        int v,p;	
        cin>>v>>p;	v--;
        range[v]=MP(p,p);
    }
    P ret=dfs(0);
    if(ret==fail){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++)	
        visited[i]=false;
    decide(0);
    for(int i=0;i<n;i++)	
        cout<<range[i].first<<endl;
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int maxn=1e5+5;
vector<ll> adj[maxn];
ll n;
ll col[maxn];
ll other[maxn];
void dfs(ll u,ll p, ll c)
{
	ll cur=1;
	for(auto i:adj[u])
	{
		ll v=other[i]^u;
		if(v==p) continue;
		if(cur==c) cur++;
		col[i]=cur++;
		dfs(v,u,col[i]);
	}
	return ;
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>n;
	rep(i,n-1)
	{
		ll x,y;
		cin>>x>>y;
		x--;
		y--;
		adj[x].pb(i);
		adj[y].pb(i);
		other[i]=x^y;
	}
	dfs(0,0,0);
	ll used=0ll;
	rep(i,n-1) used=max(used,col[i]);
	cout<<used<<'\n';
	rep(i,n-1)
	{
		cout<<col[i]<<'\n';
	}
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 13124
#include <cstdio>
char _i[500003];
int a[500004], N, D, O;
int main()
{
	scanf("%s", _i + 1);
	while (_i[N + 1])
		N++;
	for (int i = 1; i <= N; i++)
		a[i] = (_i[N + 1 - i] - '0') * 9;
	for (int i = 1; i <= N; i++)
	{
		a[i + 1] += a[i] / 10;
		a[i] %= 10;
	}
	if (a[N + 1])
		N++;
	for (int i = 1; i <= N; i++)
		D += a[i];
	while (D > O || (O - D) % 9)
	{
		int C = 1;
		while (C <= N && a[C] == 9)
			C++;
		D += 10 - 9 * C;
		for (int i = 1; i < C; i++)
			a[i] = 0;
		a[C]++;
		if (C > N)
			N = C;
		O++;
	}
	printf("%d\n", (O + 8) / 9);
	return 0;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000000;
    public static void Main()
    {
        int N = IntRead();
        int[] box = SpRead(' ').Select(int.Parse).ToArray();
        int y = (int)Math.Round(box.Average(), MidpointRounding.AwayFromZero);
        int ans = 0;
        box.ToList().ForEach(x => ans += (int)Math.Pow(x - y, 2));
        Console.WriteLine(ans);
    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
}


Measured memory_bytes: 13396
n=int(input())
s=input()
cnt=0
for i in range(1000):
  l=(3-len(str(i)))*'0'+str(i)
  if l[0] in s:
    p1=s.index(l[0])
    if l[1] in s[p1+1:]:
      p2=p1+s[p1+1:].index(l[1])+1
      if l[2] in s[p2+1:]:
        cnt+=1
print(cnt)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
using namespace std;
#define MAX 500005
#define MOD 1000000007
int main()
{
    long long int N;
    scanf("%lld",&N);
    long long sum=N*(N+1)/2;
    long long int Fizz=N/3,Buzz=N/5,FizzBuzz=N/15;
    Fizz=3*Fizz*(Fizz+1)/2;
    Buzz=5*Buzz*(Buzz+1)/2;
    FizzBuzz=15*FizzBuzz*(FizzBuzz+1)/2;
    sum=sum-Fizz-Buzz+FizzBuzz;
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll k;cin >> k;
  rep(i,k){
    if( a >= b ){
      b *= 2;
      continue;
    }
    if( b >= c ){
      c *= 2;
      continue;
    }
  }
  if( a < b && b < c ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
const int mo=1e9+7,sz=3e5;
typedef long long ll;
ll H,W,A,B,K,res,fact[sz],inv[sz],factinv[sz];
ll ncr(ll n,ll r){return (n-r>=0&&r>=0)?1LL*fact[n]*factinv[r]%mo*factinv[n-r]%mo:0;}
main()
{
    fact[0]=1;for(int i=1;i<sz;i++)fact[i]=1LL*fact[i-1]*i%mo;
    inv[1]=1;for(int i=2;i<sz;i++)inv[i]=1LL*inv[mo%i]*(mo-mo/i)%mo;
    factinv[0]=1;for(int i=1;i<sz;i++)factinv[i]=1LL*factinv[i-1]*inv[i]%mo;
    cin>>H>>W>>A>>B;ll sum=0;
    for(int i=0;i<H-A;i++)
    {
        sum+=ncr(B+i-1,B-1)*ncr((W-B-1)+(H-i-1),W-B-1);
        sum%=mo;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 7296
n = int(input())
candi = []
for i in range(1,int(n/2+1)):
  j = n - i
  candi.append([i,j])

#candi = [[2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8]]

ans = 0
for a,b in candi:
  count = 0
  a = str(a)
  b = str(b)
  for i in a:
    count += int(i)
  for i in b:
    count += int(i)
  if ans == 0 :
    ans = count
  ans = min(ans,count)

print(ans)

Measured memory_bytes: 11252
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		cout<<(n>=30?"Yes":"No");

	}
	return 0;
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	long long sum = 0 , cur = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>arr[i] ;
		sum += arr[i] ;
	}
	long long ans = 4e18 ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		cur += arr[i] ;
		sum -= arr[i] ;
		ans = min(ans , abs(sum - cur)) ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 4436
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=1005;
LL a[N],b[N];
char ans[N];
int xx[]={-1,0,1,0},yy[]={0,1,0,-1},zz[]={'L','U','R','D'};
int n,biao[555];
int ck(LL x,LL y){
	return abs(x+y)&1;
}
LL g(LL x,LL y){
	return abs(x)+abs(y);
}
int main(){
	biao['L']='R',biao['R']='L',biao['U']='D',biao['D']='U';
	bool flag=1;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
		if(ck(a[i],b[i])!=ck(a[1],b[1]))flag=0;
	}
	if(!flag)puts("-1"),exit(0);
	if(ck(a[1],b[1])==0){
		for(int i=1;i<=n;i++)a[i]--;
		flag=0;
		printf("33\n1 ");
	}
	else{
		printf("32\n");
	}
	for(int i=0;i<=31;i++)printf("%lld%c",1LL<<i," \n"[i==31]);
	for(int k=1;k<=n;k++){
		if(!flag)putchar('R');
		int cnt=0;
		LL p=a[k],q=b[k],now=0;//
		for(int i=31;i>=0;i--){
			for(int j=0;j<4;j++){
				if(g(a[k]+xx[j]*(1LL<<i),b[k]+yy[j]*(1LL<<i))<=(1LL<<i)-1){
					a[k]=a[k]+xx[j]*(1LL<<i);
					b[k]=b[k]+yy[j]*(1LL<<i);
					ans[++cnt]=zz[j];
					break;
				}
			}
		}
		assert(a[k]==0&&b[k]==0);
		for(int i=cnt;i>=1;i--){
			putchar(biao[ans[i]]);
			++now;//
			if(ans[i]=='L')p-=(1LL<<(now-1));
			if(ans[i]=='R')p+=(1LL<<(now-1));
			if(ans[i]=='U')q+=(1LL<<(now-1));
			if(ans[i]=='D')q-=(1LL<<(now-1));
		}
		assert(p==0&&q==0);
		puts("");
	}
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << " : " << x << endl;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin>>n;
    // vi X(n), L(n);
    vector<pii> xl(n);
    rep(i, n) {
        cin >> xl[i].first >> xl[i].second;
        int a = xl[i].first - xl[i].second;
        int b = xl[i].first + xl[i].second;
        xl[i].first = a;
        xl[i].second = b;
        // xl[i].second *= -1;
    }
    sort(all(xl));

    vector<int> ans;
    ans.push_back(0);
    int right_prev = xl[0].first;
    int right = xl[0].second;
    for(int i = 1; i < n; i++) {
        // cout << right_prev << " " << xl[i].first << " " << xl[i].second << " " << right << endl;
        if (right <= xl[i].first) {
            ans.push_back(i);
            right_prev = right;
            right = xl[i].second;
            // debug(i)
        } else if (right_prev <= xl[i].first and xl[i].second <= right) {
            right = xl[i].second;
        }
    }
    cout << ans.size() << endl;

    return 0;
}


Measured memory_bytes: 1660
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n = ni()
    a = na()
    nums = [0 for i in range(100001)]
    suma = 0
    for i in a:
        suma += i
        nums[i] += 1
    q = ni()
    for i in range(q):
        b,c = na()
        suma = suma + (c-b)*nums[b]
        nums[c] += nums[b]
        nums[b] = 0
        print(suma)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 83372
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	int mod = c % a;

	int sum = 0;
	for (int i = 0; i < a; i++)
	{
		sum = i * b;
		sum%=a;
		if ((mod + sum) % a == 0){cout<<"YES"<<endl; return 0;}
	}
	cout<<"NO"<<endl;


return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> A(n, vector<ll>(m)), B(m, vector<ll>(l)), C(n, vector<ll>(l, 0));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> A[i][j];
    for (int i = 0; i < m; i++)
        for (int j = 0; j < l; j++)
            cin >> B[i][j];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            for (int k = 0; k < m; k++)
            {
                C[i][j] += A[i][k] * B[k][j];
            }
        }
        printv(C[i]);
    }
}



Measured memory_bytes: 3276
INF = 10 ** 7
n, m, r = gets.split.map(&:to_i)
destinations = gets.split.map(&:to_i)
edges = []
m.times { edges << gets.split.map(&:to_i) }
memo = Array.new(n) { Array.new(n, INF) }
# 初期化　既にいる場所へ行くコストは 0
n.times { |i| memo[i][i] = 0 }
edges.each do |f, t, w|
  f -= 1
  t -= 1
  memo[f][t] = w
  memo[t][f] = w
end

# ワーシャルフロイド法 Warshall–Floyd Algorithm
# 参照渡しで若干高速化
(0...n).each do |via|
  (0...n).each do |from|
    memo_from = memo[from]
    (0...n).each do |to|
      via_dist = memo_from[via] + memo[via][to]
      memo_from[to] = via_dist if memo_from[to] > via_dist
    end
  end
end

distances = []
destinations.permutation(r).each do |cities|
  tmp = 0
  current = cities.shift
  cities.each do |city|
    tmp += memo[current - 1][city - 1]
    current = city
  end
  distances << tmp
end

puts distances.min


Measured memory_bytes: 6268
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;


int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);



    int n, m, k;
    cin >> n >> m >> k;
    n = max(n, m);
    cout << k / n + (k % n ? 1 : 0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<n; i++)
int main(void){
    int n, m;
    cin >> n >> m;
    int maxL = 1;
    int minR = n;
    rep(a, m){
        int l, r;
        cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }
    
    int ans = minR - maxL + 1;
    ans = max(ans, 0);
    cout << ans << endl;
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n; string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		s[i] += n;
		if (s[i] > 'Z') {
			s[i] -= 26;
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main()
{
	long long int s,c;
	scanf("%lld %lld",&s,&c);
	if(s*2>=c)
	{
		printf("%lld",c/2);
		return 0;
	}
	else
	{
		c=c-s*2;
		c=c/4;
		printf("%lld",c+s);
		return 0;
	}
	return 0; 
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){

  double a,b,c,d,e,f;
  double g;

  cin>>a>>b>>c>>d;

  e = pow((c-a), 2);
  f = pow((d-b), 2);
  g = e+f;

  printf("%.10f\n", sqrt(g));

}

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

int main(void) {
	int N;

	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l,r,i,j,ans;
    bool vis[100010];
    memset(vis,false,sizeof(vis));
    cin>>n;ans=0;
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&l,&r);
        for(j=l;j<=r;j++)
            vis[j]=true;
    }
    for(i=1;i<=100000;i++)
        if (vis[i]) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
Ave=10000000000
T*=1000
A*=1000
n=0
for i in range(N):
    Ave1=abs((T-H[i]*6)-A)
    if Ave1<Ave:
        Ave=Ave1
        n=i
print(n+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, A[3][3], b[10];
    bool appear[3][3];
    rep(i,3) {
       rep(j,3) cin >> A[i][j]; 
    }
    cin >> N;
    rep(i,N) cin >> b[i];
    rep(i,N) {
        rep(j,N) {
            appear[i][j] = false;
            rep(k,N) {
                if(A[i][j] == b[k]) appear[i][j] = true;
            }
        }
    }
    string ANS = "No";
    rep(i,3) {
        if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
    }
    rep(i,3) {
        if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
    cout << ANS << endl;
    return 0;
}

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

int main()
{
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> x(N), y(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	vector<int> ids(N);
	iota(ids.begin(), ids.end(), 0);
	ld res = 0;
	int cnt = 0;
	do {
		for (int i = 1; i < N; i++) {
			int dx = x[ids[i]] - x[ids[i - 1]], dy = y[ids[i]] - y[ids[i - 1]];
			res += sqrtl(dx * dx + dy * dy);
		}
		++cnt;
	} while (next_permutation(ids.begin(), ids.end()));
	cout << res / cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N,ans=0;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int count=0,save=A[0];
    rep(i,N){
        if(A[i]==save) count++;
        else ans+=count/2,count=1,save=A[i];
    }
    ans+=count/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
love_count = [0 for _ in range(M)]

for _ in range(N):
    K, *A = input().split()
    for a in A:
        love_count[int(a)-1] += 1

count = 0
for num in love_count:
    if num == N:
        count += 1

print(count)

Measured memory_bytes: 9140
import java.util.Scanner;
class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNextLong()){
    long a=sc.nextLong();
    long b=sc.nextLong();
    long c=GCD(a,b);
    long d=a*b/c;
    System.out.println(c+" "+d);
    
    }
   }
   public static long GCD(long a,long b){
   long c=a;
   long d=b;
   long r=0;
       while( (r = c % d) != 0 ) {
            c = d;
            d = r;
        }
        return d;
   }
   }
    

Measured memory_bytes: 26188
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
using namespace std;
#define mp make_pair
#define sc second
#define fs first
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ABS(a) (((a)>0)?(a):(-(a)))
typedef long long LL;
typedef pair < int , int > pii;
const LL MOD=1000000007;
int n,m,k,d,t,a[100005],v,aa,bb,goal;
LL res[100005],all[100005];
bool V[200005];
struct segT{
	LL arr[1000005];
	int l[1000005],r[1000005];
	void Init(int p,int L,int R){
		l[p]=L;
		r[p]=R;
		if(L!=R){
			int m=(L+R)>>1;
			Init((p<<1),L,m);
			Init(((p<<1)|1),m+1,R);
			arr[p]=arr[(p<<1)]*arr[((p<<1)|1)];
			arr[p]%=MOD;
		}
		else arr[p]=(LL)L;
	}
	LL getv(int p,int L,int R){
		if(l[p]>=L && r[p]<=R){
			return arr[p];
		}
		int m=(l[p]+r[p])>>1;
		LL ret=1;
		if(L<=m) ret=getv((p<<1),L,R);
		if(R>m) ret*=getv(((p<<1)|1),L,R);
		ret%=MOD;
		return ret;
	}
}segt;
LL multiply(LL val,int times){
	LL res=1;
	while(times){
		if(times&1) {
			res*=val;
			res%=MOD;
		}
		val*=val;
		val%=MOD;
		times>>=1;
	}
	return res;
}
LL GC(int N,int M){
	if(N<M) return 0;
	LL s1,s2,s3;
	s1=multiply(segt.getv(1,1,MIN(M,N-M)),(int)MOD-2);
	s2=multiply(segt.getv(1,MIN(M,N-M)+1,MAX(M,N-M)),(int)MOD-1);
	s3=multiply(segt.getv(1,MAX(M,N-M)+1,N),(int)MOD);
	s1*=s2;
	s1%=MOD;
	s1*=s3;
	s1%=MOD;
	return s1;
}
int main(){
	cin.tie(0);
	segt.Init(1,1,200000);
	int xb,x2;
	scanf("%d",&n);
	for(xb=0;xb<=n;xb++) scanf("%d",&a[xb]);
	for(xb=0;xb<=n;xb++) {
		if(V[a[xb]]){
			v=a[xb];
			bb=xb;
			break;
		}
		V[a[xb]]=1;
	}
	for(xb=0;xb<=n;xb++){
		if(a[xb]==v){
			aa=xb;
			break;
		}
	}
	goal=aa+n-bb;
	for(xb=1;xb<=n+1;xb++){
		all[xb]=GC(n+1,xb);
		res[xb]=GC(goal,xb-1);
	}
	for(xb=1;xb<=n+1;xb++){
		all[xb]+=MOD;
		all[xb]-=res[xb];
		all[xb]%=MOD;
		cout<<all[xb]<<'\n';
	}
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

int32_t main() {

    int n, k; cin >> n >> k;
    deque<int> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i];

    int ans = 0;
    for(int take = 0; take <= k && take <= n; ++take) {
        int rep = k-take;
        for(int left = 0; left <= take; ++left) {
            int right = take-left;
            int sm = 0;
            priority_queue<int, vector<int>, greater<int>> pq;
            for(int i = 0; i < left; ++i) {
                sm += v[i];
                pq.push(v[i]);
            }
            for(int i = 0; i < right; ++i) {
                sm += v[n-i-1];
                pq.push(v[n-i-1]);
            }

            for(int rem = 0; rem < rep; ++rem) {
                if(pq.empty() || pq.top() > 0) break;
                sm -= pq.top(); pq.pop();
            }

            ans = max(ans, sm);
        }
    }

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


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007LL

#define N_MAX 2000100

long long fact[N_MAX];
long long rfact[N_MAX];

long long modpow(long long a, long long b){ 
  long long r = 1LL;

  while(b){
    if(b & 1LL)r *= a;
    if(r >= MOD)r %= MOD;
    a *= a;
    if(a >= MOD)a %= MOD;
    b >>= 1LL;
  }
  return r%MOD;
}

long long nCr(long long n, long long r){ 
  long long ret = 1LL;
  ret *= fact[n];
  ret %= MOD;
  ret *= rfact[r];
  ret %= MOD;
  ret *= rfact[n-r];
  ret %= MOD;
  return ret;
}

ll f(ll r, ll c){
  ll ret = r+1;
  rep(i,1,c+1){
    ret += nCr(r+i+1,r)%MOD;
    ret %= MOD;
  }
  return ret;
}

int main(){
  clr(fact,0);
  fact[0]=1;
  rep(i,1,N_MAX){
    fact[i] = fact[i-1]*i;
    fact[i] %= MOD;
  }
  clr(rfact,0);
  rfact[0]=1;
  rep(i,1,N_MAX){
    rfact[i] = rfact[i-1]*modpow(i,MOD-2);
    rfact[i] %= MOD;
  }
  ll r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;
  ll a1 = f(r2,c2)%MOD;
  ll a2 = f(r1-1,c2)%MOD;
  ll a3 = f(r2,c1-1)%MOD;
  ll a4 = f(r1-1,c1-1)%MOD;
  ll ans = MOD*4+a1-a2-a3+a4;
  cout << ans%MOD << endl;
  return 0;
}

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

using namespace std;

char board[100][100];
bool iserase[100][100];
int h,w;

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

	memset(iserase,false,sizeof(iserase));

	cin >> h >> w;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin >> board[i][j];
		}
	}

	for(int i=0;i<h;i++)
	{
		bool ok = true;
		for(int j=0;j<w;j++)
		{
			if(board[i][j]=='#')
			{
				ok = false;
				break;
			}
		}
		if(ok)
		{
			for(int j=0;j<w;j++)
			{
				iserase[i][j] = true;
			}
		}
	}

	for(int j=0;j<w;j++)
	{
		bool ok = true;
		for(int i=0;i<h;i++)
		{
			if(board[i][j]=='#')
			{
				ok = false;
				break;
			}
		}
		if(ok)
		{
			for(int i=0;i<h;i++)
			{
				iserase[i][j] = true;
			}
		}
	}	

	for(int i=0;i<h;i++)
	{
		bool flag = false;
		for(int j=0;j<w;j++)
		{
			if(iserase[i][j]==false)
			{
				flag = true;
				cout << board[i][j];
			}
		}
		if(flag)
		{
			cout << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 500050
#define MO 
ll a[N],b[N],c,o,u,ss,L,R,mi,n,k,t1,t2;
inline int ch(ll p) // <=p  至少k个 
{
	ll s=0;
	
	if(p<0){
		p=-p;
		F(i,1,t1){
			if(!a[i])continue;
			o=(p+a[i]-1)/a[i];
			u=lower_bound(b+1,b+t2+1,o)-b;
			s+=t2-u+1;
		}
		return s>=k;
	}
	
	s+=(ll)t1*t2;
	F(i,1,t1){
		if(!a[i]){
			s+=t1-i;
			continue;
		}
		o=p/a[i]+1;
		u=lower_bound(a+1,a+t1+1,o)-a; --u;
		if(u>i)s+=u-i;
	}
	F(i,1,t2){
		if(!b[i]){
			s+=t2-i;
			continue;
		}
		o=p/b[i]+1;
		u=lower_bound(b+1,b+t2+1,o)-b; --u;
		if(u>i)s+=u-i;
	}
	return s>=k;
}

inline void _Sol_()
{
	read(n);read(k);
	F(i,1,n){
		read(c);
		if(c>=0)a[++t1]=c;else b[++t2]=-c;
	}
	sort(a+1,a+t1+1);sort(b+1,b+t2+1);
	
	ch(6);
	
	L=-1.1e18; R=1.1e18;
	while(L<=R){		
		mi=(L+R)/2;
		if(ch(mi))ss=mi,R=mi-1;else L=mi+1;
	}
	priE(ss);
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 100000000 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x*res);
    x=(x*x);    
    y=y/2;
  }
  return res;
}

ll modinv(ll x,ll m){
  return power(x,m-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;

   while(test--)
   solve();
}

void solve(){
   ll n,k;
   cin>>n>>k;
   if(n==0){
      cout<<0;
      return;
   }
   ll ans=n;
   if(n>=k)
   n=n%k;
   
   ans=min(ans,n);
   ans=min(ans,k-n);
   
   cout<<ans;
}


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/
// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/



Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define fi first
#define se second
#define ll long long int
#define pb push_back
#define MOD 998244353
int main(){
    ll a, b;
    cin>>a>>b;
    pair <ll, ll> r[b];
    for (ll i=0; i<b; i++) cin>>r[i].fi>>r[i].se;
    ll diff[2*a+2], dp[a+1];
    for (ll i=0; i<=a+1; i++) diff[i]=0;
    for (ll i=0; i<=a; i++) dp[i]=0;
    dp[1]=1;
    for (ll i=1; i<=a; i++){
        diff[i]+=diff[i-1];
        dp[i]+=diff[i];
        dp[i]%=MOD;
        for (ll j=0; j<b; j++) diff[i+r[j].fi]+=dp[i], diff[i+r[j].fi]%=MOD, diff[i+r[j].se+1]-=dp[i];
    }
    cout<<dp[a]<<endl;
}

Measured memory_bytes: 8232
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void calc() {

	double pi = 3.14;
	Int R; std::cin >> R;
	std::cout << std::setprecision(10) << (double)(2 * R) * pi;

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 3752
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
dic = defaultdict(int)
d = set()
for i in range(n):
    a,b = readInts()
    d.add(a)
    dic[a] += b
d = sorted(list(d))
ans = 0
for v in d:
    if ans + dic[v] >= k:
        print(v)
        exit()
    ans += dic[v]


Measured memory_bytes: 19880
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

ll sti(string s) {
	ll len = s.length();
	if (len < 1) return 0;
	return (s[len - 1] - '0') + 10 * (sti(s.substr(0, len - 1)));
}

/***
split by t
***/
vcs splitAll(string s, string t) {
	vcs r;
	for (int p = 0; (p = s.find(t)) != s.npos;) {
		r.pb(s.substr(0, p));
		s = s.substr(p + t.size());
	}
	r.pb(s);
	return r;
}


int vals[100][100];
int N;

int dp[100][100];

int solve() {
	minit(dp, -1);
	
	dp[0][50] = vals[0][50];
	for_(i, 0, N) {
		for_(j, 0, 100) {
			if (dp[i][j]<0) continue;
			dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j] + vals[i+1][j-1]);
			dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + vals[i+1][j+1]);
		}
	}
	
	return dp[N-1][50];
}

int main() {
	minit(vals, -1);
	
	string in; int prev_len = 0;
	int i = 0, j = 50;
	while (1) {
		getline(cin, in);
		if (in=="") break;
		
		vcs input = splitAll(in, ",");
		
		int len = (int)input.sz;
		j = 51 - len;
		
		for_(k, 0, len) {
			vals[i][j] = sti(input[k]);
			j += 2;
		}
		
		i++;
	}
	
	N = i;
	
	cout << solve() << endl;
	
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(x) begin(x), end(x)
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

template <typename UnaryPredicate>
ll binsearch(ll l, ll r, UnaryPredicate p) { // [l, r), p is monotone
    assert (l < r);
    -- l;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        (p(m) ? r : l) = m;
    }
    return r; // = min { x in [l, r) | p(x) }, or r
}

const int inf = 1e9+7;
int main() {
    int x, k; scanf("%d%d", &x, &k);
    vector<int> r(k); repeat (i, k) scanf("%d", &r[i]);
    if (r[0]) r.insert(r.begin(), 0);
    r.push_back(inf);
    vector<int> hi(k + 1, x);
    vector<int> ub(k + 1, x);
    vector<int> lb(k + 1);
    vector<int> lo(k + 1);
    repeat (i, k) {
        ll dt = r[i + 1] - r[i];
        if (i % 2 == 0) {
            hi[i + 1] = hi[i] - dt;
            ub[i + 1] = ub[i];
            lo[i + 1] = lo[i] - dt;
            lb[i + 1] = lb[i] + max<ll>(0, - lo[i + 1]);
        } else {
            hi[i + 1] = hi[i] + dt;
            lb[i + 1] = lb[i];
            lo[i + 1] = lo[i] + dt;
            ub[i + 1] = ub[i] - max(0, hi[i + 1] - x);
        }
        setmin(hi[i + 1], x); setmax(hi[i + 1], 0);
        setmin(ub[i + 1], x); setmax(ub[i + 1], 0);
        setmin(lb[i + 1], x); setmax(lb[i + 1], 0);
        setmin(lo[i + 1], x); setmax(lo[i + 1], 0);
        if (hi[i + 1] == 0) ub[i + 1] = 0;
        if (lo[i + 1] == x) lb[i + 1] = x;
    }
    int q; scanf("%d", &q);
    while (q --) {
        int t, a; scanf("%d%d", &t, &a);
        int j = binsearch(0, r.size(), [&](int i) {
            return r[i] > t;
        }) - 1;
        if (a <= lb[j]) {
            a = lo[j];
        } else if (ub[j] <= a) {
            a = hi[j];
        } else {
            a = (a - lb[j]) + lo[j];
        }
        int dt = t - r[j];
        a = j & 1 ? min(x, a + dt) : max(0, a - dt);
        printf("%d\n", a);
    }
    return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>

int main(void){
  int n, i;
  scanf("%d", &n);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = n - 1; i > 0; i--) {
    printf("%d ", a[i]);
  }
  printf("%d\n", a[0]);
}


Measured memory_bytes: 2040
N=int(input())
data=[]
for i in range(N):
    X,L=map(int,input().split())
    data.append([X+L,X-L])

data.sort()
cnt=1
R=data[0][0]
for i in range(1,N):
    r,l=data[i]
    if R<=l:
        R=r
        cnt+=1
print(cnt)

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

int main() {
    int N, a;
    cin >> N;
    int cnt = 0;
    for(int i = 1; i <= N; i++) {
        cin >> a;
        if(i % 2 == 1 && a % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
#define debug(x) cout<<#x<<": "<<x<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
typedef long long ll;

using VII = vector<vector<int>>;

int Y,X,C;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
void coloring(int y,int x,int c1,int c2,VII &s){
    if(y<0 || x<0 || x>=X || y>=Y) return;
    if(s[y][x] == c2) return;
    if(s[y][x] == c1){
        s[y][x] = c2;
        rep(i,4){
            coloring(y+dy[i],x+dx[i],c1,c2,s);
        }
    }
}

int dfs(int limit,VII cur){
    if(limit == 1){
        coloring(0,0,cur[0][0],C,cur);
        coloring(0,0,C,0,cur);
        int res = 0;
        rep(y,Y)rep(x,X){
            if(cur[y][x] == 0){
                res++;
            }
        }
        return res;
    }

    int res = 0;
    rep1(c,6)if(c != cur[0][0]){
        VII nxt = cur;
        coloring(0,0,cur[0][0],c,nxt);
        res = max(res,dfs(limit-1,nxt));
    }
    return res;
}

int main(void){
    while(cin>>Y>>X>>C, Y|X|C){
        VII s(Y);
        rep(y,Y){
            s[y].resize(X);
            rep(x,X){
                cin>>s[y][x];
            }
        }
        cout<<dfs(5,s)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3096
def main():
    a=inputList()
    n=a[0]
    k=a[1]

    blue=k
    red=n-k

    for i in range(1,k+1):
        print(solve(red,blue,i))


def solve (red,blue,i):
    if(red<i-1):
        return 0

    ans=comb(red+1,i)*comb(blue-1,i-1)
    return ans%(10**9+7)

def comb(a,b):
    if(a-b<0):
        return 0
    if(a==b):
        return 1

    ans=1
    b=min(b,a-b)
    for i in range(b):
        ans*=a-i
        ans//=i+1

    ans %=10**9+7

    return ans


def inputList():
    a=list(map(int,input().split()))
    return a

def multisort(li,index):
    return sorted(li,key=lambda x: x[index])

if(__name__=='__main__'):
    main()


Measured memory_bytes: 3316
s = int(input())

a = [s]
for i in range(2, 10**6+1):
    if a[-1] % 2 == 0:
        a.append(a[-1]/2)
    else:
        a.append(3 * a[-1] + 1)
    
    if len(a) != len(set(a)):
        print(i)
        break
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
using namespace __gnu_pbds;
 
#define ll long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second

#define pq priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define MAX  *max_element
#define MIN  *min_element
#define des_sort(v) sort(v.begin(),v.end(),greater<int>())
 
#define c_ones(number) __builtin_popcountll(number)
#define flip_bits(number) static_cast<unsigned>(~number)
 
#define all(X) X.begin(),X.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(itr,n) for(itr=n.begin();itr!=n.end();itr++)
 
#define FLUSH fflush(stdout)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb_ds tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define INF 1e18
 
const double PI = acos(-1);
 
bool compare(pair<int,int>a , pair<int,int>b){
	return a.first==b.first ? a.second<b.second : a.first < b.first;
}
 
struct hash_pair{ 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
vector<vector<ll>> v;
vector<ll> vis;
ll n,m;
vector<ll> dp;
void dfs(int u){
	vis[u]=1;
	for(auto it : v[u]){
		if(!vis[it]){
			dfs(it);
		}
		dp[u] = max(dp[u],1+dp[it]);
	}
}

int main(){
	cin>>n>>m;
	v.resize(n+1);
	vis.resize(n+1,0);
	dp.resize(n+1,0);
	ll x,y;
	while(m--){
		cin>>x>>y;
		v[x].pb(y);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i])dfs(i);
	}
	
	ll mx=-1;
	for(int i=1;i<=n;i++){
		mx = max(mx,dp[i]);
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 12124
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 28 01:21:16 2020

@author: liang
"""

#バケツソートO(n)
N, K = map(int,input().split())
num = [0]*(10**5+1)
for i in range(N):
    a, b = map(int,input().split())
    num[a] += b

tmp = 0
for i in range(10**5+ 1):
    tmp += num[i]
    if tmp >= K:
        print(i)
        break

Measured memory_bytes: 11656
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  string s;
  cin>>s;
  int ans=0;
  for(char c:s)
    if(c=='1')
      ans++;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256