akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
	ll ans=0;
	int r=0, XOR=0, PLUS=0;
	for(int l=0; l<N; l++){
		while(r<N && (A[r]^XOR)==(A[r]+PLUS)){
			XOR^=A[r];
			PLUS+=A[r];
			r++;
		}
		//cout << PLUS << XOR << endl;
		PLUS-=A[l];
		XOR^=A[l];
		ans+=(r-l);
		//cout << r << l << endl;
	}
	cout << ans << endl;

    

    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""

s, t = input().split()
a, b = map(int, input().split())
u = input()

if s == u:
    print(max(0, a-1), b)
else:
    print(a, max(0, b-1))

"""
s = input()

print("x" * len(s))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int mod=1000000007;
const int N=700;
int i,j,k,n,m,x,y,t,ans,dp[N][N],cant[N][N],w[N][N],R[N][N],Y[N][N],g[N];
int main(){
	scanf("%d%d",&n,&m);
	for (k=1;k<=n*2;k+=2)for (i=1;i<=n*2;i++)if (i+k-1<=n*2)cant[i][i+k-1]=1;
	for (k=1;k<=m;k++){
		scanf("%d%d",&x,&y);
		if (x>y)swap(x,y);
		for (i=1;i<=x;i++)for (j=x;j<y;j++)cant[i][j]=1;
		for (i=x+1;i<=y;i++)for (j=y;j<=n*2;j++)cant[i][j]=1;
		for (i=1;i<=x;i++)for (j=y;j<=n*2;j++)w[i][j]++;
	}
	g[0]=1;for (i=2;i<=n*2;i+=2)g[i]=1ll*(i-1)*g[i-2]%mod;
	for (i=1;i<=n*2;i++)
		for (j=i+1;j<=n*2;j++)
			if (!cant[i][j])
				R[i][j]=j-i+1-2*w[i][j],
				Y[i][j]=n*2-2*(m-w[i][j])-(j-i+1);
	for (t=2;t<=n*2;t+=2)
		for (i=1;i<=n*2-t+1;i++){
			j=i+t-1;
			if (!cant[i][j]){
				dp[i][j]=1ll*g[R[i][j]]%mod;
				for (k=i+1;k<j;k++)dp[i][j]=(dp[i][j]-1ll*dp[i][k]*g[R[k+1][j]]%mod+mod)%mod;
				ans=(ans+1ll*dp[i][j]*g[Y[i][j]]%mod)%mod;
			}
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int a[510][510];

struct Ans_part{
  pl from;
  pl to;

  Ans_part(pl from,pl to){
    this->from=from;
    this->to=to;
  }
};

int main(){
  int h,w;cin>>h>>w;
  // 奇数のもののみ知れば良い
  int temp;
  rep(i,h){
    rep(j,w){
      cin>>temp;
      a[i][j]=temp%2;
    }
  }

  vector<Ans_part> ans;
  // 全部右下に移動させれば良いような気がする．
  rep(j,w){
    rep(i,h-1){
      if(a[i][j]==1){
        a[i+1][j]=(a[i+1][j]+a[i][j])%2;
        a[i][j]=0;
        ans.pb(Ans_part(mp(i+1,j+1),mp(i+2,j+1)));
      }
    }
  }

  rep(j,w-1){
    if(a[h-1][j]==1){
      a[h-1][j+1]=(a[h-1][j+1]+a[h-1][j])%2;
      a[h-1][j]=0;
      ans.pb(Ans_part(mp(h,j+1),mp(h,j+2)));
    }
  }

  cout<<ans.size()<<endl;
  rep(i,ans.size()){
    cout<<ans[i].from.fi<<" "<<ans[i].from.se<<" "<<ans[i].to.fi<<" "<<ans[i].to.se<<endl;
  }
}

Measured memory_bytes: 7536
#pragma warning(disable:4996)
#include<stdio.h>
int main(void) {
	char s[101];
	bool j = true;
	fgets(s, sizeof(s), stdin);
	for (int i = 0; s[i] != NULL; ++i) {
		if ((i + 1) % 2 == 0) {
			if (s[i] == 'R') {
				j = false;
				break;
			}
		}
		else {
			if (s[i] == 'L') {
				j = false;
				break;
			}
		}
	}
	j ? printf("Yes") : printf("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
    int n; cin >> n;
    string s; cin >> s;
    string t = "";
    string u = "";
    rep(i, n/2) t += s[i];
    for(int i=(n/2); i<n; i++){
        u += s[i];
    }

    if(t == u){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
N = int(input())
S = input()
res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tnp = [i,j,k]
            flag = 0
            for s in S:
                if int(s) == tnp[flag]:
                    flag += 1
                if flag == 3:
                    res += 1
                    break
print(res)

Measured memory_bytes: 68380
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, a ,b, c, d;
string s;
bool can(int i, int j) {
    for (int k = i; k + 1 <= j; k++) {
        if (s[k] == '#' && s[k + 1] == '#') return false;
    }
    return true;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    if (!can(a - 1, c - 1) || !can(b - 1, d - 1)) {
        cout << "No";
        return 0;
    }
    if (c < d) {
        cout << "Yes";
        return 0;
    }
    for (int i = b - 1; i <= d - 1; i++) {
        if (s[i] != '#') {
            if (i > 0 && s[i - 1] == '#') continue;
            if (i + 1 < n && s[i + 1] == '#') continue;
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <stack> 
#include <set>
#include <map>
using namespace std;

typedef long long ll;
const int mod = 1000000007;

#define N 100010
#define X first
#define Y second

int father[N];

struct node
{
	int x, y, id;
}p[N];

vector<pair<int, pair<int, int> > > lis;

int Find(int x)
{
	if (x == father[x]) return x;
	father[x] = Find(father[x]);
	return father[x];
}

void Merge(int x, int y)
{
	x = Find(x);
	y = Find(y);
	father[x] = y;
}


bool cmp(node a, node b)
{
	return a.x < b.x;
}

bool cmp2(node a, node b)
{
	return a.y < b.y;
}

int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);

	int n; ll res = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d %d", &p[i].x, &p[i].y);
		p[i].id = i;
		father[i] = i;
	}
	sort(p + 1, p + n + 1, cmp);
	for (int i = 1; i < n; ++i)
	{
		lis.push_back(make_pair(p[i + 1].x - p[i].x, make_pair(p[i].id, p[i + 1].id)));
	}
	sort(p + 1, p + n + 1, cmp2);
	for (int i = 1; i < n; ++i)
	{
		lis.push_back(make_pair(p[i + 1].y - p[i].y, make_pair(p[i].id, p[i + 1].id)));
	}

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

	for (int i = 0; i < lis.size(); ++i)
	{
		int x = lis[i].Y.X, y = lis[i].Y.Y, z = lis[i].X;
		if (Find(x) != Find(y))
		{
			res += z;
			Merge(x, y);
		}
	}
	cout << res << endl;
	return 0;
}



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


int main() {
	
	int n;
	cin>>n;
	long long MAX = -10000000000;
	int a;
	long long sum = 0;
	while(n--)
	{
		cin>>a;
		
		if(a > MAX)
		{
			MAX = a;
		}
		sum+=a;
	}
	if(MAX % 2 == 0)
	{
		cout<<(sum-(MAX/2));
	}
	else
	{
		cout<<((double)sum-(MAX/2)+0.5-1);
	}
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second

ll N,K;
ll A[100005];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>K;

rep(i,N) cin>>A[i];

ll n=0;
rep1(i,100005){
	n++;
	if(n*K-(n-1)>=N) break;
}
cout<<n<<endl;

}
	


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	cout<<setprecision(10);
	if(n&1){
		ld x=(n+1)/2;
		cout<<(x)/(ld)n;
	}
	else{
		n--;
		ld x=(n+1)/2;
		cout<<(x)/(ld)(n+1);
	}
	
	
	
	return 0;
}



Measured memory_bytes: 256
<?php
$s=trim(fgets(STDIN));
$k=trim(fgets(STDIN));
$n=strlen($s);
$c=1;
while($c<=$k){
$i=0;
while($i<$n){
$a[]=substr($s,$i,$c);
++$i;
}
++$c;
}
$a=array_unique($a);
sort($a);
echo $a[$k-1];


Measured memory_bytes: 8696
#include <iostream>

using namespace std;
typedef long long ll;

int N;
ll A,B,C,D;

int main() {
        cin >> N >> A >> B >> C >> D;
        for (int k=0; k<=N-1; k++) {
                if (k*C-(N-k-1)*D <= A-B && A-B <= k*D-(N-k-1)*C) {
                        cout << "YES\n";
                        return 0;
                }
        }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

vector<int> prime;

void calcPrime(){
	prime.pb(2);
	bool flag;
	int size;
	for(int i = 3; i < 246918; i ++){
		flag = true;
		size = prime.size();
		for(int j = 0; j < size; j ++){
			if(i%prime[j] == 0){
				flag = false;
				break;
			}
		}
		if(flag)prime.pb(i);
	}
}
int main(){

	calcPrime();
	vector<int> S(246918, 0);
	for(int i = 0; i < prime.size(); i ++){
		S[prime[i]] ++;
	}
	for(int i = 1; i < 246918; i ++){
		S[i] += S[i - 1];
		//if(i < 100)cout << i << " " << S[i] << endl;
	}
	//cout << "##############################" << endl;
	while(true){
		int N;
		cin >> N;
		if(N == 0)break;
		cout << S[N * 2] - S[N]<< endl;
	}

	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h,w; cin>>h>>w;
	vector<vector<int>>g(10,vector<int>(10));
	for(auto&&i:g)for(auto&&j:i)cin>>j;
	for(int k=0;k<10;++k){
		for(int i=0;i<10;++i){
			for(int j=0;j<10;++j){
				g.at(i).at(j)=min(g.at(i).at(j),g.at(i).at(k)+g.at(k).at(j));
			}
		}
	}
	int ans=0;
	for(int i=0;i<h*w;++i){
		int a; cin>>a;
		if(a==-1||a==1)continue;
		ans+=g.at(a).at(1);
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define var auto
#define Max std::max
#define Min std::min

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline int read()
{
	int x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
	return x;
}

void writeline(int x) {
	int s = 0;
	char f[8];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

#pragma GCC optimize ("-O3")
int main()
{
	int h = read(), w = read();
	int columnAccum[2000] = {};
	int rowMax[2000] = {};
	int max = 0;
	for (int i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (int j = 0; j < w; j++)
		{
			var c = getchar_unlocked() & 1;
			if (c)
			{
				max = Max(max, columnAccum[j] + rowMax[j]);
				for (int k = j - currentChain; k < j; k++)
					rowMax[k] = Max(rowMax[k], currentChain);
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		getchar_unlocked();
		for (int j = w - currentChain; j < w; j++)
			rowMax[j] = Max(rowMax[j], currentChain);
	}
	for (int i = 0; i < w; i++)
		max = Max(max, columnAccum[i] + rowMax[i]);
	writeline(max - 1);
	return 0;
}


Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

edges = [list(map(int, input().split())) for _ in range(M)]

rlt = 0

for i in range(M):
  uf = UnionFind(N+1)
  for j in range(M):
    if i == j:
      continue
    e = edges[j]
    uf.union(e[0],e[1])
  if min(uf.parents) > -N:
    rlt += 1
    
print(rlt)

Measured memory_bytes: 73824
import java.util.*;

public class Main{
    Scanner in = new Scanner(System.in);

    void solve(){
        int n = in.nextInt();
        int[] a = new int [n];
        for(int i = 0; i < n; i++){
            a[i] = in.nextInt();
        }

        long ans1 = 0, ans2 = 0, sum = 0;
        for(int i = 0; i < n; i++){
            sum += a[i];
            if(i%2 == 1 && sum <= 0){
                ans1 += Math.abs(sum) + 1;
                sum = 1;
            }
            if(i%2 == 0 & sum >= 0){
                ans1 += Math.abs(sum) + 1;
                sum = -1;
            }
        }
        sum = 0;
        for(int i = 0; i < n; i++){
            sum += a[i];
            if(i%2 == 0 && sum <= 0){
                ans2 += Math.abs(sum) + 1;
                sum = 1;
            }
            if(i%2 == 1 & sum >= 0){
                ans2 += Math.abs(sum) + 1;
                sum = -1;
            }
        }

        System.out.println(Math.min(ans1, ans2));
    }

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

Measured memory_bytes: 50476
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   
   if(A%2==0 || B%2==0) System.out.println("No");
   else System.out.println("Yes");
 }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC148E()
{
	ll N;
	cin >> N;
	if (N % 2 == 1)
	{
		cout << 0 << endl;
		return;
	}

	N /= 2;
	vl x(50);
	for (int i = 0; i <= 26; ++i)
	{
		ll M = N;
		N /= 5;
		x[i] = M - N * 5;
		if (N == 0)
			break;
	}
	vl y(27);
	for (int i = 1; i <= 26; ++i)
	{
		for (int j = 0; j < i; ++j)
			y[i] += y[j] * 4;
		y[i] += i;
	}

	ll ans = inner_product(y.begin(), y.end(), x.begin(), 0LL);
	cout << ans << endl;
}

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

Measured memory_bytes: 256
solve :: Int -> Int
solve n
  | oh == t && t == o = n
  | oh > t || (oh >= t && oh >= o) = oh * 100 + oh * 10 + oh
  | otherwise = (oh + 1) * 100 + (oh + 1) * 10 + (oh + 1)
  where
    oh = n `div` 100
    t = (n - (100 * oh)) `div` 10
    o = n - 100 * oh - 10 * t

main = do
  n <- readLn
  let ans = solve n
  print ans

Measured memory_bytes: 508
import sys
input = sys.stdin.buffer.readline

N, M = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

deg = [len(A) for A in adj]
f = []
ok = 0
for i in range(1, N+1):
    if deg[i] % 2 == 1:
        print('No')
        exit()
    elif deg[i] >= 6:
        ok = 1
    elif deg[i] == 4:
        f.append(i)

if ok:
    print('Yes')
    exit()

if len(f) >= 3:
    print('Yes')
    exit()

if len(f) <= 1:
    print('No')
    exit()

t1, t2 = f[0], f[1]
seen = [0] * (N+1)
seen[t1] = 1
seen[t2] = 1
st = [t1]
while st:
    v = st.pop()
    for u in adj[v]:
        if seen[u] == 0:
            seen[u] = 1
            st.append(u)

if sum(seen) != N:
    print('Yes')
else:
    print('No')


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	for(int i=0,pt=0,px=0,py=0;i<n;++i){
		int t,x,y; cin>>t>>x>>y;
		int st=abs(t-pt),di=abs(x-px)+abs(y-py);
		if(di>st||(di+st)&1){
			cout<<"No\n"s;
			return 0;
		}
		pt=t,px=x,py=y;
	}
	cout<<"Yes\n"s;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010

struct UF {
	int par[N],rank[N];
	
	void init(int n){
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}
	
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = par[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

string s;
int n, l[N], r[N], a[N], t[N], used[N];

int main(){
	cin>>s;
	n = s.size();
	ll kk = (n+1)/2;
	int m;
	cin>>m;
	rep(i, m){
		cin>>l[i]>>r[i];
		if(n%2==1){
			if(l[i]==kk);
			else if(l[i]>=kk) l[i]--;
			if(r[i]>=kk) r[i]--;
		}
		l[i]--; r[i]--;
	}
	if(n%2==1){
		s = s.substr(0, kk-1)+s.substr(kk);
		n--;
	}
	int n2 = n/2;
	rep(i, n2) a[i] = s[i]-s[n-i-1];
	for(ll i = n2-1; i >= 0; i--) t[i+1] = a[i+1]-a[i];
	t[0] = a[0];
	//rep(i, n2) cerr<<a[i]<<" "; cerr<<endl;
	//rep(i, n2+1) cerr<<t[i]<<" "; cerr<<endl;
	UF uf;
	uf.init(n2+1);
	rep(i, m){
		if(l[i]>r[i]) continue;
		if(r[i]<n2) continue;
		if(l[i]>=n2){
			ll r2 = 2*n2-l[i]-1;
			ll l2 = 2*n2-r[i]-1;
			l[i] = l2;
			r[i] = r2;
		} else {
			ll wl = n2-l[i];
			ll wr = r[i]-n2+1;
			if(wl==wr){
				l[i] = r[i] = -1;
			} else if(wl>wr){
				r[i] = l[i]+wl-wr-1;
			} else {
				r[i] = l[i]-1;
				l[i] = l[i] - (wr-wl);
			}
		}
	}
	rep(i, m){
		if(l[i]>r[i]) continue;
		if(l[i]<0) continue;
		uf.unite(l[i], r[i]+1);
		//cerr<<l[i]<<" "<<r[i]<<endl;
	}
	bool f = true;
	vector<vector<int> > v(n2+1);
	rep(i, n2+1) v[uf.find(i)].push_back(i);
	rep(i, n2+1){
		if(v[i].empty()) continue;
		ll x = 0;
		bool g = false;
		rep(j, v[i].size()){
			x += t[v[i][j]];
			//if(v[i][j]==n2) g = true;
		}
		if(!g && (x%26+26)%26!=0) f = false;
	}

	cout<<(f?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 4352
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

int main(){
    ll a[5];
    ll minimum=1LL<<60;
    int soeji=0;
    ll N;
    cin >> N;
    rep(i,5){
        cin >> a[i];
        if(minimum>a[i]){
            minimum=a[i];
        }
    }

    ll group=0;
    if(N%minimum==0){
        group=N/minimum;
    }else{
        group=N/minimum+1;
    }

    cout << group-1+5 << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = a + b;
		int e;
		e = Integer.parseInt(c);
		if ((int)Math.sqrt(e)*Math.sqrt(e) !=e)
			System.out.print("No");
		else
			System.out.println("Yes");

	}

}

Measured memory_bytes: 20948
# frozen_string_literal: true

class Node
  attr_accessor :key, :parent, :left, :right

  def initialize(key)
    @key = key
  end

  def root?
    parent ? false : true
  end
end

class Tree < Array
  def insert(node)
    y = nil
    x = root_node

    until x.nil?
      y = x
      x = if node.key < x.key
            x.left
          else
            x.right
          end
    end
    node.parent = y

    if y.nil?
      push node
    elsif node.key < y.key
      y.left = node
    else
      y.right = node
    end
  end

  def root_node
    find(&:root?)
  end
end

def print_order_by_preorder(node)
  return unless node

  print ' '
  print node.key
  print_order_by_preorder(node.left)
  print_order_by_preorder(node.right)
end

def print_order_by_inorder(node)
  return unless node

  print_order_by_inorder(node.left)
  print ' '
  print node.key
  print_order_by_inorder(node.right)
end

n = gets.to_i
array = readlines.map(&:chomp!).map do |line|
  if line != 'print'
    line.split[1].to_i
  else
    'print'
  end
end

tree = Tree.new

array.each do |e|
  if e != 'print'
    tree.insert(Node.new(e))
  else
    print_order_by_inorder(tree.root_node)
    print "\n"
    print_order_by_preorder(tree.root_node)
    print "\n"
  end
end



Measured memory_bytes: 84164
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
#define sqr(x) ((x) * (x))
#ifdef LOCAL
#define dbg(as...) {\
    vector<string> _v; \
    std::stringstream _ss(#as);\
    string _cur, _loc;\
    while (getline(_ss, _cur, ',')) {\
        while (count(_cur.begin(), _cur.end(), '(') != count(_cur.begin(), _cur.end(), ')')) {\
            getline(_ss, _loc, ',');\
            _cur += "," + _loc;\
        }\
    _v.pb(_cur);\
    }\
    err(_v.begin(), as);\
}
#else
#define dbg(as...)
#endif

template<typename T>
void err(vector<string>::iterator it, T a) {
    cerr << it->substr((*it)[0] == ' ') << " = " << a << '\n';
}
template<typename T, typename...Ts>
void err(vector<string>::iterator it, T a, Ts...as) {
    cerr << it->substr((*it)[0] == ' ') << " = " << a << ", ";
    err(++it, as...);
}

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(10);
        #ifdef LOCAL
        srand(300); 
        #else
        srand(time(0));
        #endif
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;

const int MAXN = 101;

int ans[MAXN][MAXN];


int main() {

    int h, w, n;
    cin >> h >> w >> n;

    int c = 0;
    int r = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        while (x > 0) {
            if (r % 2 == 0) {
                for (; x > 0 && c < w; --x, ++c) {
                    ans[r][c] = i;
                }
                if (c == w) {
                    c = w - 1;
                    ++r;
                }
            }
            if (r % 2 == 1) {
                for (; x > 0 && c >= 0; --x, --c) {
                    ans[r][c] = i;
                }
                if (c == -1) {
                    c = 0;
                    ++r;
                }
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
            cout << ans[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}


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

typedef long long ll;
ll MOD = 1000000007;
ll MOD1 = 2019;

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()
{
    ll L, R, mi = 1LL<<60;
    cin >> L >> R;

    if (R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    } else {
        for (ll i = L; i < R; i++) {
            for (ll j = i+1; j <= R; j++) {
                chmin(mi, i*j%2019);
            }
        }
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;++i)a[i]=scan.nextInt()-(1+i);
        Arrays.sort(a);
        int b = a[n/2];
        long res = 0;
        for(int i=0;i<n;++i)res+=Math.abs((long)a[i]-(long)b);
        System.out.println(res);
    }
}

Measured memory_bytes: 65200
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 100 + 10 ;
int n , m , x , y ;
int a[maxn] , b[maxn] ;
int main()
{
	cin >> n >> m >> x >> y ; 
	for ( int i = 0 ;i< n ;i++)
		cin >> a[i] ;
	for ( int i= 0; i<m ;i++)
		cin >> b[i] ;
	sort ( a , a+n ) ;
	sort ( b , b+m ) ;
	bool q = false  ;
	if ( a[n-1] < b[0] ) 
	{
		//cout << " * " << a[n-1] << " " << 
		for ( int  i = a[n-1]+1 ; i<=b[0] ; i++)
			if ( x < i && y >= i ) 
			       q= true ;
	}
	if ( q ) 
		cout << "No War" << endl;
	else
		cout << "War" << endl;	

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int a,b;
  cin>>a>>b;
  cout<<(a*b)-(a+b-1)<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> vec;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    int x = 0;
    rep(j, b) {
      int c;
      cin >> c;
      --c;
      x += (1 << c);
    }
    vec.push_back(P (x,a));
  }
  sort(vec.begin(), vec.end());

  int size = (int)pow(2,n);
  int dp[size];
  rep(i, size) dp[i] = Inf;

  rep(i, m) {
    int id = vec[i].first, cost = vec[i].second;
    dp[id] = min(dp[id], cost);
    rep(j, size) {
      dp[id|j] = min(dp[id|j], dp[id]+dp[j]);
    }
  }
  cout << (dp[size-1] < Inf ? dp[size-1] : -1) << endl;
  return 0; 
}

Measured memory_bytes: 256
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 1000+5;
const ll MOD = 1e9+7;
using namespace std;

int dp[MAX_N][MAX_N];
int a[MAX_N][MAX_N];
int n,m;

int main()
{
    cin >> n >> m;
    for(int i = 1;i<=n;++i)
    {
        string s;
        cin >> s;
        for(int j = 1;j<=m;++j)
            a[i][j] = (s[j-1]=='#');
    }
    dp[1][1] = !(a[1][1]);
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=m;++j)
        {
            if (a[i][j] or (i==1 and j==1))
                continue;
            dp[i][j] = (dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }
    cout << dp[n][m];
    return 0;
}


Measured memory_bytes: 8064
MAX = 123456*2
$p = Array.new(MAX + 1, true)

$p[0] = $p[1] = false
(2..MAX).each do |i|
  if $p[i]
    j = i * i
    while j <= MAX
      $p[j] = false
      j += i
    end
  end
end

loop do
  n = gets.to_i
  break if n == 0
  puts $p[n+1..n*2].select{|x| x}.size
end

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    string S; cin >> S;
    int ans = -1;
    for(int i=0; i<S.size(); i++){
        for(int j=i; j<S.size(); j++){
            int len = 0;
            for(int k=i; k<=j; k++){
                if(S[k] == 'A' || S[k] == 'T' || S[k] == 'C' || S[k] == 'G'){
                    len++;
                }else{
                    break;
                }
            }
            ans = max(ans, len);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
const int INF = 1 << 30;

int main() {
	int N;
	cin >> N;
	int count = 1 << N;
	vector<int>S(count);
	for (int i = 0; i < count; ++i) {
		cin >> S[i];
	}
	sort(S.rbegin(), S.rend());
	vector<int>T;
	T.push_back(S[0]);
	S[0] = -1;
	for (int i = 0; i < N; ++i) {
		sort(T.rbegin(), T.rend());
		int memo = 0;
		int tsize = T.size();
		for (int j = 0; j < tsize; ++j) {
			bool b = false;
			for (; memo < count; ++memo) {
				if (-1 == S[memo]) {
					continue;
				}
				if (S[memo] < T[j]) {
					T.push_back(S[memo]);
					S[memo] = -1;
					b = true;
					break;
				}
			}
			if (!b) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 5340
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int n;
int h[200005];
int b[200005];
long long t[600005];
int j=(1<<18);
void zmien(int poz, ll val)
{
	poz+=j;
	while(poz)
	{
		t[poz]=max(t[poz],val);
		poz/=2;
	}
}
ll daj(int gdzie ,int pocz, int kon , int x, int y)
{
	if(y>=kon and pocz>=x)
		return t[gdzie];
	int sro=(pocz+kon)/2;
	ll naj=0;
	if(sro>=x)
		naj=daj(2*gdzie,pocz,sro,x,y);
	if(y>sro)
		naj=max(naj,daj(2*gdzie+1,sro+1,kon,x,y));
	return naj;
}
int main(){
	cin>>n;
	for(int i=1;n>=i;i++)
		cin>>h[i];
	for(int i=1;n>=i;i++)
		cin>>b[i];
	for(int i=1;n>=i;i++)
	{
		long long  wynik=b[i]+daj(1,j,2*j-1,j,j+h[i]-1);
		zmien(h[i],wynik);
	}
	cout<<daj(1,j,2*j-1,j,j+n);
	return 0;
}


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


int main() {
    int N, K, num = 1;
    cin >> N >> K;
    
    for(int i =0; i < N; i++){
        if(num*2 < num+K){
            num *= 2;
        }
        else{
            num += K;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  int X, t;   cin >> X >> t;
  int ans = (X - t < 0) ? 0 : X - t;
  SCOUT(ans) << endl;

  return 0;
}


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

#pragma warning(disable : 4267) // "int n = (unsigned)size"

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
const double INFD = numeric_limits<double>::infinity();
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
bool nearlyeq(double x, double y) { return abs(x - y) < eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	ll a, b, t; cin >> a >> b >> t;
	ll turn = t / a;
	cout << turn * b << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
using namespace std;

int main() {
  string s;
  cin>>s;
  int e=s.size();
  int A=0;
  int Z=0;
  for(int i=0;i<e;i++) {
    if(s.at(i)=='A') {
      A=i;
      break;
    }
  }
  for(int i=e-1;i>=A;i--) {
    if(s.at(i)=='Z') {
      Z=i;
      break;
    }
  }
  cout<<Z-A+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    vector<long long> sa(n+1), sb(m+1);
    rep(i, n) sa[i+1] = sa[i] + a[i];
    rep(i, m) sb[i+1] = sb[i] + b[i];
    int ans = 0;
    for (int i=0; i<=n; ++i) {
        long long rm = k - sa[i];
        if (rm < 0) break;
        auto iter = upper_bound(sb.begin(), sb.end(), rm);
        int bn = iter - sb.begin() - 1;
        if (bn == -1) continue;
        ans = max(ans, i + bn);
    }
    cout << ans << endl;
}

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

int main(void){
  int N, H;
  int a[100000];
  int b[100000];
  vector<int> z;
  pair<int, int> p[100000];
  int m = 0;
  int c = 0;
  cin >> N >> H;
  REP(i, N){
    cin >> a[i] >> b[i];
    m = max(a[i], m);
    p[i] = make_pair(a[i], b[i]);
  }
  REP(i, N){
    if(p[i].second > m){
      z.push_back(p[i].second);
    }
  }
  sort(z.begin(), z.end());
  reverse(z.begin(), z.end());
  REP(i, z.size()){
    if(H  <= 0)break;
    c++;
    H -= z[i];
  }
  if(H > 0)c += ceil((double)H / m);
  cout << c <<endl;
  return 0;
}


Measured memory_bytes: 2428
#include<bits/stdc++.h>
#define MAX 200123
#define sz(x) (int)(x).size()
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

string s;
int d, sum, f[2019], a[MAX], ans, p10, n;

int main(){_
    cin >> s;
    n = sz(s);
    p10 = 1;
    for (int i=n; i--; p10=(p10*10)%2019){
        int d = s[i]-'0';
        a[i] = (p10 * d)%2019;
    }
    f[0] = 1;
    for (int i=0; i<n; ++i){
        sum = (sum + a[i])%2019;
        ans += f[sum];
        ++f[sum];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4544
import sys
#sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

queries = [0 for _ in range(n)]
for _ in range(q):
	p, x = map(int, input().split())
	queries[p-1] += x

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

st = [(0, 0, -1)]
while st:
	l = st.pop()
	ans[l[0]] = l[1] + queries[l[0]]
	for v in adj[l[0]]:
		if v != l[2]:
			st.append((v, ans[l[0]], l[0]))

print(*ans)


Measured memory_bytes: 64996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll n, d;
	cin >> n >> d;
	vector<ll> x(n), y(n);
	rep(i,n) cin >> x[i] >> y[i];
	ll ans = 0;
	rep(i,n) {
		ll k = d * d;
		ll pq = x[i] * x[i] + y[i] * y[i];
		if (pq <= k) ans++;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 6424
#include<stdio.h>
int main(void)
{
	int n,a[100],i,j,sum,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]<a[j]){
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	sum=a[0]-a[n-1];
	//printf("a0=%d a[n]=%d\n",a[0],a[n-1]);
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 128
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

	readChars(): string[] {
		let S = this.readLine();
		return new Array(S.length).fill(null).map((_, i) => S.charAt(i));
	}

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
} 


function solve(): string {
	let reader = new Reader();
	let N = reader.readInt();
	let s = reader.readLine();
	let isSheep: (boolean|null)[] = new Array(N).fill(false);

	for(let first of [false, true]) {
		for(let second of [false, true]) {
			isSheep.fill(null)
			isSheep[0] = first;
			isSheep[1] = second;
			let found = true;
			for(let i=2; i<N+3; i++) {
				let i2 = (i-2)%N, i1 = (i-1)%N, i0 = i%N;
				let current: null|boolean = null;
				if (isSheep[i1]) {
					if (s.charAt(i1) == 'o') {
						current = isSheep[i2];
					} else {
						current = !isSheep[i2];
					}
				} else {
					if (s.charAt(i1) == 'o') {
						current = !isSheep[i2];
					} else {
						current = isSheep[i2];
					}
				}
				if (isSheep[i0] == null) {
					isSheep[i0] = current;
				} else {
					if (isSheep[i0] != current) {
						found = false;
						break
					}
					isSheep[i0] = current;
				}
			}
			if (found) {
				return isSheep.map((value) => value?'S': 'W').join("");
			}
		}
	}
	return '-1';
}


console.log(solve());


Measured memory_bytes: 37048
N = int(input())
X = list(map(int, input().split()))

tairyokus = []
for p in range(1, 101):
    tairyoku = 0
    for x in X:
        tairyoku += (x - p) ** 2
    tairyokus.append(tairyoku)
print(min(tairyokus))


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

#define ll long long
#define int long long
#define MOD 1000000007
#define MAX 100001
#define debugStart cout << "\n[DEBUG START]\n"
#define debugStop cout << "\n[DEBUG STOP]\n"
#define KHATAM cout << std::endl;
// #define MAX_H 100001
// #define MAX_W 100001 

int H, W=10000, N;
auto getValue ( std::vector<string > const& input, std::vector<std::vector<int> > const& grid, int row, int col ) -> int {
        
        int left = 0, up = 0;
        left = ( (col <= 0) or (input[row][col - 1] == '#') )? 0 : grid[row][col - 1];
        up = ( (row <= 0) or (input[row-1][col] == '#') )? 0 : grid[row - 1][col];
        return (left + up)%MOD;
}

auto solve ( ) -> void {

        std::cin >> H >> W ;
        std::vector<string> input(H);

        for ( int i = 0; i < H; ++i ) {

                std::cin >> input[i];
        }
        std::vector<std::vector<int> > grid(H);        
        for ( int i = 0; i < H; ++i ) {
                grid[i] = vector<int>(W, 0);
        }
        grid[0][0] = 1;
        
        for ( int i = 0; i < H; ++i ) {

                for ( int j = 0; j < W; ++j  ) {
                
                        if ( grid[i][j] != -1 and (i!=0 or j != 0) ) {
                                grid[i][j] = getValue( input,grid, i, j );
                        } 
                        // std::cout << grid[i][j] << " ";
                }
                // std::cout << '\n';
        }
        
        std::cout <<  grid[H-1][W-1] << std::endl;
}


signed
main() {

        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int T = 1; 
        // cin >> T;
        for ( int testcase = 1; testcase <= T; ++testcase ) {

                solve();
        }
        return 0;
}

Measured memory_bytes: 9216
s = input()
front = int(s[:2])
back = int(s[2:4])
if 0 < front <= 12 and 0 < back <= 12:
    print('AMBIGUOUS')
elif 0 < front <=12 and (back > 12 or back == 0):
    print('MMYY')
elif (front > 12 or front == 0) and  0 < back <=12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(((modPow(10, n) - modPow(9, n) * 2 % MOD + modPow(8, n)) % MOD + MOD) % MOD);
		}
	}

	/**
	 * n^m mod MOD を計算する
	 * 
	 * @param n
	 * @param m
	 * @return n^m mod MOD
	 */
	private static long modPow(long n, long m) {
		long result = 1L;
		while (m > 0) {
			if (1 == (m & 1)) {
				result = result * n % MOD;
			}
			n = n * n % MOD;
			m >>= 1;
		}
		return result;
	}
}


Measured memory_bytes: 35728
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll n,m,k;
ll poww(ll x,ll k)
{
	ll base=x,ans=1;
	while(k)
	{
		if(k&1)ans=ans*base%mod;
		base=base*base%mod;
		k>>=1;
	}
	return ans;
}
ll nok(ll x)
{
	ll ans=1;
	for(int i=1;i<=x;i++)ans=ans*i%mod;
	return ans;
}
int main()
{
	ll ans=0,dlt;
	scanf("%lld %lld %lld",&n,&m,&k);
	dlt=nok(n*m-2)*poww(nok(k-2),mod-2)%mod*poww(nok(n*m-k),mod-2)%mod;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			ans=(ans+(1+n-i)*(n-i)/2*m%mod*dlt%mod)%mod;
			ans=(ans+(1+m-j)*(m-j)/2*n%mod*dlt%mod)%mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

map<string, int>Dp;
queue < string > strQue;

void calculationAll() {
	int indexOfZero, currentPos;
	int direction[] = { 1,4,-1,-4 };
	string next;

	strQue.push("01234567");
	Dp["01234567"] = 0;
	while (!strQue.empty()) {
		string tmp = strQue.front();
		strQue.pop();
		for (int i = 0; i < 8; i++) {
			if (tmp[i] == '0') {
				indexOfZero = i;
				break;
			}
		}
		for (int i = 0; i < 4; i++) {
			currentPos = indexOfZero + direction[i];
			if (currentPos < 0 || currentPos > 7) {
				continue;
			}
			if ((indexOfZero == 3 && currentPos == 4) || (indexOfZero == 4 && currentPos == 3)) {
				continue;
			}

			next = tmp;
			swap(next[currentPos], next[indexOfZero]);
			if (Dp.find(next) == Dp.end()) {
				Dp[next] = Dp[tmp] + 1;
				strQue.push(next);
			}
		}
	}
}


int main() {
	int num;
	string input, str;
	stringstream ss;

	calculationAll();

	while (getline(cin, str)) {
		input = "";
		ss.clear();
		ss << str;
		while (ss >> num) {
			input += num + '0';
		}
		//cout << input << endl;
		cout << Dp[input] << endl;
	}


	return 0;
}


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

int main() {
  
  int64_t N; cin >> N;
  
  vector<int64_t> vec(5);
  
  for (int i = 0; i < 5; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  int64_t tmp = vec[0];
  
  if (tmp < N) {
    
    if (N % tmp == 0) cout << 4 + N / tmp << endl;
    
    else cout << 5 + N / tmp << endl;
    
  }
  
  else cout << 5 << endl;
  
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
// #include 
using namespace std;

void solve()
{
   int a, b, h;
   cin >> a >> b >> h;
   cout << (a + b) *h /2 << endl;
}

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

Measured memory_bytes: 3608