akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;i++) cin >> x[i];

  ll sum_x = 0;
  ll sum_xx = 0;
  for(int i=0;i<n;i++){
    sum_x += x[i];
    sum_xx += x[i]*x[i];
  }

  ll sum_hp = 0,ans = 1<<20;
  for(int i=-150;i<=150;i++){
    sum_hp = sum_xx - 2 * i * sum_x + n * i * i;
    ans = min(ans,sum_hp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long q[11];
int main()
{
	long long n,m;
	cin>>n>>m;
	long long maxl = -1000;
	long long minr = 1e9;
	vector<long long> vi,vi1;
	for(long long i=0;i<m;i++)
	{
		long long a,b;
		cin>>a>>b;
		vi.push_back(a);
		vi1.push_back(b);
	 } 
	for(long long i=0;i<m;i++)
	{
		long long a = vi[i];
		long long b = vi1[i];
		maxl = max(a,maxl);
		minr = min(b,minr);
	}
	if(minr-maxl+1>0)
	cout<<minr-maxl+1<<endl;
	else
	cout<<0<<endl;
}

Measured memory_bytes: 2036
#include<stdio.h>
#include<string.h>

char stack[1000000];
int top;

void push(char);
void pop(void);
int empty(void);

int main(void){
char str[101];
 int i,flag;
  while(1){
    scanf("%[^\n]%*c",str);
    if(str[0]=='.'&&strlen(str)==1)break;

    top=0;
    flag=1;
    for(i=0;i<strlen(str);i++){
      if(str[i]=='('||str[i]=='[')push(str[i]);
      else if((str[i]==')'&&stack[top-1]=='(')||(str[i]==']'&&stack[top-1]=='['))pop();
      else if((str[i]==')'||str[i]==']')&&empty()){flag=0;break;}
      else if(str[i]==']'&&stack[top-1]=='('){flag=0;break;}
      else if(str[i]==')'&&stack[top-1]=='['){flag=0;break;}
    }
    printf((flag && empty())?"yes\n":"no\n");
  }
  return 0;
}

void push(char x){
  stack[top]=x;
  top++;
}

void pop(void){
  top--;
}

int empty(void){
  return (top==0)?1:0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc 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'};
//vc 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'};
//cout<<""<<endl;
int main(){
  ll N;cin>>N;
  vi num(N+1);
  for(ll i=2;i<=N;i++){
    ll x=i;
    for(ll j=2;j<=i;j++){
      while(x%j==0){
        x = x/j;
        num[j]++;
      }
    }
  }
  ll tot=1;
  for(ll i=0;i<=N;i++){
    tot =tot*(num[i]+1)%MOD;
  }
  cout<<tot<<endl;
}





Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main {
  	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[][] adj_m = new int[100][100];
		int n = scan.nextInt();
		int u, v, k;
		
		for(int i = 0; i < n; i++){
			u = scan.nextInt();
			k = scan.nextInt();
			
			for(int j = 0; j < k; j++){
				v = scan.nextInt();
				adj_m[u - 1][v - 1] = 1;
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(j != n - 1){
					System.out.print(adj_m[i][j] + " ");
				}else{
					System.out.println(adj_m[i][j]);
				}
			}
		}
		
		return;
	}
}

Measured memory_bytes: 32184
#include<iostream>

using namespace std;

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

	if(a > 8){
		cout << ":(";
		return 0;
	}else if (b > 8) {
		cout << ":(";
		return 0;
	}

	cout << "Yay!";

	return 0;

}

Measured memory_bytes: 256
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

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

// a > b
int gcd_do(int a, int b)
{
    if(b == 0) return a;

    int r = a % b;
    return gcd_do(b,r);
}

int gcd(int a, int b)
{
    if(a < b) swap(a, b);
    return gcd_do(a,b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a,b);
}

void read_problem(int& n, vector<int>& a)
{
    scanf("%d\n", &n);

    a.resize(n);
    REP(i, n) {
        scanf("%d", &a[i]);
    }
}

int main()
{
    int n;
    vector<int> a;
    read_problem(n, a);

    int l = 1;
    REP(i, n) {
        l = lcm(l, a[i]);
    }

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

    return 0;
}

Measured memory_bytes: 2724
S=int(input())

if S<60:
  print("0:0:"+str(S))
elif S>=60 and S<3600:
  m=int(S/60)
  s=int(S%60)
  print("0:"+str(m)+":"+str(s))
elif S>=3600:
 h=int(S/3600)
 S=int(S-h*3600)
 m=int(S/60)
 s=int(S%60)
 print(str(h)+":"+str(m)+":"+str(s))



Measured memory_bytes: 5592
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;
fn main() {
    input! {
        n: usize,
        d:i64,
        x:i64,
        ass : [i64; n],
    }
    let sum: i64 = ass.iter().map(|v| 1 + (d - 1) / v).sum();
    println!("{}", sum + x);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define MOD 1000000007
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
using namespace std;
typedef vector<int> vi;
typedef list<int> li;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename P> P dectobin(P a){if(a==0)return 0; else return(a%2 + 10*dectobin(a/2));}
template<typename Y> Y bintodec(Y a){int ans=0,b=1,t=a; while (t){int ld=t%10; t/=10;ans+=ld* b;b=b*2;} return ans; }
template<typename H> H modExp(H x, H n){ int r=1; while(n>0){if(n%2==1){r=(r*x)%MOD;}x=(x*x)%MOD;n/=2;}return r;}
template<typename T> T isPowerOfTwo(T x){return x && (!(x & (x - 1)));}	
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
//template<typename T> T extendedEuclid(T A,T B){if(B==0){d=A; x=1;y=0;}else{ extendedEuclid(B,A%B);int temp=x; x=y; y=temp-(A
//B)*y;}}
int32_t main(){
	boost;osit;
	int n,d,cnt=0;
	cin>>n>>d;
	int arr[n][d];
	rep(i,0,n){
		rep(j,0,d){
			cin>>arr[i][j];
		}
	}
	rep(i,0,n-1){
		rep(j,i+1,n){
			int ans=0;
			rep(k,0,d){
				int q=arr[i][k]-arr[j][k];
				int p=pow(q,2);
				ans+=p;
				//cout<<q<<" ";
			}	
			//cout<<ans<<endl;
			if(ceil(sqrt(ans))==floor(sqrt(ans))) cnt++;
		}
	}
	cout<<cnt;
	return 0;
}

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

int main(){

  std::string S, T;
  std::cin >> S >> T;
  std::vector<char > mpS(26, '!');
  std::vector<char > mpT(26, '!');
  bool result = true;
  for (int i=0; i<S.length(); i++){
    int Svalue = int(S[i]) - int('a');
    if (mpS[Svalue]=='!'){
      mpS[Svalue] = T[i];
    } else if (mpS[Svalue]==T[i]){
      continue;
    } else {
      result = false;
      break;
    }
  }

  for (int i=0; i<T.length(); i++){
    int Tvalue = int(T[i]) - int('a');
    if (mpT[Tvalue]=='!'){
      mpT[Tvalue] = S[i];
    } else if (mpT[Tvalue]==S[i]){
      continue;
    } else {
      result = false;
      break;
    }
  }
  printf("%s\n", result?"Yes":"No");
  return 0;
}


Measured memory_bytes: 1020
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

a,b,c,d=map(int,input().split())
print(max(a*c,a*d,b*c,b*d))

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

int main(){
  vector<vector<int>> A(3, vector<int>(3));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for(int i = 0; i < N; i++){
    cin >> b.at(i);
  }
 
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
       for(int k = 0; k < N; k++){
         if(A.at(i).at(j) == b.at(k)) A.at(i).at(j) = 0;
       }
    }
  }
  
  for(int i = 0; i < 3; i++){
    if(A.at(i).at(0) == 0 &&
       A.at(i).at(1) == 0 &&
       A.at(i).at(2) == 0){
      cout << "Yes";
      return 0;
    }
  }
  for(int i = 0; i < 3; i++){
    if(A.at(0).at(i) == 0 &&
       A.at(1).at(i) == 0 &&
       A.at(2).at(i) == 0){
      cout << "Yes";
      return 0;
    }
  }
  if(A.at(0).at(0) == 0 &&
     A.at(1).at(1) == 0 &&
     A.at(2).at(2) == 0){
    cout << "Yes";
    return 0;
  }
  if(A.at(0).at(2) == 0 &&
     A.at(1).at(1) == 0 &&
     A.at(2).at(0) == 0){
    cout << "Yes";
    return 0;
  }
  
  cout << "No";
  return 0;
}

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

