akhauriyash/Code-Regression huggingface dataset:
N = int(input())
T = [list(map(int, input().split())) for _ in range(N-1)]


for i in range(N-1):
    t = T[i][1]+T[i][0]
    for j in range(i+1, N-1):
        if t < T[j][1]:
            t = T[j][1]
        if t%T[j][2] == 0:
            t += T[j][0]
        else:
            t += T[j][0]-t%T[j][2]+T[j][2]
    print(t)
print(0)

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, d, x;
	cin >> n >> d >> x;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int total = x;
	for (int i = 0; i < n; ++i) {
		int temp = (d - 1) / a[i] + 1;
		total += temp;
	}
	cout << total << '\n';
	
	return 0;
}


Measured memory_bytes: 256
import sys

mod = 10**9 + 7
n = 10**6
 
fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
    fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
    rfact[i-1] = r = r * i % mod

#nPk (mod MOD) を求める
def perm(n, k):
    return fact[n] * rfact[n-k] % mod
 
# nCk (mod MOD) を求める
def comb(n, k):
    return fact[n] * rfact[k] * rfact[n-k] % mod

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

if abs(n-m) > 1:
    print('0')
    sys.exit()

print(2*(perm(n,n)*perm(m,m))%mod) if n == m else print((perm(n,n)*perm(m,m))%mod)

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

int main() {
  long long h, w;
  cin >> h >> w;
  long long ans = 0;

  if(h==1 || w == 1){
    cout << 1;
    return 0;
  }

    if (h % 2 == 1 && w % 2 == 1){
      ans = (h * w) / 2 + 1;   
    }
    else
    {
      ans = (h * w) / 2;
      }

  cout << ans;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  string s;
  A--, B--, C--, D--;
  function<bool(int, int)> check = [&](int x, int y) {
    for (int i = x + 1; i < y; i++) {
      if (i < N - 1 && s[i] == '#' && s[i + 1] == '#') return false;
    }
    return true;
  };
  cin >> s;
  if (C < D) {
    if (check(A, C) && check(B, D)) yes(); no();
  } else {
    bool f = false;
    for (int i = B - 1; i <= min(D - 1, N - 2); i++) {
      if (i < N - 2 && s[i + 1] == '#' && s[i + 2] == '#') no();
      if (i < N - 2 && s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
        s[i + 1] = '#';
        f = true;
        break;
      }
    }
    if (!f) s[D] = '#';
    if (check(A, C) && check(B, D)) yes(); no();
  }
}


Measured memory_bytes: 592
#include <stdio.h>

int POW(int a, int b){
	int result=1;
	for(int i=0;i<b;i++){
		result=a*result;
	}
	return result;
}

