akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	llint ans = 0, n = 0, m=1, count=0, sum = 0, ch = 0;
	llint  a, aa, aaa, rr = 0, gg = 0, bb = 0,b=0;
	llint bbb=0, bbbb=0;
	bool check = false;
	string s,out;
	vector<llint> r, g;
	char c;
	
	rep(i, 6) {
		cin >> a;
		if (a == 1)b++;
		else if (a == 2)bb++;
		else if (a == 3)bbb++;
		else bbbb++;
	}
	if (b <= 2 && bb <= 2 && bbb <= 2 && bbbb <= 2)cout << "YES" << endl;
	else cout <<"NO"<< endl;
	
	please AC;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, P: int):
    print((3*A+P)//2)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(A, P)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]

N,M,Q = Is()
lis = [[0]*(N+1) for _ in range(N+1)]
for i in range(M):
    l,r = Is()
    lis[l][r] += 1

cs = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,N+1):
        cs[i][j] = cs[i][j-1] + lis[i][j]

for _ in range(Q): 
    p,q = Is()
    t = 0
    for i in range(p,q+1):
        t += cs[i][q] - cs[i][i-1]
    print(t)

Measured memory_bytes: 61788
import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
mod=int(1e9+7)
ans=0
for k in range(60):
  b=(a>>k)&1
  m=np.count_nonzero(b)
  ans+=m*(n-m)*2**k
  ans%=mod
print(ans)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

vector<ll> prime_fact(ll a){
    ll i = 2;
    vector<ll> rel;
    for(ll d = 2; d*d <= a; d++){
        if(a % d != 0) continue;
        rel.emplace_back(d);
        while(a % d == 0){
            a /= d;
        }
    }
    if(a != 1) rel.emplace_back(a);
    return rel;
}

int main() {
    int n; cin >> n;
    vector<int> pf(n+1);
    for(int i = 2; i <= n; i++){
        int a = i;
        for(int d = 2; d*d <= a; d++){
            if(a % d != 0) continue;
            while(a % d == 0){
                 a /= d;
                 pf[d]++;
            }
        }
        if(a != 1) pf[a]++;
    }
    ll ans = 1;
    for(int i = 2; i <= n; i++){
        if(pf[i] == 0) continue;
        ans = ((ans % MOD) * ((ll)pf[i] + 1)) % MOD;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    int n,m;
    int[][] dc, dt;
    int[][] cost, time;
    int INF = 100000000;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            if(n==0 && m==0) break;

            cost = new int[m][m];
            time = new int[m][m];
            for(int i=0; i<m; i++){
                Arrays.fill(cost[i], INF);
                Arrays.fill(time[i], INF);
            }
            for(int i=0; i<n; i++){
                int a = sc.nextInt()-1, b = sc.nextInt()-1;
                int c = sc.nextInt(), t = sc.nextInt();
                cost[a][b] = c; cost[b][a] = c;
                time[a][b] = t; time[b][a] = t;
            }

            dc = warshall_floyd(cost);
            dt = warshall_floyd(time);

            int k = sc.nextInt();
            for(int i=0; i<k; i++){
                int p = sc.nextInt()-1, q = sc.nextInt()-1;
                int r = sc.nextInt();
                if(r==0) System.out.println(dc[p][q]);
                if(r==1) System.out.println(dt[p][q]);
            }
        }
    }

    int[][] warshall_floyd(int[][] dd){

        for(int k=0; k<m; k++){
            for(int i=0; i<m; i++){
                for(int j=0; j<m; j++){
                    dd[i][j] = Math.min(dd[i][j], dd[i][k]+dd[k][j]);
                }
            }
        }
        return dd;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

using namespace std;

int main() {
	int N, sum;
	bool re=false;
	cin >> N;
	for (int i = 0; i < N/4+1; i++) {
		for (int j = 0; j < N/7+1; j++) {
			sum = i * 4 + j * 7;
			if (sum == N) re=true;
		}
	}
	if(re) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long ans = 0;
        for(int dx=0;dx<=s.length()-1;dx++){
            for(int start=0;start<=s.length()-1-dx;start++){
                long cur = Long.parseLong(s.substring(start,start+dx+1));
                ans += cur*(helper(start)*helper(s.length()-1-dx-start));
            }
        }
        System.out.println(ans);
    }
    static long helper(int n){
        if(n==0) return 1;
        return 1<<(n-1);
    }
}


