akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

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

    map<int, int> mp;

    int n;
    cin>>n;

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

    if (mp.size() == 1 && mp.count(0))  cout<<"Yes"<<endl;
    else if (n%3)                       cout<<"No"<<endl;
    else if (mp.size() == 2) {
        if (mp[0] == n/3)               cout<<"Yes"<<endl;
        else                            cout<<"No"<<endl;
    }
    else if (mp.size() == 3) {
        bool good = true;
        int xoor = 0;
        for (auto pr: mp) {
            if (pr.second != n/3)       good = false;
            xoor ^= pr.first;
        }

        if (good && xoor == 0)         cout<<"Yes"<<endl;
        else                           cout<<"No"<<endl;

    }
    else                                cout<<"No"<<endl;


}




Measured memory_bytes: 3840
from collections import defaultdict

N = int(input())
P = [[] for _ in range(N)]
AB = defaultdict(int)

for _ in range(N-1):
  a, b = map(lambda x: int(x)-1, input().split())
  P[a].append(b)
  P[b].append(a)
  AB[(a, b)] = -1

C = [-1] * N

def bfs(s):
    d = [-1] * N
    d[s] = 0
    p_old = [s]
    K = -1
    while p_old:
      p_new = []
      for i in p_old:
        c = 1
        for j in P[i]:
          if d[j] != -1:
            continue
          if C[i] == c:
            c += 1
          d[j] = 0
          p_new.append(j)
          C[j] = c
          AB[(i, j)] = c
          K = max(K, c)
          c += 1
      p_old = p_new
    return K

print(bfs(0))

for x in AB.values():
  print(x)


Measured memory_bytes: 39696
n,a,b=map(int,input().split())
mod=10**9+7


def Combi2(a,b):# aは大きいが、bは小さいとき
    if b>a:
        return 0
    ANS=1
    for i in range(min(b,a-b)):
        ANS=ANS*(a-i)*pow(min(b,a-b)-i,mod-2,mod)%mod

    return ANS%mod

ANS=pow(2,n,mod)-1
ANS-=Combi2(n,a)
ANS-=Combi2(n,b)
print(ANS%mod)


Measured memory_bytes: 3060
#include<stdio.h>

/* ??????????????? (0????????????)*/
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, minj;
  for ( i = 0; i < N - 1; i++ ) {
    minj = i;
    for ( j = i; j < N; j++ ) {
      if ( A[j] < A[minj] ) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if ( i != minj ) sw++;
  }
  return sw;
}

int main() {
  int A[100], N, i, sw;
  
  scanf("%d",&N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
  
  sw = selectionSort(A, N);
  
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);
  
  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  int m = min(A, B);
  vi a;
  FOR(i, 1, m + 1) {
    if (!(A % i) && !(B % i)) a.push_back(i);
  }
  sort(allg(a));

  cout << a[K - 1] << endl;
}

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

