akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int w = sc.nextInt();
			int d = sc.nextInt();
			if(n==0 && w==0 && d==0)
				break;
			
			int[] p = new int[n];
			int[] s = new int[n];
			for(int i=0;i<n;i++){
				p[i] = sc.nextInt();
				s[i] = sc.nextInt();
			}
			solve(n, w, d, p, s);
		}
	}

	public void solve(int n, int w, int d, int[] p, int[] s) {
		List<int[]> l = new LinkedList<int[]>();
		l.add(new int[]{w, d, w*d, -1});
		
		for(int i=0;i<p.length;i++){
			int[] c = l.remove(p[i]-1);
			int cp = s[i]%(c[0]+c[1]);
			if(cp<c[0]){
				int no = (c[0]-cp)*c[1]<cp*c[1] ? 0 : 1;
				l.add(new int[]{c[0]-cp, c[1], (c[0]-cp)*c[1], i*2+no});
				l.add(new int[]{cp, c[1], cp*c[1], i*2+1-no});
			}else{
				cp -= c[0];
				int no = c[0]*cp<c[0]*(c[1]-cp) ? 0 : 1;
				l.add(new int[]{c[0], cp, c[0]*cp, i*2+no});
				l.add(new int[]{c[0], c[1]-cp, c[0]*(c[1]-cp), i*2+1-no});
			}
			Collections.sort(l, new Comparator<int[]>() {
				@Override
				public int compare(int[] o1, int[] o2) {
					return o1[3]-o2[3];
				}
			});
		}
		
		Collections.sort(l, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return o1[2]-o2[2];
			}
		});
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<l.size()-1;i++){
//			System.out.println(Arrays.toString(l.get(i)));
			sb.append(l.get(i)[2]+" ");
		}
		sb.append(l.get(l.size()-1)[2]);
		System.out.println(sb.toString());
		
	}

}

Measured memory_bytes: 51992
#include <stdio.h>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
    while (1) {
        int n, m;
        scanf("%d%d", &n, &m);
        if (n == 0 && m == 0) {
            break;
        }
        pair<int, int> pl[m];
        bool first = true;
        while (n--) {
            for (int i = 0; i < m; i++) {
                if (first) {
                    pl[i] = make_pair(0, i+1);
                }
                int tmp;
                scanf("%d", &tmp);
                if (tmp) {
                    pl[i] = make_pair(--pl[i].first, i+1);
                }
            }
            first = false;
        }
        sort(pl, pl+m);

        for (int i = 0; i < m; i++) {
            if (i == m-1) {
                printf("%d\n", pl[i].second);
                break;
            }
            printf("%d ", pl[i].second);
        }
    }
}


