akhauriyash/Code-Regression huggingface dataset:
import sys
import re

N = input()
b = [int(item) for item in re.split(r"\s", input())]

out_list = []

while len(b) > 0:
    for i in range(len(b)):
        index = len(b) - 1 - i
        if b[index] == index + 1:
            out_list.append(b.pop(index))
            break
    else:
        # 最後まで探索が終ってしまう->-1
        print(-1)
        sys.exit()

else:
    for item in out_list[::-1]:
        print(item)


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

constexpr int LIM = 10006;

char isprime[LIM];
int twinprime[LIM];

void setprime() {
    fill(isprime, isprime+LIM, 1);
    isprime[0] = isprime[1] = 0;
    for (int x = 2; x * x < LIM; ++x) {
        if (isprime[x]) {
            for (int y = x * x; y < LIM; y += x) {
                isprime[y] = 0;
            }
        }
    }
    for (int x = 5; x < LIM; ++x) {
        if (isprime[x-2] && isprime[x]) {
            twinprime[x] = x;
        } else {
            twinprime[x] = twinprime[x-1];
        }
    }
}

bool solve() {
    int n;
    cin >> n;
    if (n == 0) { return false; }
    int ans = twinprime[n];
    cout << (ans - 2) << ' ' << ans << endl;
    return true;
}

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

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

