akhauriyash/Code-Regression huggingface dataset:
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n,k;
	cin >> n >> k;
	VII arr(n);
	int ans = 0;
	for(auto &x:arr)
	{
		cin >> x;
		if(x>=k)
			ans++;
	}

	cout << ans;

#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
	string st;
	vector<int>nums(26);
	while (getline(cin, st)) {

		for (auto c : st) {
			if (c <= 'z'&&c >= 'a')nums[c - 'a']++;
			if (c <= 'Z'&&c >= 'A')nums[c - 'A'] ++;
		}
	}
	for (int i = 0; i < 26; ++i) {
		cout << char('a' + i) << " : " << nums[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
//
// Darsein AC : O(MlogM)
// implement :  25 min
// debug     :  5 min
//

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

int main(){
  ll n,m,k,d,s;
  cin >> n >> m >> k >> d >> s;

  vector< vector<ll> > c(m);
  rep(i,m){
    c[i].resize(3);
    cin >> c[i][0] >> c[i][1] >> c[i][2];
  }

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

  ll cur = s;
  priority_queue< ll,vector<ll>,greater<ll> > end, out;
  map<ll,ll> regi;

  int i = 0;
  while(k && i<m){
    cur += d;
    k--;
    while(i<m && c[i][0]<=cur){
      ll t = c[i][0];
      if(regi.count(c[i][2])){
	out.push(regi[c[i][2]]);
	t = max(t, regi[c[i][2]]);	
      }
      regi[c[i][2]] = t+c[i][1];
      end.push(t+c[i][1]);
      i++;
    }
    while(!out.empty() && out.top() == end.top()){
      out.pop(); end.pop();
    }

    if((ll)regi.size()<n){
    	continue;
      //break;
    }

    cur = max(cur,end.top());
  }
  cout << cur + d*k-s << endl;
}

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

int main(){
  ll A,B,C,K;cin >> A >> B >> C >> K;
  if(K<=A){
    cout << K << endl;
  }else if(K<=A+B){
    cout << A << endl;
  }else{
    cout << 2*A+B-K << endl;
  }
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}

int main() {
int H,W,N;
cin>>H>>W>>N;
H = max(H,W);
cout<<(N%H==0 ? N/H : (N/H)+1)<<endl;
return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;


namespace Acs
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            var ss = Console.ReadLine().Split(' ');
            var a = int.Parse(ss[0]);
            var b = int.Parse(ss[1]);
            Console.WriteLine(a<=b ?a:a-1);
            */

            var int_ = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Console.WriteLine(int_[0] <= int_[1] ? int_[0] : int_[0] - 1);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll a,b;
cin >> a >> b;
cout << a * b << endl;
}

Measured memory_bytes: 3636
(let* ((n (read))
       (m (read))
       (lst (sort (loop :repeat n :collect (read)) #'>))
       (sum (reduce #'+ lst))
       (fav (subseq lst 0 m)))
  (if (every (lambda (x) x) (mapcar (lambda (x) (<= (/ sum (* 4 m)) x)) fav))
      (princ "Yes")
      (princ "No")))

Measured memory_bytes: 16228
package main

import "fmt"

func prmFac(x int) map[int]bool {
	pfm := make(map[int]bool)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			x /= i
			pfm[i] = true
		}
	}
	if x > 1 {
		pfm[x] = true
	}
	return pfm
}

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

	ans := 0
	for i := range prmFac(n) {
		t := 1
		for {
			t *= i
			if n%t != 0 {
				break
			}
			n /= t
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x>>y;
  std::vector<string> v(x);
  rep(i,x)std::cin >> v[i];

  rep(i,x){
    Rep(j,y){
      if(v[i][j]=='#'){
        std::cout << '#';
        m++;
      }else{
        for (int k = 0; k < x; k++) {
          if(v[k][j]=='#')n++;
        }
        if(n==0)continue;
        n=0;
        for (int k = 0; k < y; k++) {
          if(v[i][k]=='#')n++;
        }
        if(n>0){
          std::cout << '.';
          m++;
        }
        n=0;
      }
    }
    if(m>0){
      std::cout << '\n';
      m=0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a); 
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}	
};


map<int,int> h;
int dp[2007];
vector <int> arraySort(vector <int> v) {
	vector<int> ans;
	for(int i = 1; i <= (int)v.size(); i++){
		dp[i] = 1;
	}
	
	for(int i = 1; i <= (int)v.size(); i++){
		for(int j = 1; j < i; j++){
			if(v[j-1] <= v[i-1]){ 
				if(dp[i] < dp[j] + 1){
					dp[i] = dp[j] + 1;
					h[i] = j;
				}
				else if(dp[i] == dp[j] + 1){					
					int index = h[i];
					int val = v[index-1];
					if(v[j-1] < val){
						h[i] = j;
					}
				}
			}
		}
	}
	int index, maxi = 0, minval = inf;
	for(int i = 1; i <= (int)v.size(); i++){
		if(maxi <= dp[i] ){
			maxi = dp[i];
		}
	} 
	
	for(int i = 1; i<= (int)v.size(); i++){
		if(maxi == dp[i]){
			if(minval > v[i-1]){
				minval = v[i-1];
				index = i;
			}
		}
	}
	
	cout<<minval<<" "<<index<<endl;
	
	int next = index;
	
	while(next){
		cout<<next<<" ";
		next = h[next];
	}
	return ans;
}


int main(){
	int n, k; cin>> n >> k;
	int cnt = 0;
	while(n){
		n/= k;
		cnt++;
	}
	cout<< cnt;
	return 0;
}













Measured memory_bytes: 256
<?php

fscanf(STDIN, '%s', $s);

if (substr($s, 0, 1) === 'R' && substr($s, 1, 1) === 'R' && substr($s, 2, 1) === 'R') {
    echo 3;
} elseif (substr($s, 0, 1) === 'R' && substr($s, 1, 1) === 'R' && substr($s, 2, 1) !== 'R') {
    echo 2;
} elseif (substr($s, 0, 1) !== 'R' && substr($s, 1, 1) === 'R' && substr($s, 2, 1) === 'R') {
    echo 2;
} elseif (substr($s, 0, 1) === 'R' || substr($s, 1, 1) === 'R' || substr($s, 2, 1) === 'R') {
    echo 1;
} else {
    echo 0;
}
echo PHP_EOL;


Measured memory_bytes: 16224
#include<stdio.h>
#include<stdlib.h>
#define SIZE 200
#define L 20
int index=0;
int stack[SIZE];

void push(int n){
	stack[index++]=n;
}

int pop(){
	return stack[--index];
}

int main(void){
	//index=0;
	char op[L],dammy;
	
	while(scanf("%s",op)!=EOF){
		//scanf("%c",&dammy);
		if('0'<=op[0] && op[0]<='9'){
			push(atoi(op));
		}else{
			int b=pop();
			int a=pop();
			switch(op[0]){
				case '+':
					push(a+b);
					break;
				case '-':
					push(a-b);
					break;
				case '*':
					push(a*b);
					break;
				default:
					break;
			}
		}
	}
	printf("%d\n",pop());
	return 0;
}

Measured memory_bytes: 1748
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int a[100000];
int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    lp(i,100000){
      a[i]=0;
    }
    lp(i,n){
      int start=0;
      int memo=0;
      char x,y,z;
      cin>>x>>y>>z;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo*3600;
      memo=0;
      cin>>x>>y>>z;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo*60;
      memo=0;
      cin>>x>>y;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo;
      a[start]++;
      start=0;
      memo=0;
      cin>>x>>y>>z;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo*3600;
      memo=0;
      cin>>x>>y>>z;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo*60;
      memo=0;
      cin>>x>>y;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo;
      a[start]--;
    }
    int maxs=0;
    for(int i=1;i<90000;i++){
      a[i]+=a[i-1];
      maxs=max(maxs,a[i]);
    }
    cout<<maxs<<endl;
  }
  return 0;
}



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

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;++i){
        cin>>A[i];
    }
    
    vector<int> rev(N);
    for(int i=0;i<N;++i)rev[A[i]-1] = i+1;
    for(int i=0;i<N;++i)cout<<rev[i]<<" ";
    
    cout<<endl;
    
    return 0;
}

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

int main() {
    vector <int> a, b;
    int in;
    cin >> in; a = vector <int> (in);
    cin >> in; b = vector <int> (in);
    rep (i, a.size()) cin >> a[i];
    rep (i, b.size()) cin >> b[i];

    int ans = 0;
    for (int i = 0; i < b.size(); i++) {
        int cnt = 0, preA = -1;
        rep (j, a.size()) {
            if (b[i] == a[j]) {
                preA = j;
                cnt = 1;
                break;
            }
        }
        if (preA == -1) continue;
        int tmpi = i;
        i++;
        for (int j = preA + 1; j < a.size() && i < b.size();j++) {
            if (b[i] == a[j]) {
                i++;
                cnt++;
            }
        }
        ans = max(ans, cnt);
        i = tmpi;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3136
n, m = map(int, input().split())
pss = [input().split() for _ in range(m)]

import array; ### print(array.typecodes) ###
wacounts = array.array("l", [0] * (n+1))
acflags = array.array("b", [0] * (n+1))

for pi, si in pss:
    pi = int(pi)
    if acflags[pi] == 0:
        if si == "WA": wacounts[pi] += 1
        if si == "AC": acflags[pi] = 1
    ### print(pi, si, wacounts, acflags) ###

print(acflags.count(1), end=" ")
print(sum(x*y for x,y in zip(wacounts, acflags)))

Measured memory_bytes: 33780
#include <stdio.h>
int main(void)
{
    int S,h,m,s;
    scanf("%d\n",&S);
    h=(S-S%3600)/3600;
    m=((S-h*3600)-((S-h*3600)%60))/60;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int n, k = 2;
int dp[(int)1e5+10];
int a[(int)1e5+10];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n/* >> k*/;
	for(int i = 1; i <= n; cin >> a[i++]);
	for(int i = 0; i <= n; ++i) dp[i] = 1e9; 
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= k; ++j)
			if(j <= i) dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
	cout << dp[n];
	return 0;
}

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

int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(a!=7 && a!=5){
		cout<<"NO"<<endl;
		return 0;
	}
	if(b!=7 && b!=5){
		cout<<"NO"<<endl;
		return 0;
	}
	if(c!=7 && c!=5){
		cout<<"NO"<<endl;
		return 0;
	}

	if(a+b+c==17){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


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

int main() {
  int K, T;
  cin >> K >> T;
  vector<int> a(T);
  for(int t = 0; t < T; ++t) {
    cin >> a[t];
  }
  if(T == 1) {
    cout << K - 1 << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  int maxs = a.back();
  int rest = accumulate(a.begin(), a.end() - 1, 0);
  int ans = max(0, maxs - rest - 1);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a=1,b=1;
        while(true){
            a=sc.nextInt();
            b=sc.nextInt();
            if(a==0) break;
            for(int i=1;i<=a;i++){
                for(int j=1;j<=b;j++){
                  	if((i+j)%2==0){
                    	System.out.print("#");
                    }else if((i+j)%2==1){
                     	System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
        sc.close();
    }
}


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

typedef struct {
    char city[20];
    int no;
    int rank;
} Rest;

int cmp(const void *a, const void *b) {
    if (
        strcmp(
            (*(Rest *)a).city, (*(Rest *)b).city
        ) != 0
    )
        return strcmp((*(Rest *)a).city, (*(Rest *)b).city  );
    return (*(Rest *)b).rank - (*(Rest *)a).rank;
}

int main() {
    int n, i;
    Rest res[105], t;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %d", &t.city, &t.rank);
        t.no = i+1;
        res[i] = t;
    }
    
    qsort(res, n, sizeof(Rest), cmp);
    
    for (i = 0; i < n; i++)
        printf("%d\n", res[i].no);
    
    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
N = int(input())
P = defaultdict(int)
for i in range(N):
  P[input()] += 1
m = max(P.values())
E = []
for k, v in P.items():
  if v == m:
    E.append(k)
E.sort()
for e in E:
  print(e)

Measured memory_bytes: 32472
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fac[n] * finv[r] * finv[n-r] % p

def perm(n,r,p):
  if (r < 0) or (n < r):
    return 0
  return fac[n]*finv[n-r]%p

N = 5*pow(10,5)+100
MOD = pow(10,9)+7

fac = [-1]*(N+1); fac[0] = 1; fac[1] = 1 #階乗
finv = [-1]*(N+1); finv[0] = 1; finv[1] = 1 #階乗の逆元
inv = [-1]*(N+1); inv[0] = 0; inv[1] = 1 #逆元
for i in range(2,N+1):
  fac[i] = fac[i-1]*i%MOD
  inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
  finv[i] = finv[i-1]*inv[i]%MOD

n,m = map(int,input().split())

All = perm(m,n,MOD)**2
ans = All
for k in range(1,m+1):
  temp = cmb(n,k,MOD)*pow(-1,k-1)*perm(m,k,MOD)*(perm(m-k,n-k,MOD)**2)
  #print(temp)
  ans = (ans-temp)%MOD
print(ans)



Measured memory_bytes: 99600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int result = 0;
		for(int i = 1; i <= 5; i++) {
			int tmp = sc.nextInt();
			if(tmp == 0) result = i;
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 35704
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int A, B, K;
  cin >> A >> B >> K;
  int i;
  for(i = A; i <= min(A + K - 1, B); i++) cout << i << endl;
  for(i = max(i, B - K + 1); i <= B; i++) cout << i << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int seat[100000] = {};
int seat_num;

int listen(void) {
  string s;
  cin >> s;

  if (s == "Male") {
    return 1;
  } else if (s == "Female") {
    return 2;
  } else {
    return 0;
  }
}

void send(int seat_index) {
  cout << seat_index << endl;
}

void search(int depth, int start, int end) {
  if (depth > 21) {
    // fail
    return;
  }

  int center = (end + start + 1) / 2;
  send(center);
  seat[center] = listen();

  if (seat[center] == 0) {
    // success
    return;
  }

  if (center % 2 == start % 2) {
    if (seat[start] == seat[center]) {
      // 偶奇が一致していて、同性が座ってる場合には、後半部分に確実に空席があると判断できる。
      search(depth + 1, center, end);
    } else {
      search(depth + 1, start, center - 1);
    }
  } else {
    if (seat[start] == seat[center]) {
      // 偶奇不一致で、異性が座ってる場合には、前半部分に少なくとも1つは空席が存在
      search(depth + 1, start, center - 1);
    } else {
      search(depth + 1, center, end);
    }
  }
}

int main(void) {
  cin >> seat_num;
  send(0);
  seat[0] = listen();

  if (seat[0] == 0) {
    // lucky :)
    return 0;
  } else {
    search(1, 0, seat_num - 1);
  }

}


Measured memory_bytes: 852
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 2000000 + 1000;
const int MOD = 1000000000 + 7;

int fpow(int x, int p)
{
	int ret = 1;
	for(; p; p >>= 1, x = (long long)x * x % MOD)
		if(p & 1)
			ret = (long long)ret * x % MOD;
	return ret;
}

int inv(int x)
{
	return fpow(x, MOD - 2);
}

int fac[MAXN], fac_inv[MAXN];

void init()
{
	fac[0] = 1;
	for(int i = 1; i < MAXN; i++)
		fac[i] = (long long)fac[i - 1] * i % MOD;
	fac_inv[MAXN - 1] = inv(fac[MAXN - 1]);
	for(int i = MAXN - 2; i >= 0; i--)
		fac_inv[i] = (long long)fac_inv[i + 1] * (i + 1) % MOD;
}

int get_c(int n, int m)
{
	if(n < 0 || m < 0 || n < m)
		return 0;
	return (long long)fac[n] * fac_inv[m] % MOD * fac_inv[n - m] % MOD;
}

int get_f(int x, int y)
{
	return get_c(x + y, x);
}

int X[10], Y[10];

int calc0(int x, int y)
{
	int ret = 0;
	ret = (ret + get_f(x - X[0] + 1, y - Y[0] + 1)) % MOD;
	ret = (ret - get_f(x - X[0] + 1, y - Y[1])) % MOD;
	ret = (ret - get_f(x - X[1], y - Y[0] + 1)) % MOD;
	ret = (ret + get_f(x - X[1], y - Y[1])) % MOD;
	return (ret + MOD) % MOD;
}

int calc2(int x, int y)
{
	int ret = 0;
	ret = (ret + get_f(X[5] - x + 1, Y[5] - y + 1)) % MOD;
	ret = (ret - get_f(X[5] - x + 1, Y[4] - y)) % MOD;
	ret = (ret - get_f(X[4] - x, Y[5] - y + 1)) % MOD;
	ret = (ret + get_f(X[4] - x, Y[4] - y)) % MOD;
	return (ret + MOD) % MOD;
}

void solve()
{
	int ans = 0;
	// for(int i = X[2]; i <= X[3]; i++)
	// 	for(int j = Y[2]; j <= Y[3]; j++)
	// 		ans = (ans + (long long)calc0(i, j) * calc2(i, j)) % MOD;

	for(int i = X[2]; i <= X[3]; i++)
	{
		ans = (ans + (long long)calc0(i, Y[2] - 1) * calc2(i, Y[2]) % MOD * (MOD - (i + Y[2]))) % MOD;
		ans = (ans + (long long)calc0(i, Y[3]) * calc2(i, Y[3] + 1) % MOD * (i + Y[3] + 1)) % MOD;
	}
	for(int i = Y[2]; i <= Y[3]; i++)
	{
		ans = (ans + (long long)calc0(X[2] - 1, i) * calc2(X[2], i) % MOD * (MOD - (i + X[2]))) % MOD;
		ans = (ans + (long long)calc0(X[3], i) * calc2(X[3] + 1, i) % MOD * (i + X[3] + 1)) % MOD;
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	init();
	for(int i = 0; i <= 5; i++)
		cin >> X[i];
	for(int i = 0; i <= 5; i++)
		cin >> Y[i];
	solve();


	return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[1] << s3[2] << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, Integer> map1 = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> map2 = new HashMap<Integer, Integer>();
        map1.put(0,0);
        map2.put(0,0);
        for(int i = 0; i<n/2; i++) {
            int odd = sc.nextInt();
            int even = sc.nextInt();
            if(map1.containsKey(odd) ==  false) map1.put(odd, 1);
            else map1.put(odd, map1.get(odd)+1);

            if(map2.containsKey(even) ==  false) map2.put(even, 1);
            else map2.put(even, map2.get(even)+1);
        }

        int v1 = 0;
        int v2 = 0;
        int a1 = 0;
        int a2 = 0;
        int b1 = 0;
        int b2 = 0;

        for(Integer key: map1.keySet()) {
            int now = map1.get(key);
            if(now>=v1) {
                a2 = a1;
                a1 = key;
                v1 = now;
            }else if(now>=map1.get(a2)){
                a2 = key;
            }
        }

        for(Integer key: map2.keySet()) {
            int now = map2.get(key);
            if(now>=v2) {
                b2 = b1;
                b1 = key;
                v2 = now;
            }else if(now>=map2.get(b2)){
                b2 = key;
            }
        }

        if(a1!=b1) {
//            System.out.println(a1+" " +b1);
//            System.out.println(a2+" " +b2);
            int cnt = 0;
           for(Integer key : map1.keySet()) {
               if (map1.size()==1) break;
               if (key!=a1) cnt += map1.get(key);
           }
            //System.out.println(cnt);

            for(Integer key : map2.keySet()) {
                if (map2.size()==1) break;
                if (key!=b1) cnt += map2.get(key);
            }
            System.out.println(cnt);
            return;
        }

        if(a1==b1) {
//            System.out.println(a1+" " +b1);
//            System.out.println(a2+" " +b2);
            if(a2==0 && b2 == 0) {
                System.out.println(n/2);
                return;
            }
            int cnt = 0;
            int cnt2 = 0;
            for(Integer key : map1.keySet()) {
                if (key!=a1) cnt += map1.get(key);
                if (key!=a2 && a2!=0) cnt2 += map1.get(key);
            }
            for(Integer key : map2.keySet()) {
                if (key!=b2 && b2!=0) cnt += map2.get(key);
                if (key!=b1) cnt2 += map2.get(key);
            }
            System.out.println(Math.min(cnt,cnt2));
            return;
        }

    }
}


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

int main() {
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int num[3]={0,0,0};
  int i=0;
  while(1) {
    if(i==0&&num[0]==s[0].size()) {
      cout << "A" << endl;
      return 0;
    }
    if(i==1&&num[1]==s[1].size()) {
      cout << "B" << endl;
      return 0;
    }
    if(i==2&&num[2]==s[2].size()) {
      cout << "C" << endl;
      return 0;
    }
    i=s[i][num[i]++]-'a';
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
 
LL gcd(LL a,LL b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    int N;
    cin>>N;
    LL T[101];
    REP(i,N){
        cin>>T[i];
    }
    sort(T,T+N,greater<LL>());
    LL res=1;
    REP(i,N){
        if(res%T[i]!=0){
            res*=(T[i]/gcd(T[i],res));
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N,M;
bool A[55][55];
bool B[55][55];

int main(){
	scanf("%d%d" , &N , &M);
	repp(i,0,N){
		repp(j,0,N){
			char c;
			scanf(" %c" , &c);
			A[i][j] = c == '#';
		}
	}
	repp(i,0,M){
		repp(j,0,M){
			char c;
			scanf(" %c" , &c);
			B[i][j] = c == '#';
		}
	}
	repp(i,0,N-M+1){
		repp(j,0,N-M+1){
			repp(x,0,M){
				repp(y,0,M){
					if(A[i+x][j+y]^B[x][y]){
						x = y = M;
						break;
					}
					if(x+1==M&&y+1==M){
						printf("Yes\n");
						return 0;
					}
				}
			}
		}
	}
	printf("No\n");
	return 0;
}


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

int main() {
	// your code goes here
	int W , H, x, y ,r ;
	cin  >> W >> H >> x >> y >> r;
	
	if ((0 <= x-r)&&( x+r <= W)&&(0 <= y-r)&&(y+r<=H)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    char before = S[0];
    int cnt = 0;
    for(int i=0;i<S.size();i++){
        if(before != S[i]){
            cnt++;
        }
        before = S[i];
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fort(i,n) for (int i = 1; i <= n; i++)
#define ll long long
#define pi pair<int,int>
#define sz size()
#define er erase
#define fr first
#define sc second
using namespace std;

int n,t,x;
pi p[105];

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> t;
    fort(i,n)
        cin >> p[i].sc >> p[i].fr;
    sort (p+1,p+n+1);
    if (p[1].fr>t)
    {
        cout << "TLE";
        return 0;
    }
    x=p[1].sc;
    fort(i,n)
        if (p[i].fr<=t) x=min(x,p[i].sc);
    cout << x;
}


Measured memory_bytes: 256
n=int(input())
s=input()

wlist=[0 for i in range(n)]
blist=[0 for i in range(n)]

wnum=0
bnum=0

for i in range(n):
  if s[i]=='.':
    wnum+=1
  else:
    bnum+=1
  wlist[i]=wnum
  blist[i]=bnum
#print(wlist,blist)

ans=float('inf')  
for i in range(n):
  ans=min(ans,wlist[-1]-wlist[i]+blist[i])
  
ans=min(ans,wlist[-1],blist[-1])

print(ans)


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

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

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

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

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    string s;  cin >> s;
    cout << ((s == "ABC") ? "ARC" : "ABC") << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);
ll add[N];
bool used[N];
ll res[N];
vector<int> g[N];
void bfs(int v){
	queue<int> q;
	q.push(v);
	used[v] = 1;
	res[v] = add[v];
	while(!q.empty()){
		int u = q.front();
		q.pop();
		res[u] = add[u];
		for(int to : g[u]){
			if(!used[to]){
				used[to] = 1;
				add[to] += add[u];
				q.push(to);
			}
		}
	}
}
void solve()
{	
	int n, q;
	cin >> n >> q;
	for(int i = 0; i < n - 1; ++i){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	for(int i = 0; i < q; ++i){
		ll p, x;
		cin >> p >> x;
		add[p] += x;
	}
	bfs(1);
	for(int i = 1; i <= n; ++i){
		cout << res[i] << " ";
	}
}
int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 40820
#include <bits/stdc++.h>
#include <vector>
#include<string>

using namespace std;

int main() {
  int a,b;
  int n,m;
  cin >> a >> b;
  n = b-a;
  for(int i=1;i<n;i++){
    m = m+i;
  }
  cout << m-a << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        // ここに処理を書く
        var sc = new Scanner();
        var set = new SortedSet<int>();
        int n = sc.NextInt();
        for (int i = 0; i < n; i++)
        {
            int a = sc.NextInt();
            if (set.Contains(a))
            {
                set.Remove(a);
            }
            else
            {
                set.Add(a);
            }
        }

        Console.WriteLine(set.Count);


    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 38576
#include <iostream>
#include <queue>
using namespace std;
const int INF = 100000000;
int g[201][201];
int r[9];
bool used[9];
int N,M,R,a,b,c, ans = INF;

void dfs(int dist, int past_town, int now_pos){
    if(past_town == R){
        if(ans > dist)  ans = dist;
        return;
    }
    else{
        for(int i = 1; i <= R; i++){
            if(!used[i]){
                used[i] = true;
                if(now_pos == -1)   dfs(0, past_town, r[i]);
                else    dfs(dist + g[now_pos][r[i]], past_town + 1, r[i]);
                used[i] = false;
            }
        }
    }
}

int main(){
    for(int i = 0; i < 9; i++) used[i] = false;
    for(int i = 0; i < 201; i++)
        for(int j = 0; j < 201; j++)    g[i][j] = INF;
    cin >> N >> M >> R;
    for(int i = 1; i <= R; i++)  cin >> r[i];
    for(int i = 1; i <= M; i++)  {
        cin >> a >> b >> c;
        g[a][b] = g[b][a] = c;
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            for(int k = 1; k <= N; k++){
                if(g[j][k] > g[j][i]+g[i][k])
                    g[j][k] = g[j][i]+g[i][k];
            }
        }
    }
    dfs(0, 1, -1);
    cout << ans << '\n';
}

Measured memory_bytes: 384
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
c1 = 0
c2 = 0
for i in range(0, x+1):
    if i in a:
        c1 += 1
for j in range(x, n+1):
    if j in a:
        c2 += 1
print(min(c1, c2))

Measured memory_bytes: 3064
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys


def solve(N: int, M: int):
    f = M % 2 == 0
    for i in range(M//2):
        print(f'{i+1} {M-i+f}')
    for i in range((M+1)//2):
        print(f'{M+i+1+f} {2*M-i+1}')


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69324
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n,a,b;
cin >> n >> a >> b;
int che = a+b-n;
if(che<0)che=0;
cout << min(a,b)<<" "<<che<<endl;
}
 


Measured memory_bytes: 256
import numpy as np

h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)

max_a = max(np_ab[:, 0])
dp = [0] * (h + max_a)

for i in range(1, h + max_a):
    dp[i] = min(dp[i - a] + b for a, b in ab)

print(dp[h])


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


using namespace std;

#define MAXN 200010

char s[MAXN];
char aux[MAXN];

int main() {
    int n, a, b, c, d;
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    scanf("%s", s+1);
    int i, j;
    int can_a=1, can_b=1;
    for (i=a+1; i<=c; i++) {
        if (s[i]=='#' && s[i-1]=='#') {
            can_a = 0;
        }
    }
    for (j=b+1; j<=d; j++) {
        if (s[j]=='#' && s[j-1]=='#') {
            can_b = 0;
        }
    }
    if (can_b==0 || can_a==0) {
        printf("No\n");
    }
    else {
        if (c<d) {
            printf("Yes\n");
        }
        else {
            int can = 0;
            for (i=b; i<=d; i++) {
                if (s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') {
                    can = 1;
                }
            }
            if (can==1) {
                printf("Yes\n");
            }
            else {
                printf("No\n");
            }
        }
    }
    return 0;
}








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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

int main() {
  // n: 亀の数
  // X - n: 鶴の数
  long long n = 0;

  char output[4] = "No";
  short X, Y;
  scanf("%hd%hd", &X, &Y);

  // 全部鶴のパターンからはじめ
  // 亀を一匹ずつ増やと同時に鶴を一匹ずつ減らす
  // 鶴が0匹になるまで続ける
  while(X - n >= 0) {
    // 鶴と亀の足を合計した数がYになったら終了
    if ((4 * n) + (2 * (X - n)) == Y) {
      strcpy(output, "Yes");
      break;
    }
    n += 1;
  }

  printf("%s\n", output);
  return 0;
}


Measured memory_bytes: 1660
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m,inc=1;
    int a,b,c;
    cin >> a >> b >> c;
    cout << (c/a)*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;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll pow(ll a, ll b){
	if(b == 0) return 1;
	if(b % 2 == 1) return a * pow(a, b - 1) % MOD;

	ll d = pow(a, b / 2) % MOD;
	return d * d % MOD;
}

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

	ll n;
	cin >> n;

	vector<ll> c(n);
	rep(i, n) cin >> c[i];
	sort(c.begin(), c.end());
	if(n == 1){
		cout << 2 * c[0] % MOD << endl;
		return 0;
	}

	ll ans = pow(2ll, n);

	ll x = 0;
	for(ll i = 0; i < n; i++){
		ll y = c[i];
		y *= pow(2ll, n - 2);
		y %= MOD;
		y *= n - i + 1;
		y %= MOD;
		
		x += y;
		x %= MOD;
	}

	ans *= x;
	ans %= MOD;

	cout << ans << endl;
}


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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    for (int i = 100; i >= 1; --i) {
        if(a%i==0&&b%i==0)--k;
        if(k==0){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
queue<long>Q;
long lunlun(int j){ // j回目操作
  long this_front = Q.front();
  Q.pop();
  int x = this_front % 10;
  if (x != 0){
    Q.push(this_front * 10 + x - 1);
  }
  Q.push(this_front * 10 + x);
  if (x != 9){
    Q.push(this_front * 10 + x + 1);
  }
  return this_front;
}
int main(){
  int k;
  cin >> k;

  long this_num = 0;
  for (int i=1;i<=9;i++){ //初期状態
    Q.push(i);
  }
  for (int i=1;i<=k;i++){
    this_num = lunlun(i);
  }

  cout << this_num << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

int a, p;

void in() {
	scanf("%d%d", &a, &p);
}

void solve() {
	int x = p + a*3;
	cout << x/2;
}

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


Measured memory_bytes: 256
int main()
{
  char s[101];
  char t[101];
  scanf("%s %s", &s, &t);
  int i;
  for (i = 0; t[i] != '\0'; i++)
    printf("%c", t[i]);
  for (i = 0; s[i] != '\0'; i++)
    printf("%c", s[i]);
}

Measured memory_bytes: 128
a,b=map(int,input().split())
alllist=[]
goukei=1
for i in range(a):
    tmplist=list(map(int,input().split()))
    alllist.append(tmplist)

alllist2=sorted(alllist)
for i in range(a):
    goukei=alllist2[i][1]+goukei
    if goukei>b:
        owari=alllist2[i][0]
        break
    else:
        pass

print(owari)

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

int main() {
    int a, b;
    cin >> a >> b;
    int sum = 0;
    int c = b - a;
    
    for (int i = 1; i <= c; i++) {
        sum += i;
    }

    cout << sum - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e12+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int i,n,ans=0;cin>>n;
	vector<int>a(n);
	for(auto &it:a){cin>>it;}
	vector<int>b=a;
	sort(b.begin(),b.end());
	for(i=0;i<b.size();i++){
		if((2*n+(lower_bound(b.begin(),b.end(),a[i])-b.begin())-i)%2==1){ans++;}
	}
	cout<<ans/2<<endl;
	return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll H, W;
vector<VL> a;
struct ope {
    ll y1, x1, y2, x2;
};
vector<ope> opes;

signed main() {
    cin >> H >> W;
    a.resize(H);
    ll sum = 0;
    REP(i, H) REP(j, W) { a[i].emplace_back(IN()); }
    REP(i, H) REP(j, W) {
        if(i < H - 1 && a[i][j] % 2) {
            a[i + 1][j]++;
            opes.push_back({i + 1, j + 1, i + 2, j + 1});
        }
        if(i == H - 1 && j < W - 1 && a[i][j] % 2) {
            a[i][j + 1]++;
            opes.push_back({i + 1, j + 1, i + 1, j + 2});
        }
    }
    cout << opes.size() << "\n";
    FOREACH(o, opes) {
        cout << o.y1 << " " << o.x1 << " " << o.y2 << " " << o.x2 << "\n";
    }
}

Measured memory_bytes: 8304
#include <bits/stdc++.h>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define pb push_back
  #define f first
  #define se second
  
  using namespace std;
  int main()
  {
    std::ios::sync_with_stdio(false);
    ll n,W;
    cin>>n>>W;
    vll v(101),w(101);
    vector<vll> dp(101,vll(100001));

    v[0]=inf; w[0]=inf;

    for (ll i = 0; i < n+1; ++i)
    {
      for (ll j = 0; j < 100001; ++j)
      {
        dp[i][j]=inf;
      }
    }
    for (ll i = 1; i < n+1; ++i){
      cin>>w[i]>>v[i];
       // dp[0][i] will be infinite because it is not possible. We have already initialized it inf.
    }    
    // dp[1][0]=0;
    dp[0][0]=0;
    // dp[1][v[1]]=w[1]; // here I was making error. I was using v[0] & w[0] which is incorrect becuase 
                      // I'am using 1 based indexing.
    
    for (ll i = 1; i < n+1; ++i)
    {
      dp[i][0]=0;
      
      for (ll j = 0; j < 100001; ++j)
      {
        dp[i][j]=dp[i-1][j];

        if(j-v[i]>=0){ // maxm weight can be 0.
          dp[i][j]=min(dp[i][j],w[i]+dp[i-1][j-v[i]]);
        }
      }
    }

    for(ll i=100000; i>=0; i--){ // max element can be 0
      if(dp[n][i]<=W){
        cout<<i; break;
      }
    }

    return 0;
  }

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

Measured memory_bytes: 3120
def f():
    return raw_input()
def f2():
    return raw_input().split()

dic = {}
n = int(f())
for i in range(n):
    c1, c2 = f2()
    if c1 == 'insert':
        dic[c2] = 548
    elif c1 == 'find':
        if dic.has_key(c2):
            print 'yes'
        else:
            print 'no'

Measured memory_bytes: 64700