akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    ll n = s.size();
    ll flag = 0;
    ll j = n-1;
    j/=2;
    j--;
    ll k = j;
    for(ll i=0;i<=j;i++)
    {
        if(s[i] != s[k])
        {
            flag = 1;
            break;
        }
        k--;
    }
    if(flag)
    {
        cout<<"No";
        return 0;
    }
    flag = 0;
    j = n+3;
    j /= 2;
    j--;
    k = n-1;
    for(ll i=j;i<n;i++)
    {
        if(s[i] != s[k])
        {
            flag = 1;
            break;
        }
        k--;
    }
    if(flag)
    {
        cout<<"No";
        return 0;
    }
    flag = 0;
    ll i = 0;
    j = n-1;
    while(i<=j)
    {
        if(s[i] != s[j])
        {
            flag = 1;
            break;
        }
        i++;
        j--;
    }
    if(flag)
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
}


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

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

	int			n;
	int			max;
	int			second_max;
	cin >> n;
	vector<int>	A(n);
	vector<int>	B;

	/* rep(i, n) */
	/* 	cin >> A.at(i); */
	for (int &a : A)
		cin >> a;
	B = A;
	sort(B.rbegin(), B.rend());
	max = B.at(0);
	second_max = B.at(1);
	rep(i, n)
	{
		if (A.at(i) != max)
			cout << max << endl;
		else
			cout << second_max << endl;
	}
}


Measured memory_bytes: 3200
#include <stdio.h>
 
int main(){
	long long a,b,x;
	scanf("%lld %lld %lld",&a,&b,&x);
  
	if(a == 0ll) printf("%lld\n",(b / x) + 1ll);
	else printf("%lld\n",(b / x) - ((a - 1ll) / x));
  
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += a - 1;
    }
    cout << sum << endl;
}


Measured memory_bytes: 384
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false); 
int bit[4123];
int posb[4234],posw[4123],a[4123];
string c[4123];  
int update(int pos,int val){
	while(pos<4123){
		bit[pos]+=val;
		pos+=pos&(-pos);
	}
	return 0;
}
int query(int pos){
	int ans=0;
	while(pos>0){
		ans+=bit[pos];
		pos-=pos&(-pos);
	}
	return ans;

}
int dp[2123][2123];
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int i;
    int j;
    rep(i,2*n){
    	cin>>c[i]>>a[i];

    	if(c[i]=="W")
    		posw[a[i]]=i+1;
    	else
    		posb[a[i]]=i+1;
    }
    f(i,1,n+1){
    	update(posw[i],1);
    }
   	rep(i,n+1){
   		f(j,1,n+1){
   			update(posb[j],1);
   		}
   		rep(j,n+1){
   			if(i==0 && j==0){
   				dp[i][j]=0;
   			}
   			else{
   				dp[i][j]=inf;
   			}
   			if(j!=0){
   				if(i!=0)
   					update(posw[i],-1);
   				dp[i][j]=min(dp[i][j],dp[i][j-1]+query(posb[j])-1);
   				if(i!=0)
   					update(posw[i],1);
   			}
   			if(i!=0){
   				if(j!=0)
   					update(posb[j],-1);
   				dp[i][j]=min(dp[i][j],dp[i-1][j]+query(posw[i])-1);
   				if(j!=0)
   					update(posb[j],1);
   			}
   			if(j!=0)
   				update(posb[j],-1);

   		}
   		if(i!=0){
   			update(posw[i],-1);
   		}
   	}
   	cout<<dp[n][n]<<endl;

    return 0;  
    
}



Measured memory_bytes: 17152
def main():
    MOD = 10 ** 9 + 7

    H, W, K = map(int, input().split())

    dp = [[0] * W for _ in range(H + 1)]
    dp[0][0] = 1
    # 横線[0,H)
    # H->終着点

    for h in range(H):
        for bit in range(1 << (W - 1)):
            if '11' in bin(bit): continue
            toes = list(range(W))
            for j in range(W - 1):
                if (bit >> j) & 1:
                    toes[j], toes[j + 1] = toes[j + 1], toes[j]
            for frm, to in enumerate(toes):
                dp[h + 1][to] = (dp[h + 1][to] + dp[h][frm]) % MOD
    ans = dp[H][K - 1]
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()


Measured memory_bytes: 3064
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
r,s,p = inpm()
T = input()

cnt_r = T.count('r')
cnt_s = T.count('s')
cnt_p = T.count('p')
ans = cnt_r * p + cnt_s * r + cnt_p * s

tmp = [0]*n
for i in range(k,n):
    if tmp[i-k] == 1:
        continue
    if T[i] == T[i-k]:
        tmp[i] = 1
        if T[i] == 'r':
            ans -= p
        elif T[i] == 's':
            ans -= r
        elif T[i] == 'p':
            ans -= s
