akhauriyash/Code-Regression huggingface dataset:
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let mut chars_cnt = vec![[0; 26]; n];
    for i in 0..n {
        let vc: Vec<char> = s[i].chars().collect();
        for j in 0..vc.len() {
            chars_cnt[i][(vc[j] as u8 - b'a') as usize] += 1;
        }
    }

    for i in 0..26 {
        let mut current_min = 50 * 50 + 1;
        for j in 0..n {
            current_min = current_min.min(chars_cnt[j][i]);
            if current_min == 0 {
                continue;
            }
        }

        for _ in 0..current_min {
            print!("{}", (b'a' + i as u8) as char);
        }
    }
    println!("");
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A*B % 2 == 1) 
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#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>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N;
    cin >> N;
    for(int i = 40000;;i--){
        if(i*i <= N){
            cout << i*i << endl;
            return 0;
        }
    }
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline
import collections
import itertools

def main():
    n, k = input_list()
    a = input_list()
    b = n - 1
    x = k - 1
    ans = b // x
    if b % x == 0:
        print(ans)
    else:
        print(ans + 1)

def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


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


int main() {
    int a,b;
    cin >> a >> b;
    if(a == 1 & b == 2) cout << 3;
    else if (a == 1 & b ==3)cout << 2;
    else if(a == 2 & b ==1) cout << 3;
    else if(a == 2 & b ==3) cout << 1;
    else if(a == 3 & b ==1) cout << 2;
    else if(a == 3 & b ==2) cout << 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  ft   ios_base::sync_with_stdio(false);cin.tie(NULL);
#define  pb   push_back
#define  ll   long long
#define  pi   pair<int,int>
#define  F    first
#define  S    second
const int N=2e5+3;
int main()
{
    ft
    int t,i,j,n,m,l,r,x,y;
    cin>>x>>y>>l>>r;
    for(i=x;i<l;i++)
    {
        cout<<"R";
    }
    for(i=y;i<r;i++)
    {
        cout<<"U";
    }
    for(i=l;i>x;i--)
    {
        cout<<"L";
    }
    for(i=r;i>y;i--)
    {
        cout<<"D";
    }
    cout<<"D";
    for(i=x;i<l+1;i++)
    {
        cout<<"R";
    }
    cout<<"U";
    for(i=y;i<r;i++)
    {
        cout<<"U";
    }
    cout<<"LU";
    for(i=l;i>x-1;i--)
    {
        cout<<"L";
    }
    cout<<"D";
    for(i=r;i>y;i--)
    {
        cout<<"D";
    }
    cout<<"R\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}

class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

long long fact[100010];

int main(){
  fact[0]=fact[1]=1;
  for(int i=2;i<100010;i++){
    fact[i] = mod(fact[i-1]*i);
  }
  int n,m;
  cin>>n>>m;
  long long ans;
  if(m<n-1 || m>n+1){
    cout<<0<<endl;
    return 0;
  }
  if(m==n-1 || m==n+1){
    ans = mod(fact[m]*fact[n]);
  }else{
    ans = mod(mod(fact[m]*fact[n])*2);
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    long long L,R;
    cin >> L >>R;
    int ans = 2018;
    int check;
    if(R-L>=2019){
        ans = 0;
    }
    else{
        for(long long i=L;i<R;i++){
            for(long long j=L+1;j<=R;j++){
                check = (i*j)%2019;
                if(check <= ans){
                    ans = check;
                }
            }
        }
    }
    cout << ans <<endl;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n; cin >> n;
    vector<int> X1(n), Y1(n), X2(n), Y2(n);
    vector<int> X, Y;
    for (int i = 0; i < n; i++) {
        cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
        X.push_back(X1[i]);
        X.push_back(X2[i]);
        Y.push_back(Y1[i]);
        Y.push_back(Y2[i]);
    }

    sort(X.begin(), X.end()); X.erase(unique(X.begin(), X.end()), X.end());
    sort(Y.begin(), Y.end()); Y.erase(unique(Y.begin(), Y.end()), Y.end());

    int xs = X.size(), ys = Y.size();

    vector<vector<int>> imos(xs, vector<int>(ys, 0));
    for (int i = 0; i < n; i++) {
        int x1 = lower_bound(X.begin(), X.end(), X1[i]) - X.begin();
        int y1 = lower_bound(Y.begin(), Y.end(), Y1[i]) - Y.begin();
        int x2 = lower_bound(X.begin(), X.end(), X2[i]) - X.begin();
        int y2 = lower_bound(Y.begin(), Y.end(), Y2[i]) - Y.begin();

        imos[x1][y1]++;
        imos[x1][y2]--;
        imos[x2][y1]--;
        imos[x2][y2]++;
    }

    for (int i = 0; i < xs; i++) {
        for (int j = 1; j < ys; j++) {
            imos[i][j] += imos[i][j - 1];
        }
    }
    for (int i = 1; i < xs; i++) {
        for (int j = 0; j < ys; j++) {
            imos[i][j] += imos[i - 1][j];
        }
    }
    
    ll ans = 0;
    for (int i = 0; i < xs - 1; i++) {
        for (int j = 0; j < ys - 1; j++) {
            if (imos[i][j]) ans += (ll)(X[i + 1] - X[i]) * (Y[j + 1] - Y[j]);
        }
    }

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



Measured memory_bytes: 65624
#include <iostream>

using namespace std;

int combination(int n, int k){
  int c[n+1][n+1];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(i==j || j==0) c[i][j] = 1;
      else if(j>i){
        c[i][j] = 0;
      }
      else c[i][j] = c[i-1][j-1] + c[i-1][j];
      // cout << c[i][j] << " "; //DEBUG
    }
    // cout << endl; //DEBUG
  }
  if(n >= k) return c[n][k];
  else return 0;
}

int main(){
  int N,M;
  cin >> N >> M;
  // cout << combination(N,M) << endl; //DEBUG
  cout << combination(N,2) + combination(M,2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	bool ok = true;
	while(n--){
		int x;
		cin >> x;
		
		if(x % 2 == 0){
			if(x % 3 && x % 5)
				ok = false;
		}
	}
	
	cout << (ok ? "APPROVED" : "DENIED") << endl;

	return 0;
}


Measured memory_bytes: 256
n, k = [int(x) for x in input().split()]
a_list = [int(x) - 1 for x in input().split()]
ci = 0
while k:
    if k & 1:
        ci = a_list[ci]
    k >>= 1
    a_list = [a_list[a_list[i]] for i in range(n)]
print(ci + 1)

Measured memory_bytes: 32160
using System;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var c = Enumerable.Range(arr[0], arr[1] - arr[0] + 1).Where(e => arr[2] % e == 0).Count();

            Console.WriteLine(c);
        }
    }
}



