akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll INF = 1LL << 60; //MAX 9223372036854775807
void warshallfloyd(vector<vector<ll>> &d)
{
  for (int k = 0; k < d.size(); k++)
    for (int i = 0; i < d.size(); i++)
      for (int j = 0; j < d.size(); j++)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main()
{
ll n ,mx=-1;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
vector<ll> b(n);
rep(i, n){
  cin >> b[i];
}
rep(i,n){
  if(!(a[i]==b[i]||a[i]>b[i]*2)){
    cout << -1 << endl;
    return 0;
  }
  if(a[i]!=b[i])mx=max(mx,a[i]);
}
if(mx==-1){
  cout << 0 << endl;
  return 0;
}
vector<bool> an(mx+1,1);
an[0]=0;
an[mx]=0;
for (ll i = mx-1; i > 0; i--)
{
  an[i]=0;
  vector<vector<ll>> d(mx+1, vector<ll>(mx+1, INF));
  rep(j, mx+1)d[j][j] = 0;
  rep(k,mx)rep(l,mx){
    if(an[l+1])d[k+1][(k+1)%(l+1)]=0;
  }
  warshallfloyd(d);
  rep(k,n){
    if(d[a[k]][b[k]]!=0)an[i]=1;
  }
}
rep(i,an.size()){
  if(an[i])ans+=1LL<<i;
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;

int main() {
    string a,b,c;
    cin>>a>>b>>c;
    
    cout<<a[0]<<b[1]<<c[2]<<endl;
    
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define int int64_t
#define double long double
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end() 
using namespace std;
//using pr = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
bool has_divisor(int, int);

//グローバル変数
//const int MAX_N;
//const int MAX_M;
//vvec data(N, vec(M));
//const int INF = ;
//const int mod = ;

//関数：
/* yにxをn回乗じmodで割った余りを返す。
（素数pに対して x**p = x (mod p) が成り立つ。）*/
int mod_pow(int y, int x, int n, int mod) {
	int ans = y;
	rep(i, n) {
		ans *= x;
		ans %= mod;
	}
	return ans;
}

/* ユークリッドの互除法(mx > mn) */
int gcd(int mx, int mn) {
	if(mn == 0) return(mx);
	else gcd(mn, mx%mn);
}

/* 素数判定関数 */
bool is_prime(int n) {
	if (n == 1) return false;
	else if (n == 2) return true;
	else {
		return !has_divisor(n, 2);
	}
}

/* クイック・ソート（返し値：互換数） */
int64_t quicksort(vector<int> &arr, int left, int right) {
	int i, j, p;
	int64_t ans = 0;
	i = left; j = right;
	p = (arr[i]+arr[j]) / 2;
	while(i < j) {
		while(arr[i] < p) i++;
		while(arr[j] > p) j--;
		if (i < j) {
			swap(arr[i++], arr[j--]);
			ans += abs(i-j);
		}
		if(i == j) {
			if(arr[i] < p) i++;
			else if(arr[j] > p) j--;
		}
		if (i >= left+2) ans += quicksort(arr, left, i-1);
		if (j <= right-2) ans += quicksort(arr, j+1, right);
	}
	return ans;
}

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

	int n; cin >> n;
	vector<pair<double,double>> pt(n);
	rep(i, n) {
		double a, b;
		cin >> a >> b;
		pt[i].first = a;
		pt[i].second = b;
	}
	
	double tld = 0;
	rep(i, n)rep(j, n) {
		tld += sqrt((pt[i].first-pt[j].first)*(pt[i].first-pt[j].first) + (pt[i].second-pt[j].second)*(pt[i].second-pt[j].second));
	}
	tld /= n;
	
	cout << fixed << setprecision(10) << tld << endl;
	return 0;
}

// 以下の関数等は気にしない。
bool has_divisor(int n, int i) {
	//base case 1:
	if (i == n) return false;
	//base case 2:
	if (n % i == 0) return true;
	return has_divisor(n, i+1);
}

//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);
//int ans = (char)grid - '0';
//int id = lower_bound(all(arr), x) - arr.begin();

/*struct data {
	char *name;
	int age;
	int height;
	double weight;
};*/

/*string ans = w;
string &ref = ans;
rep(i, N) {
	ref[i] = arr[i];
}*/

/*map<int,int> mp;
for(auto p : mp) {
	ct += p.second*(p.second-1); }

map<int,int>::iterator itr;
for(itr = mp.begin(); itr != mp.end(); itr++) {
	ans += itr->second * (itr->second-1);
}*/


Measured memory_bytes: 256
N, M = map(int, input().split())
stu_li = [list(map(int, input().split())) for i in range(N)]
chk_li = [list(map(int, input().split())) for i in range(M)]

min_dist = 10 ** 10
min_num = M
for i in range(N) :
    for j in range(M) :
        dist = abs(stu_li[i][0] - chk_li[j][0]) + abs(stu_li[i][1] - chk_li[j][1])
        if dist < min_dist : 
            min_dist = dist
            min_num = j
    print(min_num + 1)
    min_dist = 10 ** 10
    min_num = M


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	string s;
	cin>>s;
	cout<<count(all(s),'+')-count(all(s),'-')<<endl;
	return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 2000;
int n;
ll x[MAXN];
ll y[MAXN];
ll dx[] = {0, 0, 1, -1};
ll dy[] = {1, -1, 0, 0};
char ch[] = {'U', 'D', 'R', 'L'};
const ll INF = 1e18;


int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> y[i];
	int fl = 0;
	if ((x[0] + y[0]) % 2 == 0) {
		fl = 1;
		for (int i = 0; i < n; ++i)
			--x[i];
	}
	for (int i = 0; i < n; ++i) {
		if ((x[i] + y[i]) % 2 == 0) {
			cout << -1 << "\n";
			return 0;
		}
	}
	vector<ll> vv;
	for (int i = 0; i <= 31; ++i)
		vv.push_back(1ll << i);
	if (fl)
		vv.push_back(1);
	reverse(vv.begin(), vv.end());
	cout << vv.size() << "\n";
	for (ll x: vv)
		cout << x << " ";
	cout << "\n";
	for (int i = 0; i < n; ++i) {
		string s;
		if (fl)
			s += "R";
		for (int j = 31; j >= 0; --j) {
			int bst = -1;
			ll now = INF;
			for (int k = 0; k < 4; ++k) {
				ll cur = abs(x[i] - dx[k] * (1ll << j)) + abs(y[i] - dy[k] * (1ll << j));
				if (cur < now)
					now = cur, bst = k;
			}
			x[i] -= dx[bst] * (1ll << j);
			y[i] -= dy[bst] * (1ll << j);
			s += ch[bst];
		}
		cout << s << "\n";
	}
	return 0;
}




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


void InputFrom(int from[], int num);
void InputTarget(int target[], int num);

int main(void)
{
    int i;

    int num_from;
    scanf("%d", &num_from);
    int *from;
    from = (int *)malloc(sizeof(int) * num_from);
    if (from == NULL) {
        printf("ERROR\n");
        return 1;
    }
    InputFrom(from, num_from);

    int num_target;
    scanf("%d", &num_target);
    int *target;
    target = (int *)malloc(sizeof(int) * num_target);
    if (target == NULL) {
        printf("ERROR\n");
        return 1;
    }
    InputTarget(target, num_target);

    int cnt = 0;
    for (i = 0; i < num_target; i++) {
        int first = 0, last = num_from;
        int mid;
        while (first <= last) {
            mid = (last + first) / 2;
            if (from[mid] < target[i]) {
                first = mid + 1;
            } else if (target[i] < from[mid]) {
                last = mid - 1;
            } else {
                cnt++;
                break;
            }
        }
    }

    printf("%d\n", cnt);

    return 0;
}

void InputFrom(int from[], int num)
{
    int i;

    for (i = 0; i < num; i++) {
        scanf("%d", from + i);
    }
}

int cmp(const void *a, const void *b)
{
    int diff = *(int *)a - *(int *)b;
    return diff;
}

void InputTarget(int target[], int num)
{
    int i;

    for (i = 0; i < num; i++) {
        scanf("%d", target + i);
    }
}

Measured memory_bytes: 1188
s=input()
f=0
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    f=1
    print(i+1,i+2)
    break
if f==0:
  for i in range(len(s)-2):
    if s[i]==s[i+2]:
      f=1
      print(i+1,i+3)
      break
if f==0:
  print(-1,-1)

Measured memory_bytes: 3188
import math

M = int(input())
L = [1 for k in range(M+1)]

P = [2]
for p in range(3,1001,2):
    f = 1
    for k in range(2,int(math.sqrt(p))+1):
        if p%k == 0:
            f = 0
    if f == 1:
        P.append(p)
S = [1 for k in range(168)]

for N in range(1,M+1):
    p = 2
    while N > 1:
        if N%p==0:
            S[P.index(p)] += 1
            N//=p
        else:
            p += 1

ans = 1
for p in S:
    ans *= p
    ans %= 10**9+7
print(ans)

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

int main(){
  string b;
  cin >> b;
  if(b=="A")
    b = "T";
  else if(b=="T")
    b = "A";
  else if(b=="G")
    b = "C";
  else
    b = "G";
  cout << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

ll w[100],v[100],ar[100][100000],sum;
ll dp[100001];
int main()
{
	ll n,wt,mx=0;
	cin>>n>>wt;
	ll i,j;
	for(i=0;i<n;i++)
		cin>>w[i]>>v[i];
	for(i=0;i<n;i++)
	{
		for(j=wt-w[i];j>=0;j--)
			dp[j+w[i]]=max(dp[j+w[i]], dp[j]+v[i]);
	}
	for(i=0;i<100001;i++)
		mx=max(mx,dp[i]);
	cout<<mx;
} 

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M, K; cin >> N >> M >> K;
    ll A[N], B[M];
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    int ans = 0;
    vector<ll> ruiA(N+1, 0), ruiB(M+1, 0);
    for(int i = 1; i <= N; i++) ruiA[i] = ruiA[i-1] + A[i-1];
    for(int i = 1; i <= M; i++) ruiB[i] = ruiB[i-1] + B[i-1];
    for(int i = 0; i <= N; i++){
        ll rem = K - ruiA[i];
        if(rem < 0) break;
        int ok = 0, ng = M+1;
        int m = (ok+ng)/2;
        while(abs(ok-ng) > 1){
            if(ruiB[m] <= rem) ok = m;
            else ng = m;
            m = (ok+ng)/2;
        }
        ans = max(ans, i + ok);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9548
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

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

        Arrays.sort(b);
        int med = b[n/2];

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.abs(a[i] - (med + i+1));
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 66200
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            if (s == "A")
            {
                WriteLine("T");
            }
            else if (s == "T")
            {
                WriteLine("A");
            }
            else if (s == "C")
            {
                WriteLine("G");
            }
            else if (s == "G")
            {
                WriteLine("C");
            }
        }
    }
}


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

int main()
{
 string a, b;
 cin >> a >> b;
 if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
     cout << "YES" << endl;
 }else{
     cout << "NO" << endl;
 }
}

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