print(ans)

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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second
 
Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int a, b, c;
    cin >> a >> b >> c;
    dump(a + b + c >= 22 ? "bust" : "win");
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;

  vector<vector<bool>> edge(N, vector<bool>(N, true));
  if ((N % 2) == 0) {
    N_TIMES(n, N) {
      edge[n][(N - 1) - n] = false;
    }
  } else {
    N_TIMES(n, N - 1) {
      edge[n][(N - 2) - n] = false;
    }
  }

  uint64_t count = 0;
  list<pair<uint64_t, uint64_t>> edges;
  N_TIMES(n, N) {
    N_TIMES(m, n) {
      if (edge[n][m]) {
        ++count;
        edges.emplace_back(m + 1, n + 1);
      }
    }
  }

  cout << count << endl;
  for (auto &e : edges) {
    cout << e.first << ' ' << e.second << endl;
  }

  return 0;
}

Measured memory_bytes: 512
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np
from scipy.misc import comb

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W = list(map(int, sys.stdin.readline().split()))
S = [list(sys.stdin.readline().rstrip()) for _ in range(H)]
seen = np.zeros((H, W), dtype=bool)


def dfs(h, w):
    if seen[h][w]:
        return 0, 0
    seen[h][w] = True
    black = int(S[h][w] == '#')
    white = int(S[h][w] == '.')
    for dh, dw in zip([h, h, h + 1, h - 1], [w + 1, w - 1, w, w]):
        if 0 <= dh < H and 0 <= dw < W:
            if S[h][w] != S[dh][dw]:
                counts = dfs(dh, dw)
                black += counts[0]
                white += counts[1]
    return black, white


ans = 0
for h, w in itertools.product(range(H), range(W)):
    black, white = dfs(h, w)
    ans += black * white
print(ans)


Measured memory_bytes: 249956
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;
 
const int mod = (int)1e8 + 7;
int h, w, pw[11];
char in[12][12];
int dp[2][11][3][60000];
 
int main(){
  pw[0] = 1;
  rep(i, 10) pw[i + 1] = pw[i] * 3;
  
  cin >> h >> w;
  rep(i, h) cin >> in[i];
  
  int cur = 0, next = 1;
  dp[0][0][0][0] = 1;
  
  rep(i, h){
    memset(dp[next], 0, sizeof(dp[next]));
    rep(j, w){
      rep(l, 3) rep(u, pw[w]) if(dp[cur][j][l][u]){
	int tu = u / pw[j] % 3;
	
	if(in[i][j] == '.'){
	  if(tu && l) continue;
	  (dp[cur][j + 1][l][u] += dp[cur][j][l][u]) %= mod;
	  continue;
	}
	int rest = in[i][j] - '0' - tu - l;
	rep(nl, 3){
	  int nu = rest - nl;
	  if(nu < 0 || nu > 2) continue;
 	  
	  (dp[cur][j + 1][nl][u + pw[j] * (nu - tu)] += dp[cur][j][l][u]) %= mod;
	}
      }
    }
    rep(u, pw[w]) dp[next][0][0][u] = dp[cur][w][0][u];
    swap(cur, next);
  }
  cout << dp[cur][0][0][0] << endl;
  
  return 0;
}

Measured memory_bytes: 16644
N = int(input())
s_lst = [input() for i in range(N)]
M = int(input())
t_lst = [input() for i in range(M)]

dict = {}
for i in s_lst:
    dict[i] = 0
for i in t_lst:
    dict[i] = 0
for i in s_lst:
    dict[i] += 1
for i in t_lst:
    dict[i] -= 1
infinity = float('inf')
max = -infinity
for i in dict.values():
    if max < i:
        max = i
print(max) if max > 0 else print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    int len = s.size();
    int leftW[len], rightE[len];
    leftW[0] = 0;
    for (int i = 1; i <= n - 1; i++) {
        if (s[i - 1] == 'W') leftW[i] = leftW[i - 1] + 1;
        else leftW[i] = leftW[i - 1];
    }
    rightE[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
        if (s[i + 1] == 'E') rightE[i] = rightE[i + 1] + 1;
        else rightE[i] = rightE[i + 1];
    }

    int ans = 1000000;
    for (int i = 0; i < n; i++) {
        ans = min(ans, leftW[i] + rightE[i]);
    }

    cout << ans << endl;
    return 0;
}


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



