akhauriyash/Code-Regression huggingface dataset:
#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 n;
  cin >> n;
  if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
    cout << "hon\n";
  else if (n % 10 == 3)
    cout << "bon\n";
  else
    cout << "pon\n";
  return 0;
}

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

const int MAX_N = 1e5 + 5;
int n, ind;
int Arr[MAX_N];

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

	for (int i = 0; i < n; i++)
		cin >> Arr[i];

	if (n == 1) {
		if (Arr[0] % 2 == 1)
			cout << "Second\n";
		else
			cout << "First\n"; 
			
		return 0;
	}
	
	sort(Arr, Arr + n);
	reverse(Arr, Arr + n);
	
	if (Arr[0] == 1) {
		if (n % 2 == 1)
			cout << "Second\n";
		else
			cout << "First\n"; 
			
		return 0;
	}
	
	ind = n;
	int h = Arr[0];
	for (int i = 1; i < n; i++) {
		if (Arr[i - 1] >= i && Arr[i] <= i) {
			ind = i;
			break;
		}
	}
	
	ind--;
		
//	cout << ind << "\n";

	if ((Arr[ind] - ind) % 2 == 0) {
		cout << "First\n";
		return 0;
	}
	
	int cnt = 0;
	int tmp = ind + 1;
	while (tmp < n && Arr[tmp] == ind + 1) {
		tmp++;
		cnt++;
	}
	
	if (cnt % 2 == 1) {
		cout << "First\n";
		return 0;
	}
	
	cout << "Second\n";
	return 0;
}

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

