akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

vector<int> parent;
vector<int> L;
vector<int> R;

int n;
vector<int> d(100005);

int Depth(int i, int x){
  d[i] = x;
  if(R[i] != -1) Depth(R[i], x);
  if(L[i] != -1) Depth(L[i], x + 1);
  
}

void print(int k){
    int c;
    cout << "node " << k << ": ";
    cout << "parent = " << parent[k] << ", ";
    cout << "depth = " << d[k] << ", ";

    if(parent[k] == -1) cout << "root, ";
    else if(L[k] == -1) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for(int i = 0, c = L[k]; c != -1; i++, c = R[c]){
      if(i) cout << ", ";
      cout << c;
    }

    cout << "]" << endl;

}

int main()
{

  cin >> n;

  parent.resize(n);
  L.resize(n);
  R.resize(n);

  for(int i = 0; i < n; i++){
    parent[i] = -1;
    L[i] = -1;
    R[i] = -1;
  }

  int id, k, c;
  int r, l;
  
  for(int i = 0; i < n; i++){
    cin >> id >> k;

    for(int j = 0; j < k; j++){
      cin >> c;
      if(j == 0) L[id] = c;
      else R[l] = c;

      l = c;
      parent[c] = id;

    }
  }

  for(int i = 0; i < n; i++){
    if(parent[i] == -1) r = i;
  }

  Depth(r, 0);

  for(int i = 0; i < n; i++) print(i);
  
  return 0;

}



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

int main() {
  int s1, s2, s3, n;
  cin >> n;
  s3 = n % 2;
  n = (n - s3) / 10;
  s2 = n % 2;
  n = (n - s2) / 10;
  s1 = n;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute22_1();
	}

	private static void execute22_1() {
		try (Scanner sc = new Scanner(System.in)) {
			int Q = sc.nextInt();
			int[][] q = new int[Q][2];

			for (int i = 0; i < Q; i++) {
				q[i][0] = sc.nextInt();
				q[i][1] = sc.nextInt();
			}

			boolean[] isSo = new boolean[100005];

			for (int i = 0; i < isSo.length; i++)
				isSo[i] = true;

			isSo[0] = false;
			isSo[1] = false;
			for (int i = 2; i*i < isSo.length; i++) {
				if(isSo[i]) for(int j = 2;i*j<isSo.length;j++) isSo[i*j] = false;
			}
			
			int[] sum = new int[100005];
			sum[0] = 0;
			for (int i = 1; i < sum.length; i++) {
				sum[i] = sum[i-1];
				if(isSo[i]&&isSo[(i+1)/2]) sum[i]++;
			}
				
			for (int i = 0; i < Q; i++) {
				int ans=sum[q[i][1]+1] - sum[q[i][0]-1];
				System.out.println(ans);
			}

		}
	}
}

Measured memory_bytes: 64752
from collections import deque

S = deque(input())
Q = int(input())
is_reversed = False

for i in range(Q):
    T, *fc = input().split()
    if T == "1":
        is_reversed = not is_reversed
        continue
    # 以下 T == "2"
    F, C = fc
    if F == "1":
        # 先頭に追加
        if is_reversed:
            S.append(C)
        else:
            S.appendleft(C)
    elif F == "2":
        # 末尾
        if is_reversed:
            S.appendleft(C)
        else:
            S.append(C)

ans = "".join(S) if not is_reversed else "".join(S)[::-1]
print(ans)


Measured memory_bytes: 8436
// AOJ 2090: Repeated Subsequences
// 2017.10.9 bal4u@uu

#include <stdio.h>
#include <string.h>

char s[303], t[303];

int c[303][303]; char z[303];    // for LCS
char f[303][303];
int LCS(char *x, int m, char *y, int n)
{
	int i, j, ret, ret2;

	memset(c, 0, sizeof(c)); memset(f, 0, sizeof(f));
	for (i = 1; i <= m; i++) for (j = 1; j <= n; j++) {
		if (x[i-1] == y[j-1]) c[i][j] = c[i-1][j-1]+1, f[i][j] = 0;
		else {
			if (c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j], f[i][j] = 1;
			else                        c[i][j] = c[i][j-1], f[i][j] = -1;
		}
	}
	ret2 = ret = c[m][n]-1;
	while (ret >= 0) {
		if      (f[m][n] > 0) m--;
		else if (f[m][n] < 0) n--;
		else z[ret] = x[m-1], ret--, m--, n--;
	}
	z[ret2+1] = 0;
	return ret2+1;
}

int main()
{
	int n, m, ans, a;

	while (scanf("%s", s) && *s != '#') {
		n = strlen(s);
		m = n/2, ans = LCS(s, m, s+m, n-m); 
		if (ans == 0) m = n-1; else m = n-ans, memcpy(t, z, ans+1);
		for (; m > ans; m--) {
			a = LCS(s, m, s+m, n-m);
			if (a > ans) { ans = a; memcpy(t, z, a+1); }
		}
		puts(t);
	}
	return 0;
}

