akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var sides = new int[M, 2];
            for (int i = 0; i < M; i++)
            {
                input = ReadArrayInt();
                sides[i, 0] = input[0];
                sides[i, 1] = input[1];
            }

            var cnt = 0;

            for (int i = 0; i < M; i++)
            {
                var ver = new bool[N + 1];
                ver[0] = true;
                ver[1] = true;
                while (true)
                {
                    var change = false;
                    for (int j = 0; j < M; j++)
                    {
                        if (j != i)
                        {
                            if (!(ver[sides[j, 0]] && ver[sides[j, 1]]) && (ver[sides[j, 0]] || ver[sides[j, 1]]))
                            {
                                ver[sides[j, 0]] = true;
                                ver[sides[j, 1]] = true;
                                change = true;
                            }
                        }
                    }
                    if (!change) break;
                }

                if (!ver.All(b => b)) cnt++;
            }            

            Console.WriteLine(cnt);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
using ll = long long;
using namespace std;

int main(){
    ll n,t,a,h,ans;
    double num=100000;
    cin >> n;
    cin >> t >> a;
    double x = (double)(t-a)/0.006;
    for(ll i=0;i<n;i++){
         cin >> h;
         if(num>abs(x-h)){
             num = abs(x-h);
             ans = i+1;
         }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
program ccc
 
implicit none
integer :: n,i
integer,allocatable,dimension(:) :: h
 
read*, n
allocate(h(n))
read*, h
 
h(1) = h(1) - 1

do i=1,n-1
if(h(i)<h(i+1)) then
h(i+1) = h(i+1) -1
end if
end do
do i=1,n-1
if((h(i)>h(i+1))) then
write(*,'(a2)') 'No'
!write(*,*) h
return
end if
end do
 
write(*,'(a3)') 'Yes'
!write(*,*) h
end program

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
constexpr int MX = 1000005;
char s[MX];
int ac[MX], am[MX], t, n, z, mi[2], aa[2];
int main(){
	scanf("%s", s);
	n = strlen(s);
	rep(i,n) z = max(z, ac[i] = t += s[i] == '1' ? 1 : -1);
	am[n-1] = ac[n-1];
	for(int i=n-2; i>=0; i--) am[i] = max(am[i+1], ac[i]);
	rep(i,n) rep(j,2){
		if(s[i] == '?' && am[i] + aa[j] + 2 <= z + j) aa[j] += 2;
		if(mi[j] > ac[i] + aa[j]) mi[j] = ac[i] + aa[j];
	}
	printf("%d\n", min(z-mi[0],z+1-mi[1]));
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

int n, m;
int walk[200][200], swim[200][200];
int dp[1000][200];

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

    cin >> n >> m;
    while (n || m) {
        rep(i, 200) rep(j, 200) walk[i][j] = swim[i][j] = INF;
        rep(i, m) {
            int3(x, y, t);
            string st;
            cin >> st;
            if (st[0] == 'L') {
                walk[y-1][x-1] = walk[x-1][y-1] = min(walk[x-1][y-1], t);
            } else {
                swim[y-1][x-1] = swim[x-1][y-1] = min(swim[x-1][y-1], t);
            }
        }
        Int(r);
        vector<int> data(r);
        for (int i = 0; i < r; i++) {
            cin >> data[i];
            data[i]--;
        }

        rep(i, n) walk[i][i] = swim[i][i] = 0;
        rep(k, n) rep(i, n) rep(j, n) {
            walk[i][j] = min(walk[i][j], walk[i][k] + walk[k][j]);
            swim[i][j] = min(swim[i][j], swim[i][k] + swim[k][j]);
        }
        rep(i, 1000) rep(j, 200) dp[i][j] = INF;
        dp[0][data[0]] = 0;

        rep(i, r-1) rep(j, n) rep(k, n) {
            if (j != k) 
            dp[i+1][k] = min(dp[i+1][k], dp[i][j] + walk[data[i]][j]
                    + swim[j][k] + walk[k][data[i+1]]);
            else 
            dp[i+1][k] = min(dp[i+1][k], 
                    dp[i][j] + walk[data[i]][data[i+1]]);
        }

        int ans = INF;
        rep(i, n) ans = min(ans, dp[r-1][i]);
        cout << ans << endl;
        cin >> n >> m;
    }
    return 0;
}







Measured memory_bytes: 5336
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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


int main() {
	ll H, W;
	cin >> H >> W;

	vector<vector<char>> a(H + 1, vector<char>(W + 1));
	repn(i, H)repn(j, W) cin >> a[i][j];

	vvmint dp(H + 1, vmint(W + 1, 0));
	dp[1][1] = 1;
	repn(i, H)repn(j, W) {
		if (a[i][j] == '#') { continue; }
		if(i>1||j>1)dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
	}

	cout << dp[H][W] << endl;
}



Measured memory_bytes: 12168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  int x, y;
  cin >> x;
  cout << x / 3600 << ':' << (x % 3600) / 60 << ':' << (x % 3600) % 60 << endl;
  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 2000000
#define MOD 1000000007
#define endl "\n"
lli arr[2005];
lli powa(lli a){
    return a*a*a*a*a;
}
int main(){
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    //cin>>t;
    t = 1;
    while(t--){
        map <lli, pair<lli,lli> > mp;
        for(lli i = -600; i<=600; i++){
            for(lli j = -600; j<=600; j++){
                lli qty = powa(i) - powa(j);
                //cout<<qty<<endl;
                mp[qty] = make_pair(i,j);
            }
        }
        lli x;
        cin>>x;
        cout<<mp[x].first<<" "<<mp[x].second<<endl;
    }

}

Measured memory_bytes: 48692
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <queue>
#include <map>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()
int BFS(int N,//頂点数
vector<vector<int>> M,//辺リスト
map<pair<int,int>,int> &C)//出力用の色分けリスト
{
    queue<int> Q;
    vector<int> used(N,0);
    vector<int> oya(N,0);
    Q.push(0);
    while(!Q.empty()){
        int now=Q.front();
        Q.pop();
        int size=M[now].size();
        int cor=1;
        REP(i,size){
            int pos=M[now][i];
            if(used[pos]!=1){
                if(cor==oya[now]){
                    cor++;
                }
                Q.push(pos);
                oya[pos]=C[make_pair(pos,now)]=C[make_pair(now,pos)]=cor;
                cor++;
            }
        }
        used[now]=1;
    }

    return 0;
}

int main(){
    ll N;
    cin>>N;
    vector<vector<int>> M(N);
    vector<pair<int,int>> P(N-1);
    REP(i,N-1){
        int f,s;
        cin>>f;
        cin>>s;
        f--;s--;
        M[f].push_back(s);
        M[s].push_back(f);
        P[i].first=f;
        P[i].second=s;
    }
    //inputここまで
    int k=0;//max degree of graph
    REP(i,N){
        int p_size=M[i].size();
        if(p_size>k){
            k=p_size;
        }
    }
    map<pair<int,int>,int> C;
    BFS(N,M,C);

    cout<<k<<endl;
    for(auto p:P){
        cout<<C[p]<<endl;
    }
    return 0;
}

Measured memory_bytes: 25344
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Selection of Participants of an Experiment
 */
public class Main {

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			List<Integer> list = new ArrayList<>(n);

			StringTokenizer st = new StringTokenizer(br.readLine());

			for (int i = 0; i < n; i++) list.add(parseInt(st.nextToken()));

			Collections.sort(list);

			int min = Integer.MAX_VALUE;
			for (int i = 0; i < n - 1; i++) {
				min = Math.min(min, list.get(i + 1) - list.get(i));
				if (min == 0) break;
			}

			System.out.println(min);

		} //end while
	} //end main
}