Measured memory_bytes: 23380
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))

div_num = 10 ** 9 + 7
sum_rest = sum(A_list)
ans = 0
for i in range(N):
    sum_rest -= A_list[i]
    ans = (ans + A_list[i] * sum_rest) % div_num

print(ans)

Measured memory_bytes: 31428
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n; cin >> n;
		vector<int> x(n), y(n);
		rep (i, n) {
			cin >> x[i] >> y[i];
		}
		auto dist = [&](int i, int j) {
			double dx = x[i] - x[j];
			double dy = y[i] - y[j];
			return sqrt((dx * dx)+ (dy * dy));
		};
		double len = 0;
		rep (i, n) {
			rep (j, i) {
				len += dist(i, j);
			}
		}
		int num = 2;
		for (int i = n - 1; i >= 1; --i) {
			num *= i;
		}
		int fact = 1;
		for (int i = n; i >= 1; --i) {
			fact *= i;
		}
		double ans = (len * num) / fact;
		printf("%0.10f\n", ans);
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int n;
  cin >> n;
  vector<int> mochi(n);
  
  rep(i, n){cin >> mochi.at(i);}
  //bool flag=false;
  int count=0;
  rep(i, n){
    //cout << i << endl;
    //cout << endl;
    if(mochi.at(i) == 0){}
    else{
    for(int j=1; i+j<n; j++){
      //cout << j << endl;
      if(mochi.at(i) == mochi.at(i+j)){
        //flag=true;
        mochi.at(i+j) = 0;
      }
    }
    //if(flag){
      count++;
      //flag=false;
    //}
    }
  }
  cout << count << endl;
  return 0;
}


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

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

    map<string, int> ana_map{};
    for (int i = 0; i < n; ++i){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ana_map[s] += 1;
    }

    ll res = 0;

    auto begin = ana_map.begin(), end = ana_map.end();
    for (auto iter = begin; iter != end; iter++) {
        ll value = iter->second;
        res += value*(value-1)/2;
    }
    cout << res << endl;
}

Measured memory_bytes: 11264
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N,X,T;
  cin>>N>>X>>T;
  int answer=0;
  int num=0;
  while(num<N){
    num+=X;
    answer+=T;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3148
def abc137c_green_bin():
    def cmb(n, r):
        """ nCrの組み合わせ数を返す """
        if n - r < r: r = n - r
        if r == 0: return 1
        if r == 1: return n

        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]

        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot

        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])

        return result
    n = int(input())
    dict_s = {}
    for _ in range(n):
        s = ''.join(sorted(input()))
        if s in dict_s.keys():
            dict_s[s] += 1
        else:
            dict_s[s] = 1
    result = 0
    for k in dict_s:
        if dict_s[k] != 1:
            result += cmb(dict_s[k], 2)
    print(result)
abc137c_green_bin()

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n-1) cout << a[i]<< " ";
  cout << a[n-1] << endl;
  for(int i=1;i<n;i++){
    int v,j;
    v = a[i];
    j = i - 1;
    while(j>=0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

    rep(i,n-1) cout << a[i]<< " ";
    cout << a[n-1] << endl;
  }
}



