akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

string a;
int main()
{
	int i;
	cin >> a;
	for (i = 0; i < a.size() - 2; i++) {
		if (a[i] == a[i + 1] || a[i] == a[i + 2]) {
			cout << i + 1 << ' ' << i + 3;
			return 0;
		}
	}
	if (a[i] == a[i + 1]) {
		cout << i + 1 << ' ' << i + 2;
		return 0;
	}
    cout << "-1 -1" << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(pow(2,n));
	for(int i=0;i<pow(2,n);i++)
		cin >> a[i];
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());

	/*
	for(int i=0;i<pow(2,n);i++)
		cout << a[i] << endl;
	*/
	
	vector<int> cnt;
	int tmpcnt=0;
	int bef=-1;
	for(int i=0;i<pow(2,n);i++)
	{
		if(a[i]==bef)
			tmpcnt++;
		else
		{
			cnt.push_back(tmpcnt);
			tmpcnt=1;
			bef=a[i];
		}
	}
	if(tmpcnt!=0)
		cnt.push_back(tmpcnt);
	cnt.erase(cnt.begin());
	int arr[18];
	for(int i=0;i<18;i++)
		arr[i]=0;

	
	/*
	cout << "cnt" << endl;
	for(int i=0;i<cnt.size();i++)
		cout << cnt[i] << endl;
	*/

	bool can=true;
	
	if(cnt[0]!=1)
	{
		can=false;
	}

	for(int i=0;i<n;i++)
		arr[i]=1;
	long long all=n;
	

	int tmparr[18];
	for(int i=0;i<18;i++)
		tmparr[i]=0;

	for(int i=1;i<cnt.size();i++)
	{
		if(all<cnt[i])
		{
			can=false;
			break;
		}


		for(int j=0;j<18;j++)
			tmparr[j]=0;
		for(int j=0;j<cnt[i];j++)
		{
			int now=-1;
			for(int k=17;k>=0;k--)
				if(arr[k]>0)
				{
					now=k;
					break;
				}
			if(now==-1)
			{
				can=false;
				break;
			}
			arr[now]--;
			for(int k=now-1;k>=0;k--)
				tmparr[k]++;
		}
		if(!can)break;
		for(int j=0;j<18;j++)
			arr[j]+=tmparr[j];
		all=0;
		for(int j=0;j<18;j++)
			all+=arr[j];
	}

	cout << (can ? "Yes" : "No") << endl;
}




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

int main(){
ll a,b,k;
cin>>a>>b>>k;
if(a>k){
  cout<<a-k<<" "<<b<<endl;
}else{
  if(b>k-a){
    cout<<0<<" "<<b-k+a<<endl;
  }else{
    cout<<0<<" "<<0<<endl;
  }
}

}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int t[n];
  for(int i=0;i<n;i++) cin >> t[i];
  int m;
  cin >> m;
  int p[m],x[m];
  for(int i=0;i<m;i++) cin >> p[i] >> x[i];
  for(int i=0;i<m;i++){
  int sum=0;
    for(int j=0;j<n;j++){
    sum+=t[j];
    }
  sum-=t[p[i]-1];
  sum+=x[i];
  cout << sum << endl;
  }
}

Measured memory_bytes: 256
import fractions
a,b=map(int,input().split())
ab_gcd=fractions.gcd(a,b)
cd=[1]
tmp=int(ab_gcd**0.5)+1
if ab_gcd==1:
    print(1)
    exit()

for i in range(2,tmp+1):
   while ab_gcd%i==0:
        ab_gcd//=i
        cd.append(i)
if ab_gcd!=1:
    cd.append(ab_gcd)
cd=set(cd)
print(len(cd) if len(cd)!=1 else 2)

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

//FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w");
#define fin stdin
#define fout stdout

#define ll long long

#define INF 1000000000000000000LL

#define MAXN 102

int a[MAXN];
ll c[MAXN][MAXN], f[MAXN][MAXN];
std::vector < int > g[MAXN];
int from[MAXN], n, q[MAXN];
bool viz[MAXN];