void solve(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  
  vector<int> vec;
  char x = '1';
  if(s[0]=='0') {vec.emplace_back(0);
    x = '0';
  }
  int j=0;
  rep(i,n){
    if(s[i]==x){
       j++;
    }
    else{
      vec.emplace_back(j);
      j=1;
      if(x=='0') x='1';
      else x='0';
    }
  }
  vec.emplace_back(j);
  int siz = vec.size();
  //cout << vec[0] << " " << vec[1] << " " << vec[2] << " " << vec[3] << " " << vec[4] << " " << vec[5] << " " << vec[6] << " " << vec[7] << " " << vec[8] << endl;
  rep(i,2*k){
    vec.emplace_back(0);
  }
  int i = 0;
  //int p = vec.size()-2*k;
  int m = 0;
  while(i<siz){
    int sum = 0;
    for(int j=i; j<i+2*k+1; j++){
      sum += vec[j];
      //cout << vec[j] << " vec[" << j << "]" << endl;
    }
    //cout << sum << " sum" << endl;
    m = max(m, sum);
    i += 2;
  }
  cout << m << endl;
}

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


Measured memory_bytes: 1528
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

MOD = 998244353

def solve(N, D):
  D1 = D[0]
  D = D[1:]

  if D1 != 0:
    return 0

  D.sort()

  ans = 1
  prev = 0
  prevCount = 1
  cur = 0
  while cur < len(D):
    c = 0
    while cur < len(D) and D[cur] == (prev + 1):
      cur += 1
      c += 1
    if c == 0:
      return 0

    ans *= (prevCount ** c) % MOD
    ans %= MOD
    prev += 1
    prevCount = c

  return ans

def main():
  N = readInts()[0]
  D = readInts()
  print(solve(N, D))

if __name__ == "__main__":
  main()


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

#define ll long long

using namespace std;


int n;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    vector <int> v(n);
    for (int i=0; i<n; i++){
        v[i]=i+1;
    }
    vector <int> p(n);
    vector <int> q(n);
    for (int i=0; i<n; i++){
        cin>>p[i];
    }
    for (int i=0; i<n; i++){
        cin>>q[i];
    }

    int nr1=1;
    int nr2=1;
    int i;
    do{
        for (i=0; i<n; i++){
            if(v[i]!=p[i])
                break;
        }
        if (i==n) break;
        nr1++;
    }while(next_permutation(v.begin(),v.end()));

    sort(v.begin(),v.end());

    do{
        for (i=0; i<n; i++){
            if(v[i]!=q[i])
                break;
        }
        if (i==n) break;
        nr2++;
    }while(next_permutation(v.begin(),v.end()));

    cout<<abs(nr2-nr1);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(int argc, const char * argv[]) {
   
    long long x,y;
    
    scanf("%lld %lld",&x,&y);
    int cnt = 0;
    while(x<=y){
        x*=2;
        cnt++;
    }
    
    printf("%d\n",cnt);
    
    return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);static void p(int i) {System.out.println(i);}static void p(long i) {System.out.println(i);}static void p(String i) {System.out.println(i);}static void p(double i) {System.out.println(i);}
	
	//a 97 || 
	public static void main(String[] args) {
		//int N=sc.nextInt();
		//String S=sc.next();
		//for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		int M=sc.nextInt();
		int X=sc.nextInt();
		int Y=sc.nextInt();
		
		int maxX=-10000009;
		int minY=10000009;
		for(int i=0;i<N;i++) {
			int t=sc.nextInt();
			maxX=Math.max(t, maxX);
		}
		for(int i=0;i<M;i++) {
			int t=sc.nextInt();
			minY=Math.min(minY, t);
		}
		boolean x=false;
		//p(maxX+" "+minY);
		for(int i=X+1;i<=Y;i++) {
			if(i>maxX&&i<=minY) {
				x=true;
			}
		}
		if(!x)p("War");
		else p("No War");
	}
	
}
	


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

const int N=2e3+5,K=1e4+5,S=1e6+5,C=26;

#define bs bitset<S> 

int n,k,len[N],st[N];
bitset<K> f[N];
char s[N][K];

bs tr[C<<2],pos[C];

#define lk k<<1
#define rk k<<1|1
#define mid (l+r>>1)

inline void mdy(int pos,int val,int k=1,int l=0,int r=C-1){
  //if(k==1)printf("mdy %d %d\n",pos,val),cout.flush();
  tr[k][val]=1;
  if(l==r)return;
  if(pos<=mid)mdy(pos,val,lk,l,mid);
  else mdy(pos,val,rk,mid+1,r);
}

bs state;

inline int qry(int k=1,int l=0,int r=C-1){
  if(l==r)return l;
  if((state&tr[lk]).none())return qry(rk,mid+1,r);
  return qry(lk,l,mid);
}

