akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    string s;
    cin>>s;
    
    int n=s.size();
    int a=-1,b=-1;
    rep(i,n-1){
        if(s.at(i)==s.at(i+1)){
            a=i+1;
            b=i+2;
        }
    }
    rep(i,n-2){
        if(s.at(i)==s.at(i+2)){
            a=i+1;
            b=i+3;
        }
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
int N,x,a[110];
int main(){
	scanf("%d%d",&N,&x);
	for(int i=0;i<N;i++)scanf("%d",a+i);
	std::sort(a,a+N);
	int cnt=0;
	for(int i=0;i<N;i++){
		if(x>=a[i])x-=a[i],cnt++;
		else break;
	}
	if(cnt==N&&x)cnt--;
	printf("%d\n",cnt);
}

Measured memory_bytes: 128
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        var sL = s.Length;
        var tL = t.Length;
        var ans = int.MaxValue;
        for (int i = 0; i <= sL - tL; i++)
        {
            var w = s.Substring(i, tL);
            ans = Min(ans, check(w, t, tL));
        }
        Console.WriteLine(ans);
    }
    static int check(string a, string b, int c)
    {
        var res = 0;
        for (int i = 0; i < c; i++)
            if (a[i] != b[i]) res++;
        return res;
    }
}


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

int main(){
	int n; cin>>n;
	vector<string>s(n);
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	int m; cin>>m;
	vector<int>sum(max(n,m));
	vector<string>t(m);
	for(int j=0;j<m;j++){
		cin>>t[j];
	}
	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++){
			if(s[i]==s[k]){
				sum[i]++;
			}
		}
		for(int j=0;j<m;j++){
			if(s[i]==t[j]){
				sum[i]--;
			}
		}
	}
	sort(sum.begin(),sum.end(),greater<int>());
	cout<<sum[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define mod        1000000007
#define all(x)     x.begin(),x.end()    
#define F          first 
#define S          second
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
 ll i,j,k,n,m;
 cin>>n;
 set<ll>s1;
 vector<ll>v1;
 ll temp=sqrt(n)+1;
 fli(i,2,temp) {
  if(n%i==0) {
    if(n/i==i) v1.pb(i);
    else {
      v1.pb(n/i);
      v1.pb(i);
    }
  }
 }
 temp=n;
 fl(i,v1.size()){
  temp=n;
  while(temp%v1[i]==0)
  {
    temp/=v1[i];
  }
  if(temp%v1[i]==1) s1.insert(v1[i]);
 }
 temp=sqrt(n-1)+1;
 fli(i,2,temp) {
  if((n-1)%i==0) {
    if((n-1)/i==i) {
      s1.insert(i);
    }
    else {
      s1.insert((n-1)/i);
      s1.insert(i);
    }
  } 
 }
 if(n==2) {
  cout<<1<<endl;
 }
 else
 cout<<s1.size()+2<<endl;
}
  
int main() {
  speedup;
  ll i=0,t;
  //cin>>t;
  t=1;
  while(t--) {
    comp();
  }
  return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

int a[100001];
int b[100001];


int main() {
	int i, j, n, m, x, y;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) a[i] = 1;
	b[1] = 1;
	while (m--) {
		scanf("%d%d", &i, &j);
		b[j] |= b[i];
		a[i]--;
		a[j]++;
		if (!a[i]) b[i] = 0;
	}
	j = 0;
	for (i = 1; i <= n; i++) j += b[i];
	printf("%d", j);
}

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

