akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
   ll K;
   cin>>K;
   priority_queue<ll, vector<ll>, greater<ll>> X;
   rep(i, 9){
       X.push(i+1);
   }
   if(K<11){
       cout<<K<<endl;
       return 0;
   }
   ll Cou=9;
   while(1){
       ll T=X.top();
       ll Am=T%10;
        if(Am>0){
            X.push(T*10+Am-1);
          	//cout<<T*10+Am-1<<endl;
            Cou++;
            if(Cou==K){
                cout<<T*10+Am-1<<endl;
            return 0;
            }
        }
        X.push(T*10+Am);
     	//cout<<T*10+Am<<endl;
        Cou++;
            if(Cou==K){
                cout<<T*10+Am<<endl;
            return 0;
            }
        if(Am<9){
            X.push(T*10+Am+1);
          	//cout<<T*10+Am+1<<endl;
            Cou++;
            if(Cou==K){
            cout<<T*10+Am+1<<endl;
            return 0;
            }
        }
     	X.pop();
       
   }
}



Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
		PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

		solve(reader, writer);
		reader.close();
		writer.close();
	}

	private static void solve(BufferedReader reader, PrintWriter writer) throws IOException {
		String[] temp = (reader.readLine()).split(" ");
		int n = Integer.parseInt(temp[0]);
		int m = Integer.parseInt(temp[1]);
		int result = 0;
		if (n >= 2) {
			result += (n * (n - 1)) / 2;
		}
		if (m >= 2) {
			result += (m * (m - 1)) / 2;
		}
		writer.println(result);
	}
}


Measured memory_bytes: 21204
#include <stdio.h>
int main(void){
    int n,m;
    scanf("%d %d", &n, &m);
    int a[100] = {};
    int sum = 0;
    for(int i = 0;i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int c = 0;
    for(int i = 0; i < n; i++){
        if((double)a[i] >= (double)sum / 4 / m) c++;
    }
    if(c >= m) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define vll vector<ll>
#define G vector<vll >
#define F first
#define S second
#define pll pair<ll,ll>
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define rll read_ll();
#define gc getchar
#define pc putchar
#define deb2(a,b,c,d) cout<<a<<":"<<b<<" "<<c<<":"<<d<<endl;
typedef long long ll;
template<class T> inline T lcm(T a,T b){
        return a/gcd(a,b)*b;
}

ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define pll pair<ll,ll>
#define FOR1(i,a) for(i=0;i<=a;i++)
#define FOR2(i,a,b) for(i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define pll pair<ll,ll>
#define FOR1(i,a) for(i=0;i<=a;i++)
#define FOR2(i,a,b) for(i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef long long ll;

ll n,dist[200005];



struct comp
{
 	bool operator()(ll a,ll b)
	{
	return dist[a]>dist[b];
	}
 };

void djikstra(vector<vll >graph,ll s)
{
	ll i,prev[n];
	priority_queue<ll,vector<ll>,comp>Q;
	FOR1(i,n-1)
	{
		if(i==s)
			{dist[i]=0;prev[i]=-1;}
		else
			{dist[i]=10000;prev[i]=-1;}
			Q.push(i);
	}
	
	while(!Q.empty())
	{
		ll u=Q.top();Q.pop();
		for(auto&v:graph[u])
		{
			ll alt=dist[u]+1;
			if(alt<dist[v])
				dist[v]=alt,prev[v]=u;	
		}
	}

	// FOR1(i,n)
	// {
	// 	cout<<endl<<"dist to "<<i<<":"<<dist[i];
	// }

}

int main()
{
	ll i,e;cin>>n>>e;
	n+=1;
	vector<vll >graph(n);

	FOR1(i,e-1)
	{
		ll u,v,w;cin>>u>>v;
		graph[u].pb(v);
		// use unordered map for efficiency
	}

	djikstra(graph,1);
	if(dist[n-1]>2)
		cout<<"IMPOSSIBLE";
	else cout<<"POSSIBLE";
	return 0;
}



Measured memory_bytes: 22256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
static const long long INF = 100000000000000;
bool warshall_floyd(vector<vector<long long> > &graph);


int main() {
    int v,e;
    scanf ("%d %d",&v,&e);
    vector<vector<long long> > g (v, vector<long long>(v,INF));
    int s,t,d;
    for(int i=0;i<e;i++){
      scanf ("%d %d %d",&s,&t,&d);
      g[s][t]=d;
    }
    bool x;
    x=warshall_floyd(g);
    if(x==true){
      for(int i=0;i<v;i++){
        if(g[i][0]>=INF){
          printf("INF");
        }
        else{
          printf("%lld",g[i][0]);
        }
        for(int j=1;j<v;j++){
          if(g[i][j]>=INF){
            printf(" INF");
          }
          else{
            printf(" %lld",g[i][j]);
          }
        }
        printf("\n");
      }
    }
    else{
      printf("NEGATIVE CYCLE\n");
    }
}

// graph は隣接行列形式！
// 戻り値は負閉路検出結果で、負閉路があれば false 、なければ true
bool warshall_floyd(vector<vector<long long> > &graph) {
    int V = graph.size();
    // 自分までの距離は 0 としておく。後で使う。
    for (int i = 0; i < V; i++) { graph[i][i] = 0; }
    // 本体
    for (int k = 0; k < V; k++) {
      for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
          // 右辺に INF を含むときは計算しないようにする。
          // 重みが負になる辺があると INF - 1 とかになってしまい、
          // INF と区別がつかなくなる。
          if (graph[i][k] < INF && graph[k][j] < INF){
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
          }
        }
      }
    }
    // 負閉路検出をやる
    for (int i = 0; i < V; i++) {
      if (graph[i][i] < 0) {
        // これ、もし負閉路がなければ最初に入れた 0 が残っているはず。
        // そうでないということは、負閉路があって、そこを経由して自分自身に戻ってきたということ。
        return false;
      }
    }
    return true;
}






