akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll N=1e5+2;
const ll MOD=1e9+7;
const ll inf=1e18+6;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(20);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(min(a+c,a+d),min(b+c,b+d));
}


Measured memory_bytes: 256
S = input()
yymm = "01" <= S[2:4] <= "12"
mmyy = "01" <= S[0:2] <= "12"
if yymm and mmyy:
    print("AMBIGUOUS")
elif yymm:
    print("YYMM")
elif mmyy:
    print("MMYY")
else:
    print("NA")


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

int main() {
	int N,A,B;
    cin >> N >> A >> B;
  
  	int ans = 0;
  
  	for(int i = 1; i <= N; i++) {
    	int rest = 0,alt = i;
      
      	while(alt > 0) {
        	rest += alt % 10;
          	alt /= 10;
        }
      
      	if(rest >= A && rest <= B) ans += i;
    }
  
  	cout << ans << endl;
}


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)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    ll h,w;cin>>h>>w;
    if(h==1||w==1){co(1);return 0;}
    co(((h*w)%2==1)?h*w/2+1:h*w/2);
}

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

int main() {
  int n, k, o = 0;
  scanf("%d %d", &n, &k);
  vector<int> v(n);
  for(int i = 0; i < n; i++) scanf("%d", &v[i]);
  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= n; j++) {
      int s = k - i - j, t = 0;
      if(i + j > n || s < 0) continue;
      vector<int> h;
      for(int r = 0; r < i; r++) h.push_back(v[r]), t += v[r];
      for(int l = 0; l < j; l++) h.push_back(v[n - 1 - l]), t += v[n - 1 - l];
      sort(h.begin(), h.end());
      int m = t;
      for(int l = 0; l < min(s, i + j); l++) m = max(m, t -= h[l]);
      o = max(o, m);
    }
  }
  printf("%d\n", o);
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N=int(input())
arr=make_divisors(N)

#print(arr)
n=N**(0.5)

min_s=10**10
min_a=-1
for i,a in enumerate(arr):
  if min_s>abs(a-n):
    min_a=a
    min_s=abs(a-n)