Measured memory_bytes: 18456
#include <bits/stdc++.h>
using namespace std;
const int N = 3000;
double p[N], dp[N][N];
int n;
double calc(int idx, int head) {
	if (idx >= n) {
		if (head > n - head)
			return 1;
		return 0;
	}
	double &ret = dp[idx][head];
	if (ret != -1)
		return ret;
	ret = calc(idx + 1, head + 1)*p[idx] + calc(idx + 1, head)*(1 - p[idx]);
	return ret;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			dp[i][j] = -1;
	cout.precision(10);
	cout << calc(0, 0) << endl;
	return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
int a[100005];

int32_t main(){
	fast;
	int n,m;
	cin >> n >> m;
	
	int wa = 0 , ac = 0;
	int a[n+1] = {0};
	int b[n+1] = {0};
	for(int i=0 ; i<m ; i++)
	{
		int p;
		string v;
		cin >> p >> v;
		if(a[p])
			continue;
		if(v == "WA")
			b[p]++;
		else
			a[p]++;
	}
	for(int i=1 ; i<=n ; i++)
	{
		if(a[i])
			ac++ , wa += b[i];
	}
	
	cout << ac << " " << wa;
}



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int N,Y;
    int x=-1,y=-1,z=-1;
    
    cin >> N >> Y;
    
    bool can = false;
    
    int sum = 0;
    
    for(x=0;x<=N;x++){
        for(y=0;y<=N;y++){
            z = N - (x + y);
            if(z>=0) sum = 10000*x + 5000*y + 1000*z;
            if(sum==Y){
                can = true;
                break;
            } 
        }
        if(can) break;
    }
    
    if(can) cout << x << " " << y << " " << z;
    if(!can) cout << "-1" << " " << "-1" << " " << "-1";
    return 0;
 
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, m;
    cin >> n >> m;

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

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		double[] x = new double[n];
		for (int i = 0; i < n; i++) {
			x[i] = scan.nextDouble();
		}

		double[] y = new double[n];
		for (int i = 0; i < n; i++) {
			y[i] = scan.nextDouble();
		}

		double p1_sum = 0;
		double p2_sum = 0;
		double p3_sum = 0;
		double p4_max = 0;
		for (int i = 0; i < n; i++) {
			double diff = Math.abs(x[i] - y[i]);
			p1_sum += diff;
			p2_sum += Math.pow(diff, 2);
			p3_sum += Math.pow(diff, 3);
			if (diff > p4_max) {
				p4_max = diff;
			}
		}

		System.out.println(p1_sum);
		System.out.println(Math.sqrt(p2_sum));
		System.out.println(Math.cbrt(p3_sum));
		System.out.println(p4_max);

	}

}