Measured memory_bytes: 3308
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    string s;
    cin >> s;
    replace(ALL(s),'?','D');
    cout << s << endl;
}

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


Measured memory_bytes: 3700
n=input()
l=list(map(int,input().split()))
n=int(input())
for i in range(n):
    b,e=map(int,input().split())
    l1=l[b:e]
    l1.reverse()
    l[b:e]=l1
l=map(str,l)
print(' '.join(map(str,l)))


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc149_d() {
	ll N, K;
	ll p[3] = { 0 };
	string T;
	ll P, Q, R;
	ll ans = 0;

	cin >> N >> K;
	cin >> p[0] >> p[1] >> p[2];
	cin >> T;
	
	ll cnt = 0;
	ll v = 0;
	vector<char> L[100001];
	rep(i, N){
		// 勝ちとなる手
		if (T[i] == 'r') v = 2;
		else if (T[i] == 's') v = 0;
		else if (T[i] == 'p') v = 1;

		L[cnt].push_back(v);
		cnt++;
		if (cnt == K){
			cnt = 0;
		}
	}

	ans = 0;
	rep(i, K){
		ans += p[L[i][0]];
		rep2(j, 1, L[i].size()){
			if ((L[i][j] != L[i][j - 1]) || L[i][j-1] == -1){
				ans += p[L[i][j]];
			}
			else{
				L[i][j] = -1;
			}
		}
	}

	cout << ans << "\n";
}

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

	solve_abc149_d();

	return 0;
}

Measured memory_bytes: 5456
n = int(input())
P = list(map(int,input().split()))
dic ={}
for i, num in enumerate(P):
    i+=1
    if num !=i:
        dic[num]=i
if len(dic)>2:
    print('NO')
    exit()
a = list(dic.keys())
b = list(dic.values())
if len(dic)==0 or (a[0]==b[1] and a[1]==b[0]):
    print('YES')

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

#define ll long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18