Measured memory_bytes: 31668
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int N,C,K,T[100000];
	vector<int> ve;

	cin>>N>>C>>K;
	REP(i,N) cin>>T[i];
	
	SORT(T,N);
	
	int tem=T[0],cn=1,rider=1;
	FOR(i,1,N){
		if(rider==C||T[i]-tem>K){
			rider=1;
			cn++;
			tem=T[i];
		}else{
			rider++;
		}
	}
	print(cn);

	return 0;
}




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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll N, K;
ll A[200005];
ll F[200005];

bool check(ll n)
{
    ll k = 0;
    REP(i, N)
    {
        if (A[i] * F[i] - n < 0)
            continue;
        ll m = (A[i] * F[i] - n + (F[i] - 1)) / F[i];
        k += m;
    }
    return k <= K;
}

int main()
{
    cin >> N >> K;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N)
    {
        cin >> F[i];
    }
    sort(A, A + N, [](ll a, ll b) { return a > b; });
    sort(F, F + N);

    ll ok = INF, ng = -1;
    while (abs(ok - ng) > 1)
    {
        ll mid = (ok + ng) / 2;
        if (check(mid))
            ok = mid;
        else
            ng = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 3456
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const S=input[0];
  var chunk=[];
  var backing=false;
  var temp=[0];
  for(var i=0;i<S.length;i++){
    if(S[i]==='R'&&backing){
      temp.push(i-1);
      chunk.push(temp.slice());
      temp=[i];
      backing=false;
    }else if(S[i]==='L'&&!backing){
      temp.push(i-1);
      backing=true;
    }
  }
  temp.push(S.length-1);
  chunk.push(temp.slice());
  var ret=new Array(S.length);
  ret.fill(0);
  chunk.forEach(e=>{
    if(e[0]%2!==e[2]%2){
      ret[e[1]]=(e[2]-e[0]+1)/2;
      ret[e[1]+1]=(e[2]-e[0]+1)/2;
    }else if(e[0]%2===e[1]%2){
      ret[e[1]]=(e[2]-e[0]+2)/2;
      ret[e[1]+1]=(e[2]-e[0])/2;
    }else{
      ret[e[1]]=(e[2]-e[0])/2;
      ret[e[1]+1]=(e[2]-e[0]+2)/2;
    }
  });
  console.log(ret.join(' '));
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 47524
a=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for i in range(n):
  b,f,r,v=map(int, input().split())
  a[b-1][f-1][r-1]+=v
for i in range(4):
  for j in range(3):
    for  k in range(10):
      print("",a[i][j][k],end="")
    print()
  if i != 3:
    print("#"*20)


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___prime_factor___////////////////////
map<int, int> prime_factor(int n){
  map<int, int> ret;
  for(int i = 2;i*i <= n;i++){
    while(n % i == 0){
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1){
    ret[n] = 1;
  }
  return ret;
}

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

int n,a[110000];
signed main(){
  cin>>n;rep(i,n)cin>>a[i];
  sort(a, a+n);
  int ok = n-1, ng = -1;
  while(abs(ok-ng) > 1){
    int mid = (ok+ng)/2;bool b = true;
    int x = a[mid];
    rep(i,n){
      if(i == mid)continue;
      if(a[i] > 2*x){
        b = false;break;
      }else{
        x += a[i];
      }
    }
    (b ? ok : ng) = mid;
  }
  cout << n-ok << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)

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

void Main(){
  int N; cin >> N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  sort(all(A), greater<int>());
  ll max1 = 0, max2 = 0;
  rep(i, 0, N - 1){
    if(A[i] == A[i + 1]){
      if(max1 == 0){
        max1 = A[i];
        i++;
      }else{
        max2 = A[i];
        break;
      }
    }
  }
  cout << max1 * max2 << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)

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


bool compare(pair<int, int> a, pair<int, int> b) {
  if(a.second == b.second) return a.first > b.first;
	return a.second > b.second;
}
 
void Main() {
	int N, M; cin >> N >> M;
  vector<vector<int>> J(MAX);
  rep(i, 0, N){
    int A, B; cin >> A >> B;
    J[A].push_back(B);
  }
  priority_queue<int> P;
  int res = 0;
  for(int day = M; day >= 0; day--){
    rep(i, 0, J[M - day].size()) P.push(J[M - day][i]);
    if(!P.empty()){
      res += P.top();
      P.pop();
    }
  }
  cout << res << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,counter=0;
    cin>>A>>B;
   for(int i=13;i<1010;i++){
   if( i*8/100==A&&i/10==B){
     cout<<i<<endl;
     break;}
   counter++;}
  if(counter==997)
  cout<<-1<<endl;}


Measured memory_bytes: 256
an = gets.to_i
n = 1
a = [an]
frag = false
ans = nil
while frag == false do 
  n += 1
  if an % 2 == 0 then an = an/2 
  else an = 3*an + 1
  end
  (a.length-1).downto(0) do |o|
    if a[o] == an 
      ans = n
      frag = true
    end
  end
  a.push(an)
end
puts ans


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

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


ll gcd(ll a,ll b){
    if(b>a) swap(a,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;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}


int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n){
        ans = gcd(ans,a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4000
n = int(input())
a = list(map(int,input().split()))
ans = []
a_xor = a[0]^a[1]

for i in range(2,n):
    a_xor = a_xor ^ a[i]

for i in range(n):
    print(a_xor^a[i], end=' ')

print()


Measured memory_bytes: 31612
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] input = Console.ReadLine().Split(' ');
      int A=int.Parse(input[0]);
      int B=int.Parse(input[1]);
      int C=int.Parse(input[2]);
      int D=int.Parse(input[3]);
      
      while(A>0 && C>0){
        C=C-B;
        A=A-D;
    
    }
    if(C<=0){
      Console.WriteLine("Yes");
  }else{
      Console.WriteLine("No");
    }

}
  }
}


