akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
using namespace std;

long long MAX = 1e9+1;

int main(void)
{
    int n; cin >> n;
    vector<long long> a(n);
    long long tmp;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        a[i] = tmp;
    }
    sort(a.begin(),a.end(),std::greater<int>());
    long long ans = 0;
    int cnt = 1;
    int idx = 0;
    for (int i = 1; i < n; i++)
    {
        ans += a[idx];
        cnt++;
        if (cnt > 1)
        {
            cnt = 0;
            idx++;
        }
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"


int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, M; in(N); in(M);

  int count[N];
  rep(i, N)
    count[i] = 0;
  rep(i, M) {
    int a; in(a); int b; in(b);
    --a; --b;
    ++count[a]; ++count[b];
  }
  rep(i, N)
    if (count[i] % 2 != 0) {
      out("NO");
      return 0;
    }
  out("YES");

  return 0;
}


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


int main(){

  int n,a,b;
  cin >> n >> a >> b;

  cout << min(a,b) << " ";
  if((a+b-n)<0){
    cout << 0 << endl;
  }else{
    cout << a+b-n << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main()
{
    ll N, M;
    cin >> N >> M;
    vllvll s(M, vll(0));
    ll tmp;
    ll k;
    rep(i, 0, M) {
        cin >> k;
        rep(j, 0, k) {
            cin >> tmp;
            --tmp;
            s[i].push_back(tmp);
        }
    }
    vll p(M);
    rep(i, 0, M) {
        cin >> p[i];
    }
    
    ll ans = 0;
    rep(bit, 0, 1<<N) {     // each pattern
        vll switches(N, 0);
        rep(i, 0, N) {      // filter
            if (bit&1<<i) {
                switches[i] = 1;
            }
        }
        bool flg = true;
        rep(i, 0, M) {      // each bulb
            ll sm = 0;
            rep(j, 0, s[i].size()) {    // each connected switch
                sm += switches[s[i][j]];
            }
            if (sm % 2 != p[i]) {
                flg = false;
                break;
            }
        }
        if (flg) {
            ++ans;
        }
    }

    cout << ans << endl;
}

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

int main(){
	
	int a,b,c,x, count = 0;
	cin >> a >> b >> c >> x;
	for (int i=0; i<=a; i++){
		for (int j=0; j<=b; j++){
			for (int k=0; k<=c;k++){
				if (i*500 + j*100 + k*50 == x) count++;
			}
		}
	}
	cout << count;
	
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
inline int in(){int x;scanf("%lld",&x);return x;}
const int N=5e5+3;
const int mod=1e9+7;
int f[N],inv[N];
int modp(int a,int b)
{
	if(b==0)return 1;
	int u=modp(a,b/2);
	u=(u*u)%mod;
	if(b&1)return (a*u)%mod;
	return u;
}
int choose(int n,int r)
{
	if(n<r)return 0;
	int res=f[n]*inv[n-r];
	res%=mod;res*=inv[r];
	res%=mod;
	return res; 
}
int32_t main()
{
	int n=in();int m=in();
	f[0]=1;inv[0]=modp(1,mod-2);
	for(int i=1;i<=m;i++)f[i]=(f[i-1]*i)%mod;
	inv[m]=modp(f[m],mod-2);
	for(int i=m-1;i>=0;i--)inv[i]=modp(f[i],mod-2);
	int ans=0,cur=1,tmp;
	for(int i=0;i<=n;i++)
	{
		tmp=choose(m-i,n-i)*choose(n,i);tmp%=mod;
		tmp*=f[n-i];tmp%=mod;
		ans+=(cur*tmp);cur=-cur;
		ans+=mod;ans%=mod;
	}	
	int perm=choose(m,n)*f[n];perm%=mod;
	cout<<(ans*perm)%mod;
	
}

Measured memory_bytes: 11500
#include<cmath>
#include<iostream>
using namespace std;
int main(){
  const int n=100000;
  int b[n+2],m;
  cin>>m;
  b[0]=0;b[1]=0;b[2]=1;
  for(int i=3;i<=n;i++)
  	b[i]=(i%2==1);
  for(int i=3;i<=n;i+=2){
	  if(b[i])
		  for(int j=i*2;j<=n;j+=i)
		 	 b[j]=0;
  }
  for(int i=n-1;i>=3;i-=2){
	  if(b[i])
		b[i]=b[(i+1)/2];
  }
  b[2]=0;
	  for(int i=2;i<=n;i++)
	  	b[i]+=b[i-1];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		cout<<b[y]-b[x-1]<<endl;
	}
  return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int solve(){
    char c;
    cin >> c;

    if(c != '['){
        int x = 0;
        while(c != ']'){
            x *= 10;
            x += c - '0';
            cin >> c;
        }
        return (x / 2) + 1;
    }

    vector<int> a;
    while(c != ']'){
        a.push_back(solve());
        cin >> c;
    }
    sort(a.begin(), a.end());
    int n = ((int)a.size()) / 2 + 1;

    int x = 0;
    rep(i, n){
        x += a[i];
    }
    return x;
}

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

    rep(i, n){
        char c;
        cin >> c;

        int ans = solve();
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3144
import sys, math


if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    N = input().strip()
    sum = 0
    Len = len(N)
    for i in range(Len):
        sum += int(N[i])
    if(sum %9 ==0):
        print("Yes")
    else:
        print("No")


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

using namespace std;
using ll = long long;

int main() {
    ll h, w;
    cin >> h >> w;
    ll a = (w + 1) / 2;
    ll b = w / 2;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
    } else {
        ll ans = (ll)a * ll((h + 1) / 2) + (ll)b * ll(h / 2);
        cout << ans << endl;
    }
    return 0;
}


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


int main(void){
    long long n,sum=1;
    cin>>n;
    if(n==1)sum=0;
    else{for(int i=n-1;i>1;i--){
      sum+=i;
    }}
    cout<<sum<<endl;



return 0;

}


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

int main() {
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
        int t;
        cin >> t;
        a[t] = i;
    }
    ll sum = 0LL;
    set<int> s;
    s.insert(0);
    s.insert(n + 1);
    for (int i = 1; i <= n; i++) {
        auto iter = s.lower_bound(a[i]);
        int r = *iter;
        int l = *--iter;
        s.insert(a[i]);
        sum += 1LL * (a[i] - l) * (r - a[i]) * i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 10368
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
def max(s1, s2)
  s1 > s2 ? s1 : s2
end

# dp[i]: i本使ってできる最大の数
dp = Array.new(N+1)
dp[0] = 0
(N+1).times do |i|
  A.each do |a|
    if i-match[a] >= 0 && dp[i-match[a]]
      dp[i] = max(dp[i].to_i, dp[i-match[a]]*10 + a)
    end
  end
end
p dp[N]

Measured memory_bytes: 38012
#include <stdio.h>
int main(){
	int n = 0,x = 0;
	int a[100000] = {0};
	scanf("%d", &n);
	for(int i = 0;i<n;i++){
		scanf("%d", &x);
		a[i] = x;
	}
	int flag = 1;
	int temp = 0;
	int cont = 0;
	while(a[1] != 0){
		if(a[flag-1]==0)break;
		temp = a[flag-1];
		a[flag-1] = 0;
		flag = temp;
		cont++;
	}
	if(a[1] != 0)printf("-1");
	else
	printf("%d", cont-1);
	return 0;
} 

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

const lint MOD = (lint)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
lint p[MAX_N];

void mod_add(lint &a, lint b){
    a = (a+b) % MOD;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string L;
    cin>>L;
    int N = L.size();
    p[0] = 1;
    for(int i=1;i<=N;i++) p[i] = p[i-1] * 3 % MOD;
    lint ans = 0, cnt = 1;
    for(int i=0;i<N;i++){
        if(L[i]=='1'){
            mod_add(ans, cnt*p[N-i-1]%MOD);
            cnt = cnt * 2 % MOD;
        }
    }
    mod_add(ans, cnt);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int x_1, y_1, x_2, y_2;
int x_3, y_3, x_4, y_4;

int main()
{
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    y_3 = y_2 - (x_1 - x_2);
    x_3 = x_2 + (y_1 - y_2);
    y_4 = y_3 - (x_2 - x_3);
    x_4 = x_3 + (y_2 - y_3);
    cout << x_3 << " " << y_3 << " " << x_4 << " " << y_4 << endl;
}


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

using namespace std;

const int N = 100010;

int a[N];

int main() {
	int n;
	cin >> n;
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a+n);
	reverse(a, a+n);
	for (int i = 0; i < n; ++i) {
		//cout << i << " " << a[i] << endl;
	}
	long long sum2 = 0;

	long long ans = -2e9;
	int best = 0;
	for (int i = 0; i < n-1; ++i) {
		sum2 += a[i];
		if(ans < 2*sum2 - sum) {
			best = i;
			ans = 2*sum2 - sum;
		}
	}
	vector <pair<long long, long long> > v;
	int pos = 1, neg = n-2;
	long long pivot_neg = a[n-1];
	long long pivot_pos = a[0];
	while(pos <= best) {
		v.push_back(make_pair(pivot_neg, a[pos]));
		pivot_neg -= a[pos++];
	}

	v.push_back(make_pair(pivot_pos, pivot_neg));
	pivot_pos -= pivot_neg;

	while(best < neg) {
		v.push_back(make_pair(pivot_pos, a[neg]));
		pivot_pos -= a[neg--];
	}
	
	cout << ans << endl;
	for (pair<long long, long long> x: v) {
		cout << x.first << " " << x.second << endl;
	}

}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	char c;
	cin >> c;
	cout << ( c >= 'A' && c <= 'Z' ? 'A' : 'a') << endl;
	return 0;
}

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

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

  int a = -1;
  int b = -1;
  rep(i, s.length()) {
    if (a == -1 && s[i] == 'A')
      a = i;
    if (s[i] == 'Z')
      b = i;
  }
  cout << b - a + 1 << endl;
}

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

int main(){
  string S;
  cin >> S;
  if(S=="ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

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

using namespace std;

int main() {
    string a;
    while(cin >> a) {
        int f = 0;
        for(int i = 0; i < a.length(); ++i) {
            if(a[i] == 'C') {
                f = 1;
            }
            if(a[i] == 'F' && f == 1) {
                f = 2;
                break;
            }
        }
        if(f == 2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

void test_case(){
    lld k;
    cin>>k;
    if(k<=10){
        test(k);
        return;
    }
    std::queue<lld> qt;
    for(int i=1;i<10;++i){
        qt.push(i);
    }
    lld e;
    for(int i=0;i<k;++i){
        e=qt.front();
        if(e%10!=0){
            qt.push(10*e+(e%10)-1);
        }
        qt.push(10*e+(e%10));
        if(e%10!=9){
            qt.push(10*e+(e%10)+1);
        }
        qt.pop();
    }
    test(e);
}

int main(){
    fastio;
    file();
    int T=1;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

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


signed main()
{
ll n;
cin>>n;
ll a=n%100;
ll b=n/100;
ll ans;
ans=a/5;
ll z=a;
a=a%5;
if(a==0){


}
else if(a==1){
    ans++;
}
else if(a==2){
    ans++;
}
else if(a==3){
    ans++;
}
else{
    ans++;
}
//cout<<ans<<" "<<z;
  if(ans>b){

        cout<<"0";
    }
    else{
        cout<<"1";
    }

    return 0;
}



Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-
N = int(raw_input())
A = [int(i) for i in raw_input().split()]
B = [int(i) for i in raw_input().split()]

rest = [0] * N
score = [0] * (N + 1)

for i in range(0, N + 1):
    if i == 0:
        if A[i] < B[i]:
            score[i] = A[i]
            rest[i] = B[i] - A[i]
        else:
            score[i] = B[i]
            rest[i] = 0
    elif i == N:
        score[i] = min([A[i], rest[i - 1]])
    else:
        if (A[i] - rest[i - 1]) < B[i]:
            score[i] = A[i]
            rest[i] = min([B[i] - A[i] + rest[i - 1], B[i]])
        else:
            score[i] = B[i] + rest[i - 1]
            rest[i] = 0
total = 0
for i in score:
    total = total + i

print total


Measured memory_bytes: 16300
#include <iostream>
//#include<stack>
#include<set>
#include<bits/stdc++.h>
using namespace std;
//int f[10005];
//int chazhao(int x)
//{
//	if(x==f[x])
//	return x;
//	else
//	return f[x]=chazhao(f[x]);
//}

int main()
{
	set<int >ss;
	int n,x;
	cin>>n>>x;
	ss.insert(x);
	for(int i=1;i<n;i++)
	{
		cin>>x;
	  if(ss.count(x)==0)
	  ss.insert(x);
	  else
	  continue;
	}
   int k=ss.size();
   if(k==n)
   cout<<"YES"<<endl;
   else
   cout<<"NO"<<endl;
 return 0;
}

Measured memory_bytes: 12964
#include <iostream>
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int N;
    int sum = 0;
    cin >> N;

    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            for (int k = 0; k < N; k++){
                sum = sum + gcd(gcd((i+1),(j+1)),(k+1));
            }
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
bool square(int n)
{
    int x;
    for(int i=1; i<n; i++)
    {
        x = i*i;
        if(x==n) return true;
    }
    return false;
}
int main()
{
    char a[101], b[101];
    scanf("%s %s", &a, &b);
    string newA = a, newB = b;
    string newString = newA+newB;
    int num = stoi(newString);
    int len = newString.length();
    if(square(num) == true) {
        printf("Yes\n");
    }else printf("No\n");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 1e3 + 9;

int32_t main(){
 L_T_S_K;
 int n ; 
 cin >> n;
 std::vector<int> a(n) , b(n) , v(n);
 for(int i = 0 ; i < n ;i++){
   cin >> a[i]; 
 }
  for(int i = 0 ; i < n ;i++){
   cin >> b[i]; 
 } 
 iota(v.begin() , v.end() , 1);
 int cnt = 1;
 int i = 0 , j = 0;
 do{
      if(a == v){i = cnt;}
      if(b == v){j = cnt;}
      cnt++;
 }while(next_permutation(v.begin() , v.end()));
 cout << abs(i  - j) << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static int[][] A = new int[3][3];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            int b = sc.nextInt();
            checkHit(b);
        }
        boolean bingo = checkBingo();
        if (bingo) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void checkHit(int b) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (A[i][j] == b) {
                    A[i][j] = 0;
                }
            }
        }
    }

    public static boolean checkBingo() {
        boolean result = false;
        for (int i = 0; i < 3; i++) {
            int sum = 0;
            for (int j = 0; j < 3; j++) {
                sum += A[i][j];
            }
            if (sum == 0) {
                result = true;
            }
        }
        for (int i = 0; i < 3; i++) {
            int sum = 0;
            for (int j = 0; j < 3; j++) {
                sum += A[j][i];
            }
            if (sum == 0) {
                result = true;
            }
        }
        if (A[0][0] + A[1][1] + A[2][2] == 0) {
            result = true;
        }
        if (A[0][2] + A[1][1] + A[2][0] == 0) {
            result = true;
        }
        return result;
    }
}


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

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_list = [list() for i in range(n)]
        for i in range(n):
          return_list[self.find(i)].append(i)
        return return_list

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


uf = UnionFind(n)
ans = 0

for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1, b-1)

for i in uf.all_group_members():
    ans = max(ans, len(i))

print(ans)


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

#define ll long long
#define pb push_back

const int maxn = 3e5 + 20;
const int mod[] = {1000 * 1000 * 1000 + 7 , 1000 * 1000 * 1000 + 9};
const int base[] = {4001, 737};

int h[maxn][2] , pw[maxn][2] , n;

string s;

int get(int l , int r , int k)
{
	return (h[r][k] - 1LL * h[l][k] * pw[r - l][k] % mod[k] + mod[k]) % mod[k];
}

bool check(int len)
{
	map<pair<int , int> , int> mp;

	for(int i = 0; i + len <= n; i++)
	{
		pair<int , int> tmp = {get(i , i + len , 0) , get(i , i + len , 1)};
		if(mp.count(tmp))
		{
			if(mp[tmp] + len <= i)
				return 1;
		}
		else
			mp[tmp] = i;
	}

	return 0;
}

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

	for(int j = 0; j < 2; j++)
	{
		pw[0][j] = 1;
		for(int i = 1; i < maxn; i++)
			pw[i][j] = 1LL * pw[i - 1][j] * base[j] % mod[j];
	}

	cin >> n >> s;

	for(int i = 0; i < n; i++)
		for(int j = 0; j < 2; j++)
			h[i + 1][j] = (1LL * h[i][j] * base[j] + s[i]) % mod[j];

	int l = 0 , r = n;

	while(r - l > 1)
	{
		int m = (l + r) / 2;
		if(check(m))
			l = m;
		else
			r = m;
	}

	cout << l << endl;
}










 


Measured memory_bytes: 4608
#include <cstdio>
#include <cmath>
#include <vector>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k;
bool ans = true;
std::vector<int> vec[100000];
bool has[100000];
int mi[100000], ma[100000];

void prod(int x, int y) {
	if(has[y]) {
		if(has[x] && abs(mi[x] - mi[y]) % 2 == 0) { ans = false; }
		
		if(has[x]) {
			mi[x] = max(mi[x], mi[y] - 1);
			ma[x] = min(ma[x], ma[y] + 1);
		} else {
			mi[x] = mi[y] - 1;
			ma[x] = ma[y] + 1;
		}
		if(mi[x] > ma[x]) { ans = false; }
		has[x] = true;
	}
}

void dfs(int node, int pre) {
	if(pre != -1) { prod(node, pre); }
	for(auto && i : vec[node]) {
		if(i != pre) {
			dfs(i, node);
			prod(node, i);
		}
	}
}

int main() {
	scanf("%d", &n);
	inc(i, n - 1) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	scanf("%d", &k);
	inc(j, k) {
		int v, p;
		scanf("%d%d", &v, &p);
		v--;
		ma[v] = p;
		mi[v] = p;
		has[v] = true;
	}
	
	dfs(0, -1);
	dfs(0, -1);
	
	printf("%s\n", ans ? "Yes" : "No");
	if(ans) {
		inc(i, n) { printf("%d\n", mi[i]); }
	}
	
	return 0;
}


Measured memory_bytes: 11904
n = int(input())
a = list(map(int, input().split()))
dp = [0 for _ in range(n)]
ans = 0
for i in range(n):
    if i + a[i] < n:
        dp[i+a[i]] += 1
    if 0<= i-a[i]:
        ans += dp[i-a[i]]
# print(dp)
print(ans)

Measured memory_bytes: 32200
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int64_t fact_log2(int64_t n) {
  int64_t res = 0;
  while(n/=2) res += n;
  return res;
}

int64_t mod2_comb(int64_t n, int64_t k) {
  if(n < 0 || k < 0 || n < k) return 0;
  int64_t e1 = fact_log2(n);
  int64_t e2 = fact_log2(k);
  int64_t e3 = fact_log2(n-k);
  if(e1 > e2+e3) return 0;
  return 1;
}

int main() {
  int N; std::cin >> N;
  int p[5] = {2, 1, 0, 1, 2};
  std::vector<int> a(N);
  char pc; std::cin >> pc; --N;
  for(int i = 0; i < N; ++i) {
    char c; std::cin >> c;
    a[i] = p[pc - c + 2];
    pc = c;
  }
  int b = 0;
  for(int i = 0; i < N; ++i) if(mod2_comb(N-1, i)) b ^= (a[i]&1);
  if(b==1) fin(1); // odd
  for(int i = 0; i < N; ++i) if(a[i]==1) fin(0);
  for(int i = 0; i < N; ++i) if(mod2_comb(N-1, i)) b ^= (a[i]&2);
  if(b==2) fin(2);
  fin(0);
  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b;cin >> a >> b;
    if(a==b) cout << "Draw" << endl;
    else if(a==1) cout << "Alice" << endl;
    else if(b==1) cout << "Bob" << endl;
    else if(a<b) cout << "Bob" << endl;
    else cout << "Alice" << endl;
    return 0;
}

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

int main() {
  int a, b;
  
  cin >> a >> b;
  double x =(double) (a + b) / 2;
  int y = (a + b) / 2;
  if ((x - y) >= 0.5) {
    y++;
  }
  cout << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, x; cin >> n >> x;
    vi a(n); for(auto& e : a) cin >> e;
    sort(_all(a));

    int res = 0;
    rep(i, n){
    	x -= a[i];
    	if(x < 0) break;
    	if(i == n - 1 and x > 0) break;
    	res++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 100000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}


int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    map<ll,ll>mp;
    for(int i=0;i<n-1;i++)
        cin>>arr[i],mp[arr[i]]++;

    for(int i=1;i<=n;i++) cout<<mp[i]<<endl;


}























Measured memory_bytes: 17692
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll; 
typedef long double ld; 
const ll mod = 1e9+7;
int solve(int src, vector<int> &dp,vector <vector <int > > &g)
{
	if(dp[src] != -1)
		return dp[src];
	bool isLeaf = true;
	int maxVal = 0;
	for(int &x : g[src])
	{
		isLeaf = false;
		maxVal = max(maxVal, solve(x,dp,g));
	}	
	return dp[src] = isLeaf ? 0 : 1 + maxVal ;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); 
    int n,m; cin >> n>> m;
    vector <vector <int > > g(100001);
    vector <int> dp(100001,-1);
    for(int i=0 ; i < m; i++)
    {	int u,v;
		cin >> u >> v;
		g[u].pb(v);
	}
	int ans = INT_MIN;
	for(int i = 1 ;i <=n ; i++)
		ans = max(ans, solve(i,dp,g));
		
	cout << ans;
    return 0;
}
 


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
//const int md = 998244353;
//const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/

int dp[20000];

signed main()
{
    showoff;
    int n;
    cin >> n;
    vector<int>v(n+5);
    FOR(i,1,n+1)cin >> v[i];
    sort(v.begin()+1,v.begin()+n+1);
    FOR(i,1,n){
        if(v[i] >= 0)break;
        if(v[i+1] <= 0)v[i] *= -1,v[i+1] *= -1,i++;
        else {
            if(v[i+1] < -v[i])v[i] *= -1,v[i+1] *= -1;
            break;
        }
    }
    int tot = 0;
    FOR(i,1,n+1)tot += v[i];
    cout << tot << "\n";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...    

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

int A, B;
 
int main(){
    cin >> A >> B;
    int ans;
    if( A <= 5 )    ans = 0;
    else if( 6 <= A && A <= 12 ) ans = B / 2;
    else    ans = B;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,end) for(int i = 0; i < end; i += 1)
#define repb(i,st) for(int i = st; i >= 0; i -= 1) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	auto start = high_resolution_clock::now(); 

	int n;
	cin >> n;
	vi a(n);
	repf(i,n) cin >> a[i];

	int dp[n+1];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i-2] + abs(a[i] - a[i-2]), dp[i-1] + abs(a[i] - a[i-1]));
	}
	cout << dp[n-1];
	
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[41][41][41];
int G[41][41];
int main(){
	int n;
	scanf("%d",&n);
	n *= 2;
	for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            char x;
            scanf(" %c",&x);
            G[i][j] = x-'0';
        }
	}
	for (int i = 1; i < n; i++) dp[i][i][i] = 1;
	for (int l = 1; l < n; l++){
        for (int s = 1; s+l < n; s++){
            int u = s+l;
            for (int t = s+1; t < u; t++){
                for (int p1 = s; p1 < t; p1++){
                    for (int p2 = t+1; p2 <= u; p2++){
                        for (int r1 = s; r1 <= p1; r1++){
                            for (int r2 = p2; r2 <= u; r2++){
                                if (G[r1][r2] == 0) continue;
                                dp[s][t][u] += dp[s][r1][p1]*dp[p1+1][t][p2-1]*dp[p2][r2][u];
                            }
                        }
                    }
                }
            }
        }
	}
	ll ans = 0;
	for (int i = 1; i <= n-1; i++){
        if (G[0][i]){
            ans += dp[1][i][n-1];
            //printf("if take 0-%d, %lld\n",i,dp(1,i,2*n-1));
        }
	}
	printf("%lld",ans);
}