int main(void){
    int i, N, V, j, k;
    int *In;
    
    scanf("%d",&N);
    In = (int*)malloc(sizeof(int)*N);
      for(k=0 ; k<N ; k++){
            scanf("%d",&In[k]);
        }
  printf("%d",In[0]);
             for(k=1 ; k<N ; k++){
            printf(" %d",In[k]);
        }
        printf("\n");
  
    
    for(i=1 ; i<N ; i++){
        V=In[i];
        j=i-1;
        while(j>=0 && In[j]>V){
            In[j+1] = In[j];
            j--;
            In[j+1]=V;
        }
        printf("%d",In[0]);
        for(k=1 ; k<N ; k++){
            printf(" %d",In[k]);
        }
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int a[202];
int main() {
    int n = read(), l = read(), sum = 0; int diff = 0x7f7f7f7f, Ans = 0;
    for (reg int i = 1; i <= n; i++) a[i] = l + i - 1, sum += a[i];
    sort(a + 1, a + n + 1);
    for (reg int i = 1; i <= n; i++) {
        reg int res = sum - a[i];
        if (abs(sum - res) < diff) diff = abs(sum - res), Ans = res;
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long int gcd(long long int a,long long int b){
  long long int i;
  while(a!=0 && b!=0){
    i=b;
    b=a%b;
    a=i;
  }
  return a;
}

long long int lcm(long long a,long long b){
  a=a/gcd(a,b);
  return a*b;
}

int main(){
  int n,i;
  scanf("%d",&n);
  long long t[n+1];
  for(i=0;i<n;i++)
    scanf("%lld",&t[i]);
  for(i=1;i<n;i++)
    t[i]=lcm(t[i],t[i-1]);
  printf("%lld\n",t[n-1]);
  return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define INF 1e8
double pi = 2 * acos(0.0);
#define ALL(x) x.begin() , x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())


int main()
{
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1)
    {
        cout<<"1";
    }
    else if(h%2==1&&w%2==1)
    {
        cout<<(h*w)/2LL+1LL;
    }
    else
    {
        cout<<(h*w)/2LL;
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

struct Vertex {
  int64_t distance{INT64_MAX};
  vector<pair<int64_t, int64_t>> edges;
};

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

  int64_t V, E, r;
  cin >> V >> E >> r;
  vector<Vertex> vertices(V);
  for (int64_t i = 0; i < E; ++i) {
    int64_t start, to, weight;
    cin >> start >> to >> weight;
    vertices[start].edges.push_back(pair<int64_t, int64_t>(weight, to));
  }

  priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>, greater<pair<int64_t, int64_t>>> q;
  q.push(pair<int64_t, int64_t>(0, r));
  vertices[r].distance = 0;
  while (q.size() > 0) {
    pair<int64_t, int64_t> t = q.top();
    q.pop();
    const int64_t c_distance = t.first;
    const int64_t c_index = t.second;
    for (const pair<int64_t, int64_t> edge : vertices[c_index].edges) {
      const int64_t weight = edge.first;
      const int64_t to = edge.second;
      const int64_t temp_distance = c_distance + weight;
      if (temp_distance < vertices[to].distance) {
        vertices[to].distance = temp_distance;
        q.push(pair<int64_t, int64_t>(temp_distance, to));
      }
    }
  }
  for (int64_t i = 0; i < V; ++i) {
    if (vertices[i].distance == INT64_MAX) {
      cout << "INF" << endl;
    } else {
      cout << vertices[i].distance << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 19316
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

## UnionFind

N, M = mi()
memo = []
rel = [[] for i in range(N)]
#d = dp2(float('inf'), N, N)

for i in range(M):
    s, t = mi()
    s, t = s-1, t-1
    memo.append((s, t))
    rel[s].append(t)
    rel[t].append(s)
    #d[s][t] = d[t][s] = 1
#print(d)

def dfs(v):
    #print(v, used)
    for nv in rel[v]:
    #for nv in range(N):
        if not used[nv]:
        #if d[v][nv] != float('inf') and not used[nv]:
            used[nv] = 1
            dfs(nv)
            if sum(used) == N:
                global flag
                flag = True
                return
            #used[nv] = 0

cnt = M
for x in range(M):
    s, t = memo[x][0], memo[x][1]
    rel[s].remove(t)
    rel[t].remove(s)
    #print(rel)
    #print(s, t)
    #d[s][t] = d[t][s] = float('inf')
    #print(d)
    for i in range(N):
        #print(x, i)
        flag = 0
        used = [0]*N
        used[i] = 1
        dfs(i)
        #print(flag)
        if flag:
            cnt -= 1
            break
    rel[s].append(t)
    rel[t].append(s)
    #d[s][t] = d[t][s] = 1

print(cnt)

Measured memory_bytes: 3188
N=int(input())
A=[int(i) for i in input().split()]
SumOdd=[0 for i in range(N+1)]
SumEven=[0 for i in range(N+1)]
for i in range(N):
    if i%2==1:
        SumOdd[i+1]=SumOdd[i]+A[i]
        SumEven[i+1]=SumEven[i]
    else:
        SumOdd[i+1]=SumOdd[i]
        SumEven[i+1]=SumEven[i]+A[i]
Sum=sum(A)
ans=[0 for i in range(N)]
for i in range(N):
    if i%2==0:
        ans[i]=Sum-2*(SumOdd[N]-SumOdd[i]+SumEven[i])
    else:
    	ans[i]=Sum-2*(SumEven[N]-SumEven[i]+SumOdd[i])
print(" ".join([str(i) for i in ans]))

Measured memory_bytes: 78180
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt();
		int B = scn.nextInt();
		int C = scn.nextInt();
		System.out.println((A==B && A==C)?"Yes":"No");
	}

}


Measured memory_bytes: 24020
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    long long a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    c+=b;
    if(c>a) printf("%lld",c-a);
    else printf("0");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
p = list(map(int, input().split()))

num = 0
for i in range(1, len(p) - 1):
    left = p[i - 1]
    center = p[i]
    right = p[i + 1]

    if (left < center < right) or (right < center < left):
        num += 1

print(num)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;



int main() {
    long long X;
    cin >> X;

    long long y=100;
    long long cnt = 0;
    while(y<X){
        y += y/100;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
multiset<int> s;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int q;cin>>q;while(q--){
        int op=0;cin>>op;
        if(op==3){
            int l,r;
            cin>>l>>r;
            auto ed=s.upper_bound(r);
            for(auto it=s.lower_bound(l);it!=ed;it++)cout<<*it<<endl;
        }else{
            int x=0;
            cin>>x;
            if(op==0){s.insert(x);cout<<s.size()<<endl;}
            if(op==1){cout<<s.count(x)<<endl;}
            if(op==2){s.erase(x);}
        }
        
    }
}
/* 

- insert(xx): Insert xx to SS and report the number of elements in SS after the operation.
- find(xx): Report the number of xx in SS.
- delete(xx): Delete all xx from SS.
- dump(LL, RR): Print elements xx in SS such that L≤x≤RL≤x≤R
9
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 4
3 2 4
 */


Measured memory_bytes: 12492
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
vector<pii> g[100005];
int res[100005];
int ans = 0;
void dfs(int u, int p, int c){
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i].first, idx = g[u][i].second;
        if(v == p) continue;
        c = (c+1)%ans;
        res[idx] = c;
        dfs(v, u, c);
    }
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n-1;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(pii(b, i));
        g[b].push_back(pii(a, i));
    }
    for(int i=1;i<=n;i++) ans = max(ans, (int)g[i].size());
    dfs(1, 0, 0);
    printf("%d\n", ans);
    for(int i=1;i<=n-1;i++) printf("%d\n", res[i]+1);
}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N, M, Vo, P;
	cin >> N >> M >> Vo >> P;

	V<int> A(N);
	rep(i, N) cin >> A[i];
	sort(ALL(A));
	reverse(ALL(A));

	auto ok = [&](int x) {
		if (x < P) return true;
		if (A[P-1] > A[x] + M) return false;
		if (N-1-x >= Vo-P) return true;

		int l = P-1;

		ll rem = (ll)(Vo-(N-(x-l))) * M;
		for (int i = l; i<x; ++i) {
			rem -= min<ll>(A[x]+M-A[i],rem);
		}
		return rem==0;
	};

	int lo = 0, hi = N;
	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		if (ok(m)) {
			lo = m;
		} else {
			hi = m;
		}
	}
	cout << (lo + 1) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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

int dp[3300][3300];
pair<pair<int, int>, bool> prevdp[3300][3300];
int main()
{
  string s, t;
  cin >> s >> t;
  REP(i, s.size()) {
    REP(j, t.size()) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
        prevdp[i + 1][j + 1] = MP(MP(i, j), true);
      } else {
        if (dp[i + 1][j] > dp[i][j + 1]) {
          dp[i + 1][j + 1] = dp[i + 1][j];
          prevdp[i + 1][j + 1] = MP(MP(i + 1, j), false);
        } else {
          dp[i + 1][j + 1] = dp[i][j + 1];
          prevdp[i + 1][j + 1] = MP(MP(i, j + 1), false);
        }
      }
    }
  }

  string ans = "";
  int i = s.size(), j = t.size();
  while (1) {
    bool flag = prevdp[i][j].SE;
    int ti = prevdp[i][j].FI.FI;
    int tj = prevdp[i][j].FI.SE;
    i = ti;
    j = tj;
    if (flag) ans += s[i];
    if (i == 0 || j == 0) break;
  }
  reverse(ALL(ans));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 157952
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return siz[root(x)];
    }
};