Measured memory_bytes: 3104
#include <stdio.h>
int main(void){
  char s[10];
  int a=700;
  scanf("%s",s);
  if(s[0]=='o'){a=a+100;}
    if(s[1]=='o'){a=a+100;}
    if(s[2]=='o'){a=a+100;}
  printf("%d",a);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, w, t, v[10], p[10];
int x[10], y[10], l[10], r[10][10], q[10][10];
int d[1 << 10][10];
ll dp2[10001];
string s[10];
map<string, int> id;

int main(){
	cin >> n >> m >> w >> t;
	rep(i, m){
		cin >> s[i] >> v[i] >> p[i];
		id[s[i]] = i;
	}
	rep(i, n){
		cin >> l[i] >> x[i] >> y[i];
		rep(j, l[i]){
			string a;
			cin >> a >> q[i][j];
			r[i][j] = id[a];
		}
	}
	rep(i, 1 << n + 1) rep(j, n + 1) d[i][j] = inf;
	d[0][n] = 0;
	rep(i, 1 << n + 1) rep(j, n + 1) if(d[i][j] < inf) rep(k, n + 1) if(!(i & 1 << k)){
		d[i | 1 << k][k] = min(d[i | 1 << k][k], d[i][j] + abs(x[j] - x[k]) + abs(y[j] - y[k]));
	}
	vector<pi> it;
	rep(i, 1 << n){
		static ll dp[10001];
		rep(j, w + 1) dp[j] = 0;
		rep(j, n) if(i & 1 << j) rep(k, l[j]) rep(h, w) if(h + v[r[j][k]] <= w){
			dp[h + v[r[j][k]]] = max(dp[h + v[r[j][k]]], dp[h] - q[j][k] + p[r[j][k]]);
		}
		it.pb(mp(d[i | 1 << n][n], dp[w]));
	}
	rep(i, t) rep(j, it.size()) if(i + it[j].first <= t)
	dp2[i + it[j].first] = max(dp2[i + it[j].first], dp2[i] + it[j].second);
	
	cout << dp2[t] << endl;
	return 0;
}

Measured memory_bytes: 1392
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll x[110];
    rep(i,0,N) cin >> x[i];
    ll ans = 0;
    rep(i,0,N){
        ans += min(x[i]*2, (K-x[i])*2);
    }
    print(ans);

}

Measured memory_bytes: 256
d,n = map(int, input().split())


if d==0:
        if n==100:
                print(101)
        else:
                print(n)

elif d==1:
        if n==100:
                print(10100)
        else:
                print(100*n)
else:
        if n==100:
                print(1010000)
        else:
                print(10000*n)

Measured memory_bytes: 3060
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    int t, a; cin >> t >> a;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }

    double mini = 1e9 + 1.0;
    int ans = 0;
    rep(i, n) {
        double temperature = t - h[i] * 0.006;
        if (mini > abs(temperature - a)) {
            mini = abs(temperature - a);
            ans = i + 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace Atcoder.Abc
{
    //https://atcoder.jp/contests/abc174/tasks/abc174_a
    public class Abc174_A
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var X = int.Parse(ReadLine());
            WriteLine(X >= 30 ? "Yes" : "No");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 17520
import java.util.Scanner;

public class Main{

	/*
	 * A??§??? ??????????????????????????????????£? ??\????±????????????±?????????????????§?????°?????????
	 *
	 * ??????????????± ??¢?£? ?????? ????????? ??¶?????°
	 *
	 * ????£???????????????????????????????????????????????????\?±??????°????????????????????? ?????????????????????????????????????????????????????????????????????????????¨?±??????\?±??????°??????????????????????????????
	 * ??\?±??????°?????????????????????????????????????????????????????? ????£????????????? #################### (20?????? # )
	 */
	public static void main(String[] args) {

		// ??????????????????????????????????£?
		int[][][] hoUse = new int[4][3][10];

		// ??????????????±
		// ??¢?£? ?????? ????????? ??¶?????°
		int building, floor, room, people;

		Scanner scAner = new Scanner(System.in);
		int info = scAner.nextInt();

		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 3; j++)
				for (int k = 0; k < 10; k++)
					hoUse[i][j][k] = 0;

		for (int i = 0; i < info; i++) {
			// ex 3
			// 1 1 3 8
			// 3 2 2 7
			// 4 3 8 1
			building = scAner.nextInt();
			floor = scAner.nextInt();
			room = scAner.nextInt();
			people = scAner.nextInt();

			hoUse[building - 1][floor - 1][room - 1] += people;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 10; k++) {
					System.out.print(" " + hoUse[i][j][k]);
				}
				System.out.println("");
			}
			if (i < 3)
				System.out.println("####################");
		}
	}
}