Measured memory_bytes: 27516
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,n;
    int s[100]= {0},h[111]= {0},c[111]= {0},d[111]= {0};
    int j=0,k=0,i,l=0,m=0;
    char c1;
    cin>>n;
    for(i=0; i<n; i++)
    {

        cin>>c1>>a;
        if(c1=='S')
            s[a]=1;
        else if(c1=='H')
            h[a]=1;
        else if(c1=='C')
            c[a]=1;
        else
            d[a]=1;
    }
    for(i=1; i<=13; i++)
    {
        if(s[i]==0)
            cout<<"S"<<" "<<i<<endl;
    }
    for(i=1; i<=13; i++)
    {
        if(h[i]==0)
            cout<<"H"<<" "<<i<<endl;
    }
    for(i=1; i<=13; i++)
    {
        if(c[i]==0)
            cout<<"C"<<" "<<i<<endl;
    }
    for(i=1; i<=13; i++)
    {
        if(d[i]==0)
            cout<<"D"<<" "<<i<<endl;
    }


    return 0;
}



Measured memory_bytes: 3120
import sys;input=sys.stdin.readline
H, W, D = map(int, input().split())
def dist(x, y):
    return abs(x[0]-y[0]) + abs(x[1]-y[1])
X = []
for _ in range(H):
    X.append(list(map(int, input().split())))