int main() {
  // ここにプログラムを追記
  int a,b;
  cin >> a >> b;
  if ((a*b)%2 == 0){
    cout << "Even" << endl;
    }
  else if ((a*b)%2 == 1){
    cout << "Odd" << endl;
    }
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, m1, m2, m3;
  double dp[310][310][310];

  void init() {
    scanf("%lld", &N);
    ll a = 0;
    rep(i, N) {
      scanf("%lld", &a);
      if(a==1) m1++;
      else if(a==2) m2++;
      else if(a==3) m3++;
    }
  }

  void solve() {
    dp[0][0][0] = 0.0;
    rep0c(i, m3) rep0c(j, m2+m3-i) rep0c(k, m1+m2+m3-i-j) {
      if(i==0&&j==0&&k==0) continue;
      double e1 = N / ((double)(i+j+k));
      double e2 = 0.0;
      if(i>0) e2 += i*dp[i-1][j+1][k];
      if(j>0) e2 += j*dp[i][j-1][k+1];
      if(k>0) e2 += k*dp[i][j][k-1];
      e2 /= (double)(i+j+k);
      dp[i][j][k] = e1 + e2;
    }
    printf("%.14lf\n", dp[m3][m2][m1]);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 225536
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int n;
	int a[100000], b[100000];
	cin >> n;
	rep(i, 0, n)
		cin >> a[i] >> b[i];
	int c[100000] = {};
	int d[100000] = {};
	rep(i, 0, n)
		d[i] = a[i] + b[i];
	sort(d, d + n);
	rep(i, 0, n) {
		c[d[i] / 31] += (1 << (d[i] % 31));
		if (c[d[i]/31] < 0) {
			c[d[i]/31] = c[d[i]/31] & 2147483647;
			c[d[i]/31+ 1] += 1;
		}
	}
	rep(i, 0, 1000000) {
		if (bitget(c[i / 31], i % 31) == 1) {
			cout << i << " " << "0" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4616
a = [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]
print(a[int(input())-1])


Measured memory_bytes: 2940
#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 <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MOD = 1000000007;

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

  long a, b, c, d;
  cin >> a >> b >> c >> d;

  ll cd = c % d;
  long c_ = c;
  long d_ = d;
  while(cd!=0){
    c_ = d_;
    d_ = cd;
    cd = c_ % d_;
  }

  cd = (c*d)/d_;

  long wac, wad, wacd;
  long wbc, wbd, wbcd;

  wac = a / c;
  wad = a / d;
  wacd = a / cd;

  wbc = b / c;
  wbd = b / d;
  wbcd = b / cd;

  if (a % c && a % d) {
    cout << (b - wbc - wbd + wbcd) - (a - wac - wad + wacd) + 1 << endl;
  } else {
    cout << (b - wbc - wbd + wbcd) - (a - wac - wad + wacd) << endl;
  }
}


Measured memory_bytes: 888
a,b,c=map(int, input().split())
n=int(input()) 
 
k = n
 
if a < b < c:
    print('Yes')
 
if a < b and b >= c:
    while  b >= c and k >= 1:
        c = 2*c
        k -= 1
        if b >= c and k == 0:
            print('No')
        if b < c and k>=0:
            print('Yes')
 
if a >= b:
    while a >= b and k >= 1:
        b = 2*b
        k -= 1
        if a >= b and k == 0 :
            print('No')
        if a < b and b >= c and k == 0:
            print('No')
        if a < b < c:
            print('Yes')
            break
        if a < b and b >= c and k >= 1:
            while  b >= c and k >= 1:
                c = 2*c
                k -= 1
                if b >= c and k == 0:
                    print('No')
                if b < c and k>=0:
                    print('Yes')
                    break

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

const int M = 1e9+7;

int mul(int x, int y){
    return 1LL*x*y%M;
}

int add(int x, int y){
    return (x%M+y%M)%M;
}



int main(){
    int n,k;cin>>n>>k;
    k = min(k,n-1);
    vector<int> fact(2*n),inv(2*n),ifact(2*n);
   
    fact[0] = ifact[0] = inv[1] = fact[1] = ifact[1] = 1;

    for(int i = 2; i < 2*n; i++){
        fact[i] = mul(fact[i-1],i);
        inv[i] = (M - mul(M/i,inv[M%i]))%M;
        ifact[i] = mul(ifact[i-1],inv[i]);
    }
    ll ans = 0;
    
    auto C = [&](int n, int k){
        if(n<=0 || k<=0) return 1;
        
        return mul(fact[n],mul(ifact[k],ifact[n-k]))%M;
    };

    for(int i = 0 ; i <= k ; i++){
        int x = n-i;
        ans+=mul(C(n,i),C(n-1,x-1));
    }
    cout<<ans%M;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
string s;
int n,q,l,r,pset[100007];
int it[400007];
set <int> query[100007];
void upd(int k,int l,int r,int L,int R,int val){
	if(l>R || r<L || L>R) return;
	if(l>=L && r<=R){
		it[k]+=val;
		return;
	}
	int mid=(l+r)/2;
	upd(k*2,l,mid,L,R,val);
	upd(k*2+1,mid+1,r,L,R,val);
}
int get(int k,int l,int r,int pos){
	if(l==r && l==pos) return it[k];
	int mid=(l+r)/2;
	if(pos<=mid) return it[k]+get(k*2,l,mid,pos);
	else return it[k]+get(k*2+1,mid+1,r,pos);
}
int main(){
	ios_base::sync_with_stdio(0);
	cin>>s;
	n=(int)s.length();
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>l>>r;
		if(l<=(n+1)/2 && r>=(n+1)/2){
			r=n-r+1;
			if(l>r) swap(l,r);
			if(l==r) continue;
			r--;
			query[l].insert(r);
		}
		else if(l<=(n+1)/2){
			query[l].insert(r);
		}
		else{
			query[n-r+1].insert(n-l+1);
		}
	}
	for(int i=1;i<=n;i++) pset[i]=i;
	for(int i=1;i<=n/2;i++){
		//cout<<(s[i-1]-s[n-i]+26)%26<<endl;
		int cal=((s[i-1]-s[n-i]+26)%26-get(1,1,n,i)+26)%26;
		//cout<<i<<" "<<cal<<endl;
		if(cal!=0 && query[pset[i]].empty()){
			cout<<"NO";
			return 0;
		}
		if(i==n/2) continue;
		if(!query[pset[i]].empty()){
			int cur=pset[i];
			auto it=query[cur].begin();
			int x=*it;
			query[cur].erase(it);
			upd(1,1,n,i,x,cal);
			int nxt=pset[x+1];
			if(query[cur].size()<query[nxt].size()){
				pset[i]=nxt;
				for(auto jt=query[cur].begin();jt!=query[cur].end();jt++){
					query[nxt].insert(*jt);
				}
			}
			else{
				pset[x+1]=cur;
				for(auto jt=query[nxt].begin();jt!=query[nxt].end();jt++){
					query[cur].insert(*jt);
				}
			}
		}
	}
	cout<<"YES";
}


Measured memory_bytes: 13952
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    while (true) {

      int a = scanner.nextInt();
      String op = scanner.next();
      int b = scanner.nextInt();
      int res = 0;

      if (op.equals("?")) {
        break;
      } else if (op.equals("+")) {
        res = a + b;
      } else if (op.equals("-")) {
        res = a - b;
      } else if (op.equals("*")) {
        res = a * b;
      } else if (op.equals("/")) {
        res = a / b;
      }

      System.out.println(res);
    }

    scanner.close();
  }
}

Measured memory_bytes: 18008
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    ll n; cin >> n;
    vector<ll> f;
    for(ll i = 1; i <= sqrt(n); i ++) {
        if(n%i==0) {
            ll a = to_string(i).length();
            ll b = to_string(n/i).length();
            f.push_back(max(a,b));
        }
    }
    cout << *min_element(ALL(f)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[51][51],b,c,d,n,m,p,q,x,y,k,h,w,sum,mi,ma,ans,l,r,res;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char cha;
string s;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

int main(){
    cin>>h>>w;
    rep(i,h)rep(j,w){
        cin>>cha;
        if(cha=='.')a[i][j]=0;
        else a[i][j]=1;
    }
    rep(i,h)rep(j,w){
        if(a[i][j]==1){
            flag=0;
            rep(k,4)if(a[i+dx[k]][j+dy[k]]==1)flag=1;
            if(flag==0){p("No"); return 0;}
        }
    }
    p("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;
const int MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  int x=0;
  int ans=0;
  while(true){
    while(h.at(x)==0){
      x++;
      if(x==n){
        cout << ans << endl;
        return 0;
      }
    }
    for(int i=x;i<n;i++){
      if(h.at(i)==0){
        ans++;
        break;
      }
      else if(i==n-1){
      h.at(i)--;
        ans++;
      }
      else
        h.at(i)--;
    }
  }
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt(), b = scn.nextInt();
		scn.close();
		System.out.print((a/b) + " " + (a % b) + " ");
		System.out.printf("%.5f", + ((double) a / b));

	}
}


Measured memory_bytes: 26496
parseline(str=readline()) = parse.(Int, split(str))
function main()
    N, K = parseline()
    LR = [Int[] for _ in 1:K]
    Mod = 998244353
    for k in 1:K
        LR[k] = parseline()
    end
    dp = zeros(Int, N)
    dp[1] = 1
    dp[2] = -1
    for n in 1:N-1
        for (l, r) in LR
            n+l≤N && (dp[n+l] = mod(dp[n+l]+dp[n], Mod))
            n+r+1≤N && (dp[n+r+1] = mod(dp[n+r+1]-dp[n]+Mod, Mod))
        end
        dp[n+1] = mod(dp[n+1]+dp[n], Mod)
    end
    println(dp[end])
end
main()

Measured memory_bytes: 182960
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
    string s;
    ll k;
    cin >> s >> k;
    int id = 0;
    k --;
    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] != '1')
        {
            id = i;
            break;
        }
    }
    if(k < id)
            cout << 1;