Measured memory_bytes: 29016
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    string s;
    int n;
    cin>>n>>s;
    n %= 26;
    f(i,s.length()){
        s[i] = ('A' + (((s[i] - 'A') + n) % 26));
    }
    cout<<s;
}


int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

int main(){
  int n,d,x,a[101];
  cin>>n>>d>>x;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  int num=0;
  for(int i=1;i<=n;i++){
    num+=(d-1)/a[i]+1;
  }
  cout<<num+x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll a[n];
    rep(i, 0, n){
        cin >> a[i];
    }

    ll ans = 0;
    rep(i, 0, n - 1){
        if(a[i] % 2 == 0){
            ans += a[i] / 2;
        }else{
            if(a[i + 1] != 0){
                ans += a[i] / 2 + 1;
                a[i + 1]--;
            }else{
                ans += a[i] / 2;
            }
        }
    }

    ans += a[n - 1] / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}


signed main()
{
    hello();
    
    int n;
    cin >> n;
    int maxx = 0;
    map <string, int> cnt;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        cnt[s]++;
        maxx = max(maxx, cnt[s]);
    }

    for (auto i : cnt)
        if (i.S == maxx)
            cout << i.F << endl;
}

Measured memory_bytes: 23808
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  long long H;
  int N;
  scanf("%lld",&H);
  scanf("%d",&N);
  std::vector<int > A(N);
  long long sum = 0;
  for (int i=0; i<N; i++){
    scanf("%d",&A[i]);
    sum += A[i];
  }
  if (sum>=H){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
	int n;
	cin>>n;
	int x[n],y[n];
	priority_queue<int,vector<int>,greater<int> >A,B;
	r(i,n){
		int x;
		cin>>x;
		if(x<0)B.push(x);
		else A.push(x);
	}
	vector<P>V;
	if(A.size() && B.size()){
		while(A.size()!=1){
			int a=A.top();A.pop();
			int b=B.top();B.pop();
			V.push_back(P(b,a));
			B.push(b-a);
		}
		while(!B.empty()){
			int a=A.top();A.pop();
			int b=B.top();B.pop();
			V.push_back(P(a,b));
			A.push(a-b);
		}
		cout<<A.top()<<endl;
		r(i,n-1)cout<<V[i].F<<' '<<V[i].S<<endl;
	}
	else if(A.empty()){
		int a[n];
		r(i,n){
			a[n-i-1]=B.top();
			B.pop();
		}
		int sum=a[n-1];
		r(i,n-1){
			//cout<<sum<<endl;
			if(!i)V.push_back(P(a[i],sum)),sum=a[i]-sum;
			else V.push_back(P(sum,a[i])),sum-=a[i];
			//cout<<sum<<endl;
		}
		cout<<sum<<endl;
		r(i,n-1)cout<<V[i].F<<' '<<V[i].S<<endl;
	}
	else{
		if(A.size()==2){
			int a=A.top();A.pop();
			int b=A.top();
			cout<<b-a<<endl;
			cout<<b<<' '<<a<<endl;
			return 0;
		}
		int a[n];
		r(i,n){
			a[i]=A.top();
			A.pop();
		}
		int sum=a[n-1];
		r(i,n-2){
			//cout<<sum<<endl;
			if(!i)V.push_back(P(a[i],sum)),sum=a[i]-sum;
			else V.push_back(P(sum,a[i])),sum-=a[i];
			//cout<<sum<<endl;
		}
		V.push_back(P(a[n-2],sum));
		sum=a[n-2]-sum;
		cout<<sum<<endl;
		r(i,n-1)cout<<V[i].F<<' '<<V[i].S<<endl;
	}
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    int N, M; cin >> N >> M;
    vi p(M);
    vector<string> S(M);
    vi cnt_ac(N+1, 0), cnt_wa(N+1, 0);
    for(int i=0; i<M; i++){
        cin >> p[i] >> S[i];
        if(S[i] == "AC") cnt_ac[p[i]]++;
        else if(cnt_ac[p[i]] == 0) cnt_wa[p[i]]++;
    }
    int res_ac=0, res_wa=0;
    for(int i=1; i<=N; i++){
        if(cnt_ac[i] >= 1){
            res_ac++;
            res_wa+=cnt_wa[i];
        }
    }
    cout << res_ac << " " << res_wa << endl;
    return 0;
}