int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (i%2 == 0){
            if (s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if (s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
	string str;
 	cin >> str;
  	int l = 0, r = str.length() - 1;
  	int cnt = 0;
  	for(; l < r; l++, r--) {
    	if(str[l] != str[r]) cnt++;
    }
  	cout << cnt;
}

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

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

	vector<int64_t> aa(n+1),bb(m+1);
	aa[0]=0;
	bb[0]=0;
	for (int i=0;i<n;++i)
	{
		aa[i+1]=aa[i]+a[i];
	}
	for (int i=0;i<m;++i)
	{
		bb[i+1]=bb[i]+b[i];
	}

	int largest=0;
	int ib=m;
	for (int i=0;i<=n;++i)
	{
		for (;ib>=0;--ib)
		{
			if (aa[i]+bb[ib]<=k)
			{
				largest=max(largest,i+ib);
				break;
			}
		}
		if (ib<0)
		{
			break;
		}
	}
	cout << largest << endl;
}







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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,c; cin >> a >> b >> c;
    bool ok;
    if(c-b-a>0 && 4*a*b<(c-a-b)*(c-a-b)) ok = true;
    else ok = false;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793



int main() {
    int x,n;
    cin >> x;
    cin >> n;
    
    vector<int> p(n);
    vector<int> q(n);
    int y;
    rep(cnt, 0, n) {
        cin >> p[cnt];
    }
    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    copy(p.begin(), p.end(), q.begin());

    
    rep(cnt, 0, n) {
        q[cnt] = abs(q[cnt] - x);
    }
    sort(q.begin(), q.end());
    //q.erase(unique(q.begin(), q.end()), q.end());
    int s = q.size();
    int zet = -1;
    /*rep(cnt, 0, s) {
        cout << q[cnt] << endl;
    }*/
    for (int cnt = 0; cnt < s; cnt++) {
        if (!((cnt %2==0 && cnt/2==q[cnt])||(cnt%2==1 && cnt/2 +1 ==q[cnt]))) {
            //zet = q[cnt];
            if (cnt % 2 == 0) {
                zet = cnt / 2;
            }
            else {
                zet = cnt / 2 + 1;
            }
            break;
        }
    }
    if (zet == -1) {
        if (s % 2 == 0) {
            zet = s / 2;
        }
        else {
            zet = s / 2 + 1;
        }
    }
    if (find(p.begin(), p.end(), x - zet) == p.end()) {
        cout << x - zet << endl;

    }
    else {
        cout << x + zet << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine()[0];

        if('a' <= n && n <= 'z')
        {
            WriteLine("a");
        }
        else
        {
            WriteLine("A");
        }
    }
}


Measured memory_bytes: 17368
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets


def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)



n=input1()
a=n-n//2
print(a/n)