int main() {
  string w;
  cin >> w;
  int count;
  count = 0;
  for  (int i=0; i<w.size(); i++){
    for (int j=0; j<w.size(); j++){
      if (w.at(i)==w.at(j)){
        count++;
      }
    }
    if (count%2==1){
      break;
    }
    count = 0;
  }
  if (count!=0){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3592
A = []
3.times{
  A << gets.chomp.split(" ").map(&:to_i)
}
B = []
gets.to_i.times{
  b = gets.to_i
  A.map!{|a|
    a.map{|aa|
      aa == b ? 0 : aa
    }
  }
}

ans = 'No'
ans = 'Yes' if A[0][0] == 0 && A[0][1] == 0 && A[0][2] == 0
ans = 'Yes' if A[1][0] == 0 && A[1][1] == 0 && A[1][2] == 0
ans = 'Yes' if A[2][0] == 0 && A[2][1] == 0 && A[2][2] == 0
ans = 'Yes' if A[0][0] == 0 && A[1][0] == 0 && A[2][0] == 0
ans = 'Yes' if A[0][1] == 0 && A[1][1] == 0 && A[2][1] == 0
ans = 'Yes' if A[0][2] == 0 && A[1][2] == 0 && A[2][2] == 0
ans = 'Yes' if A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0
ans = 'Yes' if A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0

puts ans


Measured memory_bytes: 3836
def gcd(a, b):
    if b > a:
        tmp = a
        a = b
        b =tmp
    while b != 0:
        a, b = b, a % b
    return a

N = int(input())
A = list(map(int, input().split()))

L = [0 for i in range(N+1)]
for i in range(0,N):
    L[i + 1] = gcd(L[i], A[i])
    
R = [0 for i in range(N+1)]
for i in range(N,0,-1):
    R[i-1] = gcd(R[i],A[i-1]) 

ans = []
for i in range(1,N+1):
    ans.append(gcd(L[i - 1], R[i]))

print(max(ans))

Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

int main(){
    ll n,q;cin>>n>>q;
    ll a[n+2];rep(i,2,n+1)cin>>a[i];a[0]=-inf;a[1]=-inf;
    ll s[n+2],se[n+2];
    s[1]=0;se[1]=0;
    rep(i,2,n+1){
        s[i]=s[i-1]+a[i];
        if((n-i)%2==1)se[i]=se[i-1]+a[i];
        else se[i]=se[i-1];
    }
    rep(i,0,q-1){
        ll x;cin>>x;
        ll l=1,r=(n+1)/2;
        while(l<r){
            
            ll m=(l+r)/2;
            ll b=abs(x-a[n-2*m+1]);
            ll c=abs(a[n-m+1]-x);
            if(x<=a[n-2*m+1]){
                l=m+1;
            }else if(x>=a[n-m+1]){
                r=m;
            }else if(b<=c){
                l=m+1;
            }else{
                r=m;
            }
        }
        ll ans=s[n+1]-s[n-l+1];
        if(n-2*l+1>=1)ans+=se[n-2*l+1];
        cout<<ans<<endl;
    }
    return 0;
}






Measured memory_bytes: 4096
N,K = map(int, input().split())
A = list(map(int, input().split()))


#２整数の最大公約数を求める

def gcd2(x,y): 
	while y != 0:
		x , y = y , x % y 
	return x



#N 整数の最大公約数を求める
#A = [A[0],...,A[N]] とする

def gcd(A):
    ans = A[0]
    for i in range(1,N): #range(1,N)= 1,2,...,N-1
        ans = gcd2(ans, A[i])
    return ans



g = gcd(A)
M = max(A)

if (K<= M) and (K%g == 0):
    print("POSSIBLE")
else: print("IMPOSSIBLE")

Measured memory_bytes: 14224
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	h, a := getInt(), getInt()
	ans := (h + a - 1) / a
	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 1776
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int s;
    cin >> s;
    vector<vector<lli>> dp(s+1, vector<lli>(2, 0));
    dp[s][0] = 1;
    for(int len: a){
        for(int i=1; i<=s; i++){
            if(i-len <= 0) continue;
            for(int d=0; d<2; d++){
                dp[i-len][d] += dp[i][1-d];
                dp[i-len][d] %= mod;
            }
        }
    }
    vector<lli> v(s+1, 1);
    for(int i=1; i<=s; i++){
        for(int d=0; d<n; d++){
            v[i] *= i;
            v[i] %= mod;
        }
    }
    lli ans = 0;
    for(int i=1; i<=s; i++){
        for(int d=0; d<2; d++){
            ans += (1-2*d)* dp[i][d] *v[i] %mod;
            ans %= mod;
        }
    }
    ans = (ans + mod) %mod;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8320
# ABC080D - Recording
from itertools import accumulate as acc


def main():
    N, C, *STC = map(int, open(0).read().split())
    recorders = [[0] * (10 ** 5 + 1) for _ in range(C + 1)]
    for s, t, c in zip(*[iter(STC)] * 3):
        recorders[c][s - 1 : t] = [1] * (t - s + 1)
    ans = max(map(sum, zip(*recorders)))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 36508
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  a = a * b;
  c = c * d;
  if(a >= c){
    cout << a << "\n";
    return 0;
  }
  cout << c << "\n";
}


Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		long MOD=1_000_000_007;
		long[][][][] dp=new long[101][4][4][4];
		long sum=0;
		for(int i=0; i<=100; i++) {
			for(int j=0; j<4; j++) {
				for(int k=0; k<4; k++) {
					for(int l=0; l<4; l++) {
						dp[i][j][k][l]=0;	//初期化
					}
				}
			}
		}
		/*
		 * 0 A
		 * 1 T
		 * 2 G
		 * 3 C
		 */
		for(int i=0; i<4; i++) {
			for(int j=0; j<4; j++) {
				for(int k=0; k<4; k++) {
					dp[3][i][j][k]=1;
				}
			}
		}
		dp[3][0][2][3]=0;
		dp[3][0][3][2]=0;
		dp[3][2][0][3]=0;
		for(int i=4; i<=100; i++) {
			for(int a=0; a<4; a++) {
				for(int b=0; b<4; b++) {
					for(int c=0; c<4; c++) {
						for(int d=0; d<4; d++) {
							if(b==0 && c==2 && d==3) {
								continue;
							}
							if(b==0 && c==3 && d==2) {
								continue;
							}
							if(b==2 && c==0 && d==3) {
								continue;
							}
							if(a==0 && c==2 && d==3) {
								continue;
							}
							if(a==0 && b==2 && d==3) {
								continue;
							}
							if(a==0 && b==2 && c==3) {
								continue;
							}
							else {
								dp[i][b][c][d]+=dp[i-1][a][b][c];
								dp[i][b][c][d]%=MOD;
							}
						}
					}
				}
			}
		}
		for(int j=0; j<4; j++) {
			for(int k=0; k<4; k++) {
				for(int l=0; l<4; l++) {
					sum+=dp[N][j][k][l];
					sum%=MOD;
				}
			}
		}
		pl(sum);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 22228
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a=a-b;
    c=c-a;
    if(c<0)c=0;
    printf("%d\n",c);
    return 0;
    
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
int N,D;   
std::vector<std::vector<int> > xy;
bool distanceJud(int x,int y){
    int sum=0;
    for(int i = 0; i<D;i++){
        if(N!=1){
        sum+=abs(pow(xy[x][i]-xy[y][i],2));
        }
        else
        {
           sum+=abs(pow(xy[x][i]-0,2));
        }
        
    }
    sqrt(sum);
    if (ceil(sqrt(sum)) == floor(sqrt(sum))) {
        return true;
} else { return false;}
}
int main(){

    std::cin >> N >> D;

    for(int i = 0; i<N; i++){
        std::vector<int> tmp;
        for(int j = 0; j<D;j++){
            int t;
            std::cin>>t;
            tmp.push_back(t);
        }
        xy.push_back(tmp);
    }
    int cnt=0;
    for(int i = 0; i<N; i++){
        for(int j = i+1; j<N; j++){
       
            if(distanceJud(i,j))cnt++;
    }
    
    }
    std::cout<<cnt;
}

Measured memory_bytes: 888
S = input()
t = 0
H = [0]
for c in S:
    if c == '\\':
        t -= 1
        H.append(t)
    elif c == '_':
        H.append(t)
    elif c == '/':
        t += 1
        H.append(t)
L = [0 for _ in range(len(H))] 
for i in range(1, len(H)):
    L[i] = max(L[i-1], H[i])
R = [H[len(H)-1]]
for i in reversed(range(len(H)-1)):
    R.append(max(R[len(R)-1], H[i]))
R.reverse()
C = [min(L[i], R[i]) for i in range(len(H))]
D = 0
ans = []
for i in range(len(H)-1):
    D += (C[i] - H[i]) + (C[i+1] - H[i+1])
    if C[i+1] == H[i+1] and D != 0:
        ans.append(D // 2)
        D = 0
print(sum(ans))
ans.insert(0, len(ans))
print(' '.join(map(str, ans)))


Measured memory_bytes: 6968
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    string s;
    cin>>s;
    
    int cnt=0,num=0;
    int i;
    for(i=2;i<s.length()-1;++i)
       {
           if(s[i]=='C')
              { cnt++;
                 num=i;
              }
              
            if(cnt>1)
                break;
       }
       
    if(cnt!=1)
       printf("WA");
       
    else
     {
         if(s[0]=='A')
            {
                for(i=1;i<s.size();++i)
                   {
                       if(i!=num)
                         {
                             if(s[i]>='a' && s[i]<='z')
                                 continue;
                                 
                             else
                                break;
                         }
                   } 
                   
                  if(i==s.size())
                      printf("AC");
                      
                   else
                      printf("WA");
            }
            
            else
              printf("WA");
     }
   
         
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>

using namespace std;

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

#define MAX (300+10)

string s;
int dp[MAX][MAX];

string lcs(string a, string b){
  memset(dp, -1, 0);
  rep(i,a.size()+1) dp[i][0] = 0;
  rep(j,b.size()+1) dp[0][j] = 0;
  for(int i=1;i<=a.size();i++){
    for(int j=1;j<=b.size();j++){
      if(a[i-1] == b[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  
  // rep(i,a.size()+1) {
  //   rep(j,b.size()+1){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  
  string s = "";
  int i = a.size(), j = b.size();
  while(dp[i][j] != 0){
    if(a[i-1] == b[j-1]){
      s = s + a[i-1];
      i--; j--;
    }
    else if(dp[i][j] == dp[i-1][j]){
      i--;
    }
    else{
      j--;
    }
  }
  
  reverse(s.begin(), s.end());
  
  return s;
}

void solve(){
  string res = "";
  for(int i=1;i<s.size();i++){
    string a = s.substr(0, i);
    string b = s.substr(i, s.size()-i);
    string r = lcs(a, b);
    
    if(r.size() > res.size()) res = r;
  }
  
  cout << res << endl;
}

int main(){
  while(true){
    cin >> s;
    if(s == "#END") break;
    solve();
  }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

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

  int n;
  cin >> n;
  vi a(n),b(n);

  rep(i,n){
    int x,y;
    cin >> x >> y;
    a[i] = x + y;
    b[i] = x - y;
  }
  sort(all(a));
  sort(all(b));
  cout << max(abs(a[n-1] - a[0]),abs(b[n-1] - b[0])) << endl;
}

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

int main(){
  int n;
  string s, t;
  cin >> n >> s >> t;
  rep(i, n){
    cout << s[i] << t[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint a(n);
    rep(i, n) cin >> a[i];

    int mn = INF;
    int idx = -1;
    rep(i, n) {
        if (a[i] < mn) {
            idx = i;
            mn = a[i];
        }
    }

    --k;
    int l = idx;
    int ans = (l + (k - 1)) / k;
    int r = n-ans*k-1;
    ans += (r + (k - 1)) / k;

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

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

//参考: https://pyteyon.hatenablog.com/entry/2019/03/11/200000
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll find(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return find(x) == find(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[find(x)];
    }
};

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

    vector<pair<int,int>>AB(M);
    UnionFind uf(N);

    uf.init(N);

    for (int i=0; i<M; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.unite(x,y);

        AB[i] = {x,y};
    }

    ll ans = -INF;

    for (int i=0; i<N; i++){
        chmax(ans, uf.size(i) );
    } 
    cout << ans << endl;

}

Measured memory_bytes: 7924
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define PI 3.141592653

int main(){
    string A,B;
    int n,Ak,Bk,ans[81];
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        
        for(int j=0;j<80;j++){
            ans[j]=0;
        }
        
        cin >> A >> B;
        
        if(A==B && A=="0"){
            printf("0\n");
            continue;
        }
        
        Ak=(int)A.size();
        Bk=(int)B.size();
        
        if(Ak>80 || Bk>80){
            puts("overflow");
            continue;
        }
        
        for(int j=0;j<max(Ak,Bk);j++){
            if(j<min(Ak,Bk))
                ans[79-j]+=(A[Ak-1-j]-'0')+(B[Bk-1-j]-'0');
            else if(j<Ak)
                ans[79-j]+=A[Ak-1-j]-'0';
            else if(j<Bk)
                ans[79-j]+=B[Bk-1-j]-'0';
            
            if(ans[79-j]>=10){
                if(j==79){
                    break;
                }
                ans[79-j-1]++;
                ans[79-j]-=10;
            }
        }
        
        if(ans[0]>=10){
            puts("overflow");
        }else{
            bool f = false;
            for(int j=0;j<80;j++){
                if(ans[j]>0 || f){
                    printf("%1d",ans[j]);
                    f = true;
                }
            }
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 1252
#include<stdio.h>
#include<math.h>
long long int a[200012],value[200010];
int main ()
{
    long long int n,i,min,sum=0,sum2=0;
    scanf("%lld",&n);
    for(i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    for(i=1;i<n;i++){
        sum2+=a[n-i+1];
        value[i]=llabs(sum-sum2-sum2);
    }
    min=value[i-1];
    for(i=1;i<n;i++)
        if(value[i]<min)
            min=value[i];
    printf("%lld\n",min);
    return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long a,b,n;
    cin >> a >> b >> n;
    long long ans;
    ans=0;
    if(n>=b){
        ans = (b-1)*a/b;
    }else{
        ans = n*a/b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	int a[n+5];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	int sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
	}
	cout<<sum<<endl;
}

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

bool ok(vector< tuple< int, int > >& obj)
{
  int now = 0;
  for(auto v : obj) {
    if(now + get< 0 >(v) < 0) return(false);
    now += get< 1 >(v);
  }
  return(true);
}

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

  int last = 0;
  vector< tuple< int, int > > curr, revv;
  while(N--) {
    string S;
    cin >> S;

    int height = 0, cnt = 0;
    for(char c : S) {
      if(c == '(') ++cnt;
      else         --cnt;
      height = min(height, cnt);
    }
    int revheight = 0, revcnt = 0;
    reverse(S.begin(), S.end());
    for(char c : S) {
      if(c == ')') ++revcnt;
      else         --revcnt;
      revheight = min(revheight, revcnt);
    }
    if(cnt == 0) {
      last = min(last, height);
    } else if(cnt > 0) {
      curr.emplace_back(height, cnt);
    } else {
      revv.emplace_back(revheight, revcnt);
    } 
  }
  sort(curr.rbegin(), curr.rend());
  sort(revv.rbegin(), revv.rend());

  bool flag = ok(curr) & ok(revv);
  int csum = 0, rsum = 0;
  for(auto v : curr) csum += get< 1 >(v);
  for(auto v : revv) rsum += get< 1 >(v);
  flag &= csum == rsum;
  flag &= csum + last >= 0;
  
  if(flag) cout << "Yes" << endl;
  else     cout << "No"  << endl;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N, M, V, P;
  cin >> N >> M >> V >> P;
  vector<int> A(N);
  FOR(i, N) cin >> A[i];
  sort(ALL(A), greater<int>());
  int l = 0, r = N - P + 1;
  while (r - l > 1) {
    int m = l + (r - l) / 2;
    ll base = A[P - 1 + m] + M;
    ll used = M;
    ll out = 0;
    FOR(i, N) {
      if (i == P - 1 + m) continue;
      if (A[i] > base) {
        out++;
        used += M;
      } else {
        if (out < P - 1) {
          out++;
          used += M;
        } else {
          used += min((ll)M, base - A[i]);
        }
      }
    }
    if (out < P && used >= (ll)M * V) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << P + l << endl;
  return 0;
}

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

int main() {
    const int moneys[] = {1000, 500, 100, };
    while (true) {
        int a, b;
        cin >> a >> b;
        if ((a | b) == 0) {
            break;
        }
        int change = b - a;
        int changes[3] = {};
        for (int i = 0; i < 3; i++) {
            if (change / moneys[i] > 0) {
                changes[i] = change / moneys[i];
                change %= moneys[i];
            }
        }
        for (int i = 2; i >= 0; i--) {
            cout << changes[i];
            if (i > 0) {
                cout << " ";
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 0
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std; 
int main(){
  char x[52];
  for(int i='a';i<='z';i++){
    x[i-'a']=i;
  }
  for(int i='A';i<='Z';i++){
    x[26+i-'A']=i;
  }

int n;
  while(cin>>n,n!=0){
    int k[n];
    string s;
    for(int i=0;i<n;i++){
      cin>>k[i];
    }
    cin>>s;
    for(int i=0;i<s.size();i++){
      int b=distance(x,find(x,x+52,s[i])); 
      int c=(b-k[i%n]+52)%52;
      cout<<x[c];
    }
    cout<<endl;
  }
  return 0;
}

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

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pci pair<char,int>
 
using namespace std; 

vector<int> x[100001];

void dfs(v<int> &colors,int n,queue<int> &q,map<pii,ll> dist)
{
    while(!q.empty())
    {
        int temp = q.front();
        q.pop();
        if(colors[temp] != -1)
        {
            for(int i = 0 ; i < x[temp].size() ; i++)
            {
                if(colors[x[temp][i]] == -1)
                {
                    q.push(x[temp][i]);
                    if(dist[mp(temp,x[temp][i])]%2 == 0)
                    {
                        colors[x[temp][i]] = colors[temp];
                    }
                    else
                    {
                        if(colors[temp] == 1)
                        colors[x[temp][i]] = 0;
                        else
                        {
                            colors[x[temp][i]] = 1;
                        }
                        
                    }
                    
                }
                else
                {
                    continue;
                }
                
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    v<int> colors(n+1,-1);
    map<pair<int,int>,ll> dist;
    for(int i = 0 ; i < n-1 ; i++)
    {
        int a,b;
        ll c;
        cin>>a>>b>>c;
        x[a].pb(b);
        x[b].pb(a);
        dist[mp(a,b)] = c;
        dist[mp(b,a)] = c;
    }
    colors[1] = 0;
    queue<int> q;
    q.push(1);
    dfs(colors,n,q,dist);
    for(int i = 1 ; i <= n ; i++)
    cout<<colors[i]<<endl;
    return 0;
}

Measured memory_bytes: 31360
import numpy as np

n, m = map(int, input().split())

seikai = np.zeros(n)
matigai1 = np.zeros(n)
matigai2 = np.zeros(n)
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if seikai[p]==1:
        continue
    else:
        if s=='AC':
            seikai[p] = 1
            matigai2[p] = matigai1[p]

        else:
            matigai1[p] += 1

print(int(seikai.sum()), int(matigai2.sum()))

Measured memory_bytes: 14648
#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() {
    ll a,b,n;
    cin >> a >> b >> n;

    ll x = min(b-1, n);
    ll ans = a*x/b - a*(x/b);


    cout << ans << endl;




    return 0;
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

// 0:R????????°????????§???, 1:L????????°????????§???
int dp[2001][2001][2];

void calc(string s, int K)
{
    int S=s.size();
    memset(dp,0,sizeof(dp));
    string LR="LR";
    rep(i,S)rep(j,K+1)
    {
        rep(k,2)
        {
            // ??????????????????
            dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]+(s[i]==LR[(j%2+k+1)%2]));

            if(j<K)
            {
                // ????????????
                dp[i+1][j+1][k] = max(dp[i+1][j+1][k], dp[i][j][k]+(s[i]==LR[(j%2+k)%2]));
            }
        }
    }
}

int main()
{
    string s;
    int K;
    cin >>s >>K;

    string x="",y="";
    rep(i,s.size())
    {
        if(s[i]=='L' || s[i]=='R') x+=s[i];
        else y+=(s[i]=='U')?'L':'R';
    }

    int X=x.size(), Y=y.size();
    // 0:R????????°????????§???, 1:L????????°????????§???
    int dx[2001]={};
    // 0:D????????°????????§???, 1:U????????°????????§???
    int dy[2001]={};

    calc(x,K);
    rep(i,K+1) dx[i]=max(2*dp[X][i][0]-X, 2*dp[X][i][1]-X);
    calc(y,K);
    rep(i,K+1) dy[i]=max(2*dp[Y][i][0]-Y, 2*dp[Y][i][1]-Y);

    int ans=0;
    rep(i,K+1)rep(j,K+1)if(i+j<=K) ans=max(ans,dx[i]+dy[j]);

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

Measured memory_bytes: 34444
#include <iostream>
using namespace std;
int a[150];
int main(void){
    int n,a;
    cin >>n;
    int min=1000,max=1;
    for(int i=0;i<=n;i++){
        cin >>a;
        if(min>a){
            min=a;
        }
        if(max<a){
            max=a;
        }
    }
    cout <<max-min<<endl;
    return 0;
    
}

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

int main() {
    std::string S;
    std::cin >> S;
    
    std::sort(S.begin(), S.end());
    S.erase(std::unique(S.begin(), S.end()), S.end());
    
    bool contained[26];
    for (int i=0; i<26; ++i) contained[i] = false;
    
    for (char s='a'; s<='z'; s++) {
        for (auto i=S.begin(); i!=S.end(); i++) {
            if (*i == s) {
                contained[s-'a'] = true;        
            }
        }
    }
    
    for (int i=0; i<26; ++i) {
        if (contained[i] == false) {
            std::cout << static_cast<char>(i+'a') << std::endl;
            break;
        } else if (i == 25) {
            std::cout << "None" << std::endl;
        }
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    char a1,b1,c1,d1;
    int ans,a,b,c,d;
    cin>>a1>>b1>>c1>>d1;
    a=a1-'0';
    b=b1-'0';
    c=c1-'0';
    d=d1-'0';
    for(char i='+';i<='-';i++)
        for(char j='+';j<='-';j++)
            for(char k='+';k<='-';k++)
            {
                ans=a;
                if(i=='+') ans+=b;
                else if(i=='-') ans-=b;
                if(j=='+') ans+=c;
                else if(j=='-') ans-=c;
                if(k=='+') ans+=d;
                else if(k=='-') ans-=d;
                if(ans==7)
                {
                    cout<<a<<i<<b<<j<<c<<k<<d<<"="<<ans<<"\n";
                    return 0;
                }
            }
}

Measured memory_bytes: 256
#include<stdio.h>
void preParse(int);
void Inorder(int);
void Postorder(int);

typedef  struct{
  int parent,left,right;
}Node;

Node T[25];

int main(){

  int i,n,a,b,c,num;
  scanf("%d",&n);

  for(i=0; i<n; i++) T[i].parent = -1;

  for(i=0; i<n; i++){
    scanf("%d%d%d",&a,&b,&c);

    T[a].left = b;
    T[a].right = c;
    if(T[a].right != -1) T[c].parent = a;
    if(T[a].left != -1) T[b].parent = a;

  }


  for(i=0; i<n; i++){
    if(T[i].parent == -1) num = i;
    //printf("%d ",T[i].parent);
  }
  //printf("%d\n",num);
  printf("Preorder\n");
  preParse(num);
  printf("\nInorder\n");
  Inorder(num);
  printf("\nPostorder\n");
  Postorder(num);
  printf("\n");
  return 0;
}


void preParse(int u){
  if (u == -1) return;
  printf (" %d",u);
  preParse(T[u].left);
  preParse(T[u].right);
}

void Inorder(int u){
  if (u == -1) return;
  Inorder(T[u].left);
  printf (" %d",u);
  Inorder(T[u].right);
}

void Postorder(int u){
  if (u == -1) return;
  Postorder(T[u].left);    
  Postorder(T[u].right);
  printf (" %d",u);
}

Measured memory_bytes: 616
#include<stdio.h>
int main()
{
	int n, a[5000], i, j, s, smax;
	while(scanf("%d", &n), n) {
		for (i = 0; i < n; i ++)
			scanf("%d", a+i);
		smax = a[0];
		for (i = 0; i < n; i ++) {
			s = 0;
			for (j = i; j < n; j ++) {
				s += a[j];
				if (s > smax)
					smax = s;
			}
		}
		printf("%d\n", smax);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {

    int n, m;
    boolean[][] c;

    void solve() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        int[] a = new int[m], b = new int[m];
        c = new boolean[n][n];
        for (int i = 0; i < m; i++) {
            a[i] = in.nextInt() - 1;
            b[i] = in.nextInt() - 1;
            c[a[i]][b[i]] = c[b[i]][a[i]] = true;
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            c[a[i]][b[i]] = c[b[i]][a[i]] = false;
            if (link())
                ans++;
            c[a[i]][b[i]] = c[b[i]][a[i]] = true;
        }
        System.out.println(ans);
    }

    boolean link() {
        boolean[] visited = new boolean[n];
        visited[0] = true;
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i == j)
                        continue;
                    if (visited[i]) {
                        if (c[i][j] && !visited[j]) {
                            visited[j] = true;
                        }
                    }
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (!visited[i])
                return true;
        }
        return false;
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}


Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
char str[10010];
int main()
{
	scanf("%s",str+1);
	For(i,1,strlen(str+1)-8)
		printf("%c",str[i]);
	return 0;
}


Measured memory_bytes: 256
read a b c d
ans=$(( a * c ))

if [ $(( a * d )) -gt $ans ]; then ans=$(( a * d )); fi
if [ $(( b * c )) -gt $ans ]; then ans=$(( b * c )); fi
if [ $(( b * d )) -gt $ans ]; then ans=$(( b * d )); fi

echo $ans

Measured memory_bytes: 3780
#include <cstdio>
#define MOD 1000000007
int n,k,a[110],f[110][110][256];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	f[0][0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			for(int val=0;val<256;val++){
				f[i][j][val]=f[i-1][j][val];
				if(j)f[i][j][val]=(f[i][j][val]+f[i-1][j-1][val^a[i]])%MOD;
			}
		}
	}
	int fac=1,ans=0;
	for(int i=1;i<=n;i++){
		fac=1ll*fac*i%MOD;
		ans=(ans+1ll*fac*f[n][i][k])%MOD;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 5632
#include<stdio.h>
int main(void)
{
	int n,i,t;
	long long sum=0;
	int min=1000001,max=-1000001;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&t);
		if(t<min){
			min=t;
		}if(t>max){
			max=t;
		}
		sum+=t;
	}
	printf("%d %d %ld\n",min,max,sum);

	return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

import org.omg.CORBA.SystemException;

class Main {
	public static void main(String[] a) throws IOException {
		Scanner scan = new Scanner(System.in);
		int week = scan.nextInt();
		int moto = 100000;
		int totaldebt = 100000;
		for(int i = 0; i < week;i++){
		int rishi = (int) ((int) totaldebt * 0.05);
		totaldebt = totaldebt + rishi;
		if(totaldebt % 1000 != 0){
			totaldebt = totaldebt - (totaldebt%1000) +1000;
		}
		}
		System.out.println(totaldebt);
	}
}

Measured memory_bytes: 25920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	int x, n;
	cin >> x >> n;
	vi v(n);
	in(v);
	set<int>s(all(v));
	int diff = INT_MAX;
	int num = -1;
	for (int i = -200; i <= 200; i++) {
		if (s.find(i) == s.end()) {
			if (diff>abs(i-x)) {
				num = i;
				diff = abs(i - x);
			}
		}
	}
	cout << num << endl;
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



Measured memory_bytes: 3660
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
vector<ll> a;
vector<vector<vector<ll>>> dp;
ll f(int x, int y, int t)
{
    if(x > y) return 0;
    if(dp[t][x][y] != -1) return dp[t][x][y];
    if(t)
    {
        dp[t][x][y] = max(f(x + 1, y, 0) + a[x], f(x, y - 1, 0) + a[y]);
    }
    else
    {
        dp[t][x][y] = min(f(x + 1, y, 1) - a[x], f(x, y - 1, 1) - a[y]);
    }
    return dp[t][x][y];
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    a.assign(n, 0);
    F0R(i, n) cin >> a[i];
    dp.assign(2, vector<vector<ll>>(n, vector<ll> (n, -1)));
    f(0, n - 1, 1);
    cout << dp[1][0][n - 1];
    return 0;
}

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

using namespace std;

int main()
{
	string S;
	cin >> S;

	int count = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'o') {
			count++;
		}
	}

	cout << 700 + 100 * count << endl;
	
}


Measured memory_bytes: 3552
#!/usr/bin/env python3
import sys


def warshall_floyd(A):
    #d[i][j]: iからjへの最短距離
    l = len(A)
    for k in range(l):
        for i in range(l):
            for j in range(l):
                A[i][j] = min(A[i][j], A[i][k] + A[k][j])
    return A


def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):
    c = warshall_floyd(c)
    cost = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] != -1:
                cost += c[A[h][w]][1]
    print(cost)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    c = [[int(next(tokens)) for _ in range(9 - 0 + 1)] for _ in range(9 - 0 + 1)]  # type: "List[List[int]]"
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, c, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9412
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int n;
void dfs(string s, char MX) {
  if (s.size() == n) {
    cout << s << endl;
    return;
  }
  for (char c = 'a'; c <= MX+1; c++) {
    string t = s;
    t += c;
    dfs(t, max(MX, c));
  }
}

int main() {
  cin >> n;
  dfs("", 'a'-1);

  return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

void gcd(int x,int y){
  int u = x%y;
  if(u>0) gcd(y,u);
  if(u==0)printf("%d\n",y);
}

int main(){
  int x,y;
  scanf("%d %d",&x,&y);
  gcd(x,y);
  return 0;
}

Measured memory_bytes: 2704
n=int(input())
l=list(map(int,input().split()))
d={}
f=0
for a in l:
    if a<400:
        if not 0 in d:
            d[0]=1
    elif a<800:
        if not 1 in d:
            d[1]=1
    elif a<1200:
        if not 2 in d:
            d[2]=1
    elif a<1600:
        if not 3 in d:
            d[3]=1
    elif a<2000:
        if not 4 in d:
            d[4]=1
    elif a<2400:
        if not 5 in d:
            d[5]=1
    elif a<2800:
        if not 6 in d:
            d[6]=1
    elif a<3200:
        if not 7 in d:
            d[7]=1
    else:
        f+=1
v=sum(d.values())
min_=1 if v==0 else v
max_=v+f
print(min_,max_)


Measured memory_bytes: 8944