akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 10000000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;

int n,m;
ll f[2001],t[2001],c[2001];
ll res[1001];

void solve(){
	for(int i=0;i<n;i++){
		res[i]=INF;
	}
	res[0]=0;
	int cnt=0;
	while(true){
		bool upd=false;
		bool upd2=false;
		for(int i=0;i<m;i++){
			if(res[f[i]]!=INF && res[f[i]]-c[i]<res[t[i]]){
				upd=true;
				res[t[i]]=res[f[i]]-c[i];
				if(t[i]==n-1)upd2=true;
			}
		}
		if(!upd)break;
		if(cnt>3*n && upd2){
			printf("inf\n");
			return;
		}
		if(cnt==4*n)break;
		cnt++;
	}
	printf("%lld\n",-res[n-1]);
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld",&f[i],&t[i],&c[i]);
		f[i]--;
		t[i]--;
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline().strip())

p = [0]*(n+1)
dp = [[0]*(n+1) for _ in range(n+1)]

for i in range(n):
    p[i], p[i+1] = map(int, sys.stdin.readline().strip().split())

# dpテーブルの対角成分を初期値とし、右斜に更新していく
# 利用する行列の数
for l in range(2, n+1):
    # 利用する範囲（l個の行列のうちi - jの範囲の行列を扱う）
    for i in range(1, n-l+2):
        j = i + l - 1
        dp[i][j] = float("inf")
        # 掛け合わせの区切り位置
        for k in range(i, j):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j])

print(dp[1][n])


