akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  	int N; cin >> N;
  	vector<string> s(N);
  	for(int i = 0; i < N; i++) cin >> s.at(i);
  	
    int M; cin >> M;
  	vector<string> t(M);
  	for(int i = 0; i < M; i++) cin >> t.at(i);
  	
  	int ans = 0;
     
	for(int i = 0; i < N; i++){
      int score = 0;
        for(int j = 0; j < N; j++) if(s.at(j) == s.at(i)) score++;
      	for(int j = 0; j < M; j++) if(t.at(j) == s.at(i)) score--;
         ans = max(ans, score);
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int ans[12000];

int main() {
    ans[0] = 1;
    rep (i, 10000) ans[i+1] = ans[i]+i+1;
    int n;
    while (scanf("%d", &n) != EOF) printf("%d\n", ans[n]);
    return 0;
}

Measured memory_bytes: 0
#include<set>
#include<cmath>
#include<queue>
#include<utility>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<numeric>
#include<functional>
#include<string>
#include<iostream>

using namespace std;
const int one = 1;
const int big = (one<<20);
typedef long long int llint;
const int Llong=0;
const int Rlong=1;
const int Lbow=2;
const int Rbow=3;
 vector<tuple<llint,llint,llint,llint>> bow;//??????????????????????£????????£?
inline llint GCDme(llint n,llint m){
	if(n<m){swap(n,m);}
	if(n==0||m==0){
		return n+m;
	}
	return GCDme(m,n%m);
}
inline llint LCMme(llint n,llint m){
	return (n*m)/GCDme(n,m);
}
llint make_bow(llint ter){
	llint Llcm,Rlcm,Smom;//??????????°????????????????????????¢????????????
	if(get<Lbow>(bow[ter])==0){ Llcm=1; } else{Llcm=make_bow(get<Lbow>(bow[ter]));}
	if(get<Rbow>(bow[ter])==0){ Rlcm=1; } else{Rlcm=make_bow(get<Rbow>(bow[ter]));}
	Smom=LCMme( Llcm*get<Llong>(bow[ter]) , Rlcm*get<Rlong>(bow[ter]) );
	return (Smom/get<Llong>(bow[ter])) + (Smom/get<Rlong>(bow[ter]));
}
bool solve(void){
	llint i,n,a,b,c,d,e,ans;
	bow.clear();//?£????????????????
	llint used_bow[101]={0};
	llint top_bow=0;
	scanf("%lld",&n);
	if(n==0){ return false; }
	bow.push_back(make_tuple(1,1,0,0));//1???????£?????§??????????
	for(i=1;i<=n;i++){
		scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
		bow.push_back(make_tuple(a,b,c,d));
		used_bow[c]=1;
		used_bow[d]=1;
	}
	for(i=1;i<=n;i++){
		if(used_bow[i]==0){top_bow=i;break;}
	}
	ans=make_bow(top_bow);
	printf("%lld\n",ans);
	return true;
}
int main(void){
	while(solve()){}
	return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<utility>

using namespace std;

int main(){

    while(1){
        int m, n;
        cin >> m >> n;
        if(m==0&&n==0)break;
        vector<bool> f(1e+7,false);

        int start=m;int cn=0;

        while(cn<n){
            if(f[start]==false){
                cn++;
                for(int i=1;i*start<=1e+7;i++){
                    f[i*start]=true;
                }
                start++;
            }else{
                start++;
            }
        }
        while(f[start]){
            start++;
        }
        cout<<start<<endl;
    }

    return 0;
}



Measured memory_bytes: 4288
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int d8x[8] = {0,1,1,1,0,-1,-1,-1};
int d8y[8] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int H,W;
	cin>>H>>W;
	vector<vector<char>> in(H,vector<char> (W));
	vector<vector<char>> ans(H,vector<char> (W));
	rep(i,H)rep(j,W)cin>>in[i][j];
	rep(i,H)rep(j,W){
		if(in[i][j] == '#'){
			ans[i][j] = '#';
			continue;
		}
		int count = 0;
		rep(k,8){
			int dy = i + d8y[k], dx = j + d8x[k];
			if(dy < 0 || dx < 0 || dy >= H || dx >= W)continue;
			if(in[dy][dx] == '#') ++count;
		}
		ans[i][j] = '0'+ count;
	}
	rep(i,H){rep(j,W)cout<<ans[i][j]; cout<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define SZ(a) ((int)(a).size())
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0, j = SZ(s) - 1; i < j; ++i, --j) {
		int a = 0;
		while (i <= j && s[i] == 'x')
			++i,++a;
		while (j >= i && s[j] == 'x')
			--j,--a;
		if (i > j)
			break;
		ans += abs(a);
		if (s[i] != s[j]) {
			cout << "-1\n";
			return 0;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();
		String line = sc.nextLine();
		while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		}
		int count = 0;
		for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		}
		System.out.println(count);

	}
}