print(min_a+N//min_a-2)  

Measured memory_bytes: 3280
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
high = max(s.values())
ans = [k for k,v in s.items() if v==high]
print('\n'.join(sorted(ans)))

Measured memory_bytes: 35560
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,A;
  cin >> N;
  cin >> A;
  if(N % 500 <= A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int main()
{
    vok();
    int t;
    IN t;
    while(t--)
    {
        int n;
        IN n;
        vll v(n);
        loop(i,0,n)
        {
            IN v[i];
        }
        string s;
        IN s;
        bool flag=true;
        vll xors;
        rloop(i,n-1,0)
        {
            ll x=v[i];
            for(auto next:xors)
            {
                x=min(x,x^next);
            }
            if(x==0)
            {
                continue;
            }
            if(s[i]=='0')
            {
                xors.pb(x);
            }
            else
            {
                flag=false;
                break;
            }
        }
        if(flag)
        {
            OUT 0<<endl
        }
        else
        {
            OUT 1<<endl
        }
    }
    return 0;
}

Measured memory_bytes: 3668
import numpy as np
from collections import defaultdict
from math import gcd
import time
import sys
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
start = time.time()
A, B, C, D = map(int, input().split(' '))

while 1:
    C -= B
    if C <= 0:
        print('Yes')
        exit()
    A -= D
    if A <= 0:
        print('No')
        exit()


Measured memory_bytes: 27152
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    for(int i=0;i<30;++i){
        if(BIT(i)&b){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
    }
    return res;
}

int main(){
    int N, M;
    cin >> N >> M;
    int line[N+1];
    REPA(i, N+1){
        line[i] = 1;
    }
    line[1]=-1;
    REP(i, M){
        int x, y;
        cin >> x >> y;
        if(line[x]<0){
            line[y] = -abs(line[y]) - 1;
            ++line[x];
        }else{
            line[y] += line[y]>=0?1:-1;
            --line[x];
        }
    }
    int ans = 0;
    REPA(i, N+1){
        ans += 0>line[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //上に同じ

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

  int n,x,t,cnt = 0,ans = 0;
  cin >> n >> x >> t;
  ans = n/x*t;
  if (n % x != 0){
    ans+= t;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3608
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();
    if (A >= 13)
      System.out.println(B);
    else if (A >= 6)
      System.out.println(B / 2);
    else
      System.out.println(0);
  }
}


Measured memory_bytes: 23508
#include<stdio.h>
int main(void){
	char c;
	int H,W,K,gen,max=0,h,i,j,q,w,e,r,t,step,ren,mae,tsten;
	int bans[32][32]={0};
	int gban[32][32]={0};
	int iti[30]={0};
	scanf("%d %d %d",&H,&W,&K);
	for(i=H-1;i>=0;i--){
		for(j=0;j<W;j++){
			scanf(" %c",&c);
			bans[i][j]=c-48;
		}
		bans[i][W]=0;//右だけ晩兵
	}
	W++;
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			for(q=0;q<H;q++){
				for(w=0;w<W;w++){
					gban[q][w]=bans[q][w];
				}
			}
			gban[i][j]=0;
			gen=0;
			step=0;
			for(step=0;step<30;step++){//30連鎖はしないと思ふ
				for(q=0;q<W;q++){//まず落とす
					e=0;
					for(w=0;w<H;w++){
						if(gban[w][q]!=0){
							iti[e]=gban[w][q];
							e++;
						}
					}
					for(w=0;w<H;w++){
						if(w<e){ gban[w][q]=iti[w]; } else{gban[w][q]=0;}
					}
				}
				//落とし終わった
				tsten=0;
				for(q=0;q<H;q++){
					ren=0;
					mae=0;
					for(w=0;w<W;w++){
						if(mae==gban[q][w]&&gban[q][w]!=0){
							ren++;
						} else{
							if(ren>=K){
								for(e=w-ren;e<w;e++){
									tsten+=gban[q][e];
									gban[q][e]=0;
								}
							}
							ren=1;
						}
						mae=gban[q][w];
					}
				}
				gen+=tsten<<step;
				if(tsten==0){
					break;
				}
			}
			if(max<gen){max=gen;}
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;
int main(){
	int i,j,n,cnt = 0;
	string s;
	cin >> n >> s;
	for(i=0;i<n - 2;i++){
		string u = s.substr(i,3);
		if(u=="ABC") cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")

Measured memory_bytes: 74340
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 18;
const int MM = 1000000007;

int A[MX], B[MX];

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d%d", A+i, B+i);
	ll ans = 0;
	for(int i = N; i >= 1; i--){
		if( (A[i]+ans) % B[i] == 0 ) continue;
		ans += B[i] - (A[i] + ans) % B[i];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1024
#include <cstdio>

#define ll long long

int main() {
    ll a, b, x, rez;
    scanf("%lld%lld%lld", &a, &b, &x);
    rez = b / x;
    if(a == 0)
        rez++;
    else
        rez = rez - (a - 1) / x;
    printf("%lld", rez);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j) vector<vector<ll>> name(i,vector<ll>(j))
#define vec2f(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k)))
#define vec3f(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define vec4(name,i,j,k,l) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l))))
#define vec4f(name,i,j,k,l,m) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l,m))))
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

int main(){
    ll x, n, p; cin >> x >> n;
    vector<ll> pl;
    REP(i,n){
        cin >> p;
        pl.pb(p-x);
    }
    ll cnt = 0;
    while (true){
        bool jud = true;
        REP(i,pl.size()){
            if (pl[i]==cnt){
                jud = false;
                break;
            }
        }
        if (jud){
            cout << x+cnt << endl;
            break;
        }
        if (cnt>=0) cnt = (cnt+1)*-1;
        else cnt = -1*cnt;
    }
}


Measured memory_bytes: 3624
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし


N = I()
X = LI2()
X.reverse()

if N == 1 and len(X) == 1 and X[0] == 0:
    print(1)
    exit()


def popcount(n):
    res = 0
    m = n.bit_length()
    for i in range(m):
        res += (n >> i) & 1
    return res


# 1回の操作で 2*10**5 未満になることに注意

F = [0]*(2*10**5)  # F[i] = f(i)
for i in range(1,2*10**5):
    F[i] = 1 + F[i % popcount(i)]

a = sum(X)
b = a-1
c = a+1
if a == 1:
    C = [1]  # 2冪をcで割った余り
    xc = 0  # Xをcで割った余り
    for i in range(N):
        if X[i] == 1:
            xc += C[-1]
            xc %= c
        C.append((2 * C[-1]) % c)

    ANS = []
    for i in range(N):
        if X[i] == 1:
            ANS.append(0)
        else:
            ANS.append(1 + F[(xc + C[i]) % c])

    ANS.reverse()
    print(*ANS, sep='\n')
    exit()

B,C = [1],[1]  # 2冪をb,cで割った余り
xb,xc = 0,0  # Xをb,cで割った余り
for i in range(N):
    if X[i] == 1:
        xb += B[-1]
        xc += C[-1]
        xb %= b
        xc %= c
    B.append((2*B[-1])%b)
    C.append((2*C[-1])%c)

ANS = []
for i in range(N):
    if X[i] == 1:
        ANS.append(1 + F[(xb-B[i]) % b])
    else:
        ANS.append(1 + F[(xc+C[i]) % c])

ANS.reverse()
print(*ANS,sep='\n')


Measured memory_bytes: 126140
#include <bits/stdc++.h>
const int INF = 1e9;
const int MO = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    int N,M;cin >> N >> M;
       vector<vector<Edge>> Edges(N);
       vector<vector<Edge>> uku(N);
       vector<int> deg(N, 0);
       for(int a = 0;a < M+N-1;a++){
           int b,c;cin >> b  >> c;
           deg[c-1]++;
        //   b--;
        //   c--;
           Edges.at(b-1).push_back(Edge(b-1,c-1));
           uku.at(c-1).push_back(Edge(b-1,c-1));
       }
       queue<int> S;
       vector<int> L;
       for(int a = 0;a < N;a++){
           if(deg[a]==0)S.push(a);
       }
       vector<bool> flag(N,true);
       while(!S.empty()){
           int n = S.front();S.pop();
           L.push_back(n);
           for(auto e : Edges.at(n)){
               deg[e.to]--;
               if(deg[e.to] == 0)S.push(e.to);
           }
           flag.at(n)=false;
       }
       /*
       for(int a = 0;a < N;a++){
           if(flag.at(a)){
               cout<<"DAGではない"<<endl;
               return 0;
           }
       }
       */
       vector<int> vec(N);
       for(int a = 0;a < N;a++){
           vec.at(L.at(a)) = a;
         //  COUT(L.at(a));
       }
      // ENDL;
       //for(int a = 0;a < vec.size();a++)COUT(vec.at(a));
      // ENDL;
       for(int a = 0;a < N;a++){
           if(vec.at(a) == 0){
               cout<<0<<endl;
               continue;
           }
           int s = 0,ins;
           for(auto e : uku.at(a)){
               if(s <= vec.at(e.from)){
                   s = vec.at(e.from);
                   ins = e.from;
               }
           }
           cout<<ins+1<<endl;
       }

}


Measured memory_bytes: 13052
#include "bits/stdc++.h"
using namespace std;

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

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+10;

int dp[N];
int h[N];	
int main()
{
	fast;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>h[i];
	
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);

	for(int i=3;i<=n;i++)
	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	
	cout<<dp[n]<<endl;
	
	return 0;
}

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

int main(){
  int64_t X, K ,D;
  cin >> X >> K >> D;
  X = abs(X);
  int64_t sho, amari;
  sho = X / D;
  amari = X % D;
  if(sho > K){
    cout << X - D * K;
    return 0;
  }
  if((K - sho) % 2 == 0) cout << amari;
  if((K - sho) % 2 == 1) cout << abs(amari - D);
  return 0;
}

Measured memory_bytes: 3624
# n 県数
# m 市数
n, m = gets.split.map(&:to_i)

ken = {}
data = m.times.map.with_index do |i|
  p, y = gets.split.map(&:to_i)
  ken[p] ||= []
  ken[p] << [i, y]
  [p, y]
end

# pp data
# pp ken

ken.each do |p, value|
  value
    .sort_by {|(data_index, year)|  year } # sort with year
    .each.with_index(1) do |(data_index, year), order|
      # pp ({ ken: p, data_index: data_index, order: order, year: data[data_index][1] })
      data[data_index][2] = order
    end
end

data.each do |(p, _y, o)|
  puts "%06d%06d" % [p, o]
end


Measured memory_bytes: 35836
#include <iostream>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int dup = 0;
  bool exist[100001] = {};
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (exist[a]) dup++;
    else exist[a] = 1;
  }
  cout << n - dup - dup % 2 << endl;
  return 0;
}

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

using namespace std;


void solve() {
    string s; cin >> s;
    int n = s.size();
    vector<int> rl(n, 0);
    rl[0] = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] == 'R') {
            rl[i] = rl[i-1] + 1;
        }
    }
    rl[n-1] = 1;
    for (int i = n-2; i >= 0; i--) {
        if (s[i] == 'L') {
            rl[i] = rl[i+1] + 1 - (s[i+1] == 'R');
        }
    }
    for (int i = 0; i < n; i++) {
        if (s[i]=='R' && s[i+1]=='L') {
            int x = (rl[i]+1)/2 + rl[i+1]/2;
            int y = rl[i]/2 + (rl[i+1]+1)/2;
            cout << x << " " << y << " ";
            i++;
        } else {
            cout << "0 ";
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1104
import sys
input=sys.stdin.readline

A=[]
_max = 0
_max2 = 0
N=int(input())
for i in range(N):
    a=int(input())
    A.append(a)
    if _max<a:
        _max2=_max
        _max=a
    elif _max2<a:
        _max2=a

for a in A:
    print(_max if _max!=a else _max2)



Measured memory_bytes: 15364
n, c = map(int, input().split())
x = []
v = []
for i in range(n):
  xi, vi = map(int, input().split())
  x.append(xi)
  v.append(vi)
l1 = [0]
l2 = [0]
r1 = [0]
r2 = [0]
vtotal = 0
for i in range(n):
  vtotal += v[i]
  l1.append(max(l1[-1], vtotal - x[i]))
  l2.append(max(l2[-1], vtotal - 2 * x[i]))
vtotal = 0
for i in range(n - 1, -1, -1):
  vtotal += v[i]
  r1.append(max(r1[-1], vtotal - (c - x[i])))
  r2.append(max(r2[-1], vtotal - 2 * (c - x[i])))
ans = 0
for i in range(n + 1):
  ans = max(ans, l1[i] + r2[n - i], l2[i] + r1[n - i])
print(ans)


Measured memory_bytes: 29296
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
#include <vector>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    long double r;
    cin >> r;
    cout << setprecision(15);
    cout << r * r * M_PI << " " << 2 * r * M_PI << endl;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int n,m,q;
ll st[11][11];
ll sum[11][11];
int a[55],b[55],c[55],d[55];
int ans[11];
ll res;

void dfs(int x,int cnt)
{
    if(cnt == n+1)
    {
        ll tmp = 0;
        for(int i = 0; i < q; i++)
        {
            if(ans[b[i]] - ans[a[i]] == c[i]){
                tmp += d[i];
            }
        }
        res = max(res,tmp);
        return;
    }
    for(int i = x;i <= m; i++)
    {
        ans[cnt] = i;
        dfs(i,cnt+1);
    }
}


int main(int argc, char const *argv[])
{
#ifdef indiewar
    freopen("in.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        st[a[i]][b[i]] = c[i];
        sum[a[i]][b[i]] = d[i];
    }
    dfs(1,1);
    cout << res << endl;
    return 0;
}

// floor(Ax/B)-A×floor(x/B)
// floor(A{x/B})
/* when you submit
	1.n = 0 or n = 1 ?
	2.array bounds ?
	3.int overflow ?
	4.multiple test cases ?
	Keep calm  think twice and code once
*/

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
    int n, *a, ans[100001] = {0};
    cin >> n;
    a = new int[n];
    int maxa = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans[a[i]]++;
        if (0 < a[i] && a[i] < 100000) {
            ans[a[i]-1]++;
            ans[a[i]+1]++;
        }
        else if (a[i] == 0) {
            ans[a[i]+1]++;
        }
        else {
            ans[a[i]-1]++;
        }
        maxa = max(a[i], maxa);
    }
    
    int x;
    int count = 0;

    for (x = 0; x <= 100000; x++) {
        count = max(ans[x], count);
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1272
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    int W,a,b;
    cin >> W >> a >> b;
    int ans;
    if(b > a+W) ans = b-(a+W);
    else if(b+W < a) ans = a-(b+W);
    else ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; i++){
        if(i%2==0){
            if(a%2==1){
                a--;
            }
            b += a/2;
            a -= a/2;

        }else{
            if(b%2==1){
                b--;
            }
            a += b/2;
            b -= b/2;
        }
    }

    cout << a << " " << b << endl;
    return 0;
}


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



cnt = 0
cnt1 = 0

for i in range(N):
    cnt = cnt + A[i]

for i in range(N):
    if A[i] / cnt >= 1 / 4 / M:
        cnt1 = cnt1 + 1



if cnt1 >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
	int N;
	int x = 0;
	int y = 0;
	int t = 0;
	cin >> N;
	int flag = 1;
	for(int i = 0;i < N;i++){
		int tt, xx, yy;
		cin >> tt >> xx >> yy;
		int dt = tt - t;
		int dx = abs(xx - x);
		int dy = abs(yy - y);
		if(flag){
			if(dt < dx + dy){
				flag = 0;
			}
			if((dt % 2) != (dx + dy) % 2){
				flag = 0;
			}
		}
		x = xx;
		y = yy;
		t = tt;
	}
	if(flag){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N,K = map(int,input().split())
p = list(map(int,input().split()))
ako = len(p)
p.sort()
nedan = 0
if (1<= K <= N <= 1000) and 1 <= ako <= 1000:
    for i in range(K):
        nedan += p[i]
print(nedan)

Measured memory_bytes: 9172
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val max = when {
        n >= 64 -> 64
        n >= 32 -> 32
        n >= 16 -> 16
        n >= 8 -> 8
        n >= 4 -> 4
        n >= 2 -> 2
        else -> n
    }
    println(max)
}

Measured memory_bytes: 31736
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    h: i32,
    a: i32,
  }
  
  println!("{}", h / a + if h % a > 0 { 1 } else { 0 });
}

Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N, M;
bool seen[110000];
using Graph = vector<vector<int>>;