d = dict()
for i in range(H):
    x = X[i]
    for j in range(W):
        d[x[j]] = (i, j)
Ls = []
for i in range(1, D+1):
    tmp = [0]
    st = d[i]
    j = i
    while j in d:
        tmp.append(tmp[-1]+dist(st, d[j]))
        st = d[j]
        j += D
    Ls.append(tmp)

Q = int(input())
for _ in range(Q):
    x, y = map(int, input().split())
    a, b = divmod(x, D)
    c, d = divmod(y, D)
    if b > 0:
        print(Ls[b-1][c+1]-Ls[b-1][a+1])
    else:
        print(Ls[b-1][c]-Ls[b-1][a])


Measured memory_bytes: 79324
// ABC99-C
#include <bits/stdc++.h>
#define endl "\n"
#define _GLIBCXX_DEBUG //配列外参照エラー表示,gcc依存
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    vector<int> coin={0,1}; //0は1を1番目にするため
    int num=6;
    while(num<=n){
        coin.emplace_back(num);
        num*=6;
    }
    num=9;
    while(num<=n){
        coin.emplace_back(num);
        num*=9;
    }
    int kind=coin.size()-1; //0が余分なため-1
    vector<vector<int>> dp(kind+10,vector<int>(n+10,n+10));
    for(int i=0;i<=kind;i++) dp[i][0]=0;
    for(int i=1;i<=kind;i++){
        for(int j=1;j<=n;j++){
            if(0<=j-coin[i]) dp[i][j]=min(dp[i][j-coin[i]]+1,dp[i-1][j]);
            else dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
    }
    cout<<dp[kind][n]<<endl;
    //cout<<coin<<endl;
    //cout<<dp<<endl;
    return 0;
}

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

