akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    auto encodeString = [](const string& str) {
        auto encodeChar = [](char c) {
            switch (c) {
            case 'A':
                return 1;
            case 'C':
                return 2;
            case 'G':
                return 3;
            case 'T':
                return 4;
            default:
                assert(false);
            }
        };
        auto pow = [](auto b, auto e) {
            int r{1};
            for (auto i = 0; i < e; ++i) {
                r *= b;
            }
            return r;
        };
        vector<char> v;
        transform(begin(str), end(str), back_inserter(v), encodeChar);
        int r{0};
        for (size_t i = 0; i < v.size(); ++i) {
            r += v[i] * pow(5, i);
        }
        return r;
    };
    vector<bool> b(244140624 + 1);

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string instruction;
        string s;
        cin >> instruction >> s;
        if (instruction == "insert") {
            b[encodeString(s)] = true;
        }
        else {
            if (b[encodeString(s)]) {
                cout << "yes" << endl;
            }
            else {
                cout << "no" << endl;
            }
        }
    }
}

Measured memory_bytes: 32500
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char a;
  string s;
  cin >> n;
  cin >>s;
  int l=s.length();
  a=n;
  for(int i=0;i<l;++i) {
    s[i]+=a;
    if(s[i]>'Z') s[i]-=26;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();

    let a = s.chars().all(|c| c == 'A' );
    let b = s.chars().all(|c| c == 'B' );

    if a == true || b == true {
        println!("No");
    }else{
        println!("Yes");
    }

}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  int ans = n/2+(n%2);

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


Measured memory_bytes: 256
#include<stdio.h>
#define Max 100005
#define None -1
typedef struct {
  int parent,left,right;
}Node;
Node Tree[Max];
int n,Depth[Max];
void print_out(int);
int dep(int ,int);
int main(){
  int i,j,d,v,c,r;
  int l=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    Tree[i].parent=None;
    Tree[i].left=None;
    Tree[i].right=None;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)Tree[v].left=c;
      else Tree[l].right=c;
      l=c;
      Tree[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(Tree[i].parent==None)r=i;
  }
  dep(r,0);
  for(i=0;i<n;i++)print_out(i);
  return 0;
}
int dep(int u,int p){
  Depth[u]=p;
  if(Tree[u].right!=None)dep(Tree[u].right,p);
  if(Tree[u].left!=None)dep(Tree[u].left,p+1);
}
void print_out(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",Tree[u].parent);
  printf("depth = %d, ",Depth[u]);
  if(Tree[u].parent == None)printf("root, ");
  else if(Tree[u].left == None)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i = 0,c=Tree[u].left;c!=None;i++,c=Tree[c].right){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

Measured memory_bytes: 5296
import math
N, D = map(int, input().split())  # D次元空間にN個の点

zahyo = [list(map(int, input().split())) for _ in range(N)]

ans = 0

for i in range(N):
    for j in range(i+1, N):
        distance = sum([(a-b)**2 for a, b in zip(zahyo[i], zahyo[j])])
        distance = distance ** (1/2)
        if distance == math.ceil(distance):
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=3e5+7;
ll a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    ll s=0,s1=0,s2=0;
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(int i=0;i<=60;i++){
        s1=s2=0;
        for(int j=0;j<n;j++){
            if(((a[j]>>i)&1)==1)
                s1++;
            else s2++;
        }
        __int128 gg=1;
        gg=(gg*s1*s2*(1ll<<i))%mod;
        ll tt=gg;
        s=(s+tt)%mod;
    }
    printf("%lld\n",s);
	return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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

//�G�X�g���l�X���
vector<ll> estora(vector<ll> num) {
    int sel = 0;
    while (sel < num.size()) {
        int d = num[sel];
        for (int i = 0; i < num.size(); i++) {
            if (num[i] % d == 0 && num[i] != d && d != 1) {
                num.erase(num.begin() + i);
                i--;
            }
        }
        sel++;
    }
    return num;
}

const int INF = 1001001001;

//mint�p�̒萔 (10��9�� + 7)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

//string�@�ɂ��Ē��ׂĂ�����

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

    if (x < a)
        cout << 0;
    else
        cout << 10;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
//i����ɑf���ɂ��Ă����Ȃ��Ƃ��܂��ł��Ȃ�&&�v�Z�ʃ��o�C
//�G�X�g���l�X��⿂őf����U����Ă����K�v�������肻��
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ios();
    int n, q;
    cin >> n >> q;

    vector<vector<ll>> v(n, vector<ll>(3));
    REP(i, n) REP(j, 3) cin >> v[i][j];
    sort(all(v), [](auto a, auto b){return a[2] < b[2];});

    set<pair<ll,int>> st;
    REP(i, q){
        ll a;
        cin >> a;
        st.insert(make_pair(a, i));
    }

    //for(auto i : st) cout << i.first << " " << i.second << endl;

    vector<ll> ans(q, -1);

    REP(i, n){
        ll s = v[i][0], t = v[i][1], x = v[i][2];

        auto itr = st.lower_bound(make_pair(s-x, 0));
        while(itr != st.end()){
            if(itr->first >= t-x) break;
            ans[itr->second] = x;
            itr = st.erase(itr);
        }
    }

    for(auto i : ans) cout << i << '\n';
    return 0;
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int N=5005,M=1000000007;
int n,i,a[N],vis[N],t,s[N],k,p[N],j;
long long ans,f[5005][5005],fac[N];
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		b>>=1;
		s=s*s%M;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]==-1)
			++t;
	}
	memset(vis,0,sizeof(vis));
	ans=qpow(n-1,t)*n%M;
	for(i=1;i<=n;++i)
	{
		for(j=i;a[j]!=-1&&vis[j]==0;j=a[j])
			vis[j]=i;
		if(vis[j]==i)
			ans=(ans-qpow(n-1,t))%M;
	}
	for(i=1;i<=n;++i)
	{
		memset(vis,0,sizeof(vis));
		for(j=i;a[j]!=-1&&vis[j]==0;j=a[j])
			vis[j]=1;
		if(a[j]==-1)
			++s[j];
	}
	for(i=1;i<=n;++i)
		if(s[i])
			p[++k]=s[i];
	f[0][0]=1;
	for(i=1;i<=k;++i)
	{
		f[i][0]=1;
		for(j=1;j<=k;++j)
			f[i][j]=(f[i-1][j]+f[i-1][j-1]*p[i])%M;
	}
	fac[0]=1;
	for(i=1;i<=n;++i)
		fac[i]=fac[i-1]*i%M;
	for(i=2;i<=k;++i)
		ans=(ans-f[k][i]*fac[i-1]%M*qpow(n-1,t-i))%M;
	for(i=1;i<=k;++i)
		ans=(ans-(p[i]-1)*qpow(n-1,t-1))%M;
	cout<<(ans%M+M)%M;
}