Measured memory_bytes: 26100
#!/usr/bin/env python3
import sys

def isM(a):
    return  (a >= 1 and a <= 12)

def solve(S: str):
    a = int(S[0:2])
    b = int(S[2:])

    isA = isM(a)
    isB = isM(b)

    if isA and isB:
        print("AMBIGUOUS")
    elif not isA and not isB:
        print("NA")
    elif isA:
        print("MMYY")
    else:
        print("YYMM")




# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// problem C of contest 042
//  the link for problem : https://atcoder.jp/contests/abc042/tasks/arc058_a

#include <iostream>
using namespace std;
int d[10];
bool c(int n)
{
    while(n>0){
    int t = n%10;
    if(d[t]==1)
    {
        return false;
    }
    n/=10;
    }
    return true;

}
int main()
{
    int N,K;
    cin>>N>>K;
    for(int i=0;i<K;i++)
    {
        int t;
        cin>>t;
        d[t]=1;
    }
    while(true)
    {
        if(c(N))
        {
            cout<<N;
            return 0;
        }
        N++;
    }


    return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
lst = list(map(int, input().split()))
dp = [0 for i in range(N)]
for i in range(1,N):
    mn = 999999999999999999
    for j in range(1,K+1):
        if i-j >= 0:
            mn = min(mn,dp[i - j] + abs(lst[i] - lst[i - j]))
        else:
            break
    dp[i] = mn
print(dp[-1])


Measured memory_bytes: 56544
#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005];
void update_range(int i,int j){
	b[i]++;
	b[j+1]--;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int MAXI=600;
	if(k>=MAXI){
		for(int i=1;i<=n;i++){
			cout<<n<<" ";
		}
		return 0;
	}
	for(int i=1;i<=k;i++){
		memset(b, 0, sizeof b);
		for(int i=1;i<=n;i++) update_range(max(1, i-a[i]), min(n, i+a[i]));
		a[0]=0;
		for(int i=1;i<=n;i++) a[i]=a[i-1]+b[i];
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<" ";
	}
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x | (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << ' ' << a << ' ' << b;
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m, k int
	fmt.Fscan(r, &n, &m, &k)

	ruia := make([]int, n+1)
	ruib := make([]int, m+1)
	ruia[0] = 0
	ruib[0] = 0

	for i := 0; i < n; i++ {
		var tmp int
		fmt.Fscan(r, &tmp)
		ruia[i+1] = ruia[i] + tmp
	}

	for i := 0; i < m; i++ {
		var tmp int
		fmt.Fscan(r, &tmp)
		ruib[i+1] = ruib[i] + tmp
	}
	ans := 0
	bj := m
	for i := 0; i < n+1; i++ {
		if ruia[i] > k {
			break
		}

		for ruia[i]+ruib[bj] > k && bj >= 0 {
			bj--
		}
		if bj < 0 {
			break
		}
		if i+bj > ans {
			ans = i + bj
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll S,t=1e9,a=1,b=1;
  cin >> S;
  b = (t-S%t)%t;
  a = (S+b)/t;

  cout << "0 0 1 1000000000 " << a << " " << b << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c = 0;
	int i;

	for (i = 0; i < 7; i++)
	{
		scanf("%d", &a); scanf("%d", &b);
		c = a - b;

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

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i,j;

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

	      	  int N,K;
	      	  cin >> N  >> K;

	      	  int mn=1e9;;
	      	  for(i=0;i<(1<<10);i++){
	      		  int a=1;
	      		  for(j=0;j<N;j++){
	      			  if(i&(1<<j)){
	      				  a+=K;
	      			  }else{
	      				  a*=2;
	      			  }
	      		  }
	      		  mn=min(mn,a);
	      	  }

	      	  cout << mn << endl;

	          return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
	int Max, Num = 0, In;
	while (true){
		vector<int>	Dat;
		Max = -100000;
		cin >> Num;
		if (Num == 0)break;
		Dat.push_back(-100000);
		for (int i = 0; i < Num; i++){
			cin >> In;
			Dat.push_back(In);
		}
		for (int i = 1; i < Num + 1; i++){
			Dat[i] = max(Dat[i], Dat[i - 1] + Dat[i]);
			Max = max(Max, Dat[i]);
		}
		cout << Max << endl;
	}
	return 0;
}

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

typedef long long ll;

int main(void) {
  ll t1, t2, a1, a2, b1, b2;
  scanf("%lld%lld%lld%lld%lld%lld", &t1, &t2, &a1, &a2, &b1, &b2);
  b1 -= a1;
  b2 -= a2;
  if(b1 == 0 || b2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  if(b1 < 0) {
    b1 *= -1;
    b2 *= -1;
  }
  ll d1 = b1 * t1;
  ll d2 = b2 * t2;
  if(d1 + d2 == 0) {
    cout << "infinity" << endl;
    return 0;
  } else if(d1 + d2 > 0) {
    cout << 0 << endl;
    return 0;
  } else {
    ll x = -(d1+d2);
    if(d1 % x == 0) {
      cout << d1 / x * 2 << endl;
    } else {
      cout << d1 / x * 2 + 1 << endl;
    }
  }
  return 0;
}


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

void solve(vector<vector<long long>>&dp, vector<int>&w, vector<int>&v, int i, int &n, int weight_left){
    if(i == n) return;
    if(weight_left <= 0) return;
    if(w[i]>weight_left){
        solve(dp,w,v,i+1,n,weight_left);
        dp[weight_left][i] = dp[weight_left][i+1];
    }
    else if(dp[weight_left][i] == 0){
        solve(dp,w,v,i+1,n,weight_left-w[i]);
        solve(dp,w,v,i+1,n,weight_left);
        dp[weight_left][i] = max(dp[weight_left][i+1],v[i]+dp[weight_left-w[i]][i+1]);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    // int t; cin>>t;
    // while(t--){
        int n,W; cin>>n>>W;
        vector<int>w(n),v(n);
        for(int i=0;i<n;i++){
            cin>>w[i]>>v[i];
        }
        vector<vector<long long>>dp(100001, vector<long long>(n+1, 0));
        solve(dp,w,v,0,n,W);
        cout<<dp[W][0]<<"\n";
    // }
}


Measured memory_bytes: 85304
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;


int n, flag;
ll a;
string s;

int main() {
	cin >> n >> s;
	flag = 0;
	s += '.';
	lp(n) {
		if (s[i] != s[i + 1]) {
			if (flag == 0)
				a = 3;
			else if (flag == 1)
				a *= 2;
			flag = 1;
		}
		else {
			if (flag == 0)
				a = 6;
			else if (flag == 1)
				a *= 2;
			else
				a *= 3;
			flag = 2;
			i++;
		}
		a%=mod;
	}
	cout << a << endl;
	return 0;
}

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

int main(){
  string s;
  bool a[26]={};
  cin>>s;
  for(int i=0;s[i]!='\0';i++){
    a[s[i]-'a']=true;
  }
  for(int i=0;i<26;i++){
    if(!a[i]){
      cout<<(char)(i+'a');
      return 0;
    }
  }
  cout<<"None";
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=0; i<30; i++){
            if((n - 4 * i) % 7 == 0 && (n - 4 * i) >= 0){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define int long long

#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

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

int n;
int powMOD(int a, int b, int MOD)
{
    int ans = 1;
    for (int i = 0; i < b; i++)
    {
        ans *= a;
        ans %= MOD;
    }
    return ans;
}

void solve()
{
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int a = powMOD(10, n, MOD);
    int b = powMOD(9, n, MOD);
    int c = powMOD(8, n, MOD);

    cout << (a + (-2) * b + c + 3 * MOD) % MOD << endl;
}

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


Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long int ll ;
using namespace std ;
int main()
{
    ll n , i , sum=0 ;
    cin >> n ;
    for(i =1;i<=n;++i)
    {
        ll x = (n/i) ;
        sum=sum+i*((x*(x +1)) /2) ;
    }
    cout << sum << "\n" ;
}


Measured memory_bytes: 3492
# S = input()
# N = int(input())
N, K = map(int, input().split())
# X = list(map(int, input().split()))
# LR = [list(map(int, input().split())) for _ in range(N)]

ans = 0

if (K % 2) == 1:
    tmp = N // K
    ans = pow(tmp, 3)
else:
    tmp = N // K
    ans = pow(tmp, 3)
    tmp2 = N // K
    if (N % K) >= (K // 2):
        tmp2 += 1
    ans += pow(tmp2, 3)

print(ans)


Measured memory_bytes: 3060
N=int(input())
D,X=map(int,input().split())
A=[]
for i in range(N):
    A.append(int(input()))

num=[]
for j in A:
    count=[]
    for k in range(D):
        if j*k+1<=D:
            count.append(1)
    num.append(len(count))

print(sum(num)+X)
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> pii;

int t;

void solve(){
    int n, cnt=0;
    string a;
    cin>>n>>a;
    for(int i=0;i<n;i++){
        if(i+2<n){
        if(a[i]=='A' && a[i+1]=='B' && a[i+2]=='C'){
            cnt++;
        }
        }
    }
    cout<<cnt;
}

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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


int main() {
  string s;
  cin >> s;
  if (s.at(s.size() - 1) == 's') {
    cout << s + "es";
  } else {
    cout << s + "s";
  }
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := nextInt()
	K := nextInt64()
	A := make([]int64, N)
	sum := int64(0)

	for i := 0; i < N; i++ {
		A[i] = nextInt64()
		sum += A[i]
	}

	divs := dividersOf(sum)
	l := len(divs)
	for i := 0; i < l; i++ {
		div := divs[l-1-i]

		mods := make(ints, N)
		for i := 0; i < N; i++ {
			mods[i] = A[i] % div
		}
		sort.Sort(mods)

		d := int64(0)
		k := int64(0)
		l := 0
		r := N - 1

		// fmt.Println(mods)
		for l <= r {
			if d < 0 {
				// fmt.Println(div, "r", r, div-mods[r])
				d += div - mods[r]
				r--
			} else {
				// fmt.Println(div, "l", l, -mods[l])
				d -= mods[l]
				k += mods[l]
				l++
			}
		}

		if k <= K && d == 0 {
			fmt.Println(div)
			return
		}
	}
}

type ints []int64

func (a ints) Len() int           { return len(a) }
func (a ints) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ints) Less(i, j int) bool { return a[i] < a[j] }

func dividersOf(n int64) []int64 {
	div1 := make([]int64, 0)
	div2 := make([]int64, 0)

	for i := int64(1); i*i <= n; i++ {
		if n%i == 0 {
			div1 = append(div1, i)

			if i != n/i {
				div2 = append(div2, n/i)
			}
		}
	}
	l := int64(len(div2))
	for i := int64(0); i < l; i++ {
		div1 = append(div1, div2[l-1-i])
	}
	return div1
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 4352
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(K, N):
    # next_sum_val = now_sum_val // A[i - K] * A[i]
    if A[i] > A[i - K]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 105048
program main
  implicit none
  
  integer :: i,n,t,a,h(1000),best
  real :: tt, sa = 1d10
  
  read(*,*)n
  read(*,*)t,a
  read(*,*)(h(i),i=1,n)
  
  do i = 1, n
    tt = t - 0.006*h(i)
    if (abs(tt-a) < sa) then
      best = i
      sa = abs(tt-a)
    end if
  end do
  write(*,*)best
end program main

Measured memory_bytes: 256
<?php
$str = "#.";
while (true) {
        fscanf(STDIN,"%d %d",$h,$w);
        if ($h === 0 && $w === 0) break;
        $res = "";
        for ($i = 0; $i < $h; $i++) {
                for ($j = 0; $j < $w; $j++) {
                        $res .= $str[($i+$j)&1];
                }
                $res .= PHP_EOL;
        }
        echo $res, PHP_EOL;
}

Measured memory_bytes: 15288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{ // 

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		String s = cin.next();

		long start = now();

		long ans = solve(s);
		cout.println(ans);

		trace("elapsed", now() - start);
	}

	private static long solve(String s) {
		long len = s.length();
		long[] cnt = new long['z' - 'a' + 1];
		long[] others = new long[cnt.length];
		Arrays.fill(others, len);
		for (char c : s.toCharArray()) {
			int d = c - 'a';
			cnt[d] += 1;
			others[d] -= 1;
		}
		long ans = 0;
		for (int i = 0; i < cnt.length; i++)
			ans += cnt[i] * others[i];
		ans /= 2;
		ans += 1;
		return ans;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

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

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

}


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

int main(){
	int n;
	cin >> n;
	ll ans = 1;
	ll even = 0;
	rep(i,n){
		int a;
		cin >> a;
		if(a%2==0) even++;
	}
	ll temp = 1;
	rep(i,even) temp *= 2;
	rep(i,n) ans *= 3;
	ans -= temp;
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x:x-1,A))

next=0
hoge=[]
zisyo={}

for i in range(n):
    next=A[next]
    if next in zisyo:
        t=next
        break
    else:
        zisyo[next]=1
        hoge.append(next)
hoge_1=[]
hoge_2=[]
for i in range(len(hoge)):
    if hoge[i]==t:
        hoge_1=hoge[:i]
        hoge_2=hoge[i:]

ans=0
if k<=len(hoge_1):
    for i in range(k):
        ans=A[ans]
else:
    k=k-len(hoge_1)-1
    k=k%len(hoge_2)
    ans=hoge_2[0]
    for i in range(k):
        ans=A[ans]


print(ans+1)

Measured memory_bytes: 34632
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (i % 2 == 0 && a % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
while(1){
int d[17][17]={0},i,j,a,b,n,m[17][17]={0},x,y;
scanf("%d%d",&a,&b);
if(a==0&&b==0)
return 0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d",&x,&y);
m[x][y]=1;
}
d[1][1]=1;
for(i=1;i<=a;i++){
for(j=1;j<=b;j++){
if(m[i][j]!=1){
if(a>=i+1&&m[i+1][j]!=1)
d[i+1][j]=d[i+1][j]+d[i][j];
if(b>=j+1&&m[i][j+1]!=1)
d[i][j+1]=d[i][j+1]+d[i][j];
}
}
}
printf("%d\n",d[a][b]);
}
return 0;
}



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

typedef long long ll;
int edg[10000][2];

int main(){
    ll n, k;
    cin >> n >> k;
    int sum = ((n-1)*(n-2))/2;

    if( k > sum){
        cout << -1 << endl;
        return 0;
    }

    for( int i=0; i<n-1; i++) {
        edg[i][0] = 0;
        edg[i][1] = i+1;
    }
    int cnt = n-1;
    for(int i=1; i<n; i++){
        if( sum==k ) break;
        for( int j=i+1; j<n; j++){
            edg[cnt][0] = i;
            edg[cnt][1] = j;
            sum--;
            cnt++;
            if( sum==k ) break;
        }
    }
    cout << cnt << endl;
    //cerr << k << endl;
    for( int i=0; i<cnt; i++){
        cout << edg[i][0]+1 << " " << edg[i][1]+1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val m = sc.nextInt

  val iAbt = List.fill(m)(List(sc.nextInt, sc.nextInt))

  val abt = iAbt.flatten

  val resArr = abt.foldLeft(new Array[Int](n)){case (arr, c) =>
    val newVal = arr(c - 1) + 1
    arr.update(c - 1, newVal)
    arr
  }
  resArr.foreach(println)
}


Measured memory_bytes: 25808
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

int mod = 1000000007;

int modpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

signed main(){

    int N, Q; cin >> N >> Q;
    vec A(N); readv(A);
    vec X(Q), Y(Q);
    REP(i, Q){
        cin >> X[i] >> Y[i];
        X[i]--;
        Y[i]--;
    }

    int inv2 = modpow(2, mod - 2, mod);

    mat p(N, vec(N, 0));
    REP(i, N) REP(j, N) if(A[i] < A[j]) p[i][j] = 1;
    
    REP(q, Q){
        REP(i, N){
            if(i == X[q] || i == Y[q]) continue;
            int ave = ((p[i][X[q]] + p[i][Y[q]]) * inv2) % mod;
            p[i][X[q]] = ave;
            p[i][Y[q]] = ave;
            ave = ((p[X[q]][i] + p[Y[q]][i]) * inv2) % mod;
            p[X[q]][i] = ave;
            p[Y[q]][i] = ave;
        }
        int ave = ((p[X[q]][Y[q]] + p[Y[q]][X[q]]) * inv2) % mod;
        p[X[q]][Y[q]] = ave;
        p[Y[q]][X[q]] = ave;
    }
    int ans = 0;
    REP(i, N) REP(j, i) ans = (ans + p[i][j]) % mod;
    ans = (ans * modpow(2, Q, mod)) % mod;

    cout << ans;
    
    return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  //cout << a << endl,
  //cout << b << endl;
  //cout << a % 2 << endl;
  if (A * N <= B) {
    cout << A * N << endl;
  }
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
package main

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

/* 一つ読み */
func scanText() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

/* 複数読み */
func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}
func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}
func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()
	bill := 0
	if n%1000 == 0 {
		bill = (n / 1000)
	} else {
		bill = (n / 1000) + 1
	}

	fmt.Println(bill*1000 - n)

}

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

template<size_t N>
bitset<N> prime_list(){
  bitset<N> ret, notPrime;
  notPrime[0] = notPrime[1] = true;
  int sqrt = 0;
  while(sqrt * sqrt <= N) ++ sqrt;
  for(int i = 2;i < sqrt;++ i){
    if(notPrime[i]) continue;
    ret[i] = true;
    for(int j = N - N % i, l = i * i;j >= l;j -= i) notPrime[j] = true;
  }
  for(int i = sqrt;i <= N;++ i) if(!notPrime[i])  ret[i] = true;
  return ret;
}
int main() {
  const int LEN = 10000000;
  bitset<LEN> prime = prime_list<LEN>();
  int cumsum[LEN + 1];
  for (int i = 0;i < LEN + 1;++ i) cumsum[i] = 0;
  for (int i = 3;i < prime.size();i += 2) if (prime[i] && prime[i + 1 >> 1]) ++ cumsum[i];
  for (int i = 1;i < LEN + 1;++ i) cumsum[i + 1] += cumsum[i];
  int Q;
  cin >> Q;
  while(Q--) {
    int l, r;
    cin >> l >> r;
    cout << cumsum[r] - cumsum[l - 1] << endl;
  }
}


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


int main(){
  int n,m;
  cin>>n>>m;
  int a[1000]={};
  for(int i=1;i<=m;i++){cin>>a[i];}
  int b[1000][1000]={};
  int count[1000]={};
  
  for(int i=1;i<=m;i++){
    for(int p=1;p<=n;p++){
      cin>>b[i][p];
      if(b[i][p]==a[i]){count[p]+=1;}
      else{count[a[i]]+=1;}
    }
  }

  for(int t=1;t<=n;t++){cout<<count[t]<<endl;}
  
  return 0;
}



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

dic = {}

for _ in range(N):
  s = input()
  s = sorted(s)
  s = "".join(s)
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] +=1
  
rlt = 0
for k in dic:
  rlt += dic[k]*(dic[k]-1)//2
  
print(rlt)

Measured memory_bytes: 98964
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int k = sc.nextInt();
    char c = s.charAt(k-1);
    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < s.length(); i++ ){
      if(s.charAt(i) == c) {
        sb.append(c);
      } else {
        sb.append('*');
      }
    }
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 22740
using System;

namespace atcoder108
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            int even = 0;
            int odd = 0;
            int ans;
            if (K % 2 == 0) ans = (K/ 2) * (K / 2);
            else ans = (K / 2) * ((K / 2) + 1);
            Console.WriteLine(ans);
            
        }
    }
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's') {
    cout << (s + "es") << endl;
  } else {
    cout << (s + "s") << endl;
  }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,m,q,L;
typedef pair<int,int> pii;
vector<pii>g[310];
int ans[310][310],f[310][310],vis[310];
struct ppo{
    int u,v,cos;
    bool operator<(const ppo &r)const{
        if(cos==r.cos) return v<r.v;
        return cos>r.cos;
    }
};
void bfs(int st){
    for(int i=1;i<=n;i++) vis[i]=0;
    priority_queue<ppo>q;
    q.push(ppo{st,L,0});
    while(!q.empty()){
        int u=q.top().u;q.pop();
        vis[u]=0;
        for(pii x:g[u]){
            int v=f[st][u];
            int cost=ans[st][u];
            if(v<x.second) v=L-x.second,cost++;
            else v-=x.second;
            if(cost<ans[st][x.first]||(cost==ans[st][x.first]&&v>f[st][x.first])){
                ans[st][x.first]=cost;
                f[st][x.first]=v;
                if(!vis[x.first]){
                    vis[x.fi]=1;
                    q.push(ppo{x.first,v,cost});
                }
            }
        }
    }
}
int main(){
    //ios::sync_with_stdio(false);
    //freopen("in","r",stdin);
    scanf("%d%d%d",&n,&m,&L);
    for(int i=1,a,b,c;i<=m;i++){
        scanf("%d%d%d",&a,&b,&c);
        if(c>L) continue;
        g[a].pb(pii(b,c));
        g[b].pb(pii(a,c));
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++) ans[i][j]=inf;
    }
    for(int i=1;i<=n;i++){
        ans[i][i]=0,f[i][i]=L,bfs(i);
    }
    scanf("%d",&q);
    while(q--){
        int s,t;
        scanf("%d%d",&s,&t);
        if(ans[s][t]==inf) ans[s][t]=-1;
        printf("%d\n",ans[s][t]);
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
	

fast;


ll x;
cin>>x;

ll val=8;
for(ll i=600;i<=2000;i+=200,val--)
{
	if(x<i)
	{
		cout<<val;
		return 0;
	}
	
}

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long 
using namespace std;
int dfs(int h){
    if(h==1)return 1;
    int ans=0;
    ans+=1+2*dfs(h/2);
    return ans;
}
int32_t main(){
    int h;cin>>h;
    cout<<dfs(h)<<endl;;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b;
	
	scanf("%d%d",&a,&b);
	
	if(a==b)puts("Draw");
	else if((a==13||b==13)&&(a==1||b==1)){
		if(a>b)puts("Bob");
		else puts("Alice");
	}
	else if(a>b)puts("Alice");
	else if(a<b)puts("Bob");
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){

	string s;
	cin >> s;

	int q;
	cin >> q;

	int d[q][2];
	vector<char> vec;
	char c;

	for(int i = 0;i < q;i++){
		cin >> d[i][0];
		if(d[i][0] == 1){
			d[i][1] = 0;
			continue;
		}
		else{
			cin >> d[i][1];
			cin >> c;
			vec.pb(c);
		}
	}
	
	int one_count = 0;
	int char_count = 0;
	deque<char> deq;

	rep(i,s.size()){

		deq.pb(s[i]);

	}

	rep(i,q){

		if(d[i][0] == 1){
			one_count++;
		}
		else{
			if(d[i][1] == 1){
				if(one_count%2 == 0){
					deq.push_front(vec[char_count]);
					char_count++;	
				}
				else{
					deq.pb(vec[char_count]);
					char_count++;
				}
			}
			else{
				if(one_count%2 == 1){
					deq.push_front(vec[char_count]);
					char_count++;
				}
				else{
					deq.pb(vec[char_count]);
					char_count++;
				}
			}
		}

	}

	if(one_count%2 == 0){
		for(auto itr = deq.begin();itr != deq.end();itr++){
			cout  << *itr;
		}
		cout << endl;
	}
	else{

		for(auto itr = deq.end()-1;itr != deq.begin();itr--){
			cout << *itr;
		}
		cout << deq.front();
		cout << endl;

	}

	return 0;
}


Measured memory_bytes: 2684
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 char s[n+1][15];
 ll m=0,a=0,r=0,c=0,h=0;
 rep(i,0,n){
   sc(s[i]);
  if(s[i][0]=='M')m++;
  if(s[i][0]=='A')a++;
  if(s[i][0]=='R')r++;
  if(s[i][0]=='C')c++;
  if(s[i][0]=='H')h++;
 }
 pr(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h);
  return 0;}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(0,a-2*b) << endl;
  return 0;
}

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

struct compare1 { 
    bool operator()(const pair<long, long>& value,  
                                const long& key) 
    { 
        return (value.first < key); 
    } 
    bool operator()(const long& key,  
                    const pair<long, long>& value) 
    { 
        return (key < value.first); 
    } 
}; 

int main()
{
    long X; cin >> X;
    long gohyaku = X / 500;
    long goen = (X - gohyaku * 500) / 5;
    cout << gohyaku * 1000 + goen * 5 << endl;
    
    return 0;
}



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

str1=str
str2=str
n=int(N/2)

for var in range(1,n+1):
    try:
        str1=str1.replace("()","")
    except:
        break

s1=str1.count("(")
s2=str1.count(")")

print("("*s2+str2+")"*s1)

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

int main () {
  vector<int> line(26) ;
  string a ;
  cin >> a ;
  for(int i = 0 ; i < a.length() ; i++ ) {
    int c = a[i] - 'a' ; 
    line[ c ] = 1 ;
  }
  //for(int i =  0; i < 26 ; i++ ) cout << line[i] << endl ;
  for(int i = 0 ; i < 26 ; i++ ) {
    if(line[i] == 0) {
      cout << char('a' + i ) << endl ;
      break ;
    }
    if( i == 25 ) {
      cout << "None" << endl ;
      break ;
    }
  }
}

Measured memory_bytes: 512
h,w,d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
dic = [0]*(h*w)
for i in range(h):
  for j in range(w):
    dic[a[i][j]-1] = (i,j)
sup = [0]*(h*w)
for x in range(d,h*w):
  sup[x] = sup[x-d] + abs(dic[x][0]-dic[x-d][0]) + abs(dic[x][1]-dic[x-d][1])
q = int(input())
for _ in range(q):
  l,r = map(int, input().split())
  print(sup[r-1]-sup[l-1])

Measured memory_bytes: 17964
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c));
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