Measured memory_bytes: 2072
<?php
$priority = [];
for ($count = 1, $tmp = 2; $tmp < 14; $tmp++){
    $priority[$tmp] = $count;
    $count++;
}
$priority[1] = 13;
fscanf(STDIN, "%d %d", $a, $b);
if ($priority[$a] > $priority[$b]){
    print("Alice\n");
} else if($priority[$a] < $priority[$b]){
    print("Bob\n");
} else {
    print("Draw\n");
}
?>

Measured memory_bytes: 4728
d,g = map(int,input().split())
P,C = [],[]
for i in range(1, d+1):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for j in range(d):
        if bin & 1<<j:
            cnt += P[j]
            tot += P[j]*(j+1)*100 + C[j]
    if tot < g: continue
    ans = min(ans, cnt)
    for j in range(d):
        if bin & 1<<j:
            now_cnt = cnt
            now_tot = tot - C[j]
            for k in range(P[j]-1):
                now_cnt -= 1
                now_tot -= (j+1)*100
                if now_tot >= g: ans = min(ans, now_cnt)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    double T,X;
    cin >> T >> X;
    cout << T/X;
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[500][500] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

int main() {


	cin >> a >> b>>c;

	if (a == b) {
		cout << c << endl;
	}

	if (a == c) {
		cout << b << endl;
	}

	if (c == b) {
		cout << a << endl;
	}
	

	return 0;

}


Measured memory_bytes: 2304
my @A;
my %h;
foreach my $w (split(//o, <STDIN>)){
    chomp($w);
    next if ($w eq '');
    push(@A, $w);
    $h{$w} = 1;
}
my $N = <STDIN>;
chomp($N);

my $numA = $#A;
my $numK = (keys %h);
if ($numK == 1) {
  my $numA2 = $numA+1;
  if ( ($numA2*$N) % 2 ){
    # odd
    my $tmp = $numA2*$N - 1;
    print $tmp/2;
  } else {
    # even
    my $tmp = $numA2*$N;
    print $tmp/2;
  }
  exit 0;
}
my $oddflag = 0;
my $s = $A[0];
my $e = $A[$numA];
if ( $s eq $e ) {
    my $numS = 0;
    foreach my $w (@A){
        if ( $s eq $w ) {
          $numS++;
        } else {
          last;
        }
    }
    foreach my $w (reverse @A){
        if ( $s eq $w ) {
          $numS++;
        } else {
          last;
        }
    }
    if ( $numS % 2) {
      $oddflag = 1;
    }
}
my $i = 0;
my $b = '';
my $num = 0;
my $lastflag = 0;
foreach my $w (@A){
    if ( $i == 0 ) {
      $s = $w;
      $b = $w;
    } else {
      if ( $b eq $w ) {
        $num++;
        $b = '';
      } elsif ( $i == $numA and $s eq $w and $oddflag ) {
      } elsif ( $i == $numA and $s eq $w ) {
        $num++;
        $lastflag = 1;
      } else {
        $b = $w;
      }
    }
    $i++
}
if ( $i == 1 ) {
  print $N-1;
} else {
  my $v = $num*$N;
  $v-- if ($lastflag);
  print $v;
}

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

const int maxn = 1e6 + 10;

string s[maxn];
int last[30];
int child[maxn][27], cnt[maxn][27];
int newint = 2;

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s[i];
		reverse(s[i].begin(), s[i].end());
	}
	sort(s, s+n, [](string a, string b){ return a.size() < b.size(); });
	ll answer = 0;
	for (int i = 0; i < n; i++){
		int m = s[i].size();
		memset(last, -1, sizeof last);
		for (int j = 0; j < m; j++){
			int c = (int)(s[i][j] - 'a');
			last[c] = j;
		}
		int now = 1;
		for (int j = 0; j < m-1; j++){
			for (int c = 0; c < 26; c++)
				if (last[c] >= j)
					answer += cnt[now][c];
			int c = (int)(s[i][j] - 'a');
			if (child[now][c] == 0)
				child[now][c] = newint ++;
			now = child[now][c];
		}
		cnt[now][(int)(s[i].back() - 'a')] ++;
	}
	cout << answer << endl;
}


Measured memory_bytes: 189876
#include<iostream>
using namespace std;
#define MAXN 200005

int n, a[MAXN], cnt[MAXN];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }
    long long cur, total=0;
    for(int i=1;i<=n;i++){
    	cur=cnt[i];
    	total+=cur*(cur-1)/2;
	}
    for(int i=1;i<=n;i++){
        cur=cnt[a[i]];
        long long ans=total-cur*(cur-1)/2+(cur-1)*(cur-2)/2;
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3712
D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]
T = [int(input()) for _ in range(D)]
ans = 0
L = [0]*26
for i in range(D):
    ans += S[i][T[i]-1]
    L[T[i]-1] = i+1
    for j in range(26):
        ans -= C[j]*(i+1-L[j])
    print(ans)