int main(){
  scanf("%d%d",&n,&k);
  for(int i=1;i<=n;i++)scanf("%s",s[i]+1),len[i]=strlen(s[i]+1);

  f[n+1][0]=1;
  for(int i=n;i;i--){
    for(int j=k;~j;j--)f[i][j]=f[i+1][j]|(j>=len[i]?f[i+1][j-len[i]]:0);
  }

  for(int t=0,i=1;i<=n;i++){
  //  printf("i=%d v=%d\n",i,t);cout.flush();
    st[i]=t+1;
    for(int j=1;j<=len[i];j++){
      t++;
      mdy(s[i][j]-'a',t);
      pos[s[i][j]-'a'][t]=1;
    }
  }

  state[1]=1;

  string tmp;
  for(int i=1;i<=k;i++){
    for(int j=1;j<n;j++)if(state[st[j]])state[st[j+1]]=1;
    //for(int i=1;i<=k;i++)printf("%d",(int)state[i]);puts("");
    for(int j=1;j<=n;j++)if(k-i+1<len[j]||!f[j+1][k-i+1-len[j]])state[st[j]]=0;
    //printf("i=%d\n",i-1);
    //for(int i=1;i<=k;i++)printf("%d",(int)state[i]);puts("");
    int x=qry();
    tmp.push_back(x+'a');
    //printf("%c\n",x+'a');
//    putchar(x+'a');
    (state&=pos[x])<<=1;
    //printf("x=%d\n",x);
  }
  printf("%s\n",tmp.c_str());

  return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;const double PI = acos(-1);

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];
	double sum = 0;
	
	rep(i, n){
		map<double, int> m;
		m[2 * PI] = m[0] = 0;
		
		rep(j, n) if(j != i){
			double t = atan2(x[j] - x[i], y[j] - y[i]);
			if(t < 0) t += 2 * PI;
			m[t]++;
			if(t > PI){
				m[0]++;
				m[t - PI]--;
			}
			else m[t + PI]--;
		}
		//dbg(m);
		double ans = 0, prev = 0;
		int cnt = 0;
		
		for(auto p : m){
			if(cnt == n - 1) ans += p.first - prev;
			cnt += p.second;
			prev = p.first;
			if(prev >= 2 * PI) break;
		}
		sum += ans;
		printf("%.20f\n", ans / 2 / PI);
	}
	assert(abs(sum - 2 * PI) < 1e-6);
	return 0;
}

Measured memory_bytes: 384
s = input().strip()

ss = None
r = 0
ac = 0
for c in s:
    if c == "A":
        if ss == "A":
            ac += 1
        else:
            ac = 1
    elif c == "C" and ss == "B":
        r += ac
        ss = "A"
#        print(c, r,ac)
        continue
    elif c == "B" and ss == "A":
        pass
    else:
        ac = 0
    ss = c
#print(c, r,ac)
print(r)


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

int main() {
    int N, a, b, c, d;
    cin >> N;
    a = N % 10;
    b = N / 10 % 10;
    c = N / 100 % 10;
    d = N / 1000;
    
    if (a == b && b == c) {
        cout << "Yes" << endl;
    }
    else if (b == c && c == d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" <<  endl;
    }
}

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

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

vector<vector<ll> > memo(100007,vector<ll>(3,-1));
ll N;

int dp(vector<vector<int> > &ABC,ll i,ll j){
    if(i==0) return 0;

    if(memo[i][j]!=-1) return memo[i][j];
    return memo[i][j]=max(dp(ABC,i-1,(j+1)%3)+ABC[i][j],dp(ABC,i-1,(j+2)%3)+ABC[i][j]);
}

int main(){
    cin>>N;
    vector<vector<int> > ABC(N+1,vector<int>(3));
    ABC[0][0]=0,ABC[0][1]=0,ABC[0][2]=0;
    for(int i=1;i<=N;i++){
        for(int j=0;j<3;j++){
            cin>>ABC[i][j];
        }
    }
    cout<<max(max(dp(ABC,N,0),dp(ABC,N,1)),dp(ABC,N,2))<<endl;
    return 0;
}

Measured memory_bytes: 18944
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const ll MOD = TEN(9) + 7;
int n;

int main() {
    fastio();

    cin >> n;

    ll ans = 1;
    forn1(i, n) {
        ans = (ans * i) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $S);
printf("%s%s", convertStoHMS($S), PHP_EOL);

function convertStoHMS($seconds)
{
    $hour   = floor($seconds / 3600);
    $minute = floor($seconds / 60) % 60;
    $second = $seconds % 60;
    return sprintf("%d:%d:%d", $hour, $minute, $second);
}

Measured memory_bytes: 6564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)