Measured memory_bytes: 29700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        
        String N = br.readLine();
        String target = N.substring(N.length() - 1);
        
        if("2".equals(target) || "4".equals(target) || "5".equals(target) || "7".equals(target) || "9".equals(target)) {
            pw.println("hon");
        } else if("0".equals(target) || "1".equals(target) || "6".equals(target) || "8".equals(target)) {
            pw.println("pon");
        } else {
            pw.println("bon");
        }

        br.close();
        pw.close();
    }
}

Measured memory_bytes: 32520
S=input()
n=len(S)
ans=0
for i in range(2**(n-1)):
  s=0
  c=int(S[0])
  for j in range(n-1):
    if (i>>j) & 1:
      s+=c
      c=int(S[j+1])
    else:
      c*=10
      c+=int(S[j+1])
  ans+=s+c
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n, ok, a[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
	}
	for(int i=1;i<=n;i++){
		if(a[i]-1>=a[i-1]) a[i]--;
		if(i!=n&&a[i]>a[i+1]) {
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 640
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    uinp = input()
    if uinp == "AC":
        AC += 1
    elif uinp == "WA":
        WA += 1
    elif uinp == "TLE":
        TLE += 1
    elif uinp == "RE":
        RE += 1
print(f"AC x {AC}")
print(f"WA x {WA}")
print(f"TLE x {TLE}")
print(f"RE x {RE}")


Measured memory_bytes: 9192
def main():
    N = int(input())
    lst = list(map(int, input().split()))
    groups = [lst]
    ans = 0

    while len(groups) != 0:
        #print('------')
        targetgroup = groups.pop()

        minval = min(targetgroup)
        targetgroup = [v - minval for v in targetgroup]
        ans += minval
        #print(targetgroup)

        tmp = []
        for index, v in enumerate(targetgroup):
            if v != 0:
                tmp.append(v)
            if (v==0 or index==len(targetgroup)-1) and (len(tmp) != 0):
                groups.append(tmp)
                tmp = []
        #print(groups)
    print(ans)
main()

Measured memory_bytes: 39664
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, m;
  cin >> n >> m;
  int v, s = 0;
  for (int i = 0; i < m; i++) {
    cin >> v;
    s += v;
  }
  cout << max(-1, n - s) << endl;

  return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for(int i = 0; i < m; i++)
  {
    cin >> x[i];
  }
  if (n >= m)
  {
    cout << 0 << endl;
    return 0;
  }
  sort(x.begin(), x.end());
  vector<int> dis(m-1);
  for(int i = 0; i < m-1; i++)
  {
    dis[i] = x[i+1] - x[i];
  }
  sort(dis.begin(), dis.end());
  int sum = 0;
  if (n == 1)
  {
    for(int i = 0; i < m-1; i++)
    {
      sum += dis[i];
    }
    cout << sum << endl;
    return 0;
  }
    
  for(int i = 0; i < m - n; i++)
  {
    sum += dis[i];
  }
  cout << sum << endl;
}


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

bool a[1000001];
int main(){
    int s; cin >> s;
    int i = 0;
    for(;; i++){
        if(i){
            if(s%2) s = 3 * s + 1;
            else s /= 2;
        }
        if(a[s]) break;
        else a[s] = true;
    }
    cout << i + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll h,w;
  cin >> h >> w;
  vector<char> a(h*w);
  vl cnt(26,0);
  rep(i,h*w){
    cin >> a[i];
    rep(j,26){
      if(abc[j]==a[i]){
        cnt[j]++;
      }
    }
  }
  bool A=true;
  ll k,x=0,y=0;
  if(h%2==0&&w%2==0){
    rep(i,26){
      if(cnt[i]%4!=0){
        A=false;
      }
    }
  }
  else if(h*w%2==0){
    if(h%2==0){
      k=h/2;
    }
    else{
      k=w/2;
    }
    rep(i,26){
      if(cnt[i]%2!=0){
        A=false;
      }
      else if(cnt[i]%4==2){
        x++;
      }
      if(x>k){
        A=false;
      }
    }
  }
  else{
    rep(i,26){
      if(cnt[i]%2==1){
        y++;
        if(cnt[i]%4==3){
          x++;
        }
      }
      if(cnt[i]%4==2){
        x++;
      }
    }
    if(y!=1){
      A=false;
    }
    else if(x>(h/2)+(w/2)){
      A=false;
    }
  }
  if(A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let s = buf.trim().chars().collect::<Vec<char>>();
    let n = s.len();
    let s1 = (0..n).map(|x| if x % 2 == 0 {'1'} else {'0'}).collect::<Vec<_>>();
    let s2 = (0..n).map(|x| if x % 2 == 0 {'0'} else {'1'}).collect::<Vec<_>>();
    let (mut c1, mut c2) = (0, 0);
    for i in 0..n {
        if s1[i] != s[i] {c1 += 1}
        if s2[i] != s[i] {c2 += 1}
    }
    let ans = min(c1, c2);
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String[] str = new String[N];
	HashSet<String> set = new HashSet<String>();
	for(int i = 0; i<N; i++) {
	    str[i] = sc.next();
	}
	for(int i = 0; i<N; i++) {
            if(i>=1 && str[i-1].charAt(str[i-1].length()-1) != str[i].charAt(0)) {
                System.out.println("No");
                return;
            }
            if(set.contains(str[i])) {
                System.out.println("No");
                return;
            }
	    set.add(str[i]);
	}
	System.out.println("Yes");
    }
}

Measured memory_bytes: 23124
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    ll n = 0;
    cin >> n;

    ll ans = 0;

    ll root = sqrt(n);

    repd(i, 1, root + 1) {
        if (n % i == 0) {
            ll temp = n / i - 1;
            if (temp == 0) {
                break;
            }
            if (n / temp == n % temp) {
                ans += temp;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long N;
    cin>>N;
    long a[N],b[N];
    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i];
    }
    vector<pair<int, int> > pairs(N);
    for(int i=0;i<N;i++){
        pairs[i] = make_pair(b[i],a[i]);
    }
    sort(pairs.begin(), pairs.end());
    int p=0;
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=pairs[i].second;
        if(sum>pairs[i].first){
            p=1;
            break;
        }
    }
    if(p==0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 4992
// Last Change: 05/16/2019 18:46:08.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> S(H + 2);
  string iptS;
  for (ll i = 1; i <= H; ++i) {
    cin >> iptS;
    iptS = "-" + iptS + "-";
    S[i] = iptS;
  }
  S[0] = S[H + 1] =
      "--------------------------------------------------------------";

  vector<vector<ll>> ans(H + 2, vector<ll>(W + 2, -1));

  for (ll i = 1; i <= H; ++i) {
    for (ll j = 1; j <= W; ++j) {
      if (S[i][j] == '.') {
        int cnt = 0;
        if (S[i - 1][j - 1] == '#')
          ++cnt;
        if (S[i - 1][j] == '#')
          ++cnt;
        if (S[i - 1][j + 1] == '#')
          ++cnt;
        if (S[i][j - 1] == '#')
          ++cnt;
        if (S[i][j + 1] == '#')
          ++cnt;
        if (S[i + 1][j - 1] == '#')
          ++cnt;
        if (S[i + 1][j] == '#')
          ++cnt;
        if (S[i + 1][j + 1] == '#')
          ++cnt;

        ans[i][j] = cnt;
      }
    }
  }

  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j) {
      if (ans[i][j] == -1) {
        cout << '#';
      } else {
        cout << ans[i][j];
      }
    }
    cout << endl;
  }

  //NS::LoopUntilZeroInpput();
}


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