void dfs(int v, const Graph& G, vector<int>& order) {
  seen[v] = true;

  for (auto nv : G[v]) {
    if (seen[nv]) continue; 
    dfs(nv, G, order);
  }

  order.push_back(v);
}

int main () {
  cin >> N >> M;
  Graph G(N+1);
  Graph Gyaku(N+1);

  Rep(i, N-1+M) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    Gyaku[b].push_back(a);
  }

  vector<int> order;
  rep(i, N) {
    if (seen[i]) continue;
    dfs(i, G, order);
  }

  reverse(All(order));

  map<int, int> mp;

  rep(i, N) {
    mp[order[i-1]] = i;
    //cout << order[i-1] << "\n";
  }

  rep(i, N) {
    if (mp[i] == 1) {
      cout << 0 << "\n";
    } else {
      int tmp = 0;
      int tmp_p = 0;
      for (auto nv: Gyaku[i]) {
        //cout << " " << nv << " " << mp[nv] << "\n";

        if (mp[nv] > tmp) {
          tmp = mp[nv];
          tmp_p = nv;
        }
      }

      cout << tmp_p << "\n";
    }
  }

}

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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 300005;
const int mod = 1e9 + 7; 

int cnt[N][61];

int main() {
	int n;
	ll a[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lld", a+i);
		for(int j = 0; j < 60; j++){
			cnt[i][j] += (a[i] & (1LL << j)) != 0;
			cnt[i+1][j] += cnt[i][j];
		}
	}
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 60; j++){
			ll aux = cnt[n][j] - cnt[i][j];
			if(a[i] & (1LL << j)){
				ans += ((1LL << j) % mod) * (n - i - 1 - aux);
				ans %= mod;
			}
			else{
				ans += ((1LL << j) % mod) * aux;
				ans %= mod;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 74112
n=int(input())
a=[int(i) for i in input().split()]
count4=0
count2=0
ok=0

for i in range(n):
    if a[i]%4==0:
        count4=count4+1
    elif a[i]%2==0:
        count2=count2+1

if count4==0:
    if count2-count2%2>=n:
        print("Yes")
    else:
        print("No")

else:
    if count4*2+1+count2-count2%2>=n:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define ld long double
#define uint unsigned int
#define endl '\n'
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define eb emplace_back 
#define pll pair<long long ,long long > 
#define ppll pair < pll , pll > 
#define pd pair<int, int>
#define ppdd pair<pd, pd>
#define vd vector<int>
#define sd(x) scanf("%d",&x) 
#define sld(x) scanf("%lld",&x) 
#define deb(x) { cerr << #x << '=' << x << '\n'; }
#define tc(x) sd(x); while(x--)
#define INF 1e18 
#define eps 0.00001 
#define le length 
#define inc(il)
using namespace std;

void solve(){
    //code goes here
    int n;
    cin >> n;
    int t[1+n], sum=0;
    for (int i = 1; i<=n; ++i){
        cin >> t[i];
        sum+=t[i];
    }   
    int m;
    cin >> m;
    int p[m+1], x[m+1];
    for (int i = 1; i<=m; ++i){
        cin >> p[i] >> x[i];
        cout << sum-t[p[i]]+x[i] << endl;
    }
}

int main(){
    ios::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL); 
    solve();
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str;
	int ans = 0;
	
	cin >> str;
	
	for(int i = 0; i < 3; i++) {
		if (str[i] == 'o') {
			ans += 100;
		}
	}
	
	cout << 700 + ans << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int maxx = 0;
int main() {
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int c, a, n;
		cin >> c >> a >> n;
		while (c >= 1 && a >= 1 && n >= 1) {
			c--;
			a--;
			n--;
			maxx++;
		}
		while (c >= 2 && a >= 1) {
			c -= 2;
			a--;
			maxx++;
		}
		while(c >= 3) {
			c -= 3;
			maxx++;
		}
		cout << maxx << endl;
		maxx = 0;
	}
}

Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  cin >> N;
  vector<int> C(N), V(N);
  for(int i = 0; i < N; i++) cin >> V[i];
  for(int i = 0; i < N; i++) cin >> C[i];
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(V[i] - C[i] > 0) {
      ans += V[i] - C[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
<?php
list($n) = ints();
$a = ints();
$csum = 0;
$sum = array_sum($a);
$min = PHP_INT_MAX;
for ($i = 0; $i < $n - 1; ++$i) {
    $csum += $a[$i];
    $min = min($min, abs($sum - 2 * $csum));
}
echo $min;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 36180
n = int(input())
a = [int(s) for s in input().split()]
ave = sum(a) / n
ans, m = 500, 500
for v, i in sorted(((abs(x - ave), i) for (i, x) in enumerate(a)), key=lambda t: t[0]):
    if m > 100:
        m = v
        ans = min(ans, i)
    else:
        break
print(ans)




Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[105][105],b[105][105];
  long long int c[105][105];
  int n,m,l;
  cin>>n>>m>>l;
  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];
    }
  }
  int sum=0;
  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];
      }
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<l-1;j++)
    {
      cout<<c[i][j]<<" ";
    }
    cout<<c[i][l-1]<<endl;
  }
}