Measured memory_bytes: 6912
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#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 bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
void solve(){
    int n,x;
    cin>>x>>n;
    vector<bool>mark(110);
    rep(i,n){
        int a;
        cin>>a;
        mark[a]=1;
    }
    int mini=highest(int),ans=-1;
    rep1(i,0,110){
        if(!mark[i]){
            int val=abs(i-x);
            if(val<mini){
                mini=val;
                ans=i;
            }
        }
    }
    cout<<ans<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3652
X,Y=map(str,input().split())
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']
A_number=0
B_number=0
for i in range (len(alphabet)):
    if alphabet[i]==X:
        A_number=i
    if alphabet[i]==Y:
        B_number=i

if A_number>B_number:
    print ('>')
elif A_number<B_number:
    print ('<')
else:
    print ('=')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define INF (long long) (1e15)
using namespace std;

vector<long long> dijkstra(vector<vector<pair<int, long long>>>& next, int s) {
    int n = next.size();
    vector<long long> dist(n, INF);
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
    dist[s] = 0;
    pq.push(make_pair(0, s));
    while (pq.size()) {
        int u = pq.top().second;
        pq.pop();
        for (auto t: next[u]) {
            int v = t.first;
            long long alt = dist[u] + t.second;
            if (dist[v] > alt) {
                dist[v] = alt; 
                pq.push(make_pair(alt, v));
            }
        }
    }
    return dist;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    vector<vector<pair<int, long long>>> A(n), B(n);
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        A[u].push_back(make_pair(v, a));
        A[v].push_back(make_pair(u, a));
        B[u].push_back(make_pair(v, b));
        B[v].push_back(make_pair(u, b));
    }
    vector<long long> fromS = dijkstra(A, s), fromT = dijkstra(B, t), ans(n + 1, INF);
    for (int i = n - 1; i >= 0; i--) {
        ans[i] = min(ans[i + 1], fromS[i] +  fromT[i]);
    }
    for (int i = 0; i < n; i++) {
        cout << INF - ans[i] << endl;
    }

    

}


Measured memory_bytes: 19016
#include <iostream>

using namespace std;