int main(){

  int n;
  cin >> n;
  while(n){
    int out = 0,hit = 0,point= 0;
    while(out != 3){
      string s;
      cin >> s;
      if(s == "OUT") out++;
      else if(s == "HIT"){
	hit++;
	if(hit == 4){
	  point++;
	  hit = 3;
	}
      }
      else if(s == "HOMERUN"){
	point += hit + 1;
	hit = 0;
      }
     
    }
    cout << point<<endl;
    n--;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=55;

/*
int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
*/

ll n,a,b,c,d;

int main(int argc,char *argv[]){
#ifdef CCURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	cin>>n>>a>>b>>c>>d;
	bool suc=false;
	rep(i,0,n-1){
		if(c*(n-1-i)-d*i<=b-a&&(n-1-i)*d-c*i>=b-a){
			suc=true;
			break;
		}
	}
	if(suc)puts("YES");else puts("NO"); 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int64_t query(vector<int64_t> &dp,int l,int r,int v,int b,int e){
  if(b>=r||e<=l)
    return 0;
  if(b<=l&&e>=r)
    return dp[v];
  int h=(l+r)/2;
  return max(query(dp,l,h,v*2,b,e),query(dp,h,r,v*2+1,b,e));
}
void update(vector<int64_t> &dp,int l,int r,int v,int i,int64_t x){
  if(i<l||i>=r)
    return;
  if(l==i&&r==i+1){
    dp[v]=x;
    return;
  }
  int h=(l+r)/2;
  update(dp,l,h,v*2,i,x);
  update(dp,h,r,v*2+1,i,x);
  dp[v]=max(dp[v*2],dp[v*2+1]);
  return;
} 
int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
    h.at(i)--;
  }
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  vector<int64_t> dp(n*4,0);
  for(int i=0;i<n;i++){
    int64_t q=query(dp,0,n,1,0,h.at(i));
    update(dp,0,n,1,h.at(i),q+a.at(i));
  }
  cout<<dp[1]<<endl;
}

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

using ll =                   long long int;
using pll =                  pair<ll, ll>;
#define endl                 "\n"
#define space                " "
#define TLE_na_ho            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MAX_SIZE             1024
#define MOD                  1000000007
#define pb                   push_back
#define fi                   first
#define se                   second
#define rep(i,a,n)           for(ll i=a;i<n;i++)
#define repe(i,a,n)          for(ll i=a;i<=n;i++)
#define repr(i,a,n)          for(ll i=a;i>=n;i--)
#define ain(arr,n)           for(ll i1=0;i1<n;i1++ ) cin>>arr[i1]
#define aout(arr,n)          for(ll i1=0;i1<n;i1++ ) cout<<arr[i1]<<space


int main()
{
    TLE_na_ho;
    double n;
    cin>>n;
    if(n==0.0)
    	cout<<"1";
    else if(n==1.0)
    	cout<<"0";

}


Measured memory_bytes: 3700
import sys
sys.setrecursionlimit(10**6)

N,M=map(int, sys.stdin.readline().split())

nl=[ [] for i in range(N+1) ] 

for i in range(M):
	x,y=map(int, raw_input().split())
	nl[x].append(y)


memo={}

def depth(n):
	if n in memo: return memo[n]
	ret=0
	if len( nl[n] )==0:
		return 0
	else:
		for x in nl[n]:
			ret=max(ret, depth(x)+1)
	memo[n]=ret
	return ret


ans=0
for i in range(1,N+1):
	ans=max( ans , depth(i) )

print ans

Measured memory_bytes: 172572
#include <stdio.h>
int main(){
  long long n,a[5],min;
  scanf("%lld",&n);
  for (int i=0;i<5;i++) scanf("%lld",&a[i]);
  min=a[0];
  for (int i=1;i<5;i++){
    if (min>a[i]) min=a[i];
  }
  printf("%lld\n",(n+min-1)/min+4);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    ll n, x, y, l;
    cin >> n >> x >> y;
    vector<ll> ans(n);
    queue<ll> q;
    x--; y--;
    rep(fv,n){
        q.push(fv);
        vector<ll> dist(n, -1);
        dist.at(fv)=0;
        while(!q.empty()){
            ll v = q.front(); q.pop();
            if(v==x){
                if(dist.at(y)==-1){
                    q.push(y);
                    dist.at(y)=dist.at(v)+1;
                }
            }
            if(v==y){
                if(dist.at(x)==-1){
                    q.push(x);
                    dist.at(x)=dist.at(v)+1;
                }
            }
            if(v+1<n){
                if(dist.at(v+1)==-1){
                    q.push(v+1);
                    dist.at(v+1)=dist.at(v)+1;
                }
            }
            if(v-1>=0) {
                if(dist.at(v-1)==-1){
                    q.push(v-1);
                    dist.at(v-1)=dist.at(v)+1;
                }
            }
        }
        rep(i, n){
            ans.at(dist.at(i))++;
        }
    }
    for(int i=1;i<n;i++){
        cout << ans.at(i)/2 << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
L_ = []
for i in range(N):
    L_ += [L[i]*(10**3) + (N-i-1)]
# length_list[m] m 以下の長さの辺の個数
length_list = [0] * (10**3 + 1)
for i in range(N):
    length_list[L[i]] += 1
for i in range(10**3):
    length_list[i+1] += length_list[i]

length_list_ = [0] * (2* 10**6 + 1)
for i in range(N):
    length_list_[L_[i]] += 1
for i in range(2* 10**6):
    length_list_[i+1] += length_list_[i]
    
ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += max(0, length_list_[L_[j]-1] - length_list[(L[i]-L[j])] )
print(ans)

Measured memory_bytes: 57308
def luca(n):
    memo =[0 for _ in range(100)]
    
    memo[0] = 2
    memo[1] = 1
    
    for i in range(n):
        memo[i+2] = memo[i] + memo[i+1]
    
    return memo


n = int(input())
ans = luca(n)

print(ans[n])

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define OUT(x) cout<<(x)<<"\n"
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)
#define pb push_back
#define mp make_pair

const int mod = 1e9 + 7;
int n;

int main() {
    FASTIO;
    cin >> n;
    vi cnt(n+5, 0);

    rep(i,n){
        int a; cin >> a;
        if((a == 0 and cnt[0]) or (n%2 == 0 and a%2 == 0)
                or (n%2 == 1 and a%2 == 1)){
            puts("0");
            return 0;
        }
        ++cnt[a];
    }

    bool f = true;
    ll res = 1;
    rep(i,n){
        if(n % 2 == 0) {
            if(cnt[i] and i % 2 == 0) f = false;
            if(i!=0 and i%2 == 1) res *= 2;
            res %= mod;
        }
        else{
            if(cnt[i] and i % 2 == 1 and i != 0) f = false;
            if(i == 0 and cnt[0] != 1) f = false;
            if(i!=0 and i%2 == 0) res *= 2;
            res %= mod;
        }
    }

    OUT(f ? res : 0);
    return 0;
}


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

const int Max = 1500;
struct Node
{
    int height, pos;
};
int H, W;
int G[Max][Max], T[Max][Max];

int main()
{
    cin >> H >> W;
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            cin >> G[i][j];
        }
    }
    //标记
    for(int j=0; j<W; j++)
    {
        for(int i=0; i<H; i++)
        {
            if(G[i][j])
            {
               T[i][j] = 0;
            }
            else
            {
                if(i==0)
                    T[i][j] = 1;
                else
                    T[i][j] = T[i-1][j]+1;
            }
            //cout << T[i][j] << " ";
        }
       // cout << endl;
    }

    //栈式动态规划
    stack<Node> S;
    int maxv = 0, area = 0;
    for(int i=0; i<H; i++)
    {
        T[i][W] = 0;
        for(int j=0; j<=W; j++)
        {
            Node rect;
            rect.height = T[i][j];
            rect.pos = j;
            if(S.empty())
                S.push(rect);
            else
            {
                if(S.top().height<rect.height)
                {
                    S.push(rect);
                }
                else if(S.top().height>rect.height)
                {
                    int target = j;
                    while(!S.empty() && S.top().height>=rect.height)
                    {
                        Node pre = S.top(); S.pop();
                        area = (j-pre.pos)*pre.height;
                        maxv = max(maxv, area);
                        target = pre.pos;
                    }
                    rect.pos = target;
                    S.push(rect);
                }
            }
        }
    }
    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 19504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	int n; cin >> n;
	long double sum = 0;
	rep(i, n)
	{
		string u;
		long double x;
		cin >> x >> u;
		if (u == "JPY")
			sum += x;
		else
			sum += (x * 380000.0);
	}
	printf("%Lf\n", sum);
	return (0);
}