Measured memory_bytes: 640
S = input()
T = input()
R, R_ = [-1] * 26, [-1] * 26
for s, t in zip(S, T):
  s_ = ord(s) - ord('a')
  t_ = ord(t) - ord('a')
  if (R[s_] >= 0 and R[s_] != t_) or (R_[t_] >= 0 and R_[t_] != s_):
    print("No")
    break
  if R[s_] == -1:
    R[s_] = t_
  if R_[t_] == -1:
    R_[t_] = s_
else:
  print("Yes")


Measured memory_bytes: 3632
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;

    auto ls = new bool[][](N, 10);
    auto rs = new bool[][](N, 10);
    foreach (i; 0..N) {
        if (i != 0) {
            foreach (j; 0..10) {
                ls[i][j] = ls[i-1][j];
            }
        }
        ls[i][S[i] - '0'] = true;
    }
    foreach_reverse (i; 0..N) {
        if (i != N-1) {
            foreach (j; 0..10) {
                rs[i][j] = rs[i+1][j];
            }
        }
        rs[i][S[i] - '0'] = true;
    }
    auto rr = new bool[](1000);
    foreach (i; 1..N-1) {
        foreach (a; 0..10) foreach (c; 0..10) {
            if (ls[i-1][a] && rs[i+1][c]) rr[a*100 + (S[i] - '0')*10 + c] = true;
        }
    }
    int res;
    foreach (i, r; rr) if (r) {
        ++res;
    }
    writeln(res);
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.141592653589793238;
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  long double eps = 1.0E-20;

  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l;
  double ans;
  double a, b, h, m, x, aru, bet;
  cin >> a >> b >> h >> m;
  aru = 6 * m;
  bet = 60 * h + m;
  bet = bet / 2;
  x = abs(aru - bet);
  if (x > 180)
  {
    x = 360 - x;
  }
  ans = a * a + b * b - 2 * a * b * cos(x / 180.0000000000000000 * PI);
  cout << std::fixed;
  std::cout << std::setprecision(20) << sqrt(ans); // "3.14"
  // cout <<  << endl;
}


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