int _gcd(int a,int b) {
  int r;
  if(a < b) swap(a,b);
  while(b > 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {
  int k;
  cin >> k;
  long long ans = 0;
  for(int i = 1; i <= k; i++) {
    for(int j = 1; j <= k; j++) {
      for(int l = 1; l <= k; l++) {
        long long tmp = _gcd(i,j);
        ans += _gcd(tmp,l);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if  (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,cnt=0,ans=0;;
    cin >> n;
    vll h(n);
    rep(i,n) cin >> h[i];
    rep(i,n-1){
        if(h[i]>=h[i+1]) cnt++;
        else cnt=0;
        ans=max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a[3];
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    sort(a,a+3);
    for(int i=0;i<3;i++){
        cout << a[i];
        if(i != 2){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s;
  int k;
  char ans='1';
  
  cin >> s >> k;

  for(int i=0; i<k; i++){
    if(s[i]!='1'){
      ans = s[i];
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int a[1000];
    for(int i=0;i<N;i++)
        cin >> a[i];
    
    // 昇順ソート
    sort(a, a + N);

    cout << a[N-1] - a[0] << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    int k = s.back() - '0';
    if (k == 0 || k == 1 || k == 6 || k == 8) {
        cout << "pon" << endl;
    } else if (k == 3) {
        cout << "bon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3700
N=int(input())
LI=[]
for i in range(N):
    tt=input()
    LI.append(tt)

moto=['AC','WA','TLE','RE']
suum=[]
for i in moto:
    moji=LI.count(i)
    suum.append(moji)

for i in range(4):
    print('{} x {}'.format(moto[i],suum[i]))

Measured memory_bytes: 16288
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll n ,ans=0; cin>>n  ;
  vector<ll>a(n),b(n),c(n-1);
  rep(i,n) cin>>a[i];
  rep(i,n) {
  ll t; cin>>t; ans+=t;
  }
  rep(i,n-1) cin>>c[i];
  rep(i,n-1){
  if(a[i+1]==a[i]+1) ans+=c[a[i]-1];
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
#define num_size 100000
typedef long long ll;

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    string c[110];
    for (int i = 1; i <= H; i++){
	    cin >> c[i];
    }

    string res[210];
    for (int i = 1; i <= 2*H; i++){
	    res[i] = c[(i+1)/2];
    }

    for (int i = 1; i <= 2*H; i++){
	    cout << res[i] << endl;
    }

    return 0;
}


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

# (Pi,Yi)のようなタプルの形で保存する
# Yiでソートしたいので、別のリストで管理するのは非効率
PY = []

# keyはYi、valueはi
# i順に出力するためのメモ用辞書
Y_to_i = dict()

for i in range(M):
    p, y = map(int, input().split())
    # タプルは後で変更できない（良く言えば「保持される」）
    PY.append((p, y))
    # yに対するiを記録、ここでyはuniqueであることが問題で保証されている
    Y_to_i[y] = i

# 第一引数(=県の番号)で大雑把にソート、同じ県内では、第二引数(=誕生年)で細かくソート
PY.sort()

ID_list = [""] * M

temp_p = PY[0][0]

idx = 1

for p, y in PY:

    # 県が変わったらidxは1に初期化
    if p != temp_p:
        idx = 1

    # 上のifをやるために現在のpをtemp_pとして記録しておく
    temp_p = p

    # ID_listには、最初に受け取った「市の番号」順に結果を格納
    ID_list[Y_to_i[y]] = str(p).zfill(6) + str(idx).zfill(6)

    # 次のためにidxをincrement
    idx += 1

# 市の番号順に入っているのでそのまま出力するだけ
for a in ID_list:
    print(a)


Measured memory_bytes: 37812
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
char s[1000010];
struct node{
	int l,r;
};
vector<node> d;
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	int res=1;
	int cnt=0;
	int head=0;
	for(int i=1;i<=len+1;i++){
		if(s[i]!=s[i-1]){
			if(i!=1){
				cnt++;
				d.push_back({head,i});
			}
			head=i;
		}
	}
	if(cnt==1){
		printf("%d\n",len);
		return 0;
	}
	if(cnt==2){
		printf("%d\n",max(d[1].r-d[1].l,d[0].r-d[0].l));
		return 0;
	}
	/*
	for(int i=1;i+1<cnt;i++){
		res=max(res,min(d[i].r-d[i-1].l,d[i+1].r-d[i].l));
	}
	for(int i=1;i+1<cnt;i++){
		res=max(res,min(max(len+1-d[i].r,d[i+1].l-1),d[i+1].r-d[i].l));
	}
	*/
	for(int i=1;i+1<cnt;i++){
		res=max(res,min(d[i].r-1,len+1-d[i].l));
	}
	printf("%d\n",res);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  for (int i=1;i<10;i++){
    if (n%i==0){
      int dn = n/i;
      if (dn<=9){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
typedef long long ll;

int main(){
	ll N;
	cin>>N;
	ll ans = N/2;
	if(N%2==1) ans++;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256