int n, k;
int r, s, p;

int add(string S, int idx){
    int t = 0;
    if(S[idx] == 'r') t = p;
    else if(S[idx] == 's') t = r;
    else t = s;
    return t;
}

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

    cin >> n >> k;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    int ans = 0;
    for(int i = 0; i < k; i++){
        char bef = t[i];
        ans += add(t, i);
        
        for(int j = i + k; j < n; j += k){
            if(bef == t[j]){
                bef = 'x';
            }else{
                ans += add(t, j);
                bef = t[j];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    if (s[0] == s[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main(){
  int n, m, x, y;
  std::cin >> n >> m >> x >> y;
  int x_max = -INT_MAX;
  int y_min = INT_MAX;

  for(int i=0; i<n; i++){
    int temp;
    std::cin >> temp;
    if( x_max < temp ) x_max = temp;
  }

  for(int i=0; i<m; i++){
    int temp;
    std::cin >> temp;
    if( y_min > temp ) y_min = temp;
  }
  bool judge = false;
  for(int i=-99; i<=100; i++){
    if( x_max < i && y_min >= i && x < i && i <= y ){
      judge = true;
    }
  }
  if( judge ) std::cout << "No War" << '\n';
  else std::cout << "War" << '\n';
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat May 26 12:16:54 2018
DPL-1A Rec Call Revised
@author: maezawa
"""

n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort()
dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
#print(n,m)
#print(c)
#print(*dp, sep='\n')

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < c[i]:
            continue
        else:
            temp.append(dp[j-c[i]]+1)
    dp[j] = min(temp)

print(dp[n])


Measured memory_bytes: 7500
#include <iostream>
#include <limits.h>
#include <vector>

using namespace std;

struct Node {
    int cost = INT_MAX;
    int color = 0;
    vector<int> next_node;
    vector<int> len_cost;
} node[100];

int main() {
    int n, id, k;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> id >> k;
        node[id].next_node.resize(k);
        node[id].len_cost.resize(k);
        for (int j = 0; j < k; j++) {
            cin >> node[id].next_node[j] >> node[id].len_cost[j];
        }
    }

    int size1, size2;
    vector<int> vec;
    node[0].cost = 0;
    node[0].color = 1;
    vec.push_back(0);
    while (1) {
        size1 = vec.size();
        if (size1 == n) {
            break;
        }
        for (int i = 0; i < size1; i++) {
            size2 = node[vec[i]].next_node.size();
            for (int j = 0; j < size2; j++) {
                if (node[node[vec[i]].next_node[j]].cost > node[vec[i]].cost + node[vec[i]].len_cost[j]) {
                    node[node[vec[i]].next_node[j]].cost = node[vec[i]].cost + node[vec[i]].len_cost[j];
                }
            }
        }
        int min = INT_MAX, mini;
        for (int i = 0; i < size1; i++) {
            size2 = node[vec[i]].next_node.size();
            for (int j = 0; j < size2; j++) {
                if (min > node[node[vec[i]].next_node[j]].cost && node[node[vec[i]].next_node[j]].color == 0) {
                    min = node[node[vec[i]].next_node[j]].cost;
                    mini = node[vec[i]].next_node[j];
                }
            }
        }
        vec.push_back(mini);
        node[mini].color = 1;
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << node[i].cost << endl;
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 string s;
  cin >> s;
  deque<int> num;
  int n=s.size();
  rep(i,n){
    if(s.at(i)=='0'){
      num.push_back(0);
    }
    else if(s.at(i)=='1'){
      num.push_back(1);
    }
    else if(s.at(i)=='B' && !num.empty()){
	  num.pop_back();
    }
  }
  int m=num.size();
  rep(i,m){
    cout << num.at(i);
    if(i==m-1)cout << endl;
  }   
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>

struct shop{
	std::string s;
	int p;
	int id;
};

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

	std::vector<shop> spList(n);

	for(int i=0; i<n; i++){
		std::cin>>spList[i].s>>spList[i].p;
		spList[i].id= i;
	}
	
	std::stable_sort(spList.begin(), spList.end(), [](const shop &x, const shop &y){return x.p> y.p;});
	std::stable_sort(spList.begin(), spList.end(), [](const shop &x, const shop &y){return x.s< y.s;});

	for(int i=0; i<n; i++)
		std::cout<< spList[i].id +1 <<std::endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
K = int(input())
q = deque()

mod = 0
for i in range(1,10):
    q.append(i)
for _ in range(K):
    x = q.popleft()
    mod = x % 10
    if mod != 0:
        q.append(x * 10 + mod - 1)
    q.append(x * 10 + mod)
    if mod != 9:
        q.append(x * 10 + mod + 1)
print(x)




Measured memory_bytes: 11956
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//code
	long long n,ans=0;
	cin>>n;
	vector<long long> v(n);
	for(long long &i:v)
		cin>>i;
		
	map<long long,long long> mp;
	for(long long i=0;i<n;i++)
	{
		mp[v[i]]++;
	}
	
	for(auto x:mp)
	{
		ans+=x.second*(x.second-1)/2;
	}
	for(long long i=0;i<n;i++)
		cout<<ans-(mp[v[i]]-1)<<endl;
 	return 0;
}


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

int abs(int x){
    if(x<0){
        return -x;
    }
    else{
        return x;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> p;
    vector<int> q;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        p.push_back(x);
    }
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        q.push_back(x);
    }
    vector<int> np;
    for(int i=0; i<n; i++){
        np.push_back(i+1);
    }
    int a,b;
    int count = 0;
    do{
        count++;
        if(np == p) a = count;
        if(np == q) b = count;
    } while(next_permutation(np.begin(),np.end()));
    cout << abs(a-b);
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int memo[200005];

int calc(int x){
	if(x == 0) return 0;
	if(memo[x] != -1) return memo[x];
	int p = 0;
	int y = x;
	while(y > 0){
		p += y%2;
		y /= 2;
	}
	if(p == 0) return 0;
	return calc(x%p) + 1;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	memset(memo, -1, sizeof(memo));
	memo[0] = 0;
	for(int i = 1; i < 200005; ++i){
		memo[i] = calc(i);
	}
	int cnt = 0;
	rep(i,n){
		if(s[i] == '1') ++cnt;
	}
	int lCnt = cnt - 1;
	chmax(lCnt, 1);
	int uCnt = cnt + 1;
	int lNum = 0, uNum = 0;
	rep(i,n){
		lNum = (lNum * 2 + (s[i] - '0')) % lCnt;
		uNum = (uNum * 2 + (s[i] - '0')) % uCnt;
	}
	int lTwo = 1, uTwo = 1;
	vector<int> ans(n, 0);
	for(int i = n-1; i >= 0; --i){
		int num = 0;
		if(s[i] == '0'){
			num = (uNum + uTwo) % uCnt;
			ans[i] = memo[num] + 1;
		}
		else{
			if(cnt != 1){
				num = (lNum + lCnt - lTwo) % lCnt;
				ans[i] = memo[num] + 1;
			}
			else{
				ans[i] = 0;
			}
		}
		lTwo = (lTwo * 2) % lCnt;
		uTwo = (uTwo * 2) % uCnt;
	}
	rep(i,n) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector <ll> X(N);
    loop(i, 0, N) cin >> X[i];
    int longestDecreasing=1;
    for (int i=0; i<N; ++i)
    {
        int len=1;
        int j;
        for (j=i+1; j<N; ++j)
        {
            if (X[j-1]<X[j]) break;
            else len++;
        }
        longestDecreasing=max(longestDecreasing, len);
        i=j-1;
    }
    cout << longestDecreasing-1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e6;
const int inf=1e9;
int main(){
	long N,M;cin>>N>>M;
	long A[N];
	rep(i,0,N) cin>>A[i];
	sort(A,A+N);
	int a=0,b=2e5+1;
    int cnt; long sum=0;
	while(b-a>1){
		int v=(a+b)/2;
        sum=0;
		rep(i,0,N){
			cnt=lower_bound(A,A+N,v-A[i])-A;
			sum+=N-cnt;
		}
		if(sum>=M){ a=(a+b)/2; }
		else{ b=(a+b)/2; }
	}
    long acm[N+1]={};
    rep(i,1,N+1) acm[i]=acm[i-1]+A[i-1];
    long ans=0; sum=0;
    rep(i,0,N){
        cnt=lower_bound(A,A+N,a-A[i])-A;
        sum+=N-cnt;
        if(cnt<N){
            ans+=A[i]*(N-cnt)+acm[N]-acm[cnt];
        }
    }cout<<ans-a*(sum-M)<<endl;
}

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

bool check(string s,int k){
    
    for(int i = 0; i < k; i++){
        if(s[i] != s[k+i])
            return false;
    }
    
    return true;
    
}

int main(void){
    
    string s;
    cin >> s;
    
    for(int i = (s.size()-1)/2; i >= 0 ; i--){
        
        if(check(s,i)){
            cout << i*2 << endl;
            return 0;
        }
        
    }
    
    cout << 2 << endl;
    
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, H; scanf("%d %d", &N, &H);
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &A[i], &B[i]);
  }
  ll wield_max = *max_element(A.begin(), A.end());
  sort(B.begin(), B.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < N and H > 0 and B[i] > wield_max; ++i) {
    ++ans;
    H -= B[i];
  }
  if (H > 0) {
    ans += (1LL * H + wield_max - 1) / wield_max;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int n;
int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  scanf("%d", &n);
  int cnt = 0;
  for(int i = 1 ; i <= n ; ++i){
    int x;
    scanf("%d", &x);
    if((i & 1) && (x & 1))
      cnt++;
  }
  printf("%d\n" , cnt);

  return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

    string s;
    cin >> s;

    if (s[5] == '1' || s[6] - '0' > 4) cout << "TBD" << endl;
    else cout << "Heisei" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char S;
  cin >> S;
  
  if(S=='a'||S=='e'||S=='i'||S=='o'||S=='u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" <<endl;
  }
 
}

Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN (1<<18)

int n, m;
int a[MAXN];
pair<int,int> s[MAXN][2];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	m = (1<<n);
	for (int i=0; i<m; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
	memset(s, 0, sizeof(s));
}

void merge(int i, int j) {
	pair<int,int> x[4] = {s[i][0], s[i][1], s[j][0], s[j][1]};
	sort(x, x+4);
	int k = unique(x, x+4)-x;
	//p(k, x[0], x[1], x[2], x[3]);
	s[i][0] = x[k-1];
	s[i][1] = x[k-2];
}

long solve() {
	for (int i=0; i<m; i++) s[i][0] = {a[i], i};
	for (int k=0; k<n; k++) {
		int b = (1<<k);
		for (int i=0; i<m; i++)
			//if ((i&b)==0)
				merge(i|b, i);
	}
	return 1;
}

void output(long ans) {
	long x = 0;
	for (int i=1; i<m; i++) {
		//p(s[i][0], s[i][1]);
		x = max(x, long(s[i][0].first)+s[i][1].first); 
		printf("%ld\n", x);
	}
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	vector<vector<char>> c(2,vector<char>(3));
	rep(i,2)rep(j,3)cin>>c.at(i).at(j);
	reverse(all(c.at(0)));
	cout<<(c.at(0)==c.at(1)?"YES":"NO")<<endl;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define int ll
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ll tree[5000000];

    void build(int node,int l,int r)
    {
        if(l==r)
        {
            tree[node]=0;   //Change for min/sum
            return;
        }
        build(node*2,l,(l+r)/2);
        build(node*2+1,(l+r)/2+1,r);
        tree[node]=max(tree[node*2],tree[node*2+1]);    //Change for min/sum
    }

    void update(int node,int l,int r,int i,ll x)
    {
        if(i<l || r<i)
            return;
        if(l==r)
        {
            tree[node]=x;
            return;
        }
        update(node*2,l,(l+r)/2,i,x);
        update(node*2+1,(l+r)/2+1,r,i,x);
        tree[node]=max(tree[node*2],tree[node*2+1]);    //Change for min/sum
    }
    
    ll query(int node,int l,int r,int i,int j)
    {
        if(j<l || r<i)
            return 0;   //Change for min/sum
        if(i<=l && r<=j)
        {
            return tree[node];
        }
        ll q1=query(node*2,l,(l+r)/2,i,j);
        ll q2=query(node*2+1,(l+r)/2+1,r,i,j);
        return max(q1,q2);  //Change for min/sum
    }

    signed main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,x,k,z;
            cin>>n>>k;
            int ar[n+1];
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
            }
            build(1,0,300000);
            for(i=1;i<=n;++i)
            {
                x=query(1,0,300000,max(0ll,ar[i]-k),min(300000ll,ar[i]+k));
                // cout<<ar[i]<<" "<<x<<" "<<max(0ll,x-k)<<" "<<min(300000ll,x+k)<<endl;
                update(1,0,300000,ar[i],x+1);
            }
            x=query(1,0,300000,0,300000);
            cout<<x<<endl;
        }
        return 0;
    }


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

int main() {
    cout << "square1001" << endl;
}



Measured memory_bytes: 3004