Measured memory_bytes: 256
import java.util.*;

class Main{

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

        long mod = (long)Math.pow(2,32);

        int dataset = sc.nextInt();
        while(dataset-->0){
            long[] N = new long[9];
            for(int i=0; i<9; i++){ 
                String s = sc.next();
                N[i] = Long.parseLong(s, 16);
            }

            long k = (long)0;

            for(int i=0; i<32; i++){
                long sum = (long)0;
                for(int j=0; j<8; j++) sum += N[j] ^ k;
                if((sum & (long)Math.pow(2, i)) != ((N[8] ^ k) & (long)Math.pow(2, i))){
                    k |= (long)Math.pow(2,i);
                }
            }
            System.out.println(Long.toString(k, 16));
        }
    }

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

Measured memory_bytes: 22588
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ans = count(begin(S), end(S), '+');
  ans -= count(begin(S), end(S), '-');
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);
        var c = int.Parse(spl[2]);
        var x = int.Parse(spl[3]);
        var y = int.Parse(spl[4]);

        long min = long.MaxValue;

        for(int i = 0; i<=Math.Max(x,y)*2; i+=2) {
            long yen = c * i;

            int tmp = (x - i / 2);
            yen += a * (tmp > 0 ? tmp : 0);

            tmp = (y - i / 2);
            yen += b * (tmp > 0 ? tmp : 0);

            min = Math.Min(min, yen);
        }

        return min;
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