#define rep(a,b) for(ll ii=a;ii<b;ii++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'

int main()
{
  string s;
  ll sum=0;
  cin>>s;

  rep(0,s.length()) sum += (int)s[ii] - 48;
  if(sum%9 == 0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main() {
	cout.precision(16);
	double a, b, x;
	cin >> a >> b >> x;
	if (2 * x < a * a * b) {
		cout << atan(a * b * b / 2 / x) * 180 / M_PI << endl;
	}
	else {
		cout << atan(2 / a * (b - x / a / a)) * 180 / M_PI << endl;
	}
}


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

typedef struct{
  double x;
  double y;
}point;

void koch(int, point, point);

int main(){
  point p1 = {0.0, 0.0}, p2 = {100.0, 0.0};
  int n;

  scanf("%d", &n);

  printf("%f %f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%f %f\n", p2.x, p2.y);
  
  return 0;
}

void koch(int n, point p1, point p2){
  point s, u, t;
  double rad;

  if(n == 0) return;

  rad = M_PI * 60.0 / 180.0;
  s.x = (2.0 * p1.x + p2.x) / 3.0;
  s.y = (2.0 * p1.y + p2.y) / 3.0;
  t.x = (p1.x + 2.0 * p2.x) / 3.0;
  t.y = (p1.y + 2.0 * p2.y) / 3.0;
  u.x = (t.x - s.x) * cos(rad) - (t.y - s.y) * sin(rad) + s.x;
  u.y = (t.x - s.x) * sin(rad) + (t.y - s.y) * cos(rad) + s.y;

  koch(n-1, p1, s);
  printf("%f %f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%f %f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%f %f\n", t.x, t.y);
  koch(n-1, t, p2);
}



Measured memory_bytes: 2048
/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define int long long
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
priority_queue <int> pq; 	LL x;
void solve() {
//	cerr << lshll((LL)log2(x)) << endl;
	cout << lshll((LL)log2(x) + 1) - 1 << endl;
}
signed main() {
	cin >> x; solve();
	return 0;
}



Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

static const int MOD = 1000000007;

int main() {
        int n;
        cin >> n;
        vector<string> s(2);
        for (int i = 0; i < 2; i ++) cin >> s[i];
        bool prev_ver = false;
        bool first = true;
        long long ans = 1;
        for (int i = 0; i < n; i ++) {
                if (s[0][i] == s[1][i]) {
                        if (first) { 
                                first = false;
                                ans = ans * 3 % MOD;
                        } else if (prev_ver) { 
                                ans = ans * 2 % MOD;
                        }
                        prev_ver = true;
                } else {
                        if (first) {
                                first = false;
                                ans = ans * 6 % MOD;
                        } else if (prev_ver) {
                                ans = ans * 2 % MOD;
                        } else {
                                ans = ans * 3 % MOD;
                        }
                        prev_ver = false;
                        i ++;
                }
        }
        cout << ans % MOD << endl;
        return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  int snum=0;
  int ans = 0;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='S') snum++;
    else {
      if(snum>0) {
        ans++;
        snum--;
      }
    }
  }
  cout<<S.size()-2*ans<<endl;
}



Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#define MOD (ll)(1e9+7)
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];
    int ans=0;
    int diff=0;
    rep(i,n-1){
        if (diff==0){
            if (a[i]<a[i+1]){
                diff=1;
            }else if (a[i]>a[i+1]){
                diff=-1;
            }
        }else if (diff==1){
            if (a[i]>a[i+1]){
                diff=0;
                ans++;
            }
        }else{
            if (a[i]<a[i+1]){
                diff=0;
                ans++;
            }
        }
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const int mod = 1000000007;

int n;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	cout << (mod_pow(10, n, mod) - 2 * mod_pow(9, n, mod) % mod + mod + mod_pow(8, n, mod)) % mod << endl;
}