inline void add(int x, int y, ll z) {
    c[x][y] = z;
    g[x].push_back(y);
    g[y].push_back(x);
}

bool bfs() {
    memset(viz, 0, sizeof viz);
    viz[0] = 1;
    int st = 0, dr = 1;
    q[0] = 0;
    while (st < dr && viz[n + 1] == 0) {
        int x = q[st++];
        for (auto &y : g[x]) {
            if (viz[y] == 0 && c[x][y] - f[x][y] > 0) {
                viz[y] = 1;
                from[y] = x;
                q[dr++] = y;
            }
        }
    }
    return viz[n + 1];
}

int main() {
    fscanf(fin, "%d", &n);

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        fscanf(fin, "%d", &a[i]);
        if (a[i] < 0)
            add(0, i, -a[i]);
        else if (a[i])
            add(i, n + 1, a[i]), ans += a[i];
    }

    for (int i = 1; i <= n; i++)
        if (a[i] < 0)
            for (int j = 2 * i; j <= n; j += i)
                add(i, j, INF);

    while (bfs()) {
        for (auto &y : g[n + 1]) {
            if (viz[y] && c[y][n + 1] - f[y][n + 1] > 0) {
                from[n + 1] = y;
                int x = n + 1;
                ll best = INF;
                while (x) {
                    best = std::min(best, c[from[x]][x] - f[from[x]][x]);
                    x = from[x];
                }
                x = n + 1;
                while (x) {
                    f[from[x]][x] += best;
                    f[x][from[x]] -= best;
                    x = from[x];
                }
                ans -= best;
            }
        }
    }

    fprintf(fout, "%lld\n", ans);

    fclose(fin);
    fclose(fout);
    return 0;
}


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


typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++);
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}
map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	char a[1];
	cin >> a;
	a[0]++;
	cout << a;
	return 0;
}









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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int r, g;
    cin >> r >> g;
    cout << g + (g - r) << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  string s,t;
  cin >> s >> t;
  int n=s.length(),m=t.length();
  vector<int> a(n+1,0),b(n+1,0);
  for(int i=0;i<n;i++){
    a[i+1]=(a[i]+(s[i]=='A'?1:2))%3;
  }
  for(int i=0;i<m;i++){
    b[i+1]=(b[i]+(t[i]=='A'?1:2))%3;
  }
  int q;
  cin >> q;
  int l1,r1,l2,r2;
  for(int i=0;i<q;i++){
    cin >> l1 >> r1 >> l2 >> r2;
    if((a[r1]-a[l1-1]+3)%3==(b[r2]-b[l2-1]+3)%3){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

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

int main() {
  ll x, year, money;
  cin >> x;
  year = 1;
  money = 100;
  while(1) {
    money = floor(money * 1.01);
    if (money >= x) {
      break;
    }
    year++;
  }
  cout << year << endl;
  return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int n;
vl vec,sum;
ll partsum(int l,int r){
    ll res=sum[r];
    if(l-1>=0){
        res-=sum[l-1];
    }
    return res;
}
ll f(int l,int x,int r){//[l,x),[x,r)
    ll a=partsum(l,x-1);
    ll b=partsum(x,r-1);
    return max(a,b)-min(a,b);
}
P calc(int l,int r){//[l,r:を二等分
    ll x=l;
    ll y=r;
    REP(_,100){
        ll p=(x*2+y)/3;
        ll q=(x+y*2)/3;
        ll a=f(l,p,r);
        ll b=f(l,q,r);
        if(a<=b){
            y=q;
        }else{
            x=p;
        }
    }
    ll mi=LINF;
    P res;
    FOR(i,x-8,x+8){
        if(i-1<l||i>r-1){
            continue;
        }
        ll a=partsum(l,i-1);
        ll b=partsum(i,r-1);
        if(abs(a-b)<mi){
            mi=abs(a-b);
            res=P(a,b);
        }
    }
    return res;
}
int main(){
    cin>>n;
    vec.resize(n);
    REP(i,n){
        cin>>vec[i];
    }
    sum=vec;
    REP(i,n-1){
        sum[i+1]+=sum[i];
    }
    ll ans=LINF;
    FOR(i,2,n-1){
        P a=calc(0,i);
        P b=calc(i,n);
        chmin(ans,max({a.fi,a.se,b.fi,b.se})-min({a.fi,a.se,b.fi,b.se}));
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#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; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    bool zero = false;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
        if(a == 0)
            zero = true;
    }

    ll ans = 1;
    ll lim = 1e18;
    REP(i,N){
        ll a = A[i];
        ll x = (lim)/ans;
        //cout << x << endl;
        if(x < a){
            ans = -1;
            break;
        }
        ans *= a;
    }

    if(zero) ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4000
let (>>=) xs f = List.map f xs |> List.concat
let ops = [("+", (+)); ("-", (-))]
let () =
  Scanf.scanf "%1d%1d%1d%1d" @@ fun a b c d ->
  ops >>= (fun (l0, (++)) ->
  ops >>= (fun (l1, (+-)) ->
  ops >>= (fun (l2, (+*)) ->
    if a ++ b +- c +* d = 7 then
      [Printf.sprintf "%d%s%d%s%d%s%d=7" a l0 b l1 c l2 d]
    else
      []
  ))) |> List.hd |> print_endline

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define loop(i,l,r) for(int i=(l);i<=(r);i++)
typedef long long LL;
const int maxn=2e5+5;
const int p=1e9+7;
LL quick_mod(LL a, LL b)
{
    LL ans = 1;
    a %= p;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % p;
            b--;
        }
        b >>= 1;
        a = a * a % p;
    }
    return ans;
}

LL C(LL n, LL m)
{
    if(m > n) return 0;
    LL ans = 1;
    for(int i=1; i<=m; i++)
    {
        LL a = (n + i - m) % p;
        LL b = i % p;
        ans = ans * (a * quick_mod(b, p-2) % p) % p;
    }
    return ans;
}

LL Lucas(LL n, LL m)
{
    if(m == 0) return 1;
    return C(n % p, m % p) * Lucas(n / p, m / p) % p;
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int m=n-k;
    printf("%d\n",m+1);
    for(int i=2;i<=k;i++)
    {
        int cnt=m-i+1;
        LL ans;
        /*
        if(i==2)
        {
            ans=(2*Lucas(cnt+i,i))%p;
        }
        else if(i==k)
        {
            ans=Lucas(cnt+i,i);
        }
        else ans=(Lucas(k-1,i-1)*Lucas(cnt+i,i))%p;*/
        ans=(Lucas(k-1,i-1)*Lucas(cnt+i,i))%p;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    sc.close();
    int answer = s.length();
    for(int i = 0; i <= s.length() - t.length(); i++){
      int diff = 0;
      for(int j = 0; j < t.length(); j++){
        if(s.charAt(i + j) != t.charAt(j)){
          diff++;
        }
      }
      answer = Math.min(answer, diff);
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 35660
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll x[51] = {};
ll dp[51][51][3001] = {};
int main() {
	ll N, A; cin >> N >> A;
	rep(i, 0, N)cin >> x[i];

	dp[0][0][0] = 1;
	rep(i, 0, N) {
		rep(j, 0, N) {
			rep(k, 0, N*A) {
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}

	ll ans = 0;
	repe(i, 1, N) {
		ans += dp[N][i][i*A];
	}

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

Measured memory_bytes: 60032
#!/usr/bin/env python3
from collections import deque

n, q = map(int, input().split())
a, b = [0] * (-1 + n), [0] * (n - 1)
path = [[] for _ in range(n)]
for i in range(n - 1):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    path[a[i]].append(b[i])
    path[b[i]].append(a[i])
add = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    add[p] += x
q = deque()
ans = [0] * n
# 根 0 から見ていく
q.append(0)
visit = [0] * n
visit[0] = 1
ans[0] = add[0]
while q:
    pos = q.popleft()
    for v in path[pos]:
        if visit[v] == 0:
            ans[v] = ans[pos] + add[v]
            q.append(v)
            visit[v] = 1
print(*ans)


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

int main(void){
    int n; cin >> n;
    double sum=0;
    for(int i=0;i<n;i++){
        double tmp; cin >> tmp;
        sum += 1/tmp;
    }
    printf("%.7f\n",1/sum);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    x, a = mi()
    print(10) if x >= a else print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;

int main(){ ; 
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;

    if (a1+a2+a3 >= 22){
        cout << "bust" << endl;
    }

    else{
        cout << "win" << endl;
    }
}   

Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        string s;
        cin>>s;
        int a=s[0]-'0';
        int b=s[1]-'0';
        int c=s[2]-'0';
        int d=s[3]-'0';
        if(a+b+c+d==7)cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
        else if(a-b+c+d==7)cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
        else if(a-b-c+d==7)cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
        else if(a-b-c-d==7)cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
        else if(a+b+c-d==7)cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
        else if(a+b-c-d==7)cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
        else if(a-b+c-d==7)cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
        else if(a+b-c+d==7)cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;


return 0;
}




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

const int OO = 0x3f3f3f3f;

string s1, s2, str = "";
int lengthOfS1, lengthOfS2;
int memo[3050][3050];

int solve(int l1, int l2){

    for(int i = 0 ; i <= l1 ; ++i)
        for(int j = 0 ; j <= l2 ; ++j){
            if(!i || !j)
                memo[i][j] = 0;
            else if(s1[i - 1] == s2[j - 1])
                memo[i][j] = memo[i-1][j-1] + 1;
            else
                memo[i][j] = max(memo[i-1][j], memo[i][j-1]);
        }
}
string print(int l1, int l2){

    if(!l1 || !l2) return str;

    else if(s1[l1 - 1] == s2[l2 - 1]) return print(l1 - 1, l2 - 1) + s1[l1 - 1];
    else if(memo[l1][l2 - 1] > memo[l1 - 1][l2]) return print(l1, l2 - 1);
    else return print(l1 - 1, l2);

}
int main() {
    cin >> s1 >> s2;
    lengthOfS1 = s1.length();
    lengthOfS2 = s2.length();
    solve(lengthOfS1, lengthOfS2);
    cout << print(lengthOfS1, lengthOfS2);

    return 0;
}


Measured memory_bytes: 36480
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
int r[114514], t[114514], a[114514];
bool b[114514];
int ans;
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)cin >> t[i];
	for (int i = 0; i < n; i++)cin >> a[i];
	r[0] = t[0]; b[0] = 1;
	for (int i = 1; i < n; i++) {
		r[i] = t[i];
		if (t[i] > t[i - 1]) b[i] = 1;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (i == n - 1 || a[i] > a[i + 1]) {
			if (b[i]) {
				if (a[i] != r[i]) {
					cout << "0\n";
					return 0;
				}
			}
			else {
				if (r[i] < a[i]) {
					cout << "0\n";
					return 0;
				}
				r[i] = a[i]; b[i] = 1;
			}
		}
		else r[i] = min(r[i], a[i]);
	}
	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (!b[i]) {
			ans *= r[i];
			ans %= 1000000007;
		}
	}
	cout << ans << endl;
}

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

int main(void){
  int top=0;
  int S[1000];
  int a,b,c;
  char op[1000];


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

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

  while(scanf("%s",op)!=EOF){
    if(op[0]=='+'){
      a=pop();
      b=pop();
      c=a+b;
      push(c);
    }else if(op[0]=='-'){
      a=pop();
      b=pop();
      c=b-a;
      push(c);
    }else if(op[0]=='*'){
      a=pop();
      b=pop();
      c=a*b;
      push(c);
    }else if(op[0]=='/'){
      a=pop();
      b=pop();
      c=b/a;
      push(c);
    }else{
      push(atoi(&op[0]));
    }
  }

  printf("%d\n",pop());

  return 0;
}

Measured memory_bytes: 1832
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)    for (int i = (int)b; i < (int)e; i++)
#define forr(i, b, e)    for (int i = (int)b; i < (int)e; i++)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 334112
ll v[tam];
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    ll k,n;
    cin>>k>>n;
    forr(i,0,n)
    {
        cin>>v[i];
    }
    ll maxx=0;
    forr(i,1,n)
    {
        maxx=max(maxx,v[i]-v[i-1]);
    }
    maxx=max(maxx,v[0]+k-v[n-1]);
    cout<<k-maxx<<endl;
}
// PLUS ULTRA!


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0, now = 0;
    rep (i, n) {
        char c; cin >> c;
        now += (c == 'I' ? 1 : -1);
        chmax(ans, now);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			int k = sc.nextInt();
			
			int d = 0;
			while ( n > 0 ) {
				n = n / k;
				d++;
			}
			
			System.out.println(d);
			
		}
	}
}

Measured memory_bytes: 21716
N, M, V, P = map(int, input().split())
A = sorted([int(x) for x in input().split()], reverse=True)

def func():
    S = 0
    c = 0
    for i in range(P-1, N):
        if A[i] + M >= A[P-1] and (V - (P-1) - (N-i-1) - 1) * M <= S + (A[i] + M - A[P-1]) * c:
            pass
        else:
            return i
        S += A[P-1] - A[i]
        c += 1
    return N
print(func())

Measured memory_bytes: 62704
#include<stdio.h>
int p[100005],count[100005];
int root(int n){
    if(p[n]!=n)
        p[n]=root(p[n]);
    return p[n];
}
void uni(int x,int y){
    x=root(x);y=root(y);
    if(x!=y){
        p[x]=y;
        count[y]+=count[x];
    }
    return ;
}
int main(){
    int n,m,k,i;
    scanf("%d%d%d",&n,&m,&k);
    int a[100005],b[100005],c[100005],d[100005],e[100005];
    for(i=0;i<m;i++){
        scanf("%d%d",&a[i],&b[i]);
        a[i]--;b[i]--;
    }
    for(i=0;i<k;i++){
        scanf("%d%d",&c[i],&d[i]);
        c[i]--;
        d[i]--;
    }
    for(i=0;i<n;i++){
        p[i]=i;
        count[i]=1;
    }
    for(i=0;i<m;i++)
        uni(a[i],b[i]);
    for(i=0;i<n;i++) e[i]=1;
    for(i=0;i<m;i++){
        if(root(a[i])==root(b[i])){
            e[a[i]]++;e[b[i]]++;
        }
    }
    for(i=0;i<k;i++){
        if(root(c[i])==root(d[i])){
            e[c[i]]++;e[d[i]]++;
        }
    }
    for(i=0;i<n;i++)
        printf("%d ",count[root(i)]-e[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 4096
x,y=map(int,input().split())
A=list(list(map(int,input().split())) for i in range(x))
B=list(int(input()) for i in range(y))
ans=[]
for i in range(x):
    count=0
    for j in range(y):
        count +=A[i][j]*B[j]
    ans.append(count)
for i in range(len(ans)):print(ans[i])


Measured memory_bytes: 5976
N = int(input())
S = {}
for i in range(N):
  Si = input()
  if S.setdefault(Si, 0) == 0:
    S[Si] = 1
  else:
    S[Si] += 1
S_sorted = sorted(S.items(), key=lambda x:-x[1])
anslist = []
for s in S_sorted:
  if s[1] < S_sorted[0][1]:
    break
  anslist.append(s)
anslist.sort()
for s in anslist:
  print(s[0])

Measured memory_bytes: 45788
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>
#include <fstream>
#include <sstream>
#include <time.h>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 200005
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

char s[N];
int main(){
    //freopen("1.txt","w",stdout);
    //cout<<setprecision(3)<<fixed;
    int T,i,j,k,n,m=0;
    scanf("%s",s);n=strlen(s);
    int ans=0;
    rep(i,0,n){
        if(s[i]=='T'){if(m)m--;else ans++;}
        else m++;
    }
    printf("%d\n",ans+m);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  int n, m;
  cin >> n >> m;

  cout << n*(n-1)/2 + m*(m-1)/2 << endl;

  return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  int d;
  bool s[103]={0};
  while(K--){
    int n,x ; cin>>n;
    while(n--) {
      cin>>x;
      s[x]=1;
    }
  }
  int a = 0;
  for(int i=1;i<=N;++i) if(!s[i]) a++;
  cout<<a;
}

Measured memory_bytes: 3620
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int n;
    
    cin >> n;
    
    int a[n];
    
    for(int i=0; i<n; i++) cin >> a[i];
    
    int ans[n];
    
    for(int i=0; i<n; i++) ans[a[i] - 1] = i + 1;
    
    for(int i=0; i<n; i++) cout << ans[i] << " ";
    
    return 0;
}


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

int main(void)
{
    int N, K;
    cin >> N >> K;
    multiset<int> sum;
    for(int i=0; i<N; ++i){
        int p;
        cin >> p;
        sum.insert(p);
    }

    int ans = 0;
  	int counter = 0;
    for(auto itr = sum.begin(); itr != sum.end(); ++itr){
        ans += *itr;
      	++counter;
      	if(counter >= K){
          break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
int a,b,c,d;
int l[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
char A,B,C;
priority_queue<int,vector<int>,greater<int> >small;

int main(){
  cin >>a>>b>>c>>d;
  if(a<=b)o(a*c);
  else o(b*c+(a-b)*d);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

vector<pair<int, int>> adj[100];
int in[100];

bool dfs(int now, int goal, int i, int prev = -1) {
    if (now == goal) {
        return true;
    }
    for (auto p : adj[now]) {
        int to = p.first;
        int eid = p.second;
        if (to == prev) continue;
        if (dfs(to, goal, i, now)) {
            in[eid] |= 1 << i;
            return true;
        }
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].pb(mp(b, i));
        adj[b].pb(mp(a, i));
    }

    cin >> m;
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        dfs(u, v, i);
    }

    ll ans = 1ll << (n - 1);
    vector<int> bitcnt(1 << m, 0);
    for (int bit = 1; bit < (1 << m); bit++) {
        bitcnt[bit] = bitcnt[bit >> 1] + bit % 2;
        int free = n - 1;
        for (int eid = 0; eid < n - 1; eid++) {
            if (in[eid] & bit) {
                free--;
            }
        }
        ans += (bitcnt[bit] & 1 ? -(1ll << free) : ll(1ll << free));
    }
    cout << ans << endl;
}

Measured memory_bytes: 7416
def calcsum(n):
    return n * (n + 1) // 2

s = str(input())
n = len(s) + 1
arrk = []
arrg = []
tmp = s[0]
cnt = 1
for i in range(1, n-1):
    if s[i] == tmp:
        cnt += 1
    elif s[i] != tmp:
        if tmp == '<':
            arrk.append(cnt)
        else:
            arrg.append(cnt)
        cnt = 1
        tmp = s[i]
if tmp == '<':
    arrk.append(cnt)
else:
    arrg.append(cnt)
#print(arrk, arrg)
ans = 0
for i in range(len(arrk)):
    #print(calcsum(arrk[i]-1))
    ans += calcsum(arrk[i]-1)
for i in range(len(arrg)):
    #print(calcsum(arrg[i]-1))
    ans += calcsum(arrg[i]-1)
#print('ans',ans)
l = min(len(arrg), len(arrk))
m = max(len(arrg), len(arrk))
#print(l, len(arrg), len(arrk))
if s[0] == '<':
    for i in range(l):
        ans += max(arrg[i], arrk[i])
    if l < len(arrk):
        ans += arrk[len(arrk) - 1]
elif s[0] == '>':
    ans += arrg[0]
    #print(arrg[0])
    if l != m:
        for i in range(l):
            #print('a', arrg[i+1], arrk[i], max(arrg[i+1], arrk[i]))
            ans += max(arrg[i+1], arrk[i])
    else:
        for i in range(l-1):
            #print('a', arrg[i+1], arrk[i], max(arrg[i+1], arrk[i]))
            ans += max(arrg[i+1], arrk[i])
    if s[n-2] == '<':
        ans += arrk[len(arrk) - 1]
    if l < len(arrk):
        ans += arrk[len(arrk) - 1]
print(ans)

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
vector<l_l> v;
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 200100;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = i;
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }
    // hannkaikukann 
    int getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const ll mod = 998244353;
ll N;
vector<ll> dp;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    v.resize(N);
    for(int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());
    SegmentTree seg;
    for(int i = N - 2; i >= 0; i--) {
        l_l tmp = {v[i].first + v[i].second, -1};
        auto itr = lower_bound(v.begin(), v.end(), tmp);
        int idx = distance(v.begin(), itr);
        int nowidx = seg.getmax(i, idx);
        //cerr << i << " " << idx << " " << nowidx << endl;
        seg.update(i, nowidx);
    }
    for(int i = 0; i < N; i++) {
        //cerr << i << " " << seg.getmax(i, i + 1) << endl;
    }
    dp.resize(N + 1);
    dp[0] = 1;
    for(int i = 0; i < v.size(); i++) {
        dp[i+1] += dp[i];
        int nxt = seg.getmax(i, i + 1);
        dp[nxt+1] += dp[i];
        dp[i+1] %= mod;
        dp[nxt+1] %= mod;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const int MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
    string s, t;
    cin >> s >> t;
    vector<char> a;
    vector<char> b;
    rep(i, s.size()) a.pb(s[i]);
    rep(i, t.size()) b.pb(t[i]);
    sort(a);
    sort(b);
    riverse(b);
    string S, T;
    for (char x : a) S = S + x;
    for (char y : b) T = T + y;
    if (S < T) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main() {
	long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;

	if(N%2==0){
		bool ok = true;
		for(int i=0; i<N/2; i++) ok = ok && S[i]==S[i+N/2];
		cout << (ok ? "Yes" : "No") << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [a;b] = reads int
    let f k = a + (a - 1) * (k - 1)
    Seq.initInfinite f
    |> Seq.findIndex (fun x -> x >= b)
    |> printfn "%i"
    0

Measured memory_bytes: 14172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int X, N;
    cin >> X >> N;
    set<int> st;
    rep(i, N) {
        int p;
        cin >> p;
        st.insert(p);
    }
    int ans = 0;
    for (int i = 1; i <= 101; i++) {
        if (st.count(i)) continue;
        if (abs(i - X) < abs(ans - X)) ans = i;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3624
import math
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)

def dfs(here, p, d, parent, depth, connect):
    parent[0][here] = p
    depth[here] = d
    for next_v in connect[here]:
        dfs(next_v, here, d + 1, parent, depth, connect)

def lca(v1, v2, parent, depth):
    if depth[v2] > depth[v1]:
        v1, v2 = v2, v1
    for i in range(max_log):
        if depth[v1] - depth[v2] >> i & 1:
            v1 = parent[i][v1]
    if v1 == v2:
        return v2
    for i in range(max_log - 1, -1, -1):
        if parent[i][v1] != parent[i][v2]:
            v1 = parent[i][v1]
            v2 = parent[i][v2]
    return parent[0][v1]

connect = defaultdict(list)
v_num = int(input())
root = 0
for i in range(v_num):
    edge = [int(n) for n in input().split(" ")]
    connect[i].extend(edge[1:])
depth = [-1 for n in range(v_num)]
max_log = max(int(math.log(v_num, 2)), 1)
parent = [[-1 for n in range(v_num)] for m in range(max_log)]
dfs(root, -1, 0, parent, depth, connect)
for i in range(max_log - 1):
    for v in range(v_num):
        parent[i + 1][v] = -1 if parent[i][v] < 0 else parent[i][parent[i][v]]
q_num = int(input())
for _ in range(q_num):
    v1, v2 = (int(n) for n in input().split(" ") )
    print(lca(v1, v2, parent, depth))

Measured memory_bytes: 137720
fun main(args: Array<String>) {
    val strings = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
    println(strings.split(", ")[readLine()!!.toInt()-1])
}

Measured memory_bytes: 36132
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,m,r;
    cin>>n>>m>>r;
    ll city[n];
    ll dist[n][n];
    rep(i,n)rep(j,n)dist[i][j]=1LL<<60;
    rep(i,r)cin>>city[i];
    rep(i,r)city[i]--;
    rep(i,m){
        ll ts,tt,tw;
        cin >> ts >> tt >> tw;
        tt--;ts--;
        dist[ts][tt]=tw;
        dist[tt][ts]=tw;
    }
    rep(k,n)rep(i,n)rep(j,n){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    }
    ll res=1LL<<60;
    sort(city,city+r);
    do{
        ll tmp=0;
        rep(i,r-1){
            tmp+=dist[city[i+1]][city[i]];
        }
        res=min(res,tmp);
    }while(next_permutation(city, city+r));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
int n;
int a[200000];
long long cnt[200001];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	long long ans=0;
	for(int i=1;i<=n;i++){
		ans+=(cnt[i]*(cnt[i]-1)/2);
	}
	for(int i=0;i<n;i++){
		cout<<ans-(cnt[a[i]]-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

string S, T; int cnt;

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

Measured memory_bytes: 3828
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver() ? "Yes" : "No");
        }
        static bool solver()
        {
            var ABC = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            if (ABC[0] == ABC[1])
            {
                return ABC[0] != ABC[2];
            }
            else if (ABC[0] == ABC[2])
            {
                return true;
            }
            else
            {
                return ABC[1] == ABC[2];
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct camel{
    ll k,l,r;
};

void solve(){
    int n;
    cin >> n;
    ll ans = 0;
    vector<camel> left;
    vector<camel> right;
    rep(i,n){
        camel c;
        cin >> c.k >> c.l >> c.r;
        --c.k;
        if(c.l>c.r){
            ans += c.r;
            c.l -= c.r;
            left.push_back(c);
        }
        else if(c.l==c.r){
            ans += c.r;
        }
        else{
            ++c.k;
            ans += c.l;
            c.r -= c.l;
            right.push_back(c);
        }
    }
    sort(left.begin(),left.end(),[](const camel& p,const camel& q){
        return p.k > q.k;
    });
    sort(right.begin(),right.end(),[](const camel& p,const camel& q){
        return p.k < q.k;
    });
    priority_queue<ll> pql;
    int id = 0;
    for(int i=left.size()-1;i>=0;i--){
        while(left[id].k>=i&&id<left.size()){
            pql.push(left[id].l);
            ++id;
            if(id==left.size()) break;
        }
        if(!pql.empty()){
            ans += pql.top();
            //cout << "L" << pql.top() << endl;
            pql.pop();
        }
    }
    priority_queue<ll> pqr;
    id = 0;
    for(int i=n-right.size();i<=n-1;i++){
        while(right[id].k<=i&&id<right.size()){
            pqr.push(right[id].r);
            ++id;
            if(id==right.size()) break;
        }
        if(!pqr.empty()){
            ans += pqr.top();
            //cout << "R" << pqr.top() << endl;
            pqr.pop();
        }
    }
    cout << ans << endl;
}

int main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 9704
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [0] * M
B = [0] * M
G = [1] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())
    me = A[i]-1
    t = B[i]-1
    if H[me] <= H[t]:
        G[me] = 0

    me = B[i]-1
    t = A[i]-1
    if H[me] <= H[t]:
        G[me] = 0
print(G.count(1))

Measured memory_bytes: 21772
#include <iostream>
#include <string>
#include <vector>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  std::map<int, int> m;
  rep(i, N) {
    int a;
    cin >> a;
    m[a]++;
  }

  int sum = 0;
  for (const auto& e : m) {
    if (e.first > e.second) sum += e.second;
    else sum += e.second - e.first;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4736