class Main {

    static double hoge(double x) {
        if (-0.0004 < x && x < 0.0004) {
            return 0.0;
        }
        return x;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            double a = scan.nextDouble();
            double b = scan.nextDouble();
            double c = scan.nextDouble();
            double d = scan.nextDouble();
            double e = scan.nextDouble();
            double f = scan.nextDouble();

            double x = hoge(((e * c) - (b * f)) / ((e * a) - (b * d)));

            System.out.printf("%.3f", x);
            System.out.print(" ");

            double y = hoge(((d * c) - (a * f)) / ((d * b) - (a * e)));

            System.out.printf("%.3f", y);
            System.out.println("");
        }
    }
}



Measured memory_bytes: 28376
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
char s[5005][4004];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        sum += a * b;
        
        ans += sum / 9;
        sum %= 9;

        c += b;
    }
    if(sum == 0){
        ans --;
    }
    ans = c - 1 + ans;
    p(ans);



    return 0;
}


















Measured memory_bytes: 13696
import math
from queue import Queue

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

gh = {}
for i in range(m):
    p1, p2 = map(int, input().split(" "))
    if p1 in gh:
        gh[p1].append(p2)
    else:
        gh[p1] = [p2]

    if p2 in gh:
        gh[p2].append(p1)
    else:
        gh[p2] = [p1]

_mp = [-1 for _ in range(n)]
_mp[0] = 0
q = Queue()
q.put(1)

while q.qsize() != 0:
    cp = q.get()
    for p in gh[cp]:
        if _mp[p - 1] != -1: continue
        q.put(p)
        _mp[p - 1] = cp

for k, v in gh.items():
    if len(v) == 0:
        print("No")
        exit()

print("Yes")
for mpi in _mp[1:]:
    print(mpi)


Measured memory_bytes: 41156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back

int main(){
    ll n;
    cin>>n;
    ll x,y;
    // vector<pair<ll,ll>> vp;
    // vector<ll> v1;
    // vector<ll> v2;
    vector<int> a,b;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        a.pb(x+y);
        b.pb(x-y);
        // vp.push_back({x,y});
        // v1.pb(x);
        // v2.pb(y);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll ans=0;
    // sort(vp.begin(),vp.end());
    // for(int i=0;i<n;i++){
    //     for(int j=i+1;j<n;j++){
    //         ans = max(ans, (abs(vp[i].f-vp[j].f) + abs(vp[i].s-vp[j].s)));
    //     }
    // }
    // for(int i=0;i<n;i++){
    //     ans = max(ans, (abs(vp[0].f-vp[i].f) + abs(vp[0].s-vp[i].s)));
    // }
    // ll ans = dist(v1, n) + dist(v2, n);
    // sort(v.begin(),v.end());
    ans = max(abs(a[n-1]-a[0]), abs(b[n-1]-b[0]));
    cout<<ans;
}

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