bool chk(int x) {
	for(int i=2;i*i<=x;i++)
		if(x%i==0) return false;
	return true;
}

int main() {
	int x;
	scanf("%d", &x);
	while(!chk(x)) x++;
	printf("%d\n", x);
	
	return 0;
}

Measured memory_bytes: 256
n, y = list(map(int, input().split()))
ansFlg = False
for a in range(n+1):
    for b in range(n+1):
        if 9000*a + 4000*b == y-1000*n:
            c = n - a - b
            if c>=0:
                print(a, b, c)
                ansFlg =True
        if ansFlg:
            break
    if ansFlg:
        break
if ansFlg==False or y-1000*n < 0:
     print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
bool chmin(ll&a,ll b){if(a>b){a=b;return true;}return false;}
bool chmax(ll&a,ll b){if(a<b){a=b;return true;}return false;}
#define debg cout<<"debg"<<endl
#define out(a) cout<<(a)<<endl

signed main(){
  
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];

  vector<ll> b(n);
  rep(i,n){
    ll bi=i+1;
    b[i]=a[i]-bi;
  }
  sort(b.begin(),b.end());
  ll cent1,cent2;
  cent1=n/2;
  cent2=cent1-1;
  ll ans=0;
  rep(i,n){
    ans+=abs(a[i]-(b[cent1]+i+1));
  }
  if(cent2>=0){
    ll tmp=0;
    rep(i,n){
      tmp+=abs(a[i]-(b[cent2]+i+1));
    }
    chmin(ans,tmp);
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll

using namespace std;
using Graph = vector<vector<int> >;

int Input[200100];
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> inline bool chmin(T&a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  int N; cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
  }

  int right = 0;
  int ans = 0;
  int sum = 0;
  for (int left = 0; left < N; left++) {
    if (right == left) {
      sum += Input[right];
      right++;
    }
    while (right < N && (sum ^ Input[right]) == sum + Input[right]) {
      sum += Input[right];
      right++;
    }
    
    ans += right - left;
    sum -= Input[left];
  }
  cout << ans << endl;
}


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