#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	mod1 			1000003
#define 	inf				2e18
#define 	lli 			long long int
#define 	rep(i, n) 		for(int i = 0 ; i < n ; i++)
#define 	repn(i, n) 		for(int i = n - 1 ; i >= 0 ; i--)
#define 	loop(i, a, b) 	for(int i = a ; i < b ; i++)
#define 	hello 			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define 	F 				first
#define 	S 				second
#define 	B 				begin()
#define 	E 				end()
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	pb 				push_back
#define 	vi 				vector<int>
#define 	print(a) 		for(auto &i : a)cout<<i<<"\n";//cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//g++ -std=c++14
//fixed<<setprecision(9);
//max_element(mp.begin(), mp.end(), compare)


bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

int gcd(int a, int b) 
{ 	
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}

int main()
{
	boost;
	char c;
	cin>>c;
	cout<<(char)(c+1)<<'\n';
}

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

int main() {
    long long n;
    std::cin >> n;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::vector<std::set<long long>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        std::cin >> a >> b; a--; b--;
        g[a].insert(b);
        g[b].insert(a);
    }

    std::vector<std::deque<long long>> ch(n);
    std::vector<long long> p(n, -1);
    std::deque<long long> q2;
    q2.push_back(0);
    while (!q2.empty()) {
        auto curr = q2.front();
        for (auto to : g[curr]) {
            if (to == p[curr]) continue;
            ch[curr].push_back(to);
            p[to] = curr;
            q2.push_back(to);
        }
        q2.pop_front();
    }

    std::deque<long long> q;
    std::vector<bool> done(n, false);
    std::vector<long long> c(n), t(n);
    q.push_back(0);
    while (!q.empty()) {
        auto curr = q.back();
        if (ch[curr].empty()) {
            t[curr] = a[curr];
            q.pop_back();
        } else if (done[curr]) {
            if (ch[curr].size() == 1) {
                t[curr] = t[ch[curr][0]];
                if (t[curr] != a[curr]) {
                    std::cout << "NO" << std::endl;
                    return 0;
                }
                q.pop_back();
                continue;
            }
            // 2*c + t = sum_of_children_t
            // c + t = a_i
            auto s = std::accumulate(ch[curr].begin(), ch[curr].end(), 0ll, [&](auto init, auto k) {
                return init + t[k];
            });

            c[curr] = s - a[curr];
            t[curr] = a[curr] - c[curr];
            q.pop_back();
            if (c[curr] < 0 || t[curr] < 0 || t[curr] > a[curr] || c[curr] > a[curr]) {
                std::cout << "NO" << std::endl;
                return 0;
            }
            s += t[curr];
            if (std::any_of(ch[curr].begin(), ch[curr].end(), [&](auto el) { return 2 * t[el] > s; }) || 2 * t[curr] > s) {
                std::cout << "NO" << std::endl;
                return 0;
            }
        } else {
            for (auto el : ch[curr]) q.push_back(el);
            done[curr] = true;
        }
    }

    if (g[0].size() == 1) {
        std::cout << (t[0] == a[0] ? "YES" : "NO") << std::endl;
    } else {
        std::cout << (t[0] ? "NO" : "YES") << std::endl;
    }

    return 0;
}