Measured memory_bytes: 199136
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
mod = 1000000007

s = 0
t = 0
n.times{|i|
    s = s + a[i..-1].count{|e|a[i]>e}
    t = t + a.count{|e|a[i]>e}
}
p (s*k + t*(k*(k-1)/2) )% mod

Measured memory_bytes: 1916
import std;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long K = lread();
    long ans;
    foreach (i; 1 .. K + 1)
        foreach (j; 1 .. K + 1)
            foreach (k; 1 .. K + 1)
            {
                ans += gcd(i, j).gcd(k);
            }
    writeln(ans);
}


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

int main() {
    int n;
    cin >> n;
    double ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += 1.0 / a;
    }

    cout << fixed << setprecision(9) << 1.0 / ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[] sides = new int[3];
		int side1 = 0, side2 = 0, side3 = 0;

		while ((line = br.readLine()) != null) {
			if (line.contains(" ")) {
				sides[0] = Integer.parseInt(line.split(" ")[0]);
				sides[1] = Integer.parseInt(line.split(" ")[1]);
				sides[2] = Integer.parseInt(line.split(" ")[2]);
				Arrays.sort(sides);
				side1 = sides[0];
				side2 = sides[1];
				side3 = sides[2];
				if (side1 * side1 + side2 * side2 - side3 * side3 == 0) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}
			}
		}
	}
}

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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

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

  ll ans = 0;
  each (i, s) {
    if (i == '+') ++ans;
    if (i == '-') --ans;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
// C++ program to find Excel
// column name from a given
// column number
#include <bits/stdc++.h>
#define MAX 50
using namespace std;
#define ll long long
// Function to print Excel column name for a given column number
void printString(ll n)
{
	char str[MAX]; // To store result (Excel column name)
	ll i = 0; // To store current index in str which is result

	while (n > 0) {
		// Find remainder
		ll rem = n % 26;

		// If remainder is 0, then a 'Z' must be there in output
		if (rem == 0) {
			str[i++] = 'z';
			n = (n / 26) - 1;
		}
		else // If remainder is non-zero
		{
			str[i++] = (rem - 1) + 'a';
			n = n / 26;
		}
	}
	str[i] = '\0';

	// Reverse the string and print result
	reverse(str, str + strlen(str));
	cout << str << endl;

	return;
}

// Driver program to test above function
int main()
{
	ll n,i;
	cin>>n;
	ll xo=0;
	ll ar[n+1];
	for(i=0;i<n;i++)
	{
		cin>>ar[i];
		xo^=ar[i];
	}
	for(i=0;i<n;i++)
		cout<<(xo^ar[i])<<" ";
	printf("\n");
}


Measured memory_bytes: 5160
#include<stdio.h>
int main()
{
	int a,b;
	while(~scanf("%d%d",&a,&b))
  {
	if((a>=1&&a<=9)&&(b>=1&&b<=9))
	printf("%d\n",a*b);
	else printf("%d\n",-1);
  }
	return 0;
}

Measured memory_bytes: 128
//Bubble Sort

#include <stdio.h>
#include <stdlib.h>

main(){
  
  int n;
  int *a; //配列用ポインタ
  int c; //交換回数

  int i,j,tmp;

  scanf("%d", &n);

  a = (int *)malloc(sizeof( int ) * n);

  for( i=0; i<n; i++) {
    scanf("%d", &a[i]);
  }

  c = 0;

  for( i=0; i<n; i++) {
    for( j=n-1; j>i; j--) {
      if( a[j] < a[j-1] ) {
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	c++;
      }
    }
  }

  for( i=0; i<n-1; i++) { 
    printf("%d ", a[i]);
  }
  printf("%d\n%d\n", a[n-1], c);

  free(a);

  return 0;

}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << "\n";
	return 0;
}

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