Measured memory_bytes: 3200
#include<stdio.h>
#include<math.h>

#define csb ((sqrt(3))/2.0)

struct zb{
	double x;
	double y;
};

void cpt(double x,double y,double *px,double *py){
	double x1 = x/2.0 - y*csb;
	double y1 = x*csb + y/2.0;
	*px=x1;
	*py=y1;
}

void pr(zb s){
	printf("%.8f",s.x);
	printf(" %.8f\n",s.y);
}

void koch(int d,zb p1,zb p2){
	zb s,u,t;
	if(d==0) return;
	s.x=(p2.x-p1.x)/3.0+p1.x;
	t.x=(p2.x-p1.x)/3.0*2.0+p1.x;
	s.y=(p2.y-p1.y)/3.0+p1.y;
	t.y=(p2.y-p1.y)/3.0*2.0+p1.y;
	cpt((t.x-(s.x)),(t.y-(s.y)),&(u.x),&(u.y));
	u.x+=s.x;
	u.y+=s.y;
	koch(d-1,p1,s);
	pr(s);koch(d-1,s,u);
	pr(u);koch(d-1,u,t);
	pr(t);koch(d-1,t,p2);
}

int main(){
	zb p1;
	zb p2;
	p1.x=0;p1.y=0;
	p2.x=100.0;p2.y=0;
	int d;
	scanf("%d",&d);
	pr(p1);
	koch(d,p1,p2);
	pr(p2);
}