int main() {
    unsigned long long A, B, N, first, second, max = 0;
    cin >> A >> B >> N;

    if (N < B) {
        max =  A * N / B;
    } else {
        first = A * (B - 1) / B;
        second = (B - 1) / B;
        max =  first - A * second;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);

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

  return 0;
}
  

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pr make_pair
#define fi first
#define se second
const int MAX_N = 1e5 + 5;
typedef long long ll;
vector<pair<ll, ll> > v;
ll mx[MAX_N], rmx[MAX_N];
int main() {
    int n;
    ll C, x, y, sum = 0, prv = 0, ans = 0;
    scanf("%d%lld", &n, &C);
    for (int i = 1; i <= n; i++) {
        scanf("%lld%lld", &x, &y);
        v.pb(pr(x, y));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        sum += (v[i].se - (v[i].fi - prv));
        mx[i + 1] = max(sum, mx[i]);
        rmx[i + 1] = max(sum - v[i].fi, rmx[i]);
        //printf("sum[%d] = %lld, mx[%d] = %lld, rmx[%d] = %lld\n", i, sum, i, mx[i + 1], i, rmx[i + 1]);
        ans = max(ans, sum);
        //printf("%d : %lld\n", i, ans);
        prv = v[i].fi;
    }
    sum = 0, prv = 0;
    for (int i = n - 1; i >= 0; i--) {
        sum += v[i].se - (C - v[i].fi - prv);
        //printf("sum[%d] = %lld\n", i, sum);
        ans = max(ans, sum);
        //printf("ans1[%d] = %lld\n", i, sum);
        ans = max(ans, sum - (C - v[i].fi) + mx[i]);
        //printf("ans2[%d] = %lld\n", i, sum - (C - v[i].fi) + mx[i]);
        ans = max(ans, sum + rmx[i]);
        //printf("ans3[%d] = %lld\n", i, sum + rmx[i]);
        prv = C - v[i].fi;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    for(ll i=0; i<n; i++){
        if(a[i]-1 == i){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <cmath>
#include <string>

using namespace std;

long long max(long long a,long long b) {
    if(a > b)
        return a;
    else
        return b;
}

long long min(long long a,long long b) {
    if(a < b)
        return a;
    else
        return b;
}

long long max_mp(long long x,long long y,long long f) {
    long long k = ((-1) * x + y + f + 1) / 2;
    k = max(0,min(y-x,k));
    return (x + k) * (y + f - k);
}

long long max_k(long long a,long long b) {
    if(a == 0)
        return 0;
    pair<long long,long long> r;
    r.first = 0;
    r.second = a - 1;
    while(r.second - r.first > 1) {
        long long mid = (r.first + r.second) / 2;
        if(max_mp(1, mid, b) < a * b)
            r.first = mid;
        else
            r.second = mid;
    }
    if(max_mp(1, r.second, b) < a * b)
        r.first = r.second;
    else
        r.second = r.first;
    return r.first;
}

long long solve(long long a,long long b) {
    long long ret = 0,x = max_k(a,b),y = max_k(b, a);
    ret = x + y + min(a - x - 1,b - y - 1);
    return ret;
}

int main(void) {
    long long q,a,b;
    cin >> q;
    for(long long i = 0;i < q;i++) {
        cin >> a >> b;
        cout << solve(a, b) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
num_R = 0
for i in range(n):
    if s[i]=='R':
        num_R+=1
s_sort = ['R' if i<num_R else 'W' for i in range(n)]
ans = 0
for i in range(n):
    if s[i]=='W' and s_sort[i]=='R':
        ans += 1
    
print(ans)

Measured memory_bytes: 87104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int BIT[1000000];
void add(int A, int B) {
	while (A <= 1000000) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}

int query(int A) {
	int kotae = 0;
	while (A > 0) {
		kotae = max(kotae, BIT[A]);
		A -= A & -A;
	}
	return kotae;
}

int N;
int B[1000000];
pair<pair<int, int>, pair<int, int>> memo[1000000];
pair<pair<int, int>, pair<int, int>> keisan(int A) {
	if (memo[A].first.first != 0) return memo[A];
	if (A == 0) memo[0] = mp(mp(B[0], 0), mp(0, 0));
	else {
		set<pair<int, int>> V;
		V.insert(mp(B[A], A));
		rep(i, N) {
			if (A >> i & 1) {
				auto p = keisan(A - (1 << i));
				V.insert(p.first);
				V.insert(p.second);
			}
		}
		memo[A] = mp(*(--V.end()), *(--(--V.end())));
	}
	return memo[A];
}


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


	cin >> N;
	rep(i, 1 << N) cin >> B[i];

	rep1(i, (1 << N) - 1) {
		auto p = keisan(i);
		add(i, p.first.first + p.second.first);
		co(query(i));
	}

	Would you please return 0;
}

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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    double sum = 0, p, tmp;
    for(int i = 1; i <= n; i++)
    {
        if(i > m)
        {
            sum += 1;
        }
        else
        {
            tmp = ceil( log2( (float)m/i ) );
            sum += pow(2, (-1)*tmp);
        }
    }
    cout << setprecision(10) << (sum/n);
}


Measured memory_bytes: 256
alp=["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","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"]

n=int(input())
s=list(input())

for i in range(len(s)):
    s[i]=alp[alp.index(s[i])+n]

print(("".join(s)).upper())

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

using namespace std;

int main()
{
  int a[3];
  int cnt = 0;
  for(int i = 0; i < 3; i++) {
    cin >> a[i];
    bool flag = false;
    for(int j = 0; j < i; j++) flag |= (a[i] == a[j]);
    if(!flag) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
H, W, D = gets.chomp.split(" ").map(&:to_i)
A = Array.new(H*W+1)
H.times{|i|
  tmp = gets.chomp.split(" ").map(&:to_i)
  W.times{|j|
    A[tmp[j]] = [i, j]
  }
}
M = Array.new(H*W+1)
(H*W-D+1..H*W).each{|i| M[i] = 0}
(H*W-D).downto(1){|i|
  M[i] = M[i+D] + (A[i+D][0] - A[i][0]).abs + (A[i+D][1] - A[i][1]).abs
}

gets.to_i.times{
  l, r = gets.chomp.split(" ").map(&:to_i)
  puts M[l] - M[r]
}


Measured memory_bytes: 11644
import math

lh, lm, h, m = (int(i) for i in input().split())
ang1 = 360 / 12 * h + (30 / 60) * m
ang2 = 360 / 60 * m
ang = abs(ang1 - ang2)
#print(ang)
ang = ang / 360 * 2 * math.pi
#print(ang)
sq = lh**2 + lm**2 - 2 * lh * lm * math.cos(ang)
print(math.sqrt(sq))


Measured memory_bytes: 61952
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <map>
#include <set>
#include <algorithm>
#include <stack>

using namespace std;

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vll> vvl;
typedef pair<ll, ll> pll;
typedef pair<string, ll> psl;
typedef vector<psl> vpsl;
typedef vector<pll> vpl;
typedef unordered_set<ll> usl;
typedef set<ll> sl;
typedef unordered_map<ll, ll> uml;
typedef map<ll, ll> ml;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

#define all(v) v.begin() , v.end()
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll inf = 1e9 + 7;
const double pie = 3.14159265358979323846;
const char nl = '\n';

template<typename Type>
istream &operator>>(istream &in, vector<Type> &v)
{
    ll n = v.size();
    for (int i = 0; i < n; i++)
        in >> v[i];
    return in;
}

template<typename Type>
ostream &operator<<(ostream &out, vector<Type> &v)
{
    for (auto value : v)
        out << value << " ";
    out << endl;
    return out;
}

void solve()
{
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    vvl dp(n + 1, vll(m + 1, 0));
   for (ll i = 0; i < n; ++i)
   {
       for (ll j = 0; j < m; ++j)
       {
           if (s[i] == t[j])
               dp[i + 1][j + 1] = dp[i][j] + 1;
           else
               dp[i + 1][j + 1] = max (dp[i + 1][j], dp[i][j + 1]);
       }
   }
//    for (const auto& v : dp)
//    {
//        for (ll i : v)
//            cout << i << ' ';
//        cout << nl;
//    }
    string LCS;
    ll i = n, j = m;
    while (i > 0 and j > 0)
    {
        ll k = max({dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]});
        if (dp[i][j] > k)
        {
            LCS.push_back(t[j - 1]);
            --i, --j;
        }
        else
            k == dp[i][j - 1] ? --j : --i;
    }
    reverse(all(LCS));
    cout << LCS << nl;
}

int main()
{
    IOS
    ll t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
  int A=0, B=0, C=0;
  cin >> A >> B >> C;
  
  string ans = "NO";
  if (A == 5) {
	if (B == 7 && C == 5) {
      ans = "YES";
    }
    else if (B == 5 && C == 7) {
      ans = "YES";
    }
  }
  else if (A == 7) {
    if (B == 5 && C == 5) {
      ans = "YES";
    }
  }
  
  cout << ans << endl;  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int a,b,c,d,e,f;
int tot1=0,tot2=0,now1,now2;
int main()
{
	a=read(),b=read(),c=read(),d=read(),e=read(),f=read();
	now1=0,now2=0;
	tot1=100*a;
	for (int i=0;i<=f/(100*a);i++)
		for (int j=0;j<=f/(100*b);j++)
			if (i+j>0&&i*100*a+j*100*b<=f)
			{
				for (int x=0;x<=(f-i*100*a-j*100*b)/c;x++)
					for (int y=0;y<=(f-i*100*a-j*100*b)/d;y++)
						if (x*c+y*d+i*100*a+j*100*b<=f&&x*c+y*d<=e*(i*a+j*b))
						{
							if ((double)(x*c+y*d)/(i*a*100+j*b*100+x*c+y*d)>(double)tot2/tot1)
							{
								tot1=i*a*100+j*b*100+x*c+y*d;
								tot2=x*c+y*d;
							}
						}
			}
	printf("%d %d\n",tot1,tot2);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 30;
const int N = (int)3e5 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int ans = 0, arr[N];
int n, m, q, a[N], b[N], c[N], d[N];

void rec(int len, int elem) {
	if (len == n) {
		int score = 0;
		for (int i = 0; i < q; i++) {
			if (arr[b[i]] - arr[a[i]] == c[i])
				score += d[i];
		}
		uax(ans, score);
		return;
	}
	for (int i = elem; i <= m; i++) {
		arr[len] = i;
		rec(len + 1, i);
	}
}

void solve() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--, b[i]--;
	}
	rec(0, 1);
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3628
n = int(input())
a = [None] * n
for i in range(n):
    num = int(input())
    a[i] = [list(map(int,input().split())) for _ in range(num)]

def check(i, bit_):
    com = a[i]
    for xy in com:
        x,y = xy
        if( (bit_ >> (x-1))&1 != y ):
            return 0
    return 1

ans = 0
for i in range(2**n):
    c_num = 1
    honest = 0
    for j in range(n):
        if( (i>>j)&1 == 1 ):
            honest += 1
            c_num *= check(j, i)
    if(c_num == 0):
        continue

    ans = max(ans, honest)

print(ans)

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

int main() {
	long long int n; cin>>n;
	double d; cin>>d;
	int count=0;
	for(int i=0;i<n;i++){
		long long int x,y; cin>>x>>y;
		double distt = sqrt((x*x)+(y*y));
		if(distt<=d) count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3744
#include <cstdio>
using namespace std;

int main() 
{
	int a, b, c, k;
	scanf("%d%d%d%d", &a, &b, &c, &k);
	if (k <= a) printf("%d\n", k);
	else if (k <= a + b) printf("%d\n", a);
	else printf("%d\n", 2 * a - k + b);
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)

int main() {
    int n;
    cin >> n;
    vector<int> t(n+1), x(n+1), y(n+1);
    t[0] = x[0] = y[0] = 0;
    rep1(i,n) {
        cin >> t[i] >> x[i] >> y[i];
    }
    rep(i,n) {
        int d = abs(x[i]-x[i+1])+abs(y[i]-y[i+1]);
        int surp = t[i+1]-t[i]-d;
        // cout << surp << endl;
        if (surp < 0 || abs(surp)%2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int a,b,c,k; cin >> a >> b >> c >> k;
	int64 ans = 0;
	int cnt = 0;
	for (int i = 1; i <= a; ++i) {
		ans++;
		cnt++;
		if (cnt >= k) {
			cout << ans << endl;
			return;
		}
	}
	for (int i = 1; i <= b; ++i) {
		cnt++;
		if (cnt >= k) {
			cout << ans << endl;
			return;
		}
	}
	for (int i = 1; i <= c; ++i) {
		ans--;
		cnt++;
		if (cnt >= k) {
			cout << ans << endl;
			return;
		}
	}
	return;
}
int main() {
	solve();
	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int64_t lo = 0, hi = 1e8, X;
	cin >> X;
	while (lo < hi) {
		int64_t mid = (lo+hi)/2;
		int64_t sum = mid*(mid+1)/2;
		if (sum < X) {
			lo = mid+1;
		} else {
			hi = mid;
		}
	}
	cout << lo << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s[50];
 int n;
 cin>>n;
 cin>>s[0];
 int a=0,b=s[0].size();

 for(int i=1;i<n;i++){
  cin>>s[i];
  if(b>s[i].size())a=i;
 }

 int vc[26]={};
 for(int i=0;i<s[a].size();i++)vc[(int)(s[a][i])-97]++;

 for(int i=0;i<26;i++)
  if(vc[i]!=0){
   char ch=(char)(i+97);
   int min=vc[i];
   for(int k=1;k<n;k++){
    int count=0;
    for(int j=0;j<s[k].size();j++)
     if(s[k][j]==ch)count++;
    if(min>count)min=count;
   }
   vc[i]=min;
  }

 for(int i=0;i<26;i++)
  if(vc[i]!=0)
   for(int j=0;j<vc[i];j++)cout<<(char)(i+97);
 cout<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, k, x, sum = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        sum += min(x*2, (k-x)*2);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long P=1000000007;
int main(){
  long N;cin>>N;string S;cin>>S;
  vector<long>A(26,1);
  for(char c:S)A[c-97]++;
  long ans=1;
  for(long x:A)ans=(ans*x)%P;
  cout<<(ans-1+P)%P;
}

Measured memory_bytes: 3696
A, B = map(int, input().split())

r = 0
def F(n):
	ec = (n + 1) // 2
	r = ec % 2
	if not n % 2:
		r ^= n
	return r
"""
def F2(n):
	r = 0
	for i in range(n + 1):
		r ^= i
	return r
"""
#print("{:04b}".format(F2(4)))
print(F(A - 1) ^ F(B))


Measured memory_bytes: 3060
S = list(input())
dp = [[0]*13 for j in range(len(S)+1)]
dp[0][0] = 1
mod = 10**9 + 7
k = 1
for i, s in enumerate(S[::-1]):
    if s == '?':
        for c in range(10):
            for j in range(13):
                dp[i+1][(k*c+j) % 13] += dp[i][j] % mod
    else:
        c = int(s)
        for j in range(13):
            dp[i+1][(k*c+j) % 13] += dp[i][j] % mod
    k = k * 10 % 13
print(dp[-1][5] % mod)


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

int main(){
  string S;
  cin >> S;
  string hi = "hi";
  string res = hi;
  for(int i=0; i<10; i++){
    if(res==S){
      cout << "Yes" << endl;
      return 0;
    }
    res = res + hi;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
int main()
{
    long N;
    long long power = 1;
   
    
    scanf("%d", &N);

    for (int i = 1; i <= N; i++) {
        power = power*i % (10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7);
    }

    printf("%lld",power);

    return 0;
}

Measured memory_bytes: 2140
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int maxs(int &a,int b){
  if(a<b){
    a = b;
    return 1;
  }else if(a==b){
    return 2;
  }else{
    return 0;
  }
}
signed main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> t;
  char last = s[0];
  int conti = 1;
  if(s[0]=='0') t.eb(0);
  FOR(i,1,n){
    if(last==s[i]){
      conti++;
    }else{
      t.eb(conti);
      conti = 1;
      last = s[i];
    }
  }
  t.eb(conti);
  if(t.size()%2==0) t.eb(0);
  int ans = 0;
  int sum = t[0];
  if((int)(t.size()-1)/2<k){
    cout << accumulate(ALL(t),0) << endl;
    return 0;
  }
  REP(i,k){
    sum += t[2*i+1] + t[2*i+2];
  }
  ans = sum;
  int l = 0,r = 2*k+1;
  while(r<(int)t.size()){
    sum -= t[l]+t[l+1];
    sum += t[r]+t[r+1];
    l += 2;
    r += 2;
    ans = max(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1020
# -*- coding: utf-8 -*-
import sys

def main():
	N, K = map(int, input().split(" "))
	H = input().split(" ")
	H = [int(s) for s in H]
	
	DP = [-1 for _ in range(N)]
	DP[0] = 0
	
	for i in range(1, len(H)):
		paths = [DP[j] + abs(H[j] - H[i]) for j in range(max(0, i-K), i)]
		DP[i] = min(paths)
		
	print(DP[N-1])
		
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 13980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		System.out.println((a-b*2>=0)? a-b*2:"0");
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> b[i];
    }
    int total = 0, maxim = 0, c, d;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= i; ++j){
            total += a[j];
        }
        for(int l = i; l < n; ++l){
            total += b[l];
        }if(total > maxim){
            maxim = total;
            total = 0;
        }else{
            total = 0;
        }
    }
cout << maxim  << "\n";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    while(getline(cin,s)&&s!="."){
        string c;
        for(int i=0;i<s.size();i++)if(s[i]==')'||s[i]=='('||s[i]=='['||s[i]==']')c+=s[i];
        stack<char> s;
        int f=1;
        for(int i=0;i<c.size();i++){
            if(s.empty()||c[i]=='('||c[i]=='[')s.push(c[i]);
            else if((s.top()=='('&&c[i]==')')||(s.top()=='['&&c[i]==']'))s.pop();
            else {f=0;break;}
        }
        if(s.empty())cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

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

using namespace std;



int main(int argc, char* argv[])
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;

  vector<int> x(N+1);
  for (int& xi : x) cin >> xi;
  sort(x.begin(), x.end());

  int res = 0;
  for (int i = 1; i <= N; ++i)
    res = __gcd(res, x[i] - x[i-1]);
  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 640
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int gcd_all(vi &A){int g = 0; for(int a:A) g = gcd(g, a);return g;}

int sum_array(vi &C, int start, int end, int step){
	int c = 0;
	for(int j=start; j<end; j+=step) c += C[j];
	return c;
}

bool is_pairwise(vi &A){
	int MAX_A = 1000000 + 1;
	vi C(MAX_A, 0); for(int a:A) C[a]++;
	if(sum_array(C, 2, MAX_A, 2) > 1) return false;
	for(int i=3; i<MAX_A; i+=2)
		if(sum_array(C, i, MAX_A, i) > 1) return false;
	return true;
}

int solve(vi &A){
	if(is_pairwise(A)) return 0;
	if(gcd_all(A) == 1) return 1;
	return 2;
}

int main(){
	int N; cin>>N;
	vi A(N); for(int i=0; i<N; ++i) cin>>A[i];
	cout<< vector<string>{"pairwise","setwise","not"}[solve(A)] <<" coprime\n";
}


Measured memory_bytes: 11088
n = int(input())
a = sorted([int(item) for item in input().split()], reverse=True)

l = 0
edge = []
while l < n-1:
    if a[l] == a[l+1]:
        edge.append(a[l])
        l += 2
    else:
        l += 1
    if len(edge) >= 2:
        break
if len(edge) >= 2:
    print(edge[0] * edge[1])
else:
    print(0)

Measured memory_bytes: 14252