#define ll long long
#define pll pair<ll,ll> 

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


	ll n;
	cin>>n;
	map<string, ll> M;
	string s;
	for(ll i=0;i<n;i++){
		cin>>s;
		M[s]++;
	}
	cout<<"AC x "<<M["AC"]<<endl;
	cout<<"WA x "<<M["WA"]<<endl;
	cout<<"TLE x "<<M["TLE"]<<endl;
	cout<<"RE x "<<M["RE"]<<endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N;
	cin >> N;

	vector<Int> b(N);
	for (Int i = 0; i < N; i++) {
		cin >> b[i];
	}

	Int temp;
	vector<Int> ans;

	for (Int i = N; i > 0; i--) {
		temp = 0;
		for (Int j = 0; j < i; j++) {
			if (b[j] == j + 1)temp = j + 1;
		}

		if (temp == 0) {
			printf("-1\n");
			return 0;
		}
		ans.push_back(temp);
		b.erase(b.begin() + temp-1);
	}

	for (Int i = N-1; i >= 0; i--) {
		printf("%lld\n", ans[i]);
	}

}


Measured memory_bytes: 256
using System;

namespace ABC124B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int cnt = 0;
            for(int i = 0; i < N; i++)
            {
                bool flg = true;
                for(int j = 0; j < i; j++)
                {
                    if (int.Parse(input[i])< int.Parse(input[j])){
                        flg = false;
                    }
                }
                if (flg)
                {
                    cnt++;
                }
            }
            Console.Write(cnt);

        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main() {

	int n, x,i,j,k,ans=0;

	while(1){

		scanf("%d %d", &n, &x);

		if (n == 0 && x == 0)
			break;

		for (i = 1; i < n - 1; i++) {
			for (j = i + 1; j < n; j++) {
				for (k = j + 1; k < n + 1; k++) {
					if (i + j + k == x)
						ans++;
				}
			}
		}
		printf("%d\n",ans);
		ans = 0;

	}

	return 0;

}

Measured memory_bytes: 600
#include<stdio.h>

int main(){
  int a, b, c, k;
  int flag = 0;
  int i;

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

  if(a > b){
    if(a > c){
      //a > b, c
      flag = 0;
    }
    else if(b > c){
      //a > b > c
      flag = 0;
    }
    else{
      //c > a > b
      flag = 2;
    }
  }
  else{
    if(a > c){
      //b > a > c
      flag = 1;
    }
    else if(b > c){
      //b > c, a
      flag = 1;
    }
    else{
      //a, b < c
      flag = 2;
    }
  }

  if(flag == 0){
    for(i = 0; i < k; i++){
      a *= 2;
    }
  }
  else if(flag == 1){
    for(i = 0; i < k; i++){
      b *= 2;
    }
  }
  else{
    for(i = 0; i < k; i++){
      c *= 2;
    }
  }

  printf("%d\n", a + b + c);

  return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int64_t a, b, x;
  cin >> a >> b >> x;
  int64_t cnt = 0;
  
  if(a % x == 0){
    cnt = (b-a) / x + 1;
  }
  else if(a + x - (a % x) <= b){
    cnt = (b-(a + x - (a % x))) / x + 1;
  }
  
  cout << cnt << endl;
}
  

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left, bisect_right
from functools import lru_cache, reduce
MOD = int(1e9)+7
INF = float('inf')


def solve():
    n, m = [int(x) for x in input().split()]
    a = []
    starts = []
    for i in range(n):
        a.append(input())
        for j in range(m):
            if a[i][j] == '.':
                starts.append((i, j))

    def bfs(v):
        q = deque([(v, 0)])
        mx = 0
        mv = v
        w = defaultdict(int)
        w[v] = 1
        while q:
            v, d = q.popleft()
            if d > mx:
                mv = v
                mx = d
            i, j = v
            for x, y in ((0, 1), (0, -1), (1, 0), (-1, 0)):
                if 0 <= i + x < n and 0 <= j + y < m and not w[(i+x,j+y)] and a[i+x][j+y] == '.':
                    w[(i+x,j+y)] = 1
                    q.append(((i+x, j+y), d + 1))
            

        return mx, mv

    ans = 0
    for start in starts:
        _, start = bfs(start)
        cur, start = bfs(start)

        ans = max(ans, cur)
    print(ans)


    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
1
4
-1 1 1 -1

