akhauriyash/Code-Regression huggingface dataset:
//Gvs Akhil (Vicennial)
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int N=1000006;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T> T power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
int fact[N];
int get(int x){
	if(x==0) return 1;
	return fact[x]=(x*get(x-1))%MOD;
}
int32_t main(){
	int n,m; cin>>n>>m;
	if(abs(n-m)>1){
		cout<<"0"; return 0;
	}
	if(n==m){
		int a=(get(n)*get(n))%MOD;
		a=(a*2)%MOD;
		cout<<a;
	}
	else{
		if(n<m) swap(n,m);
		int a=(get(n)*get(m))%MOD;
		cout<<a;		
	}
}



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

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

int main() {
    int x,y;
    cin >> x >> y;
    cout << x+y-gcd(x,y)+1 << endl;
}


Measured memory_bytes: 3116
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

const int MAX = 510000;
const int MOD = 1000000007;

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

// 二項係数計算
long long 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;
}

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

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

    ll ans = 0;
    // 前処理
    COMinit();

    rep(i,0,N+1) {
        if (i % 2 == 0) ans += Per(M-i,N-i) * COM(N,i);
        else ans -= Per(M-i,N-i) * COM(N,i);
        ans += MOD;
        ans %= MOD;
    }
    ans *= Per(M,N);
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 15584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    cout << N / 3 << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
// 詰まった入力例　S'=?b?? T=ab  ?の辞書順は英数字より前
using namespace std;

int MAX_S = 50, MAX_T = 50, pos=0;
string S2, T;