int main(void) {
	int X,temp=1;
	scanf("%d",&X);
	
	int MAX=1;
	

	
	for(int i=1;i<X;i++){
		for(int j=2;;j++){
			temp=POW(i,j);
			
			if(temp>MAX){
				if(temp<=X)
					MAX=temp;
			}
			
			if(POW(i,j)==POW(i,j-1)){
				break;
			}
			if(temp>X){
				break;
			}
			
			
			
			
		}
		//temp=1;
	}
	
	//printf("%d",POW(1,2));
	printf("%d\n",MAX);
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int m;
int main(){
  scan(m);
  prin(48-m);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
const long double PI = acos(-1.0);
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;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   ll m;
           cin>>m;
           vll d(m),c(m);
           ll ans=0;
           rep(i,0,m){
             cin>>d[i]>>c[i];
             ans+=c[i];
           }
           ll cnt=0;
           rep(i,0,m){
             cnt+=d[i]*c[i];
             while(cnt>=10){
               ll c=cnt/10;
               ans+=c;
               cnt%=10;
               cnt+=c;
             }
           }
           cout<<ans-1<<endl;
}

Measured memory_bytes: 6336
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n = int(input())
    A = list(map(int,input().split()))
    A.sort(reverse=True)
    ans = A.pop(0)
    if n % 2 == 0: #偶数
        ans += sum(A[: (n // 2 - 1)]) * 2
    else: # 奇数
        ans += sum(A[: (n // 2 - 1)]) * 2
        #print(ans)
        #print(A[n // 2 - 1])
        ans += A[n // 2 - 1]
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 49988
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
const int maxn = 62, mlg = 18, rt = 1<<10, mod = 1e9 + 7;
int dp[maxn][2][2][2];//[current_bit][sum flag leqal/greater][xor flag lequal/greater][carry out]
ll n;
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
void solve() {
	memset(dp, 0, sizeof dp);
	dp[0][0][0][0] = 1;
	for(int i = 0; i < 60; i++) {
		int ncur = ((n>>i)&1);
		for(int sf = 0; sf < 2; sf++) {
			for(int xf = 0; xf < 2; xf++) {
				for(int co = 0; co < 2; co++) {
					for(int c1 = 0; c1 < 2; c1++ ) {
						for(int c2 = 0; c2 <= c1; c2++) {
							int cur = (c1 + c2 + co)&1;
							int nco = !!((c1 + c2 + co)&2);
							int nsf = ncur == cur ? sf : (cur > ncur);
							int nxf = ncur == (c1^c2) ? xf : ((c1^c2) > ncur);
							add(dp[i+1][nsf][nxf][nco], dp[i][sf][xf][co]);
						}
					}
				}
			}
		}
	}
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	solve();
	cout << dp[60][0][0][0];
} 


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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

const long long MAX = 110000;
long long N;
vector<long long> x, y;

long long solve() {
    UnionFind uf(MAX * 2);
    x.resize(N); y.resize(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i], uf.merge(x[i], y[i] + MAX);

    // 連結成分ごとに、左ノードと右ノードの個数を数える
    map<int, long long> mx, my;
    for (int i = 0; i < MAX; ++i) mx[uf.root(i)]++;
    for (int i = MAX; i < MAX*2; ++i) my[uf.root(i)]++;
    long long res = 0;
    for (int r = 0; r < MAX*2; ++r) res += mx[r] * my[r];
    return res - N;
}

int main() {
    cin >> N;
    cout << solve() << endl;
}


Measured memory_bytes: 30208
S = input()

if len(S) % 2 != 0:
	S = S[0:len(S) - 1]
else:
	S = S[0:len(S) - 2]


while len(S) > 0:	
	if S[0:int(len(S)/2)] == S[int(len(S)/2) : len(S)]:
		print(len(S))
		break
	S = S[0:len(S) - 2]

Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vi v(3);
	v[0] = a;
	v[1] = b;
	v[2] = c;
	sort(all(v));
	cout << v[2]*10+v[1]+v[0] << endl;
}


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

using namespace std;

int main() {
	
	int n;
	cin >> n;
	priority_queue<int> qe[n];
	
	int n2;
	cin >> n2;
	
	int choice;
	int temp, temp2;
		
	for(int i=0;i<n2;i++) {
		
		cin >> choice;
		
		switch(choice) {
			
			case 0:
				cin >> temp >> temp2;
				qe[temp].push(temp2);
				break;
				
			case 1:
				cin >> temp;
				
				if(qe[temp].size() == 0)
					break;
					
				else
					cout << qe[temp].top() << "\n";
				break;
				
			case 2:
				cin >> temp;
				
				if(qe[temp].size() == 0)
					break;
				
				else
					qe[temp].pop();
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 4008
#include<cstdio>
#include<algorithm>

using namespace std;

long long vals[50];
long long N;
long long M;

long long dfs(int id,int toTake,int taken,long long curVal,bool flg){
//	printf("%d %d %d %lld\n",id,toTake,taken,curVal);
	if(id==-1){
		if(taken==toTake) return curVal;
		else return -1;
	}
	if(toTake==taken){
		return curVal;
	}
	long long nxtVal=curVal+vals[id];
//	printf("nxt=%lld\n",nxtVal);
	long long res=-1;
	if(nxtVal>M){
		res=dfs(id-1,toTake,taken,curVal,flg);
		return res;
	}
	if(flg==false){
		//not take
		res=dfs(id-1,toTake,taken,curVal,true);
	}
	long long res2=dfs(id-1,toTake,taken+1,nxtVal,flg);
	res=max(res,res2);
	return res;
}

long long dfs2(int id,int toTake,int taken,long long curVal){
	if(id==-1){
		if(toTake!=taken) return -1;
		if(curVal<M) return -1;
		return curVal;
	}
	long long nxtVal=curVal+vals[id];
	if(toTake==taken+id+1){
		long long tmp=dfs2(id-1,toTake,taken+1,nxtVal);
		return tmp;
	}
	long long notTake=curVal;
	for(int i=1;i<=toTake-taken;i++){
		notTake+=vals[id-i];
	}
	long long res;
	if(notTake>=M){
		res=dfs2(id-1,toTake,taken,curVal);
	}else{
		res=dfs2(id-1,toTake,taken+1,nxtVal);
	}
	return res;
}

long long mult(long long a,long long b,long long c){
	long long x=c/a;
	if(b>x) return -1;
	long long res=a*b;
	if(res>c) return -1;
	return res;
}

int main(){
	long long a,b,p,q;
	scanf("%lld%lld%lld%lld%lld%lld",&N,&M,&a,&b,&p,&q);
	if(a==1&&b==1){
		long long x=p+q;
		long long num=M/x;
		num=min(num,N);
		long long train=x*num;
		long long ans=M-train;
		if(num+1<=N){
			train+=x;
			ans=min(ans,train-M);
		}
		printf("%lld\n",ans);
		return 0;
	}
	long long pa=1,pb=1;
	int n=0;
	for(int i=0;i<N;i++){
		long long cur1=mult(pa,p,M*2);
		long long cur2=mult(pb,q,M*2);
		if(cur1==-1||cur2==-1) break;
		long long cur=cur1+cur2;
		if(cur>M*2) break;
		vals[n++]=cur;
		pa=mult(pa,a,M*2);
		pb=mult(pb,b,M*2);
		if(pa==-1||pb==-1) break;
	}
	if(n==0){
		printf("%lld\n",M);
		return 0;
	}
//	for(int i=0;i<n;i++){
//		printf("%d %lld\n",i,vals[i]);
//	}
	N=n;
	long long ans=M;
	for(int i=1;i<=n;i++){
		long long tmp=dfs(n-1,i,0,0,false);
//		printf("%d %lld\n",i,tmp);
		if(tmp==-1) continue;
		ans=min(ans,M-tmp);
	}
	for(int i=1;i<=n;i++){
		long long tmp=dfs2(n-1,i,0,0);
		if(tmp==-1) continue;
		ans=min(ans,tmp-M);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int a[100005], n, m;
vector<int> v;
signed main(){
	cin >> n >> m;
	if(n >= m) {
		cout << 0;
		return 0;
	}
	for(int i = 1 ; i <= m ; i ++)
		cin >> a[i];
	sort(a + 1, a + m + 1);
	int ans = a[m] - a[1];
	for(int i = 1 ; i < m ; i ++)
		v.push_back(a[i + 1] - a[i]);
	sort(v.begin(), v.end(), greater<int>());
	for(int i = 0 ; i < n - 1 ; i ++)
		ans -= v[i];
	cout << ans;
}


Measured memory_bytes: 2168
import Data.List

solve :: Int -> [Int] -> Int
solve n [] = n
solve n l
  | 0 /= getIndex l = solve (n+1) $ change l $ getIndex l
  | otherwise = solve n (tail l)
    where getIndex l = (\(Just x) -> x) $ elemIndex (minimum l) l
          change l i = tail $ (take i l) ++ [head l] ++ drop (i + 1) l
main = do
 list <- fmap (map read . tail . words) getContents
 putStrLn $ unwords $ map show $ sort $ list
 print $ solve 0 list

Measured memory_bytes: 4004
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

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

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

ll calc(int k, ll a) {
    if (k == 2) {
        return (a + 1) % 2;
    } else if (1 <= k && k <= 3) {
        return (a == 0 ? 2 : a % 2);
    } else {
        return a;
    }
}

int main() {
    int N;
    cin >> N;
    ll a[N + 2];
    for (int i = 1; i <= N; ++i) cin >> a[i];
    a[N + 1] = 0;

    ll dp[N + 2][5];
    fill(dp[0], dp[1], 0);
    fill(dp[1], dp[N + 2], INF);

    for (int i = 1; i <= N + 1; ++i) {
        for (int k = 0; k < 5; ++k) {
            ll m = *min_element(dp[i - 1], dp[i - 1] + k + 1);
            dp[i][k] = m + calc(k, a[i]);
        }
    }

    cout << dp[N + 1][4] << endl;
    return 0;
}


Measured memory_bytes: 9728
import sys


#https://note.nkmk.me/python-union-find/
class AlgUnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    ab = [list(map(int, readline().split())) for _ in range(m)]
    for i in range(m):
        ab[i][0] -= 1
        ab[i][1] -= 1
    ans = []
    uf = AlgUnionFind(n)
    cnt = 0
    for i in range(m):
        if i == 0:
            ans.append(n * (n - 1) // 2)
        else:
            ans.append(n * (n - 1) // 2 - cnt)
        a, b = ab[-i-1]
        if not uf.same(a, b):
            cnt += uf.size(a) * uf.size(b)
        uf.union(a, b)
    ans.reverse()
    print(*ans, sep="\n")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 104156
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

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


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

    int x, n;
    cin >> x >> n;

    vector<int> p(n);

    rep(i,n){
        cin >> p[i];
    }

    sort(all(p));

    int res = LINF;

    for(int i = 0; i <= 101; ++i){
        if(!binary_search(all(p), i)){
            if(abs(res - x) > abs(i - x)){
                res = i;
            }else if(abs(res - x) == abs(i - x)){
                chmin(res, i);
            }
        }
    }

    cout << res << '\n';

    return (0);
}


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

using namespace std;

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (T &i: v) os << i << ",";
  os << "]";
  return os;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

typedef pair<int, int> pii;
const int MAXN = 2010;

int N, M;
vector<int> adj[MAXN];
int par[MAXN][MAXN], id[MAXN][MAXN];
int ans;

void dfs1(int here, int pre, int rt){
  par[rt][here] = pre;
  for(int there : adj[here]) if(there != pre) dfs1(there, here, rt);
}

void add(int a, int b){
  if(id[a][b] == b || id[b][a] == a) return;
  else if(id[a][b] != -1) add(id[a][b], b);
  else if(id[b][a] != -1) add(id[b][a], a);
  else {
    vector<pii> nxt;
    queue<int> q;

    id[a][b] = b; id[b][a] = a;
    
    q.push(b);
    while(q.size()){
      int here = q.front(); q.pop();
      for(int there : adj[here]){
        if(there != par[a][here]) {
          if(id[a][there] != -1) nxt.emplace_back(there, b);
          else {
            id[a][there] = b;
            q.push(there);
          }
        }
      }
    }
    q.push(a);
    while(q.size()){
      int here = q.front(); q.pop();
      for(int there : adj[here]){
        if(there == par[b][here]) continue;
        if(id[b][there] != -1)  nxt.emplace_back(there, a);
        else{
          id[b][there] = a;
          q.push(there);
        }
      }
    }
    for(pii val : nxt) add(val.first, val.second);
  }
}

void dfs2(int here, int pre, int rt){
  if(id[rt][here] == here) ans++, rt = here;
  for(int there : adj[here]){
    if(pre != there) dfs2(there, here, rt);
  }
}

int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  cin >> N >> M;
  for(int x, y, i = 1 ; i <= N - 1 ; i++) cin >> x >> y, adj[x].push_back(y), adj[y].push_back(x);

  for(int i = 1 ; i <= N ; i++) dfs1(i, -1, i);
  memset(id, -1, sizeof(id));

  int cnt = 0;
  while(M--){
    int x, y;
    cin >> x >> y;
    add(x, y);
  }
  
  for(int i = 1 ; i <= N ; i++) {
    for(int j : adj[i]) dfs2(j, i, i);
  }
  
  cout << ans / 2 << '\n';
  return 0;
}

Measured memory_bytes: 32384
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int[] line1 = ReadIntArray();
    int N = line1[0], M = line1[1];
    Dictionary<int,int> dic = new Dictionary<int,int>();
    // key is price, value is quantity.
    for (int i = 0; i < N; i++) {
      int[] line2 = ReadIntArray();
      if (dic.ContainsKey(line2[0])) {
        dic[line2[0]] += line2[1];
      } else {
        dic.Add(line2[0], line2[1]);
      }
    }
    var _dic = dic.OrderBy(x => x.Key);
    long res = 0;
    int c = 0;
    foreach (var i in _dic) {
      if (c + i.Value > M) {
        res += (M-c) * (long)i.Key;
        break;
      } else {
        res += i.Key * (long)i.Value;
        c += i.Value;
      }
    }
    Console.WriteLine(res);
  }

  private static string ReadStr() { return Console.ReadLine(); }
  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout << x2 - y2 + y1 << " " << y2 + x2 - x1 << " " << x1 - y2 + y1 << " " << y1 + x2 - x1 << endl;
}

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

int main(){
  int N;
  vector<int> V(N), C(N),X(N);
  cin >>N;
  int sum=0;
  for(int i=0 ; i<N; i++){
    cin >> V.at(i);}
  for(int i=0; i<N; i++){
    cin >> C.at(i);
    X.at(i)=V.at(i)-C.at(i);
  if(sum+X.at(i)>sum){
    sum+=X.at(i);}
    
  }
  cout << sum << endl;}
  

Measured memory_bytes: 640
def main():
  import sys
  n=int(input())
  w=list(map(int,sys.stdin.read().split()))
  #w=sorted(v,reverse=False)
  w.sort()
  ans=(w[0]+w[1])/2
  for i in range(2,n):
    ans=max(ans,ans/2+w[i]/2)
  print(ans)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 3060
class WarshallFloyd(object):

    def __init__(self, adj):
        """
        ワーシャル・フロイド法によって全頂点間の最短距離を O(|V|^3) で計算する。

        :param adj: 隣接行列 adj[i][j] でi番目の頂点からj番目の頂点へのコストを示す パスがなければINF
        """
        self._dist = adj  # 各頂点間の最短距離 初期値として隣接行列をそのまま用い、[i, i]要素を0に初期化する
        for i in range(len(adj)):
            self._dist[i][i] = 0

        self._solve()

    def _solve(self):
        v_len = len(self._dist)
        for i in range(v_len):  # 経由する頂点
            for j in range(v_len):  # 開始頂点
                for k in range(v_len):  # 終端
                    self._dist[j][k] = min(self._dist[j][k], self._dist[j][i] + self._dist[i][k])

    def distance(self, start, goal):
        return self._dist[start][goal]

    def path(self, start, goal):
        pass


H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

wf = WarshallFloyd(C)

ans = 0
for row in A:
    for cell in row:
        if cell == -1:
            continue
        ans += wf.distance(cell, 1)
print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, q;
  cin >> n >> q;
  vi v(n, 0);
  string s;
  cin >> s;
  rep(i, 1, n) {
    if (s[i - 1] == 'A' && s[i] == 'C')
      v[i] = v[i - 1] + 1;
    else
      v[i] = v[i - 1];
  }
  rep(i, 0, q) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    cout << v[r] - v[l] << endl;
  }
}


Measured memory_bytes: 1488
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 
    string s;
    cin>>s;
    for(char a='a';a<='z';a++){
        if(s.find(a)==string::npos){
            cout<<a<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;




}


Measured memory_bytes: 512
X = int(input())

# 素数と個数を求める
def factorize(n):
    res = list()
    i = 2
    while i*i <= n:
        if n%i == 0:
            c = 0
            while n%i == 0:
                n /= i
                c += 1
            res.append([i,c])
        i += 1
    return res

# for a in range(200+1):
for a in range(-200,200+1):
    a5 = a**5
    b5 = a5 - X
    sign = 1
    if b5 < 0:
        b5 = -b5
        sign = -1

    pc = factorize(b5)

    b = 1
    if b5 == 0: b = 0
    for p,c in pc:
        if c == 5:
            b *= p
        else:
            break

    if b**5 == b5:
        print(a, sign*b)
        break


Measured memory_bytes: 9284
N = int(input())
C ,S, F = ([],[],[])
for i in range(N-1):
    a, aa, aaa = (int(i) for i in input().split())
    C.append(a)
    S.append(aa)
    F.append(aaa)

def move_time(i, t):
    ride = 0
    if t > S[i]:
        if t % F[i] == 0:
            ride = t
        else:
            ride = (t//F[i] + 1) * F[i]
    else:
        ride = S[i]

    return ride + C[i]

for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        t = move_time(j, t)
    print(t)

print(0)

Measured memory_bytes: 3188
///int ->(-2147483648<->2147483647)
///unsigned int(0<->4294967295)
///long long int (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
///unsigned long long int (0 to 18,446,744,073,709,551,615)
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define OPEN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","r",stdin)
#define INF 1000000000
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define pdd pair<double,double>
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vd vector<double>
#define sci(value) scanf("%d%*c",&value)
#define scl(value) scanf("%lld%*c",&value)
#define pi  (2*acos(0))
#define pb push_back
#define valid(value123,value234,limitrow,limitcol) value123>=0&&value123<limitrow&&value234>=0&&value234<limitcol
//int fx[]= {0,0,1,-1,-1,1,-1,1};//kings move
//int fy[]= {1,-1,0,0,-1,1,1,-1};//kings move
//int fx[]={-2,-2,-1,-1, 1,1, 2,2};  // Knights Move
//int fy[]={-1, 1,-2, 2,-2,2,-1,1}; // Knights Move
//ll powFunction(ll a,ll b){if(b==0)return 1;ll re=powFunction(a,b/2);re=(re*re);if(b&1)re=(re*a);return re;}
///ll digitSum(ll a){ll ans=0;while(a){ans+=(a%10);a/=10;}return ans;}

#define MX 100005
#define mod 1000000007
int arr[MX],dp[MX];
int main()
{
    int n;
    sci(n);
    for(int i=0;i<n;i++)
    {
        sci(arr[i]);
    }
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));

    }
    printf("%d\n",dp[n-1]);
}




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

int main() {
    int input;
    cin >> input;
    int tmp = input, sum = 0;
    while(tmp > 0){
        sum += tmp % 10;
        tmp /= 10;
    }
    if (input % sum == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3616
function main(input) {
    const args = input.split(/\s/);
    const N = parseInt(args[0], 10),
          A = parseInt(args[1], 10),
          B = parseInt(args[2], 10);

    const nums = [];
    for (var i = 1; i <= N; i++) {
        var n = i.toString().split('').reduce((p, c) => p + parseInt(c), 0);
        if (n >= A && n <= B) nums.push(i);
    }

    // const nums = Array.from(new Array(N), (v, i) => ++i).filter((i) => {
    //     var n = i.toString().split('').reduce((p, c) => p + parseInt(c), 0);
    //     return (n >= A && n <= B);
    // });
    
    console.log(nums.reduce((p, c) => p + c, 0));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 23688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    // スイッチの数がたかだかN<=10なので、1<<Nまでループして
    // それぞれのスイッチの状態を復元し、電球がつくかどうかを判定する

    int n, m; cin >> n >> m;
    vector<vector<int>> a(m);
    rep(i, m) {
        int k; cin >> k;
        rep(j, k) {int x; cin >> x; a[i].push_back(--x);}
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];

    int ans = 0;
    rep(bit, 1<<n) {
        vector<bool> s(n, false);
        rep(i, n) {
            if (bit & (1<<i)) s[i]=true;
        }
        bool ok = true;
        rep(i, m) {
            auto vec = a[i];
            int cnt = 0;
            for (const auto v: vec) if (s[v]) cnt++;
            if ((cnt%2) != p[i]) ok = false;
        }
        if (ok) ans++;
    }

    cout << ans << endl;
}

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

int main() {
  string S, original;
  original = "CODEFESTIVAL2016";
  cin >> S;
  int count=0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != original.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
N = int(input())
S = []
P = []
for i in range(N):
    tmp_S, tmp_P = input().split()
    S.append(tmp_S)
    P.append(int(tmp_P)*(-1))

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

ZIP = zip(S, P, index)

ZIP = sorted(ZIP)

S, P, index = zip(*ZIP)

for i in range(N):
    print(index[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

long long inv(int n) {
    return modpow(n, mod-2);
}

int main() {
    int n; cin >> n;
    long long all = modpow(3, n);
    long long sub = 0;
    long long comb = 1;
    long long pow2 = 1;
    for (int i = 0; i < n/2; i++) {
        sub = (sub + (comb * pow2 % mod)) % mod;
        comb = comb * (n-i) % mod * inv(i+1) % mod;
        pow2 = pow2 * 2 % mod;
        //cout << comb << " " << sub << endl;
    }
    cout << (all + mod - sub * 2 % mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b; a=4;b=7;
  int x; cin>>x;
  
  for(int i=0;i<=25;i++)
  {
    for(int j=0;j<=14;j++)
    {
      int total =i*a+j*b;
      if(total==x){cout <<"Yes" <<endl;
                   //cout <<"aが" <<i <<"bが" <<j <<endl;
                  return 0;
                  }
    }
  
  }
  
  cout <<"No" <<endl;
  
}


Measured memory_bytes: 256
N = int(input())
A = list(int(i) for i in input().split())
A.insert(0, 0)
A.append(0)

Sum = 0
Ans = 0

for i in range(len(A) - 1):
    Sum += abs(A[i+1] - A[i])

for i in range(N):
    Ans = Sum
    Ans = Ans - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) + abs(A[i+2] - A[i])
    print("%d" % (Ans))

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

int main(int argc, const char * argv[]) {
    
    int x;
    int i =1;
    while (true) {
        cin >> x;
        if(x == 0){
            break;
        }
        
        cout << "Case " << i << ": " << x << endl;
        i++;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    cout << n * (n+1) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k;
    ll yoko;
    ll hoge;
    ll ans = 0;
    cin >> n >> k;
    bool all[n];
    for(int i = 0; i < n ; i++){
        all[i] = false;
    }
    for(int i = 0; i < k; i++){
        cin >> yoko;
        for(int j = 0; j < yoko; j++){
            cin >> hoge;
            all[hoge-1] = true;
        }
    }

    for(int i = 0; i < n ; i++){
        if(!all[i]){
            ans += 1;
        }

    }
    cout << ans << endl;

    
    
}

Measured memory_bytes: 3636
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	l := make([]int, n)
	r := make([]int, n)
	for i := 0; i < n; i++ {
		l[i] = nextInt()
		r[i] = nextInt()
	}
	res := 0
	for i := 0; i < n; i++ {
		res += r[i] - l[i] + 1
	}
	fmt.Println(res)
}

// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(next())
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define io ios_base::sync_with_stdio(false); cin.tie(0);

#define fs first
#define sc second
#define pb push_back

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef long double ld;

const ll LINF = 1e18;
const int INF = 1e9;
const ld EPS = 1e-9;
const int MOD = 1e9+7;

/// Scanf para ler char array separado por espacos -> scanf(" %[^\n]", texto);
 
////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5+5;

int n;

int main(){
	
	scanf("%d", &n);
	vector<int> dp(3);
	for(int i = 0; i < n; i++){
		vector<int> c(3);
		vector<int> aux(3);
		for(int j = 0; j < 3; j++){
			scanf("%d", &c[j]);
		}
		/// 'Tabela' 3x3 para ver a melhor combinacao das
		///  escolhas ja feitas e a que posso fazer:

		///      | aux[0] | aux[1] | aux[2] |
		/// dp[0]|    x   |    o   |    o   |
		/// dp[1]|    o   |    x   |    o   |
		/// dp[2]|    o   |    o   |    x   |

		/// Os 'x's representam onde eu nao posso escolher
		/// para nao epetir dias
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){ 
				if(i != j) aux[j] = max(aux[j], dp[i] + c[j]);
			}
		}
		dp = aux;
	}
	printf("%d\n", max(dp[0], max(dp[1], dp[2])));
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a = in.nextLong();
		long b = in.nextLong();
		long ans = (long)((long)a * (long)b) / (long)gcd(Math.max(a, b), Math.min(a, b));
		System.out.println(ans);
	}
	public static long gcd(long a, long b) {
		if(a % b == 0) return b;
		else return gcd(b, a % b);
	}
}

Measured memory_bytes: 21844
#include<iostream>

int main()
{
    int a, b;

    std::cin>>a>>b;

    if(a>b){
        std::cout<<"a > b"<<std::endl;
    }else if(a<b){
        std::cout<<"a < b"<<std::endl;
    }else if(a==b){
        std::cout<<"a == b"<<std::endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)2e6 + 123;

int n, k;
set <int> s;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif	
	Fast_Read_Out();
	Random();
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> k, s.insert(k);
	if(sz(s) == n) cout << "YES";
	else cout << "NO";   
}                                

Measured memory_bytes: 9600
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        if a[i] + a[i+1] >= b[i]:
            ans += b[i]
            a[i+1] -= b[i] - a[i]
        else:
            ans += a[i] + a[i+1]
            a[i+1] = 0

print(ans)


Measured memory_bytes: 19116
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#define El Patron
using namespace std;
using boost::irange;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    int X;
    cin >> X;
    vector<deque<int>> A(X + 1, deque<int>());
    for (int i: irange(1, X + 1)) {
        for (int j: irange(0, X - 1)) {
            int valUE;
            cin >> valUE;
            A[i].push_back(valUE);
        }
    }

    vector<int> DAY(X + 1, 1);
    int empty_queues = 0;
    while (empty_queues < X) {
        bool matched = false;
        for (int i: irange(1, X + 1)) {
            int comp = A[i].front();
            if (A[comp].front() == i) {
                matched = true;
                A[i].pop_front();
                A[comp].pop_front();
                int date = max(DAY[i], DAY[comp]) + 1;
                DAY[i] = date;
                DAY[comp] = date;
                if (A[i].empty()) {
                    empty_queues++;
                }
                if (A[comp].empty()) {
                    empty_queues++;
                }
            }
        }
        if (!matched) {
            cout << -1 << endl;
            exit(0);
        }
    }
    int RES = 0;
    for (int i: irange(1, X + 1)) {
        RES = max(RES, DAY[i]);
    }
    cout << RES - 1 << "\n";
}

Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

string s;
string da;
bool checkA(long long  i){
    if(s[i]=='A'){
        return true;
    }
    else{
        return false;
    }
}

bool checkBC(long long i){
    if(s[i]=='B'&&s[i+1]=='C'){
        return true;
    }
    else{
        return false;
    }
}

long long  que(int i){
int le=da.size();
int a=0;
long long ret=0;
for(int t=0;t<le;t++){
    if(da[t]=='A'){
    a++;
    }
    else{
    ret+=a;
    }
}

return ret;
}

int main(){
cin>>s;
long long ans=0;
long long len=s.size();

for(long long i=0;i<len;i++){
if(checkA(i)){
da.push_back('A');
}
else if(checkBC(i)){
da.push_back('D');
i++;
}
else if(da.size()>0){
    ans+=que(0);
    da.clear();
}

}
if(da.size()>0){
    ans+=que(0);
    da.clear();
}

cout<<ans<<endl;
/*
len=da.size();
int d[len+1];
int a[len+1];
d[0]=a[0]=0;
for(int i=0;i<len;i++){
    if(da[i]=='A'){
        a[i+1]=a[i]+1;
        d[i+1]=d[i];
    }
    else{
        d[i+1]=d[i]+1;
        a[i+1]=a[i];
    }
}

for(int i=0;i<=len;i++){
long long total;
total=d
}
*/
 return 0;
}
/*
ABCABC

3

C

0

ABCACCBABCBCAABCB

6
*/

Measured memory_bytes: 776