int main(){
  int i,j,n;

  scanf("%d",&n);
  char s[12];
  long long m=0,a=0,r=0,c=0,h=0;
  scanf("%c",&s[0]);

  for(i=0;i<n;i++){
    for(j=0;j<=10;j++){
      scanf("%c",&s[j]);
      if(s[j]=='\n') break;
    }
    if(s[0]=='M') m++;
    if(s[0]=='A') a++;
    if(s[0]=='R') r++;
    if(s[0]=='C') c++;
    if(s[0]=='H') h++;
  }
  long long x=0;
  x=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
  printf("%lld",x);
  return 0;
}


Measured memory_bytes: 128
#include<cmath>
#include<vector>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main() {
	int N;
	cin >> N;
	double f;
	if (N % 2 == 0) {
		f = 0.5000000000;
	}
	else {
		f = static_cast<double>(N / 2 + 1) / static_cast<double>(N);
	}

	cout << f << endl;
}



Measured memory_bytes: 256
from collections import Counter

s = input()


def convert(st, toS, cou):
    if st.count(st[0]) == len(st):
        return cou
    for i in range(len(st)):
        if i+1 < len(st) and st[i+1] == toS:
            st[i] = toS
    return convert(st[:-1], toS, cou+1)


ans = 200
for j in set(s):
    ans = min(ans, convert(list(s), j, 0))
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<list>
using namespace std;
 
typedef long long ll;


pair<int,int> getPair(int a,int b){
	return pair<int,int>(min(a,b),max(a,b));
}

int main(){
	int n ;
	cin >> n;
	vector<queue<int> > v(n);
	for(int i=0;i<n;++i){
		int a;
		for(int j=0;j<n-1;++j){
			cin >> a;
			a--;
			v[i].push(a);
		}
	}

	queue<pair<int,int> > que;
	
	set<pair<int,int> > se;
	for(int i=0;i<n;++i){
		pair<int,int> p = getPair(i,v[i].front());
		v[i].pop();
		que.push(p);
	}
	vector<int> ma(n,0);
	while(!que.empty()){
		pair<int,int> p = que.front();
		que.pop();
		set<pair<int,int> >::iterator it = se.find(p);
		int a = p.first;
		int b = p.second;
		if(it != se.end()){
			se.erase(it);
			if(!v[a].empty()){
				//cout << "push a " << getPair(v[a].front(),a).first << " "<<  getPair(v[a].front(),a).second <<endl;
				
				que.push(getPair(v[a].front(),a));
				v[a].pop();
			}
			if(!v[b].empty()){
				//cout << "push b " << getPair(v[b].front(),b).first << " "<<  getPair(v[b].front(),b).second <<endl;
				
				que.push(getPair(v[b].front(),b));
				v[b].pop();
			}
			
			int d = max(ma[a],ma[b]) + 1;
			ma[a] = ma[b] = d;
			//cout << a << " " << b << " " << d <<endl;
		}else{
			//cout << p.first << " " << p.second <<endl;
			se.insert(p);
		}
	}
	
	for(int i=0;i<n;++i){
		if(!v[i].empty()){
			cout << -1 <<endl;
			return 0;
		}
	}
	
	int res = 0;
	for(int i=0;i<n;++i){
		res = max(res,ma[i]);
	}
	cout << res <<endl;
	
	//cout << "tmp, f" << tmp << " " << f <<endl;
		
	
	
	
	return 0;
}



Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    n%=10;
    if(n==3) cout<<"bon";
    else if(n==0 or n==1 or n==6 or n==8) cout<<"pon";
    else cout<<"hon";
    cout<<'\n';
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
 