Measured memory_bytes: 5672
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    double n,t,a;
    cin>>n>>t>>a;
    vector<double> hoge(n);
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    
    int ans=-1;
    double minc=999999;
    
    for(int i=0;i<n;i++){
        double pre=t-hoge.at(i)*0.006;
        
        minc=min(minc,abs(pre-a));
        if(minc==abs(pre-a)) ans=i+1;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

int main()
{
    int arr[5];
    int i=0;

    for(i=0;i<5;i++)
    {
        cin>>arr[i];

        if(arr[i]==0)
            break;
    }

    cout<<i+1;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
vector <int> num;
vector <int> cmp;
vector <char> erg2;
int main () {
long double numm;
cin>>numm;
numm/=3;
numm=pow(numm,3);
cout<<setprecision(12)<<fixed;
cout<<numm;
   return 0;
}


Measured memory_bytes: 640
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

def meguru(ok, ng):
    while abs(ok - ng) > 1:
        mid = (ok + ng)//2
        if isOK(mid): ok = mid
        else: ng = mid
    return ok

def isOK(num): return bcum[num] <= tb

n,m,k = imap()
a,b = iarr(),iarr()
acum,bcum = np.array(a).cumsum(),np.array(b).cumsum()

anss = []
for i in range(n+1):
    ans = 0 if i==n else i + 1
    ta = 0 if i==n else acum[i]
    if ta > k: continue
    else: tb = k - ta
    ok,ng = -1,m
    ans += meguru(ok,ng) + 1 # OKなければansは-1+1で不変
    #ans += bs.bisect_right(bcum, tb)
    anss.append(ans)
ans = max(anss) if anss else 0
print(ans)


Measured memory_bytes: 69912
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
       ll len;
       cin>>len;
       vector<ll> arr(len);
       for(auto &i:arr) cin>>i;
       ll mn = LLONG_MAX, ans = 0;
       for(auto i:arr){
           if(i <= mn) ans++, mn = i;
       }
       cout<<ans;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 4820
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

const long long int mod = 1e9 + 7;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<vector<int> > G(N);

    for (int i = 0; i < N-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    function<long long(int, int, int)> dfs;

    dfs = [&](int ncol, int from, int node) {
        int nxt_ncol = (ncol == K - 2) ? K - 2 : ncol - 1;
        int nchild = G[node].size()-1;
        if(from==-1) nchild++;

        long long  cnt = 1;
        if(ncol<nchild) return 0LL;
        for (int i = ncol; i > ncol - nchild; i--)
        {
            cnt *= i;
            cnt %= mod;
        }

        for (auto nxt : G[node])
        {
            if (nxt == from)
                continue;
            cnt *= dfs(nxt_ncol, node, nxt);
            cnt %= mod;
        }

        return cnt;
    };

    long long  answer = K*dfs(K-1, -1, 0);
    answer %= mod;
    
    cout << answer << endl
         << flush;
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

vec b(8);
ll cost(ll a, ll s){
    ll temp = 0, m = -10;
    rep(i,N){
        if((s>>i)&1) {
            temp += b.at(i);
            m += 10;
        }
    }
    return abs(a - temp) + m;
}

int main(){
    ll C;
    cin>>N>>A>>B>>C;
    rep(i,N) cin>>b[i];
    ll ans = 2e+9;
    rep(s1,1<<N){
        rep(s2,1<<N){
            ll fa = s1&s2, fb = s1^fa, fc = s2^fa;
            if(fa==0||fb==0||fc==0) continue;
            ll temp = 0;
            temp += cost(A,fa);
            temp += cost(B,fb);
            temp += cost(C,fc);
            ans = min(ans,temp);
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m, x;
	cin>>n>>m>>x;
	int c[n];
	int a[n][m];
	for(int i=0; i<n; i++) {
		cin>>c[i];
		for(int j=0; j<m; j++)
			cin>>a[i][j];
	}
	int wynik = INT_MAX;
	for(int maska = 0; maska < (1<<n); maska++) {
		int lvl[m] = {0};
		int w = 0;
		for(int j=0; j<n; j++) {
			if((1<<j) & maska) {
				w+=c[j];
				for(int z=0; z<m; z++) {
					lvl[z]+=a[j][z];
				}
			}
		}
		bool czy = 1;
		for(int j=0; j<m; j++) {
			if(lvl[j] < x) {
				czy = 0;
				break;
			}
		}
		if(czy)
			wynik = min(wynik, w);
	}
	if(wynik == INT_MAX)
		cout<<-1;
	else
		cout<<wynik;
}


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

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

	int paper[15][15] = {};
	// (0, 0) -> (2, 2)
	// (9, 9) -> (11, 11) ??¨??????

	int x, y, size;
	char c1, c2;
	while(cin >> x >> c1 >> y >> c2 >> size){
		x += 2;
		y += 2;

		if(size >= 1){
			paper[x][y] ++;
			paper[x + 1][y] ++;
			paper[x - 1][y] ++;
			paper[x][y + 1] ++;
			paper[x][y - 1] ++;
		}

		if(size >= 2){
			paper[x + 1][y + 1] ++;
			paper[x + 1][y - 1] ++;
			paper[x - 1][y + 1] ++;
			paper[x - 1][y - 1] ++;
		}

		if(size >= 3){
			paper[x + 2][y] ++;
			paper[x - 2][y] ++;
			paper[x][y + 2] ++;
			paper[x][y - 2] ++;
		}
	}

	int ans1 = 0;
	int ans2 = 0;
	for(int i = 2; i < 10 + 2; ++i){
		for(int j = 2; j < 10 + 2; ++j){
			if(paper[i][j] == 0){
				ans1++;
			}

			ans2 = max(ans2, paper[i][j]);
		}
	}

	cout << ans1 << endl;
	cout << ans2 << endl;

	return 0;
}

Measured memory_bytes: 1188
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


using ll=long long;

class mod_ll
{
public:
	ll m_v;
	static const ll m_m=1000000007; // prime value ex. 1000000009
	mod_ll(ll v=0) : m_v(v) {}
	mod_ll operator = (ll rhs)
	{
		m_v=rhs%m_m;
		return *this;
	}
	ll operator ()(){return m_v;}
	mod_ll operator = (mod_ll rhs)
	{
		m_v=rhs.m_v;
		return *this;
	}
	mod_ll operator += (ll rhs)
	{
		m_v=(m_v+rhs)%m_m;
		return *this;
	}
	mod_ll operator += (mod_ll rhs)
	{
		m_v=(m_v+rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator + (mod_ll rhs)
	{
		auto ret=*this;
		return ret+=rhs;
	}
	mod_ll operator -= (mod_ll rhs)
	{
		m_v=(m_v-rhs.m_v+m_m)%m_m;
		return *this;
	}
	mod_ll operator - (mod_ll rhs)
	{
		auto ret=*this;
		return ret-=rhs;
	}
	mod_ll operator *= (ll rhs)
	{
		m_v=(m_v*rhs)%m_m;
		return *this;
	}
	mod_ll operator *= (mod_ll rhs)
	{
		m_v=(m_v*rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator * (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret*=rhs;
	}
	mod_ll operator ^ (ll rhs)
	{
		mod_ll t=*this;
		mod_ll ret(1LL);

		for(;rhs>0;rhs>>=1)
		{
			if(rhs&1) ret*=t;
			t*=t;
		}
		return ret;
	}
	mod_ll operator /= (mod_ll rhs)
	{
		return *this*=(rhs^(m_m-2));
	}
	mod_ll operator /= (ll rhs)
	{
		mod_ll t(rhs);
		return *this/=t;
	}
	mod_ll operator / (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret/=rhs;
	}
};


mod_ll mod_fact(int n)
{
	static vector<mod_ll> memo(1);

	if((int)memo.size()<=n)
	{
		if(memo.size()==1)
		{
			memo[0]=1;
		}
		for(int i=memo.size();i<=n;i++)
		{
			memo.push_back(memo.back()*i);
		}
	}
	return memo[n];
}


mod_ll mod_nCr(int n, int r)
{
	mod_ll bunsi=mod_fact(n);
	mod_ll bunbo=mod_fact(n-r)*mod_fact(r);
	return bunsi/bunbo;
}


mod_ll mod_nPr(int n, int r)
{
	mod_ll ret(1);

	for(int i=0;i<r;i++)
	{
		ret*=(n-i);
	}
	return ret;
}


int main(void)
{
	int n, k;
	while(scanf("%d%d", &n, &k)==2)
	{
		mod_ll ans;
		if(k<=n-1)
		{
			ans=1;
			for(int i=1;i<=k;i++)
			{
				auto t1=mod_nCr(n-1, i);
				auto t2=mod_nCr(n, i);
				auto t=t1*t2;
				ans+=t;
//				printf("i=%d t1=%lld t2=%lld t=%lld ans=%lld\n", i, t1(), t2(), t(), ans());
			}
		}
		else
		{
			ans=mod_nCr(n*2-1, n);
		}
		printf("%lld\n", ans());
	}
	return 0;
}


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

int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i{0}; i<N; ++i)
        cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    int sumA{0}, sumB{0};
    for(int i{0}; i<N; i+=2){
        sumA += a[i];
        sumB += a[i+1];
    }

    cout << sumA - sumB;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long i,j;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	long long t=1,k,c=0,temp,n,m,flag=0;
	string st,sn,sm;
	cin >> t;
	vector <pair<string,long long> > a;
	for(i=0;i<t;i++){
		cin>> st >> temp;
		a.push_back(make_pair(st,temp));
	}
	cin >> sn;
	for(i=0;i<a.size();i++){
		if(flag==1) c+=a[i].second;
		if(a[i].first==sn) flag=1;
	}
	cout << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int N,M; cin>>N>>M;
  vii keys(M);
  rep(i,M) {
    int a,b; cin>>a>>b;
    int s=0;
    rep(i,b) {
      int t; cin >> t;
      s |= (1<<(t-1));
    }
    keys[i]=ii(s,a);
  }
  vi dp(1<<N, INF);
  dp[0] = 0;
  rep(i, 1<<N) {
    rep(j, M) {
      int t = i | keys[j].first;
      int cost = dp[i]+keys[j].second;
      dp[t] = min(dp[t], cost);
    }
  }
  int ans = 0;
  if (dp.back() == INF) {
    ans = -1;
  } else {
    ans = dp.back();
  }
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int an[SIZE];
int main(){
    int n;
    R(n);
    VI d[3];
    REP(i,n){
        int x;
        R(x);
        if(x%4==0)d[2].PB(x);
        else if(x%2==0)d[1].PB(x);
        else d[0].PB(x);
    }
    if(SZ(d[2])*2+max(1,SZ(d[1]))>=n)W("Yes");
    else W("No");
    return 0;
}


Measured memory_bytes: 1012
#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn scan_split<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_split_with<T: std::str::FromStr>(ch: char) -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split(ch)
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_lines<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| scan::<T>()).collect()
}

#[allow(unused_macros)]
macro_rules! scan_as_tuple {
    ( $t:ty ) => {
        (scan::<$t>(),)
    };
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok();
            let v = s.trim().split_whitespace();
            let mut it = v;
            let ret = ( $(it.next().unwrap().parse::<$t>().ok().unwrap()),* );
            assert!(it.next() == None, "not all tokens consumed");
            ret
        }
    };
}

fn main() {
    let s = scan_split::<String>();
    println!(
        "{}", s.iter().map(|x| x.chars().nth(0).unwrap()
        .to_uppercase().next().unwrap()).collect::<String>()
    );
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int  is(string str)
{
    // Start from leftmost and rightmost corners of str
    int l = 0;
    int h = str.size()- 1;

    // Keep comparing characters while they are same
    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return -1;
        }
    }
   return 1;

}
int isPalindrome(string str,int l,int h)
{
    // Start from leftmost and rightmost corners of str


    // Keep comparing characters while they are same
    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return -1;
        }
    }
    return 1;

}

 main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //#define int long long int
    string s;
    cin>>s;
    int n=s.size();
    if(isPalindrome(s,0,(((n-1)/2))-1)==1 && isPalindrome(s,((n+3)/2)-1,n-1)==1 && is(s)==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int n; cin>>n;
    long long int ans=0;
    for(int i=1; i<=n; i++) {
        if(i%3==0) continue;
        else if (i%5==0) continue;
        else ans+=i;

    }
    cout<<ans;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b,int &x,int &y)
{
	if(b==0)
	{
		x=1; y=0;
		return a;
	}
	int g=gcd(b,a%b,x,y);
	int t1=y;
	int t2=x-(a/b)*y;
	x=t1;
	y=t2;
	return g;
}
int main() {
	// your code goes here
	long long n; cin>>n;
	cout<<ceil(n*1.0/2);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1;i <= n;i++){
        int cnt = 0;
        if (i % 2 != 0){
            for (int j = 1;j <= i;j++){
                if(i % j == 0){
                    cnt++;
                }
            }
            if (cnt == 8){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
typedef long long ll;
const ll mod=pow(10,9)+7;
int main()
{
    ll n;
    cin >> n;

    ll ans = 0;

    for(int i=1; i<n; i++){
        ans += (n-1)/i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
 
#define MIN(a,b) ((a) > (b) ? (b) : (a))
 
int N;
int main(void)
{
    int res[100001];
    int i, j;
    scanf("%d", &N);
 
    /* 1円を入れた場合 */
    for(i=0; i<=N; i++) res[i] = i;
 
    /* 6^n円を入れた場合 */
    for(i=6; i<=N; i*=6){
        for(j=0; (i+j)<=N; j++) res[i+j] = MIN(res[i+j], res[j]+1);
    }
 
    /* 9^n円を入れた場合 */
    for(i=9; i<=N; i*=9){
        for(j=0; (i+j)<=N; j++) res[i+j] = MIN(res[i+j], res[j]+1);
    }
 
    printf("%d\n", res[N]);
 
    return 0;
}

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

#define INF 1234567890
#define ll long long

/*
	MCMF O(VEf), Min Cost, Using SPFA Version
	주의 : 문제가 MCF를 요구하는 경우도 있으니 잘 확인하자.
	MCMF mcmf(V) : 정점 V개로 그래프를 생성한다.
	mcmf.AddEdge(a, b, c, w) : (a, b) 간선을 용량 c, 비용 w로 생성한다.
	mcmf.Run(src, snk) : MCMF를 찾고 {flow, cost}를 리턴한다.
*/
struct MCMF_Edge {
	int next, rev, c, f;
	ll w;
};
struct MCMF {
	vector<vector<MCMF_Edge> > g;
	vector<int> p, pp;
	queue<int> q;
	vector<ll> dist;
	vector<bool> inq;
	int V;
	MCMF(int _V) { V = _V; g.resize(V); }
	void AddEdge(int a, int b, int c, ll w) {
		g[a].push_back({ b, (int)g[b].size(), c, 0, w });
		g[b].push_back({ a, (int)g[a].size() - 1, 0, 0, -w });
	}
	pair<int, ll> Run(int src, int snk) {
		pair<int, ll> ret = { 0, 0 };
		while (1) {
			p = vector<int>(V, -1); p[src] = src;
			pp = vector<int>(V, -1); pp[src] = src;
			while (!q.empty()) q.pop(); q.push(src);
			dist = vector<ll>(V, 4e18); dist[src] = 0; // 4e18?
			inq = vector<bool>(V, false); inq[src] = true;
			while (!q.empty()) {
				int n = q.front(); q.pop(); inq[n] = false;
				for (int i = 0; i < g[n].size(); i++) {
					int next = g[n][i].next;
					ll ncost = dist[n] + g[n][i].w;
					if (g[n][i].c - g[n][i].f > 0) {
						if (dist[next] > ncost) {
							dist[next] = ncost;
							p[next] = n;
							pp[next] = i;
							if (inq[next] == false) {
								q.push(next);
								inq[next] = true;
							}
						}
					}
				}
			}
			if (p[snk] == -1) break;
			//if (dist[snk] >= 0) break; // Min Cost Flow?
			int flow = 1234567890; // 1234567890?
			for (int i = snk; i != src; i = p[i])
				flow = min(flow, g[p[i]][pp[i]].c - g[p[i]][pp[i]].f);
			for (int i = snk; i != src; i = p[i]) {
				auto &edg = g[p[i]][pp[i]];
				edg.f += flow; g[edg.next][edg.rev].f -= flow;
				ret.second += flow * edg.w;
			}
			ret.first += flow;
		}
		return ret;
	}
};

int N, M;
string s[55];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	MCMF mcmf(N*M+2);
	int src = N*M, snk = N*M+1;
	for(int i=0; i<N; i++)
		cin >> s[i];
	for(int i=0; i<N; i++)
		for(int j=0; j<M; j++)
		{
			if (s[i][j] == 'o') mcmf.AddEdge(src, i*M+j, 1, 0);
			if (s[i][j] != '#') mcmf.AddEdge(i*M+j, snk, 1, 0);

			if (i+1 != N && s[i+1][j] != '#')
				mcmf.AddEdge(i*M+j, (i+1)*M+j, 100, -1);
			if (j+1 != M && s[i][j+1] != '#')
				mcmf.AddEdge(i*M+j, i*M+j+1, 100, -1);
		}
	cout << (-mcmf.Run(src, snk).second);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    ll x;
    cin >> x;

    vector<ll> D;
    for(ll d = 1; d*d <= x; d++){
        if (x%d == 0){
            D.push_back(d);
            D.push_back(x/d);
        }
    }

    for(ll d : D) {
        for (ll a = -3000; a <= 3000; a++) {
            ll b = a - d;
            ll d2 = a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b;
            if (d2*d == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }


    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ans;
    ans = a+b+c;
    
    if(ans >= 22)cout << "bust" << endl;
    else{
        cout << "win" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inS = Console.ReadLine().Split(' ');
            int N = int.Parse(inS[0]);
            int M = int.Parse(inS[1]);

            Console.WriteLine((3 * N + M) / 2);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

int main() {
	int N;

	cin >> N;

	if (N % 2 == 0)cout << N << endl;
	else cout << N * 2 << endl;

	return 0;
}


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

int main(){
  int a,b,l;
  cin>>a>>b>>l;
  set<int> s;
  for(int i=a;i<=b;i++){
  	if(i<a+l or i>b-l) s.insert(i);
  }
  for(auto i:s)cout<<i<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#include <cstring>
#include <typeinfo>
#include <utility>
#define REP(i,n) for(int i = 0;i < n ;i++)
#define FOR(i,m,n) for(int i= m ;i<n;i++)
using namespace std;

int main(void){
  string str,str2="CODEFESTIVAL2016";
  cin >> str;
  int i;
  int count=0;
  for(i=0;i<16;i++){
    if(str[i]!=str2[i])count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace Frog_Going_Straight
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int d = int.Parse(s[0]);
            int l = int.Parse(s[1]);
            Console.WriteLine("{0}", d / l + d % l);
        }
    }
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b, c;
    cin >> a >> b >> c;

    // 処理
    // 出力
    cout << max({a, b, c}) - min({a, b, c}) << endl;

    return 0;
}


Measured memory_bytes: 256
n, y = gets.chomp.split.map(&:to_i)
_i, _j, _k = -1, -1, -1

(0..n).each do |i|
  (0..n-i).each do |j|
    if 10000 * i + 5000 * j + 1000 * (n-i-j) == y      
      _i, _j, _k = i, j, (n-i-j)
      break
    end
  end
end
puts "#{_i} #{_j} #{_k}"

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

int main(){
    int x,y;
    int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    cin >> x >> y;
    cout << (a[x] == a[y] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map { it.toLong() }
    
    val cumsum = Array(n + 1) { 0L }
    val memo = mutableMapOf<Long, Long>()
    memo[0] = 1
    for (i in 0 until an.size) {
        var sum = cumsum[i] + an[i]
        cumsum[i + 1] = sum

        memo[sum] = memo.getOrPut(sum) { 0 } + 1
    }

    val ans = memo.filter { it.value >= 2 }.map { it.value * (it.value - 1) / 2 }.sum();
    println(ans)

}

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

int main() {
  int n,a;
  cin>>n>>a;
  bool b=false;
  for(int i=0;i<=a;i++){
      int tmp=n;
      tmp-=i;
      if(tmp%500==0){
          b=true;
          break;
      }
  }
  if(b){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
Oh, can you tell me, can you tell me the way the story ends?
A monster in my heart
A ghost inside my chest
I'm broken down, the world around us
Surround my suffering
You smile and laugh at me
But you don't see a thing

Damaged and broken as I am
I'm trying not to breathe
Unraveled, I'm not unraveled by
The truth I finally see, freeze

I'm breakable, unbreakable
I'm shakeable, unshakeable
Unraveling since I found you

And now I'm turning to dust in a world that's twisted
Don't come searching when I go missing
Close your eyes or just try to look away
Don't want to hurt you
We live in a world someone else imagined
The ghost of what's left of me all but vanished
Remember my heart, how bright I used to shine

Entangled in the loneliness
The memory of innocence
It's stinging me, it's breaking me
The pain is spreading endlessly
I cannot move, I close my eyes
I try to breathe, I realize -
I'm paralyzed, I'm paralyzed
UNRAVEL THE WORLD

I'm not what I was then
Don't touch the infection
Entwined we will both die
So stay away, and stay alive
I'm breakable, unbreakable
I'm shakeable, unshakeable
Unraveling, I won't infect you!

Now I'm turning to dust in a world that's twisted
Don't come searching when I go missing
Close your eyes or just try to look away
Don't want to hurt you
We live in a world someone else imagined
The ghost of what's left of me all but vanished
Remember my heart, how bright I used to shine

Please, just don't forget me...
Just don't forget me
Just don't forget me
Just don't forget me
Don't forget me

We live in a world someone else imagined
The ghost of what's left of me all but vanished
Remember my heart, how bright I used to shine

Oh, can you tell me?
Oh, can you tell me?
A monster in my heart
And now there's nothing left
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=500020;

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
     
      ll n,k;
      cin>>n>>k;
      n=(n+1)/2;
      if(k<=n)
      {
        cout<<"YES";
      }
      else cout<<"NO";
}


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

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

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: String = read();

    if N.contains("7") {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

int main(){
    int x ,y;
    int n = 0;
    vector<int> a;
    cin >> x >> y;
    if(x > y){
        int p = y;
        y = x;
        x = p;
    }
    int mod = x % y;
    if(mod == 0)a.push_back(y);
    for(int l = 1; mod / l >l;l++){
        if(mod % l ==0){
            a.push_back(l);
            a.push_back(mod / l);
        }
    }
    sort(a.begin(),a.end(),greater<int>());
    for(auto k : a){
        int o = y%k;
        if(o == 0){
                cout << k <<endl;
                break;
        }
    }
}


Measured memory_bytes: 3148
#include<stdio.h>
#include<string.h>
int main()
{
    char s[11],s1[11];
    int i;
    scanf("%s",s);
for(i=0;i<10;i++)
{
    if(i==0)
    {
         s1[i]='2';
    }
    else if(i==1)
    {
         s1[i]='0';
    }
    else if(i==2)
    {
         s1[i]='1';
    }
    else if(i==3)
    {
         s1[i]='8';
    }
    else
    {
        s1[i]=s[i];
    }
    printf("%c",s1[i]);


}
 printf("\n");


    return 0;

}


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

int main(){
    int N, i, j, k, num = 0;
    cin >> N;
    vector<int> tri(N);
    for(i = 0; i < N; i++){
        cin >> tri[i];
    }
    sort(tri.begin(), tri.end());
    for(i = 0; i < N-2; i++){
        for(j = i+1; j < N-1; j++){
            for(k = j+1; k < N; k++){
                if(tri[k] < tri[j] + tri[i])num++;
                else break;
            }
        }
    }
    cout << num << endl;
}

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

int main()
{
  int n;
  cin >> n;
  
  int v[n];
  rep(i,n) cin >> v[i];
  
  sort(v,v+n);
  
  ld ans = (v[0] + v[1]) / 2.0; 
  for(int i = 2; i < n; i++)
  {
    ans = (long double)( (ans + v[i]) / 2.0 );
  }
  
  cout << fixed;
  cout << setprecision(20);
  cout << ans << endl;
  
}

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

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

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int s; cin >> s;
    int l = s / 100, r = s % 100;
    if (1 <= l && l <= 12) {
        if (1 <= r && r <= 12) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    } else {
        if (1 <= r && r <= 12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static int H, W, A, B;
    const int MOD = 1000000007;
    static long[] x;
    static long[] xx;
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        H = int.Parse(s[0]);
        W = int.Parse(s[1]);
        A = int.Parse(s[2]);
        B = int.Parse(s[3]);
         x = new long[H + W - 1];
        xx = new long[H + W - 1];
        x[0] = 1;
        xx[0] = 1;
        for(int i = 1; i <= H + W - 2; i++)
        {
            x[i] = (x[i - 1] * i) % MOD;
            xx[i] = Pow(x[i], MOD - 2);
        }
        long cnt = 0;
        for(int i = B; i < W; i++)
        {
            long a = nCm(H-A-1+i,i);
            a = (a * nCm(W-1-i+A-1 , A-1)) % MOD;
            cnt = (cnt + a) % MOD;
        }
        Console.WriteLine(cnt);
    }
    static long nCm(int n,int m)
    {
        long a = (x[n] * xx[m]) % MOD;
        return (a * xx[n - m]) % MOD;
    }
    static long Pow(long x, long y)
    {
        long r = 1;
        long p = x % MOD;
        while (y > 0)
        {
            if (y % 2 == 0)
            {
                p = (p * p) % MOD;
                y /= 2;
            }
            else
            {
                r = (r * p) % MOD;
                y--;
            }

        }
        return r;
    }
}





Measured memory_bytes: 5848
#coding: utf-8
import math
import heapq
import bisect
#from scipy.misc import comb

MOD = 10**9+7

W,H,x,y = map(int, input().split())

print(W*H/2)

if x==W/2 and y==H/2:
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
n, k = map(int, input().split())

if k > (n - 1) * (n - 2) // 2:
    print(-1)
    exit()

ans = [[0 for _ in range(n)] for _ in range(n)]

for i in range(1, n):
    ans[0][i] = 1

m = n-1

temp = (n-1) * (n-2) // 2 - k
for i in range(1, n):
    if temp == 0:
        break
    for j in range(i+1, n):
        ans[i][j] = 1
        m += 1
        temp -= 1
        if temp == 0:
            break

print(m)
for i in range(n):
    for j in range(n):
        if ans[i][j] == 1:
            print(i+1, j+1)

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

using namespace std;

#define MAX 100
#define INF 1e9

int main() {
	int d, n; cin >> d >> n;
	vector<int> t(d), a(n), b(n), c(n);
	vector < vector<int> > dp(d, vector<int>(MAX + 1, -INF));
	for (int i = 0; i < d; ++i) cin >> t[i];
	for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];

	for (int i = 0; i < d; ++i) {
		for (int j = 0; j < n; ++j) {
			if (a[j] <= t[i] && t[i] <= b[j]) {
				if (i == 0) {
					dp[i][c[j]] = 0;
					continue;
				}
				for (int k = 0; k <= MAX; ++k) {
					dp[i][c[j]] = max(dp[i][c[j]], dp[i - 1][k] + abs(k - c[j]));
				}
			}
		}
	}
	cout << *max_element(dp[d - 1].begin(), dp[d - 1].end()) << endl;

	return 0;
}


Measured memory_bytes: 3244
N,Y = [int(i) for i in input().split()]

# x+y+z = N
# 10000x + 5000y + 1000z = Y
# これを変形して
# 9000x + 4000y = Y - 1000Nが成り立つような
# 整数x,yの組を調べればO(N)な気がする

# y = (-9000x + Y - 1000N) / 4000

is_found = False
for x in range(0,N+1) :
    y = (-9000*x + Y - 1000* N) / 4000
    # print("x : " + str(x) + " y : " + str(y))
    if (y >= 0 and x + y <= N and float.is_integer(y)) :
        is_found = True
        print(x,int(y),int(N-x-y))
        break

if (not is_found) :
    print("-1 -1 -1")


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int id;
  int parent;
  int left;
  int right;
}Node;
int main(){
  int n,x;
  int i;
  Node *T;
  
  scanf("%d",&n);
  T=(Node*)malloc(sizeof(Node)*(n+1));
  for(i=1;i<=n;i++){//入力
    scanf("%d",&x);
    T[i].id=x;
    T[2*i].parent=x;
    T[2*i+1].parent=x;
    if(i%2==0)T[i/2].left=x;
    else T[(i-1)/2].right=x;
    }
  for(i=1;i<=n;i++){//出力
    printf("node %d: key = %d, ",i,T[i].id);
    if(T[i].parent!=0)printf("parent key = %d, ",T[i].parent);
    if(T[i].left!=0)printf("left key = %d, ",T[i].left);
    if(T[i].right!=0)printf("right key = %d, ",T[i].right);
    printf("\n");
    } 
  // printf("node 1: key = 10, left key = 8, right key = 5,\n");
  //printf("node 2: key = 8, parent key = 10, left key = 1, right key = 2,\n");
  //printf("node 3: key = 5, parent key = 10, left key = 3,\n");
  //printf("node 4: key = 1, parent key = 8,\n");
  //printf("node 5: key = 2, parent key = 8,\n");
  //printf("node 6: key = 3, parent key = 5,\n");
  return 0;
}



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

const int maxn(2e5 + 5);

int n, x, y, lim[maxn], fa[maxn], ans, dis[maxn];
queue <int> q;
vector <int> edge1[maxn], edge2[maxn];

# define Orzyyb puts("-1"), exit(0)

inline void Add1(int u, int v) {
	edge1[u].push_back(v), edge1[v].push_back(u);
}

inline void Add2(int u, int v) {
	edge2[u].push_back(v), edge2[v].push_back(u);
}

inline int Dis(int x, int y) {
	if (fa[x] == y || fa[y] == x) return 1;
	if (fa[x] == fa[y] || fa[fa[x]] == y || fa[fa[y]] == x) return 2;
	return 233;
}

int main() {
	int i, u, v;
	scanf("%d%d%d", &n, &x, &y);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), Add1(u, v);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), Add2(u, v);
	lim[y] = 1, q.push(y);
	while (!q.empty()) {
		u = q.front(), q.pop();
		for (auto to : edge2[u])
			if (!lim[to]) fa[to] = u, lim[to] = lim[u] + 1, q.push(to);
	}
	for (i = 1; i <= n; ++i) --lim[i];
	dis[x] = 1, q.push(x);
	while (!q.empty()) {
		u = q.front(), q.pop();
		if (dis[u] - 1 > lim[u]) continue;
		ans = max(ans, lim[u]);
		if (dis[u] - 1 == lim[u]) continue;
		for (auto to : edge1[u]) if (Dis(u, to) > 2) Orzyyb;
		for (auto to : edge1[u])
			if (!dis[to]) dis[to] = dis[u] + 1, q.push(to);
	}
	printf("%d\n", ans << 1);
    return 0;
}

Measured memory_bytes: 26740
n = int(input())
a = [0] * 4
for i in range(n):
  s = input()
  if s == "AC":
    a[0] += 1
  elif s == "WA":
    a[1] += 1
  elif s == "TLE":
    a[2] += 1
  else:
    a[3] += 1
print("AC x " + str(a[0]))
print("WA x " + str(a[1]))
print("TLE x " + str(a[2]))
print("RE x " + str(a[3]))


Measured memory_bytes: 9052
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#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 all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
vector<int> par(100010),dis(100010,0);
vector<vector<int>> g(100010);
void dfs(int v){
    for (int u:g[v]){
        if (u == par[v]) continue;
        dis[u] = dis[v]+1;
        par[u] = v;
        dfs(u);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,u,v,a,b;
    cin >> n >> u >> v;
    --u;
    --v;
    rep(i,n-1){
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dis[v] = 0;
    par[v] = -1;
    dfs(v);
    int d = 0,ans = 0;
    if (dis[u]%2){
        d = dis[u]/2;
        ans += dis[u]-d;
    }
    else{
        d = dis[u]/2-1;
        ans += dis[u]-d;
    }
    int k = u;
    rep(i,d) k = par[k];
    dis.assign(n,-1);
    dis[k] = 0;
    dfs(k);
    d = 0;
    rep(i,n){
        chmax(d,dis[i]);
    }
    ans += d-1;
    PRINT(ans);
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
 
using namespace std;
 
int LevenshteinDistance(string s, string t) {
   
  int len_s = s.size();
  int len_t = t.size();
   
  vector<vector<int> > dp(len_s+1, vector<int>(len_t+1, 0));
 
  for(int i=0; i<=len_s; i++)
    dp[i][0] = i;
   
  for(int i=0; i<=len_t; i++)
    dp[0][i] = i;
   
  int cost;
  for(int i=1; i<=len_s; i++) {
    for(int j=1; j<=len_t; j++) {
      if(s[i-1] == t[j-1]) cost = 0;
      else cost = 1;
       
      dp[i][j] = min(dp[i-1][j] + 1, min(dp[i][j-1] + 1, dp[i-1][j-1] + cost));
    }
  }
   
  return dp[len_s][len_t];
}
 
int main() {
   
  string s, t;
   
  cin >> s >> t;
   
  cout << LevenshteinDistance(s, t) << endl;
   
  return 0;
}

Measured memory_bytes: 4964
N = int(input())
list_r = []
for i in range(N):
    a,b = input().split()
    list_r.append((i+1, a, int(b)))
sorted_list=sorted(list_r, key=lambda x:(x[1],-x[2]))

for i in range(N):
    print(sorted_list[i][0])

Measured memory_bytes: 3060
/*
AizuOnline A1208
Title Rational Irrationals
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
#include <math.h>
//#include <limits.h>
//Global data section
int n,p;
int x,y,u,v;
//
calc_kinji_more(int p1,int n1,int * x,int * y)
{
        int savex,savey;
        int i;
        int bunsi;

        for(i=1;i<=n1;i++)
        {
                bunsi = (double)i*sqrt((double)p1)+1;
                if(bunsi > n1)
                        continue;
                //printf("::%d/%d",bunsi,n1);  
                if(i==1 ||(double)savex/(double)savey > (double)bunsi/(double)i)
                {
                        savex=bunsi;
                        savey=i;
                }
        }
        *x=savex;
        *y=savey;
}
calc_kinji_less(int p1,int n1,int * x,int * y)
{
        int savex,savey;
        int i;
        int bunsi;

         for(i=1;i<=n1;i++)
        {
                bunsi = (double)i*sqrt((double)p1);
                if(bunsi > n1)
                        continue;
                //printf("i%d/%d\n",bunsi,i);
               if(i==1 ||
                  ((double)savex)/((double)savey) < ((double)bunsi)/((double)i))
                {
                        savex=bunsi;
                        savey=i;
                }
        }
        *x=savex;
        *y=savey;
}

main()
{
        while(EOF!=scanf("%d %d",&p,&n) && (n||p))
        {
                calc_kinji_more(p,n,&x,&y);
                calc_kinji_less(p,n,&u,&v);
                printf("%d/%d %d/%d\n",x,y,u,v);
        }
return(0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
typedef long long LL;
inline int rd() {int r;scanf("%d",&r);return r;}

struct Edge{int b,v,n;}e[2*N];
int siz[N],h[N],cnt,mark,g,n;
LL ans;

void link(int a,int b,int v) {
    e[++cnt] = (Edge){b,v,h[a]}, h[a] = cnt;
}

void dfs(int u,int f,int p) {
    siz[u] = 1;
    int mx = 0;
    for (int i=h[u];i;i=e[i].n) {
        int v = e[i].b, cp = e[i].v;
        if (v == f) continue;
        dfs(v, u, cp);
        siz[u] += siz[v];
        mx = max(mx, siz[v]);
    }
    mx = max(mx, n-siz[u]);
    if (siz[u]*2 == n) mark = p;
    if (mx*2 <= n) g = u;
    ans += 2LL * p * min(siz[u], n-siz[u]);
}

int main() {
    n = rd();
    for (int i=1;i<n;i++) {
        int a = rd(), b = rd(), c = rd();
        link(a, b, c);
        link(b, a, c);
    }

    dfs(1,1,0);

    if (!mark) {
        mark = 2147483647;
        for (int i=h[g];i;i=e[i].n)
            mark = min(e[i].v, mark);
    }
    cout << ans - mark << endl;
    return 0;
}

Measured memory_bytes: 15488
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int n, x, t; cin >> n >> x >> t;
  int ans = t *((n-1) / x + 1);
  cout << ans << endl;
}


Measured memory_bytes: 3620