struct edge {
    int from, to, cost;
};

int kruskal(vector<edge> &edges, int V) {
    sort(edges.begin(), edges.end(), [](const edge &a, const edge &b) {
        return a.cost < b.cost;
    });
    UnionFind unionFind(V);
    int res = 0;
    for (edge &e: edges) {
        if (unionFind.unite(e.to, e.from)) {
            res += e.cost;
        }
    }
    return res;
}

signed main() {
  int N;
  cin >> N;
  
  // x y i
  vector<pair<pair<int, int>, int>> c(N);
  REP(i, N){
    int x, y;
    cin >> x >> y;
    c[i] = make_pair(make_pair(x, y), i);
  }

  vector<edge> graph;

  sort(ALL(c));
  REP(i, N-1){
    edge e;
    e.to   = c[i].second;
    e.from = c[i+1].second;
    e.cost = abs(c[i].first.first-c[i+1].first.first);
    graph.emplace_back(e);
  }
  sort(ALL(c),   // dai -> syou
      [](pair<pair<int, int>, int> const & l, pair<pair<int, int>, int> const &  r){
      return l.first.second > r.first.second;
      });
  REP(i, N-1){
    edge e;
    e.to   = c[i].second;
    e.from = c[i+1].second;
    e.cost = abs(c[i].first.second-c[i+1].first.second);
    graph.emplace_back(e);
  }

  cout << kruskal(graph, N) << endl;

  return 0;
}

Measured memory_bytes: 10864
import math
import itertools

INF = 10**9+7

n,t = map(int,input().split())
c = list(map(int,input().split()))

def solve():
	global n,t,c
	ans = 0
	for i in range(1,n):
		if(c[i]-c[i-1]<t):
			ans += c[i]-c[i-1]
		else:
			ans += t
	ans += t
	return ans

def sgn(n):
	if(n>0): return 1
	if(n<0): return -1
	return 0

print(solve())

Measured memory_bytes: 25208
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>

using namespace std;