Measured memory_bytes: 13628
#include <stdio.h>
int main(void){
    
    int i,n;
    long int l[86]={0};
    
    l[0]=2;
    l[1]=1;
    scanf("%d",&n);
    
    for(i=2;i<=n;i++){
        l[i]=l[i-1]+l[i-2];
    }
    
    printf("%ld",l[n]);
    
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int ans=0;
  int N=0;
  int K=0;

  cin >> N >> K;

  
  if(K > 1){
    cout << N-K << endl;
  }else{
    cout << 0 << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector <int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    ans += p[i];
  }
  ans += p[N-1]/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
//#define int long long
#define inf 200000000
const int maxnodes=1005;
#define ll long long
#define N 501
#define EPS 0.01

int32_t main()
{
    IOS;

   	int n,m;
   	cin >> n >> m;
   	vector<int> v[m];
   	for(int i = 0;i < m;i++)
   	{
   		int k;
   		cin >> k;
   		for(int j = 0;j < k;j++)
   		{
   			int a;
   			cin >> a;
   			a--;
   			v[i].push_back(a);
   		}
   	}
   	vector<int> state(m);
   	for(int i = 0;i < m;i++)
   		cin >> state[i];
   	int ans = 0;
   	for(int i = 0;i < (1<<n);i++)
   	{
   		bool check = 1;
   		for(int b = 0; b < m;b++)
   		{
   			int ch = 0;
   			for(int z = 0;z < v[b].size();z++)
   			{
   				if(i & (1<< v[b][z]))
   					ch++;
   			}
   			
   			if((ch & 1) != state[b])
   				check = 0;


   		}
   		if(check)
   			ans++;
   	}
   	cout << ans;


    return  0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x,n,i,c[4][13]={0},j;
	char m;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>m>>x;
		if(m=='S'){
			c[0][x-1]=1;
		}else if(m=='H'){
			c[1][x-1]=1;
		}else if(m=='C'){
			c[2][x-1]=1;
		}else if(m=='D'){
			c[3][x-1]=1;
		}
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(c[i][j]==0){
				if(i==0){
					cout<<"S "<<j+1<<endl;
				}else if(i==1){
					cout<<"H "<<j+1<<endl;
				}else if(i==2){
					cout<<"C "<<j+1<<endl;
				}else{
					cout<<"D "<<j+1<<endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3104
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	long a, b, k, i;
	scanf("%ld%ld%ld", &a, &b, &k);
	i = a>k?k:a;
	a-=i; k-=i;
	i = b>k?k:b;
	b-=i; k-=i;
	printf("%ld %ld\n", a, b);
}



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

int main()
{
long long int n , T, sum=0, A[200005];
cin>>n>>T;
cin>>A[0];
for(int i=1 ; i<n; i++)
{
cin>>A[i];
int ans = A[i] - A[i-1];
//cout<<A[i]<<" "<<A[i-1] <<" "<<ans<<endl;
if( ans <= T)
sum=sum+ans;
else
sum=sum+T;
//cout<<sum<<endl;
}
cout<<sum+T<<endl;;
}


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

using namespace std;

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

int main(){
  int a, b;
  cin >> a >> b;
  cout << (a * 500 >= b ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
d_max = max(d.values())
ans = [k for k, v in d.items() if v == d_max]
for a in sorted(ans):
    print (a)

Measured memory_bytes: 32988
#include <stdio.h>

#define N 20
int main(void){
    int stk[N], sp=0;
    int n;
   
    while (scanf("%d", &n) != EOF){
        if (n==0 && sp!=0){
            printf("%d\n", stk[--sp]);
        } else {
            stk[sp++] = n;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define print(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
const int INF = 2e9 + 7;

typedef struct {
    uint32_t i;
    uint32_t p;
    uint32_t y;
} info_t;

int main() {
    fastio();
    
    int32_t n, m;
    cin >> n >> m;

    vector<info_t> v(m);
    for (auto i = 0; i < m; ++i) {
        cin >> v[i].p >> v[i].y;
        v[i].i = i;
    }

    sort(v.begin(), v.end(), [](info_t x1, info_t x2) { return x1.y < x2.y; });

    vector<uint64_t> number(m);
    vector<uint32_t> count(n, 0);
    for (auto &x : v) {
        ++count[x.p];
        number[x.i] = count[x.p] + 1e6 * x.p;
    }

    for (auto &x : number) {
        cout << setw(12) << std::setfill('0') << x << '\n';
    }
}

Measured memory_bytes: 3840
#include <stdio.h>
int main() {
    int data[5] = {0},ave = 0,i;
    for (i = 0; i < 5; i++) {
        scanf("%d",&data[i]);
        if (data[i] < 40) {
            data[i] = 40;
        }
        ave += data[i];
    }
    ave = ave / 5;
    printf("%d\n",ave);
    
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<stack>
#define MAX 100000
#define NIL -1

using namespace std;

int n;
vector<int> ver[MAX];
int grp[MAX];

void dfs(int r, int c);

int main() {
	int i, j, a, b, m, q, id = 1;
	
	cin >> n >> m;

	for (i = 0; i < m; i++) {
		cin >> a >> b;
		ver[a].push_back(b);
		ver[b].push_back(a);
	}

	for (i = 0; i < n; i++)grp[i] = NIL;
	for (i = 0; i < n; i++) {
		if (grp[i] == NIL)dfs(i, id++);
	}

	cin >> q;

	for (i = 0; i < q; i++) {
		cin >> a >> b;
		if (grp[a] == grp[b])cout << "yes\n";
		else cout << "no\n";
	}
	return 0;
}

void dfs(int r, int c) {
	int i, u, v;
	stack<int> s;
	s.push(r);
	grp[r] = c;
	while (!s.empty()) {
		u = s.top();
		s.pop();
		for (i = 0; i < ver[u].size(); i++) {
			v = ver[u][i];
			if (grp[v] == NIL) {
				grp[v] = c;
				s.push(v);
			}
		}
	}
}

Measured memory_bytes: 8972
h,w,m=map(int,input().split())
d_h=[0]*(h+1)
d_w=[0]*(w+1)
d=[]
for i in range(m):
  nh,nw=map(int,input().split())
  d_h[nh]+=1
  d_w[nw]+=1
  d.append([nh,nw])
  
#print(d_h)
#print(d_w)

hantei=0
ans1=max(d_h)
memoh=set()
for i in range(1,h+1):
  hantei=d_h[i]
  if ans1==hantei:
    memoh.add(i)
    
hantei=0
ans2=max(d_w)
memow=set()
for j in range(1,w+1):
  hantei=d_w[j]
  if ans2 == hantei:
    memow.add(j)
ans = ans2+ans1-1
#print(memoh,memow)
count = len(memoh)*len(memow)
for hw in d:
  if hw[0] in memoh and hw[1] in memow:
    count-=1
if count>0:
  print(ans+1)
else:
  print(ans)

Measured memory_bytes: 100932
#include <stdio.h>

void era_name(int year, int month, int date);

int main(void)
{
    int year, month, date;
    while (scanf("%d %d %d", &year, &month, &date) != EOF) {
        era_name(year, month, date);
    }
    return 0;
}

void era_name(int year, int month, int date)
{
    int meiji_year = year - 1868 +1;
    int taisho_year = year - 1912 + 1;
    int showa_year = year - 1926 + 1;
    int heisei_year = year - 1989 + 1;
    if (year > 1989 || (year == 1989 && month > 1) || (year == 1989 && month == 1 && date >= 8)) {       //1989.1.8〜は平成
        printf("heisei %d %d %d\n", heisei_year, month, date);
    } else if (year > 1926 || (year == 1926 && month == 12 && date >= 25)) {      //1926.12.25〜1989.1.7は昭和
        printf("showa %d %d %d\n", showa_year, month, date);
    } else if (year > 1912 || (year == 1912 && month > 7) || (year == 1912 && month == 7 && date >= 30)) {      //1912.7.30〜1926.12.24は大正      
        printf("taisho %d %d %d\n", taisho_year, month, date);
    } else if (year > 1868 || (year == 1868 && month > 9) || (year == 1868 && month == 9 && date >= 8)) {      //1868.9.8〜1912.7.29は明治
        printf("meiji %d %d %d\n", meiji_year, month, date);
    } else {
        printf("pre-meiji\n");
    }
}

Measured memory_bytes: 1040
package main

import "fmt"

var leaderboard [8]bool
var freeColorNum int

func judgecolor(rate int) {
	color := rate / 400
	if color >= 8 {
		freeColorNum++
	} else {
		leaderboard[color] = true
	}
}

func minMaxColor() (int, int) {
	min := 0
	for _, v := range leaderboard {
		if v {
			min++
		}
	}

	max := min + freeColorNum
	if min == 0 {
		min = 1
	}

	return min, max
}

func main() {
	var N int
	fmt.Scan(&N)

	var rate int
	for i := 0; i < N; i++ {
		fmt.Scan(&rate)
		judgecolor(rate)
	}

	min, max := minMaxColor()
	fmt.Println(min, max)
}


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



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   

int main(){
        lint N,count=0;
        string s;
        cin>>N>>s;
      bool h[3];
        rep(i,10){
            
            rep(j,10){
              rep(k,10){
                  h[0]=false;
                  h[1]=false;
                  h[2]=false;
                       rep(a,N){
            lint x=s[a]-'0';
            
            if(x!=i&&h[0]==false)continue;
            if(!h[0]){
            h[0]=true;
            continue;
            }
              if(x!=j&&h[1]==false)continue;
              if(!h[1]){
            h[1]=true;
            continue;
            }
                if(x!=k&&h[2]==false)continue;
                h[2]=true;
                    count++;
                    break;
              }
            }
        }
        }
        cout<<count;
}

Measured memory_bytes: 256
let m = 1000000007
let ( +^ ) x y = (x + y) mod m

let () =
  let s = read_line () in
  let dp = Array.make_matrix (String.length s + 1) 13 0 in
  dp.(0).(0) <- 1;
  String.iteri (fun i ->
    let go n =
      for j = 0 to 12 do
        dp.(i + 1).((10 * j + n) mod 13) <-
          dp.(i + 1).((10 * j + n) mod 13) +^ dp.(i).(j)
      done in
    function
      | '?' ->
          for i = 0 to 9 do
            go i
          done
      | c -> go (int_of_char c - int_of_char '0')) s;
  Printf.printf "%d\n" dp.(String.length s).(5)


Measured memory_bytes: 15488
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define MAXN 500000
int v[MAXN];
int pari[MAXN];
int dispari[MAXN];
int N;
int maxValore = 0;
void conta() {
    for(int i = 0; i<N - 1;i+=2) {
        pari[v[i]]++;
    }
    for(int i = 1; i<N;i+=2) {
        dispari[v[i]]++;
    }

}
void coutta() {
    cout<<"V"<<endl;
    for(int i = 0; i< N; i++) {
        cout<<v[i];
    }
    cout<<endl;
    cout<<"pari"<<endl;
    for(int i = 0; i<= maxValore; i++) {
        cout<<pari[i];
    }
    cout<<endl;
    cout<<"dispari"<<endl;
    for(int i = 0; i<= maxValore; i++) {
        cout<<dispari[i];
    }
    cout<<endl;
}
int trovaSomma() {
    //trovo i due massimi dei pari
    int maxPari1 = 0, maxPari2 = 0;
    int maxPi;
    int maxDispari1 = 0, maxDispari2 = 0;
    int maxDi;
    for(int i = 0; i<= maxValore; i++) {
        if(pari[i] > maxPari1) {
            maxPari2 = maxPari1;
            maxPari1 = pari[i];
            maxPi = i;
        } else if(pari[i] > maxPari2) {
            maxPari2 = pari[i];
        }

        if(dispari[i] > maxDispari1) {
            maxDispari2 = maxDispari2;
            maxDispari1 = dispari[i];
            maxDi = i;
        } else if(dispari[i] > maxDispari2) {
            maxDispari2 = dispari[i];
        }
    }
    //cout<<"massimi "<<maxPari1<<"  "<<maxDispari1<<endl;
    if(maxDi != maxPi) {
        return maxDispari1 + maxPari1;
    }
    return max(maxDispari1 + maxPari2, maxPari1+ maxDispari2);
}
int main()
{
    cin>>N;
    for(int i = 0; i< N; i++) {
        cin>>v[i];
        maxValore = max(maxValore,v[i]);
    }
    fill(pari,pari+N,0);
    fill(dispari,dispari+N,0);
    //cout<<maxValore<<endl;
    conta();
    //coutta();
    //cout<<"Trovasomma "<<trovaSomma()<<endl;
    cout<<N-trovaSomma()<<endl;
    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
  string s;
  cin>>s;
  string ans;
  int n=s.size();
  for(int i=0;i<n;i++)
  {
    if(s.at(i)=='0') ans.push_back('0');
    else if(s.at(i)=='1') ans.push_back('1');
    else if(ans.size()>0&&s.at(i)=='B') ans.pop_back();
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3596
def gcd(a,b):
    while b != 0:
        a, b = b, a % b
    return a


A, B, C, D = map(int, input().split())
if C == 1 or D == 1:
    print(0)
else:
    an1 = B//C
    an2 = (A - 1)//C
    an3 = B//D
    an4 = (A - 1)//D
    an5 = B//(C*D//gcd(C,D))
    an6 = (A - 1)//(C*D//gcd(C,D))
    print(B - A + 1 - (an1-an2+an3-an4-(an5-an6)))


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if (s.Contains("7")) Console.WriteLine("Yes");
            else Console.WriteLine("No");


        }
    }
}


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

int main(){
  string n;
  cin >> n;
  int dp[n.size()][2];
  dp[n.size()-1][0] = n.at(n.size()-1)-'0';
  dp[n.size()-1][1] = 2+'9'-n.at(n.size()-1);
  for(int i=n.size()-2; i>=0; --i){
    dp[i][0] = min(dp[i+1][0]+n.at(i)-'0', dp[i+1][1]+n.at(i)-'0');
    dp[i][1] = min(dp[i+1][0]+2+'9'-n.at(i), dp[i+1][1]+'9'-n.at(i));
  } 
  int ans;
  ans = min(dp[0][0], dp[0][1]);
  cout << ans << endl;
}

Measured memory_bytes: 9220
#include<stdio.h>

int main(void){
    int a[3];
    for(int i=0;i<3;i++){
        scanf("%d", &a[i]);
    }
    int jud = 1;
    if((a[0]+a[1]+a[2])==17){
        if(a[0]==5){
            if(a[1]==5) jud = 0;
            else if(a[1]==7) jud = 0;
        }
        else if(a[0]==7){
            if(a[1]==5) jud = 0;
        }
    }
    if(jud == 0) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int selectionsort(int, int *);
int A[102];
int main(void)
{
    int i;
    int N,k;

    scanf("%d", &N);
    for (i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    k = selectionsort(N, A);
    printf("%d", A[0]);
    for (i = 1; i < N; i++){
        printf(" %d", A[i]);
    }
    printf("\n");
    printf("%d\n", k);

    return (0);
}
int selectionsort(int N, int *A)
{
    int i,j;
    int min;
    int temp;
    int count;

    //printf("%d\n", N);
    count = 0;
    for (i = 0; i < N; i++){
        min = i;
        for (j = i; j < N; j++){
            if (A[j] < A[min]){
                min = j;
            }
        }
        if (i != min){
            temp = A[i];
            A[i] = A[min];
            A[min] = temp;
            count++;
            //printf("<%d %d>\n", A[i],A[min]);
        }
    }
    return count;
}


Measured memory_bytes: 2100
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

int N, K;
bool ng[11];
int limit;

int slv(int idx, char s[], bool h0)
{
    if (idx > 4) {
        const int  len = strlen(s);
        const int val = atoi(s);
        int i = 0; while(s[i] == '0' && i < len) ++i;
        for (; i < len; ++i) if (ng[s[i] - '0']) return INF;
        if (val < N) return INF;
        return val;
    }

    int ans = INF;

    for (int i = 0; i <= 9; ++i) {
        s[idx] = i + '0';
        s[idx+1] = '\0';
        chmin(ans, slv(idx+1, s, h0 && i == 0));
    }

    return ans;
}


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

    cin >> N >> K;
    for (int i = 0; i < K; ++i) {
        int d; cin >> d;
        ng[d] = true;
    }

    char s[10] = {};

    int ans = INF;
    chmin(ans, slv(0, s, true));

    cout << ans << endl;

    return 0;
}

// vim: set foldmethod=marker :


Measured memory_bytes: 256
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
ma = A.index(max(A))
maxA = max(A)
ma2 = sorted(A)[-2]
for i in range(N):
  if i == ma:
    print(ma2)
  else:
    print(maxA)

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt();

			for (int i = 0; i < N; i++) {
				char[] s1 = in.nextString().toCharArray();
				char[] s2 = in.nextString().toCharArray();

				int len1 = s1.length;
				int len2 = s2.length;

				int[][] dp = new int[len1+1][len2+1];
				for (int j = 0; j < len1; j++) {
					for (int k = 0; k < len2; k++) {
						if (s1[j] == s2[k]) {
							dp[j+1][k+1] = dp[j][k]+1;
						} else {
							dp[j+1][k+1] = Math.max(dp[j+1][k], dp[j][k+1]);
						}
					}
				}

				out.println(dp[len1][len2]);
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 63280
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int r, g, b;
    cin >> r >> g >> b;
    int n = 100 * r + 10 * g + b;
    if(n % 4 == 0){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

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

int main(){
    long long n;
    vector <long long> a(5);
    cin >> n >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> a.at(4);
    long long fast_member; 
    long long fast_time = 5;

    fast_member = *min_element(a.begin(), a.end());

    long long ans = fast_time + ((n - 1) / fast_member);
    cout << ans << endl;
}

Measured memory_bytes: 3604
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut ans = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**7)
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    a, b = LI()

    cnt = 0
    ana = 1
    for i in range(1000):
        if ana >= b:
            break
        cnt += 1
        ana += (a - 1)

    print(cnt)

solve()

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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main() {
    int N,K;
    cin >> N >> K;
    int count = 0;
    int tmp = 1;
    while(1){
        count++;
        tmp *= K;
        if(tmp>N)break;
    }

    cout << count << endl;
    // int N,K;
    // cin >> N >> K;
    // ll tmp = 1;
    // int count = 0;
    // while(1){
    //     count++;
    //     if(tmp > N){
    //         count--;
    //         break;
    //     }else if(tmp == N) {

    //         break;
    //     }
    //     tmp *= K;
    // }
    // cout << count << endl;
    return 0;
}




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

int main() {
    ll N; cin >> N;
    ll sum = 0;
    ll cur_num = 1;
    while (N > 0) {
        N /= 2;
        sum += cur_num;
        cur_num *= 2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
template<typename T>
void swap(T &a, T &b) {
    T tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<vector<ll>> XY(N,vector<ll>(N,-1));
  //親切、不親切
  FOR(i,N){
    cin>>A[i];
    FOR(j,A[i]){
      ll x,y;
      cin>>x>>y;
      XY[i][x-1]=y;
    }
  }
  //検証
  ll max_=0;
  for(ll i=0;i<pow(2,N);++i){
    bitset<15> b(i);
    bool bb=true;
    FOR(j,N){
      for(int j=0;j<N;++j){//jの証言が正しい
        if(b[j]!=1)continue;
        for(int k=0;k<N;++k){
          //cout<<"_"<<XY[j][k];
          if(XY[j][k]==1){
            if(b[k]==1){
            }else{
              bb=false;
              j=N;
              break;
            }
          }else if(XY[j][k]==0){
            if(b[k]==0){
            }else{
              bb=false;
              j=N;
              break;
            }
          }
        }
      }
    }
    if(bb==false)continue;
    ll n=0;
    FOR(j,N){
      //cout<<b[j];
      if(b[j]==1){
        n++;
      }
    }
    //cout<<endl;
    if(n>max_)max_=n;
  }
  cout<<max_<<endl;
  return 0;
}


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

int main(){
    int n,k,ans=0;
    cin >> n >> k;
    vector<int> a(n);

    for(int i=0;i<n;i++) cin >> a.at(i);

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

    for(int i=0;i<k;i++) ans+=a.at(i);

    cout << ans << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	unsigned int n;
	unsigned long ans = 0;
	unsigned long now;
	double check;
	bool solved = true;
	int i, j, k;

	cin >> n;
	unsigned int *a = new unsigned int[n + 1];
	unsigned long *top = new unsigned long[n + 1];

	cin >> a[0];
	if (a[0] > 1) {
		top[0] = 0;
		solved = false;
	}
	else {
		top[0] = 1 - a[0];
	}
	for (i = 1; i < n; i++) {
		cin >> a[i];
		if (top[i-1] < a[i-1]) {
			solved = false;
			top[i] = 0;
		}
		else {
			top[i] = (top[i - 1] - a[i - 1]) * 2;
		}
		if (top[i] < a[i]) {
			solved = false;
		}
		//		top[i] = top[i] - a[i-1];
		//		cout << i << " -> " << top[i] << endl;
	}

	if (n > 0) {
		cin >> a[n];
		if (a[n] > top[n - 1] * 2) {
			solved = false;
		}
		else {
			top[n] = a[n];
		}
	}

	if (solved == false) {
		cout << -1 << endl;
		return 0;
	}

	ans = now = a[n];
	for (i = n - 1; i >= 0; i--) {
		now += a[i];
		//		cout << i << ": " << now << " / " << top[i] << endl;
		now = min(now, top[i]);
		ans += now;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4812
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
int L[110000],R[110000];
int n,m,A[110000],len,a[110000];
char ch[110000];
struct tree{
	int w,l,r,d;
}t[110000];
int merge(int k1,int k2){
	if (k1==0||k2==0) return k1+k2;
	if (t[k1].w>t[k2].w) swap(k1,k2);
	t[k1].r=merge(k2,t[k1].r);
	if (t[t[k1].l].d<t[t[k1].r].d) swap(t[k1].l,t[k1].r);
	t[k1].d=t[t[k1].r].d+1;
	return k1;
}
int LL;
int root[110000];
void add(int k1,int k2){
	LL++; t[LL]=(tree){k2,0,0,0};
	root[k1]=merge(root[k1],LL);
}
int main(){
	scanf("%s",ch+1); len=strlen(ch+1); n=len/2;
	scanf("%d",&m);
	for (int i=1;i<=m;i++) scanf("%d%d",&L[i],&R[i]);
	for (int i=1;i<=n;i++) A[i]=(ch[len-i+1]-ch[i]+26)%26;
	for (int i=1;i<=m;i++){
		int k1=L[i],k2=R[i];
		if (k2*2<=len+1) add(k1,k2);
		else if (k1*2>=len+1){
			add(len-k2+1,len-k1+1);
		} else if (len-L[i]+2<=R[i])
			add(len-R[i]+1,L[i]-1);
		else if (len-R[i]>=L[i])
			add(L[i],len-R[i]);
	}
	memset(a,0x00,sizeof a);
	for (int i=1;i<=n;i++){
		while (root[i]&&t[root[i]].w<i) root[i]=merge(t[root[i]].l,t[root[i]].r);
		if (root[i]){
			a[i]=t[root[i]].w;
			root[a[i]+1]=merge(merge(root[a[i]+1],t[root[i]].l),t[root[i]].r);
		}
	}
	for (int i=n;i;i--) A[i]=(A[i]-A[i-1]+26)%26;
	//for (int i=1;i<=n;i++) cout<<A[i]<<" "; cout<<endl;
	for (int i=1;i<=n;i++){
		if (a[i]==0&&A[i]){
			printf("NO\n"); return 0;
		}
		int num=A[i];
		if (num) A[a[i]+1]=(A[a[i]+1]+num+26)%26;
	}
	printf("YES\n"); return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
const int maxn = 600000 + 5;
int n,m,q,psz;
int a[maxn],t[maxn],T[maxn],ret[maxn];
struct Edge{
	int u,v;
	int id;
	bool operator < (const Edge &other) const {
		return other.v > v;
	} 
}edge[maxn],que[maxn];

int lowbit(int x) {
	return x&(-x);
}

long long sum(int pos) {
	long long ret = 0;
	while (pos > 0) {
		ret += T[pos];
		pos -= lowbit(pos);
	}
	return ret;
}

void add(int pos,int x) {
	while(pos <= n) {
		T[pos] += x;
		pos += lowbit(pos);
	}
}

int main() {
	scanf("%d%d%d",&n,&m,&q);
	for (int i = 0; i < m; i++) {
		scanf("%d%d",&edge[i].u,&edge[i].v);
		t[psz++] = edge[i].u;
		t[psz++] = edge[i].v;
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d",&que[i].u,&que[i].v);
		que[i].id = i;
		t[psz++] = que[i].u;
		t[psz++] = que[i].v;
	}
	sort(t,t+psz);
	n = unique(t,t+psz) - t;
	for(int i = 0; i < m; i++){
    	edge[i].u = lower_bound(t,t + n,edge[i].u)-t+1;
    	edge[i].v = lower_bound(t,t + n,edge[i].v)-t+1;
    }
    for(int i = 0; i < q; i++){
    	que[i].u = lower_bound(t,t + n,que[i].u)-t+1;
    	que[i].v = lower_bound(t,t + n,que[i].v)-t+1;
    }
    sort(edge,edge+m);
    sort(que,que+q);
    int j = 0;
    for (int i = 0; i < q; i++) {
    	while (j < m && edge[j].v <= que[i].v) add(edge[j++].u,1);
    	ret[que[i].id] = j - sum(que[i].u-1);
	}
    for (int i = 0; i < q; i++) printf("%d\n",ret[i]);
    return 0;
}

Measured memory_bytes: 10076
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(x,y) for(lli i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
bool checkpal(string s){
	lli n=s.length();
	bool check=0;
	for(lli i=0;i<n/2;i++){
		if(s[i]!=s[n-i-1]){
			check=1;
			break;
		}
	}
	return !(check);
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    string a,b;
    lli n=s.length();
    rep(0,(n-1)/2){
    	a+=s[i];
	}
	rep((n+3)/2-1,n){
		b+=s[i];
	}
	if(checkpal(s)==1 && checkpal(a)==1 && checkpal(b)==1)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
struct bian{
	int x,to,next;
}edge[400001];
int cnt,head[100001],dis[100001];
bool vis[100001],f;
 
inline void add(int u,int v,int x){
	edge[++cnt].x=x,edge[cnt].to=v,edge[cnt].next=head[u],head[u]=cnt;
}
 
inline void dfs(int x){
	for(int i=head[x];i;i=edge[i].next){
		if(!vis[edge[i].to]){
			vis[edge[i].to]=1;
			dis[edge[i].to]=dis[x]+edge[i].x;
			dfs(edge[i].to);
		}
		else if(dis[edge[i].to]!=dis[x]+edge[i].x){
			f=0;
			return;
		}
	}
}
 
int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int l,r,d;
		cin>>l>>r>>d;
		add(l,r,-d),add(r,l,d);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			vis[i]=1;
			f=1;
			dfs(i);
			if(!f||dis[i]!=0){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int x,y;
    int tot=(n*(n+1))/2+(n*(n+1)*(2*n+1))/6;
    tot/=2;
    for(int i=0;i<n-1;i++)
    {
        cin>>x>>y;      
        int mn=min(x,y);
        int mx=max(x,y);
        tot-=(mn*(n-mx+1));
    }
    cout<<tot;

  
} 
    


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

signed main() {
  int N;
  string S;
  cin >> N;
  cin >> S;

  int ans = 0;

  for(int i=0; i<N-2; i++) if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    vector<int> A(3);
    REP(i, 3) cin >> A[i];
    sort(All(A));
    int tmp = 2*A[2]-A[1]-A[0];
    if(tmp%2){
        cout << tmp/2 + 2 << "\n";
    }else{
        cout << tmp/2 << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;

int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n),b(n);
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    ll sum=0;
    for(ll i=n-1;i>=0;i--){
        ll r=-a[i]-sum;
        if(r>0)sum+=r%b[i];
        else{
            ll x=(-r)%b[i];
            sum+=(-x+b[i])%b[i];
        }
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
ll gcd(ll x, ll y) {
    if(y == 0) {
        return x;
    }
    return gcd(y, x%y);
}
 
ll lcm1(ll x, ll y) {
    return x/gcd(x, y)*y;
}
 
ll LCM(vl &v) {  // vの全要素のlcm
    ll res = 1;
    rep(i, v.size()) {
        res = lcm1(res, v[i]);
    }
    return res;
}
 
int main() {
    ll n, m;
    cin >> n >> m;
 
    vl a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] /= 2;
    }
 
    ll lcm = LCM(a);
    rep(i, n) {
        if((lcm/a[i])%2 == 0) {
            out(0);
            re0;
        }
    }
 
    ll ans = m/(2*lcm);
    if(m%(2*lcm) >= lcm) {
        ans++;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
S=list(input())
A="AKIHABARA"
id=0
for i in range(len(A)):
  if len(S) > i and A[i]==S[i]:
    continue
  else:
    if A[i]=="A":
      S.insert(i,"A")
    else:
      print("NO")
      exit(0)
if "".join(S)==A:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
# coding: utf-8
# Here your code !
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct  9 22:12:40 2017

@author: kitagenbakurou
"""
import numpy as np
import copy

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

mp_moto = np.zeros((N , N))  # a to b への連結関係を記述

s_list = []
for i in range(M) : 
    s = input().split()
    s = [int(k) for k in s]
    mp_moto[s[0] - 1 , s[1] - 1] = 1
    mp_moto[s[1] - 1 , s[0] - 1] = 1
    s_list.append(s)

def df(x) : 
    visited[x] = 1
    for i in range(N) : 
        go = mp[x , i]
        if go == 0 : continue
        elif visited[i] == 1 : continue
        else : 
            df(i)

cnt = 0
for i in range(M) : 
    visited = np.zeros(N)
    mp = copy.deepcopy(mp_moto)
    #どれか一つの辺を取り除く
    s = s_list[i]
    mp[s[0] - 1 , s[1] - 1] = 0
    mp[s[1] - 1 , s[0] - 1] = 0
    df(0)
    if sum(visited) != N : cnt += 1

print(cnt)

Measured memory_bytes: 12444
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int N, K, t;
vector<int> len;
int main(void)
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &t);
		len.push_back(t);
	}
	sort(len.begin(), len.end(), greater<int>());
	t = 0;
	for (int i = 0; i < K; ++i)
		t += len[i];
	printf("%d\n", t);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && A!=C)
    cout << C << endl;
  if(A!=B && B==C)
    cout << A << endl;
  if(A==C && A!=B)
    cout << B << endl;
}


Measured memory_bytes: 256