akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

int table[10001];

int main(void)
{
    string T, P;
    cin >> T >> P;
    int i = 0, j = 1;
    while (j < P.length())
    {
        bool match = P[i] == P[j];
        if (!match && i > 0)
        {
            i = table[i];
        }
        else
        {
            if (match) i++;
            j++;
            table[j] = i;
        }
    }
    j = 0;
    for (i = 0; i < T.length(); i++)
    {
        // cout << "i" << i << "j" << j << "\n";
        bool match = T[i] == P[j];
        if (match)
        {
            j++;
            if (j == P.length())
            {
                cout << i - P.length() + 1 << "\n";
                j = table[j];
            }
        }
        else
        {
            if (j != 0) i--;
            j = table[j];
        }
    }
    return 0;
}


Measured memory_bytes: 3864
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    sa = sum(A)
    M = N*(N+1)//2
    if sa % M != 0:
        return 'NO'

    k = sa // M

    kk = k
    for i in range(N):
        b = A[(i+1) % N] - A[i]
        b -= k
        if b > 0:
            error_print('a')
            return 'NO'
        if b % N != 0:
            error_print('b')
            return 'NO'
        kk += b // N

    if kk != 0:
        error_print('c')
        return 'NO'

    return 'YES'


def main():
    N = read_int()
    A = read_int_n()
    # N = 10
    # A = [random.randint(1, 10**9) for _ in range(N)]
    # print(A)
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17368
#include<stdio.h>
int main(){
  int n,i,v,j,A[100];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  for(j=0;j<n-1;j++)
    printf("%d ",A[j]);
  printf("%d\n",A[n-1]);
  for(i=1;i<n;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
	A[j+1]=A[j];
	j--;
	A[j+1]=v;
      }
    for(j=0;j<n-1;j++)
      printf("%d ",A[j]);
    printf("%d\n",A[n-1]);
  }
  return 0;
}



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

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

  vector<ll> a(n + 1);
  vector<bool> ans(n + 1);

  for (ll i = 1; i <= n; i++) {
    cin >> a[i];
  }

  ll total = 0;
  for (ll i = n; i >= 1; i--) {
    ll cnt = 0;
    ll j = i * 2;
    while (j <= n) {
      cnt += (ll) ans[j];
      j += i;
    }
    ans[i] = cnt % 2 != a[i] % 2;
    if (ans[i]) total++;
  }

  cout << total << endl;
  for (ll i = 1; i <= n; i++) {
    if (ans[i]) {
      cout << i << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000007

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	string ans = (a - b) % 2 ? "Borys" : "Alice";
	cout << ans;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
S = input()
cnt = 0

for i in S:
    if i == '-':
        cnt += 1

if cnt == 1:
    post = S.split('-')
    if len(post[0]) == A and len(post[1]) == B:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  sort(ALL(s));
  if (s[0] == s[SZ(s) - 1]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=1e5+10;

bool can[maxn][3][3];
string s[3];
int ans;
int lenth[3];

void getcan(int t1,int t2){
	for(int i=0;i<(int)s[t1].size();i++){
		can[i][t1][t2]=true;
		for(int j=i;j<min(i+(int)s[t2].size(),(int)s[t1].size());j++){
			if(s[t1][j]!='?'&&s[t2][j-i]!='?'&&s[t1][j]!=s[t2][j-i]){
				can[i][t1][t2]=false;
			}
		}
	}
}

void getans(int pos,int t1,int t2,int t3){
	if((pos<lenth[t1])&&(can[pos][t1][t2]==false)){
		return;
	}	
	int len=max(pos+lenth[t2],lenth[t1]);
	for(int i=0;i<=len;i++){
		int l=i,r=i+lenth[t3]-1,r2=pos+lenth[t2]-1;
		bool ft1=true,ft2=true;
		if((i<=lenth[t1]-1)&&(can[i][t1][t3]==false)){
			ft1=false;
		}
		if((l<=pos)&&(pos<=r)&&(can[pos-l][t3][t2]==false)){
			ft2=false;
		}
		if((pos<=l)&&(l<=r2)&&(can[l-pos][t2][t3]==false)){
			ft2=false;
		}
		if(ft1&&ft2){
			ans=min(ans,max(i+lenth[t3],len));
		}
	}
}

int main(){
	for(int i=0;i<3;i++) cin>>s[i];
	for(int i=0;i<3;i++) lenth[i]=(int)s[i].size();
	for(int t1=0;t1<3;t1++){
		for(int t2=0;t2<3;t2++) if(t1!=t2){
			getcan(t1,t2);
		}
	}
	ans=lenth[0]+lenth[1]+lenth[2];
	for(int t1=0;t1<3;t1++){
		for(int t2=0;t2<3;t2++) if(t1!=t2){
			int t3=3-t1-t2;
			for(int i=0;i<=lenth[t1]+lenth[t3];i++){
				getans(i,t1,t2,t3);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int h, w, n;
    cin >> h >> w >> n;
    int x = max(h,w);
    int ans = (n+x-1)/x;

    cout << ans << '\n';

    return 0;
}

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

int main() {
  string S;
  string T;
  
  cin >> S >> T; 
    
  int H = 0;
  
  for (int i = 0; i < 3; i++) {
    if ( S.at(i) == T.at(i) ) {
      H = H + 1;
    }
  }
  
  cout << H << endl;
  
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000


N,M = map(int,input().split())
a = [0 for i in range(M)]
for i in range(M):
    a[i] = int(input())

miss_stairs = [0 for i in range(N)]
for i in range(M):
    miss_stairs[a[i]-1] = 1


dp = [0 for i in range(N+1)]
dp[0] = 1
if miss_stairs[0] == 1:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(N-1):
    if miss_stairs[i+1] == 0:
        dp[i+2] = (dp[i] + dp[i+1]) % mod
# print(dp)

print(dp[-1]% mod)


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

string s;
int x,y;
vector < int > mv[2];
bool is_possible(int ind, int M)
{
	int sm[9000];
	for(int i = 0 ; i < 9000;++i)
		sm[i] = 0;
	sm[0] = 1;
	int SM = 0;
	for(int i = (ind == 0? 1:0);  i< mv[ind].size();++i)
	{
		SM += mv[ind][i];
		for(int j = 8999;j>=mv[ind][i];--j)
			if(sm[j-mv[ind][i]] == 1)
				sm[j] = 1;
	}
	//cout << SM << ' ' << M << endl;
	if((M >=0 && SM < M) || (M < 0 && SM < -M) )
	return false;
	if((M >= 0 && ((SM-M)&1)==0 &&sm[(SM-M)/2]==1) || (M < 0 && ((-M+SM)&1) == 0 && sm[(-M+SM)/2]==1))
	return true;
	return false;
}
int main() {
	cin >> s;
	cin >> x >> y;

	int ind = 0, sm = 0;
	for(int i = 0 ; i < s.length();++i)
	{
		if(s[i]=='T')
		{
			if(i==0)
				mv[ind].push_back(0);
			if(sm != 0)
				mv[ind].push_back(sm);
			ind ^=1;	
			sm = 0;
			continue;
		}
		sm+=1;
	}
	if(sm!=0)
	mv[ind].push_back(sm);
	if(is_possible(0,x-mv[0][0]) && is_possible(1,y))
	cout << "Yes\n";
	else
	cout << "No\n";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 200005
#define inf 1e17
#define eps 1e-6
#define ll long long
#define ull unsigned long long
#define main() int main()
#define pii pair<int, ll>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define sa(x) scanf("%d",&x)
#define sab(x,y) scanf("%d%d",&x,&y)
#define pa(x) printf("%d",&x)
#define pab(x,y) printf("%d%d",x,y) 
#define ms(a,x) memset(a,x,sizeof(a))
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define ff0(i,n) for(int i=0;i<n;++i)
#define ff1(i,n) for(int i=1;i<=n;++i)

const ull mod = 1e9+7;
ll powermod(ll a,ll n)
{
    if(a==0) return 1;
    ll ret=1,res=a;
    while(n)
    {
        if(n&1) ret=ret*res%mod;
        res=res*res%mod;
        n>>=1;
    }
    return ret;
}
ll fun(ll n,ll m)
{
    if(n>m/2) n=m-n;
    ll  ans=1,i=1;
    while(i<=n)
    {
        ans=ans*(m-i+1)%mod*powermod(i,mod-2)%mod;
        i++;
    }
    return ans%mod;
}
main()
{
    IO;
    ull n,a,b;
    cin>>n>>a>>b;
    ull ans=powermod(2,n);
	ans--;	
	ans=(ans-fun(a,n)+mod)%mod;
	ans=(ans-fun(b,n)+mod)%mod;
	
	cout<<ans<<endl;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

int f[N][4];
int a[4];

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

    int n;  cin >> n;

    for(int i = 1 ; i <= n ; ++i)   {
        for(int j = 1 ; j <= 3 ; ++j)   cin >> a[j];

        for(int j = 1 ; j <= 3 ; ++j)
        for(int k = 0 ; k <= 4 ; ++k)   if (j != k)
            f[i][j] = max(f[i][j],f[i - 1][k] + a[j]);
    }

    cout << *max_element(f[n],f[n] + 4) << endl;
}


Measured memory_bytes: 1792
import math

def main():
    N = int(input())
    p = 10**math.floor(math.log(N, 10))
    a = (N+1) // p
    a = p * a - 1
    r = 0
    while a > 0:
        r += (a%10)
        a //= 10
    print(r)
main()


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



ll attack(ll H) { 
  if (H <= 1) {
    return 1ll;
  } else {
    return 1 + 2ll * attack(H / 2);
  }
}

int main() {
  ll H;
  cin >> H;
  cout << attack(H) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              998244353LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  1000050LL
#define tmod            998244353
using namespace std;

ll MI(ll a, ll m);

ll fac[N+2],Ifac[N+2],inv[N+2],w[N+2],fr[N+2];

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll n,m,k,i,j,l,r,c=0,b,a,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    fac[0] = fac[1] = Ifac[0] = Ifac[1] = inv[1]  = 1;
    for(i=2;i<=N;i++) fac[i] = (fac[i-1]*i)%mod;
    Ifac[N] = MI(fac[N],mod);
    for(i=N-1;i>=1;i--) Ifac[i] = (Ifac[i+1]*(i+1))%mod;
    for(i=2;i<=N;i++) inv[i] = (Ifac[i]*fac[i-1])%mod;

    memset(w,0,sizeof(w));
    for(i=1;i<=N;i++)
    {
        w[i] = (w[i] + inv[i])%mod;
        for(j=2LL*i;j<=N;j+=i)
            w[j] = (w[j] - w[i] + mod)%mod;
    }

    memset(fr,0,sizeof(fr));

    cin >> n;
    for(i=0;i<n;i++) {cin >> x; fr[x]++;}
    ll ans = 0;
    for(i=1;i<=N;i++)
    {
        ll temp = 0,stemp=0;
        for(j=i;j<=N;j+=i)
        {
            temp = (temp + (fr[j]*j)%mod)%mod;
            stemp = (stemp + (fr[j]*((j*j)%mod))%mod)%mod;
        }
        ans = ( ans + (((((((temp*temp)%mod) - stemp  + mod )%mod)*inv[2])%mod)*w[i])%mod )%mod;
    }

    cout << ans << endl;

}
    return 0;
}

ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}


Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define endl '\n'

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e5 + 5;
int n, m;
vector<int> adj[N];
int sign[N];
int component = 0;

void bfs(int start) {
	queue<int> q;
	q.push(start);
	sign[start] = 0;
	while (!q.empty()) {
		int cur = q.front(); q.pop();
		for (auto &next : adj[cur]) {
			if (sign[next] != -1) continue;
			sign[next] = cur;
			q.push(next);
		}
	}
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0, u, v; i < m; i++) {
		scanf("%d %d", &u, &v);
		adj[u].pb(v); adj[v].pb(u);
	}
	
	memset(sign, -1, sizeof sign);
	for (int i = 1; i <= n; i++)
		if (sign[i] == -1) bfs(i), component++;
	
	if (component > 1) {
		printf("%s\n", "No");
	} else {
		printf("%s\n", "Yes");
		for (int i = 2; i <= n; i++) printf("%d\n", sign[i]);
	}
	
	return 0;
}

Measured memory_bytes: 10664
#include<stdio.h>

int main()
{
//変数定義
int A;
int B;

//スペースの入力
scanf("%d %d",&A, &B);

//A,Bの判定
if(A<=9 && B<=9){
 printf("%d\n",A*B);
}else
 printf("-1\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

const int N = 111;
const int M = 101 * 101;
const ll INF = 1e18;

int n, m, a, b, s;

vector <pair<int, int>> g[N];

int A[N], B[N], C[N], D[N];

ll dis[N][M + 1];

priority_queue <pair<ll, pair<int, int>>> q;

ll res[N];

int main() {
	scanf ("%d%d%d", &n, &m, &s);
	s = min(s, M);
	rep(i, 1, m) {
		scanf ("%d%d%d%d", &a, &b, A+i, B+i);
		g[a].pb({b, i});
		g[b].pb({a, i});
	}
	rep(i, 1, n) {
		scanf ("%d%d", C+i, D+i);
		C[i] = min(C[i], M);
		res[i] = INF;
	}
	rep(i, 1, n) rep(j, 0, M) dis[i][j] = INF;
	
	dis[1][s] = 0;
	q.push({0, {1, s}});
	
	while (ss(q)) {
		auto it = q.top();
		q.pop();
		int V = it.se.fi;
		int S = it.se.se;
		
		res[V] = min(res[V], dis[V][S]);
		
		// 1. zostan
		int nS = min(M, S + C[V]);
		ll nT = dis[V][S] + D[V];
		if (dis[V][nS] > nT) {
			dis[V][nS] = nT;
			q.push({-dis[V][nS], {V, nS}});
		}
		// 2. idz
		for (auto it : g[V]) {
			int G = it.fi;
			int ID = it.se;
			int Koszt = A[ID];
			int Czas = B[ID];
			if (S < Koszt) continue;
			int nS = S - Koszt;
			if (dis[G][nS] > dis[V][S] + Czas) {
				dis[G][nS] = dis[V][S] + Czas;
				q.push({-dis[G][nS], {G, nS}});
			}
		}
	}
	
	rep(i, 2, n) printf ("%lld\n", res[i]);
	
	
	return 0;
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.second != b.second){
        return a.second < b.second;
        
    }else{
        return a.first < b.first;
    }
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}

const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
int main() {
    ll N,M;
    cin>>N>>M;
    vector<Pi>ab(M);

    rep(i,M){
        ll a,b;
        cin>>a>>b;
        ab[i] = mp(a,b);
    }

    sort(all(ab),compare);
    ll now = -INF;
    ll ans = 0;
    rep(i,M){
        if(ab[i].first>= now){
            ans++;
            now = ab[i].second;
        }
    }
    cout<<ans<<endl;

    return 0;
    

}

Measured memory_bytes: 4848
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
XY = np.array(read().split(),np.int64)

X = XY[::2]; Y = XY[1::2]
theta = np.arctan2(Y,X)
ind = theta.argsort(); X = X[ind]; Y = Y[ind]

# 2周
X = np.tile(X,2)
Y = np.tile(Y,2)
Xcum = np.cumsum(X)
Ycum = np.cumsum(Y)

answer = 0
for items in range(1,N+1):
    x = Xcum[items:] - Xcum[:-items]
    y = Ycum[items:] - Ycum[:-items]
    L = (x*x+y*y).max()
    if answer < L:
        answer = L

answer **= 0.5
print(answer)

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

int main() {
	int n;
	cin >> n;
	int score, bh, hh, maxscore;
	score=bh=maxscore=0;
	cin >> bh;
	for (int i=1; i<n; i++){
		cin >> hh;
		//cout << bh << "," << hh << ":";
		if (bh >= hh){
			score++;
			//cout << "score++=" << score << endl;
		}
		else{
			if (maxscore<score)
			maxscore=score;
			//cout << "maxscore=" << maxscore << endl;
			score=0;
		}
		bh=hh;
	}
	if (maxscore<score)
	maxscore=score;
	cout << maxscore;
	return 0;
}

Measured memory_bytes: 256
N = int(input())

for i in range(N,-1,-1):
  if i == 64:
    print(i)
    break
  elif i == 32:
    print(i)
    break
  elif i == 16:
    print(i)
    break
  elif i == 8:
    print(i)
    break
  elif i == 4:
    print(i)
    break
  elif i == 2:
    print(i)
    break
  elif i == 1:
    print(1)
  
    
    
   
    



Measured memory_bytes: 3060
S = input()
N = len(S)

h = S[0:((N-1)//2)]
ah = S[((N+3)//2 -1):]

if h == ah:
    hh = h[0:len(h)//2]
    flg = True
    for i in range(len(hh)):
        if not hh[i] == h[-(i+1)]:
            flg = False
            break
    if flg:
        print('Yes')
    else:
        print('No')
else:
    print('No')


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;
int a[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) cin >> a[i];
    int ans = 0;
    bool check[n] = {};
    bool inc = true;
    rep(i, n) {
        if (check[i]) continue;
        check[i] = true;
        ans++;
        int now = -1;
        rep2(j, i, n - 1) {
            if (a[j + 1] > a[j]) {
                now = j;
                inc = true;
                break;
            }
            else if (a[j + 1] < a[j]) {
                now = j;
                inc = false;
                break;
            }
            check[j + 1] = true;
        }
        if (now == -1) break;
        if (inc) {
            while (now < n - 1 && a[now + 1] >= a[now]) {
                check[now + 1] = true;
                now++;
            }
            if (now == n - 1) break;
        }
        else {
            while (now < n - 1 && a[now + 1] <= a[now]) {
                check[now + 1] = true;
                now++;
            }
            if (now == n - 1) break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define do(i,j,k) for(register int i=j;i>=k;i--) 
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
int n; 
ll sum;
int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int main()
{
	cin>>n;
	fo(i,1,n)
	{
		fo(j,1,n)
		{
			fo(k,1,n)
			{
				sum+=gcd(i,gcd(j,k));
			} 
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3620
/**
 *    author:  tourist
 *    created: 25.11.2017 13:09:09       
**/
#include <bits/stdc++.h>

using namespace std;

const long long inf = (long long) 1e18;

const int N = 5010;

long long f[N][N];

int main() {
  int n;
  scanf("%d", &n);
  vector< pair<int,int> > a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first, &a[i].second);
    a[i].first += a[i].second;
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    a[i].first -= a[i].second;
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      f[i][j] = inf;
    }
  }
  f[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      long long ft = f[i][j];
      if (ft == inf) {
        continue;
      }
      f[i + 1][j] = min(f[i + 1][j], ft);
      if (ft <= a[i].first) {
        f[i + 1][j + 1] = min(f[i + 1][j + 1], ft + a[i].second);
      }
    }
  }
  int ans = 0;
  for (int j = 0; j <= n; j++) {
    if (f[n][j] != inf) {
      ans = j;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 194176
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Modularness
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_K = 5000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

int ds[MAX_K], zss[MAX_K + 1];
ll dss[MAX_K + 1];

/* subroutines */

/* main */

int main() {
  int k, q;
  scanf("%d%d", &k, &q);

  for (int i = 0; i < k; i++) scanf("%d", ds + i);

  while (q--) {
    int n, x, m;
    scanf("%d%d%d", &n, &x, &m);

    dss[0] = zss[0] = 0;
    for (int i = 0; i < k; i++) {
      int d = ds[i] % m;
      dss[i + 1] = dss[i] + d;
      zss[i + 1] = zss[i] + ((d == 0) ? 1 : 0);
    }

    ll sum = x % m + dss[k] * ((n - 1) / k) + dss[(n - 1) % k];
    int zn = zss[k] * ((n - 1) / k) + zss[(n - 1) % k];
    printf("%lld\n", (n - 1) - (zn + sum / m));
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b)){
    cout<<"A"<<"\n";
    return(0);
  }
  cout<<"B"<<"\n";
  return(0);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    static int Search(int ok, int ng)
    {
        while (Math.Abs(ok - ng) > 1)
        {
            var mid = (ok + ng) / 2;
            if (Check(mid))
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        return ok;
    }

    static int[] Count;
    static int[] A;
    static long M;

    static bool Check(int x)
    {
        return GetSatisfyCount(x) >= M;
    }
    static long GetSatisfyCount(int x)
    {
        return A.Sum(a => (long)Count[Math.Max(x - a, 0)]);
    }

    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var N = (int)vals[0];
        M = vals[1];
        A = Console.ReadLine().Split(' ').Select(int.Parse).OrderByDescending(v => v).ToArray();

        var max = A.First() * 2 + 1;
        var cur = 0;
        long sum = 0;
        var p = 0;
        Count = new int[max];
        var SumAcc = new long[max];
        for (int i = max - 1; i >= 0; i--)
        {
            while (p < N && A[p] == i)
            {
                cur++;
                sum += A[p];
                p++;
            }
            Count[i] = cur;
            SumAcc[i] = sum;
        }

        var x = Search(1, max);

        for (int i = 0; i < N; i++)
        {
        }

        var maxScore = A.Sum(a =>
        {
            var b = Math.Max(x -a, 0);
            return a * (long)Count[b] + SumAcc[b];
        });
        var ex = GetSatisfyCount(x) - M;
        maxScore -= ex * x;

        Console.WriteLine(maxScore);
    }
}

Measured memory_bytes: 25824
#include <stdio.h>
#include <string.h>

const char red_tile = '#';
const int step[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int count_area(char t[][21], int x, int y, int w, int h) {
    int i, count = 0;
    if (x < 0 || w <= x || y < 0 || h <= y) return 0;
    if (t[y][x] == red_tile) return 0;
    t[y][x] = red_tile;
    count += 1;
    for (i = 0; i < 4; i++) {
        count += count_area(t, x+step[i][0], y+step[i][1], w, h);
    }
    return count;
}

int main() {
    int w, h, i, sx, sy;
    char *p;
    char tile[20][21];

    while (scanf("%d%d\n", &w, &h) != EOF && w && h) {
        for (i = 0; i < h; i++) {
            scanf("%s", &tile[i]);
            if ((p = strchr(tile[i], '@')) != NULL) {
                sx = p - (char*)&tile[i];
                sy = i;
            }
        }
        printf("%d\n", count_area(tile, sx, sy, w, h));
    }

    return 0;
}

Measured memory_bytes: 628
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int[] p = new int[n];
        int a = 0;
        for(int i = 0; i < n; i++){
            p[i] = scan.nextInt();
        }
        for(int i = 0; i < n; i++){
            if(p[i] - 1 != i){
                a++;
            }
        }
        if(a <= 2){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

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

using namespace std;
typedef long long ll;
ll n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    if(n == 0) return 0 * printf("0\n");
    string ret = "";
    ll power = 1;
    while(n){
        if(n % (2 * abs(power))){
            ret += "1";
            n -= power;
        }
        else{
            ret += "0";
        }
        power *= (-2);
    }
    reverse(ret.begin(), ret.end());
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

int main(){
    int D, G;
    int a, b;
    cin >> D >> G;
    G /= 100;
    int p[D];
    int c[D];
    int sump[D];
    int i;
    int j;
    int bit;
    int count = 0;
    int cost = 0;
    int flag = 0;
    int ans = 114514;
    
    for(i = 0; i < D; i++){
        cin >> a >> b;
        b /= 100;
        p[i] = a;
        c[i] = b;
        sump[i] = (i+1)*a + b;
    }
    
    for(bit = 0; bit < (1 << D); bit++){
        count = 0;
        cost = 0;
        flag = 0;
        for(i = 0; i < D; i++){
            if((bit>>i)&1){
                count += p[i];
                cost += sump[i];
            }
        }
        if(cost >= G){
            if(ans > count){
                ans = count;
            }
        }else{
            for(i = D-1; i >=0; i--){
                if(!((bit>>i)&1)){
                    for(j = 1; j <= p[i]; j++){
                        count++;
                        cost += (i+1);
                        if(cost >= G){
                            flag = 1;
                            break;
                        }
                    }
                }
                if(flag){
                    break;
                }
            }
            
            if(ans > count){
                ans = count;
            }
        }
    }
    
    
    cout << ans << endl;
    
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cassert>
#include<cctype>
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>

using namespace std;

string S;
size_t cur = 0;

int term();
int factor();
int expression();

int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur] - '0';
	cur = cur + 1;
	return n;
}

int number(){
	int n = digit();
	while (cur < S.size() && isdigit(S[cur]))
		n = n * 10 + digit();
	return n;
}

int expression(){
	int a = term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')){
		char op = S[cur];
		cur = cur + 1;
		int b = term();
		if (op == '+') a += b;
		else a -= b;
	}
	return a;
}

int term(){
	int a = factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur];
		cur = cur + 1;
		int b = factor();
		if (op == '*') a *= b;
		else a /= b;
	}
	return a;
}

int factor(){
	if (S[cur] != '(') return number();
	cur += 1;
	int n = expression();
	assert(S[cur] == ')');
	cur += 1;
	return n;
}

int main(){
	int N;
	cin >> N;
	for (int i = 0; i < N; i++){
		cur = 0;
		cin >> S;
		S.resize(S.size() - 1);
		cout << expression() << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 1e6 + 5;

int K;
bool vis[maxn];

void read_input()
{
    cin >> K;
}

void solve()
{
    if(7 % K == 0)
    {
        cout << "1\n";
        return;
    }
    fill(begin(vis), end(vis), false);
    int cur = 1, r = 7 % K;
    vis[r] = true;
    while(true)
    {
        ++cur;
        r = (r * 10 + 7) % K;
        if(r == 0)
        {
            cout << cur << '\n';
            return;
        }
        if(vis[r])
        {
            cout << "-1\n";
            return;
        }
        vis[r] = true;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 4660
#include <stdio.h>

int main(){
	int N;
	scanf("%d", &N);
	
	int a = N / 100, b = (N - a * 100) / 10, c = N % 10;
	
	if(a== 7 || b == 7 || c == 7){
		puts("Yes");
	}
	else{
		puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 1660
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for line in sys.stdin.readlines():
        a,b,c=map(int, line.split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

main()


Measured memory_bytes: 57308
package main

import (
        "fmt"
)

func solution(a []int) string {
        k := a[5]
        for i := 0; i < 5; i++ {
                for j := 0; j < 5; j++ {
                        if i == j {
                                continue
                        }
                        if a[i]-a[j] > k {
                                return ":("
                        }
                }
        }
        return "Yay!"
}

func main() {
        a := make([]int, 0, 6)
        for i := 0; i < 6; i++ {
                t := 0
                fmt.Scan(&t)
                a = append(a, t)
        }
        fmt.Println(solution(a))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<int> S(m), C(m);
  vector<int> d(n, -1);
  rep(i, m) {
    cin >> S[i] >> C[i];
    S[i]--;
  }
  rep(i, m) {
    if(d[S[i]] != -1 && d[S[i]] != C[i]) {
      cout << -1 << endk;
      return 0;
    } else {
      d[S[i]] = C[i];
    }
  }
  if(n == 1) {
    if(d[0] == -1) cout << 0 << endk;
    else cout << d[0] << endk;
  } else {
    if(d[0] == 0) cout << -1 << endk;
    else {
      if(d[0] == -1) d[0] = 1;
      ll ans = 0;
      rep(i, n) {
        if(d[i] != -1) ans += pow(10, n-1-i) * d[i];
      }
      cout << ans << endk;
    }
  }
  return 0;
}


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

#define F(i, a, b) for (LL i = a; i <= b; i ++)
#define G(i, a, b) for (LL i = a; i >= b; i --)
#define add(a, b) ((a) = (a + b) % Mo)

typedef long long LL;
 
const LL N = 1e5 + 10;
const LL Mo = 1e9 + 7;
const LL inf = 5e18;

using namespace std;

LL n, A, B, L1,R1, L2,R2;
LL S[N], f[N][2], S0[N],S1[N];

int main() {	
	scanf("%lld %lld %lld", &n, &A, &B);
	F(i, 1, n) scanf("%lld", &S[i]);
	sort(S + 1, S + n + 1);
	S[n + 1] = inf, S[0] = - inf;
	S0[0] = S1[0] = f[0][0] = f[0][1] = 1;
	F(i, 1, n) {
		// Update f[i][0]
		while (R1 < i - 1 && S[R1 + 1] <= S[i + 1] - B)
			R1 ++;
		if (S[i] - A < S[i - 1])
			L1 = i - 1;
		if (R1 >= L1) add(f[i][0], S1[R1] - (L1 ? S1[L1 - 1] : 0));
		// Update f[i][1]
		
		while (R2 < i - 1 && S[R2 + 1] <= S[i + 1] - A)
			R2 ++;
		if (S[i] - B < S[i - 1])
			L2 = i - 1;
		if (R2 >= L2) add(f[i][1], S0[R2] - (L2 ? S0[L2 - 1] : 0));
			
		S1[i] = (S1[i - 1] + f[i][1]) % Mo;
		S0[i] = (S0[i - 1] + f[i][0]) % Mo;
	}
	printf("%lld\n", ((f[n][0] + f[n][1]) % Mo + Mo) % Mo);
}

Measured memory_bytes: 4096
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int dp[10001];
int AB[10001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H = getint(), N = getint();
	rep1(i, 10000) dp[i] = 1e9;
	rep1(i, 10000) AB[i] = 2e9;

	rep(i, N) {
		int a = getint(), b = getint();
		chmin(AB[min(H, a)], b);
	}

	double saikou = 1e20;
	rep1(i, 10000) {
		int k = AB[i];
		if (k < 1e9) {
			int ima = k;
			for (int j = i + i; j <= 10000; j += i) {
				ima += k;
				if (AB[j] >= ima) AB[j] = 2e9;
			}
			chmin(saikou, 1.0 * k / i);
		}
	}

	int kotae = 2e9;
	for (int i = 10000; i >= 1; i--) {
		int k = AB[i];
		if (k < 1e9) {
			double kouritu1 = 1.0 * k / i;
			double kouritu2 = 1.0 * kotae / H;
			double are = H * (kouritu2 - saikou) / (kouritu1 - saikou);
			if (are > i) {
				auto dp2 = dp + i;
				int kazu = max(0, H - i);
				for (int j = 0; j < kazu; j++) if (dp2[j] > dp[j] + k) dp2[j] = dp[j] + k;
				for (int j = kazu; j <= H; j++) if (kotae > dp[j] + k) kotae = dp[j] + k;
			}
		}
	}
	printf("%d", kotae);

	Would you please 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 i;
    string o,e;
    cin>>o;
    cin>>e;
    int ol=o.size(),el=e.size();
    if(ol==el){
        for(i=0;i<el;i++) cout<<o[i]<<e[i];
    } else {
        for(i=0;i<el;i++) cout<<o[i]<<e[i];
        cout<<o[ol-1];
    }
    return 0;
}

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

bool isprime(int x){
    if(x==2){return true;}
    if(x<2||x%2==0){return false;}
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0){return false;}
    }
    return true;
}
int main(){
    int n,count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(isprime(x)){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


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

using namespace std;

long long dp[3000][51];

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int N, A; cin >> N >> A;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];
    vector<int> p(N);
    for (int i = 0; i < N; ++i)
        p[i] = A * (i + 1);
    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for (int j = 0; j < N; ++j) {
            for (int k = p[i]; k >= 0; --k) {
                for (int z = 1; z < i + 2; ++z) {
                    if (k - a[j] + 1 > 0)
                        dp[k][z] += dp[k-a[j]][z-1];
                }
            }
        }ans += dp[p[i]][i+1];
    }cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 4848
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a1.append(0)
suml = []
for i in range(n):
    suml.append([sum(a1[:-i - 1]) + sum(a2[-i - 1:])])
print(max(suml)[0])


Measured memory_bytes: 3060
N, K = list(map(int, input().split()))

l = [None] * N
b = 0
for i in range(1, N + 1):
    a = i
    b = 0
    while a < K:
        a *= 2
        b += 1
    l[i - 1] = b

ans = 0
for i in range(N):
    ans += (1 / N) * (1 / 2) ** l[i]

print(ans)

Measured memory_bytes: 3828
// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    static ArrayList<Integer>[] adj;
    static boolean[] visited;

    public static void dfs(int v) {
        visited[v] = true;
        for(int next : adj[v]) {
            if(!visited[next]) {
                dfs(next);
                break;
            }
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        adj = new ArrayList[4];
        for(int i=0;i<4;i++) {
            adj[i] = new ArrayList<Integer>();
        }

        for(int i=0;i<3;i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            adj[a].add(b);
            adj[b].add(a);
        }

        visited = new boolean[4];
        dfs(0);
        //pw.println(Arrays.toString(visited));

        for(int i=0;i<4;i++) {
            if(!visited[i]) {
                pw.println("NO");
                pw.close();
                return;
            }
        }
        pw.println("YES");
        pw.close();
	}

}

Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		//System.out.println(N);
		long m=0;
		long a=0;
		long r=0;
		long c=0;
		long h=0;
		for(int i =0;i<N;i++){
			String str=sc.next();
			//System.out.println(str);
			char hoge =str.charAt(0);
			//System.out.println(hoge);
			if(hoge== 'M'){
				//System.out.println("M");
				m++;
			}else if(hoge=='A'){
				a++;
				//System.out.println("A");
			}else if(hoge=='R'){
				r++;
				//System.out.println("R");
			}else if(hoge=='C'){
				c++;
				//System.out.println("C");
			}else if(hoge=='H'){
				h++;
				//System.out.println("H");
			}
		}
		long ans=0;
		ans = m*(a*(r+c+h)+r*(c+h)+c*h)+a*(r*(c+h)+c*h)+r*c*h;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 45164
#include <iostream>
#include <map>
#include <vector>

using namespace std;
typedef long long LL;
const int LEN = 2e5 + 10;
LL arr[LEN];

int main() {
    int N;
    LL sum = 0;
    map<LL, LL> m;
    vector<LL> v;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> arr[i];
        m[arr[i]] += 1;
    }
    map<LL, LL>::iterator it = m.begin();
    for (; it != m.end(); it++) {
        LL num = it->second;
        sum += num * (num - 1) / 2;
    }
    //cout << "sum " << sum << endl;
    LL cnt, minus, value;
    for (int i = 1; i <= N; i++) {
        value = m[arr[i]] * (m[arr[i]] - 1) / 2;
        cnt = m[arr[i]] - 1;
        if (cnt < 2) {
            minus = value;
        } else {
            minus = value - cnt * (cnt - 1) / 2;
        }
        cout << sum - minus << endl;
    }
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  ll cnt=0,ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='W'){
      ans+=i-cnt;
      cnt++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
//##MohK
//16/2/2020 .....2,50
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,n,counter=0,res=0;
    cin>>a;
    for(ll i=0;i<a;i++){
        cin>>n;
        if(n%2==0){
                res++;
            if(n%3==0||n%5==0){
                counter++;
            }
        }
    }
    if(res==counter)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

   return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  FOR(i,0,N) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  ll ans = 0;
  FOR(i,0,N-K) {
    ans += H[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;

int main(){
    //std::stack<int> stack;
    int n, m;
    cin >> n >> m;
    int sum = 0;
    int ans;
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        sum += a;
    }
    if(sum > n){
        ans = -1;
    }else{
        ans = n - sum;
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    }
    else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int a[m+1];
  for(int i=1;i<=m;i++)cin>>a[i];
  int left=0;
  int right;
  int ans;
  for(int i=1;i<=m;i++){
    if(a[i]<x)left+=1;
    else{
      break;
    }
  }
  right=m-left;
  ans=min(left,right);
  cout<<ans;
  return 0;
}

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

signed main(){
  int n;cin>>n;
  map<int,int>m;
  while(n--){
    int a;cin>>a;
    m[a]++;
  }
  int ans=0;
  for(auto p:m){
    int v=p.first,c=p.second;
    if(!c)continue;
    ans+=c==1;
    for(int i=2*v;i<1e6+1;i+=v)if(m.count(i))m[i]=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 12816
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	input := bufio.NewReader(os.Stdin)

	var N int
	fmt.Fscanf(input, "%d\n", &N)
	var count int
	for i := 0; i < N; i++ {
		var pi int
		fmt.Fscanf(input, "%d", &pi)
		if pi != i+1 {
			count++
		}
	}
	if count > 2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 640
#include<stdio.h>



int three_min( int c ,int a ,int n )
{
	if( c > a )
	{
		c = a ;
	}

	if( c > n )
	{
		return n ;
	}


	return c ;
}


int min_min( int c ,int a )
{
	return c > a ? a : c ;
}



int main()
{
	int q ;
	int c ,a ,n ;

	int ans ;


	scanf( "%d" ,&q ) ;


	int i ;
	for( i = 0 ; i < q ; ++i )
	{
		ans = 0 ;

		scanf( "%d %d %d" ,&c ,&a ,&n ) ;


		if( c == 0 ) ;

		else if( a > 0 )
		{
			int min = three_min( c ,a ,n ) ;

			if( n > 0 )
			{
				c -= min ;
				a -= min ;
				n -= min ;

				ans += min ;
			}

			if( a > 0 )
			{
				min = min_min( c / 2 ,a ) ;

				c -= ( min * 2 ) ;
				a -= min ;

				ans += min ;
			}
		}


		ans += c / 3 ;


		printf( "%d\n" ,ans ) ;
	}


	return 0 ;
}

Measured memory_bytes: 600