int main(void){
  int prime[60000],i,j,x;

  for(i=0;i<60000;i++)
    prime[i]=0;
  prime[0]=1;
  prime[1]=1;

  
  for(i=2;i*i<60000;i++){
    if(prime[i]==0){
      for(j=i*2;j<60000;j+=i){
	prime[j]=1;
      }
    }
  }

  while(scanf("%d",&x)!=EOF){
    for(i=x-1;i>=2;i--){
      if(prime[i]==0){
	cout << i <<" ";
	break;
      }
    }
    
    for(i=x+1;i<60000;i++){
      if(prime[i]==0){
	cout << i << endl;
	break;
      } 
    }
  }
  return 0;
}

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

int S[200];
int top = 0;

void push(int x) {
  S[top++] = x;
}

int pop() {
  return S[--top];
}

int main() {
  string s;
  char c;
  int a, b;
  // cin >> s;
  //getline(cin, s);
  //int i=0;
  //cout << s << endl;


  //for (char& c: s) {
    //cout << "c: "<< c << endl;
  //while(c = s[i]){
  while(cin >> s){
    //cout << "s: " << s << endl;
    if (s=="+") {
      a = pop();
      b = pop();
      push(a+b);
      //cout << "\t" << a+b << " push " << endl;
    } else if (s=="-") {
      a = pop();
      b = pop();
      //cout << "\t" << a-b << " push " << ", a: "<< a << ", b: "<< b << endl;
      push(b-a);
    } else if (s=="*") {
      a = pop();
      b = pop();
      push(a*b);
      //cout << "\t" << a*b << " push " << endl;
    } else {
      int numA = 0;
	  numA=0;
      for(int i=0;i<(int)s.size();i++){
    numA*=10;
    numA+=s[i]-'0';
      }
      push(numA);
      //cout << "\t" << numA << " push " << endl;
    }
  }
  cout << pop() << endl;;
  return 0;
}


Measured memory_bytes: 3164
D = int(input())
c = list(map(int, input().split()))
S = 0
s = []
dec_s = [0] * D
open_event = []

for i in range(D):
  temp = list(map(int, input().split()))
  s.append(temp)

for s_sim in s:
  open_event.append(s_sim.index(max(s_sim)))

for num in open_event:
  print(num+1)

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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    ll x;

ll power(ll x, ll y) {
    if (y == 0) {
      return 1;
    }
    else {
      ll sq = power(x, y / 2);
      sq *= sq;

      if (y % 2 != 0) {

        sq *= x;
      }

      return sq;
    }
  }

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>x;
    for (int i=-1000; i<=1000; i++) {
        ll a = power(i,5);
        for (int j=-1000; j<=1000; j++) {
            ll b = power(j,5);
            if (a - b == x) {
                cout <<i <<" " <<j;
                return 0;
            }
        }
    }



    return 0;
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll a[3][3];
    ll aa[3][3];
    rep(i, 3) {
        rep(j, 3) {
            cin >> a[i][j];
            aa[i][j] = 0;
        }
    }
    ll n;
    cin >> n;
    ll b[n];
    rep(i, n) {
        cin >> b[i];
        rep(j, 3) {
            rep(k, 3) {
                if ( b[i] == a[j][k] ) {
                    aa[j][k] = 1;
                }
            }
        }
    }
    int ans = 0;
    int num = 0;
    int num2 = 0;
    if ( (aa[0][0] == 1 && aa[1][1] == 1 && aa[2][2] == 1)
        || (aa[0][2] == 1&& aa[1][1] == 1 && aa[2][0] == 1) ) {
        ans = 1;
    } else {
        rep(i, 3) {
            rep(j, 3) {
                if ( aa[i][j] == 1 ) {
                    num++;
                }
                if ( aa[j][i] == 1 ) {
                    num2++;
                }
            }
            if ( num == 3 || num2 == 3 ) {
                ans = 1;
                break;
            }
            num = 0;
            num2 = 0;
        }
    }

    if ( ans ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int i;

  /* 文字 */
  char moji;

  /* 文字を入力 */
  scanf("%c", &moji);

  /* アルファベットの小文字か大文字かを判定 */
  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else if((moji>= 'A') && (moji<='Z')){
    printf("A\n");
  }
  return 0;
}

Measured memory_bytes: 1588
#include<bits/stdc++.h>
using namespace std;
int main(){
  char X,Y;
  cin>>X>>Y;
  int x=X-'A';
  int y=Y-'A';
  if(x>y){
    cout<<">"<<endl;
  }
  else if(x<y){
    cout<<"<"<<endl;
  }
  else{
    cout<<"="<<endl;
  }
}


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