Measured memory_bytes: 2680
n=int(input())
a=list(map(int,input().split()))
o=0
x=[]
for i in range(n):
  if a[i]>=3200:
    o+=1
  else:
    x.append(a[i]//400)
p=len(set(x))
q=max(1,p)
print(q,o+p)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const ll mod = (1e+9) + 7;

int main() {
	static int len, mo = 1, tmp;
	static pair<int, int> rl;
	string S;
	cin >> S;
	len = S.length();
	vector<int> child(len);
	for (int i = 0; i < len; ++i) {
		if (i + 1 != len && S[i] == 'R' && S[i + 1] == 'L') {
			child[i]++;
			child[i + 1]++;
			child[tmp] += rl.second - rl.second / 2;
			child[tmp + 1] += rl.second / 2;
			tmp = i;
			child[tmp] += rl.first / 2;
			child[tmp + 1] += rl.first - rl.first / 2;
			rl.first = rl.second = 0;
			i++;
			continue;
		}
		if (S[i] == 'R') rl.first++;
		if (S[i] == 'L') rl.second++;
	}
	child[tmp] += rl.second - rl.second / 2;
	child[tmp + 1] += rl.second / 2;
	for (int i = 0; i < len; ++i)
		cout << child[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
 
typedef long long int ll;
typedef string str;
 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}
 
ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}
 
void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	
	ll t,n,m,k,i,j,a,b;
	// cin >> t;
    str st,s;
    cin >> n;
    ll arr[n+2],d=0;
    for(i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    m=arr[0];
    for(i=1;i<n;i++)
    {
        m=max(arr[i],m);
        d+=m-arr[i];
    }
    cout << d << "\n";
    return 0;
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int s,ans=0;
    cin>>s;
    map<int,bool>a;
    stack<int>st;
    
    st.push(s);
    a[s]=true;
    
    int i=1;
    while(ans==0){
        int n=st.top();
        int fn;
        if(n&1)fn=3*n+1;
        else fn=n/2;
        
        i++;
        if(a[fn])ans=i;
        st.pop();
        st.push(fn);
        a[fn]=true;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
// gcd: 最大公約数, lcm: 最小公倍数
template<typename T>
T euclidean(T a, T b){
    if(a < b) swap(a, b);
    T r = a % b;
    while(r != 0){
        a = b; b = r; r = a % b;
    }
    return b;
}
template<typename T>
T gcd(T a, T b){
    return euclidean(a, b);
}
template<typename T>
T lcm(T a, T b){
    T g = gcd(a, b);
    return a / g * b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int t;
    cin >> t;
    REP(i, t){
        LL a, b, c, d;
        cin >> a >> b >> c >> d;
        if(b > d || a < b){
            cout << "No" << endl;
            continue;
        }
        if(c >= b){
            cout << "Yes" << endl;
            continue;
        }

        LL y = gcd(d, b);
        LL x = a % y;
        cout << (b - y + x > c ? "No" : "Yes") << endl;
    }
}


Measured memory_bytes: 256
S=input()
x=len(S)
temp=ans=check=0
for i in range(x):
  if S[i]=="<":
    if temp>0 and S[i-1]==">":
      ans=ans-(temp*check)
      temp=0    
    check=0
    temp+=1
    ans+=temp
  else:
    check+=1
    temp-=1
    if temp<0:
      temp=0
      ans+=check
    else:
      ans+=temp
print(ans)

Measured memory_bytes: 4104
#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>;

int main() {

    int n;
    cin >> n;
    while(n) {
        int d = n % 10;
        if(d == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 3636
A,B,C = [int(hoge) for hoge in input().split()]
cnt = 0
while not (A%2 or B%2 or C%2):
    NewA = B//2 + C//2
    NewB = A//2 + C//2
    NewC = A//2 + B//2
    A,B,C = NewA,NewB,NewC
    cnt += 1
    if A==B==C:
        print(-1);exit()
print(cnt)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define mod 1000000007
int main()
{
ll i,x,k,d,z,dist;
cin>>x>>k>>d;
if(x<0)
    x=x*(-1);
if(d>=x&&k%2==1)
    dist=d-x;
else if(d>=x&&k%2==0)
    dist=x;
else if(d<x)
{
    z=x/d;ll mini=min(z,k);
    if((z%2==0&&k%2==0)||(z%2==1&&k%2==1)||k<z)
        dist=x-mini*d;
    else
        dist=abs(x-(mini+1)*d);
}
cout<<dist;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;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--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, W;
    cin >> N >> W;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    rep(i, N) {
        P p = items[i];
        rep(j, W + 1) {
            if (j - p.second >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - p.second] + p.first);
            }
            dp[i + 1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << '\n';
}

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



Measured memory_bytes: 10796
#include <bits/stdc++.h>
#define loop for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
#define in(n)  int n; cin>>n;
using namespace std;
typedef   long long int ll;
int main()
{
	ll h;
	ll w;
	cin>>h>>w;
	if(h==1 or w==1)
	cout<<1<<endl;
	else{
	if((h*w)%2==0)
	cout<<(h*w)/2;
	else
	cout<<((h-1)*w)/2+(w/2)+1;
}
}


Measured memory_bytes: 256
//53
#include<iostream>

using namespace std;

int main(){
  int q;
  cin>>q;
  long long cn[128]={};
  while(q--){
    int p,n;
    char c;
    cin>>p>>c>>n;
    cn[c]+=n;
    cout<<((cn['(']==cn[')'])?"Yes":"No")<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 1156
import java.util.*;
import java.io.*;
import java.util.function.*;

public class Main {
	public final int MOD = (int)1e9 + 7;
	
	public void solve(BufferedReader br) throws IOException {
		int n = Integer.parseInt(br.readLine());
		int[] ar = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] dp = new int[n];
		Arrays.fill(dp, 1000000000 + 7);
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			int[] array = new int[] {i + 1, i + 2};
			for (int j: array) {
				if (j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(ar[i] - ar[j]));
				}
			}
		}
		System.out.println(dp[n - 1]);
		//System.out.println(Arrays.toString(ar));	
	}
	
	public long mathPow(long base, long exp, long mod) {
		long res = 1;
		base = base % mod;
		while (exp > 0) {
			if ((exp & 1) == 1) res = (res * base ) % mod;
			exp = exp >> 1;
			base = (base * base) % mod;
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
	}
}



Measured memory_bytes: 38928
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[123456];
signed main() {
	std::map<long long, long long>uiop;
	int n, k, a, b = 0, l, r; string s; cin >> n >> k;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	sort(test, test + n);
	for (int h = 0; h < k; h++) {
		cin >> l >> r;
		int ok = -1, ng = n;
		for (int i = 0; i < 100; i++) {
			if (ng - ok <= 1) { break; }
			if (test[(ok + ng) / 2] <= r) {
				ok = (ok + ng) / 2;
			}
			else {
				ng = (ok + ng) / 2;
			}
		}
		int ko = -1, gn = n;
		for (int i = 0; i < 100; i++) {
			if (gn - ko <= 1) { break; }
			if (test[(ko + gn) / 2] < l) {
				ko = (ko + gn) / 2;
			}
			else {
				gn = (ko + gn) / 2;
			}
		}
		cout << ok - ko << endl;
	}
}


Measured memory_bytes: 3896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Prac
{
    class Prog
    {
        public static void Main()
        {
            StringBuilder input = new StringBuilder();
            String temp = "";
          
            while (true)
            {
                temp = Console.ReadLine().ToLower();
      
                input.Append(temp);
                if ((new string(temp.Take(4).ToArray()) == "this") | (new string(temp.Take(6).ToArray()) == "before") | (temp == "z") | temp.Last() == '"')
                    break;
            }
            var input2 = input.ToString().ToCharArray();
            for (var i = 'a'; i <= 'z'; i++)
            {
                Console.WriteLine(i.ToString() + " : " + input2.Count(x => x == i).ToString());
                
            }
           
        }
    }
}

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

int main() {
    int a,b;
    cin >> a >> b;

    int x = (a+b)%2;
    if (x ==0)
    {
        cout << (a+b)/2;
        return 0;
    }
    
    cout << "IMPOSSIBLE";
    return 0;
}

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

int main(){
  char t;
  int a, b, c;
  int s1=0, s2=0;
  while(cin >> a >> t >> b >> t >> c){
    if(a*a+b*b==c*c) s1++;
    if(a==b)s2++;
  }
  cout << s1 << endl;
  cout << s2 << endl;
  return 0;
}

Measured memory_bytes: 1160
N, M, Q = map(int, input().split())
res = 0

def dfs(L: list):
    global res
    A = L[::]
    if len(A) == N + 1:
        now = 0
        for i in range(Q):
            if A[b[i]] - A[a[i]] == c[i]:
                now += d[i]
        res = max(res, now)
        # print(A, now)
        return
    
    A.append(A[-1])
    while A[-1] <= M:
        dfs(A)
        A[-1] += 1
    
a, b, c, d = [], [], [], []
for _ in range(Q):
    _a, _b, _c, _d = map(int, input().split())
    a.append(_a)
    b.append(_b)
    c.append(_c)
    d.append(_d)

dfs([1])
print(res)


Measured memory_bytes: 77012
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 1000000007ll // prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
ModInt pow(ModInt a,ll x){
	ModInt res = ModInt(1ll);
	while(x){
		if(x&1)res *= a;
		x >>= 1;
		a = a*a;
	}
	return res;
}
const int SIZE = 100100;
ModInt inv[SIZE+10],fac[SIZE+10],facinv[SIZE+10];
// notice: 0C0 = 1 
ModInt nCr(int n,int r){
	assert(!(n<r));
	assert(!(n<0||r<0));
	return fac[n]*facinv[r]*facinv[n-r];
}
void init(){
	fac[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)fac[i]=fac[i-1]*ModInt(i);
	inv[1]=ModInt(1ll);
	for(int i=2;i<=SIZE;i++)inv[i]=ModInt(0ll)-ModInt(MOD/i)*inv[MOD%i];
	facinv[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)facinv[i]=facinv[i-1]*inv[i];
	return;
}
int H,W;
string a[1010];
ModInt dp[1010][1010];
int main(){
	init();
	cin >> H >> W;
	for(int i=0;i<H;i++)cin >> a[i];
	dp[0][0]=ModInt(1ll);
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(a[i][j]=='#')continue;
			if(i>0)dp[i][j]+=dp[i-1][j];
			if(j>0)dp[i][j]+=dp[i][j-1];
		}
	}
	cout << dp[H-1][W-1] << endl;
    return 0;
}


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

int main() {
  int a, b, c;
  cin>>a>>b>>c;
  if (a == b) {
    cout<<c<<endl;
  }
  if (b == c) {
    cout<<a<<endl;
  }
  if (a == c) {
    cout<<b<<endl;
  }
}


Measured memory_bytes: 256
/*
    Doubly Linked List
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/3/ALDS1_3_C
*/
#include <bits/stdc++.h>
using namespace std;

class Node {
  public:
    int key;
    Node *next, *prev;
};

class DoublyLinkedList {
  private:
    Node *listSearch(int key);
    void deleteNode(Node *t);

  public:
    Node *nil; // 番兵
    void insert(int key);
    void deleteFirst();
    void deleteLast();
    void deleteKey(int key);

    DoublyLinkedList() {
        nil = new Node();
        nil->key = -1;
        nil->next = nil;
        nil->prev = nil;
    }

    ~DoublyLinkedList() {
        Node *cur = nil->next;
        cout << cur->key;
        while ((cur = cur->next) != nil) {
            cout << " " << cur->key;
        }
        cout << endl;
    }
};

void DoublyLinkedList::insert(int key) {
    Node *x = new Node();
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node *DoublyLinkedList::listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void DoublyLinkedList::deleteNode(Node *t) {
    if (t == nil)
        return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    delete t;
}

void DoublyLinkedList::deleteFirst() {
    deleteNode(nil->next);
}

void DoublyLinkedList::deleteLast() {
    deleteNode(nil->prev);
}

void DoublyLinkedList::deleteKey(int key) {
    deleteNode(listSearch(key));
}

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

    int n;
    cin >> n;
    DoublyLinkedList *dll = new DoublyLinkedList();

    for (int i = 0; i < n; i++) {
        int key;
        string command;
        cin >> command;
        if (command == "insert") {
            cin >> key;
            dll->insert(key);

        } else if (command == "delete") {
            cin >> key;
            dll->deleteKey(key);

        } else if (command == "deleteFirst") {
            dll->deleteFirst();

        } else if (command == "deleteLast") {
            dll->deleteLast();
        }
    }

    delete dll;
    return 0;
}


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

int main() {
  long long N;

  string res;

  
  cin >> N;

  vector <long long>vec(N);
  
  for( long long i = 0;i< N;i++){
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());
  
  res = "YES";
  for( long long i = 1;i< N;i++){
    if(vec.at(i-1) == vec.at(i)){
      res = "NO";
      break;
    }
  }
  
  cout << res << endl;
}







Measured memory_bytes: 1792
x, n = map(int, input().split())

if n == 0:
    print(x)
    exit()
    

li = list(map(int, input().split()))

check = 10**10
ans = 10**10


for i in range(0, 102):
    if i in li:
        continue
    
    if abs(x-i) == check:
        ans = min(ans, i)
    elif abs(x-i) < check:
        ans = i
        check = abs(x-i)
        
print(ans)

Measured memory_bytes: 9112
#include<iostream>
#include<cmath>

using namespace std;
class Dice{
public:
    int face[7],n;
    Dice(){}
    void role_E(){
        role(1,3,6,4);
    };
    void role_N(){
        role(1,5,6,2);
    };
    void role_S(){
        role(1,2,6,5);
    };
    void role_W(){
        role(1,4,6,3);
    };
    
    void role(int i, int j, int k, int l){
        n = face[l],face[l] = face[k], face[k] = face[j], face[j] = face[i], face[i] = n;
        
    }
    void way(char w){
        if(w == 'E') role_E();
        if(w == 'N') role_N();
        if(w == 'S') role_S();
        if(w == 'W') role_W();
    }

};
int main(){
    
    Dice dice;
    char dre;
    
    for (int i = 1; i<7; i++){
        cin >> dice.face[i];
    }
    while(cin >> dre){
        dice.way(dre);
    }
    cout <<dice.face[1]<<endl;
}



Measured memory_bytes: 3096
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

x,n=mp()
p=lmp()
for i in range(200):
    if x-i not in p:
        print(x-i)
        exit()
    elif x+i not in p:
        print(x+i)
        exit()

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define inf LLONG_MAX
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
#define mod 998244353
typedef  long long ll; 
typedef  unsigned long long ull; 
//using u64 = uint64_t; 
//using u128 = __uint128_t;
typedef vector< ll > edge; 
typedef pair< ll , bool > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll N=1e5+20;
ll parent[N];
void make_set(ll n)
{
	for(ll i=1;i<=n;i++) parent[i]=i;
}
ll find_set(ll a)
{
	if(parent[a]==a) return a;
	return parent[a]=find_set(parent[a]);
}
void uni(ll a, ll b)
{
	a=find_set(a);
	b=find_set(b);
	if(a==b) return ;
	if(rand()%2) swap(a,b);
	parent[a]=b;
}
int main()
{
	boost;
	ll n,m;
	cin>>n>>m;
	make_set(n);
	while(m--)
	{
		ll x,y,z;
		cin>>x>>y>>z;
		uni(x,y);
	}
	std::vector<bool> v(n+1,0);
	for(ll i=1;i<=n;i++) v[find_set(i)]=1;
	ll ans=0;
	for(ll i=1;i<=n;i++) if(v[i]) ans++;
	cout<<ans;	


	return 0;
}

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

using namespace std;

char a[5],b[5];

int main()
{
    scanf("%s%s",a,b);
    //cout << a << "*" << b << endl;
    int sum = 0;
    for(int i=0;i<3;i++)
    {
        if(a[i]==b[i])
            sum++;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
X=input()
x=X.count('1')
x_plus=int(X,2)%(x+1)
keta=n-1
if x==1:
    for i in range(n):
        tmp=0
        ans=1
        if X[i]=='0':
            tmp+=x_plus
            tmp+=pow(2,keta,(x+1))
            tmp%=(x+1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        else:
            print(0)
        keta-=1
else:
    x_minus=int(X,2)%(x-1)
    for i in range(n):
        tmp=0
        ans=1
        if X[i]=='0':
            tmp+=x_plus
            tmp+=pow(2,keta,(x+1))
            tmp%=(x+1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        else:
            tmp+=x_minus
            tmp-=pow(2,keta,(x-1))
            tmp%=(x-1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        keta-=1

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

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

//最大公約数を計算する
int gcd(int a,int b)
{
    if(a<b)swap(a,b);
	if (a%b==0){
		return(b);
    }else{
		return(gcd(b,a%b));
    }
}
int gcd2(int a, int b) {
  while(1) {
    if (b == 0) return a;
    int t = a;
    a = b;
    b = t%b;
  }
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n,0);
    int max = 0;
    rep(i,n){ 
        cin >> a[i];
        if(a[i] > max) max = a[i];
    }
    
    if(max < k){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    int tmp = gcd2(a[0],a[1]);
    int tmp2;
    rep(i,n-2){
        tmp2 = gcd2(tmp,a[i+2]);   
        if(tmp > tmp2){
            tmp = tmp2;
        }
    }

    if(tmp == 1){
        cout << "POSSIBLE" << endl;
    }else{
        if(k % tmp == 0){
           cout << "POSSIBLE" << endl;
        }else{
           cout << "IMPOSSIBLE" << endl;
        }
    }

    return 0;    
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int main()
{
	int n;
	while (scanf("%d", &n) && n){
		vector<P> line;
		for (int i = 0; i < n; i++){
			int col;
			scanf("%d", &col);
			if (!i) line.push_back(make_pair(col, 1));
			else if (i % 2 == 0){
				if (line.size() && line[line.size() - 1].first == col){
					line[line.size() - 1].second++;
				}
				else line.push_back(make_pair(col, 1));
			}
			else {
				if (line[line.size() - 1].first == col) line[line.size() - 1].second++;
				else {
					line[line.size() - 1].first = col;
					line[line.size() - 1].second++;
					if (line.size() > 1 && line[line.size() - 2].first == col){
						line[line.size() - 2].second += line[line.size() - 1].second;
						line.erase(line.end() - 1, line.end());
					}
				}
			}
		}
		int sum = 0;
		for (int i = 0; i < line.size(); i++) if (line[i].first == 0) sum += line[i].second;
		
		printf("%d\n", sum);
	}
	return (0);
}

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

int N;
int suff[100005];
int A[100005];

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  int now = 1, ans = 0;
  for(int i = 0; i <= N; i++) {
    cin >> A[i];
  }
  for(int i = N; i >= 0; i--) {
    suff[i] += suff[i + 1] + A[i];
  }
  for(int i = 0; i <= N; i++) {
    cin >> A[i];
    ans += min(now, suff[i]);
    now -= A[i];
    now *= 2;
    if(now < 0) {
      cout << "-1\n";
      return 0;
    }else if(now > 1e18) now = 1e18;
  }
  cout << ans << "\n";
}


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

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


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int m;
    cin >> m;
    cout << 48 - m << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
S=input()
w,e='W','E'
if e not in S or w not in S:print(0);exit()
ecnt=len([1 for i in list(S) if i==e])
p0,p1=0,ecnt-(S[0]==e)
ans=p0+p1
p=S[0]
for i in S[1:]:
  p0,p1=(p0+(p==w),p1-(i==e))
  #(l and gyaku,r and gyaku)
  ans=min(ans,p0+p1)
  p=i
print(ans)

Measured memory_bytes: 8352
#include<iostream>
using namespace std;
int main(){
  int cost[10],sum;

  while(cin >>sum && sum != 0){
 
  for(int i=0;i<9;i++){
    cin >>cost[i];
    sum-=cost[i];
  }
  cost[9] = sum;
  cout <<cost[9]<<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  string s; cin >> s;
  int l = s.size();
  bool ok = false;
  string k = "keyence";
  //if (s == "keyence") ok = true;
  //if (s.substr(0,7) == k) ok = true;
  //if (s.substr(l-7,7) == k) ok = true;
  for (int i = 0; i <= 7; i++)
  {
    string t = s.substr(0,i) + s.substr(l-(7-i),7-i);
    
    if (t == k) ok = true;
  }
  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main(){
    int a[3];
    scanf("%d%d%d", &a[0], &a[1], &a[2]);   
    sort(a, a+3);
    if(a[0] == a[1] && a[0] != a[2]) printf("Yes\n");
    else if(a[0] != a[1] && a[1] == a[2]) printf("Yes\n");
    else printf("No\n");
}

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

int n, ma, mb, a[50], b[50], c[50], inf = 1e9 + 7, Ma, Mb, dp[50][444][444], ans = inf;

int main(){
    cin >> n >> ma >> mb;
    for (int i = 0; i < n; i++){
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        Ma = max(a[i], Ma);
        Mb = max(b[i], Mb);
    }
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n * Ma; j++){
            for (int k = 0; k <= n * Mb; k++){
                dp[i][j][k] = inf;
            }
        }
    }

    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= n * Ma; j++){
            for (int k = 0; k <= n * Mb; k++){
                if (dp[i][j][k] == inf) continue;
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    for (int i = 1; i <= n * Ma; i++){
        for (int j = 1; j <= n * Mb; j++){
            if (i * mb == j * ma) ans = min(ans, dp[n][i][j]);
        }
    }
    if (ans == inf) ans = -1;
    printf("%d\n", ans);
}

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



int main(){
    cout<<fixed<<setprecision(10);

    
    int a,b;
    char op;
    cin>>a>>op>>b;
    
    while( op != '?' ){
        if(op == '+') cout<< a+b <<endl;
        if(op == '-') cout<< a-b <<endl;
        if(op == '*') cout<< a*b <<endl;
        if(op == '/') cout<< a/b <<endl;
        
        cin>>a>>op>>b;
    }

    return 0;
}



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

const int MAX = 200000;
const int MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int n,a,b[100009],x;

signed main(){
    COMinit();
    cin>>n;
    for(int i=0;i<n+1;i++){
        cin>>a;
        if(b[a])x=i+1-b[a];
        else b[a]=i+1;
    }
    for(int i=1;i<=n+1;i++){
        cout<<(COM(n+1,i)-COM(n-x,i-1)<0?COM(n+1,i)-COM(n-x,i-1)+MOD:COM(n+1,i)-COM(n-x,i-1))<<endl;
    }
}

Measured memory_bytes: 6656
int main(){
    int H, W, i, r;
    for(;;){
        scanf("%d%d",&H, &W);

        if( H == 0 && W == 0 ){
            break;
        }

        for( i = 0; i < H; i++){
            for( r = 0; r < W; r++){
                if( i == 0 || i == H - 1 ){
                    printf("#");
                }
                else if( r > 0 && r < W - 1){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

int binarySearch(int A[], int key, int right) {

  int mid, left = 0;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) return 1;

    else if (key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}

int main() {
  
  int n, q, count=0;
  int S[100000], T[50000];

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }

  cin >> q;

  for (int i = 0; i < q; i ++) {
    cin >> T[i];
  }

  for (int i = 0; i < q; i++) {

    if (binarySearch(S, T[i], n)) count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 1744
#include<cstdio>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<complex>
#define inf 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int> 
const int N=1e6+10;
const int mod=998244353;
using namespace std;

int a[N];
void solve(){
    int n,k; scanf("%d%d",&k,&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    a[n+1]=k;
    int ans=a[n]-a[1];
    for(int i=1;i<=n+1;++i) ans=min(ans,k-(a[i]-a[i-1]));
    printf("%d\n",ans);
}
int main() 
{
    int _=1;  //scanf("%d",&_);
    while(_--) solve();
return 0;
}
/*
2 1
1 2
*/




Measured memory_bytes: 1024
x, y, a, b, c = map(int,input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

pqr = p[:x] + q[:y] + r
pqr.sort(reverse=True)
print(sum(pqr[:x+y]))

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

int main(){
	int h, w;
	for(;;){
		cin >> h >> w;
		if(h == 0) return 0;
		bool tmp, b = true;
		for(int i = 0; i < h; i++){
			tmp = b;
			for(int j = 0; j < w; j++){
				cout << (tmp ? '#' : '.');
				tmp = !tmp;
			}
			cout << endl;
			b = !b;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3092
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{



   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>str;

      n=str.size();

      if(str[n-1]=='s')
      {

          cout<<str<<"es"<<endl;
      }
      else cout<<str<<"s"<<endl;













}



Measured memory_bytes: 3648
package main

import (
	"fmt"
)

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

const (
	MOD = 1000000007
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

type pair struct {
	l, r int
}

func main() {
	var N, K int
	fmt.Scanf("%d %d\n", &N, &K)

	max := (N - 1) * (N - 2) / 2
	if K > max {
		fmt.Println(-1)
		return
	}
	result := []*pair{}
	for i := 1; i <= N-1; i++ {
		result = append(result, &pair{l: i, r: N})
	}

	l, r := 1, 2
	for i := 0; i < max-K; i++ {
		result = append(result, &pair{l: l, r: r})
		r++
		if r == N {
			l++
			r = l + 1
		}
	}

	fmt.Println(len(result))
	for _, pair := range result {
		fmt.Println(pair.l, " ", pair.r)
	}
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, a, b;
  cin >> x >> a >> b;
  int B = abs(b - x);
  int A = abs(a - x);
  if (B < A) { cout << 'B' << endl; }
  else { cout << 'A' << endl; }
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int ans = M / N;
    while (ans > 0)
    {
        if (M % ans == 0)
            break;
        ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	ll g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}

void solve()
{
	
	ll h,w;
	cin>>h>>w;
	vector<string> v;
	v.push_back("Shivam");
	for(ll i=1;i<=h;i++)
	{
	string s,t;
	s+='0';
	cin>>t;
	s = s+t;
	v.push_back(s);	
	//cout<<"== "<<v[i]<<endl;
	}
	
	
	//for(ll i=1;i<=h;i++)
	//{
	//for(ll j = 1;j<=w;j++)
	//{		
		//cout<<v[i][j];
	//}		
	//cout<<endl;
	//}
	for(ll i=1;i<=2*h;i++)
	{
	for(ll j = 1;j<=w;j++)
	{
		char ch ;
		
		{
		ch = v[(i+1)/2][j] ;	
		}
		
		cout<<ch;
	}		
	cout<<endl;
	}
	
	 //if(ans)
  //{
  //cout<<"Yes"<<endl; 
  //}
  //else
   //{
  //cout<<"No"<<endl;
  //}
 
	
    //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
return ;
}


signed main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


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

const int SIGMA = 26;
void print(vector<ll> a) {
    for (int i = 0; i < (int)a.size(); i++) printf("%lld%c", a[i], " \n"[i + 1 == (int)a.size()]);
}

vector<int> getPr(string s) {
    int n = s.length();
    vector<int> pr(n);
    for (int i = 1; i < n; i++) {
        pr[i] = pr[i - 1];
        while (pr[i] > 0 && s[i] != s[pr[i]]) pr[i] = pr[pr[i] - 1];
        pr[i] += s[i] == s[pr[i]];
    }
    return pr;
}

string f(string s) {
    int n = s.length();
    auto pr = getPr(s);

    int per = -1;
    int len = (int)1e9;
    for (int x = pr[n - 1];; x = pr[x - 1]) {
        int cper = n - x;
        int cn = n;
        cn = cn / cper * cper + cper;
        if (cn / cper % 2 == 1) cn += cper;
        if (len > cn) {
            len = cn;
            per = cper;
        }
        if (x == 0) break;
    }
    while (s.length() < len) {
        char c = s[s.length() % per];
        s += c;
    }
    return s;
}

vector<ll> solve(string s, ll r) {
    vector<ll> ans(SIGMA);

    string t = f(s);
    t = t.substr(0, t.length() / 2);

    int m = t.length();
    auto pr = getPr(t);
    int per = m - pr[m - 1];

    vector<pair<ll, vector<ll> > > vct;
    vct.push_back({m - per, vector<ll>(SIGMA)});
    for (int i = per; i < m; i++) vct.back().second[t[i] - 'a']++;
    vct.push_back({per, vector<ll>(SIGMA)});
    for (int i = 0; i < per; i++) vct.back().second[t[i] - 'a']++;

    while (vct.back().first < r) {
        auto x = vct[(int)vct.size() - 1];
        auto y = vct[(int)vct.size() - 2];
        auto z = make_pair(x.first + y.first, vector<ll>(SIGMA));
        for (int i = 0; i < SIGMA; i++) {
            z.second[i] = x.second[i] + y.second[i];
        }
        vct.push_back(z);
    }
    while (vct.size() > 2) {
        if (r >= vct.back().first) {
            r -= vct.back().first;
            for (int i = 0; i < SIGMA; i++) ans[i] += vct.back().second[i];
        }
        vct.pop_back();
    }
    for (int i = 0; i < r; i++) ans[t[i] - 'a']++;

    return ans;
}

vector<ll> solve(string s, ll l, ll r) {
    auto a1 = solve(s, r);
    auto a2 = solve(s, l - 1);
    for (int i = 0; i < SIGMA; i++) {
        a1[i] -= a2[i];
    }
    return a1;
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    string s;
    ll l, r;
    while (cin >> s >> l >> r) {
        print(solve(s, l, r));
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 1856
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
19
885 8 1 128 83 32 256 206 639 16 4 128 689 32 8 64 885 969 1
)");
#define cin input
#endif

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

	queue<int> q;
	int s = 0;
	ll r = 0;
	REP (i, n)
	{
		int a;
		cin >> a;
		while (s & a)
		{
			s &= ~q.front();
			q.pop();
		}
		s |= a;
		q.push(a);
		r += q.size();
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 1024
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  string s, t; cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i < 3; ++i) {
    cnt += s[i] == t[i];
  }

  print(cnt);

  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
///////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll ans=0;
    while(n--){
        ll c;cin>>c;
        while(c>0&&c%2==0){
            c/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256