Measured memory_bytes: 68520
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,less<int> > q;
const int N=3e6+10;
const int mod=1e9+7;
string s,t;
int main()
{
	cin>>s;
	cin>>t;
	int sum=0;
	for(int i=0;i<3;i++)if(s[i]==t[i])sum++;
	cout<<sum<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> v;
  vector<int> w;

  int i = 0;
  while (i * 4 <= 100) {
    v.push_back(i * 4);
    i++;
  }
  i = 0;
  while (i * 7 <= 100) {
    w.push_back(i * 7);
    i++;
  }

  string ans = "No";
  for (auto x : v) {
    for (auto y : w) {
      if (x + y == n) {
        ans = "Yes";
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MP make_pair
using namespace std;
typedef long double ld;
ld px[201],py[201],pz[201];
ld vx[201],vy[201],vz[201];
ld r[201],vr[201];
ld lim[201];
ld d[201][201];

ld dist(int i,int j, ld t){
    ld tmp = 0;
    tmp += (px[i]+vx[i]*t-(px[j]+vx[j]*t))*(px[i]+vx[i]*t-(px[j]+vx[j]*t));
    tmp += (py[i]+vy[i]*t-(py[j]+vy[j]*t))*(py[i]+vy[i]*t-(py[j]+vy[j]*t)); 
    tmp += (pz[i]+vz[i]*t-(pz[j]+vz[j]*t))*(pz[i]+vz[i]*t-(pz[j]+vz[j]*t));
    tmp = sqrt(tmp);
    tmp -= r[i]-vr[i]*t;
    tmp -= r[j]-vr[j]*t;
    // if(i==1&&j==0)cerr << i << " " << j << " " << t << " " << tmp << endl;
    return tmp;
}


ld calc(int i,int j){
    ld T = min(lim[i],lim[j]);
    ld x = 0,y = T;
    // cerr << dist(i,j,x) << " " << dist(i,j,y) << endl;
    rep(s,60){
        ld X = (x*2.0+y)/3.0;
        ld Y = (x+y*2.0)/3.0;
        if(dist(i,j,X)>dist(i,j,Y)){
            x = X;
        }else{
            y = Y;
        }
    }
    if(dist(i,j,x)<=0){
        // cerr << x << endl;
        ld ok = x;
        ld ng = 0;
        rep(s,60){
            ld mid = (ok+ng)/2.0;
            if(dist(i,j,mid)<=0){
                ok = mid;
            }else{
                ng = mid;
            }
        }
        return ok;
    }
    return 1000000000;
}

int main(){
    int n;
    while(cin >> n &&n!=0){
        rep(i,n){
            cin >> px[i] >> py[i] >> pz[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i];
            lim[i] = r[i]/vr[i];
        }
        rep(i,n){
            rep(j,n)d[i][j] = (1000000000.0);
        }
        priority_queue<pair<ld,pair<int,int> >,vector<pair<ld,pair<int,int> >>,greater<pair<ld,pair<int,int> >> > pq;
        rep(i,n){
            rep(j,i){
                d[i][j] = calc(i,j);
                if(d[i][j]<1000000.0){
                    pq.push(MP(d[i][j],MP(i,j)));
                    // cerr << i << " " << j << " " << d[i][j] << endl;
                }
            }
        }
        bool flag[201]={};
        ld res[201]={};
        while(!pq.empty()){
            auto x = pq.top();
            pq.pop();
            if(flag[x.second.first]||flag[x.second.second])continue;
            flag[x.second.first] = 1;
            flag[x.second.second] = 1;
            res[x.second.first] = x.first;
            res[x.second.second] = x.first;
        }
        cout.precision(16);
        rep(i,n){
            if(flag[i]){
                cout << fixed  << res[i] << "\n";
            }else{
                cout << fixed << lim[i] << "\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3948
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    LL n;
    LL k;
    cin >> n >> k;
    vector<LL> a(n);
    for(LL i=0; i<n; i++){
        cin >> a[i];
    }

    for(LL i=k; i<n; i++){
        if(a[i]>a[i-k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  VLL a(m), b(m);

  VVLL c(m);
  set<int> st;
  rep(i, m) {
    cin >> a[i] >> b[i];
    rep(j, b[i]) {
      ll cc;
      cin >> cc;
      cc--;
      st.insert(cc);
      c[i].push_back(cc);
    }
  }

  if(st.size() != n) {
    cout << -1 << endl;
    return 0;
  }

  VVLL dp(m + 1, VLL(1ll << n, ll(1e10)));
  dp[0][0] = 0;
  rep(i, m) {
    rep(j, (1ll << n)) {
      ll tmp = j;
      for(ll x : c[i]) {
        tmp |= (1ll << x);
      }

      chmin(dp[i + 1][tmp], a[i] + dp[i][j]);

      chmin(dp[i + 1][j], dp[i][j]);
    }
  }
  // rep(i, m) {
  //   rep(j, 1ll << n) { cout << dp[i][j] << " "; }
  //   cout << endl;
  // }
  cout << dp[m][(1ll << n) - 1] << endl;
  return 0;
}


Measured memory_bytes: 32512
/*
候補者は2人

第1段階 有権者の過半数の票を得た候補者がその選挙区の勝者
第k段階の選挙区の勝者は，この選挙区に含まれる第k − 1段階の選挙区のうち過半数で勝った候補者
最終段階 選挙区は一つ
*/

// [l, r]
// 一番下の選挙区の場合 → その選挙区の人数の過半数
// 中間の選挙区の場合 → 下の選挙区で
// [[....][...][...],...,[....]]
// ↑                           ↑
// l                           r
// [ ← -1, ] ← +1 として、levelっている変数に加算
// vector<int> Nums;    ← 子の選挙区で勝ち取るのに必要な最小得票数
// int left = l+1, int right = l + 1
// while(right++ <= r) 
//      if(input[right] == ']') 
//          Nums.push_back(rec(left, right))
//          left = right+1
// 

#include<bits/stdc++.h>
using namespace std;

string input;

int rec(int l, int r){
 

    if(input[l+1] == '['){ //中間の選挙区
        vector<int> Nums;
        int Left = l+1;
        int level = 0;
        for(int i = Left; i < r; ++i) {
            if(input[i] == '[') --level;
            else if(input[i] == ']') ++level;
            if(level == 0) {
                // [Left, i]
                Nums.push_back(rec(Left, i));
                // Leftを更新
                Left = i+1;
            }
        }
        sort(Nums.begin(), Nums.end());
        // 小さい得票で勝ち取れる選挙区から過半数ぶんだけ取る。
        int min_vote = 0;
        for(int i = 0; i < Nums.size()/2 + 1; ++i) {
            min_vote += Nums[i];
        }
        return min_vote;
    }else{ //一番下の選挙区
        //[l+1, r-1]の数字/2+1
        string Num = input.substr(l+1, r-1 - (l+1) + 1);
        return stoi(Num)/2 + 1;
    }

}


int main(){
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        cin >> input;
        cout << rec(0, input.size() - 1) << "\n";
    }
}



Measured memory_bytes: 3248
n,p = map(int,input().split())
A = list(map(int,input().split()))

even = sum([a%2==0 for a in A])
odd = n - even

def nCr(n,r):
  ret = 1
  for i in range(r):
    ret *= n-i
    ret //= i+1  
  return ret
  
ans = 0
add = 2 ** even
for k in range(p,odd+1,2):  
  ans += nCr(odd,k) * add  
  
print(ans)  

Measured memory_bytes: 3064
#include<functional>
#include<iostream>
#include<string.h>
using namespace std;
int main(){
  int i;
  char s[100];
  cin>>s;
  for(i=0;s[i]!='\0';i++){
  	s[i] = 'x';
  }
  cout<<s;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <map>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll x,y;

int main()
{
    scanf("%lld%lld",&x,&y);
    int ans=0;
    while (x<=y) {
        ans++;
        x*=2;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int a[1000][1000];
vector<int> e[1000000];
bool saw[1000000];
int cost[1000000];

bool dfs (int v) {
    saw[v] = true;
    int cnt = 0;
    rep(i,e[v].size()) {
        if (saw[e[v][i]] && cost[e[v][i]] == -1) {
            return false;
        }
        if (saw[e[v][i]]) {
            cnt = max(cnt, cost[e[v][i]]);
            continue;
        }
        if (!dfs(e[v][i])) return false;
        cnt = max(cnt, cost[e[v][i]]);
    }
    cost[v] = cnt+1;
    return true;
}

int main() {
    memset(cost, -1, sizeof(cost));
    cin >> n;
    rep(i,n) {
        rep(j,n-1) cin >> a[i][j];
        rep(j,n-1) a[i][j]--;
        for (int j = 1; j < n-1; j++) {
            pi x = pi(i, a[i][j-1]);
            pi y = pi(i, a[i][j]);
            if (x.second < x.first) swap(x.first, x.second);
            if (y.second < y.first) swap(y.first, y.second);
            e[x.first*1000+x.second].push_back(y.first*1000+y.second);
        }
    }
    rep(j,n) {
        for (int k = j+1; k < n; k++) {
            int id = j*1000+k;
            if (saw[id]) continue;
            if (!dfs(id)) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    int ans = 0;
    rep(j,n) {
        for (int k = j+1; k < n; k++) {
            int id = j*1000+k;
            ans = max(ans, cost[id]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 48256
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){
	int k;
	cin>>k;
	
	if(k%2==0 or k%5==0){
		cout<<-1<<endl;
		return 0;
	}
	
	int ans=0;
	llong num=0LL;
	while(1){
		ans++;
		num=(10*num+7)%k;
		if(num==0){
			cout<<ans<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3584
#include <iostream>
#include <array>

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

    long int n;

    while (std::cin >> n, n++) {
        long int age;
        std::array<long int, 7> arr{{}};

        for (; --n;) {
            std::cin >> age;
            age = (age < 70 ? age : 60);
            ++arr[age / 10];
        }
        
        for (const auto& cnt : arr) {
            std::cout << cnt << std::endl;
        }
    }

    return 0;
}

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

using namespace std;

int main()
{
   ios::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int n;
   cin >> n;
   set<string>s;
   for (int i = 0; i < n; i++)
   {
       string str;
       cin >> str;
       s.insert(str);

   }
   cout << s.size();
}


Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
int main(){
    long a,b;
    cin >> a >> b;
    if(a*b<=0){
        cout << "Zero" << endl;
    }else{
        if((a>0)&&(b>0)){
            cout << "Positive" << endl;
        }else{
            long diff = b - a;
            if(diff%2==1){
                cout << "Positive" << endl;
            }else{
                cout << "Negative" << endl;
            }
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;


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

int main(void) {
    string S, T;
    ll N, M, g, l;
    cin >> N >> M >> S >> T;
    g = gcd(N, M);
    l = N * M / g;

    for (int i = 0; i < g; ++i) {
        if (S[i * N / g] != T[i * M / g]) {
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << l << endl;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    char str[64];
    int count[4];
    for(int i=0;i<4;i++) count[i]=0;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> str;
        if(str[0]=='A'){
            count[0]++;
        }else if(str[0]=='W'){
            count[1]++;
        }else if(str[0]=='T'){
            count[2]++;
        }else if(str[0]=='R'){
            count[3]++;
        }
    }
    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3] << endl;
    
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  
  double ans;
  for(int i = 1; i < n + 1; i++){
    double pro = 1.0 / n;
    int now = i;
    while(now < k){
      pro /= 2;
      now *= 2;
    }
    ans += pro;
  }
  
  cout << fixed << setprecision(10) << ans << endl;
}

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

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

int main(){

    int N;
    cin>>N;
    vector<int64_t> A(N);
    int J = 0;

    rep(i,N){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    rep(i,N-1){
        if(A.at(i)==A.at(i+1)){
            J=1;
            break;
        }
    }
    if(J==1)
        cout << "NO" << endl;
    else
    {
        cout << "YES" << endl;
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int ans = 0;
    for(int i=0; i<n; i++){
        if(abs((double)a[n-1]/2 - a[i]) < abs((double)a[n-1]/2 - a[ans])){
            ans = i;
        }
    }

    cout << a[n-1] << ' ' << a[ans] << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e16;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



///////////////////////___modpow___////////////////////

////////////////////////////////////////////////////////////////////


signed main(){
  int n,a,b;cin>>n>>a>>b;
  int ans = a*(n/(a+b));
  cout << ans + min(a, n-(a+b)*(n/(a+b))) << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
    double w;
    while(cin>>w){
        if(w<=48){
            cout<<"light fly"<<endl;
        }
        else if(48<w&&w<=51){
            cout<<"fly"<<endl;
        }
        else if(51<w&&w<=54){
            cout<<"bantam"<<endl;
        }
        else if(54<w&&w<=57){
            cout<<"feather"<<endl;
        }
        else if(57<w&&w<=60){
            cout<<"light"<<endl;
        }
        else if(60<w&&w<=64){
            cout<<"light welter"<<endl;
        }
        else if(64<w&&w<=69){
            cout<<"welter"<<endl;
        }
        else if(69<w&&w<=75){
            cout<<"light middle"<<endl;
        }
        else if(75<w&&w<=81){
            cout<<"middle"<<endl;
        }
        else if(81<w&&w<=91){
            cout<<"light heavy"<<endl;
        }
        else if(91<w){
            cout<<"heavy"<<endl;}
        }
    }

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

int main() {
	int a, b;
	std::cin >> a >> b;
	
	if(a%2 == b%2){
	    std::cout << (a + b) / 2 << std::endl;
	}else{
	    std::cout << "IMPOSSIBLE" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
a=[0]
b=[0]
for i in range(100):
	a.append(i*i*i)
	b.append((i*(i-1)*(i-2))/6)

while(True):
	n=int(raw_input())
	if n==0:	break
	ans=1<<30
	for i in b:
		if i>n: break
		ans=min(ans, n-i)
	for i in a:
		if i>n:	break
		ans=min(ans, n-i)
		for j in b:
			if i+j>n:	break
			ans=min(ans, n-(i+j))
	print n-ans

Measured memory_bytes: 4240
#include <iostream>

using namespace std;

int main()
{
int a,b,su1,su2,su3,ma;
cin>>a>>b;
su1=a*b;
su2=a-b;
su3=a+b;
ma=su1;
if(ma<su2)
ma=su2;
if(ma<su3)
ma=su3;
cout<<ma;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int m=26;
int n;
vl a;
vvl b;

int main(){
	cin>>n;
	a=vl(m);
	b=vvl(n,vl(m));
	for(int i=0;i<m;i++) cin>>a[i];
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>b[i][j];
	ll res=0;
	vl c(m,-1);
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		x--;
		res+=b[i][x];
		c[x]=i;
		for(int j=0;j<m;j++) res-=a[j]*(i-c[j]);
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  string S;
  cin>>S;

  if(S[2]==S[3]&&S[4]==S[5]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    long long f = 100;
    long long X; cin >> X;
    long long res = 0;
    while(true) {
        ++res;
        f *= 1.01;
        if (f >= X) break;
    }
    cout << res << endl;
}


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

signed main() {
    string s;
    cin >> s;
    int ans = 0;
    if (s == "SUN") {
        ans = 7;
    }
    else if (s == "MON") {
        ans = 6;
    }
    else if (s == "TUE") {
        ans = 5;
    }
    else if (s == "WED") {
        ans = 4;
    }
    else if (s == "THU") {
        ans = 3;
    }
    else if (s == "FRI") {
        ans = 2;
    }
    else {
        ans = 1;
    };
    cout << ans << endl;
}

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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> a(n),b(n);
  set<long> x;
  for(long i=0;i<n;i++) {
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b.begin(),b.end());
  for(long i=0;i<n;i+=2) x.insert(b[i]);
  for(long i=1;i<n;i+=2) if(x.count(a[i])) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 7212
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int A[3];
unsigned int use[100000001];
priority_queue<int,vector<int>,greater<int> > ans;
int main()
{
  int n;
  cin >>n;
  int Min = 1e+9;
  for(int i = 0;i < n;i++){
    cin >>A[i];
    if(Min >A[i]){
      Min = A[i];
    }
  }
    if(n ==2){
      for(int i = 1;i <=Min;i++){
	  if(A[0]%i==0&&use[i]!=1&&A[1]%i==0){
	    use[i] = 1;
	    ans.push(i);
	}
      }
    }
      if(n == 3){
	for(int i = 1;i <=Min;i++){
	    if(A[0]%i==0&&use[i]!=1&&A[1]%i==0&&A[2]%i==0){
	      use[i] = 1;
	      ans.push(i);
	    }
	}
      }
      while(!ans.empty()){
	cout <<ans.top()<<endl;
	ans.pop();
      }
  return 0;
}

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

int parse(int P, int Q, int R, std::string &str) 
{
	switch(str[0]) {
		case '0':
			str.erase(0, 1);
			return 0;
			break;
		case '1':
			str.erase(0, 1);
			return 1;
			break;
		case '2':
			str.erase(0, 1);
			return 2;
			break;
		case 'P':
			str.erase(0, 1);
			return P;
			break;
		case 'Q':
			str.erase(0, 1);
			return Q;
			break;
		case 'R':
			str.erase(0, 1);
			return R;
			break;
		case '-': 
			{
				str.erase(0, 1);
				int a = parse(P, Q, R, str);
				return 2 - a;
				break;
			};
		case '(':
			{
				str.erase(0, 1);
				int a = parse(P, Q, R, str);
				if ( str[0] == '*' ) {
					str.erase(0, 1);
					int b = parse(P, Q, R, str);
					str.erase(0, 1);
					if ( a == 0 || b == 0 ) return 0;
					else if ( a == 2 && b == 2 ) return 2;
					else return 1;
				} else {
					str.erase(0, 1);
					int b = parse(P, Q, R, str);
					str.erase(0, 1);
					if ( a == 2 || b == 2 ) return 2;
					else if ( a == 0 && b == 0 ) return 0;
					else return 1;
				}
			}
	}
	return -1;
}

int main()
{
	while (true) {
		std::string str;
		std::getline(std::cin, str);
		if ( str == "." ) break;

		std::string buf;
		int count = 0;
		for ( int i = 0; i < 3; ++i ) {
			for ( int j = 0; j < 3; ++j ) {
				for ( int k = 0; k < 3; ++k ) {
					buf = str;
					if ( parse(i, j, k , buf) == 2 ) count++;
				}
			}
		}
		std::cout << count << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll X;
    cin >> X;
    ll score = 400;
    for(ll i=8;i>=1;i--){
        if(score <= X && X < score +200){
            cout << i << endl;
            return 0;
        }
        score += 200;
    }
}


Measured memory_bytes: 3620
from math import gcd
k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(i,k+1):
        for k in range(j,k+1):
            s=len(set([i,j,k]))
            if s==1:
                p=1
            elif s==2:
                p=3
            elif s==3:
                p=6
            tmp=gcd(i,j)
            tmp= p*gcd(tmp,k)
            ans+=tmp
print(ans)

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

int main() {
	int N;
	cin >> N;
	map<int, int> A;

	rep(i, N) {
		int a;
		cin >> a;
		A[a] = i;
	}

	int i = 0;
	for (auto& a : A) {
		cout << a.second + 1;
		if (i < A.size()-1)
			cout << " ";
		else
			cout << endl;
		i++;
	}
}

Measured memory_bytes: 8172
n, m = gets.chomp.split.map(&:to_i)

map = []
m.times do
    a, b = gets.chomp.split.map(&:to_i)
    map[a] = map[a] || []
    map[a] << b
    map[b] = map[b] || []
    map[b] << a
end

dp = []
dp[1] = 1

queue = Queue.new
queue << 1

loop do
    break if queue.empty?
    a = queue.pop
    bs = map[a]
    bs.each do |b|
        if dp[b].nil?
            dp[b] = a
            queue << b
        end
    end
end

result = dp[(2..n)]

if result.include?(nil)
    puts 'No'
else
    puts 'Yes'
    result.each do |r|
        puts r
    end
end


Measured memory_bytes: 31660
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


int main()
{
string n;
cin>>n;
int ans=0;
rep(i,n.length())
{
if(n[i]=='1')ans+=1;
if(n[i]=='2')ans+=2;
if(n[i]=='3')ans+=3;
if(n[i]=='4')ans+=4;
if(n[i]=='5')ans+=5;
if(n[i]=='6')ans+=6;
if(n[i]=='7')ans+=7;
if(n[i]=='8')ans+=8;
ans=ans%9;
}
if(ans==0)cout <<"Yes";
else cout <<"No";

    
}

Measured memory_bytes: 3756
using System;

namespace ConsoleApp__ITP1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            var a = Int32.Parse(input[0]);
            var b = Int32.Parse(input[1]);
            var c = Int32.Parse(input[2]);

            if(a < b & b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

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

fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    let mut a: Vec<T> = vec![];
    for _ in 0..n {
        a.push(read());
    }
    a
}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let x: i64 = read();

    let l: Vec<i64> = read_n(n);
    // println!("l:{:?}", l);

    let mut sum = 0;
    let mut cnt = 1;

    for i in l {
        sum += i;
        if sum <= x {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2156
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>


#define rep(i,n) for(int i = 0; i < n; i++)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second

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


ll bits[64];

int main(void){
    int n;
    vector<ll> a;
    vector<ll> b;

    cin >> n;
    a.resize(n);
    b.resize(n);
    for(auto &e: a)cin >> e;
    for(auto &e: b)cin >> e;
    sort(all(b));
    ll T = 1, p = 2;
    rep(bit, 31){
        vector<ll> bp = b;
        rep(i, n)bp[i]%=p;
        sort(all(bp));
//         cout << "-------- " << bit << endl; 
//         rep(i,n) cout << bp[i] << " ,";
//         cout << endl;
        rep(j, n){
            ll ap = a[j]%p;

            // [p-ap, 2*p-ap), [3*p-ap, 4*p-ap)内のbpの数が偶数or奇数
//             cout << "---- " << ap  << " " << T << " " << 1*T-ap << " " << 2*T-ap << " " << 3*T-ap << " " << 4*T-ap<< endl;
//             cout << (lower_bound(bp.begin(), bp.end(), 2*T-ap)-bp.begin()) << " - " << (lower_bound(bp.begin(), bp.end(), 1*T-ap)-bp.begin()) << endl;
//             cout << (lower_bound(bp.begin(), bp.end(), 4*T-ap)-bp.begin()) << " - " << (lower_bound(bp.begin(), bp.end(), 3*T-ap)-bp.begin()) << endl;
            ll cnt = (lower_bound(bp.begin(), bp.end(), 2*T-ap)-bp.begin()) - (lower_bound(bp.begin(), bp.end(), 1*T-ap)-bp.begin());
            cnt += (lower_bound(bp.begin(), bp.end(), 4*T-ap)-bp.begin()) - (lower_bound(bp.begin(), bp.end(), 3*T-ap)-bp.begin());
            bits[bit]+=cnt;
        }
        T*=2;
        p*=2;
    }

    ll ans = 0;
    ll z = 1;
    rep(i, 32){
        if(bits[i]%2==1) ans += z;
        z*=2;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4992
<?php
  list($n, $k) = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  for ($h=0; $h<$k; $h++) {
    $x = array_fill(0, $n+1, 0);
    for ($i=0; $i<$n; $i++) {
      $l = max($i-$a[$i], 0);
      $r = min($i+$a[$i]+1, $n);
      $x[$l]++;
      $x[$r]--;
    }
    $a[0]=$x[0];
    $a_back = $a;
    for ($i=1; $i<$n; $i++) {
      $a[$i]=$a[$i-1]+$x[$i];
    }
    $sa = array_diff($a_back, $a);
    if(count($sa) == 0){
      break;
    }
  }

  echo implode(" ", $a);

Measured memory_bytes: 58604
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    int foo[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<foo[in()-1]<<endl;
}


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

ll gcd(ll x, ll y) {
  return y ? gcd(y, x%y) : x;
}

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n%i) continue; //割り切れないならcontinue
    res.emplace_back(i, 0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  ll ans = factorize(g).size() + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int v[N], vis[N];
vector<int> g[N];

void dfs(int n) {
    vis[n] = 1;
    for (auto i : g[n]) {
        if (vis[i]) continue;
        v[i] += v[n];
        dfs(i);
    }
}

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++) {
        int a, b ;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    while (q--) {
        int p, x;
        cin >> p >> x;
        v[p] += x;
    }
    dfs(1);
    for (int i = 1; i <= n; i++)
        cout << v[i] << " ";
    return 0;
}

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

int main(){
 string s;
 cin>>s;
 if(s=="SUN"){
     cout<<7<<endl;
 }else if(s=="MON"){
   cout<<6<<endl;
 }else if(s=="TUE"){
   cout<<5<<endl;
 }else if(s=="WED"){
   cout<<4<<endl;
 }else if(s=="THU"){
   cout<<3<<endl;
 }else if(s=="FRI"){
   cout<<2<<endl;
 }else{
   cout<<1<<endl;
 }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        char[] s = sc.next().toCharArray();
        int n = s.length;
        
        int[] a = new int[n+1];
        for(int i=0; i<n; i++){
            if(s[i]=='<'){
                a[i+1] = a[i]+1;
            }
        }
        for(int i=n; i>=1; i--){
            if(s[i-1]=='>' && a[i-1]<a[i]+1){
                a[i-1] = a[i]+1;
            }
        }
        
        long ans = 0;
        for(int i=0; i<n+1; i++){
            ans += a[i];
        }
        System.out.println(ans);
    }
}


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

using namespace std;


const int Nmax = 2e5 + 5, lim = 2e5;
typedef long long ll;

namespace
{
    const int Mod = 1e9 + 7;
    int fact[Nmax], ifact[Nmax], itwo[Nmax], inv[Nmax];

    static void add_to(int &x, int y) { x+=y; if(x>=Mod) x-=Mod; }
    static int inm(int x, int y) { return (ll) x * y % Mod; }
    static int inm(int x, int y, int z) { return (ll) x * y % Mod * z % Mod; }

    static int power(int a, int b)
    {
        int ans = 1;
        while(b)
        {
            if(b&1) ans = inm(ans, a);
            a = inm(a, a); b >>= 1;
        }
        return ans;
    }

    static void prec(int lim)
    {
        int i;

        fact[0] = ifact[0] = 1;
        for(i=1; i<=lim; ++i) fact[i] = inm(fact[i-1], i);

        ifact[lim] = power(fact[lim], Mod-2);
        for(i=lim-1; i; --i) ifact[i] = inm(ifact[i+1], i+1);

        itwo[0] = 1;
        itwo[1] = ifact[2];
        for(i=2; i<=lim; ++i) itwo[i] = inm(itwo[i-1], itwo[1]);

        for(i=1; i<=lim; ++i)
            inv[i] = inm(ifact[i], fact[i-1]);
    }

    static int comb(int n, int k)
    {
        assert(k>=0 && k<=n);
        return inm(fact[n], ifact[k], ifact[n-k]);
    }

    static int prob(int a, int b)
    {
        assert(a >= b);
        if(!b) return 0;
        return inm(b, inv[a]);
    }
}


int p1[Nmax], p2[Nmax], delta[Nmax];
int B, W, i;

static void add(int p, int x, int y)
{
    add_to(delta[x], p);
    add_to(delta[y+1], Mod-p);
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);
    cin.tie(0);

    prec(lim);

    cin >> B >> W;

    for(i=W; i<B+W; ++i) p1[i] = inm(itwo[i], comb(i-1, W-1));
    for(i=B; i<B+W; ++i) p2[i] = inm(itwo[i], comb(i-1, B-1));

    for(i=W; i<B+W; ++i)
    {
        add(p1[i], i+1, B+W);
        add(inm(p1[i], prob(i-1, i-W)), 1, i-1);
    }

    for(i=B; i<B+W; ++i)
    {
        add(p2[i], i, i);
        add(inm(p2[i], prob(i-1, B-1)), 1, i-1);
    }

    int ans = 0;
    for(i=1; i<=B+W; ++i)
    {
        add_to(ans, delta[i]);
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 6528