int main()
{
    int N;cin>>N;
    vector<int>a(N);
    int sum=0,sum1=0;
    REP(i,N){cin>>a[i];sum+=a[i];if(i%2)sum1+=a[i];}
    int ans=sum-2*sum1;
    cout<<ans;
    REP(i,N-1)
    {
        ans=a[i]*2-ans;
        cout<<" "<<ans;
    }cout<<endl;
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
def prim(edges, *, start=0, adj_matrix=False, default_value=float('inf')):
    '''
    Returns the Minimum Spanning Tree(MST) of a given graph

    # sample input when given not as adjacency list (generally works faster)
    edges = [[(1, 2), (2, 5), (3, 4)],         # node 0
             [(0, 2), (3, 3), (4, 6)],         # node 1
             [(0, 5), (3, 2), (5, 6)],         # node 2
             [(0, 4), (1, 3), (2, 2), (4, 2)], # node 3
             [(1, 6), (3, 2), (5, 4)],         # node 4
             [(2, 6), (4, 4)]]                 # node 5

    # sample input when given as adjacency matrix
    edges = [[0, 2, 5, 4, inf, inf],           # node 0
             [2, 0, inf, 3, 6, inf],           # node 1
             [5, inf, 0, 2, inf, 6],           # node 2
             [4, 3, 2, 0, 2, inf],             # node 3
             [inf, 6, inf, 2, 0, 4],           # node 4
             [inf, inf, 6, inf, 4, 0]]         # node 5
    '''

    n = len(edges)
    mst = []
    cost = 0
    T = [start]

    while True:
        tmp_edges = [(cost, (u, v)) for u in T for v, cost in enumerate(edges[u]) if cost != default_value and v not in T] if adj_matrix else\
                    [(cost, (u, v)) for u in T for v, cost in edges[u] if v not in T]

        if tmp_edges:
            min_cost, min_edge = min(tmp_edges)
            mst.append(min_edge)
            cost += min_cost
            T.append(min_edge[1])

        else:
            if len(mst) != n - 1:
                raise NoSpanningError(
                    'There is no spanning tree in this graph (search started from node{})'.
                    format(start))

            else:
                return mst, cost


class NoSpanningError(Exception):
    pass


if __name__ == '__main__':
    '''
    an example of using this function
    AIZU ONLINE JUDGE - ALDS_1_12_A
    '''

    n = int(input())
    edges = [[(j, int(cost)) for j, cost in enumerate(input().split()) if int(cost) != -1] for i in range(n)]

    print(prim(edges)[1])



Measured memory_bytes: 6868
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N, M;
    vs32 X;
    cin >> N >> M;
    X.resize(M);
    rep (i, M)
    {
        cin >> X[i];
    }

    if (N >= M)
    {
        cout << "0\n";
        return 0;
    }

    sort(X.begin(), X.end());
    s32 ans = X[M - 1] - X[0];

    priority_queue<s32> pq;
    rep (i, M - 1)
    {
        pq.push(X[i + 1] - X[i]);
    }

    rep (i, N - 1)
    {
        ans -= pq.top();
        pq.pop();
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1276
import math
A,B = map(int,input().split())
ans = 0
AT = 0.08
BT = 0.1

a = A/AT
b = B/BT
aPlus = (A+1)/AT
bPlus = (B+1)/BT

if a == b :
    ans = a
elif a < b :
    if aPlus <= b :
        ans = -1
    else :
        ans = b
elif b < a :
    if bPlus <= a :
        ans = -1
    else :
        ans = a

# print(a,b)
# print(aPlus,bPlus)
print(math.ceil(ans))

Measured memory_bytes: 9124
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N,A[212345];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &A[i]);

	int max_i = -1;

	int ans = -1;
	rep(i, N) {
		if (ans < A[i]) {
			ans = A[i];
			max_i = i;
		}
	}

	int ans2 = -1;
	rep(i, N) {
		if (i != max_i) {
			ans2 = max(ans2, A[i]);
		}
	}

	rep(i, N) {
		if (i == max_i) printf("%d\n", ans2);
		else printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n;
    int A[n],B[n],C[n];
    for(int i=0;i<n;i++)
    cin>>A[i]>>B[i]>>C[i];
    int dp[n][3];
    dp[0][0]=A[0];
    dp[0][1]=B[0];
    dp[0][2]=C[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            if(j==0)
            dp[i][j]=A[i]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
            if(j==1)
            dp[i][j]=B[i]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
            if(j==2)
            dp[i][j]=C[i]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
        }
    }
    
    /*
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    cout<<endl;
    */
    cout<<max(dp[n-1][2],max(dp[n-1][0],dp[n-1][1]))<<endl;
    
}

Measured memory_bytes: 2560
import numpy as np

inf = float('inf')

N = int(input())
a = map(int, input().split())

dp = np.empty((N + 1, 2))
dp[0][0] = 0
dp[0][1] = -inf
# dp[i][0]:=1-indexedで、a_iとa_i+1を反転させない場合の最大値
# dp[i][1]:=1-indexedで、a_iとa_i+1を反転させる場合の最大値

for i, aa in enumerate(a, 0):
    dp[i + 1][0] = max(dp[i][0] + aa, dp[i][1] - aa)
    dp[i + 1][1] = max(dp[i][0] - aa, dp[i][1] + aa)