int main(){
    int n;
    cin>>n;
     
    for(int i=1;i<=n;i++){
        if(i % 3 == 0){
            cout<<" "<<i;
            continue;
        }
        int j = i;
        while(j>0){
            if(j % 10 == 3){
                cout<<" "<<i;
                break;
            }else j /= 10;
        }
    }
    cout<<endl;
 
    return 0;
}

Measured memory_bytes: 1160
N,K,*A = `dd`.split.map &:to_i
ss = [0]
sp = [0]
A.each{ |a| 
  ss << ss[-1] + a
  sp << sp[-1] + [a,0].max
}
#p A, ss, sp
p (0..N-K).map{ |i|
  j = i+K
  x = sp[i]
  z = sp[-1] - sp[j]
  #p [i,j,x,z]
  [x+0+z, x+ss[j]-ss[i]+z].max
}.max


Measured memory_bytes: 14724
#include <bits/stdc++.h>
using namespace std;
inline int read(int &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
inline void write(int x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}
int ans;
char s[100005];
signed main(){
	read(ans);ans=0;
	scanf("%s",s+1);
	for(int i=1;s[i];i++) if(s[i]!=s[i-1]) ans++;
	write(ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a, b,ans=0;
    scanf("%lld %lld",&a, &b);
    ans=max({a+(a-1),b+(b-1),a+b});
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
int main()
{
	int i;
	char s[5];
	for (i = 0; i < 3; i++) {
		scanf("%c", &s[i]);
	}
	if (s[0] == 'S' && s[1] == 'U') {
		printf("7\n");
	}
	if (s[0] == 'M') {
		printf("6\n");
	}
	if (s[0] == 'T' && s[1] == 'U') {
		printf("5\n");
	}
	if (s[0] == 'W') {
		printf("4\n");
	}
	if (s[0] == 'T' && s[1] == 'H') {
		printf("3\n");
	}
	if (s[0] == 'F') {
		printf("2\n");
	}
	if (s[0] == 'S' && s[1] == 'A') {
		printf("1\n");
	}
	return 0;
}

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

int main(){
    int N, a[100];

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

    bool b[N];

    for(int i = 0; i < N; i++) b[i] = false;

    for(int i = 0; i < N; i++){
        if(a[i]%2 == 1) b[i] = true;
        else if(a[i]%3 == 0 || a[i]%5 == 0) b[i] = true;
    }

    string ANS = "APPROVED";

    for(int i = 0; i < N; i++){
        if(b[i] == false) ANS = "DENIED";
    }

    cout << ANS << "\n";


}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B >= C + D) {
    if (A + B == C + D){
      cout << "Balanced" << endl;
    } else {
      cout << "Left" << endl;
    }} else {
      cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll a, b, x;
	cin >> a >> b >> x;
	ll B = b / x + 1;
	ll A = (a - 1) / x + 1;
	if (a == 0)A = 0;
	cout << B - A << "\n";

	return 0;
}

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

def sg(li):
    be = sum(li) / len(li)
    if be >= int(be) + 0.5:
        return int(be) + 1
    else:
        return int(be)

P = sg(X)
cnt = 0
for x in X:
    cnt += (x - P)**2
    
print(cnt)

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

constexpr int64_t MOD = 1e9 + 7;
constexpr int64_t SIZE = 1e5;

array<int64_t, SIZE+10> fac, ifac;

int64_t modpow(int64_t x, int64_t n, int64_t m = 1) {
    return n == 0 ? m : modpow(x * x % MOD, n >> 1, n & 1 ? m * x % MOD : m);
}

int64_t comb(int64_t n, int64_t k) {
    return n == 0 && k == 0 ? 1
        : n < k || n < 0 ? 0
        : fac[n] * ifac[k] % MOD * ifac[n-k] % MOD;
}

int main() {
    fac[0] = ifac[0] = 1;
    for (int64_t i = 0; i < SIZE + 10; i++) {
        fac[i+1] = fac[i] * (i+1) % MOD;
        ifac[i+1] = ifac[i] * modpow(i+1, MOD-2) % MOD;
    }

    int64_t n;
    cin >> n;
    vector<int64_t> a(n+1);
    map<int64_t, int64_t> m;
    int64_t d = 0;
    for (int64_t i = 0; i < n+1; i++) {
        int64_t aa;
        cin >> aa;
        if (m[a[i] = aa]++ == 1) d = aa;
    }
    auto c1itr = find(begin(a), end(a), d);
    auto c2itr = find(next(c1itr), end(a), d);
    int64_t c = distance(begin(a), c1itr) + distance(c2itr, end(a)) - 1;

    for (int64_t i = 1; i <= n+1; i++) {
        cout << (comb(n+1, i) - comb(c, i-1) + MOD) % MOD << endl;
    }
}


Measured memory_bytes: 9856
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int main(){
	int n,k,t,u,v,l;
	bool is[10000]={};
	double eps=1e-9;
	cin>>n>>k>>t>>u>>v>>l;
	rep(i,n){
		int d;
		cin>>d;
		is[d]=1;
	}
	double ans=0;
	int now=0;
	double lt=0;
	rep(i,l){
		if(lt<eps && now>0) now--,lt=t;
		if(is[i]){
			if(now<k) now++;
			else lt=t;
		}
		if(lt<eps && now>0) now--,lt=t;
		if(lt>eps*100) lt-=1.0/v,ans+=1.0/v;
		else ans+=1.0/u;
	}
	printf("%.9f\n",ans);
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
using namespace std;
const int inf = (1<<29);

int main() {
  int h, n; cin >> h >> n;
  vector<int> a(n), b(n);
  for (int i=0; i<n; i++) cin >> a[i] >> b[i];

  vector<int> dp(h+1, inf);
  dp[0] = 0;

  for (int i=0; i<h; i++) {
    for (int j=0; j<n; j++) {
      int x = min(i + a[j], h);
      dp[x] = min(dp[x], dp[i] + b[j]);
    }
  }

  cout << dp[h] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
struct Tree
{
	char win;
	int winnum;
};
map<int, Tree> tree;
int numchar = 0;
int hash1[2000];
int res = 0;
void judge(int i)
{
	if (tree[i].win==0)
	{
		judge(i * 2);
		judge(i * 2 + 1);
		if (tree[i * 2].winnum&&tree[i * 2 + 1].winnum)
			res = 1;
		if (tree[i * 2].winnum < 0 || tree[i * 2 + 1].winnum < 0)
			res = 1;
		if (tree[i * 2].winnum > tree[i * 2 + 1].winnum)
		{
			tree[i].win = tree[i * 2].win;
			tree[i].winnum = tree[i * 2].winnum - 1;
		}
		else
		{
			tree[i].win = tree[i * 2 + 1].win;
			tree[i].winnum = tree[i * 2 + 1].winnum - 1;
		}
		if (tree[i].winnum < 0)
			res = 1;
		if (i == 1 && tree[i].winnum)
			res = 1;
	}
}
int main()
{
	string str;
	cin >> str;
	int flag = 0;
	int now = 1;
	memset(hash1, 0, sizeof(hash1));
	for (int i = 0; i < str.size(); i++)
	{
		char s = str[i];
		if (s == '[')
		{
			flag++;
			now *= 2;
		}
		else if (s == '-')
		{
			now += 1;
		}
		else if (s == ']')
		{
			now /= 2;
			tree[now].win = 0;
			tree[now].winnum = -1;
		}
		else
		{
			tree[now].win = s;
			tree[now].winnum = -1;
			numchar++;
			hash1[s - 'a'] = now;
		}
		//cout << now << endl;
	}
	//cout << numchar << endl;
	for (int i = 0; i < numchar; i++)
	{
		char c;
		int x;
		cin >> c >> x;
		tree[hash1[c - 'a']].winnum = x;
	}
	judge(1);
	if (res)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3228
nk = gets
nk = nk.split(' ')
n = nk[0].to_i
k = nk[1].to_i

aa = gets
aa = aa.split(' ')
a = aa.map{|i| i.to_i}

def point(i, k, a)
    return 0 if i < k

    total = 1
    k.times do |j|
        total *= a[i-j]
    end

    return total
end

(n-k).times do |c|

#    puts(a[k+c],a[c])
    if a[k+c] > a[c]
        puts('Yes') 
    else
        puts('No')
    end
end

Measured memory_bytes: 33920
#include<bits/stdc++.h>
using namespace std;
const int maxn=200000;
vector<int>eds[maxn],vv;
int n,x,y;
pair<int,int>go[maxn];
int ad[maxn],ans[maxn];
void dfs1(int v,int p,pair<int,int>ma)
{
    if(ma.second<v) ma.second=v;
    if(ma.second>ma.first) swap(ma.second,ma.first);
    go[v]=ma;
    for(int i=0;i<eds[v].size();i++)
    {
        int u=eds[v][i];
        if(u==p) continue;
        dfs1(u,v,ma);
    }
}
void dfs3(int v,int p,int cnt)
{
    cnt+=ad[v];
    ans[v]=cnt;
    for(int i=0;i<eds[v].size();i++)
    {
        int u=eds[v][i];
        if(u==p) continue;
        dfs3(u,v,cnt);
    }
}
void dfs2(int v,int p)
{
    vv.push_back(v);
    if(v==0) ad[0]++;
    else
    {
        int l=0;
        int r=vv.size()-1;
        while(r-l>1)
        {
            int m=l+r>>1,x=vv[m],f1=0;
            if(go[x].first!=x&&go[x].first==go[v].first
               ||go[x].first==x&&go[x]==go[v]) f1=1;
            if(f1) r=m;
            else l=m;
        }
        ad[vv[r]]++;
    }
    for(int i=0;i<eds[v].size();i++)
    {
        int u=eds[v][i];
        if(u==p) continue;
        dfs2(u,v);
    }
    vv.pop_back();
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        x--;y--;
        eds[x].push_back(y);
        eds[y].push_back(x);
    }
    dfs1(0,-1,make_pair(-1,-1));
    dfs2(0,-1);
    dfs3(0,-1,0);
    for(int i=1;i<n;i++)
        printf(i==n-1?"%d\n":"%d ",ans[i]-1);
}


Measured memory_bytes: 31480
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double h, w;
  cin >> h >> w;
  if(h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  if(int(h) % 2 == 0) cout << long(w*(floor(h/2.0))) << endl;
  else cout << long(w*(floor(h/2.0)) + double(ceil(w/2.0))) << endl;
}


Measured memory_bytes: 256
n=int(input())
q=lambda i:input('%d\n'%i)
i,j=0,n-1
a,b=q(i),q(j)
while 1:
  k=(j-i+1)//2+i
  c=q(k)
  if((k-i)%2)==(a==c):
    j=k
  else:
    a=c
    i=k

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b,k;
	cin>>a>>b>>k;

	for (int i = 0; i < k; ++i){
		if(i%2==0){
			b+=a/2;
			a/=2;
		}else{
			a+=b/2;
			b/=2;
		}
	}
	
	cout<<a<<" "<<b<<endl;
}


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



int main(){
  int P,Q,R;
  cin >> P >> Q >> R;
  int ans = 0;
  if(P > Q)
  {
    if(P > R)
    {
      ans = Q+R;
    }
    else { ans = P + Q; }
  }
  else
  {
    if(Q > R)
    { ans = P + R; }
    else {ans = P + Q;}
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
static const int NINF = -100;
int dp[17][17];

void solve()
{
	int a, b;
	while(cin >> a >> b, a || b)
	{
		int n;
		cin >> n;
		for(int i = 0; i < b; ++i)
		{
			for(int j = 0; j < a; ++j)
			{
				dp[i][j] = NINF;
			}
		}
		for(int i = 0; i < n; ++i)
		{
			int x, y;
			cin >> x >> y;
			x--; y--;
			dp[y][x] = 0;
		}
		for(int i = 0; i < a; ++i)
		{
			if(dp[0][i] != 0)
			{
				dp[0][i] = 1;
			}
			else
			{
				for(int j = i; j < a; ++j)
				{
					dp[0][j] = 0;
				}
				break;
			}
		}
		for(int i = 0; i < b; ++i)
		{
			if(dp[i][0] != 0)
			{
				dp[i][0] = 1;
			}
			else
			{
				for(int j = i; j < a; ++j)
				{
					dp[j][0] = 0;
				}
				break;
			}
		}
		for(int i = 1; i < b; ++i)
		{
			for(int j = 1; j < a; ++j)
			{
				if(dp[i][j] != 0)
				{
					dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
				}
			}
		}
		cout << dp[b - 1][a - 1] << endl;
	}
}

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

Measured memory_bytes: 0
n, x, m = map(int, input().split())



set_ = set([x])
res = [x]
for i in range(m + 200):
    x = x ** 2 % m
    if x in set_:
        break
    res.append(x)
    set_.add(x)

if len(res) >= n:
    print(sum(res[0:n]))
    exit()

init = 0
init_terms = 0
ans = 0
for i in range(len(res)):
    if res[i] == x:
        l = i
        break
    init += res[i]
    init_terms += 1

ans = init
lap = res[l:]
sum_lap = sum(lap)
len_lap = len(lap)



div, mod = divmod(n - init_terms, len_lap)
ans += div * sum_lap + sum(lap[0:mod])
print(ans)

Measured memory_bytes: 77256
#include<iostream>
#include<iomanip>
#define MAX 10000000
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) Rep(i,0,a)
using namespace std;
int sum,u[70][70][4],v[70][70];
int w,h;
int dx[]={0,0,-1,1},dy[]={1,-1,0,0},d[70][70];
void func(int x,int y,int now){
	d[y][x]=now;
	if(x!=w-1||y!=h-1){
		rep(i,4)
			if(u[y][x][i]==1)
				if(d[y+dy[i]][x+dx[i]]>now+1)
					func(x+dx[i],y+dy[i],now+1);
	}
}
int main(){
	int box[70][70];
	while(cin>>w>>h,w||h){
		rep(i,2*h-1)
		rep(j,w-1+i%2)
		cin>>box[i][j];
		//1
	   //2 3
		//0
		rep(i,h)
		rep(j,w){
			d[i][j]=MAX;
			if(j==0)
				u[i][0][2]=0;
			else {
				if(box[2*i][j-1]==1)
					u[i][j][2]=0;
				else u[i][j][2]=1;
			}
			if(i==0)
				u[0][j][1]=0;
			else {
				if(box[2*i-1][j]==1)
					u[i][j][1]=0;
				else u[i][j][1]=1;
			}
			if(i==h-1)
				u[h-1][j][0]=0;
			else {
				if(box[2*i+1][j]==1)
					u[i][j][0]=0;
				else u[i][j][0]=1;
			}
			if(j==w-1)
				u[i][w-1][3]=0;
			else {
				if(box[2*i][j]==1)
					u[i][j][3]=0;
				else u[i][j][3]=1;
			}
		}
		func(0,0,1);
		if(d[h-1][w-1]==MAX)
			d[h-1][w-1]=0;
		cout<<d[h-1][w-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
typedef long long l1;
#define mod 1000000007
#define f first
#define se second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define set(a,b) memset(a,b,sizeof(a))
#define mn *min_element
#define mx *max_element
#define input l1 t; cin>>t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
  	l1 n,x;
  	cin>>n;
  	x=n/500;
  	cout<<(x)*1000+((n-x*500)/5)*5;
    return 0;
}


Measured memory_bytes: 764
import java.util.*;
 
public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
      
          if((B-A-1)%2==0){
				System.out.print("Borys");
	      }else{
				System.out.print("Alice");
	      }
	}
}

Measured memory_bytes: 35876
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 100005
void solve()
{
   int n,W;
		cin>>n>>W;
		vector<int> dp(N+1,1e12);
		dp[0]=0;
		for(int j=0;j<n;j++)
		{
		    int w,v;
		    cin>>w>>v;
		    for(int i=N-v;i>=0;i--)
		        dp[i+v]=min(dp[i+v],dp[i]+w);
		}
		int ans=0;
		for(int i=0;i<=N;i++) if(dp[i]<=W) ans=i;
		cout<<ans;
	
   
}
int32_t main()
{
    rapido;
    int t;t=1;
    while(t--)
    solve();
}

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

int main() {
  string s = "Yes";
  int n;
  cin >> n;
  int h[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = n - 2; i >= 0; i--) {
    if (h[i] == h[i + 1] + 1) {
      h[i]--;
    } else if (h[i] > h[i + 1] + 1) {
      s = "No";
      break;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 640
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    x=parseInt(readline())
    for i in x:10^5+3
        flg=true
        for j in 2:sqrt(i)+1
            if i%j==0 && x>2
                flg=false
                break
            end
        end
        if flg
            println(i)
            break
        end
    end
end
main()

Measured memory_bytes: 113960
#include<iostream>
#include<algorithm>
using namespace std;
int a[100001];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
		cin>>a[i];
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
		if(i+1>a[i+1])
		{
			int sum=0;
			for(int j=i+1;a[j]==i;j++)
				sum++;
			if(sum%2||(a[i]-i)%2)cout<<"First";else cout<<"Second";
			return 0;
		}
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    ll n,x;
    cin >> n >> x;
    if(x == 1 or x == 2*n-1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        ll numu = 2*n - 1 - x;
        ll numl = x - 1;
//        cout << numu << " " << numl << endl;
        if(numu > numl){
            for(ll i=0;i<numu-n+1;i++){
                cout << x+i+1 << endl;
            }
            for(ll i=0;i<numl;i++){
                cout << i+1 << endl;
            }
            cout << x << endl;
            for (ll i=numu-n+1;i<numu;i++){
                cout << x+i+1 << endl;
            }
        }else if(numu < numl){
            for(ll i=0;i<n-1;i++){
                cout << i+1 << endl;
            }
            cout << x << endl;
            for (ll i=0;i<numu;i++){
                cout << x+i+1 << endl;
            }
            for(ll i=n-1;i<numl;i++){
                cout << i+1 << endl;
            }
        }else{
            for(ll i=0;i<2*n-1;i++){
                cout << i+1 << endl;
            }
        }
    }



}




Measured memory_bytes: 1536
using static System.Math;
using System.Linq;
using System;

public class P
{
    public int p { get; set; }
    public bool d { get; set; }
}

public class hello
{
    public static int n, L;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        n = int.Parse(line[0]);
        L = int.Parse(line[1]);
        var ps = new P[n];
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var p = int.Parse(line[0]) - 1;
            var d = line[1] == "0";
            ps[i] = new P { p = p, d = d };
        }
        ps = ps.OrderBy(x => x.p).ToArray();
        getTable(ps);
    }
    static void getTable(P[] ps)
    {
        var h = new long[n];
        var m = new long[n];
        var preh = 0L;
        var prem = 0L;
        var pth = 0;
        var ptm = L - 1;
        for (int i = 0; i < n; i++)
        {
            var a = ps[i].p - pth++;
            h[i] = ps[i].d ? preh + a : preh - a;
            preh = h[i];
            var b = ptm-- - ps[n - 1 - i].p;
            m[n - 1 - i] = ps[n - 1 - i].d ? prem - b : prem + b;
            prem = m[n - 1 - i];
        }
        var ans = Max(h[n - 1], m[0]);
        for (int i = 0; i < n - 1; i++)
            ans = Max(ans, h[i] + m[i + 1]);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 30852
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int A[N];
    A[0] = -1;
    for(int i=1; i<N; i++){
        cin >> A[i];
        A[i]--;
    }
    
    //部下の数
    int B[N];
    for(int i=0; i<N; i++)
        B[i] = 0;
    
    for(int i=0; i<N; i++){
        if(A[i] == -1)
            continue;
        else
        B[A[i]]++;
    }
    
    for(int i=0; i<N; i++)
        cout << B[i] << endl;
    
}


Measured memory_bytes: 5196
#include <iostream>

using namespace std;

int main(){
  int N, sum = 0, price, max = 0;

  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> price;
    sum += price;
    if(price > max){
      max = price;
    }
  }

  cout << sum - max / 2 << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n,l;
  cin>>n>>l;
  vi a(n);
  rep(i,n)cin>>a[i];
  rep(i,n-1)if(a[i]+a[i+1]>=l){
    cout<<"Possible"<<endl;
    rep(j,i)
      cout<<j+1<<endl;
    for(j=n-1;j>i;j--)
      cout<<j<<endl;
    return 0;
  }
  cout<<"Impossible"<<endl;
}


Measured memory_bytes: 1664
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
int main(){
	while(1){
		long cnt[11];
		for(int i = 0; i < 11; i++){
			cnt[i] = 0;
		}
		cnt[0] = 1;
		long n = 0;
		std::string s;
		std::cin >> s;
		if(s[0] == '0'){
			return 0;
		}
		long ans = 0;
		for(int i = 0; i < s.length(); i++){
			if(i % 2 == 0){
				n += s[i] - '0';
			}else{
				n -= s[i] - '0';
			}
			n += 11;
			n %= 11;
			if(s[i] != '0'){
				ans += cnt[n];
				cnt[n]++;
			}else{
				ans += std::max(0l, cnt[n]-1);
			}
		}
		printf("%ld\n", ans);
	}
	return 0;
}
	



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

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

  vector<long int> a(3 * n);
  for (int i = 0; i < 3 * n; i++) cin >> a[i];

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  long int c = 0;
  int k = 0;

  for (int i = 1; i < 3 * n && k < n; i += 2) {
    if (i % 2 == 1) {
      c += a[i];
      k++;
    }
  }

  cout << c << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	static const ULL M = 998244353;

	void Solve() {
		UL N; cin >> N;
		string S; cin >> S;
		UL r, g, b; r = g = b = 0;
		UL r2, g2, b2; r2 = g2 = b2 = 0;
		ULL ans = 1;
		rep(i, N * 3) {
			char c = S[i];
			if (c == 'R') {
				if (r2) { ans = ans * r2 % M; r2--; }
				else if (g) { ans = ans * g % M; b2++; g--; }
				else if (b) { ans = ans * b % M; g2++; b--; }
				else r++;
			}
			if (c == 'G') {
				if (g2) { ans = ans * g2 % M; g2--; }
				else if (r) { ans = ans * r % M; b2++; r--; }
				else if (b) { ans = ans * b % M; r2++; b--; }
				else g++;
			}
			if (c == 'B') {
				if (b2) { ans = ans * b2 % M; b2--; }
				else if (r) { ans = ans * r % M; g2++; r--; }
				else if (g) { ans = ans * g % M; r2++; g--; }
				else b++;
			}
			//cout << r << " " << g << " " << b << " "
			//	<< r2 << " " << g2 << " " << b2 << endl;
		}
		rep(i, N) ans = ans * (i + 1) % M;
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int n;
set<string> ans;
void dfs(string s,int a){
  vector<int> v;
  for(int i=0;i<n;i++)if(s[i]=='#')v.push_back(i);
  int A=v.size();
  if(!A)ans.insert(s);
  else{
    s[v[0]]=(char)('a'+a);
    for(int i=0;i<(1<<A-1);i++){
      string t=s;
      for(int j=0;j<A-1;j++)if((i>>j)&1)t[v[j+1]]=(char)('a'+a);
      dfs(t,a+1);
    }
  }
}

int main(){
  cin>>n;
  dfs(string(n,'#'),0);
  for(string p:ans)cout<<p<<endl;
}


Measured memory_bytes: 12416
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}

const ll N=5e5+5;

ll sp[N];

void sieve(){
  for(int i=2;i<N;i++)sp[i]=i;

    for(int i=2;i*i<N;i++){
      if(sp[i]==i){
      for(int j=i*i;j<N;j+=i){
        sp[j]=i;
      }
    }
}

}

ll fac[N],inv[N];

ll p=1e9+7;

void fill(){
  fac[0]=inv[0]=1;

  for(int i=1;i<N;i++){
    fac[i]=fac[i-1]*i%p;
    inv[i]=powM(fac[i],p-2,p);
  }
}

ll c(ll a,ll b,ll p){
if(a<b)return 0;

  return (fac[a]*inv[a-b]%p)*(inv[b])%p;
}


ll lcm(ll a,ll b)
{
  return (a*b)/(__gcd(a,b));
}

int main()
{ 

  IOS;

  string s;
  cin>>s;

  ll x=0;

  for(int i=0;i<3;i++){
    x+=(s[i]==s[i+1]);
  }

  cout<<(x?"Bad":"Good")<<endl;

return 0;
 
}



Measured memory_bytes: 3632
from fractions import gcd
n = int(input())
a = [int(i) for i in input().split()]
lgcd = [a[0]]*n
rgcd = [a[n-1]]*n
for i in range(n-1):
    lgcd[i+1] = gcd(lgcd[i],a[i+1])
    rgcd[n-i-2] = gcd(rgcd[n-i-1],a[n-i-2])
ans = [0]*n
for i in range(1,n-1):
    ans[i] = gcd(lgcd[i-1],rgcd[i+1])
ans[0] = rgcd[1]
ans[n-1] = lgcd[n-2]
print(max(ans))
#print(lgcd)
#print(rgcd)

Measured memory_bytes: 16612
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  string s=to_string(n);
  ll k=s.size();
  bool nine=true;
  ll ans=0;
  if(k==1){
    cout<<n<<endl;
    return 0;
  }
  rep(i,k){
    
    if(i!=0){
      if(s[i]!='9')nine=false;
      ans+=9;
    }
    else ans+=s[0]-'0'-1;
  }
  if(nine)ans++;
  cout<<ans<<endl;
}
    
    
  

Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

MOD = 1000000007

def binpow_mod(b, e)
  return 1       if e <= 0
  return b % MOD if e == 1

  p = binpow_mod(b, e >> 1)
  q = (p * p) % MOD
  q = (q * b) % MOD if (e % 2) == 1
  return q
end

def solve(n)
  a = binpow_mod(10, n)
  b = binpow_mod(9,  n)
  c = binpow_mod(8,  n)

  x = (2 * (a + MOD - b)) % MOD
  y = ((a + MOD) - c) % MOD
  return ((x + MOD) - y) % MOD
end

def main(argv)
  n = InputLine.to_i

  puts solve(n).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14272
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>


using namespace std;


int main() {

	int x;
	int cnt = 0;

	cin >> x;
	if (x < 0) {
		x = x * -1;
	}

	for (int i = 1; i < 1000000000; i++)
	{
		cnt += i;
		if (cnt >= x) {
			cout << i << endl;
			return 0;
		}

	}

	

}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def solve(x):
    rot = x // (6 + 5)
    res = x % (6 + 5)
    ans = 2 * rot
    # rot:evenなら、つぎに当たるのは6
    if res > 0 and rot % 2 == 0:
        if res <= 6:
            ans += 1
        else:
            ans += 2
    elif res > 0 and rot % 2 == 1:
        if res <= 5:
            ans += 1
        else:
            ans += 2
    else:
        pass
    return ans

def main():
    x = I()
    ans = solve(x)
    print(ans)
    # print()
    # for i in range(1, 30):
    #     print(i, solve(i))
main()



Measured memory_bytes: 6224