else
        cout << s[id];










    getchar();
    getchar();
    return 0;
    //ios::sync_with_stdio(false);
    //cin.tie(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()	
{
	int a,b,k;
	set<int>S;
	cin>>a>>b>>k;
	for(int i=a;i<=min(a+k-1,b);i++)S.insert(i);
	for(int i=b;i>=max(b-k+1,a);i--)S.insert(i);
	for(auto i=S.begin();i!=S.end();i++) 
	{
		cout<<*i<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
inline int rrr()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
inline ll rll()
{
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
ll x1,x2,y11,y2,x3,y3;

int main()
{
    ll s=rll();
	if(s!=1e18) y3=x2=(ll)sqrt(s)+1;
    else y3=x2=(ll)sqrt(s);
    
	ll tmp=x2*y3-s;
    y2=tmp;
	x3=1;
	x1=0;
	y11=0;
    cout<<x1<<" "<<y11<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	ll n, k;
	cin >> n >> k;
	VLL a(n), b(n + 1), asum(n + 1);
	b[0] = 0;
	asum[0] = 0;
	REP(i, n) {
		cin >> a[i];
		b[i + 1] = b[i] + max(a[i], 0LL);
		asum[i + 1] = asum[i] + a[i];
	}


	ll ans = -INFL;

	REP(i, n - k + 1) {
		ll tmp = 0;
		tmp += max(0LL, asum[i + k] - asum[i]);
		tmp += b[i] + b[n] - b[i + k];
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 2560
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,d=0,e=0;cin>>a;
  vector<ll>c(14,0);
  rep(i,a){
    cin>>b;
    c[b/400]++;
  }
  rep(i,8)if(c[i]!=0)d++;
  rep(i,6)e+=c[i+8];
  cout<<max(d,(ll)1)<<" "<<d+e;
}



Measured memory_bytes: 26948
#include<iostream>
using namespace std;
int main(){
  long l,r;
  cin >> l >> r;
  int min = 9999;
  if(r-l >= 4038) cout << 0;
  else{
    long i;
    long j;
    long tmp;
    for(i=l;i<r;i++){
      for(j=i+1;j<=r;j++){
        tmp = ((i%2019) * (j%2019)) % 2019;
        if(tmp < min) min = tmp;
      }
    }
    cout << min;
    
    
  }
}
  
  

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	while(true){
	    int n = scan.nextInt();

	    if(n == 0){
		break;
	    }

	    int[][] data = new int[n][3];
	    int[] sum = new int[n];
	    
	    for(int i = 0; i < n; i++){
		sum[i] = 0;
	    }

	    for(int i = 0; i < n; i++){
		data[i][0] = scan.nextInt();
		data[i][1] = scan.nextInt();
		data[i][2] = scan.nextInt();
		sum[i] = data[i][1] + data[i][2];
	    }


	    int stock;

	    for(int i = 0; i < 1; i++){
		for(int j = i; j < n; j++){
		    if(sum[i] < sum[j]){
			stock = sum[i];
			sum[i] = sum[j];
			sum[j] = stock;
			stock = data[i][0];
			data[i][0] = data[j][0];
			data[j][0] = stock;
		    }
		}
	    }
    

	    System.out.println(data[0][0] + " " + sum[0]);
	}
    }
}
	

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

#define MOD 1000000007

long long mod_pow(long long a,long long b)
{
    a %= MOD;
    long long res = 1;
    while(b){
        if(b & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}


ll a[10000000];

int main(){
    int s;
    cin >> s;
    int lll = 1;
    int dd = 1;
    while(lll<10000000){
        for(int i=lll;i<10*lll;i++){
            a[i] = a[i-1]+dd;
        }
        lll*=10;
        dd++;
    }
    ll res = 0;
    int id = 0;
    for(int i=1;i<=9999999;i++){
        if(s>68888889-a[i-1]){
            if((s-68888889+a[i-1])%8==0){
                res++;
            }
        }else{
            while(id<9999999&&a[id]<s+a[i-1]){
                id++;
            }
            if(a[id]==s+a[i-1]){
                res++;
            }
        }
    }
    for(ll len=8;len<=s;len++){
        if(len==s/2+5){
            len = s-1;
        }
        if(s%len==0){
            ll p = s/len;
            //cerr << len << " " << (9*mod_pow(10,len-1)+mod-p+1)%mod << " " << p << " " << (p-1)/(len+1) << endl;
            res += 9*mod_pow(10,len-1)+mod-p+1;
            res %= mod;
            res += (p-1)/(len+1);
            res %= mod;
        }else{
            ll p,q;
            q = s%len;
            p = (s-q*(len+1))/len;
            if(p<=0)continue;
            //cerr << len << " " << p << " " << q << " " << (p-1)/(len+1)+1 << endl;
            res += (p-1)/(len+1)+1;
            res %= mod;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 78336
M = 10 ** 9 + 7


def main():
    n = int(input())
    s1, s2 = input(), input()

    com = 1
    i, j = 0, 0
    while i < n or j < n:
        if i <= j:
            if s1[i] == s2[j]:
                if i == 0:
                    com = com * 3 % M
                elif s1[i-1] == s2[j-1]:
                    com = com * 2 % M
                i += 1
                j += 1
            else:
                if i == 0:
                    com = com * 3 % M
                else:
                    com = com * 2 % M
                i += 2

        else:
            if j == 0:
                com = com * 2 % M
            elif s1[i-3] != s2[j-1]:
                com *= 1.5
            j += 2

    print(int(com) % M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
abc = [LIST() for _ in range(N-1)]

graph = defaultdict(list)
for a, b, c in abc:
	graph[a-1].append((b-1, c))
	graph[b-1].append((a-1, c))

Q, K = MAP()
xy = [LIST() for _ in range(Q)]

dist = [-1]*N
dist[K-1] = 0

def dfs(node):
	for to, cost in graph[node]:
		if dist[to] == -1:
			dist[to] = dist[node] + cost
			dfs(to)

dfs(K-1)
#print(dist)

for x, y in xy:
	print(dist[x-1] + dist[y-1])


Measured memory_bytes: 186364
from collections import deque

p_copy = []


def change(y):
    global p_copy
    x = p_copy[0][0]
    que = deque()
    que.append((0, 0))
    memo = {(0, 0): 1}
    while len(que) > 0:
        i, j = que.popleft()
        p_copy[i][j] = y
        if i + 1 < h and p_copy[i + 1][j] == x and (i + 1, j) not in memo:
            que.append((i + 1, j))
            memo[(i + 1, j)] = 1
        if j + 1 < w and p_copy[i][j + 1] == x and (i, j + 1) not in memo:
            que.append((i, j + 1))
            memo[(i, j + 1)] = 1
        if i - 1 >= 0 and p_copy[i - 1][j] == x and (i - 1, j) not in memo:
            que.append((i - 1, j))
            memo[(i - 1, j)] = 1
        if j - 1 >= 0 and p_copy[i][j - 1] == x and (i, j - 1) not in memo:
            que.append((i, j - 1))
            memo[(i, j - 1)] = 1


def count():
    global p_copy
    res = 0
    que = deque()
    if p_copy[0][0] == c:
        que.append((0, 0))
    memo = {(0, 0): 1}
    while len(que) > 0:
        i, j = que.popleft()
        res += 1
        if i + 1 < h and p_copy[i + 1][j] == c and (i + 1, j) not in memo:
            que.append((i + 1, j))
            memo[(i + 1, j)] = 1
        if j + 1 < w and p_copy[i][j + 1] == c and (i, j + 1) not in memo:
            que.append((i, j + 1))
            memo[(i, j + 1)] = 1
        if i - 1 >= 0 and p_copy[i - 1][j] == c and (i - 1, j) not in memo:
            que.append((i - 1, j))
            memo[(i - 1, j)] = 1
        if j - 1 >= 0 and p_copy[i][j - 1] == c and (i, j - 1) not in memo:
            que.append((i, j - 1))
            memo[(i, j - 1)] = 1
    return res


_max = 0


def solve(p, n, before):
    global _max, p_copy
    if n == 1:
        change(c)
        temp = count()
        if temp > _max:
            _max = temp
        return
    for k in range(1, 7):
        if k == before:
            continue
        p_copy = [[j for j in i] for i in p]
        change(k)
        solve(p_copy, n - 1, k)


while True:
    h, w, c = map(int, input().split())
    if h | w | c == 0:
        break
    p_list = [list(map(int, input().split()))for i in range(h)]
    solve(p_list, 5, -1)
    print(_max)
    _max = 0


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n;
	set<ll> s;

	cin >> n;

	ll prev = n;
	ll now;
	ll cnt = 1;
	s.insert(n);

	while (true) {
		cnt++;
		if (prev % 2 == 0) {
			now = prev / 2;
		}
		else {
			now = 3 * prev + 1;
		}
		if (s.find(now) != s.end()) {
			cout << cnt << endl;
			break;
		}
		else {
			s.insert(now);
			prev = now;
		}
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n];

		String[] tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(tmpArray[i]);
		}

		long[] x = new long[n];
		//まずはx1を確定させる
		for(int i = 0; i < n; i++){
			if(i %2 == 0){
				x[0] += a[i];
			}
			else {
				x[0] -= a[i];
			}
		}
		x[0] /= 2;

//		System.out.println(x[0]*2);

		for(int i = 1; i < n; i++){
			x[i] = a[i - 1] - x[i - 1];
		}

		for(int i = 0; i < n; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(x[i]*2);
		}
		System.out.println();
	}

}


Measured memory_bytes: 47676
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    int c;
    bool ok;
    foreach (_; 0..N) {
        auto ab = readln.split;
        if (ab[0] == ab[1]) {
            ++c;
            if (c >= 3) ok = true;
        } else {
            c = 0;
        }
    }
    writeln(ok ? "Yes" : "No");
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
class {
public:
	int a[N] = {};
	void add(int i, ll x){ i++;
		while(i < N){
			a[i] += x;
			i += i&-i;
		}
	}
	int sum(int i){ i++;
		int ret = 0;
		while(i){
			ret += a[i];
			i -= i&-i;
		}
		return ret;
	}
	int sum(int a, int b){
		return sum(b-1)-sum(a-1);
	}
} bt, ba;
pii x[N];
map<int, int> xs, ys;
ll pw[N];

#define MOD 998244353LL

int main(){
	// bt.add(1, 9);
	// bt.add(2, 6);
	// bt.add(3, 8);
	// REP(i, 5){
	// 	FOR(j, i, 5){
	// 		DEBUG("[%d, %d) = %lld\n", i, j, bt.sum(i, j));
	// 	}
	// }
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d%d", &x[i].first, &x[i].second);
	REP(i, n) xs[x[i].first] = ys[x[i].second] = 0;
	{ int i = 0;
		for(auto &p : xs) p.second = i++;
	}
	{ int i = 0;
		for(auto &p : ys) p.second = i++;
	}
	REP(i, n) x[i].first = xs[x[i].first], x[i].second = ys[x[i].second];
	sort(x, x+n);
	pw[0]=1; FOR(i, 1, N) pw[i] = pw[i-1]*2 % MOD;
	REP(i, N) pw[i]--;
	REP(i, n) ba.add(x[i].second, 1);
	ll ans = 0;
	REP(i, n){
		int p = bt.sum(0, x[i].second), 
				q = bt.sum(x[i].second + 1, n+1),
				r = ba.sum(0, x[i].second) - p,
				s = ba.sum(x[i].second + 1, n+1) - q;
		DEBUG("(%d, %d), (%d, %d, %d, %d)\n", x[i].first, x[i].second, p, q, r, s);
		assert(p+q == i);
		assert(p+q+r+s == n-1);
		ll tmp = pw[n] - pw[p+r] - pw[q+s] - pw[p+q] - pw[r+s]
			+ pw[p] + pw[q] + pw[r] + pw[s];
		DEBUG("%d-%d-%d-%d-%d+%d+%d+%d+%d=%d\n", 
				pw[n], pw[p+r], pw[q+s], pw[p+q], pw[r+s],
				pw[p], pw[q], pw[r], pw[s], tmp);
		if(tmp<0) tmp += ((-tmp)/MOD + 3) * MOD;
		ans += tmp;
		ans %= MOD;
		bt.add(x[i].second, 1);
	}
	printf("%lld\n", ans);
}




Measured memory_bytes: 23936
n,m,k = (int(i) for i in input().split())
flag = False
for i in range(0,m+1):
	for j in range(0,n+1):
		if k==i*n+j*m-2*i*j:
			flag = True
			break
	if flag: break
if flag: print("Yes")
else: print("No")


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>

int main(){
	int t;
	int n,h;
	
	scanf("%d", &t);
	for(;t > 0; t--){
		scanf("%d", &n);
		int before; // ツ前ツづ個段ツ債キ
		scanf("%d", &before);
		int maxup, maxdown;
		maxup = maxdown = 0;
		for(int i = 1; i < n; i++){
			scanf("%d", &h);
			if(before < h){
				int up = h - before;
				if(maxup < up){
					maxup = up;
				}
			}
			else{
				int down = before - h;
				if(maxdown < down){
					maxdown = down;
				}
			}
			before = h;
		}
		
		printf("%d %d\n", maxup, maxdown);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
int main(){
	int a[3];
	int cnt=0,i;
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	sort(a,a+3);
	while(a[0]!=a[2]){
		cnt++;
		if(a[1]==a[2]||a[2]-a[0]>1){
			a[0]+=2;
		}else{
			a[0]++;
			a[1]++;
		}
		sort(a,a+3);	
	}
	cout<<cnt<<endl;
}

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

//?????§??¬?´???°
int gcd(int m, int n){
	if ((m == 0) || (n == 0)) return 0;


	while ((m != 0) && (n != 0)){
		m > n ? m = m%n : n = n%m;
	}
	if (m == 0) return n;
	else return m;
}

//????°???¬?????°
int lcm(int m, int n){
	if ((m == 0) || (n == 0)) return 0;

	return m*n / gcd(m, n);
}



int main()
{
	long long int a, b, n, m;
	while (scanf("%lld %lld", &a, &b) != EOF)
	{
		n = gcd(a, b);
		m = a * (long long int)(b / n);
		cout << n << " " << m << endl;
	}

	return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char arr[1000],rev[1000];
    int i,j,ln;
    while(scanf("%s",arr)!=EOF)
    {
        ln=strlen(arr);
        j=0;
        for(i=ln-1; i>=0; i--)
        {
            rev[j]=arr[i];
            j++;
        }
        rev[j]='\0';

        if(strcmp(arr,rev)==0)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define ll long long
#define ull unsigned long long
using namespace std;

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

	string s1, s2;
	cin >> s1 >> s2;
	int l1 = s1.length();
	int l2 = s2.length();
	vector<vector<int>> DP(l1 + 1, vector<int>(l2 + 1));
	for (int i = 1; i <= l1; i++){
		for (int j = 1; j <= l2; j++){
			if (s1.at(i - 1) == s2.at(j - 1)){
				DP.at(i).at(j) = DP.at(i - 1).at(j - 1) + 1;
			} else {
				DP.at(i).at(j) = max(DP.at(i - 1).at(j), DP.at(i).at(j - 1));
			}
		}
	}
	int i = l1, j = l2;
	string ans = "";
	while (i > 0 && j > 0){
		if (DP.at(i).at(j) == DP.at(i - 1).at(j - 1) + 1 && s1.at(i - 1) == s2.at(j - 1)){
			ans += s1.at(i - 1);
			i--;
			j--;
		} else if (DP.at(i).at(j - 1) > DP.at(i - 1).at(j)){
			j--;
		} else {
			i--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    vector<char> a(3);
    vector<char> b(3);
    for (int i = 0; i < 3; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < 3; i++) {
        cin >> b.at(i);
    }
    if (a.at(0) == b.at(2) && a.at(1) == b.at(1) && a.at(2) == b.at(0)) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(0, a + 1):
  for ii in range(0, b + 1):
    for iii in range(0, c + 1):
      sum = 500 * i + 100 * ii + 50 * iii
      if sum == x:
        count += 1

print(count)

Measured memory_bytes: 3064
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input);
    println!("{}", output);
}

fn run(input: String) -> String {
    let list: Vec<i32> = input
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect();

    let a = list[0];
    let b = list[1];
    let c = list[2];
    let d = list[3];

    let l = a + b;
    let r = c + d;

    if r > l {
        "Right".to_string()
    } else if l > r {
        "Left".to_string()
    } else {
        "Balanced".to_string()
    }
}

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


int main() {
  long long a;
  double b;
  cin >> a >> b;
  long long ib = b*100+0.5;
  a *= ib;
  a /=  100;
    printf("%lld\n", a);
  return 0;
}
  

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int s,a,b,YM,MY;
    cin >> s;
    a = s/100;
    b = s-(a*100);
    YM = 0;
    MY = 0;
    
    if(0<=a&&a<=99&&1<=b&&b<=12){
        YM++;
    }
    if(1<=a&&a<=12&&0<=b&&b<=99){
        MY++;
    }
    if(YM==1&&MY==1){
        cout << "AMBIGUOUS" << endl;
    }
    if(YM==0&&MY==0){
        cout << "NA" << endl;
    }
    if(YM==1&&MY==0){
        cout << "YYMM" << endl;
    }
    if(YM==0&&MY==1){
        cout << "MMYY" << endl;
    }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
using namespace std;
int main(){
int i,t[20];
for(i=0;i<20;i++){
cin>>t[i];
}
sort(t,t+10,greater<int>());
sort(t+10,t+20,greater<int>());
cout<<t[0]+t[1]+t[2]<<" "<<t[10]+t[11]+t[12]<<endl;
return 0;
}

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

int main(){

  int n, q, i, j, count=0;
  int s[10000],t[500];

  cin >> n;
  for (i=0; i<n; i++){
    cin >> s[i];
  }

  cin >> q;
  for (i=0; i<q; i++){
    cin >> t[i];
  }

  for (i=0; i<q; i++){
    for (j=0; j<n; j++){
      if (s[j]==t[i]){
	count++;
	break;
      }
    }
  }

  cout << count << endl;

  return 0;

}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define int boost::multiprecision::cpp_int
using namespace std;

typedef unsigned long long ll;
typedef unsigned long long ull;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
struct Edge
{
    long long to;
    long long cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
const long long INF = 1LL << 60;
int a[100000];

signed main()
{
    int n;

    cin >> n;

    int total = 1;
    long tmp = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> tmp;
        if(tmp == (int)0){

            cout << 0 << endl;
            return 0;
        }
        a[i] = tmp;
    }

      for (ll i = 0; i < n; i++)
    {
        total *= a[i];
  
      if (total > (int)1000000000000000000)
      {
        cout << -1 << endl;
        return 0;
      }
    }

    cout << total << endl;
}
//cout << std::fixed << std::setprecision(15)


Measured memory_bytes: 6808
#include<iostream>

using namespace std;

int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;

    for(int i = 0; flag; i++){       
        flag = 0;
        for(int j = N-1; j >= i+1; j--){
            if(A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }

    return sw;
}

int main(){
    int A[100], N, sw;

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];

    sw = bubbleSort(A, N);

    for(int i = 0; i < N; i++) {
        if(i) cout << " ";
        cout << A[i];
    }

    cout << endl;
    cout << sw << endl;

    return 0;
}


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


int main(){
    long long x,k,d;
    cin >> x >> k >> d;
    long long num = abs(x)/d;
        long long ans = 0;
    if(num<=k){
        if((k-num)%2==0){
            ans = abs(x)%d;
        }else{
            ans = abs(abs(x)%d-d);
        }
    }else{
        ans = abs(x)-k*d;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main(){
  int n,m; cin>>n>>m;
  long long ans=1;
  if(n>m+1 || n+1<m) ans=0;
  else{
    for(int i=n;i>=1;--i) ans=ans*i%MOD;
    for(int i=m;i>=1;--i) ans=ans*i%MOD;
  }
  if(n==m) ans=ans*2%MOD;
  cout<<ans%MOD<<endl;  
  return 0;
}


Measured memory_bytes: 256
fun judgeKaibun(s: String): Int {
    val end: Int = s.length
    for(i in 0..end/2) {
        if(s[i] != s[end - i - 1]) {
            println("No")
            return -1
        }
    }
    return 0
}
fun main(args: Array<String>) {
    val s: String = readLine()!!
    val n: Int = s.length
    if(judgeKaibun(s.substring(0, n)) !=  0) return
    if(judgeKaibun(s.substring(0, (n - 1) / 2)) !=  0) return
    if(judgeKaibun(s.substring((n + 3) / 2 - 1, n)) !=  0) return
    println("Yes")
}

Measured memory_bytes: 31620
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;

int a[100];
int b[100];
int c[100];

int main() {
    int n;cin>>n;
    for(int i = 0;i<n;i++) cin >>a[i];
    for(int i = 0;i<n;i++) cin >>b[i];
    for(int i = 1;i<n;i++) cin>>c[i];
    int m;
    for(int i = 0;i<n;i++){
      m+=b[a[i]-1];
      if(a[i] == a[i-1]+1) m+= c[a[i-1]];
    }
    cout<<m;
    return 0;
}

Measured memory_bytes: 256
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 9;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

int n;
int a[N], suf[N];

int main(){
    Speedforce
    //fop("", "")
    cin >> n;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
    }
    int ans = -inf;
    for(int i = n;i >= 1;i --){
        if(a[i] >= a[i + 1]){
            suf[i] = suf[i + 1] + 1;
        }
        else{
            suf[i] = 1;
        }
        ans = max(ans, suf[i]);
    }
    cout << ans - 1;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Seg{
	int t[800005],tag[800005];
	Seg(){
		memset(t,0x3f,sizeof(t));
		memset(tag,0x3f,sizeof(tag));
	}
	void Tag(int p,int k){
		t[p]=min(t[p],k),tag[p]=min(tag[p],k);
	}
	void Pushdown(int p){
    	if(tag[p]!=0x3f3f3f3f)Tag(2*p,tag[p]),Tag(2*p+1,tag[p]),tag[p]=0x3f3f3f3f;
	}
	void Upd(int p,int l,int r,int x,int y,int z){
		if(x<=l&&r<=y)return Tag(p,z);
		int mid=(l+r)/2;
		Pushdown(p);
		if(x<=mid)Upd(p*2,l,mid,x,y,z);
		if(mid<y)Upd(p*2+1,mid+1,r,x,y,z);
	}
	int Q(int p,int l,int r,int x){
		if(l==r)return t[p];
		int mid=(l+r)/2;
		Pushdown(p);
		if(x<=mid)return Q(p*2,l,mid,x);
		else return Q(p*2+1,mid+1,r,x);
	}
}sheng,sshu;
ll ans=0;
int n,q;
int main(){
	cin>>n>>q;
	ans=1ll*(n-2)*(n-2);
	sheng.Upd(1,1,n,1,n,n),sshu.Upd(1,1,n,1,n,n);
	while(q--){
		int opt,x;
		cin>>opt>>x;
		if(opt==1){
			int u=sheng.Q(1,1,n,x);
			ans-=max(u-2,0);
			sshu.Upd(1,1,n,1,u-1,x);
		}
		else {
			int u=sshu.Q(1,1,n,x);
			ans-=max(u-2,0);
			sheng.Upd(1,1,n,1,u-1,x);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0,b=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        r++;
        else if(s[i]=='B')
        b++;
    }    
    if(r>b)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n,m;
   cin>>n>>m;
   n=abs(n-m);
   if(n%m==0)
   {
       cout<<0;
       return 0;
   }
   ll rem=n%m;
   ll rem2=m-rem;
   ll minval=INT_MAX;
   if(rem<rem2)
   {
       minval=rem;
   }
   else minval=rem2;
   cout<<minval;
       
      

 

}

Measured memory_bytes: 256
using System;

namespace _20200711
{
    class Program
    {
        static void Main()
        {
            var lrd = Console.ReadLine().Split(' ');
            var l = int.Parse(lrd[0]);
            var r = int.Parse(lrd[1]);
            var d = int.Parse(lrd[2]);
            var count = 0;
            for (var i = l; i <= r; ++i)
            {
                if (i % d == 0)
                {
                    ++count;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27312
c=set(range(input()))
l=sorted([map(int,raw_input().split()) for _ in c])
for i in l:c-=set(i[1:])
d=c.pop()
def f(n):return "" if n<0 else "".join([" "+str(n) if j<1 else f(l[n][j]) for j in a])
for i in range(3):
    a=[1,2]
    a[i:i]=[0]
    print ["Pre","In","Post"][i]+"order"
    print f(d)

Measured memory_bytes: 4236
#include <iostream>
#define REP(i, a, n) for(int i = a; i <= n; i++)
using namespace std;


int nxt[200002], prv[200002], n, m;

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

  int h = 1;
  REP(i, 0, n + 1) {
    nxt[i] = i + 1;
    prv[i] = i - 1;
  }

  int e, ntmp, ptmp;
  REP(i, 1, m) {
    cin >> e;
    if(h != e) {
      nxt[prv[e]] = nxt[e];
      prv[nxt[e]] = prv[e];
      nxt[e] = h;
      prv[e] = 0;
      nxt[0] = e;
      prv[h] = e;
      h = e;
    }
  }

  int k = h;
  REP(i, 1, n) {
    cout << k << endl;
    k = nxt[k];
  }

  return 0;
}

Measured memory_bytes: 4648
import java.util.Scanner;


// 138_a
public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        String s = scan.next();

        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }

    }

}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int s = 0;
    rep(i, n) s += a[i];
    int cnt = 0;
    rep(i, n) {
        if (a[i] * (4 * m) >= s) cnt++;
    }
    if (cnt >= m) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
buf = sys.stdin.buffer
N,Q = map(int,buf.readline().split())
S = np.zeros(N+2, dtype='S1')
S[1:] = np.frombuffer(buf.read(N+1), dtype='S1')
A = (S == b'A')
C = (S == b'C')
AC = (A[:-1] & C[1:])
AC_cum = list(AC.cumsum())

for _ in range(Q):
  L,R = map(int,buf.readline().split())
  print(AC_cum[R-1] - AC_cum[L-1])


Measured memory_bytes: 17580
#include<stdio.h>

int main(void){
	int i,j,k;	//sñ\¦
	double p,d,a[5][5]={0};			//p=s|bgAd=XC[vìÏ
	
	
	while(scanf("%lf %lf %lf %lf %lf %lf",&a[0][0],&a[0][1],&a[0][2],&a[1][0],&a[1][1],&a[1][2])!=EOF)
	{		
	
		//printf("%fx+%fy=%f\n",a[0][0],a[0][1],a[0][2]);		mF
		//printf("%fx+%fy=%f\n",a[1][0],a[1][1],a[1][2]);
	
	
		for(k=0;k<2;k++){
			/* s{bgXC[vìÅWðÎp»:s{bgW */
			p=a[k][k];	
			
			for(j=k;j<(2+1);j++){
				/* s{bgsÌeWðs{bgWÅé*/
				a[k][j]=a[k][j]/p;
			}
			
			for(i=0;i<2;i++){
				/*s{bgñÌXC[vì:s{bgsÅÈ¢êÌÝÀs */
				if (i!=k) {   
					d=a[i][k];
					
					for (j=k;j<2+1;j++){
						a[i][j]= a[i][j]-d*a[k][j];
					}
				
				}
			}
		}	
	
		printf("%.3f %.3f\n",a[0][2],a[1][2]);
		
		
		
	}	
	
	return 0;
}

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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int cnt = 0;
    rep(ai, 0, a){
        rep(bi, 0, b){
            rep(ci, 0, c){
            if (ai * 500 + bi * 100 + ci * 50 == x) cnt ++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256