int main() {
  int N,Q;
  cin >> N;
  long long sum = 0;
 
  vector<int>A(N);
  vector<int>count(100000,0);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    count.at(A.at(i)-1)++;
    sum += A.at(i);
  }
  cin >> Q;
  
  vector<int>B(Q);
  vector<int>C(Q);
  for (int i = 0; i < Q; i++) {
    cin >> B.at(i) >> C.at(i);
  }
  
  for (int i = 0; i < Q; i++) {
    count.at(C.at(i)-1) += count.at(B.at(i)-1);
    sum += (count.at(B.at(i)-1)) * (C.at(i)-B.at(i));
    count.at(B.at(i)-1) = 0; 
    cout << sum << endl;
  }
}

Measured memory_bytes: 4832
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    A,B,C =map(int,input().split())
    K =int(input())

    count =0
    while A>=B:
        B*=2
        count +=1

    while B>=C:
        C*=2
        count +=1
    if count >K:
        print("No")
    else:
        print("Yes")






if __name__ == "__main__":
    main()


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

int main(){
  int K;
  string S;
  cin >> K >> S;
  int L=S.size();
  if(L<=K){
    cout << S << endl;
  }
  else{
    cout << S.substr(0, K) << "..." << endl;
  }
}

Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String[] args) throws IOException {
        int A = in.nextInt();
        String op = in.next();
        int B = in.nextInt();
        
        if(op.equals("+")){
            println(A+B);
        }
        else{
            println(A-B);
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);
    static void read(int arr[], int N) throws IOException{ for(int i = 0; i < N; i++){ arr[i] = in.nextInt(); } }
    static void read(long arr[], int N) throws IOException{ for(int i = 0; i < N; i++){ arr[i] = in.nextLong(); } }
    static void read(String arr[], int N) throws IOException{ for(int i = 0; i < N; i++){ arr[i] = in.next(); } }
    static void print(Object O){ out.print(O); }
    static void println(Object O){ out.println(O); }
    static void print(int arr[]){ for(int i = 0; i < arr.length; i++){ print(arr[i]+" "); } println(""); }
    static void print(int arr[][]){ for(int i = 0; i < arr.length; i++){ print(arr[i]); } }
    static void debug(Object O){ System.out.println(O); }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 20564
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARounding solver = new ARounding();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARounding {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int a = in.nextInt();
            if (x < a) out.println(0);
            else out.println(10);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21716
n, x = [int(w) for w in input().split()]
a_li = [int(w) for w in input().split()]
a_li.sort()

ans = 0
for a in a_li:
    x -= a
    if x >= 0:
        ans += 1
    else:
        break

if x == 0:
    pass
else:
    if x > 0:
        ans = max(ans - 1, 0)

print(ans)


Measured memory_bytes: 9116
from collections import deque

H, W = map(int, input().split())
m = [list(input()) for i in range(H)]
ans = 0

for h in range(H):
  for w in range(W):
    if m[h][w] == "#": continue
    q = deque([(h, w, 0)])
    used = set()
    while q:
      h, w, c = q.popleft()
      if (h, w) in used: continue
      ans = max(ans, c)
      if 0 <= h-1 and m[h-1][w] == "." and (h-1, w) not in used: q.append((h-1, w, c+1))
      if h+1 < H  and m[h+1][w] == "." and (h+1, w) not in used: q.append((h+1, w, c+1))
      if 0 <= w-1 and m[h][w-1] == "." and (h, w-1) not in used: q.append((h, w-1, c+1))
      if w+1 < W  and m[h][w+1] == "." and (h, w+1) not in used: q.append((h, w+1, c+1))
      used.add((h, w))
print(ans)

Measured memory_bytes: 63980