Measured memory_bytes: 3632
/**
 * Created by hiramekun at 20:51 on 2019-12-22.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

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

ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;
    return ((m / gcd(m, n)) * n);
}

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int p, n, s, a, c;
    s = 0; a = 0; c = 0;
    while( scanf("%d,%d", &p, &n) != EOF ){
        c++;
        s += p * n;
        a += n; 
    }
    if( (double)a/c - a/c >= 0.5 ) a = a/c+1;
    else a = a/c;
    printf("%d\n%d\n", s, a);
    return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>
#include<string.h>
int main()
{
	char c,s[105],t[105];
	int i,j,n,k;
	k=0;
	scanf("%s",&s);
	scanf("%s",&t);
	n=strlen(s);
	for(i=0;i<n;i++)
	{
		if(strcmp(s,t)==0)
		{
			k=1;break;	
		}
		c=s[n-1];
		for(j=n-2;j>=0;j--)
		s[j+1]=s[j];
		s[0]=c;
	}
	if(k==0)
	printf("No\n");
	else
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> p;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;

int main(){
    int N,M;cin>>N>>M;
    string s;cin>>s;
    reverse(s.begin(),s.end());
    vector<int> ans;
    int n=0;
    while(n<N){
        bool flag=true;
        for(int i=M;i>=1;--i){
            if(n+i>N) continue;
            if(s[n+i]=='0'){
                n+=i;
                ans.push_back(i);
               flag=false;
               break;
            }
        }
       if(flag){
         cout<<-1<<endl;
         return 0;
       }
    }
  reverse(ans.begin(),ans.end());
  for(int i=0;i<(int)ans.size();++i){
    cout<<ans[i];
    if(i<(int)ans.size()-1) cout<<' ';
  }
  cout<<endl;
}
              

Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
vector<P> px, py;

struct edge { int to; int cost; };
vector<edge> G[100100];
int mincost[100100];
int res = 0;
bool used[100100];

int prim() {
	for (int i = 0; i < 100100; i++) {
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;

	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, 0));

	while (que.size()) {
		P p = que.top(); que.pop();
		int v = p.second;

		if (used[v])continue;

		used[v] = 1;

		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (used[e.to])continue;
			if (mincost[e.to] > e.cost) {
				mincost[e.to] = e.cost;
				que.push(P(e.cost, e.to));
			}
		}
	}

	REP(i, n) {
		//cout << mincost[i] << endl;
		res += mincost[i];
	}
	return res;
}

int main() {
	cin >> n;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		px.push_back({ a,i });
		py.push_back({ b,i });
	}
	sort(ALL(px));
	sort(ALL(py));
	REP(i, n - 1) {
		int a = px[i].second, b = px[i + 1].second, c = px[i + 1].first - px[i].first;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
		a = py[i].second, b = py[i + 1].second, c = py[i + 1].first - py[i].first;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	cout << prim() << endl;
}

Measured memory_bytes: 14564
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
string s;

int main(){
    cin >> n >> k;
    k--;
    cin >> s;
    REP(i, n){
        if(i == k){
            if('A' <= s[i] && s[i] <= 'Z'){
                s[i] = char('a' + s[i] - 'A');
            }else{
                s[i] = char('A' + s[i] - 'a');
            }
        }
    }
    cout << s << endl;
}

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

int main() {
  int A,B,X;
  cin >> A >> B >> X;
  if(A > X){
    cout << "NO" << endl;
  }
  else if(A + B < X){
    cout << "NO" << endl;
  }
  else if(A + B >= X){
    cout << "YES" << endl;
  }
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,x,p,j;
	int sin[6];
	float a[41];
	x=0;
	p=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%f",&a[i]);
	}
	for(i=0;i<6;i++){
		sin[i]=0;
	}
	for(i=0;i<n;i++){
		if(165>a[i]){
			sin[0]++;
		}
		else if(165<=a[i] && a[i]<170){
			sin[1]++;
		}
		else if(170<=a[i] && a[i]<175){
			sin[2]++;
		}
		else if(175<=a[i] && a[i]<180){
			sin[3]++;	
		}
		else if(180<=a[i] && a[i]<185){
			sin[4]++;
		}
		else if(185<=a[i]){
			sin[5]++;
		}
	}
	for(i=0;i<6;i++){
		x++;
		p=sin[i];
		printf("%d:",x);
		if(p!=0){
			for(j=0;j<p;j++){
				printf("*");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
#define X first
#define  Y second
#define mp make_pair
using namespace std;
typedef long long ll;
const int P =1e9+7;
const int N = 200010;
int n,p[N],Pow[N];
vector<int> v[N];
vector<int> q[N];
int tot,dfn[N],low[N],dep[N];
int Fa[20][N];
void dfs(int x,int fa){
	//cout<<x<<endl;
	dep[x] =dep[fa]+1;
	q[dep[x]].push_back(x);
	dfn[x] =++tot;
	Fa[0][x] =fa;
	int i = 0;
	while(Fa[i][x]!=0){
		Fa[i+1][x] = Fa[i][Fa[i][x]];
		i++;
	}
	for(auto t:v[x]) if(t!=fa){
		dfs(t,x);
	}
	low[x] =tot;
}
inline int LCA(int x,int y){
	if(dep[x]<dep[y]) swap(x,y);
	for(int i =19;i>=0;i--) if(dep[x]-(1<<i)>=y){
		x = Fa[x][i];
	}
	if(x==y) return x;
	for(int i =19;i>=0;i--) if(Fa[i][x]!=Fa[i][y]){
		x = Fa[i][x];
		y = Fa[i][y];
	}
	return Fa[0][x];
}
int flag[N];
int cmp(int a,int b){
	return dfn[a]<dfn[b];
}
int ans = 0;
int Stack[N],top;
int Powmod(int a,int b){
	if(b==0) return 1;
	int ret =Powmod(a,b>>1);
	ret = 1ll*ret*ret%P;
	if(b&1) ret =1ll*ret*a%P;
	return ret;
}
int leaf[N],one[N];
void dfs2(int x){
	//cout<<"dfs2 "<<x<<endl;
	if(v[x].size()==0){
		leaf[x] =1;
		one[x] = 1;
		return;
	}
	leaf[x] = 0;
	one[x] = 0;
	int t,tmp = 1;
	for(int i = 0;i<v[x].size();i++){
		t = v[x][i];
		dfs2(t);
		tmp = 1ll*tmp*(Pow[leaf[t]]-one[t])%P;
		leaf[x] += leaf[t];
	}
	for(int i = 0;i<v[x].size();i++){
		t = v[x][i];
		//tmp = 1ll*tmp*one[t];
		one[x] = (one[x]+1ll*tmp*Powmod(Pow[leaf[t]]-one[t],P-2)%P*one[t])%P;
	}
}
int main(){
	Pow[0] =1;
	for(int i =1;i<N;i++) Pow[i] =Pow[i-1]*2ll%P;
	scanf("%d",&n);
	n++;
	for(int i=2;i<=n;i++){
		scanf("%d",p+i);
		p[i]++;
		v[p[i]].push_back(i);
	}
	dfs(1,0);
	ans = 0;
	for(int i =1;i<=n;i++) v[i].clear();
	for(int i =1;i<=n;i++) if(q[i].size()>0){
		//cout<<q[i].size()<<endl;
		for(auto x:q[i]) flag[x] = i;
		sort(q[i].begin(),q[i].end(),cmp);
		int cnt =q[i].size();
		cnt--;
		for(int j = 0;j<cnt;j++){
			int tmp = LCA(q[i][j],q[i][j+1]);
			if(flag[tmp]==i) continue;
			flag[tmp] = i;
			q[i].push_back(tmp);
		}
		sort(q[i].begin(),q[i].end(),cmp);
		for(auto x:q[i]) v[x].clear();
		top = 0;
		for(int j = 0;j<q[i].size();j++){
			int t = q[i][j];
			while(top>0 && low[Stack[top]]<dfn[t]) top--;
			if(top>0) v[Stack[top]].push_back(t);
			Stack[++top] = t;
		}
		dfs2(Stack[1]);
		ans =(ans+1ll*one[Stack[1]]*Pow[n-leaf[Stack[1]]])%P;
		
		//cout<<one[Stack[1]]<<' '<<Pow[n-leaf[Stack[1]]]<<endl;
	}
	ans =(ans+P)%P;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 53632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int a,b,k; cin >> a >> b >> k;
    int ans=0;
    for(int i=100; i>0; i--){
        if(a%i==0 && b%i==0) ans++;
        if(ans==k){
            cout << i << endl;
            return 0;
        }
    }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;

  int a = 0, b = 0;
  for (char s : S) {
    bool pass = false;
    if (s == 'a') {
      if (a < A + B) pass = true, a++;
    }
    if (s == 'b') {
      if (a < A + B && b < B) pass = true, a++;
      b++;
    }

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

  return 0;
}


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

# input
a = [['' for _ in range(3)] for _ in range(3)]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
a[2] = list(map(int, input().split()))
n = int(input())
b = []
for _ in range(n):
    tmp = int(input())
    b.append(tmp)

# calc
f = [['' for _ in range(3)] for _ in range(3)]
for i in range(3):
    for j in range(3): f[i][j] = 0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                f[i][j] = 1

for i in range(3):
    s = 0
    for j in range(3):
        s += f[i][j]
    if s == 3:
        print('Yes')
        sys.exit()

for i in range(3):
    s = 0
    for j in range(3):
        s += f[j][i]
    if s == 3:
        print('Yes')
        sys.exit()

if f[0][0] + f[1][1] + f[2][2] == 3:
    print('Yes')
    sys.exit()
if f[0][2] + f[1][1] + f[2][0] == 3:
    print('Yes')
    sys.exit()

print('No')

Measured memory_bytes: 3064
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())
uf = UnionFind(n)
l = []

for _ in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)

ans = uf.group_count()-1
print(ans)

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


int main() {
  string s,t;
  int ans=0;
  cin >> s >> t;
  int a=s.size();
  rep(i,a){if(s[i]==t[i])ans++;}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<chrono>
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

const int MAXN = 1e5 + 20;


int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;
 	
    int n;
    cin >> n;
    cout << (n + 1) / 2 * 1.0 / n << endl;

    return 0;
}























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

const int MAX = 90;

int a[MAX][MAX];
int c[MAX][MAX];

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

int m, n;

int dfs(int x, int y) {
	c[x][y] = 0;
	int ma = 0;
	for (int i = 0; i < 4; i++) {
		int tx = x + dx[i], ty = y + dy[i];
		if (0 <= tx && tx < n && 0 <= ty && ty < m && c[tx][ty]) {
			ma = max(ma, dfs(tx, ty));
		}
	}
	c[x][y] = 1;
	return ma + 1;
}

int main()
{
	while (cin >> m >> n, m | n) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> a[i][j];
			}
		}
		int res = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (a[i][j] == 1) {
					for (int x = 0; x < n; x++) {
						for (int y = 0; y < m; y++) {
							c[x][y] = a[x][y];
						}
					}
					res = max(res, dfs(i, j));
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;
int dp[2][(1<<19)];
int dp2[2][(1<<19)][21];
int r1[22], r2[22];
int nx[21][(1<<19)];
int main(){
	int n, m, k;
	cin >> n >> m >> k;
	n--;
	for(int i = 0; i < 22; i++){
		r1[i] = 0;
		r2[i] = 0;
	}
	for(int c = 0; c < n; c++){
		for(int i = 0; i < (1<<n); i++){
			nx[c][i] = -1;
			if( (i & (1<<c)) == 0) continue;
			nx[c][i] = i ^ (1<<c);
			for(int j = c-1; j >= 0; j--){
				if( (i & (1<<j)) == 0){
					nx[c][i] = i ^ (1<<j) ^ (1<<c);
					break;
				}
			}
		}
		/*for(int i = 0; i < (1<<n); i++){
			for(int a = n-1; a >= 0; a--){
				cout << (i >> a) % 2;
			}
			cout << " " << i << " ";
			for(int a = n-1; a >= 0; a--){
				cout << (nx[c][i]>>a) % 2;
			}
			cout << endl;
		}*/
	}
	for(int i = 0; i < k; i++){
		int a, b, c;
		cin >> a >> b >> c;
		b--;
		if(c) r1[a] |= (1<<(n-1-b));
		r2[a] |= (1<<(n-1-b));
	}
	for(int i = 0; i << (1<<n); i++){
		dp[0][i] = 0;
	}
	dp[0][0] = 1;
	for(int i = 1; i <= m; i++){
		int c = 1-i%2;
		int d = i%2;
		for(int j = 0; j < (1<<n); j++){
			for(int l = 0; l <= n; l++){
				dp2[c][j][l] = 0;
			}
			dp2[c][j][0] = dp[c][j];
		}
		for(int l = 1; l <= n; l++){
			for(int j = 0; j < (1<<n); j++){
				dp2[c][j][l] += dp2[c][j][l-1];
				if(nx[l-1][j] >= 0) dp2[c][j][l] += dp2[c][nx[l-1][j]][l-1];
				dp2[c][j][l] %= MOD;
				/*cout << j << " ";
				for(int a = n-1; a >= 0; a--){
					cout << (j >> a) % 2;
				}
				cout << " " << l << " ";
				cout << dp2[c][j][l] << " ";
				if(nx[l-1][j] >= 0){
					for(int a = n-1; a >= 0; a--){
						cout << (nx[l-1][j] >> a) % 2;
					}
				}
				cout << endl;*/
 
			}
		}
		for(int j = 0; j < (1<<n); j++){
			dp[d][j] = 0;
			if((j & r2[i]) != r1[i]){
				continue;
			}
			dp[d][j] = dp2[c][j][n];
			//if(dp[d][j] > 0) cout << d << " " << j << " " << dp[d][j] << endl;
		}
	}
	LL ans = 0;
	for(int j = 0; j < (1<<n); j++){
		ans += dp[m%2][j];
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 131328
#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 all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
const LL INF = 999999999999;

signed main(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i = 100; i>=1; i--){
        if(!(a%i) && !(b%i)){
            k--;
            if(k == 0){
                cout << i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
x, n = gets.split.map(&:to_i)
if n == 0
  puts x
else
  pi = gets.split.map(&:to_i)
  ans = 0
  for i in 0..101 do
    if !pi.include?(i)
      ans = i if (i - x).abs < (ans - x).abs
    end
  end
  puts ans
end


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, t[102], v[102];
int x[40001];

int main() {
	cin >> n;
	t[0] = v[0] = 0;
	inc1(i, n) { cin >> t[i]; t[i] *= 2; }
	inc1(i, n) { cin >> v[i]; v[i] *= 2; }
	t[n + 1] = v[n + 1] = 0;
	n += 2;
	
	inc(i, 40001) { x[i] = 202; }
	
	int s = 0;
	inc(i, n) {
		inc(j, t[i] + 1) { setmin(x[s + j], v[i]); }
		s += t[i];
	}
	s++;
	
	inc(i, s) {
		if(i != 0 && x[i - 1] - x[i] > 1) {
			int j = i - 1;
			while(setmin(x[j], x[j + 1] + 1)) { j--; }
		}
		if(i != s - 1 && x[i + 1] - x[i] > 1) {
			int j = i + 1;
			while(setmin(x[j], x[j - 1] + 1)) { j++; }
		}
	}
	
	int in = -1, b = 0;
	inc(i, s) {
		if(x[i] == 0) { b++; } else { in += x[i] - 1; b += 2; }
	}
	
	printf("%.5f\n", (1.0 * in + b / 2.0) / 4.0);
	
	return 0;
}


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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        vec1.push_back(cin2var<T>());
    }
    return vec1;
}

int main()
{
    const auto N(cin2var<size_t>());
    const auto Hs(cin2vec<size_t>(N));

    size_t count     = 0;
    size_t max_count = 0;
    size_t prev      = Hs.front();
    for (auto ite(next(Hs.cbegin())); ite != Hs.cend(); ++ite) {
        const auto cur = *ite;
        if (cur <= prev) {
            ++count;
            if (max_count < count) {
                max_count = count;
            }
        }
        else {
            count = 0;
        }
        prev = cur;
    }
    cout << max_count << endl;
    return 0;
}

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

// Euclid's algorithm for greatest common divisor
long long gcd(long long p, long long q,long long *x,long long *y)
{
 long long x1, y1;
 long long g;

 
 if (q > p) return(gcd(q,p,y,x));
 if ( q == 0) {
    *x = 1;
    *y = 0;
    return(p);
 }

 g = gcd(q, p%q, &x1, &y1);
 
 *x = y1;
 *y = (x1 - floor(p/q)*y1);

 return(g);
}

int main()
{
 int N;
 long long T[105];
 int i;
 long long time;
 long long gcdiv;
 long long x, y;
 
 scanf("%d",&N);
 scanf("%lld",&T[0]);
 time=T[0];
 for(i=1;i<N;i++) 
 {
  scanf("%lld",&T[i]);
  gcdiv = gcd(time, T[i], &x, &y);
  time=time/gcdiv;
  time=time*T[i];
 }
 printf("%lld\n",time);
 return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
			String str;
			int A, B, result = 0;
			float T;
			Scanner scanner = new Scanner(System.in);

			str = scanner.nextLine();

			A = Integer.parseInt(str.split(" ")[0]);
			B = Integer.parseInt(str.split(" ")[1]);
			T = Integer.parseInt(str.split(" ")[2]);

			for (int i = A; i < T + 0.5; i = i + A) {
				result += B;
			}

			System.out.print(result);

			scanner.close();
		}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    string S;
    cin >> S;
    ll ans = 0;
    if(S[0] == 'o')ans++;
    if(S[1] == 'o')ans++;
    if(S[2] == 'o')ans++;
    cout << ans * 100 + 700 << endl;
}

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

using namespace std;

#define int long long

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

#ifdef DBG
#define log(item) cout << #item << " " << item << endl
#define loga(array, val) cout << #array << "[" << val << "] " << array [ val ] << endl
#else
#define log(item)
#define loga(array, val)
#endif

typedef vector<int> VI;
typedef pair<int, int> PII;

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

int N, L;

signed main(){
    cin >> N;
    cin >> L;

    int u = 0;

    int y = LLONG_MAX;

    rep(i, N){
        u += L + i;
    }

    if(N + L - 1 < 0){
        u -= N+L -1;
    }
    else if(L > 0){
        u -= L;
    }
    
    cout << u << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
   int main()
   {
       string str;
       string temp;
       cin >> str;
       
       string::iterator it = str.end();
       temp = *(it - 1);
       
       if (temp == "s"){
           str.append("es", 2);
       }else{
           str.append("s", 1);
       }
       
       cout << str ;
       return 0;
    }

Measured memory_bytes: 3640
import itertools
import math

n = int(input())
coordinate = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for route in itertools.permutations(range(n)):
    prev = coordinate[route[0]]
    for i in range(1, n):
        ans += math.sqrt((prev[0] - coordinate[route[i]][0])**2 + (prev[1] - coordinate[route[i]][1])**2)
        prev = coordinate[route[i]]

print(ans / math.factorial(n))


Measured memory_bytes: 41068
import sys
from collections import deque

input = sys.stdin.readline


def dfs(N):
    stack = deque(["3", "5", "7"])
    num = 0
    while stack:
        n = stack.pop()
        if int(n) > N:
            continue
        num += 1 if all(s in n for s in "357") else 0
        stack.append("3" + n)
        stack.append("5" + n)
        stack.append("7" + n)
    return num


def main():
    N = int(input())

    ans = dfs(N)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define N 233
const int dig=18;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,a[N],k,S,T;
ll ans,C[N][N];
ll calc(int x){
	static int cnt[1<<18],vis[1<<18];
	for(int i=1;i<=n;++i){
		++cnt[a[i]&x];
	}
	ll tot=0;
	for(int i=1;i<=n;++i){
		int c=a[i]&x;
		if(vis[c])continue;
		vis[c]=1;
		for(int j=1;j<=k;++j){
			tot+=C[cnt[c]][j];
		}
	}
	for(int i=1;i<=n;++i){
		vis[a[i]&x]=cnt[a[i]&x]=0;
	}
	return tot;
}
int main(){
	n=read(),k=read(),S=read(),T=read();
	for(int i=0;i<dig;++i){
		if((S>>i)&1&&!((T>>i)&1)){
			return !printf("0\n");
		}
	}
	for(int i=1;i<=n;++i){
		int x=read();
		bool ok=true;
		for(int j=0;j<dig;++j){
			if((S>>j)&1&&!((x>>j)&1)||!((T>>j)&1)&&(x>>j)&1){
				ok=false;break;
			}
		}
		if(ok)a[++m]=x;
	}
	C[0][0]=1;
	for(int i=1;i<=n;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j){
			C[i][j]=C[i-1][j-1]+C[i-1][j];
		}
	}
	if(!n)return !printf("0\n");
	n=m;
	for(int i=S^T;;i=(i-1)&(S^T)){
		ans+=__builtin_popcount(i)&1?-calc(i):calc(i);
		if(!i)break;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5832