void Main()
{
  int N; cin >> N;
  vector<int> s(N);
  int sum = 0;
  int min_not_div_10 = 101;
  rep(i,N) {
    cin >> s[i]; 
    sum += s[i];
    if (s[i] % 10 != 0) min_not_div_10 = min(min_not_div_10, s[i]);
  }
  if (sum % 10 != 0) {cout << sum << endl;}
  else if (min_not_div_10 < 101) {cout << sum-min_not_div_10 << endl;}
  else cout << 0 << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
import io.StdIn.readLine
object Main extends App {
  val Array(x, a, b) = readLine.split(" ").map(_.toInt)
  println(solve(x, a, b))

  def solve(x: Int, a: Int, b: Int) = {
    if (a >= b) "delicious"
    else if ((b - a) <= x) "safe"
    else "dangerous"
  }
}


Measured memory_bytes: 25524
def input_li():
    return list(map(int, input().split()))

def input_int():
    return int(input())

N = input_int()
if N % 2 == 0:
    ans = 0
    N //= 2
    while N > 0:
        ans += N // 5
        N //= 5
    print(ans)
else:
    print(0)


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

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


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;

  int tmp = n % 1000;
  int ans = (1000 - tmp) % 1000;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include<string>
#include <algorithm>
#include<math.h>
#include<queue>
#include<stack>

typedef long long ll;

#define veci            vector<int>
#define vecs            vector<string>

#define vecpii          vector<pair<int,int>>
#define vecpis          vector<pair<int,string>>
#define vecpss          vector<pair<string,string>>
#define mkp             make_pair

#define vecvi(vv,n,m,l) vector<vector<int>> vv(n,veci(m,l))
                                                     // lで初期化
#define vecvs           vector<vector<string>>

using namespace std;

int main()
{
  vecs v(2);
  cin >> v[0];
  cin >> v[1];

  if (v[0].length() == v[1].length() - 1) {
    if (equal(v[0].begin(), v[0].end(), v[1].begin())) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  } else {
    cout << "No";
  }



  return (0);
}

Measured memory_bytes: 3596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()	
	{
		int N = Int32.Parse(Console.ReadLine());
		string[] args = Console.ReadLine().Split(' ');
		int gcd = Int32.Parse(args[0]);
		for(int i = 1; i < N; i++)
		{
			int A = Int32.Parse(args[i]);
			gcd = getGcd(gcd, A);
		}

		int ans = 0;
		int tmp = gcd;
		while(tmp % 2 == 0)
		{
			tmp /= 2;
			ans++;
		}
		Console.WriteLine(ans);
	}

	private static int getGcd(int x, int y)
	{
		return (y == 0) ? x : getGcd(y, x % y);
	}
}





Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
int main()
{
    char str1[1000];
    while(gets(str1)){
        char str2[1000];
        int i,j,w,len;
        scanf("%d",&w);
        len=strlen(str1);
    for(i=0,j=0;i<len;i=i+w,j++){
        str2[j]=str1[i];
    }

    for(i=0;i<j;i++)
        printf("%c",str2[i]);
        printf("\n");
    }
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	for (int i = 0; i < k; i++) {
		if (a + i > b) break;
		printf("%d\n", a + i);
	}
	for (int i = k - 1; i >= 0; i--) {
		if (b - i < a + k) continue;
		printf("%d\n", b - i);
	}
}

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

int main()
{
    int n, m, l, r, cnt = 0;
    vector<int> v;
    cin >> n >> m;
    v.resize(n + 2);
    for (int i = 0; i < n + 2; i++)
    {
        v[i] = 0;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> l;
        v[l] += 1;
        cin >> r;
        v[r + 1] += -1;
    }
    for (int i = 1; i < n + 2; i++)
    {
        v[i] += v[i - 1];
        if (v[i] == m)
            cnt++;
        // cout << i << ": " << v[i] << " += " << v[i - 1] << endl;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int x[214514];
double y[214514];
string z[214514];
int sum[214514];
signed main(){
	ic(n) ic(t)
	int ans=0;
	rep(1,i,n+1){
		rep(1,j,t+1){
			if(j%10>1&&j/10>1&&(j%10)*(j/10)==i){
				ans++;
			}
		}
	}
	c(ans)
}			

Measured memory_bytes: 2688
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		int N = sc.nextInt();
      	int L = sc.nextInt();
      	int aji[] = new int[N];
      	int sum = 0;
      	int min = L;
		
      	for(int i=1;i<=N;i++){
          aji[i-1] = L + i - 1;
          if(Math.abs(aji[i-1]) < Math.abs(min)){
            min = aji[i-1];
          }
          sum = sum + aji[i-1];
        }
      System.out.println(sum-min);
	}
}

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