int main(){
    cin >> S2 >> T;
    int s_size = (int)(S2.length());
    int t_size = (int)(T.length());
    
    vector<string> ans;
    string S = S2;
    
    //cout << "t_size=" << t_size  <<endl;
    for(int i=0;i+t_size-1<s_size;i++){
        S = S2;
        int count = 0;
        int k = 0;  //T用の添え字
        for(int j=i;j<i+t_size;j++){
            //cout << S2[j] << " " << T[k] << " k=" << k << " j=" << j<<" count=" << count << endl;
            if(S2[j] != T[k] && S2[j] !='?'){
                k++;
                break;
            } 
            else {
                S[j] = T[k];
                count++;
                k++;
            }
        }
        if(count == t_size){
            pos = 1;
            for(int i=0;i<s_size;i++){
                if(S[i]=='?'){
                    //S.replace(i, 1, "a");
                    S[i] = 'a';
                }
            }
            ans.push_back(S);
            
        }
            //break;
        count = 0;
    }
    //for(int i=0;i<s_size;i++) cout << S[i];
    //cout << endl;
    if(!pos || t_size>s_size)cout << "UNRESTORABLE" << endl;
    else{
        sort(ans.begin(), ans.end());
        cout << ans[0] << endl;
    }
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll l = 0;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        l += a[i];
    }
    pair<ll,ll> mn = {mod*mod,-1};
    vector<ll> L(n);
    ll mid,now = 0;
    for(ll i = 0; i < n; i++){
        now += a[i];
        L[i] = now;
        if(2*L[i] >= l){
            if(i == 0){
                cout << a[0]-(l-a[0]) << endl;
                return 0;
            }
            if(abs(l-2*L[i]) > abs(l-2*L[i-1])){
                cout << abs(L[i-1]-(l-L[i-1])) << endl;
                return 0;
            }
            else{
                cout << abs(L[i]-(l-L[i])) << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int markToNum(char mark){
	if(mark == 'S'){
		return 0;
	}else if(mark == 'H'){
		return 1;
	}else if(mark == 'C'){
		return 2;
	}else{
		return 3;
	}
}

char numToMark(int num){
	if(num == 0){
		return 'S';
	}else if(num == 1){
		return 'H';
	}else if(num == 2){
		return 'C';
	}else{
		return 'D';
	}
}
int main()
{
	//S H C D : 0 1 2 3??????????????????
	//??°??????(??????????????° - 1)????????????index?????????
	bool card[4][13] = {false};			//false??§???????????????????????????????????????????????????true?????????
	int n;
	cin>>n;
	char mark;
	int index;
	for(int i = 0; i < n; i++){
		cin>>mark>>index;
		card[markToNum(mark)][index -1 ] = true;
	}
	//cout<<"------------------"<<endl;
	for(int i = 0; i < 4 ; i++){
		for(int j = 0; j < 13; j++){
			if(card[i][j]==false){
				cout<<numToMark(i)<<" "<<j + 1<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3068
import java.util.Scanner;
 
class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		int[] B = new int[M];
		int[] count = new int[N+1];
		for(int i=0; i<=N; i++){
			count[i] = 0;
		}
		for(int i=0; i<M; i++){
			A[i]  = sc.nextInt();
			B[i]  = sc.nextInt();
			count[A[i]]++;
			count[B[i]]++;
		}
		int[][] dp = new int[N+1][];
		for(int i=0; i<=N; i++){
			dp[i] = new int[count[i]];			
		}
		for(int i=0; i<=N; i++){
			count[i] = 0;
		}
		for(int i=0; i<M; i++){
			dp[A[i]][count[A[i]]] = B[i];
			dp[B[i]][count[B[i]]] = A[i];
			count[A[i]]++;
			count[B[i]]++;
		}
 
		int[] ans = new int[2*N];
		ans[N] = A[0];
		int min = N;
		int max = N;
		boolean[] v = new boolean[N+1];
		for(int i=1;i<=N; i++){
			v[i] = true;
		}
		v[ans[N]] = false;
		boolean update = true;
		while(true){
			update = false;
			for(int i=0; i<count[ans[max]]; i++){
				if(v[dp[ans[max]][i]]==true){
					ans[max+1] = dp[ans[max]][i];
					v[dp[ans[max]][i]] = false;
					max++;
					update = true;
					break;
				}
			}
			for(int i=0; i<count[ans[min]]; i++){
				if(v[dp[ans[min]][i]]==true){
					ans[min-1] = dp[ans[min]][i];
					v[dp[ans[min]][i]] = false;
					min--;
					update = true;
					break;
				}
			}
			if(update==false){
				break;
			}
		}
 
		System.out.println(max-min+1);
		for(int j=min; j<max; j++){
			System.out.print(ans[j] + " ");
		}
		System.out.print(ans[max]);
 
	}
 
}

Measured memory_bytes: 67212
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
# 2D + 1 の木を見ることが出来る
    N, D = map(int, sys.stdin.readline().split())
    r = 2*D + 1
    if N % r == 0:
        print(int(N / r))
    else:
        print(int(N / r) + 1)

Measured memory_bytes: 5356
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>

using namespace std;

int main() {
	string s;
	cin >> s;
	int length = s.length();

	vector<int> max;
	int count = 0;
	for (int i = 0; i < length; ++i) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			++count;
		}
		else {
			count = 0;
		}
		max.push_back(count);
	}
	sort(max.rbegin(), max.rend());
	cout << max[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF   = 1000000000000000000;
const ll MAX_N = 100000 + 1;
ll h[MAX_N];

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll N, K;
  cin >> N >> K;
  for(ll i = 1; i <= N; i++) cin >> h[i];

  ll dp[N + 1];
  dp[1] = 0;
  for(ll i = 2; i <= N; i++) {
    ll mincost = INF;
    for(ll k = 1; k <= K; k++) {
      if(i-k < 1) continue;
      mincost = min(mincost, dp[i-k] + abs(h[i] - h[i-k]) );
    }
    dp[i] = mincost;
  }
  cout << dp[N] << endl;
  return 0;
}


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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

vector<ll> in_arr_long(int N) {
    vector<ll> arr;

    REP(i, N) {
        ll a;
        cin >> a;
        arr.pb(a);
    }

    return arr;
}

signed main() {
    int X, Y, Z, K;
    vector<ll> A, B, C;

    cin >> X >> Y >> Z >> K;
    A = in_arr_long(X);
    B = in_arr_long(Y);
    C = in_arr_long(Z);

    vector<ll> AB;
    for (ll a: A) {
        for (ll b: B) {
            AB.pb(a+b);
        }
    }

    sort(ALL(AB), greater<ll>());

    if (SZ(AB) > K) {
        AB.erase(AB.begin() + K, AB.end());
    }

    vector<ll> ABC;
    for (ll ab: AB) {
        for (ll c: C) {
            ABC.pb(ab+c);
        }
    }
    sort(ALL(ABC), greater<ll>());

    REP(i, K) {
        cout << ABC[i] << endl;
    }

    return 0;
}

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

using namespace std;

int n, da[205], db[205], dc[205], ma, mb, mc, ta, tb;
vector< int > v[205], vv;
long long dd[205], ans, aa;
int ddc[205];
long long ddd[205];

void dfs1(int a, int b) {
	da[a] = da[b] + 1;
	ma = max(ma, da[a]);
	for (int i = 0; i < v[a].size(); i++)
		if (v[a][i] != b)
			dfs1(v[a][i], a);
}

void dfs2(int a, int b) {
	db[a] = db[b] + 1;
	mb = max(mb, db[a]);
	for (int i = 0; i < v[a].size(); i++)
		if (v[a][i] != b)
			dfs2(v[a][i], a);
}

void dfs3(int a, int b) {
	int cur = 0;
	dc[a] = dc[b] + 1;
	for (int i = 0; i < v[a].size(); i++)
		if (!dc[v[a][i]]) {
			dfs3(v[a][i], a);
			cur++;
		}
	dd[dc[a]] = max(dd[dc[a]], (long long)cur);
}

void dfs4(int a, int b) {
	int cur = 0;
	ddc[a] = ddc[b] + 1;
	for (int i = 0; i < v[a].size(); i++)
		if (!ddc[v[a][i]]) {
			dfs4(v[a][i], a);
			cur++;
		}
	ddd[ddc[a]] = max(ddd[ddc[a]], (long long)cur);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &ta, &tb);
		v[ta].push_back(tb);
		v[tb].push_back(ta);
	}
	da[0] = db[0] = -1;
	dfs1(1, 0);
	for (int i = 1; i <= n; i++)
		if (da[i] == ma) {
			dfs2(i, 0);
			for (int j = 1; j <= n; j++)
				if (db[j] == mb) {
					vv.push_back(j);
					while (db[vv.back()])
						for (int k = 0; ; k++)
							if (db[v[vv.back()][k]] + 1 == db[vv.back()]) {
								vv.push_back(v[vv.back()][k]);
								break;
							}
					break;
				}
			break;
		}
	for (int i = 0; i < vv.size(); i++) {
		db[vv[i]] = min(db[vv[i]], mb - db[vv[i]]);
		mc = max(mc, db[vv[i]]);
	}
	// for (int i = 0; i < vv.size(); i++) printf("!! %d %d\n", vv[i], db[vv[i]]);
	for (int i = 0; i < vv.size(); i++)
		if (db[vv[i]] == mc)
			dc[vv[i]] = 1;
	for (int i = 0; i < vv.size(); i++)
		if (db[vv[i]] == mc) {
			dd[0]++;
			// printf("! %d\n",vv[i]);
			dfs3(vv[i], 0);
		}
	for (int i = 0; dd[i]; i++) {
		if (i) {
			if (dd[i] > LLONG_MAX / dd[i - 1])
				dd[i] = LLONG_MAX;
			else
				dd[i] *= dd[i - 1];
		}
		ans = dd[i];
	}
	// printf("%d %d\n", vv.size(), mb);
	// for (int i = 0; i <= n; i++) printf("  %d\n", dd[i]);
	if (mb % 2 == 0) {
		for (int i = 1; i <= n; i++)
			if (dc[i] == 1) {
				for (int j = 1; j <= n; j++)
					if (dc[j] == 2) {
						memset(ddc, 0, sizeof(ddc));
						memset(ddd, 0, sizeof(ddd));
						ddc[i] = ddc[j] = 1;
						ddd[0] = 2;
						dfs4(i, 0);
						dfs4(j, 0);
						aa = 0;
						for (int k = 0; ddd[k]; k++) {
							if (k) {
								if (ddd[k] > LLONG_MAX / ddd[k - 1])
									ddd[k] = LLONG_MAX;
								else
									ddd[k] *= ddd[k - 1];
							}
							aa = ddd[k];
						}
						ans = min(ans, aa);
					}
				break;
			}
	}
	printf("%d %lld\n", mb / 2 + 1, ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ull unsigned long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
ll modPow(ll x,ll n,ll m)   //fast modular exponentiation
{
    if(n==0)
    return 1%m;
    ll u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
ll seive[1000000];
void seiveForm()
{
    ll i,j;
    seive[0]=seive[1]=1;
    f(i,2,100000)
    {
        if(seive[i]==0)
            for(j=i*i;j<1000000;j+=i)
                seive[j]=1;
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,l,i,j,k,temp=0;
    bool ans=false;
    cin>>n>>l;
    string s[n];
    rep(i,n)
    cin>>s[i];
    sort(s,s+n);
    rep(i,n)
    cout<<s[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

public class Main<T> {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//System.setIn(new FileInputStream("./input.txt"));
		Reader r = new InputStreamReader(System.in);
		int n = r.read() - 0x30;
		//n = 2;
		Point[] p = Koch(n);
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < p.length; ++i){
			sb.append(p[i] + "\n");
		}
		System.out.println(sb);
	}

	public static Point[] Koch(int n) {
		Point[] p, p2;
		if(n == 0){
			p = new Point[2];
			p[0] = new Point(0.0, 0.0);
			p[1] = new Point(100.0, 0.0);
			return p;
		}else{
			p = Koch(n-1);
			p2 = new Point[(p.length - 1)*4 + 1];
			for(int i = 0; i < p.length; ++i) {
				// left edge
				p2[i*4] = new Point(p[i].x, p[i].y);
				if(i == p.length - 1){
					break;
				}
				// 3 middle points
				double mx = (p[i+1].x - p[i].x);
				double my = (p[i+1].y - p[i].y);
				
				p2[i*4 + 1] = new Point(mx / 3.0 + p[i].x, my / 3.0 + p[i].y);
				p2[i*4 + 2] = new Point(mx / 2.0 - my / (2.0 * Math.sqrt(3.0)) + p[i].x,
						my / 2.0 + mx / (2.0 * Math.sqrt(3.0)) + p[i].y);
				p2[i*4 + 3] = new Point(mx * 2.0 / 3.0 + p[i].x, my * 2.0 / 3.0 + p[i].y);
			}
			return p2;
		}
	}

	
}
class Point {
	public double x;
	public double y;
	@Override
	public String toString(){
		return String.format("%.5f %.5f", x, y);
	}
	public Point(double x, double y){
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 39168
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
a, b, c, d = gets.chop.split.map(&:to_i)

x = c / b
y = a / d

xx = c % b
yy = a % d

xxx = xx == 0 ? x : x + 1
yyy = yy == 0 ? y : y + 1

if xxx <= yyy
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14344
using System;

namespace ABC148B
{
	class Program
	{
		static void Main(string[] args)
		{
			string str1 = Console.ReadLine();
			int n = int.Parse(str1);
			string[] str2 = Console.ReadLine().Split(' ');
			char[] c1 = str2[0].ToCharArray();
			char[] c2 = str2[1].ToCharArray();
			for(int i = 0; i < n; i++)
			{
				Console.Write("{0}{1}",c1[i], c2[i]);
			}
			Console.Write("\n");
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int MODN=1e9+7;
const int MAXN=2e5+10;
int fact[MAXN];
int quick_pow(int a,int b,int modn=MODN){
    a%=MODN;
    int ret=1;
    // int cheng=a;
    while(b){
        if(b&1)ret*=a;
        ret%=MODN;
        a*=a;
        a%=MODN;
        b>>=1;
    }
    return ret;
}
int C(int n,int r){
    return fact[n]*(quick_pow((fact[n-r]*fact[r]),MODN-2))%MODN;
}

int32_t main(){
    
    int n,k;cin>>n>>k;
    fact[0]=1;
    for(int i=1;i<MAXN;i++)fact[i]=(fact[i-1]*i)%MODN;
    int sum=0;
    for(int i=0;i<=min(k,n-1);i++){
        sum+=C(n,i)*C(n-1,i);
        sum%=MODN;
    }
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

const ll MAX = 1e9 + 5;
int target;

int op(int a, int b) {
	return max(a, b);
}

int e() {
	return -1;
}
bool f(int v) {
	return v < target;
}
int main() {
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	segtree<int, op, e> seg(a);
	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;
		if (t == 1) {
			int x, v;
			cin >> x >> v;
			x--;
			seg.set(x, v);
		}
		else if (t == 2) {
			int l, r;
			cin >> l >> r;
			l--;
			cout << seg.prod(l, r) << endl;
		}
		else {
			int p;
			cin >> p >> target;
			p--;
			cout << seg.max_right<f>(p) + 1 << endl;
		}
	}
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    ll A, B;

    cin >> K;
    cin >> A >> B;
    for(ll i=A; i<=B; i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h> 
 int main(){ 
     int h, w; 
     int i, j; 
     while(1){ 
         scanf("%d %d ", &h, &w); 
         if(h==0&&w==0)break; 
         for(i=0;i<h;i++){ 
             for(j=0;j<w;j++){ 
                 if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){ 
                     printf("#"); 
                 }else{ 
                     printf("."); 
                 } 
             } 
             printf("\n"); 
         } 
         printf("\n"); 
         }
  
  
     return 0; 
 }


Measured memory_bytes: 2088
#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 N, K;
    cin >> N >> K;
    set<int> st;
    rep(i, K) {
        int D;
        cin >> D;
        rep(i, D) {
            int a;
            cin >> a;
            st.insert(a);
        }
    }
    int ans = N - sz(st);
    cout << ans << '\n';
    return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  LL n, m;

  scanf("%lld %lld",&n, &m);

  if (2 * n > m) printf("%lld\n",min(n, m / 2));
  else if (m > 1) printf("%lld\n",n + ((m - (2 * n)) / 4));
  else printf("0\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;
const int mod = 1e9+7;

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

    ll ans;;
    int num;
    bool count;
    if(a[0] != b[0]){ ans = 6; num = 2; count = true; }
    else{ ans = 3; num = 1; count = false; }

    while(num < n){
        if(a[num] != b[num]){
            if(count){
                ans *= 3;
                ans %= mod;
                num += 2;
                count = true;
            }
            else{
                ans *= 2;
                ans %= mod;
                num += 2;
                count= true;
            }
        }
        else{
            if(count){
                num++;
                count = false;
            }
            else{
                ans *= 2;
                ans %= mod;
                num++;
                count = false;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N, K, a, sum;
  cin >> N >> K;
  a = K / 2;
  for(; N > 0; N--) {
    int x;
    cin >> x;
    if(x > a) {
      sum += K - x;
    }
    else {
      sum += x;
    }
  }
  
  cout << sum * 2 << endl;
}

Measured memory_bytes: 3544
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<string>
using namespace std;
char buf[1030];
main(){
  string s;
  vector<string> res;
  fgets(buf,sizeof(buf),stdin);
  s = buf;
  // cout << s;
  int co=0;
  for(int i=0;i<s.size()-1;i++){
    //    cout << co << " " << i << endl;
    if(s[i]==' ' || s[i]==',' || s[i]=='.'){
      //    cout << s.substr(co,i-co)<<endl;
      if(co==i) co++;
      else{
	res.push_back(s.substr(co,i-co));
	co=i+1;
      }
    }
  }
  if(co<s.size()-1){
    res.push_back(s.substr(co,s.size()-co-1));
  }
  bool f=false;
  for(int i=0;i<res.size();i++){
    if(res[i].size()>=3 && res[i].size()<=6){
      if(f) cout << " ";
      cout << res[i];
      f=true;
    }
  }
  cout << endl;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const ll mod = 1000000007;
const ll maxN = 111;

ll n, i, j, h[maxN], act, bef;
vector<ll> ord;
ll dp[maxN][maxN];

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

int get_id(int x) {
    return lower_bound(ord.begin(), ord.end(), x) - ord.begin();
}

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%lld", &n);
    for (i = 1; i <= n; i++) scanf("%lld", &h[i]), ord.pb(h[i]);

    ord.pb(0);
    sort(ord.begin(), ord.end());
    ord.resize(unique(ord.begin(), ord.end()) - ord.begin());

    dp[1][0] = 2; //! doua colorari variabile

    //! initializeaza
    act = get_id(h[1]);
    dp[1][1] = ((poww(2, ord[1]) + mod - 2) * poww(2, h[1] - ord[1])) % mod;

    for (i = 2; i <= act; i++) {
        dp[1][i] = ((poww(2, ord[i] - ord[i - 1]) + mod - 1) * 2LL) % mod;
        dp[1][i] = (dp[1][i] * poww(2, h[1] - ord[i])) % mod;
    }

    //! rezolva
    for (i = 2; i <= n; i++) {
        bef = get_id(h[i - 1]);
        act = get_id(h[i]);

        if (h[i] == 1) {
            for (j = 0; j <= bef; j++)
                dp[i][0] = (dp[i][0] + dp[i - 1][j]) % mod;
            dp[i][0] = (dp[i][0] * 2LL) % mod;
            continue;
        }

        if (h[i - 1] <= h[i]) {
            //! creste nebunia
            for (j = 1; j <= bef; j++) {
                dp[i][j] = (dp[i - 1][j] * poww(2, h[i] - ord[bef])) % mod;
            }

            dp[i][0] = (dp[i - 1][0] * 2) % mod;
            for (j = bef + 1; j <= act; j++) {
                dp[i][j] = (dp[i - 1][0] * ( poww(2, ord[j] - ord[j - 1]) + mod - 1 )) % mod;
                dp[i][j] = (dp[i][j] * poww(2, h[i] - ord[j])) % mod;
                dp[i][j] = (dp[i][j] * 2) % mod;
            }
        } else {
            dp[i][0] = (dp[i - 1][0] * 2) % mod;

            for (j = 1; j <= act; j++)
                dp[i][j] = dp[i - 1][j];
            for (j = act + 1; j <= bef; j++)
                dp[i][0] = (dp[i][0] + dp[i - 1][j] * 2LL) % mod;
        }
    }

    ll ans = 0;
    act = get_id(h[n]);
    for (i = 0; i <= act; i++) ans = (ans + dp[n][i]) % mod;

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 384
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18

long double dp[3000][3000];

void solve(){
	int n; cin>>n;
	long double p[n];
	f(i,n) cin>>p[i];
	dp[0][0] = 1.0;
	for(int i=1;i<=n;i++) dp[i][0] = (1 - p[i-1]) * dp[i-1][0];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1 - p[i-1]);
		}
	}
	long double ans = 0.0;
	for(int i=(n/2)+1;i<=n;i++) ans += dp[n][i];
	cout << fixed << setprecision(10) <<ans << endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

ll gcd(ll a, ll b){ return b ? gcd(b,a%b):a; }

int main(){
  ll a,b;
  cin >> a >> b;
  ll tmp = gcd(a,b);
  ll ans=1;
  for(int i=2; i<=1000010; i++)if(tmp%i==0){
    ans++;
    while(tmp%i==0){ tmp/=i; }
  }
  for(int i=mx; i<=sqrt(tmp) && tmp!=1; i++)if(tmp%i==0){
    ans++;
    while(tmp%i==0){ tmp/=i; }    
  }
  if(tmp!=1){ans++;}
  cout << ans << endl;
  return 0;
}


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

int GCD(int former, int latter){
    if(former % latter == 0)return latter;
    if(latter % former == 0)return former;
    return GCD(latter, former % latter);
}

int main(void){
    int N, Abuf, gcdAll;
    bool isPairwise = true;
    vector<int> A;
    vector<long long> primes;
    vector<bool> covered;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
        if(i==0){
            gcdAll = Abuf;
        }else{
            gcdAll = GCD(gcdAll, Abuf);
        }
    }
    if(gcdAll != 1){
        cout << "not coprime" << endl;
    }else{
        primes.push_back(2LL);
        for(long long i=3; i<1000; i+=2){
            bool isPrime = true;
            for(long long j: primes){
                if(i < j * j)break;
                if(i % j == 0){
                    isPrime = false;
                    break;
                }
            }
            if(isPrime)primes.push_back(i);
        }
        covered.assign(1000000, false);
        for(int i=0; i<N; i++){
            if(A[i] == 1)continue;
            for(long long p: primes){
                bool flgMultiplier = false;
                while(A[i] % p == 0){
                    if(covered[p]){
                        isPairwise = false;
                        break;
                    }
                    flgMultiplier = true;
                    A[i] /= p;
                }
                if(!isPairwise)break;
                if(flgMultiplier){
                    covered[p] = true;
                }
                if(A[i]==1)break;
            }
            if(A[i] > 1){
                if(covered[A[i]]){
                    isPairwise = false;
                }else{
                    covered[A[i]] = true;
                }
            }
            if(!isPairwise)break;
        }
        if(isPairwise){
            cout << "pairwise coprime" << endl;
        }else{
            cout << "setwise coprime" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7456
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

struct node{
    int w;
    int s;
    int v;
};

int main(){
    int N;cin >> N;
    vector<node> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i].w >> v[i].s >> v[i].v;
    }
    vector<LL> dp(20001,-1);
    dp[0] = 0;
    sort(ALL(v),[&](node l,node r){return l.w+l.s<r.w+r.s;});
    for (int i = 0; i < N; i++) {
        for (int j = v[i].s; j >= 0; j--) {
            if(dp[j]==-1) continue;
            dp[j+v[i].w] = max(dp[j+v[i].w],dp[j]+v[i].v);
        }
    }
    cout << *max_element(ALL(dp)) << endl;
    return 0;
}


Measured memory_bytes: 384
X, K, D = map(int, input().split())
if X <= 0:
    X *= -1

if X - K * D >= 0:
    print(X - K * D)
else:
    rem = X % D
    tmp = (X - rem) / D
    if tmp % 2 == K % 2:
        print(rem)
    else:
        print(D - rem)


Measured memory_bytes: 61960
#include <stdio.h>
#include <math.h>

int main(void){
    int f=0,i,u=0;
    float d[6],ax[10000],ay[10000]; 
    while(1){
        for(i=0;i<6;i++){
            if (scanf("%f",&d[i])==EOF){f=1;break;};
        }
        if(f==1){break;}
        ax[u]=round(((d[4]*d[2]-d[1]*d[5])/(d[0]*d[4]-d[1]*d[3]))*1000)/1000;
        ay[u]=round(((d[0]*d[5]-d[3]*d[2])/(d[0]*d[4]-d[1]*d[3]))*1000)/1000;
        if(-1e-9<ax[u]&&ax[u]<1e-9){ax[u]=0.0;}
        if(-1e-9<ay[u]&&ay[u]<1e-9){ay[u]=0.0;}
        u++; 
    }
    for(i=0;i<u;i++){
        printf("%.3f %.3f\n",ax[i],ay[i]);
    }
    return 0;
}

        



Measured memory_bytes: 2040
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
	Scanner scan=new Scanner(System.in);
	int X=scan.nextInt();
	int A=0;
	int B=0;
	outside: for(int i=-118;i<120;i++) {
		for(int j=-119;j<119;j++) {
			int Y=i*i*i*i*i-j*j*j*j*j;
			if(Y==X) {
				A=i;
				B=j;
				break outside;
			}
		}
	}
	System.out.println(A+" "+B);
	}
}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
	ll a[n], b[n-1];
	REP(i,n-1) {cin >> b[i];}
	a[0] = b[0];
	FOR(i,1,n-1) {
    	if (b[i-1] <= b[i]) {
            a[i] = max(a[i-1], b[i-1]);
        } else {
        	a[i] = b[i];
        }
    }
	a[n-1] = b[n-2];
    cout << accumulate(a, a+n, 0) << endl;
}


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

using namespace std;

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

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

    bool ac[n];
    fill(ac, ac+n, false);
    int pen[n];
    fill(pen, pen+n, 0);
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        p--;

        if (!ac[p]) {
            if (s == "AC") {
                ac[p] = true;
                ans1++;
                ans2 += pen[p];
            } else {
                pen[p]++;
            }
        }
    }

    cout << ans1 << " " << ans2 << endl;

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a;
    cin >> a;
    
    /*
    if(c7 == 1 && c5 == 2 ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    */
    
    cout << a * ( a + 1 ) / 2 << endl;

    return 0; 
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	ll div = N / (A + B);
	ll answer = div * A;
	N -= div * (A + B);
	answer += min (N, A);
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  	int i,j;
  	cin >> i >> j;
    cout << (i+j)%24 << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

Measured memory_bytes: 256
/**-------------------------
|--------From A.R.A--------|
-------------------------**/

#include <bits/stdc++.h>

#define ll            long long int
#define pb            push_back
#define ull           unsigned long long int
#define endl          "\n"
#define sz(c)         (c).size()
#define sall(c)       sort((c).begin(),(c).end())
#define rsall(c)      sort((c).rbegin(),(c).rend())
#define rev(c)        reverse((c).begin(),(c).end())
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define max3(a,b,c)   max(max(a,b),c)
#define min3(a,b,c)   min(min(a,b),c)
#define input(a,i,n)  for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}

using namespace std;
int64_t R=1;
void solution(){
    int64_t x,n,a,k=0;
    cin>>x>>n;
    map <int64_t,int64_t> m;
    for(int i=0;i<n;++i){
        cin>>a;
        m[a]++;
    }
    while(true){
        if(m[x-k]==0){
            cout<<x-k<<endl;
            return;
        }
        if(m[x+k]==0){
            cout<<x+k<<endl;
            return;
        }
        k++;
    }

}
int main()
{
    FOR(i,R){solution();}
    return 0;
}


Measured memory_bytes: 3608
#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;
  vector<int> d(n);
  rep(i,n) cin >> d.at(i);
  sort(d.begin(), d.end());
  cout << d.at(n/2)- d.at(n/2-1) << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define bod 100000007
/****************************/
using namespace std;
int n,m;
vi g[100010];
bool vis[100010];
void dfs(int now)
{
	vis[now]=true;
	rep(i,g[now].size())
	{
		if(!vis[g[now][i]])
		{
			dfs(g[now][i]);
		 } 
	}
}
int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	zero(vis);
	int ans=0;
	rep3(i,1,n+1)
	{
		if(!vis[i])
		{
			ans++;
			dfs(i);
		}
	 }
	 cout<<ans-1;
	return 0;
}

Measured memory_bytes: 9652
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b>>c;
    if((a==c+b) || (b==a+c) || (c==a+b))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3568
# coding: utf-8

N=int(input())
A=list(map(int,input().split()))
INF=10**18

dp=[[-INF for i in range(2)] for j in range(N+1)]
dp[0][0]=0
dp[1][0]=0
dp[2][0]=0
dp[1][1]=A[0]
dp[2][1]=A[1]

for i in range(3,N+1):
    dp[i][0]=max(dp[i-2][0]+A[i-1],dp[i-2][1])
    if i%2==0:
        dp[i][0]=max(dp[i][0],dp[i-3][0]+A[i-1])
    else:
        dp[i][0]=max(dp[i][0],dp[i-3][1]+A[i-1])
    
    dp[i][1]=dp[i-2][1]+A[i-1]
    if i%2==0:
        dp[i][1]=max(dp[i][1],dp[i-3][1]+A[i-1])

if N%2==0:
    print(max(dp[N][1],dp[N-1][1]))
else:
    print(max(dp[N][0],dp[N-1][1],dp[N-2][1]))


Measured memory_bytes: 71384
#include <iostream>
#include <set>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=100000+10;
int n,a[N];
LL dp[N][2];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)for(int j=0;j<2;j++)dp[i][j]=-1e18;
    dp[1][0]=a[1];
    for(int i=1;i<n;i++){
        dp[i+1][0]=max(dp[i][0],dp[i][1])+a[i+1];
        dp[i+1][1]=max(dp[i][0]-2*a[i],dp[i][1]+2*a[i])-a[i+1];
    }
    cout<<max(dp[n][0],dp[n][1])<<endl;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
bool check(int a[3], int b[3], int c[3][3])
{
  bool ret = true;
  for (int i = 0; i < 3; i++) {
    if (a[i] < 0 || 100 < a[i]) ret = false;
  }
  for (int i = 0; i < 3; i++) {
    if (b[i] < 0 || 100 < b[i]) ret = false;
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (a[i] + b[j] != c[i][j]) ret = false;
    }
  }
  return ret;
}

int main() {
  int a[3], b[3], c[3][3];
  scanf("%d %d %d", &c[0][0], &c[0][1], &c[0][2])+1;
  scanf("%d %d %d", &c[1][0], &c[1][1], &c[1][2])+1;
  scanf("%d %d %d", &c[2][0], &c[2][1], &c[2][2])+1;

  int a0_max = c[0][0];
  a0_max = a0_max < c[0][1] ? c[0][1] : a0_max;
  a0_max = a0_max < c[0][2] ? c[0][2] : a0_max;
  int a1_max = c[1][0];
  a1_max = a1_max < c[1][1] ? c[1][1] : a1_max;
  a1_max = a1_max < c[1][2] ? c[1][2] : a1_max;
  int a2_max = c[2][0];
  a2_max = a2_max < c[2][1] ? c[2][1] : a2_max;
  a2_max = a2_max < c[2][2] ? c[2][2] : a2_max;

  for (int x = 0; x <= a0_max; x++) {
    for (int y = 0; y <= a1_max; y++) {
      for (int z = 0; z <= a2_max; z++) {
        a[0] = x;
        a[1] = y;
        a[2] = z;
        b[0] = c[0][0] - x;
        b[1] = c[0][1] - x;
        b[2] = c[0][2] - x;
        if (check(a, b, c)) {
          printf("Yes\n");
          return 0;
        }
      }
    }
  }
  
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int N,M,ne[111111],ans=0;

int root(int x){
	if(ne[x]==x)return x;
	return ne[x]=root(ne[x]);
}
bool same(int x,int y){return root(x)==root(y);}
void unite(int x,int y){
	if(same(x,y))return;
	int X=root(x),Y=root(y);
	ne[X]=Y;
	return;
}

int main() {
	cin>>N>>M;
	for(int i=1;i<=N;i++)ne[i]=i;
	for(int i=0;i<M;i++){
		int x,y,z;
		cin>>x>>y>>z;
		unite(x,y);
	}
	set<int>gr;
	for(int i=1;i<=N;i++){
		ne[i]=root(i);
		gr.insert(ne[i]);
	}
	cout<<(int)gr.size()<<endl;
	return 0;
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
void solve()
{
    int i,j,l1=s1.length(),l2=s2.length(),tag=0;
    for (i=0;i<l1;i++)
    {
        string t;
        for (j=i;j<l1;j++)
            t.push_back(s1[j]);
        for (j=0;j<i;j++)
            t.push_back(s1[j]);
        if (t==s2) {tag=1;break;}
    }
    if (tag) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>s1>>s2)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    string str;
    std::cin >> n;
    std::cin >> str;
  
    int ans = 1;
    std::string temp = str.substr(0, 1);
    
    for(int i=0; i<n; i++) {
	    if (temp != str.substr(i, 1)){
        	ans += 1;
            temp = str.substr(i, 1);
        }
    }
  
    cout << ans << endl;
}

Measured memory_bytes: 512
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
ll n ; 
ll toBase10(string x){
	reverse(x.begin(),x.end()) ; 
	ll ans = 0 ; 
	int m = (int)x.size() ; 
	ll t = 1 ; 
	for(int i=0;i<m;i++){
		if ( i == 0 ){
			ans += x[i] - '0' ; 
			continue ; 
		}
		t*=10 ; 
		ans += (x[i]-'0')*t ; 
	}
	return ans ; 
}
ll cnt = 0 ; 
void dfs(string x){
	ll c = toBase10(x) ; 
	if ( c > n ) return ; 
	bool three = false , five = false , seven = false ; 
	for(int i=0;i<(int)x.size();i++){
		if ( x[i] == '3' ) three = true ; 
		if ( x[i] == '5' ) five = true ; 
		if ( x[i] == '7' ) seven = true ; 
	}
	if ( three && five && seven ) {
		cnt++ ; 
	}
	//debug() << imie(x) ; 
	dfs(x+"3") ; 
	dfs(x+"5") ; 
	dfs(x+"7") ; 
}
int main(){
	cin >> n ; 
	dfs("") ; 
	cout << cnt << endl;
	return 0 ;
}


Measured memory_bytes: 256