Measured memory_bytes: 85376
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <algorithm>

using namespace std;
#define n_max 1000

int main()
{
    int N, L;
    int sum = 0;
    string ans = "";
    vector<string> s;

    cin >> N >> L;
    
    for(int i = 0; i < N; i++){
        string tmp;
        cin >> tmp;
        s.push_back(tmp);
    }

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

    for(int i = 0; i < N; i++) {
        ans += s[i]; 
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
ll g1( ll n, int p ) {
    if ( n == 0 ) return 0;
    return n / p + g1(n/p, p);
}

ll g2 ( ll n, int p ) {
    if ( n % 2 == 1 ) {
        return g1(n,p) - g2(n-1,p);
    }
    ll res = g1(n/2, p);
    if ( p == 2 ) res += n / 2;
    return res;
}

int main(){
    ll n;
    cin >> n;
    ll ans = min(g2(n,2), g2(n,5));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int N; 
  cin >> N;
  int n = N % 10;
  switch (n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      return 0;
	case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      return 0;
    case 3:
      cout << "bon" << endl;
    default:
      return 0;   
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

LL n, a, b;

int main()
{
	scanf("%lld%lld%lld", &n, &a, &b);
	if(a > b) swap(a, b);
	LL ret = 0;
	if((b - a) % 2 == 1) {
		ret = min(b - 1, n - a);
		ret = min(ret, (a + b - 1) / 2);
		ret = min(ret, (2 * n - b - a + 1) / 2); 
	} else ret = (b - a) / 2;
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
main () {
	int n;
	string a, b;
	cin>>n;
	cin>>a>>b;
	string temp = "";
	for (int i=0;i<n;i++) {
		temp += a[i];
		temp+= b[i];
	}
	cout<<temp<<endl;
}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    string sa,sb,sc;
    cin >> sa >> sb >> sc;

    reverse(sa.begin(),sa.end());
    reverse(sb.begin(),sb.end());
    reverse(sc.begin(),sc.end());

    char x = 'a';

    for(;;){
        if(x == 'a'){

            if(sa.size() == 0){
                cout << 'A' << endl;
                return 0;
            }

            x = sa.at(sa.size()-1);
            sa.pop_back();
        }else if(x == 'b'){

            if(sb.size() == 0){
                cout << 'B' << endl;
                return 0;
            }

            x = sb.at(sb.size()-1);
            sb.pop_back();
        }else{

            if(sc.size() == 0){
                cout << 'C' << endl;
                return 0;
            }

            x = sc.at(sc.size()-1);
            sc.pop_back();

        }
    }
}


Measured memory_bytes: 256
<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$x = trim(fgets(STDIN));

$count = 0;
for($i=0; $i<=$a; $i++){
  for($j=0; $j<=$b; $j++){
    for($k=0; $k<=$c; $k++){
      if(500*$i+100*$j+50*$k == $x) $count++;
    }
  }
}

echo $count;

?>

Measured memory_bytes: 4604
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string str;
	cin >> str;
	vector<int> pat1(str.size()), pat2(str.size());
	int n = 0;
	vector<int> a_str(str.size());
	for (int i = 0; i < str.size(); i++) {
		a_str[i] = (int)str[i] - static_cast<int>('0');
		pat1[i] = n;
		pat2[i] = !n;
		n = !n;
	}
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < str.size(); i++) {
		if (a_str[i] != pat1[i]) {
			cnt1++;
		}
		if (a_str[i] != pat2[i]) {
			cnt2++;
		}
	}
	cout << min(cnt1,cnt2) << endl;;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;scanf("%d%d",&n,&m);
    int ans=1;
    for(int i=1;i<sqrt(m)+10;i++){
        if(m%i)continue;
        int a=i,b=m/i;
        if(m/a>=n)ans=max(ans,a);
        if(m/b>=n)ans=max(ans,b);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,ans;
int main()
{
	scanf("%d",&a);
	for(int i=1;i<=a;i++)
	{
		    scanf("%d",&b);
		    while (b%2==0)
		    {
				ans++;
				b=b/2;
		    }
	}
	printf("%d",ans);
//	system("pause");
	return 0;
}


Measured memory_bytes: 256
// Binary Trees
#include <stdio.h>
#define MAX 25 // 接点の個数の上限
#define NIL -1 // 接点番号として使われない値を設定(とりあえず-1としておく)

struct node{
  int parent; // 接点の親を参照
  int left;   // 左の子を参照
  int right;  // 右の子を参照
};
struct node T[MAX];

int getDegree(int);
int getDepth(int);
int getSibling(int);
int getHeight(int);
int printNodeType(int);

int main(){
  int i, n, id, l, r;

  scanf("%d", &n);

  for(i=0; i < n; i++){ // NILを代入して初期化
    T[i].parent = T[i].left = T[i].right = NIL;
  }

  for(i=0; i < n; i++){
    scanf("%d", &id);
    scanf("%d%d", &T[id].left, &T[id].right);
    T[T[id].left].parent = T[T[id].right].parent = id;
  }

  for(i=0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
    i, T[i].parent, getSibling(i), getDegree(i), getDepth(i), getHeight(i));
    printNodeType(i);
      printf("\n");
  }
  return 0;
}

// 接点の子の数を返す
int getDegree(int u){
  int count=0;
  if(T[u].left != NIL)count++;
  if(T[u].right != NIL)count++;
  return count;
}

// 接点の深さを返す
int getDepth(int u){
  int d=0;
  while(T[u].parent != NIL){
    u = T[u].parent;
    d++;
  }
  return d;
}

// 接点の兄弟を返す
int getSibling(int u){
  int p;
  p = u;
  if(T[u].parent == NIL) return -1;
  else u = T[u].parent;
  if(T[u].left != NIL && T[u].left != p) return T[u].left;
  else if(T[u].right != NIL && T[u].right != p) return T[u].right;
  else return -1;
}

// 接点の高さを返す
int getHeight(int u){
  int h1=0, h2=0;
  if(T[u].right != NIL)h1 = getHeight(T[u].right) + 1;
  if(T[u].left != NIL)h2 = getHeight(T[u].left) + 1;
  if(h1 > h2)return h1;
  else return h2;
}

// 根、内部ノードまたは葉のどれかを判定して表示
int printNodeType(int u){
  if(T[u].parent == NIL)printf("root");
  else if(T[u].left == NIL && T[u].right == NIL)printf("leaf");
  else printf("internal node");
}



Measured memory_bytes: 2048