"""


Measured memory_bytes: 9984
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <stdint.h>
#define ll long long
#define oku7 1000000007
using namespace std;


//う ず ま き
int x=-1, y=0, d=1;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { -1, 0, 1, 0 };

const int MAXINT = 2147483647 / 3;
int G[201][201];

int main(){
	int N, M, R;
	cin >> N >> M >> R;
	vector<int> iku;
	for (int i = 0; i < R; i++){
		int tmp;
		cin >> tmp;
		iku.push_back(tmp);
	}
	for (int i = 0; i < 201; i++){
		for (int j = 0; j < 201; j++){
			G[i][j] = MAXINT;
		}
	}
	for (int i = 0; i < M; i++){
		int a, b, c;
		cin >> a >> b >> c;
		G[a][b] = G[b][a] = c;
	}


	//ワーシャルフロイドをする
	for (int i = 1; i <= N; i++){
		for (int j = 1; j <= N; j++){
			for (int k = 1; k <= N; k++){
				if (G[j][k] > G[j][i] + G[i][k]){
					G[j][k] = G[j][i] + G[i][k];
				}
			}
		}
	}

	sort(iku.begin(), iku.end());
	int ans = MAXINT;
	while (next_permutation(iku.begin(), iku.end())){
		int tmp = 0;
		for (int i = 0; i < (int)iku.size() - 1; i++){
			tmp += G[iku[i]][iku[i + 1]];
		}
		if (tmp < ans) ans = tmp;
	}
	cout << ans << "\n";

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

ll pow5(ll n)
{
    ll m(1);
    rep(i, n) m *= 5;
    return m;
}

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    if (n % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    ll m(0);
    for (int i = 40; i >= 1; --i)
    {
        ll dd = (pow5(i) * 2);
        if (dd > n)
            continue;
        m += n / dd;
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll t = n / (a + b);
    ll ans = t * a;
    ll tmp = n % (a + b);
    ans += min(a, tmp);
    cout << ans << endl;
}

Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=0,b=0,c=0,d=0,e=0;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
    	cout<<"1";
    else if(b==0)
    	cout<<"2";
    else if(c==0)
    	cout<<"3";
    else if(d==0)
    	cout<<"4";
    else
    	cout<<"5";
    cout<<endl;
}

Measured memory_bytes: 3528
n = int(input())

def get_divisors(n):
    result = []
    for i in range(1, int(n**.5)+1):
        if n % i == 0:
            result.append(i)
            if n != i ** 2:
                result.append(n // i)
    result.sort()
    return result

c = 0
for number in get_divisors(n)[1:]:
    tmp = n
    while tmp % number == 0:
        tmp //= number
    if tmp % number == 1:
        c += 1

c += len(get_divisors(n-1)) - 1
print(c)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ
    
    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
};

int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    UnionFind Uni(n);
    Uni.init(n);
    vl x(n, 1);  // x[v] : 頂点vとつながっている頂点の個数(v自身も含める)

    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        x[a]++;  x[b]++;
        Uni.unite(a, b);
    }

    vvl B(n);
    rep(i, k) {
        ll c, d;
        cin >> c >> d;
        c--;  d--;
        B[c].pb(d);
        B[d].pb(c);
    }

    vl ans(n);
    rep(v, n) {
        ans[v] = Uni.size(v) - x[v];
        for(auto u : B[v]) {
            if(Uni.root(v) == Uni.root(u)) {
                ans[v]--;
            }
        } 
    }
    
    rep(v, n) {
        cout << ans[v] << " ";
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 9856
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by Dmitry on 25.08.2017.
 */
public class Main {
    public static void main(String[] args) {
        //System.out.print("Hello");
        solve();
    }

    static void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        sc.close();
        Arrays.sort(arr);
        //long ans = 0;
        long max1=0;
        long max2 = 0;
        //int i = arr.length-1;
        for(int i = arr.length-1; i>=1;i--){
            if(arr[i-1] == arr[i]){
                if(max1==0){
                    max1 = arr[i];
                    i--;
                }
                else{
                    max2 = arr[i];
                    break;
                }
            }
        }
        long res = max1*max2;
        System.out.println(res);
    }
}


Measured memory_bytes: 50164
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 1000000000
typedef long long int lli;
typedef pair<int,int> P;

const int MAX_V=100;
int cost[MAX_V][MAX_V];
bool used[MAX_V];
int mincost[MAX_V];

int main(){
	int n,m;
	while(cin>>n){
		if(n==0) break;
		cin >>m;
		for(int i=0; i<n; ++i){
			mincost[i]=INF;
			used[i]=false;
			for(int j=0; j<n; ++j){
				cost[i][j]=INF;
			}
		}
		mincost[0]=0;
		for(int i=0; i<m; ++i){
			int a,b,d;
			scanf("%d,%d,%d",&a,&b,&d);
			cost[a][b]=cost[b][a]=d;
		}
		int res=0;
		while(true){
			int v=-1;
			for(int u=0; u<n; ++u){
				if(!used[u]&&(v==-1||mincost[v]>mincost[u])) v=u;
			}
			if(v==-1) break;
			used[v]=true;
			res+=mincost[v];
			for(int u=0; u<n; ++u){
				mincost[u]=min(mincost[u],cost[v][u]);
			}
		}
		cout << res/100-n+1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  map<string,int> mp;
  string s,t;
  int n;cin>>n;
  rep(i,n){
    cin>>s;
    mp[s]++;
  }
  int m;cin>>m;
  rep(i,m){
    cin>>t;
	if(mp.count(t))mp[t]--;
  }
  int mx=0;
  for(auto a:mp){
    auto x=a.second;
    mx=max(mx,x);
  }
  cout<<mx;
}

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

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

  string s; cin >> s;

  string ans = "";
  rep(i, s.size()) {
    if(s[i] == '0') ans += "0";
    if(s[i] == '1') ans += "1";
    if(s[i] == 'B') {
      if(ans == "") continue;
      ans.erase(ans.end()-1);
    }
  }
  cout << ans << '\n';
  return 0;
}


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

typedef long long ll;

const int p=1e9+7;

inline int power(int x, int y){
	int s=1;
	while (y){
		if (y&1) s=(ll)s*x%p;
		x=(ll)x*x%p; y>>=1;
	}
	return s;
}

const int N=2e5+10;

int fac[N],ifac[N];

inline int C(int n, int m){
	return (ll)fac[n]*ifac[m]%p*ifac[n-m]%p;
}

int main(){
	int n,a,b,c;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	a=(ll)a*power(100-c,p-2)%p;
	b=(ll)b*power(100-c,p-2)%p;
	fac[0]=1;
	for (int i=1;i<=n<<1;i++)
		fac[i]=(ll)fac[i-1]*i%p;
	ifac[n<<1]=power(fac[n<<1],p-2);
	for (int i=(n<<1)-1;~i;i--)
		ifac[i]=(ll)ifac[i+1]*(i+1)%p;
	int ans=0;
	for (int i=0;i<n;i++)
		(ans+=((ll)power(a,n)*power(b,i)%p+(ll)power(a,i)*power(b,n)%p)*C(n+i-1,i)%p*(n+i)%p)%=p;
	printf("%d\n",(ll)ans*100%p*power(100-c,p-2)%p);
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
s = input()

m = 1

for i in range(1,n+1):
    m*=i
    m%=10**9+7

if s[0]=='B' and s[-1]=='B':
    if s.count('B')%2==0:
        l = [1]
        for i in range(1,len(s)):
            if s[i-1]!=s[i] and l[-1]==1:
                l.append(1)
            elif s[i-1]==s[i] and l[-1]==0:
                l.append(1)
            else:
                l.append(0)
        x = [1]
        for i in range(1,len(l)):
            if l[i]==1:
                x.append(x[-1]+1)
            else:
                x.append(x[-1]-1)
        if x[-1]!=0:
            print(0)
            exit()
        ans = 1
        for i in range(len(l)):
            if l[i]==0:
                ans *= x[i-1]
                ans %= 10**9+7
        print(m*ans%(10**9+7))
        exit()
print(0)

Measured memory_bytes: 56948
package main

import (
	"fmt"
	"io"
	"os"
)

func run(input io.Reader, output io.Writer) int {
	var n, k int
	fmt.Fscanf(input, "%d %d\n", &n, &k)

	cnt := 1
	for {
		if n < k {
			break
		}
		cnt++
		n = n / k
	}

	fmt.Println(cnt)

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 512
#pragma warning(disable:4996)
#include <stdio.h>

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

	int a, b;
	a = x / 500;
	b = (x % 500) / 5;
	printf("%d", a * 1000 + b * 5);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int area = a*b;
        int length = a*2+b*2;
        System.out.println(area +" "+ length);
        }
    }


Measured memory_bytes: 26140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// a == -1 is a turn query
struct Query {
  int t, a;

  Query (int _t, int _a) : t(_t), a(_a) {}
};

bool operator< (Query p, Query q) {
  return p.t < q.t;
}

int main () {
  ios::sync_with_stdio(false);

  int cap;
  cin >> cap;

  int K;
  cin >> K;

  vector<Query> queries;
  for (int i = 0; i < K; i++) {
    int r;
    cin >> r;

    queries.push_back(Query(r, -1));
  }

  int Q;
  cin >> Q;

  for (int i = 0; i < Q; i++) {
    int t, a;
    cin >> t >> a;

    queries.push_back(Query(t, a));
  }

  sort(queries.begin(), queries.end());

  int speed = -1, last = 0, l = 0, r = cap, add = 0;
  for (Query q : queries) {
    add += speed * (q.t - last);
    last = q.t;
    
    if (speed == -1) {
      l = max(l, -add);
      if (l > r) r = l;
    } else {
      r = min(r, cap - add);
      if (r < l) l = r;
    }

    if (q.a == -1) {
      speed *= -1;
    } else {
      q.a = min(q.a, r);
      q.a = max(q.a, l);
      cout << q.a + add << '\n';
    }
  }
}


Measured memory_bytes: 2928
MOD = 10**9+7
N = 200000
p = [1] * (N+1)
q = [1] * (N+1)
for i in range(1, N+1):
    p[i] = (p[i-1]*(i)%MOD)
q[0] = pow(p[-1], MOD-2, MOD)
for i in range(1, N+1):
    q[i] = (N-i+1)*q[i-1]%MOD
q.reverse()

def nCk(n,k):
    if k > n or n == 0:
        return 0
    elif k == 0:
        return 1
    else:
        return p[n]*q[k]%MOD*q[n-k]%MOD

h,w,a,b = map(int, input().split())

ans = 0
for i in range(b, w):
    ans += nCk(h-a+i-1, i)*nCk(max(1, w-i-2+a), w-i-1)%MOD
print(ans%MOD)


Measured memory_bytes: 18804
hands_a, hands_b, hands_c = (input() for i in range(3))

hands = {'a': hands_a, 'b': hands_b, 'c': hands_c}

turn = 'a'
while True:
    if len(hands[turn]) == 0:
        print(turn.upper())
        exit()
    next_turn = hands[turn][0]
    hands[turn] = hands[turn][1:]
    turn = next_turn


Measured memory_bytes: 3060
from collections import Counter
 
n = int(input())
a = [int(i) for i in input().split()]
c = Counter()
b = 0
for i in a:
    if i < 3200:
        c.update([i//400])
    else: b += 1
print(len(c) if len(c) else 1, len(c) + b)


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

int main(){
    int s, pre, post;
    string ans;
    cin >> s;
    pre = s / 100;
    post = s % 100;
    if (1 <= pre & pre <= 12 & 1 <= post & post <= 12) ans = "AMBIGUOUS";
    else if (1 <= pre & pre <= 12) ans = "MMYY";
    else if (1 <= post & post <= 12) ans = "YYMM";
    else ans = "NA";
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 01:05:48
*/

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


int main(){
    string s;
    cin >> s;
    if(s[1]=='9' || s[0]=='9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

 


public class Main {
        public static void main(String[] args) {
         
          Scanner sc = new Scanner(System.in);
         
          String s = sc.next(); // こいつにはsnukeが入る
          String t = sc.next(); // こいつにはsnekeeが入る
          
          // ここまではこれでおっけ
         
         // s = s.substring(s.length() -1); こう書いてるけど
         
         String T1 = t.substring(s.length() - 0); // こう書いたらｔの末尾一文字だけを取り出せる

 

           if(t.equals(s+T1)) //あとはTとs+T1が同じだったらみたいな感じの条件式にする
           {
             System.out.println("Yes");
           }
        else{
           System.out.println("No");
            }
         }
      }

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

int main(){
    
    int n;

    cin>>n;

    int a[n];

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

    for(int i = n-1 ;i >= 0 ;i-=2){
        cout<<a[i]<<" ";
    }

    if(n %2 == 0){
    
        for(int i = 0; i < n; i+=2){
            cout<<a[i]<<" ";
        }
        
    }else{

        for(int i = 1; i < n; i+=2){
            cout<<a[i]<<" ";
        }
        
    }
    
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<iostream>
using namespace std;

struct Node{
	int x,y;
}a[210000];
int n;
int prenn[210000],prenx[210000],prexn[210000],prexx[210000],sufnn[210000],sufnx[210000],sufxn[210000],sufxx[210000];

typedef long long ll;

ll ans=1ll<<60;

int cmp(Node x,Node y){
	if(x.x!=y.x)return x.x<y.x;
	return x.y<y.y;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&a[i].x,&a[i].y);
		if(a[i].x>a[i].y)swap(a[i].x,a[i].y);
	}sort(a+1,a+n+1,cmp);
	prenn[0]=1<<30;prenx[0]=0;
	sufnn[n+1]=1<<30;prenx[n+1]=0;
	prexn[0]=1<<30;prexx[0]=0;
	sufxn[n+1]=1<<30;sufxx[n+1]=0;
	for(int i=1;i<=n;i++){
		prenn[i]=min(prenn[i-1],a[i].x);
		prenx[i]=max(prenx[i-1],a[i].x);
		prexn[i]=min(prexn[i-1],a[i].y);
		prexx[i]=max(prexx[i-1],a[i].y);
	}for(int i=n;i;i--){
		sufnn[i]=min(sufnn[i+1],a[i].x);
		sufnx[i]=max(sufnx[i+1],a[i].x);
		sufxn[i]=min(sufxn[i+1],a[i].y);
		sufxx[i]=max(sufxx[i+1],a[i].y);
	}ans=min(ans,(ll)(prenx[n]-prenn[n])*(prexx[n]-prexn[n]));
	for(int i=1;i<=n-1;i++){
		ans=min(ans,(ll)(max(prexx[i],sufnx[i+1])-min(prexn[i],sufnn[i+1]))*(max(prenx[i],sufxx[i+1])-min(prenn[i],sufxn[i+1])));
	}printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8320
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int x=c,ans=0;
  while(1)
  {
    if(c>b)
      break;
    if(c>=a && c<=b)
      ans++;
    c+=x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3448
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def main():

    def gcd(a,b):
        if b>a:
            a,b=b,a
        while b:
            a,b=b, a%b
        return a

    def cul(n,x):
        l=len(x)
        b=[x[i] for i in range(l)]
        b.pop(n)
        tmp=b[0]
        for i in range(1,l-1):
            tmp=gcd(tmp,b[i])
        return tmp

    N, *a = map(int, sys.stdin.read().split())
    p=50
    if p>N: p=N

    ans=0
    for i in range(p):
        s=cul(i,a[:p])
        if s>ans: ans=s
    print(ans)

if __name__=='__main__':
  main()

Measured memory_bytes: 14652
a=[]
a1,a2,c = input().split()
a.append(int(a1))
a.append(int(a2))
c = int(c)
cur = 0
for i in range(c):
    a[1-cur]+=a[cur]//2
    a[cur]//=2
    cur=1-cur
print(a[0], a[1])


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    k = int(input())
    s = '1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51'.split(
        ',')
    print(s[k-1])


main()


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char const* argv[])
{
    int n, l;
    string line;
    vector<string> s;

    cin >> n >> l;
    for (int i = 0; i < n; i++) {
        cin >> line;
        s.push_back(line);
    }
    sort(s.begin(),s.end());
    for (int i = 0; i < n; i++) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<queue>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=1000000000LL;
typedef long long ll;
typedef pair<ll,ll> Pa;
int N,K,A[200005],D[200005]={},B=0,C=INF;
ll L[55],ans=0;
int h;
int main(){
	priority_queue<int,vector<int> > que;
	cin>>N>>K;
	for(int i=0;i<N;++i){
		cin>>A[i];
		++D[A[i]];
	}
	for(int i=0;i<200005;++i){
		que.push(D[i]);
	}
	for(int i=0;i<K;++i){
		int s=que.top();que.pop();
		ans+=s;
	}
	cout<<N-ans<<endl;



	return 0;
}


Measured memory_bytes: 2936
/*
		Author : Kaustubh Gangwar
		||S||A||M||R||A||T||
*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ld long double
#define pb push_back
#define gcd __gcd
#define mp make_pair
#define vii vector<int>
#define vll vector<long long>
#define all(x) x.begin(),x.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
typedef long long  ll;
typedef pair<int,int> pii;

ll bpow(ll a, ll b) {
	a=a;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	ll test=1;
	//cin>>test;
	while(test--)
	{ 
		int x,n;
		cin>>x>>n;
		set<int> s;
		f(i,0,n)
		{
			int a; cin>>a; s.insert(a);
		}
		int j=0;
		while(1)
		{
			if(s.count(x-j)==0)
			{
				cout<<x-j;
				break;
			}
			if(s.count(x+j)==0)
			{
				cout<<x+j;
				break;
			}
			j++;
		}
		
		
	}
return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
	long int n;
	int k;
	int i;

	scanf("%d%d", &n, &k);

	for (i = 0; n > 0; i++)
	{
		n /= k;
	}

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

	return 0;
}


Measured memory_bytes: 128
D=[]
for i in range(5):
  D.append(int(input()))

D_mod_max = D[0]%10
D_remove = D[0]

for i in range(1,5):
  if D_mod_max==0:
    D_remove = D[i]
    D_mod_max = D[i]%10
    
  elif (D[i]%10 != 0) & (D[i]%10 < D_mod_max):
    D_remove = D[i]
    D_mod_max = D[i]%10
    
D.remove(D_remove)

sum=0
for i in range(len(D)):
  if D[i]%10 !=0:
    sum=sum+D[i]+(10-D[i]%10)
  else:
    sum=sum+D[i]

sum=sum+D_remove

print(sum)

Measured memory_bytes: 3064
def solve(c):
    def check(xs):
        xs = [[e - es[0] for e in es] for es in xs]
        return xs[0] == xs[1] and xs[0] == xs[2]
    return check(c) and check(list(zip(*c)))

c = [[int(_) for _ in input().split()] for i in range(3)]

if solve(c):
    print("Yes")
else:
    print("No")


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

const int N = 2010;
char C[N][N];
int A[N][N];
int B[N][N];
int X[N][N];
int Y[N][N];

int h, w;

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

    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(C[i][j] == '#') A[i][j] = 0;
            else{
                if(j > 0) A[i][j] = A[i][j - 1] + 1;
                else A[i][j] = 1;
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = w - 1; j >= 0; j--){
            if(C[i][j] == '#') B[i][j] = 0;
            else{
                if(j < w - 1) B[i][j] = B[i][j + 1] + 1;
                else B[i][j] = 1;
            }
        }
    }

    for(int i = 0; i < w; i++){
        for(int j = 0; j < h; j++){
            if(C[j][i] == '#') X[j][i] = 0;
            else{
                if(j > 0) X[j][i] = X[j - 1][i] + 1;
                else X[j][i] = 1;
            }
        }
    }
        
    for(int i = 0; i < w; i++){
        for(int j = h - 1; j >= 0; j--){
            if(C[j][i] == '#') Y[j][i] = 0;
            else{
                if(j < h - 1) Y[j][i] = Y[j + 1][i] + 1;
                else Y[j][i] = 1;
            }
        }
    }

    /*
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << Y[i][j] << ' ';
        }
        cout << endl;
    }
    */
    
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(C[i][j] == '#') continue;
            int cnt = 1;
            if(j != 0 and j != w - 1){
                cnt += A[i][j - 1] + B[i][j + 1];
            }else if(j == 0 and j != w - 1){
                cnt += B[i][j + 1];
            }else if(j != 0 and j == w - 1){
                cnt += A[i][j - 1];
            }
            if(i != 0 and i != h - 1){
                cnt += X[i - 1][j] + Y [i + 1][j];
            }else if(i == 0 and i != h - 1){
                cnt += Y[i + 1][j];
            }else if(i != 0 and i == h - 1){
                cnt += X[i - 1][j];
            }
            ans = max(ans, cnt);
        }
    }

    cout << ans  << endl;

    return 0;
}

Measured memory_bytes: 67328
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr
N=int(input())
fac=[factor(i+1) for i in range(N)]
A=list(map(int,input().split()))
ball=[0]*N
res=[]
for i in reversed(range(N)):
    y=0
    if ball[i]!=A[i]:
        y=1
        ball[i]=(ball[i]+1)%2
        res.append(i+1)
        for k in fac[i]:
            ball[k-1]=(ball[k-1]+1)%2
print(len(res))
print(*res,sep=' ')

Measured memory_bytes: 113600
def solve():
    A, B, C = map(int, input().split())
    if A == B == C and A % 2 == 0:
        return -1

    cnt = 0
    while True:
        if A % 2 or B % 2 or C % 2:
            return cnt
        A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2
        cnt += 1


print(solve())

Measured memory_bytes: 3060
def dfs(edges, curr, visited = {})
  visited[curr] = true
  next_edges = edges[curr] || []
  next_edges.each do |node|
    next if visited[node]
    dfs(edges, node, visited)
  end
  visited
end

def bridge?(n, abs, i)
  edges = {}
  abs.each_with_index do |ab, j|
    next if j == i
    a, b = ab
    edges[a] ||= []
    edges[b] ||= []
    edges[a] << b
    edges[b] << a
  end
  visited = dfs(edges, abs[0][0])
  visited.keys.length < n
end

n, m = STDIN.gets.split(" ").map(&:to_i)

abs = []
m.times do
  a, b = STDIN.gets.split(" ").map(&:to_i)
  abs << [a, b]
end

ans = 0
for i in 0...m
  ans += 1 if bridge?(n, abs, i)
end
puts ans


Measured memory_bytes: 2172
//https://atcoder.jp/contests/keyence2020/tasks/keyence2020_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    ll N,K,S; cin>>N>>K>>S;
    vector<ll> an(N);
    FOR(i,0,K){
        an[i]=S;
    }
    auto tmp=S+1;
    if(tmp>1e+9) tmp=1;
    FOR(i,K,N){
        an[i]=tmp;
    }
    REP(i,N){
        if(i!=0)cout<<" ";
        cout<<an.at(i);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2048
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		BigDecimal a = new BigDecimal(sc.next());
		BigDecimal b = new BigDecimal(sc.next());

		BigDecimal result = a.multiply(b);
		result =  result.setScale(0, BigDecimal.ROUND_DOWN);

		System.out.println(result);

	}

}

Measured memory_bytes: 36052
#include<cstdio>

using namespace std;

void print(int l,int r,bool ini=false){
	static bool b=false;
	if(ini)	b=false;
	else{
		if(b)		putchar(' ');
		if(l==r)	printf("%d",l);
		else		printf("%d-%d",l,r);
		b=true;
	}
}

int main(){
	for(int n;scanf("%d",&n),n;){
		print(-1,-1,true);

		int l=-100,r=-100;
		for(int i=0;i<n;i++){
			int a;	scanf("%d",&a);
			if(r+1==a)	r++;
			else{
				if(l!=-100)	print(l,r);
				l=r=a;
			}
		}
		print(l,r);
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll a[100009];
ll pre[100009];
int main()
{
	FAST
	#ifdef ayk_16
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	ll n,k,r,p,s;
	string t;
	cin>>n>>k>>r>>s>>p;
	cin>>t;
	for(ll i=0;i<n;i++)
	{
		if(t[i]=='r')
		{
			a[i]=p;
		}
		if(t[i]=='s')
		{
			a[i]=r;
		}
		if(t[i]=='p')
		{
			a[i]=s;
		}
	}
	for(ll i=k;i<n;i++)
	{
		pre[i]=a[i-k];
		if(t[i]==t[i-k])
		{
			a[i]+=pre[i-k];
		}
		else
			a[i]+=a[i-k];
	}
	ll ans=0;
	for(ll i=n-1;i>=(n-k);i--)
		ans+=a[i];
	cout<<ans;
}

Measured memory_bytes: 2000