public class Main {

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

	static int n;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			n = in.nextInt();
			out.println(calcFib(1, 1, 1));
		}
		static long calcFib(long a1, long a2, int count) {
			if (count >= n) return a2;
			long a3 = a1 + a2;
			return calcFib(a2, a3, ++count);
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

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

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

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

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

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

	}

}



Measured memory_bytes: 24408
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int x,id;
}a[200010];
int ans[200010];
bool cmp(node x,node y)
{
	return (x.x<y.x)||(x.x==y.x&&x.id<y.id);
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i].x),a[i].id=i;
	sort(a+1,a+1+n,cmp);
	for (int i=1;i<=n;i++)
	{
		if (i+i<=n) ans[a[i].id]=a[n/2+1].x;
		else ans[a[i].id]=a[n/2].x; 
	}
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
 } 

Measured memory_bytes: 4480
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_C
 */
#include <iostream>
#include <sstream>
#include <map>
#include <vector>
#include <utility>

using namespace std;

typedef vector<pair<char, int> > VPCI;

int
partition(VPCI &a, const int p, const int r)
{
    int x = a[r].second;
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (a[j].second <= x) {
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i + 1], a[r]);
    return i + 1;
}

void
quicksort(VPCI &a, const int p, const int r)
{
    if (p >= r) { return; }
    int q = partition(a, p, r);
    quicksort(a, p, q - 1);
    quicksort(a, q + 1, r);
}

void
checkstable(const VPCI &original, const VPCI &sorted)
{
    auto sit = sorted.begin();
    for (auto oit = original.begin(); oit != original.end(); oit++, sit++) {
        if (*oit != *sit) {
            cout << "Not stable" << endl;
            return;
        }
    }
    cout << "Stable" << endl;
}

int
main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n; cin.ignore();

    VPCI A(n);
    map<int, vector<char> > O;
    for (int i = 0; i < n; i++) {
        char M;
        int L;
        cin >> M >> L; cin.ignore();

        A[i] = make_pair(M, L);
        if (O.find(L) == O.end()) {
            vector<char> t(1);
            t[0] = M;
            O.emplace(L, t);
        } else {
            O.at(L).push_back(M);
        }
    }
    quicksort(A, 0, n - 1);

    VPCI S(n);
    int c = 0;
    for (auto& itk : O) {
        for (auto& itv : itk.second) {
            S[c++] = make_pair(itv, itk.first);
        }
    }

    checkstable(S, A);
    for (auto it : A) {
        cout << it.first << ' ' << it.second << endl;
    }

    return 0;
}

Measured memory_bytes: 6964
package main

import "fmt"