Measured memory_bytes: 2696
// Queue
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000 // キューの最大の長さ

typedef struct pp{
  char name[10];
  int t;
}P;

P Q[MAX]; // データを格納するための配列
int head; // キューの先頭を指し示す
int tail; // キューの末尾＋ 1 の場所（最後の要素の隣）を指し示す変数
int n;

void initialize();
int isEmpty();
int isFull();
void enqueue(P x);
P dequeue();

int main(){
  int i;
  int q; // 各プロセスの最大処理時間
  int time=0; // かかった処理時間を格納
  P u;
  initialize();
  
  scanf("%d %d", &n, &q);
  for (i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;
  while(head != tail){
    u = dequeue();
    if(u.t > q){ // プロセスの処理時間がqより長いとき
      time += q;
      u.t -= q;
      enqueue(u);
    }
    else{ // プロセスの処理時間がqより短いとき
      time += u.t;
      printf("%s %d\n", u.name, time);
    }
    
  }
  return 0;
}

// キューを空にする
void initialize(){
  head = 0;
  tail = 0;
}

// キューが空かどうかを調べる
int isEmpty(){
  if(tail == head)return 1;
  else return 0;
}

// キューが満杯かどうかを調べる
int isFull(){
  if(head == (tail + 1) % MAX)return 1;
  else return 0;
}

// キューの末尾に要素xを追加する
void enqueue(P x){
  if(isFull() == 1)exit(8);
  Q[tail] = x;
  if(tail + 1 == MAX)tail = 0;
  else tail++;

}

// キューの先頭から要素を取り出す
P dequeue(){
  P x;
  if(isEmpty() == 1)exit(8);
  x = Q[head];
  if(head + 1 == MAX)head = 0;
  else head++;
  return x;
}



Measured memory_bytes: 3288
#include<cstdio>
#include<functional>
#include<algorithm>
#include<queue>
#include<vector>
#define MM 210000000000000000
using namespace std;
typedef pair<long long,int> P;
vector<int> mati[100000],cost[100000];
int main(void)
{
	int i,n,m,j,b,c,d,p,s,t,r,v,e,flg[100000];
	long long leng[100000],a;

	priority_queue<P,vector<P>,greater<P> > que;
	P ppp;
	scanf("%d %d %d",&v,&e,&r);
	for(i=0;i<e;i++)	{
		scanf("%d %d %d",&s,&t,&d);
		mati[s].push_back(t);
		cost[s].push_back(d);
	}

	for(i=0;i<v;i++)	{
		leng[i]=MM;	flg[i]=0;
	}
	que.push(P(0,r));
	while(que.size()!=0)	{
		ppp=que.top();	que.pop();
		a=ppp.first;	b=ppp.second;
		if(a<leng[b])	{
			leng[b]=a;	flg[b]=1;
			for(i=0;i<mati[b].size();i++)	{
				if(flg[mati[b][i]]==0)	{
					que.push(P(a+cost[b][i],mati[b][i]));
				}
			}
		}
	}
	for(i=0;i<v;i++)	{
		if(leng[i]==MM)	printf("INF\n");
		else printf("%lld\n",leng[i]);
	}
	return 0;
}



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


bool binarySearch(int A[], int N, int x) {
    int left=0, right=N, mid;
    while (left < right) {
        mid = (right + left) / 2;
        if (A[mid] == x) return true;
        else if (A[mid] > x) right = mid;
        else left = mid + 1;
        // cout << right << " " << left << endl;
    }
    return false;
}

int main() {
    int n, q, m=0;
    int S[100010], T[50010];
    cin >> n;
    for (int i=0; i < n; i++) scanf("%d", &S[i]);
    cin >> q;
    for (int i=0; i < q; i++) scanf("%d", &T[i]);
    
    for (int i=0; i < q; i++) {
        if (binarySearch(S, n, T[i])) m++;
    }

    cout << m << endl;
    return 0;
} 


Measured memory_bytes: 3716
<?php
    fscanf(STDIN, "%d %d", $a, $x);
    $sticks = explode(" ", trim(fgets(STDIN)));
    rsort($sticks);
    $size = 0;
    for ($i = 0; $i < $x; $i++) {
        $size += $sticks[$i];
    }
    echo $size . "\n";
?>


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 10001
#define PI 3.1415926535897932384
#define F first
#define S second
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair




int main() 
{ 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout); 
#endif
ll n;
cin>>n;
ll a[n],b[n],c[n];
fr(n)
{
    cin>>a[i]>>b[i]>>c[i];

}
ll dp[n][3];
dp[0][0]=max(b[0],c[0]);
dp[0][1]=max(a[0],c[0]);
dp[0][2]=max(b[0],a[0]);
rep(i,1,n){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

    return 0; 
} 

Measured memory_bytes: 8260
package main

import "fmt"

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

	var c = make([][]rune, 2*H)
	for i := 0; i < 2*H; i++ {
		c[i] = make([]rune, W)
		for j := 0; j < W; j++ {
			c[i][j] = rune(canvas[i/2][j])
		}
		fmt.Println(canvas[i/2])
	}
}