print(int(dp[N][0]))
# np.emptyのせいか、float型になっているので、WA扱いになる

# np.zerosよりも、np.emptyの方が速い？

Measured memory_bytes: 22600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
using namespace std;
using namespace __gnu_cxx;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;

string st;

int main()
{
	cin>>st;
	int n=SZ(st);
	for(int i=n-1;i>=0;i--)
	{
		if(st.substr(0,i/2)==st.substr(i/2,i/2)&&i%2==0)
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int r,d,x20,xi;
    while(cin>>r>>d>>x20){
        xi=x20;
        for(int i=1;i<=10;i++){
            int rslt=r*xi-d;
            cout<<rslt<<endl;
            xi=rslt;


        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL INF = 1 << 60;
int X[100000];
int main() {
	int N;
	LL A, B;
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}
	LL ans = 0;
	for (int i = 0; i + 1 < N; i++) {
		ans += min(A*(X[i + 1] - X[i]), B);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n,m; cin>>n>>m;
    int ans=0;
    for(int i=1; i*i<=m; i++){
        if(m%i==0){
            if(i*n<=m){
                ans=max(i,ans);
            }
            if(m/i*n<=m){
                ans=max(m/i,ans);
            }
        }
    }
    cout<<ans<<endl;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll get(ll x, ll y, ll lo, ll hi) {
	x = min(max(x, lo), hi);
	if (abs(y - x) % 2 == 0) {
		return x;
	}
	if (x >= 0) --x;
	else ++x;
	return x;
}

int main() {
	ll K, X, Y;
	cin >> K >> X >> Y;

	ll x = (X + Y), y = (X - Y);

	if (x % 2 != 0 && K % 2 == 0) {
		puts("-1");
		return 0;
	}

	ll m = max(abs(x), abs(y)) / K;

	for (; ; ++m) {
		if (((ll)m * K - x) % 2 != 0 || ((ll)m * K - y) % 2 != 0) continue;

		for (ll i = 0; i <= m; ++i) {
			ll j = m - i;
			ll a = min(max(x / K, -i), i);
			ll b = min(max(y / K, -j), j);

			for (ll p = a-3; p <= a+3; ++p) {
				for (ll q = b-3; q <= b+3; ++q) {
					if (abs(p) > i || abs(q) > j || (i - p) % 2 != 0 || (j - q) % 2 != 0) {
						continue;
					}
					//dump(p); dump(q);
					if ((p - j) * K <= x && x <= (p + j) * K && (q - i) * K <= y && y <= (q + i) * K) {

						if (((p + j) * K - x) % 2 == 0 && abs(x - K * p) / K <= j && ((q + i) * K - y) % 2 == 0 && abs(y - K * q) / K <= i) {
							vector<pair<ll, ll>> vec;

							ll zx = x - K * p;
							ll zy = y - K * q;

							rep(t, i) {
								if (p != 0) {
									ll a = get(zy, K, -K, K);
									zy -= a;

									if (p < 0) {
										vec.eb(-K, a);
										++p;
									} else {
										vec.eb(K, a);
										--p;									
									}
								} else {
									ll a = get(zy, K, -K, K);
									vec.eb(-K, a);
									++p;
									zy -= a;									
								}
							}

							rep(t, j) {
								if (q != 0) {
									ll a = get(zx, K, -K, K);
									zx -= a;

									if (q < 0) {
										vec.eb(a, -K);
										++q;
									} else {
										vec.eb(a, K);
										--q;									
									}
								} else {
									ll a = get(zx, K, -K, K);
									vec.eb(a, -K);
									++q;
									zx -= a;									
								}
							}

							cout << m << "\n";

							ll a = 0, b = 0;
							rep(i, m) {
								a += (vec[i].fi + vec[i].se) / 2;
								b += (vec[i].fi - vec[i].se) / 2;
								cout << a << " " << b << "\n";
							}
							return 0;
						}
					}
				}
			}
		}		
	}

	return 0;
}

Measured memory_bytes: 5740
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        HashSet<Integer> items = new LinkedHashSet<>();

        int min = -1;

        for (int i = 0; i < n; i++) {
            int item = scanner.nextInt();
            if (i == 0) min = item;
            items.add(item);
        }

        if (solve(min, items, k, new HashMap<>(), 0) == 0) {
            System.out.println("First");
        } else {
            System.out.println("Second");
        }
    }

    // return winner id 0 means first
    private static int solve(int min, Set<Integer> choices, int k, Map<Integer, Boolean> canWinMemo, int myId) {
        int otherId = 1 - myId;

        if (canWinMemo.containsKey(k)) return canWinMemo.get(k) ? myId : otherId;

        if (k < min) return otherId;
        if (choices.contains(k)) return myId;

        int winnerId = otherId;

        for (int choice : choices) {
            if (choice > k) break;
            if (solve(min, choices, k - choice, canWinMemo, otherId) == myId) {
                winnerId = myId;
                break;
            }
        }
        canWinMemo.put(k, winnerId == myId);
        return winnerId;
    }
}


Measured memory_bytes: 118896
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int a = (s[0] - '0') * 10 + s[1] - '0';
  int b = (s[2] - '0') * 10 + s[3] - '0';
  
  if((a > 12 || a == 0) && (b > 12 || b == 0)) cout << "NA" << endl;
  if(0 < a && a <= 12 && 0 < b && b <= 12) cout << "AMBIGUOUS" << endl;
  if(0 < a && a <= 12 && (b > 12 || b == 0)) cout << "MMYY" << endl;
  if((a > 12 || a == 0) && 0 < b && b <= 12) cout << "YYMM" << endl;
  
  return 0;
}

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

typedef long long int LL;

LL gcd(LL a, LL b) {
  return b != 0 ? gcd(b, a % b) : a;
}
LL lcm(LL a, LL b) {
  return a * b / gcd(a, b);
}

int main(){
	LL a, b;
	while(cin>>a>>b){
		cout<<gcd(a, b)<<" "<<lcm(a, b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main(void){
    // Your code here!
    int n;
    int a[200010];
    long b[200011];
    long ans_tmp=0;
    
    for(int i=0; i<200011; i++){
        b[i]=0;
    }
    
    scanf("%d", &n);
    
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        b[a[i]]++;
    }
    
    for(int i=1; i<=n; i++){
        ans_tmp+=b[i]*(b[i]-1)/2;
    }
    
    for(int i=0; i<n; i++){
        printf("%ld\n", ans_tmp-(b[a[i]]-1));
    }
    
}

Measured memory_bytes: 4864
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) a[i] = in.nextInt();
            long s = 0;
            for (int b : a) s += b;
            long one = n * (long) (n + 1) / 2;
            if (s % one != 0) {
                out.println("NO");
                return;
            }
            s /= one;
            long w = 0;
            for (int i = 0; i < n; ++i) {
                long d = a[(i + 1) % n] - a[i];
                if (d > s) {
                    out.println("NO");
                    return;
                }
                d = s - d;
                if (d % n != 0) {
                    out.println("NO");
                    return;
                }
                w += d / n;
            }
            if (w == s) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24040
#include<stdio.h>
#define N 250

int main(){
  int i, H, A[N-1];

  scanf("%d", &H);
  for(i = 0; i < H; i++)scanf("%d", &A[i+1]);

  for(i = 1; i <= H; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(i != 1)printf("parent key = %d, ", A[i/2]);
    if(i*2 <= H)printf("left key = %d, ", A[i*2]);
    if(i*2+1 <= H)printf("right key = %d, ", A[i*2+1]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2112
S = list(str(input()))
N = len(S)
S1 = list()
S2 = list()

for i in range((N - 1) // 2):
  S1.append(S[i])
for j in range((N - 1) // 2):
  S2.append(S[j + (N + 1) // 2])

S_reverse = list(reversed(S))
S1_reverse = list(reversed(S1))
S2_reverse = list(reversed(S2))

if S == S_reverse and S1 == S1_reverse and S2 == S2_reverse:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

vector<int> to[200005];
vector<int> ans;
void dfs(int v,int p=-1){
    for(int u:to[v]){
        if(u==p)
            continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main()
{
    int n, k,q;
    cin >> n>>k>>q;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        a[i]=k-q;
    }
    for (int i = 0; i < q; i++)
    {
        int t;
        cin >> t;
        t--;
        a[t]++;
    }
    for (int i = 0; i < n;i++){
        if(a[i]>0)
        cout<< "Yes" << endl;
        else{
            cout<< "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5760
s=gets.chomp
N=s.size
a = 0
ab = 0
all = 1
ans = 0
MOD = 10**9+7
N.times do |i|
  if s[i] == 'A'
    a += all
  elsif s[i] == 'B'
    ab += a
  elsif s[i] == 'C'
    ans += ab
  else
    ans = ans*3 + ab
    ab = ab*3 + a
    a = a*3 + all
    all *= 3
  end
  a %= MOD
  ab %= MOD
  ans %= MOD
  all %= MOD
end
p ans# % MOD

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<int> v(n);
  for (auto &x: v) cin >> x;

  unordered_map<int, int> countEven, countOdd;
  for (int i = 0; i < n; i += 2) countEven[v[i]]++;
  for (int i = 1; i < n; i += 2) countOdd[v[i]]++;
  countEven[0] = 0;
  countOdd[0] = 0;

  vector<Pii> countEvenVec, countOddVec;
  for (auto &x: countEven) countEvenVec.emplace_back(n/2-x.second, x.first);
  for (auto &x: countOdd) countOddVec.emplace_back(n/2-x.second, x.first);
  sort(countEvenVec.begin(), countEvenVec.end());
  sort(countOddVec.begin(), countOddVec.end());

  int ans = countEvenVec[0].first + countOddVec[0].first;
  if (countEvenVec[0].second == countOddVec[0].second) ans = min(countEvenVec[1].first + countOddVec[0].first, countEvenVec[0].first + countOddVec[1].first);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5896
import sys
sys.setrecursionlimit(1000000)
memo = {0:1}
def fact(x):
  if x in memo:
    return memo[x]
  memo[x] = x * fact(x - 1)
  return memo[x]

def comb(x, y):
  return fact(x) // fact(x - y) // fact(y)

n, k = map(int, input().split())
if n < k:print(0)
else:
  ans = 0
  for i in range(k):
    #print(ans)
    ans += (k - i) ** n * comb(k, i) * (-1) ** i
  print(ans % 1000000007)


Measured memory_bytes: 6776
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = int(1e18)
for i in range(n-k+1):
    if x[i+k-1] <= 0:
        ans = min(ans,-x[i])
    elif 0 <= x[i]:
        ans = min(ans, x[i+k-1])
    else:
        ans = min(ans, x[i+k-1]*2-x[i], -(x[i]*2)+x[i+k-1])

print(ans)


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

#define int long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"

const int N = 2005;

pair<int, int>a[N];
int cache[N][N];
int n, x;

int dp(int idx, int i, int j)
{
	if (idx > n)
		return 0;
	int &ans = cache[idx][i];

	if (ans != -1)
		return ans;

	ans = abs(i - a[idx].ss) * a[idx].ff + dp(idx + 1, i + 1, j);
	ans = max(ans, abs(j - a[idx].ss) * a[idx].ff + dp(idx + 1, i, j - 1));

	return ans;
}

int32_t main()
{
	IOS;
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		a[i].ff = x;
		a[i].ss = i;
	}
	sort(a + 1, a + n + 1);

	reverse(a + 1, a + n + 1);

	memset(cache, -1, sizeof(cache));

	int ans = dp(1, 1, n);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35240
rishi=0.05
debt= 100000
week = int(raw_input())
kiriage = 1000

def ceil(src, range):
    return((int)(src / range) + 1) * range

for i in range(0,week):
    if  debt * 1.05 % kiriage !=0:
        debt = ceil(debt * (1+rishi), kiriage)
        #print debt
    else:
        debt = debt * (1+rishi)
        #print debt

print debt

Measured memory_bytes: 4684
#include<bits/stdc++.h>
using namespace std; 
using ll=long long;
#define endl "\n"
#define F(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ALL(v) v.begin(),v.end()
void solve(){
    
    ll n,cnt=0;
    cin>>n;
    ll A[n];
    F(i,n)  cin>>A[i];

    if(n%2){ cout<<0; exit(0); }
    else{
        sort(A,A+n);
        if(A[n/2]==A[n/2-1]){ cout<<0; exit(0); }
        else{ cout<<A[n/2]-A[n/2-1]; }
    }

}
signed main(){
    fast;
     
    solve();
 
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main() {
    long long int n;
    scanf("%lld", &n);
    char s[20];
    int i = 0;
    while(n/26){
        s[i] = 'a' - 1 + (n % 26);
        if(s[i]=='a'-1){
            n = n / 26 - 1;
            s[i] = 'z';
        }else{
        n /= 26;
        }
        i++;
    }
    s[i] = 'a' - 1 + (n % 26);
    if(s[i]=='a'-1){
        i--;
    }
    for (; i >= 0;i--){
        printf("%c", s[i]);
    }
    return 0;
}

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

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

using namespace std;

int counter(int x) {
  if (x == 0)
    return 0;
  return counter(x >> 1) + (x & 1);
}

int main() {
  int N;
  int A[20];
  int x[20][20], y[20][20];

  std::cin >> N;
  for (int i = 1; i <= N; i++) {
    std::cin >> A[i];
    for (int j = 1; j <= A[i]; j++) {
      std::cin >> x[i][j] >> y[i][j];
    }
  }

  int maxv = 0;
  for (int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for (int i = 1; i <= N; i++) {
      if (!(bits & (1 << (i - 1))))
        continue;
      for (int j = 1; j <= A[i]; j++) {
        if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j])
          ok = false;
      }
    }
    if (ok)
      maxv = max(maxv, counter(bits));
  }

  std::cout << maxv << std::endl;
  return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		sc.close();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum = sum + Character.getNumericValue(n.charAt(i));
		}
		printBool(sum % 9 == 0);
	}

	public static void printBool(boolean bool) {
		print(bool ? "Yes" : "No");
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 40364