func main() {
	var a [3]int

	fmt.Scanf("%d %d %d", &a[0], &a[1], &a[2])

	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if a[i] < a[j] {
				a[i], a[j] = a[j],a[i]
			}
		}
	}
	fmt.Printf("%d %d %d\n", a[0], a[1], a[2])
}



Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

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

    string s[n];
    rep(i, n)
    {
        cin >> s[i];
    }
    int m;
    cin >> m;

    string t[m];
    rep(i, m)
    {
        cin >> t[i];
    }

    vector<string> vs(s, s + n);
    vector<string> vt(t, t + m);
    sort(vs.begin(), vs.end());
    sort(vt.begin(), vt.end());

    int cnt = 0;
    int max = 0;
    int jj = 0;
    string before = "\0";
    rep(i, n)
    {
        if (before != vs[i])
        {
            cnt = 0;
            rep2(j, jj, m)
            {
                jj = j;
                if (vs[i] == vt[j])
                    cnt--;
                else if (vs[i] <= vt[j])
                    break;
            }
        }
        cnt++;
        before = vs[i];
        chmax(max, cnt);
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int C[10004];
int A[20000006];
int B[20000006];

int main() {
    rep(i,10004) C[i]=0;
    int n;
    cin>>n;
    rep(i,n) {
        scanf("%d",A+i+1);
        C[A[i+1]]++;
    }
    rep(i,10003) C[i+1]+=C[i];
    rep(i,n+1) if(i) {
        B[C[A[i]]]=A[i];
        C[A[i]]--;
    }
    rep(i,n+1) if(i) {
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 17656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define inf INT_MAX
#define ninf INT_MIN
#define W(x) cout<<x<<endl
#define WW(x,y) cout<<x<<' '<<y<<endl;
#define in(x) cin>>x
#define int long long
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
//define oset tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 
template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}
struct Node{
    int first;int second;
    Node(int x,int y){
        this->first = x;
        this->second = y;
    }
};
struct comparator{
    bool operator()(const Node &a,const Node &b){
        int lena = a.second-a.first+1;
        int lenb = b.second-b.first+1;
        if(lena == lenb)return a.first<b.first;
        else return lena>lenb;
    }
};

signed main(){
    fastio();
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int ans = 60-m1;
    h1+=1;
    ans+=m2;
    ans+=(h2-h1)*60;
    cout<<max(0*1LL,ans-k)<<"\n";
}

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

const int N = 100010;

int a[N * 3], n;

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n * 3; ++ i){
		scanf("%d", &a[i]);
	}
	std::sort(a, a + 3 * n);
	long long ans = 0;
	for (int i = 3 * n - 2, cnt = 0; i && cnt < n; i -= 2){
		ans += a[i];
		++ cnt;
	}
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 1408
M=998244353;N=gets.to_i;v=$<.map{|e|Complex(*e.split.map(&:to_i))};h={};r=2**N%M-N-1;N.times{|i|(i+1...N).map{|j|h[x=[i,j]]&&next;(j+1...N).map{|k|((v[j]-v[k]).conj*(v[i]-v[k])).imag.abs<1e-9&&x<<k};x.size.times{|a|(a+1...x.size).map{|b|r=(r-2**(b+~a))%M;h[[x[a],x[b]]]=1}}}};p r

Measured memory_bytes: 5116
N = int(input())
for n in range(1, 3501):
    for w in range(1, 3501):
        denominator = 4*n*w - w*N - n*N
        numerator = n*w*N
        if denominator != 0 and numerator%denominator == 0:
            h = numerator // denominator
            if 0 < h <= 3500:
                print(h, n, w)
                break
    else:
        continue
    break

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

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const int N=2e6+7;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}
int main()
{

    ll n,m;
    cin>>n>>m;
    ll x;
    ll td=0;
rep(i,0,m)cin>>x,td+=x;

if(n>=td)cout<<n-td;
else cout<<"-1";







}


Measured memory_bytes: 3568
var
  s: string;
  alpha: array[1..26] of int64;
  i: int64;
  ok: boolean;
begin
  readln(s);
  for i := 1 to length(s) do
  begin
    alpha[ord(s[i]) - ord('a') + 1] := 1;
  end;
  
  ok := False;
  for i := 1 to 26 do
  begin
    if alpha[i] = 0 then
    begin
      writeln(chr(i + ord('a') - 1));
      ok := True;
      break;
    end;
  end;
  
  if ok = False then
  begin
    writeln('None');
  end;