void testCase()
{
     
   // ll t; cin>>t; while(t--)
    
    {
    ll n;
    cin>>n;
    if(n>=30)
    cout<<"Yes\n";
    else
    cout<<"No\n";
    }
    
        
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

Measured memory_bytes: 3648
from collections import *

def main():
    H,W = map(int, input().split())
    ch,cw = map(int, input().split())
    dh,dw = map(int, input().split())
    s = ["#"*(W+4)]
    s.append("#"*(W+4))
    for i in range(H):
        s.append("##"+input()+"##")
    s.append("#"*(W+4))
    s.append("#"*(W+4))
    
    ans = [[-1]*(W+4) for _ in range(H+4)]
    for i in range(H+4):
        for j in range(W+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ch += 1; cw += 1
    dh += 1; dw += 1
    ans[ch][cw] = 0
    
    move = [[-1,0],[1,0],[0,-1],[0,1]]
    magic = [[-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],[-1,-2],[-1,-1],[-1,1],[-1,2],[0,-2],[0,2],[1,-2],[1,-1],[1,1],[1,2],[2,-2],[2,-1],[2,0],[2,1],[2,2]]
    
    mylist = deque([[ch,cw]])
    mylist2 = deque([])
    while len(mylist) > 0:
        x,y = mylist.popleft()
        mylist2.append([x,y])
        for p,q in move:
            v1,v2 = x+p,y+q
            if ans[v1][v2] == -1:
                mylist.append([v1,v2])
                ans[v1][v2] = ans[x][y]
        if len(mylist) == 0:
            while len(mylist2) > 0:
                x2,y2 = mylist2.popleft()
                for v1,v2 in magic:
                    i,j = x2+v1,y2+v2
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        mylist.append([i,j])
    print(ans[dh][dw])
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 23456
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <cmath>
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
typedef long long lli;
typedef long li;
typedef pair<int,int> PI;
typedef pair<long,int> PLI;
typedef pair<int,long> PIL;
typedef pair<long, long> PL;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<long long> VLL;
typedef priority_queue<int> PQ;
typedef priority_queue<long> PQL;
typedef priority_queue<long long> PQLL;
#define FAST ios::sync_with_stdio(0)
#define forz(n) for (long i = 0; i < n; i++)
#define forv(i,x,y) for (long i=x; i<y; i++)
#define rforz(a,n) for (long i = a; i < n; i++)
#define forlz(n) for (long int i = 0; i < n; i++)
#define TRAV(it, v) for(auto it = v.begin(); it != v.end(); it++) 
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define SQ(a) (a)*(a)
#define UM unordered_map
#define US unordered_set
#define LB(v,x) lower_bound(v.begin(),v.end(),x);
#define UB(v,x) upper_bound(v.begin(),v.end(),x);
#define CUBE(a) (a)*(a)*(a)
#define SORT(v) sort(v.begin(),v.end());
#define SORTC(v,c) sort(v.begin(),v.end(),c);
#define Pi 3.14159265358979323846
 
 
#define module 1000000007
 
 
lli gcd(lli x,lli y){
    if(x==0) return y;
    return gcd(y%x,x);
}
 
PL Egcd(lli x,lli y){
    if(x==0) return MP(0,1);
    PL t=Egcd(y%x,x);
    return MP(t.S-t.F*(y/x),t.F);
}
 

bool comp(PLL a,PLL b){
    return a.S > b.S;
}
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
void solve2(){
   lli a,b;
   cin>>a>>b;
   lli x = (max(a-1,(lli)0)*25)/2;
   lli y = ((b+1))*10;
   int best = (a*25)/2;
   forv(i,x,y+1){
       double a1 = (((double)i)/100)*8;
       double a2 = (((double)i)/10);
       int t1 = a1;
       int t2 = a2;
    //    cout<<a1<<" "<<a2<<'\n';
    //    cout<<t1<<" "<<t2<<'\n';
    //    if(a1 - 0.5 > t1){
    //        t1 = t1+1;
    //    }
    //    if(a2 - 0.5 > t2){
    //        t2 = t2+1;
    //    }
    //    cout<<t1<<" "<<t2<<'\n';
       if(t1==a && t2==b){
           cout<<i<<'\n';
           return;
       }
   }
   cout<<"-1\n";
   return;
}   
 
int main(){
    FAST;
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //=====================================code starts here
    // lli n;
    // cin>>n;
    // while(n--){
        solve2();
    // }
    
    
    return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll X;
    cin >> X;

    ll ans = 0;
    for(ll i=1; ; i++)
    {
        ans+=i;

        if(ans>=X)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = []
Y = []

for i in range(N):
  a, b = map(int, input().split())
  X.append((a, b))

for i in range(N):
  c, d = map(int, input().split())
  Y.append((c, d))


X.sort(key=lambda x: -x[1])
Y.sort(key=lambda x: x[0])

B = []
result = 0

for x in range(N):
  red = list(map(int, X[x]))

  for y in range(N):
    blue = list(map(int, Y[y]))
    if y in B:
      continue
    if red[0] < blue[0] and red[1] < blue[1]:
      result += 1
      B.append(y)
      break
  
print(result)

Measured memory_bytes: 3188
mod=10**9+7
n=gets.to_i
dp=(0..n).map{{}}
dp[0]['TTT']=1
n.times{|i|
    dp[i].each{|k, v|
        a, b, c=k.chars
        'ACGT'.chars{|d|
            next if (a+b+c+d)['AGC']
            next if (b+a+c+d)['AGC']
            next if (a+c+b+d)['AGC']
            next if (a+b+d+c)['AGC']
            s=b+c+d
            dp[i+1][s]=dp[i+1][s].to_i+v
            dp[i+1][s]%=mod
        }
    }
}
puts dp[n].values.inject(:+)%mod

Measured memory_bytes: 2428
/*
* 挑战程序设计竞赛2 第四章 第二题 queue
* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B
*/

# include <cstdio>

static const int maxn = 10000000;
int Q[maxn], n, q, head, tail;

struct Job {
	char name[15];
	int time;
} job[100005];

void dequeue() {
	head++;
}

void enqueue(int x) {
	Q[++tail] = x;
}

int main() {
	// 输入输出重定向
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
	
	scanf("%d%d", &n, &q); 
	for (int i = 0; i < n; i++) {
		scanf("%s%d", job[i].name, &job[i].time);
		Q[i] = i;
	}
	head = 0; tail = n-1; // 初始化队列的头和尾
	int p, t = 0; // p是正在操作的任务，t是目前的时间
	while (head <= tail) {
		p = Q[head];
		if (job[p].time <= q) {
			t += job[p].time;
			printf("%s %d\n", job[p].name, t);
			dequeue();
		}
		else {
			t += q;
			job[p].time -= q;
			enqueue(p);
			dequeue();
		}
	}
	return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll n,m;
string s,t;
int main(){
    cin>>n>>m;
    cin>>s>>t;
    ll l=n/__gcd(n,m)*m;
    ll tn=l/n,tm=l/m;
    bool flag=true;
    rep(i,n){
        ll tmp=l/n*i;
        if(tmp%tm==0){
            if(s[i]!=t[tmp/tm]) flag=false;
        }
    }
    rep(i,m){
        ll tmp=l/m*i;
        if(tmp%tn==0){
            if(t[i]!=s[tmp/tn]) flag=false;
        }
    }
    if(flag) cout<<l<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main()
{
      string a;cin>>a;
      int n=a.length();
      if(a[n-1]=='s')
      {
          cout<<a<<'e'<<'s';
      }
      else if(a[n-1]!='s')
      cout<<a<<'s';
          
      }



 

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

typedef long long ll;

ll x,y,z;
ll m[3],a[3];

ll GCD(ll a,ll b){
  if(b == 0) return a;
  return GCD(b,a%b);
}

int main(){

  while(1){
    int sum = 0;

    for(int i = 0; i < 3; i++){
      cin >> a[i] >> m[i];
      sum += a[i]+m[i];
    }

    if(sum == 0) break;
 
    ll pos[3] = {1,1,1};
    ll t[3] = {0,0,0};

    for(int i = 0; i < 3; i++){
      while(1){
	pos[i] = (pos[i]*a[i])%m[i];
	t[i]++;
	if(pos[i] == 1) break;
      }
    }

    ll tmp = (t[0]*t[1])/GCD(t[0],t[1]);
    ll ans = (tmp*t[2])/GCD(tmp,t[2]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n;
	while(cin >> n){
		int cnt = 0,last = -1;
		while(n){
			int m = n % 10;
			if(m == last) cnt++;
			else if(cnt >= 3) break;
			else cnt = 1;
			last = m;
			n /= 10;
		}
		if(cnt >= 3)
			cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

ll getLCM(ll a, ll b){
	if (a < b) { swap(a, b); }
	while (a % b) {
		a = a % b;
		swap(a, b);
	}
	return b;
}

int main(){
	ll a, b, A, B;
	ll gcd, lcm;
	for (; cin >> a >> b; cout << lcm << " " << gcd << endl) {
		lcm = getLCM(a, b);
		gcd = a * b / lcm;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define ff first
#define sc second
typedef long long ll;
using namespace std;
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    //freopen("test.txt","r",stdin);
    ll n;
    cin>>n;
    map<string,int>m;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
}



Measured memory_bytes: 3612
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

const Int dy[] = {-1, 0, 1, 0};
const Int dx[] = {0, 1, 0, -1};

template <typename T> void reverse(vector<T> &v) {
  reverse(v.begin(), v.end());
}
template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }
template <typename T> T sum(const vector<T> &v) {
  return accumulate(v.begin(), v.end(), T(0));
}
template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> void update_min(T &a, const T &b) { a = min(a, b); }
vector<pair<char, Int>> merge_cont_char(const string &s) {
  vector<pair<char, Int>> ret;
  if (s.empty())
    return ret;
  ret.push_back(make_pair(s[0], 0));
  FOR(c, s) {
    if (ret.back().first == c)
      ret.back().second++;
    else
      ret.push_back(make_pair(c, 1));
  }
  return ret;
}

class Shakutori {
public:
  // 全体の範囲
  // [0, end)
  // 注目している範囲
  // [tail, head)
  Int head, tail, end = 0;
  bool moveHead() {
    if (head == end) {
      return false;
    }
    head++;
    return true;
  }
  void moveTail() { tail++; }
  bool valid() {
    if (head == tail)
      return true;
    // [tail, head)
    // が解として適当か検証する
    return true;
  }
  void solve() {
    head = tail = 0;
    Int ans = 0;
    while (moveHead()) {
      while (!valid()) {
        moveTail();
      }
      // ここで解を更新する
    }
  }
};
class Solver {
public:
  Solver() {}
  Int n, k, ans;
  void input() {
    cin >> n >> k;

  }
  void solve() {
    ans  = n - k +1;
  }
  void output() {
    cout << ans <<endl;

  }
};

void initilization() {
  struct BoolName : numpunct<char> {
    string t, f;
    BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
    string do_truename() const { return t; }
    string do_falsename() const { return f; }
  };
  cin.tie(nullptr);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(15) << boolalpha;
  cout.imbue(locale(cout.getloc(), new BoolName));
}


int main() {
#ifdef LOCAL
  while (1) {
    Solver s;
    s.input();
    if (cin.eof())
      break;
    s.solve();
    s.output();
  }
#else
  Solver s;
  s.input();
  s.solve();
  s.output();
#endif
}

Measured memory_bytes: 888
a = input()
b = input()
c = input()
t = "a"

for i in range(len(a)+len(b)+len(c)):
    if t == "a":
        if len(a) == 0:
            print("A")
            break
        t = a[0]
        a = a[1:]
    if t == "b":
        if len(b) == 0:
            print("B")
            break
        t = b[0]
        b = b[1:]
    if t == "c":
        if len(c) == 0:
            print("C")
            break
        t = c[0]
        c = c[1:]



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s.back() << endl;
}




Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    Vl v(n);
    REP(i, n) {
        cin >> v[i];
    }

    ll res = 0;
    REP(i, 61) {
        ll c = 0;
        REP(j, n) {
            if (v[j] & (1LL << i)) {
                c++;
            }
        }
        ll ex = (1LL << i) % MOD;
        ll temp = c * (n - c) % MOD;
        res += ex * temp % MOD;
        res %= MOD;
    }
    std::cout << res << '\n';
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  cout << n * n << endl;
  return 0;
}


Measured memory_bytes: 256
# coding:utf-8
# abc?????????????????????

abc = raw_input().split()

a = int(abc[0])
b = int(abc[1])
c = int(abc[2])

if b < a:
    a,b = b,a

if c < b:
    c,b = b,c

if b < a:
    a,b = b,a

print a,b,c

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;

    i64 s = 0;
    i64 n1 = 0;
    i64 n2 = 0;
    REP(i, N) {
        i64 a, b; cin >> a >> b;
        i64 m = a + b;
        if (s > 0) {
            i64 k = max(n1 / a + (n1 % a > 0), n2 / b + (n2 % b > 0));
            a *= k, b *= k;
            n1 = a, n2 = b;
            s = n1 + n2;
        } else {
            s = m;
            n1 = a, n2 = b;
        }
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  N,C,D[50][50],c[507][507],F[4][50];

int main(){
  cin >> N >> C;
  rep(i,C){
    rep(j,C){
      cin >> D[i][j];
    }
  }
  rep(i,N){
    rep(j,N){
      cin >> c[i][j];
      c[i][j]--;
    }
  }
  rep(i,C){
    rep(j,N){
      rep(k,N){
        F[(j+k+2)%3][i]+=D[c[j][k]][i];
      }
    }
  }
  ll Z=LINF;
  rep(i,C){
    rep(j,C){
      if(i==j){
        continue;
      }
      rep(k,C){
        if(j==k || i==k){
          continue;
        }
        Z=min(F[0][i]+F[1][j]+F[2][k],Z);
      }
    }
  }
  cout << Z << endl;
}


Measured memory_bytes: 5580
#include<bits/stdc++.h>
#define pb push_back
//#define int long long
#define mod 1000000007
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define pi 3.14159
using namespace std;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<ll,ll> pll ;
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];*/
int main()
{
	fast;
	ll r;
	cin>>r;
	double c=2*pi*r;
	cout<<fixed<<setprecision(6)<<c;
	return 0;
}

Measured memory_bytes: 3804
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = not True
def ddprint(x):
  if DBG:
    print(x)

n,q = inm()
s = input()
a = [0] * (n+1)
cnt = 0
prevA = False
for i in range(n):
    if s[i] == 'A':
        prevA = True
    elif s[i] == 'C':
        if prevA:
            cnt += 1
        prevA = False
    else:
        prevA = False
    a[i] = cnt

ddprint(a)

for j in range(q):
    l,r = inm()
    ddprint(str(l) + ' ' + str(r))
    print(a[r-1] - a[l-1])


Measured memory_bytes: 53336
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = Math.min(B,  A*N);



        out.println(ans);
        out.flush();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int N) {
            int a[] = new int[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextInt();
            }

            return a;
        }

        long[] nextLongArray(int N) {
            long a[] = new long[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextLong();
            }

            return a;
        }

        double[] nextDoubleArray(int N) {
            double a[] = new double[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextDouble();
            }

            return a;
        }

        String[] nextTokenArray(int N) {
            String a[] = new String[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextToken();
            }

            return a;
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){
  int h, w, n;
  std::cin >> h >> w >> n;

  double a = std::max(h, w);
  std::cout << std::ceil(n/a) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void) {
 int a;
  scanf("%d",&a);
  if (a % 2 == 0) {
  printf("%d",a/2 * a/2);
  } else {
    printf("%d", a/2 * (a/2 + 1));
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using city = tuple<int, int, int>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<city> v;
  map<int, pair<int, int>> m;
  map<int, int> u;
  for (int i = 0; i < M; i++) {
    int p, y;
    cin >> p >> y;
    v.push_back(make_tuple(y, p, 0));
  }
  auto vorg = v;
  sort(v.begin(), v.end());
  for (auto i : v) {
    auto [y, p, tmp] = i;
    m[y] = make_pair(p, ++u[p]);
  }

  for (auto i : vorg) {
    auto [y, p, tmp] = i;
    cout << setfill('0') << right << setw(6) << m[y].first;
    cout << setfill('0') << right << setw(6) << m[y].second << endl;
  }
}


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

int min(int,int);

int main() {
    int n,i,a[100000],b[100000];
    int minimum,ans;
    
    scanf("%d",&n);
    for(i = 0; i < (n-1); i++)
        scanf("%d",&b[i]);
    
    ans = b[0];
    for(i = 1; i < (n-1); i++) {
        minimum = min(b[i-1],b[i]);
        a[i] = minimum;
        ans += a[i];
    }
    ans += b[n-2];
    printf("%d",ans);
}

int min(int x,int y) {
    if(x <= y)
        return x;
    else
        return y;
}

Measured memory_bytes: 128
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound

/*	For Debugging	*/
#define DEBUG 		cerr<<"/n>>>I'm Here<<</n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  20
bool v[N];
ll n;
vii a[N];
ll mx;

bool cal()
{
	rep(i,0,n)
	{
		if(v[i]==1)
		{
			rep(j,0,sz(a[i]))
			{
				if(v[a[i][j].F-1]!=a[i][j].S)
					return  0;
			}
		}
	}
	return 1;
}

void fun(ll p)
{
	if(p==n)
	{
		if(cal())
		{
			ll ans=0;
			rep(i,0,n)
			{
				ans+=v[i];
			}
			mx=max(mx,ans);
		}
		return;
	}
	fun(p+1);
	v[p]=1;
	fun(p+1);
	v[p]=0;
	return;
}

void solve()
{
	cin>>n;
	ll p,x,y;
	rep(i,0,n)
	{
		cin>>p;
		rep(j,0,p)
		{
			cin>>x>>y;
			a[i].pb({x,y});
		}
	}
	fun(0);
	cout<<mx<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x = Q[head];
  head=(head+1)%LEN;
  return x;
}
int min(int a,int b){return a<b ? a:b;}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;
  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)
      enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



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

int main()
{
    int N,M;cin>> N >> M;
    vector<pair<int,int>> bridge(M);
    int a,b;
    for (int i=0;i<M;i++)
    {
        cin >> a>> b;
        bridge[i]=make_pair(a,b);
    }
    sort(bridge.begin(),bridge.end());
    int cnt=0,left=0,right=0;
    for (int i=0;i<M;i++)
    {
        a=bridge[i].first;b=bridge[i].second;
        if (right<=a)
        {
            cnt++;
            right=b;
            left=a;
        }
        else
        {
            if (b<right) right=b;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(0<i&& i<H-1 && 0<j && j<W-1){
                        System.out.printf(".");
                    }else{
                        System.out.printf("#");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 53452
#include<iostream>
#include<queue>
#include<algorithm>

#define MAX_NUM 1000000000
using namespace std;

int check(long long P,int k,queue<int>Q)
{
    queue<int> R(Q);
    for(int j=1;j<=k;++j)
    {
        if(R.empty()) break;
        long long t =P;
        while(t>0)
        {
            if(R.empty()) break;
            int a= R.front();
            t=t-a;
            if(t < 0) break;
            else 
            {
               // cout << t << " " << a<<endl;
                R.pop();
            }
        }
    }
    return (Q.size()-R.size());
}

int main()
{
    int n,k; cin >> n>> k;
    queue<int> Q;
    for(int i=0;i<n;++i)
    {
        int t;
        cin >> t;
        Q.push(t);
    }

    long long left=0;
    long long right=MAX_NUM;
    while(left+1<right)
    {
        long long mid = (left + right)/2;
        if(check(mid,k,Q) < n) left = mid;
        else right = mid;
    }

    cout << right << endl;
}


Measured memory_bytes: 4180
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class Magatro
{
    static long n, k;
    static void Main()
    {
        Read();
        if (n <= 2)
        {
            Console.WriteLine(0);
            return;
        }
        
        long a = (n-3) % 11;
        long c = (n-3) / 11;
        long aa=0;
        long b = 0;
        for(int i = 0; i < 11; i++)
        {
            for(int j = 1; j <= 7; j++)
            {
                if (j == 6 || j == 7)
                {
                    continue;
                }
                long e = 7 * i + j;
                if ((9 * e + 72) % 11 == k)
                {
                    aa++;
                   // Console.WriteLine(e);
                }
            }
            if (i == a)
            {
                b = aa;
            }
        }
        Console.WriteLine(b + aa * c);

    }
    static void Read()
    {
        string[] s = Console.ReadLine().Split(' ');
        n = int.Parse(s[0]);
        k = int.Parse(s[1]);
    }
}




Measured memory_bytes: 2776
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  int a, b, c;
  cin >> a >> b >> c;

  int mx = max({a, b, c});

  int diff = mx - a + mx - b + mx - c;
  if(diff % 2){
    cout << (diff + 3) / 2;
  }else{
    cout << diff / 2;
  }
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/
using Graph = vector<bitset<10>>;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
#define mod 1000000007
ll factorial(ll n){
    ll i = 1;
    ll ans = 1;
    while(i<=n){
        ans = (i*ans)%mod;
        i++;
    }
    return ans;
}
 
ll calc(ll a,ll b ,ll p){
    if(b == 0){
        return 1;
    }
    else if(b %2 == 0){
        ll d = calc(a,b/2,p);
        return ((d%p)*(d%p))%p;
    }
    else{
        return ((a%p)*calc(a,b-1,p))%p;
    }
}
ll count_prs = 0;
ll PowMod_RepeatSquaring(ll N, ll P, ll M){
    ++count_prs;
    if(P==0) return 1;
    if(P%2==0){
        ll t = PowMod_RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * PowMod_RepeatSquaring(N, P-1, M);
}


int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  if(n == 2) cout << 0 << endl;
  else{
  ll ca = 1;
  for(ll i = n;i>=n-a+1;i--){
    ca *= i;
    ca %= mod;
  }
  ll nCa = (ca*calc(factorial(a),mod-2,mod))%mod;

  ll cb = 1;
  for(ll i = n;i>=n-b+1;i--){
    cb *= i;
    cb %= mod;
  }
  ll nCb = (cb*calc(factorial(b),mod-2,mod))%mod;
  //cout << nCa << " " << nCb << endl;
  
  ll nzyo = calc(2, n, 1000000007);
  ll ans = nzyo -1;
  if(ans - nCa >= 0) ans -= nCa;
  else ans = ans - nCa + mod;

  if(ans - nCb >= 0) ans -= nCb;
  else ans = ans - nCb + mod;
 
  cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int max(int a, int b) {
	return a > b ? a : b;
}

char s[501010];
int next[501010] = {};
int back[501010] = {};
int f[501010] = {};

int main() {
	int n;


	scanf("%d", &n);
	scanf("%s", s);

	int bk = -1;
	int i;
	for (i = 0; i < n; i++) {
		back[i] = bk;
		if (s[i] == '0') bk = i;
	}

	int nx = n;
	for (i = n - 1; i >= 0; i--) {
		next[i] = nx;

		if (s[i] == '0') nx = i;
	}

	for (i = 0; i < n; i++) {
		f[i] = max(f[i - 1], f[i]);

		if (s[i] == '1') {
			if (back[i] >= 1 && s[back[i] - 1] == '1') {
				int c = i - back[i];
				f[i] = max(f[i], f[back[i] - 2] + c);
			}

			if (next[i] < n - 1 && s[next[i] + 1] == '1') {
				int c = next[i] - i;
				f[next[i] + 1] = max(f[next[i] + 1], f[i - 1] + c);
			}
		}
	}

	printf("%d", f[n - 1]);

	getchar(); getchar();

}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
//#define ivorysi
#define MAXN 100005
#define eps 1e-7
#define mo 974711
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
const int P = 100000;
int a[5];
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    for(int i = 1 ; i <= 3 ; ++i) scanf("%d",&a[i]);
    sort(a + 1,a + 4);
    if((a[3] - (a[1] + a[3] - a[2])) % 2 == 0) {
	printf("%d\n",a[3] - a[2] + (a[3] - (a[1] + a[3] - a[2])) / 2);
    }
    else {
	++a[3];++a[1];
	if(a[2] < a[1]) swap(a[2],a[1]);
	int cnt = 1 + a[3] - a[2] + (a[3] - (a[1] + a[3] - a[2])) / 2;
	printf("%d\n",cnt);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<int> V(N);
    rep(i,N){
        cin>>V.at(i);
    }
    rep(i,N){
        int c;
        cin>>c;
        V.at(i)-=c;
    }
    int nas=0;
    rep(i,N){
        if(V.at(i)>0){
            nas+=V.at(i);
        }
    }
    cout<<nas<<endl;
}

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

#define R 1046527
#define N (-1)
#define L 14

char Hi[R][L];

int gc(char X){
  if(X == 'A'){
    return 1;
  }
  else if(X == 'C'){
    return 2;
  }
  else if(X = 'G' ){
    return 3;
  }
  else if(X == 'T') {
    return 4;
  }
  else return 0;
}


long long gt(char A[]){
  long long s = 0,p1=1,i;
  for(i=0;i<strlen(A);i++){
    s += p1*(gc(A[i]));
    p1*=5;
  }
  return s;
}

int he1(int A){
  return A % R;
}

int he2(int A){
  return 1 + (A % (R-1));
}

int mi(char A[]){
  long long im,i,he;

  im = gt(A);
  for(i=0;;i++){
    he = (he1(im) + i * he2(im))% R;
    if(strcmp(Hi[he],A) ==0){
      return 1;
    }
    else if(strlen(Hi[he]) == 0){
      return 0;
    }
  }
  return 0;
}

int na(char A[]){
  long long im,i,he;
  im = gt(A);
  for(i=0;;i++){
    he = (he1(im) + i * he2(im))% R;
    if(strcmp(Hi[he],A) == 0) {
      return 1;
    }
    else if(strlen(Hi[he]) == 0){
      strcpy(Hi[he],A);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,num;
  char si[L],da[9];
  for(i=0;i<R;i++){
    Hi[i][0]='\0';
  }
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s %s",da,si);

    if( da[0] == 'i'){
      na(si);
    }
    else{
      if(mi(si)){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 16016