Measured memory_bytes: 768
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var t = int.Parse(_[2]);

            var count = 0;
            for(var i = 1; i * a <= t; i++){
                count += b;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string s;
int ans;

signed main() {
	cin >> s;
	for (int i = 0; i < (int)s.size() / 2; i++) {
		if (s[i] != s[(int)s.size() - 1 - i])ans++;
	}
	cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll k, ans = 0, t = 0;
  cin >> k;
  rep(i, k) {
    t = t * 10 + 7;
    t %= k;
    ans++;
    if (t == 0) {
      cout << ans << endl;
      return 0;
    }
  }

  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 3588
import numpy as np

def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx


n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

temp = []

for i in range(n):
    temp_var = t - h[i] * 0.006
    temp.append(temp_var)

print(getNearestValue(temp,a) + 1)

Measured memory_bytes: 27240
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<vec.at(n-1)-vec.at(0)<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    string S, T;
    cin >> S >> T;

    ll cnt = 0;
    for (ll i = 0; i < (ll)S.size(); i++)
    {
        if(S[i] != T[i])
        {
            cnt++;
        }
    }
    OUTX(cnt);
    


    return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main(){
    int n,ac=0,wa=0,tle=0,re=0;
    cin >> n;
    string s;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;
        else if(s=="TLE") tle++;
        else re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(void){
    int a, b, c, f = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(int x = a; x <= b; x++){
        if(c % x == 0)f++;
    }
    printf("%d\n", f);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

ll tax(ll price, ll per) {
    return price * (per + 100) / 100;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll x, y, s;
    while (cin >> x >> y >> s, x || y || s) {
        ll ans = -1;
        FOR(i, 1, s+1) {
            FOR(j, 1, s+1) {
                if (tax(i, x) + tax(j, x) == s) {
                    ans = max(ans, tax(i, y) + tax(j, y));
                }
            }
        }
        assert(ans >= 0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3104
n = int(input())
sr = []
ans = [0]*n
for _ in range(n):
    s,r = input().split()
    sr += [[str(s), int(r)]]
se = sorted(sr, key=lambda x: (x[0], -x[1]))
for i in range(n):
    ans[i] = sr.index(se[i])+1
for i in range(n):
    print(ans[i])


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

int main() {
	int n;
	int a[20], b[20], c[19];
	int res = 0;

	cin >> n;

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

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

	for (int i = 0; i < n-1; ++i)
		cin >> c[i];

	for (int i = 0; i < n; ++i) {
		res += b[a[i] - 1];
		if (i != 0) {
			if (a[i] - a[i - 1] == 1)
				res += c[a[i-1] - 1];
		}
	}

	cout << res << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int n,i;
    cin>>n;
    double a[n],ans;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);

    ans = a[0];
    for(i=1; i<n; i++)
    {
        ans = (ans + a[i])/2;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256