end.

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int p[8][3] = {
        {0,1,2},
        {3,4,5},
        {6,7,8},
        {0,3,6},
        {1,4,7},
        {2,5,8},
        {0,4,8},
        {2,4,6}
    };
    char s[10], ans;

    while(cin >> s){
        ans = 'd';
        rep(i,8){
            if(s[ p[i][0] ] == 'o' && s[ p[i][1] ] == 'o' && s[ p[i][2] ] == 'o')
                ans = 'o';
            if(s[ p[i][0] ] == 'x' && s[ p[i][1] ] == 'x' && s[ p[i][2] ] == 'x')
                ans = 'x';
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1132
def sosuu(A, cnt):
    sosuu=[2]
    ans=[] # 5n+1の素数
    for L in range(3,A,2):
        for L2 in sosuu:
            if L%L2==0:
                break
        else:
            sosuu.append(L)
            if L%5==1:
                ans.append(L)
                cnt-=1
                if cnt==0:
                    break
    return ans
n=int(input())
print(*sosuu(55555,n))


Measured memory_bytes: 3060
#include<stdio.h>
#define S 100000
#define T 50000
int main(){
  int s[S],t[T],n,q,i,j=0,count=0,k,r,l,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
   scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
  for(i=0;i<q;i++){
    k=t[i];
    l=0;
    r=n;
    while(1){
      m=(l+r)/2;
      if(s[m]==k){
	count++;
	break;
      }
      else if(s[m]<k){
	l=m+1;
      }
      else if(s[m]>k){
	r=m-1;
      }
      if(r<l){
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


ll dp[101][100005];

int main() {
    int N, W; cin >> N >> W;
    vll w(N + 1, 0), v(N + 1, 0);
    rep(i, N) cin >> w[i + 1] >> v[i + 1];

    for (int i = 1 ; i <= N; i++) {
        rep(j, W + 1) {
            if (j - w[i] < 0) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }

    cout << dp[N][W] << endl;


}


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

int main(){
    long long int n, x=0, sum=0, ans;
    cin >> n;
    vector<long long int> vec(n);
    for(int i=0 ; i<n ; i++){
        cin >> vec.at(i);
        sum+=vec.at(i);
    }
    if(sum-2*vec.at(0)>0){
        ans = sum-2*vec.at(0);
    }else{
        ans = 2*vec.at(0)-sum;
    }
    for(int j=0 ; j<n-1 ; j++){
        x+=vec.at(j);
        if(sum-2*x<0){
            if(ans>2*x-sum){
                ans=2*x-sum;
            }
        }else{
            if(ans>sum-2*x){
                ans=sum-2*x;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=5e5+5;
int mod=1e9+7;

ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}


int main()
{
    FIO
string s;
cin>>s;
int ans=1;
string x;
x+=s[0];
string cu;
for(int i=1;i<s.size();i++)
{
    cu+=s[i];
    if(x!=cu)
    {
    ///cout<<cu<<" "<<x<<endl;
        ans++;
        x=cu;
        cu="";
    }
}

    cout<<ans;

    return 0;
}

Measured memory_bytes: 3732
N = int(input())
S = input()

r_num = S.count('R')
g_num = S.count('G')
b_num = S.count('B')

num = r_num * g_num * b_num

for j in range(N):
    for i in range(j):
        k = j + (j - i)
        if k < N:
            if S[i] == S[j]:
                continue
            if S[i] == S[k]:
                continue
            if S[j] == S[k]:
                continue
            num -= 1

print(num)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 3e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

vector<int> adj[N];
int vis[N];
int len = OO;
vector<int> vv, ans;

bool cycle(int node, int par) {
  vis[node] = 1;
  int ret = 0;
  for(auto it: adj[node]) {
    if(it == par) continue;
    if(vis[it] == 0)
      ret |= cycle(it, node);
    else if(vis[it] == 1)
      return 1;
  }
  vis[node] = 2;
  return ret;
}

void cycleAns(int node, int root, bool awlMra) {
  if(!awlMra && root == node) {
    if((int)vv.size() < len) {
      len = vv.size();
      ans = vv;
    }
    return;
  }
  if(vis[node])
    return;
  vis[node] = 1;
  vv.push_back(node);
  for(auto it: adj[node])
    cycleAns(it, root, 0);
  vis[node] = 2;
  vv.pop_back();
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
  }
//  if(!cycle(1, -1)) {
//    cout << -1;
//    return 0;
//  }
  for (int i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof vis);
//    vv.clear();
    cycleAns(i, i, 1);
  }
  if(len > n) len = -1;
  cout << len;
  if(len != -1) {
    cout << '\n';
    for(int it: ans)
      cout << it << '\n';
  }
  return 0;
}


Measured memory_bytes: 8576
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element


int N;
int Q;
int sum = 0;
int pool[100010];

signed main()
{
	cin >> N;
	REP(i, N)
	{
		int a;
		cin >> a;
		pool[a]++;
		sum += a;
	}

	cin >> Q;
	REP(q, Q)
	{
		int b, c;
		cin >> b >> c;
		int cnt = pool[b];
		sum -= cnt * b;
		sum += cnt * c;
		pool[b] = 0;
		pool[c] += cnt;
		cout << sum << endl;
	}
}



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


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




int main() {
	int k;
	cin>>k;
	vector<ll>a;
	for(int i = 1;i<=9;i++){
		a.push_back(i);
	}
	while(1){
		if(k<=a.size()){
			cout<<a[k-1]<< endl;
			return 0;
		}
			 k -= a.size();
		vector<ll>old;
		swap(old,a);
		for(ll x:old){
			for(int i = -1;i<=1;i++){
				int d = x%10+i;
				if(d < 0 || d > 9)continue;
				ll nx = x*10+d;
				a.push_back(nx);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=1e5+9;
vector<ll>v;
int main()
{
    FASTINOUT;
    ll x;
    cin>>x;
    for (ll i=-1000;i<=1000;i++){
        ll kl=i;
        kl=kl*kl*kl*kl*kl;
        v.push_back(kl);
    }
    bool b=0;
    for (int i=0;i<v.size()&&!b;i++){
        for (int j=0;j<v.size()&&!b;j++){
            if (v[i]-v[j]==x){
                cout<<i-1000<<" "<<j-1000;
                b=1;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3640