akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll tenbai[100];
int ketawa(ll m){
	int ans=0;
	while(m){
		ans+=m%10;
		m/=10;
	}
	return ans;
}
int keta(ll m){
	rep(i,19){
		if(m<tenbai[i]) return i;
	}
	return 19;
}
int main(){
	tenbai[0]=1;
	rep(i,18){
		tenbai[i+1]=tenbai[i]*10;
	}
	ll K;
	scan(K);
	ll count=0;
	vll sunuke;
	ll kouho=1e+15-1;
	double sunukemin=(double)kouho/ketawa(kouho);
	sunuke.push_back(kouho);
	while(kouho){
		if(kouho>=100) kouho-=tenbai[keta(kouho)-3];
		else if(kouho>=10) kouho-=tenbai[keta(kouho)-2];
		else kouho--;
		double snu=(double)kouho/ketawa(kouho);
		if(snu-eps<=sunukemin){
			sunuke.push_back(kouho);
			sunukemin=snu;
			//printf("%15lld \tsnuke\n",kouho);
		}
		else{
			//printf("%15lld \n",kouho);
		}
	}
	sort(sunuke.begin(),sunuke.end());
	rep(i,K){
		prin(sunuke[i]);
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct stack{
  int car_number;
  struct stack *down;
};

struct stack *push(int,struct stack *);
struct stack *pop(struct stack *);

int main(void){
  struct stack bottom = {0,NULL};
  struct stack *top = &bottom;
  int car_number;

  while(scanf("%d",&car_number) != EOF){
    if(car_number == 0){
      top = pop(top);
    }else{
      top = push(car_number,top);
    }
  }

  return 0;
}

struct stack *push(int car_number, struct stack *top){
  struct stack *new;

  new = (struct stack *) malloc(sizeof(struct stack));

  new -> car_number = car_number;
  new -> down       = top;

  return new;
}

struct stack *pop(struct stack *top){
  struct stack *p;
  
  printf("%d\n",top->car_number);

  p = top -> down;

  free(top);

  return p;
}

Measured memory_bytes: 600
loop do
  n = gets.to_i
  break if n==0
  hash = Hash.new(0)
  max =0
  n.times do
    m,a,b = gets.split.map(&:to_i)
    hash[a] += m
    hash[b] += -m
    max = [max,b].max
  end
  flag = true
  sum=0
  hash.keys.sort.each do |t|
    sum+=hash[t]
    if sum>150
      flag = false
      break
    end
  end
  puts flag ? "OK" : "NG"
end

Measured memory_bytes: 2792
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    ll n,m;
    std::cin >> n>>m;
    std::vector<ll> w(n),v(n);
    rep(i,n)std::cin >> w[i]>>v[i];
    vvector(dp,ll,n+1,100001,INF64);
    dp[0][0]=0;
    rep(i,n){
        rep(j,100001){
            if(j-v[i]>=0)dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    ll ans=0;
    rep(i,100001){
        if(dp[n][i]<=m)ans=i;
    }
    //std::cout << dp[n][100000] << std::endl;
    std::cout << ans << std::endl;
}

Measured memory_bytes: 80256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> p(n);
	REP(i,n) cin>>p[i];
	vector<ll> dp(n+1,-1);
	REP(i,n) {
		if(dp[p[i]-1]==-1) dp[p[i]]=1;
		else dp[p[i]]=dp[p[i]-1]+1;
	}
	ll ans=0;
	REP(i,n+1) ans=max(ans,dp[i]);
	cout<<n-ans<<endl;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    int ans = 0;
    rep(i, n) {
        if (i % 2 == 0) {
            ans += a.at(i);
        }
        else {
            ans -= a.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = "; cout << (x) << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

#define sqr(x) ((x) * (x))

#define ll long long int
#define MOD 1000000007
#define MN 200005
#define foru(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)


using namespace std;
void checkDefine();

ll n;

struct m {
    ll a, b;
};
bool comp(m a, m b) {
    return a.a + a.b > b.a + b.b;
}

vector<m> a;

int main() {
    cin >> n;
    ll s1 = 0, s2 = 0;
    FOR(i, 0, n-1) {
        m t;
        cin >> t.a >> t.b;
        a.push_back(t);
    }

    sort(a.begin(), a.end(), comp);
    bool b = true;
    FOR(i, 0, n-1) {
        if(b) {
            s1 += a[i].a;
        } else {
            s2 += a[i].b;
        }
        b = !b;
    }
    cout << s1 - s2 << endl;
    return 0;
}

void checkDefine(){
	ll n, a[MN];
	map<ll, ll> m;
	cin >> n;
	FOR(i, 0, n - 1) {
		cin >> a[i];
		m[a[i]]++;
	}

	string s; cin >> s;
	DEBUG(s);
	PR0(a, n);
	DEBUG("------------");
	EACH(it, m){
		cout << it->first << " " << it->second << endl;
	}
	//if(s.find("abc") != npos) // found
}
	




Measured memory_bytes: 2420
import java.io.PrintWriter;
import java.util.Map;
import java.util.TreeMap;
import java.util.Scanner;
import static java.lang.Math.*;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
		int max = 0;
		while(scan.hasNext()){
			int a = si();
			if(!map.containsKey(a)){
				map.put(a, 1);
				max = max(max,1);
			}
			else{
				int tmp = map.get(a)+1;
				map.put(a, tmp);
				max = max(max,tmp);
			}
		}
		for (Map.Entry<Integer, Integer> e : map.entrySet())
			if(e.getValue()==max) out.println(e.getKey());
		out.flush();
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int MAXN=200000;
vector<int> bucket(MAXN);

int main() {
  int N, K; cin >> N >> K;
  set<int> st;
  for(int i = 0; i < N; ++i) {
    int A; cin >> A;
    bucket[A]++;
    st.insert(A);
  }
  sort(bucket.begin(), bucket.end());
  int ans = 0, cnt=0;
  if(st.size() <= K) {
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < MAXN; ++i) {
    if(bucket[i] > 0 && K < st.size() - cnt) {
      ans += bucket[i];
      cnt++;
    } else if(st.size() - cnt == K) {
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 10368
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main(){
  sc.Scan()
  temp := sc.Text()
  var a, b int
  fmt.Sscan(temp, &a, &b)
  if (a*b)%2 == 0 {
    fmt.Print("Even")
  }else {
    fmt.Print("Odd")
  }
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
'''
所要時間は、分位であった。
'''


# ライブラリのインポート
#import re #正規表現
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#import collections
#import math
#from pprint import pprint

def main():
    while 1:
        w, h = map(int, input().split())
        if w == 0 and h == 0: break
        mp = []
        for i in range(h):
            mp.append(list(input().strip()))
            if "@" in mp[-1]:
                stj = mp[-1].index("@")
                sti = i
        flag = [[0]*w for i in range(h)]
        #pprint(flag)
        flag = dfs(sti, stj, flag, mp)
        ans = sum([flag[i].count(1) for i in range(h)])
        print(ans)
        #pprint(flag)
def dfs(rw, cm, flag, mp):
    flag[rw][cm] = 1
    #print(rw,cm)
    #pprint(flag)
    try:
        c = mp[rw][cm-1]
        b = flag[rw][cm-1]
    except: c = "#"
    if c == "." and b == 0 and rw>=0 and cm>0: dfs(rw, cm-1, flag, mp)
    try:
        c = mp[rw-1][cm]
        b = flag[rw-1][cm]
    except: c = "#"
    if c == "." and b == 0 and rw>0 and cm>=0: dfs(rw-1, cm, flag, mp)
    try: 
        c = mp[rw][cm+1]
        b = flag[rw][cm+1]
    except: c = "#"
    if c == "." and b == 0: dfs(rw, cm+1, flag, mp)
    try: 
        c = mp[rw+1][cm]
        b = flag[rw+1][cm]
    except: c = "#"
    if c == "." and b == 0: dfs(rw+1, cm, flag, mp)
    return flag


    


    
if __name__ == '__main__':
    main()



Measured memory_bytes: 6040
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[][] m = new int[H][W];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        m[i][j] = sc.nextInt();
      }
    }

    List<String> list = new ArrayList<>();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (m[i][j]%2 == 1) {
          m[i][j]--;
          if (j < W-1) {
            m[i][j]--;
            m[i][j+1]++;
            list.add((i+1)+" "+(j+1)+" "+(i+1)+" "+(j+2));
          } else if (i < H-1) {
            m[i][j]--;
            m[i+1][j]++;
            list.add((i+1)+" "+(j+1)+" "+(i+2)+" "+(j+1));
          }
        }
      }
    }
    
    System.out.println(list.size());
    StringBuilder ans = new StringBuilder();
    for (String s : list) {
      ans.append(s).append('\n');
    }
    System.out.print(ans);
  }
}

Measured memory_bytes: 99512
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,m,g=0;
   int t[1000],re[1000],p,x;
   cin >> n ;
   for(int i=0;i<n;i++){
       cin >> t[i] ;
       re[i]=t[i];
   }
   cin >> m;
   for(int i=0;i<m;i++){
       cin >> p >> x;
       t[p-1]=x;
       for(int j=0;j<n;j++){
           g+=t[j];
           if(j==n-1){
           cout << g << endl;
           t[p-1]=re[p-1];
           g=0;
           }
       }
   }
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 1e9+7;

signed main(){
    int n;
    cin >>n;
    int ans = 0;
    FOR(i,1,n) {
        ans+=(n-1)/i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#pragma region header
#include <bits/stdc++.h>
#define int long long
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++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    vi a(n);
    int Min=inf,Max=-inf;
    rep(i, n) {
        cin >> a[i];
        chmin(Min,a[i]);chmax(Max,a[i]);
    }
    int cost = 0;
    int mi = inf;
    for(int i = Min;i<=Max;i++) {
        cost=0;
        rep(j, n) {
            cost+=(a[j]-i)*(a[j]-i);
        }
        chmin(mi,cost);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  deque<int> q;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    if(n % 2 == i % 2)q.push_back(a);
    else q.push_front(a);
  }
  for(int i = 0; i < q.size(); i++){
    cout << q[i];
    if(i == q.size() - 1)cout << endl;
    else cout << " ";
  }
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int p[105];
int N;

ll num(int n){
    ll res = 0;
    for(int i=2; i<=N; i++) if(p[i] >= n) res++;
    return res;
}

int main(){
    cin >> N;

    for(int i=2; i<=N; i++){
        int cur = i;
        for(int j=2; j*j<=cur; j++){
            while(cur%j == 0){
                p[j]++;
                cur /= j;
            }
        }
        if(cur != 1) p[cur]++;
    }

    cout << num(74) + num(24)*(num(2)-1) + num(14)*(num(4)-1) + num(4)*(num(4)-1)/2*(num(2)-2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	vector<int> dis(5);
	for (int i = 0; i < 5; i++)
		cin >> dis[i];
	int k;
	cin >> k;
	for (int j = 0; j < 5; j++)
	{
		for (int i = 0; i < 5; i++)
		{
			if (j != i)
			{
				if (abs(dis[i] - dis[j]) > k)
				{
					cout << ":(" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc1 := bufio.NewScanner(os.Stdin)
	sc1.Split(bufio.ScanLines)
	sc1.Scan()
	sc1.Text()
	sc1.Scan()
	in := strings.Split(sc1.Text(), " ")
	heap := make([]int, len(in)+1)

	for i, v := range in {
		val, _ := strconv.Atoi(v)
		heap[i+1] = val
	}

	for i := range heap {
		if i == len(heap)-1 {
			break
		}
		idx := i + 1
		fmt.Printf("node %d: key = %d, ", idx, heap[idx])
		if idx/2 >= 1 {
			fmt.Printf("parent key = %d, ", heap[idx/2])
		}

		if idx*2 < len(heap) {
			fmt.Printf("left key = %d, ", heap[idx*2])
		}

		if idx*2+1 < len(heap) {
			fmt.Printf("right key = %d, ", heap[idx*2+1])
		}

		fmt.Println()
	}

}

func print(heap []*int) {
	for i, v := range heap {
		p := getParent(heap, i)
		l := getLeft(heap, i)
		r := getRight(heap, i)
		fmt.Printf("node %d: key = %d, ", i+1, *v)
		if p != nil {
			fmt.Printf("parent key = %d, ", *p)
		}
		if l != nil {
			fmt.Printf("left key = %d, ", *l)
		}
		if r != nil {
			fmt.Printf("right key = %d, ", *r)
		}
		// node 2: key = 8, parent key = 10, left key = 1, right key = 2,

		fmt.Println()
	}
}

func getParent(heap []*int, index int) *int {
	pi := (index + 1) / 2
	if pi <= 0 {
		return nil
	}

	return heap[pi-1]
}

func getLeft(heap []*int, index int) *int {
	li := index*2 + 1
	if len(heap) <= li {
		return nil
	}

	return heap[li]
}

func getRight(heap []*int, index int) *int {
	ri := index*2 + 2
	if len(heap) <= ri {
		return nil
	}

	return heap[ri]
}



Measured memory_bytes: 1108
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define RevRange(container) container.rbegin(), container.rend()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(){
    Cins(int, 3, a);
    sort(RevRange(a));
    Cout(a[0]*10 + a[1] + a[2]);
}



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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<ll> A;

vector<ll> dp1;
vector<ll> dp2;
int bit_len;

vector<int> convert_binary(ll k) {
    vector<int> ans;
    while (k > 0) {
        ans.push_back(k & 0x1);
        k >>= 1;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

int op(const int bit, const int idx) {
    int ans = 0;
    for (int i = 1; i < (int) A.size(); i++) {
        ll x = A[i];
        ans += bit ^ ((x >> (bit_len - idx)) & 0x1);
    }
#ifdef DEBUG
    printf("bit: %d, idx: %d, ans: %d\n", bit, idx, ans);
#endif
    return ans;
}

int main(void) {
    int N;
    ll K;
    cin >> N >> K;

    A.resize(N + 1);
    for (int i = 1; i <= N; i++) {
        ll x;
        cin >> x;
        A[i] = x;
    }

    vector<int> binary_k = convert_binary(K);
    bit_len = (int) binary_k.size();
#ifdef DEBUG
    printf("bit_len: %d\n", bit_len);
#endif

    dp1.resize(bit_len + 1, -1);
    dp2.resize(bit_len + 1, -1);
    dp1[0] = 0;

    for (int i = 0; i < bit_len; i++) {
        int d = binary_k[i];

        // dp1
        if (dp1[i] != -1) {
            chmax(dp1[i + 1], op(d, i + 1) + (dp1[i] << 1));
            if (d == 1) chmax(dp2[i + 1], op(0, i + 1) + (dp1[i] << 1));
        }

        // dp2
        if (dp2[i] != -1) {
            chmax(dp2[i + 1], op(0, i + 1) + (dp2[i] << 1));
            chmax(dp2[i + 1], op(1, i + 1) + (dp2[i] << 1));
        }
    }

#ifdef DEBUG
    printf("dp1: \n");
    for (int i = 0; i <= bit_len; i++) {
        cout << dp1[i] << " ";
    }
    cout << endl;

    printf("dp2: \n");
    for (int i = 0; i <= bit_len; i++) {
        cout << dp2[i] << " ";
    }
    cout << endl;
#endif

    ll ans = max(dp1[bit_len], dp2[bit_len]);
    for (int i = 1; i <= N; i++) {
        ans += A[i] & ~(((1LL << bit_len) - 1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
 
int main()
{
  int n, a, i, j, x;
  int y[8] = {0,0,0,0,0,0,0,0};
  int z = 0;
  int min = 0;
  int max = 0;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++)
  {
    scanf("%d", &a);
    x = a / 400;
    if(x < 8)
    {
      y[x] += 1;
    }
    else if(x >= 8)
    {
      z += 1;
    }
  }
  for(j = 0; j < 8; j++)
  {
    if(y[j] > 0)
    {
      min += 1;
    }
  }
  max = min + z;
  if(min == 0)
  {
    min = 1;
  }
  printf("%d %d", min, max);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
typedef pair<int,int> Pi;
#define F first
#define S second

int main()
{
  int N;
  Pi point[105];
  int out[105];
  cin >> N;

  Rep(i,N)point[i].S = i;
  
  int A, B, C, D;
  Rep(i,N * (N - 1) / 2) {
    cin >> A >> B >> C >> D;
    --A,--B;
    if(C < D) {
      point[B].F += 3;
    } else if(C == D) {
      point[A].F++,point[B].F++;
    } else {
      point[A].F += 3;
    }
  }
  
  sort(point, point + N,greater<Pi>());

  int cnt = 1;
  int p = INT_MAX;
  Rep(i,N) {
    if(p != point[i].F) {
      cnt = i + 1;
      p = point[i].F;
    }
    out[point[i].S] = cnt;
  }
  Rep(i,N)cout << out[i] << endl;
  return 0;
}
    

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

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

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

ll mod = 1000000007;

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

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

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

  int n;
  cin >> n;
  if(n < 2) cout << 0 << endl;
  else {
    ll eight = 1,nine = 1,ten = 1;
    rep(i,n) {
      eight = eight * 8 % mod;
      nine = nine * 9 % mod;
      ten = ten * 10 % mod;
    }
    ll ret = ten;
    ret -= (nine * 2) % mod;
    if(ret < 0)ret += mod;
    ret = (ret + eight) % mod;
    cout << ret << endl;
  }
}

Measured memory_bytes: 3644
# AGC033C

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n = int(input())
ns = defaultdict(set)
for _ in range(n-1):
    u,v = map(int, input().split())
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)

def bfs(start):
    from queue import deque
    q = deque([start])
    seen = [None] * n
    seen[start] = 0
    dd = 0
    target = start
    while q:
        u = q.pop()
        d = seen[u]
        if d>dd:
            dd = d
            target = u
        for v in ns[u]:
            if seen[v] is None:
                seen[v] = d + 1
                q.appendleft(v)
    return target, dd
target, tmp = bfs(0)
_, d = bfs(target)
if (d-1)%3!=0:
    print("First")
else:
    print("Second")

Measured memory_bytes: 127448
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn main() {
    let mut s = Vec::new();
    let mut t = Vec::new();

    s.push(0);
    t.push(0);

    get_line().chars().fold(0, |acc, x| {
        let next =
            if x == 'A' {
            acc + 1
        }
        else {
            acc + 2
        };
        s.push(next);
        next
    });

    get_line().chars().fold(0, |acc, x| {
        let next =
        if x == 'A' {
            acc + 1
        }
        else {
            acc + 2
        };

        t.push(next);
        next
    });

    let q = get_line().parse().unwrap();

    for _ in 0..q {
        let abcd: Vec<usize> = get_line().split(' ').map(|x| x.parse().unwrap()).collect();

        println!("{}",
            if (s[abcd[1]] - s[abcd[0] - 1]) % 3 == (t[abcd[3]] - t[abcd[2] - 1]) % 3 {
                "YES"
            }
            else {
                "NO"
            }
        );
    }
}


Measured memory_bytes: 4604
#include<iostream>
using namespace std;
int main() {
	int n,x,o,k=0;
	for(;;){
		cin>>n>>x;
		k=0;
		if(n==0&&x==0){
			break;
		}
		for(int y = 1 ; y <= n  ; y++){
			for(int v = y + 1 ; v <= n  ;v++){
				for(int s = v + 1 ; s <= n  ;s++){
					o=y+v+s;
					if(o==x){
						k++;
					}
				}
			}
		}cout<<k<<endl;
	}
return 0;
}


Measured memory_bytes: 3084
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]

    score = 0
    last_day = [-1] * 26
    ans = [1] * D
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9392
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    int sum=0;
    for (int i=0;i<n;i++) {
        int l,r;
        cin>>l>>r;

        sum+=r-l+1;
    }

    cout<<sum<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int read() {
    int x; scanf("%lld", &x); return x;
}
#define xx first
#define yy second
#define pb push_back
typedef pair<int, int> pir;
const int mod = 1000000007;

vector<pir> f, s[100];
int fib[100];
int find(int a, int b) {
	int ka = upper_bound(fib + 1, fib + 91, a) - fib;
	int kb = upper_bound(fib + 1, fib + 91, b) - fib;
	if (ka > kb + 1) ka = kb + 1;
	if (ka == kb) kb--;
	return kb - 1;
}

signed main() {
    f.pb(pir(1, 1));
    f.pb(pir(3, 2));
    f.pb(pir(4, 3));
    s[2].pb(pir(3, 2));
    for (int i = 3; i <= 90; i++) {
        f.pb(pir(f[i - 1].xx + f[i - 2].xx, f[i - 1].yy + f[i - 2].yy));
        for (int j = 0; j < i - 2; j++) {
            s[i].push_back(pir(s[i - 1][j].xx + s[i - 1][j].yy, s[i - 1][j].xx));
        }
        s[i].pb(pir(f[i - 1].xx + f[i - 1].yy, f[i - 1].xx));
    }
    fib[0] = fib[1] = 1;
    for (int i = 2; i <= 90; i++)
    	fib[i] = fib[i - 1] + fib[i - 2];
    	
    int Q = read();
    while (Q--) {
    	int A = read(), B = read(), ans = 0;
		if (A < B) swap(A, B);
		if (B == 1) { printf("1 %lld\n", A % mod); continue; }
		if (A == 2 && B == 2) { puts("1 4"); continue; }
    	int k = find(A, B);
    	printf("%lld ", k);
    	for (int i = 0, _ = s[k].size(); i < _; i++) {
    		int x = s[k][i].xx, y = s[k][i].yy;
    		if (y <= B && x <= A) {
    			ans = (ans + (A - x) / y + 1) % mod;
    		}
    		if (y <= A && x <= B) {
    			ans = (ans + (B - x) / y + 1) % mod;
    		}
    	}
    	if (f[k].xx <= A && f[k].yy <= B)
    		ans = (ans + 1) % mod;
    	if (f[k].xx <= B && f[k].yy <= A)
    		ans = (ans + 1) % mod;
    	printf("%lld\n", ans);
    }
}

Measured memory_bytes: 4096
import java.util.*;
import java.util.regex.*;

class Main{
	private final static Pattern addsubmuldiv = Pattern.compile("^(.*?)(-?\\d+)([+Z*/])(-?\\d+)(.*)$");
	private final static Pattern addsub = Pattern.compile("^(.*?)(-?\\d+)([+Z])(-?\\d+)(.*)$");
	private final static Pattern muldiv = Pattern.compile("^(.*?)(-?\\d+)([*/])(-?\\d+)(.*)$");

	private static String process(String s){
		Matcher m=muldiv.matcher(s);
		while(m.find()){
			if(m.group(3).equals("*"))
				s=m.group(1)+(Integer.parseInt(m.group(2))*Integer.parseInt(m.group(4)))+m.group(5);
			else
				s=m.group(1)+(Integer.parseInt(m.group(2))/Integer.parseInt(m.group(4)))+m.group(5);
			m=muldiv.matcher(s);
		}

		m=addsub.matcher(s);
		while(m.find()){
			if(m.group(3).equals("+"))
				s=m.group(1)+(Integer.parseInt(m.group(2))+Integer.parseInt(m.group(4)))+m.group(5);
			else
				s=m.group(1)+(Integer.parseInt(m.group(2))-Integer.parseInt(m.group(4)))+m.group(5);
			m=addsub.matcher(s);
		}
		return s;
	}

	private static String process2(String s){
		Matcher m=addsubmuldiv.matcher(s);
		while(m.find()){
			if(m.group(3).equals("*"))
				s=m.group(1)+(Integer.parseInt(m.group(2))*Integer.parseInt(m.group(4)))+m.group(5);
			else if(m.group(3).equals("/"))
				s=m.group(1)+(Integer.parseInt(m.group(2))/Integer.parseInt(m.group(4)))+m.group(5);
			else if(m.group(3).equals("+"))
				s=m.group(1)+(Integer.parseInt(m.group(2))+Integer.parseInt(m.group(4)))+m.group(5);
			else
				s=m.group(1)+(Integer.parseInt(m.group(2))-Integer.parseInt(m.group(4)))+m.group(5);
			m=addsubmuldiv.matcher(s);
		}
		return s;
	}

	public static void main(String[]z){
		Scanner x=new Scanner(System.in);
		String s=x.next().replaceAll("-","Z");
		String ans=x.next();
		boolean a=process(s).equals(ans);
		boolean b=process2(s).equals(ans);
		if(a&&b)System.out.println("U");
		if(a&&!b)System.out.println("M");
		if(!a&&b)System.out.println("L");
		if(!a&&!b)System.out.println("I");
	}
}

Measured memory_bytes: 17328
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> a(n);
  map<long long int,long long int> left;
  map<long long int,long long int> right;
  set<long long int> all;
  for(long long int i=0; i<n; i++){
    cin>>a.at(i);
    left[i+1+a.at(i)]++;
    right[i+1-a.at(i)]++;
    all.insert(i+1+a.at(i));
    all.insert(i+1-a.at(i));
  }

  long long int ans=0;
  for(long long int i:all){
    ans+=left[i]*right[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 67404
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define Cr7 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define N   111
ll n,k,d,x,b[N],Res;
int main()
{
    Cr7
    cin>>n>>k;
    while(k--)
    {
        cin>>d;
        while(d--)  cin>>x  ,   b[x]=1;
    }
    for(ll i=1 ; i<=n ; i++)    Res+=(!b[i]);
    cout<<Res<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define fi first
#define pb push_back
#define si second
#define int long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  mod 1e18
#define double long double
#define all(o) o.begin(),o.end()
using namespace std;

int32_t main()
{
	fast
	string s,t;
	cin>>s>>t;
	int i;
	int ans=0;
	for(i=0;i<s.length();i++)
		if(s[i]!=t[i])ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 3792
#include <stdio.h>
#include <stdlib.h>

int calc_tax(int p, int t){
	return (int)(p*(100+t)/100);
}

int main(){
	int x, y, sum;
	int a, b;
	int max = 0, s;
	while(1){
		scanf("%d %d %d", &x, &y, &sum);
		if(x == 0) break;
		for(a = 1; a <= sum/2; a++){
			for(b = a; a+b <= sum; b++){
				if(calc_tax(a, x) + calc_tax(b, x) == sum){
					s = calc_tax(a, y) + calc_tax(b, y);
					if(max < s) max = s;
				}
			}
		}
		printf("%d\n", max);
		max = 0;
	}
	return 0;
}

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

bool check=false;
string s;
/*
void dfs(string t){
  if(s == t){
    check = true;
  }
  if(s.size() < t.size()){
    return;
  }
  
  int n=t.size();
  int m=s.size();
  if(m >= n + 7 && s.substr(t.size(),7) == "dreamer"){
    dfs(t+"dreamer");
  }
  if(m >= n + 6 && s.substr(t.size(),6) == "eraser"){
    dfs(t+"eraser");
  }
  if(m >= n + 5 && s.substr(t.size(),5) == "erase"){
    dfs(t+"erase");
  }
  if(m >= n + 5 && s.substr(t.size(),5) == "dream"){
    dfs(t+"dream");
  }
}
*/
int main() {
  cin >> s;
  string t="";
  
  reverse(s.begin(),s.end());
  int m,n;
  while(s != t){
    n = t.size();
    m = s.size();
    if(m >= n + 7 && s.substr(t.size(),7) == "remaerd"){
      t += "remaerd";
    }
    else if(m >= n + 6 && s.substr(t.size(),6) == "resare"){
      t += "resare";
    }
    else if(m >= n + 5 && s.substr(t.size(),5) == "esare"){
      t += "esare";
    }
    else if(m >= n + 5 && s.substr(t.size(),5) == "maerd"){
      t += "maerd";
    }else{
      break;
    }
  }
  
  if(s==t){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return(0);
}

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

int main(void)
{
        int x,y,z;
        char a[11],b[11],c[11];

        scanf("%s%s%s",a,b,c);
        x=strlen(a);
        y=strlen(b);

        if((a[x-1] == b[0])&&(b[y-1] == c[0]))
                printf("YES\n");
        else
                printf("NO\n");
        return 0;
}


Measured memory_bytes: 128
S=input().strip()
ws=['dream','dreamer','erase','eraser']
while True:
  change = False
  for w in ws:
    if len(w) <= len(S) and S[-len(w):] == w:
      S = S[:-len(w)]
      change = True
  if not change:
    break
print("YES" if len(S) == 0 else "NO")


Measured memory_bytes: 3188
#include<stdio.h>
typedef struct mathgrade{
							int m;
							int f;
							int r;
}math;
int main(void){
	math ms[1000];
	int i=0,j=0;

	while(1){
		scanf("%d %d %d",&ms[i].m,&ms[i].f,&ms[i].r);
		if(ms[i].m==-1 && ms[i].f==-1 && ms[i].r==-1){
			break;
		}
		i++;
	}

	while(i-j){
	if(ms[j].m==-1 || ms[j].f==-1) printf("F\n");
	else if(ms[j].m+ms[j].f>=80)   printf("A\n");
	else if(ms[j].m+ms[j].f>=65 && ms[j].m+ms[j].f<80) printf("B\n");
	else if(ms[j].m+ms[j].f>=50 && ms[j].m+ms[j].f<65) printf("C\n");
	else if(ms[j].m+ms[j].f>=30 && ms[j].m+ms[j].f<50 && ms[j].r>=50) printf("C\n");
	else if(ms[j].m+ms[j].f>=30 && ms[j].m+ms[j].f<50) printf("D\n");
	else if(ms[j].m+ms[j].f<30) printf("F\n");
	j++;
	}
return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
const int MOD=1000000007;
const int INF=LLONG_MAX/2;

signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	int bb = b / k;
	int aa = a / k;
	int cc = b % k;
	int dd = a % k;
	if (bb - aa > 0 || cc==0 || dd==0) {
		cout << "OK" << endl;
	}
	else
		cout << "NG" << endl;
	return 0;
}


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

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

    if(A==B){
        cout<<"Draw"<<endl;
    }else if(A==1){
        cout<<"Alice"<<endl;
    }else if (B==1){
        cout<<"Bob"<<endl;
    }
    if(A>B&&B!=1)   cout<<"Alice"<<endl;
    if(B>A&&A!=1)   cout<<"Bob"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
// B - Sumo

using namespace std;

int main() {
    string S;
    int cnt;

    cin >> S;

    cnt = 0;
    for (char c : S) {
        if (c == 'o')
            cnt++;
    }

    if (cnt + (15 - S.size()) >= 8)
        cout << "YES" << "\n";
    else
        cout << "NO" << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	private void doit(){
		
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		while(sc.hasNext()){
			char []  c = sc.next().toCharArray();
			int count = 0;
			char prev = c[0];
			for(int i = 1; i < c.length; i++){
				if(prev != c[i]){
					count++;
					prev = c[i];
				}
			}
			System.out.println(count);
			
		}

	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 14084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>

int gcd_euclid(int u, int v)
{
    int r;
    while (0 != v)
    {
        r = u % v; u = v; v = r;
    }
    return u;
}

int main()
{
    int N, X;
    std::cin >> N >> X;

    std::vector<int> abs(N);
    for (int i = 0; i < N; i++)
    {
        int in;
        std::cin >> in;
        abs[i] = std::abs(in - X);
    }

    int gcd = abs[0];
    for (int i = 1; i < N; i++)
    {
        gcd = gcd_euclid(gcd, abs[i]);
    }

    std::cout << gcd << std::endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
ai = [int(input()) for i in range(n)]

ans = 0
nokori = 0

ans = ai[0] // 2
ai[0] %= 2

for i in range(1,n):
    if ai[i] > 0:
        ans += ai[i] // 2
        if ai[i] % 2 == 1:
            if ai[i-1] == 1:
                ans += 1
            else:
                ai[i] = 1
        else:
            if ai[i-1] == 1:
                ai[i] = 1

print(ans)

Measured memory_bytes: 50392
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var A = Number(lines[0].split(" ")[0]);
    var B = Number(lines[0].split(" ")[1]);

    if (A * B % 2 === 0) { console.log("Even") }
    else { console.log("Odd") }
});

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

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t long long
// sort(&a[0], &a[4], [](auto& x, auto& y){return x[0] < y[0];});
//accumulate(&arr2[n], &arr2[m-1], 0);
using namespace std;

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

  int N;std::cin >> N;
  vector<vector<ll>> AB(N,vector<ll>(2,0));
  for (size_t i = 0; i < N; i++) {
    std::cin >> AB[i][0] >> AB[i][1];
  }
  sort(&AB[0], &AB[N], [](auto& x, auto& y){return x[1] < y[1];});

  ll sum = 0;
  for (size_t i = 0; i < N; i++) {
    sum += AB[i][0];
    if(sum > AB[i][1]){
      std::cout << "No" << '\n';
      return 0;
    }
  }
  std::cout << "Yes" << '\n';

  return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
int a,b,c; 
int main()
{
	cin>>a>>b>>c;
	for(int i=1;i<=1000;i++)
	{
		if(a*i%b==c) {
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long int n,a,b;
cin>>n>>a>>b;
long long int c = (n/(a+b));
long long int ans=c*a;
long long int rem =n%(a+b);
if(rem>a)
ans+=a;
else
ans+=rem;


cout<<ans;

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 2005000
#define MOD 1000000007
#define N 100005
#define M 1000005
#define LOG 60
#define KOK 4000000
using namespace std;

int n,a,b;
ll ar[N],ar2[N];

bool ok(ll val) {

	ll tot=val*b;

	for(int i=1;i<=n;i++) ar2[i]=ar[i]-tot;

	ll cnt=0;

	for(int i=1;i<=n;i++) {

		if(ar2[i]>0) cnt+=(ar2[i]+(a-b)-1)/(a-b);

	}

	return cnt<=val;

} 

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d %d %d",&n,&a,&b);

	for(int i=1;i<=n;i++) {

		scanf("%lld",&ar[i]);

	}

	ll bas=0,son=100000000000000/max(a,b);

	while(bas<=son) {

		if(ok(orta)) son=orta-1;
		else bas=orta+1;

	}

	printf("%lld",bas);

}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int a,b=0,c;
    scanf("%d",&a);
    int i=a;
    while(i){
        c =i % 10;
        b =b + c;
        i =i / 10;
    }
    if(a%b==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import itertools
N,M,X=map(int,input().split())

calist=[]
for i in range(N):
  c,*alist=list(map(int,input().split()))
  calist.append((c,alist))
#print(calist)

answer=float("inf")
for perm in itertools.product(range(2),repeat=N):
  #print(perm)
  if sum(perm)==0:
    continue
    
  perm_price=0
  achieve=[0]*M
  for i in range(N):
    if perm[i]==0:
      continue
    
    ci,alist=calist[i]
    perm_price+=ci
    for j in range(M):
      achieve[j]+=alist[j]
      
  if min(achieve)>=X:
    answer=min(answer,perm_price)
    
if answer==float("inf"):
  print(-1)
else:
  print(answer)

Measured memory_bytes: 68860
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
//struct edge {int to,cost;};
#define VMAX 200+10
    ll N,A[100010];
    ll F[100010];
    ll l,r;
    ll ans;

ll LP(ll x,ll y){
    if(y==0)return 1;
    if(y%2==0)return LP(x,y/2)*LP(x,y/2)%MOD;
    else return LP(x,y-1)*x%MOD;
}
ll Fact[100010];
ll Com[100010];
void FC(ll x){
    Fact[0]=Com[0]=1;
    ll temp=1;
    EREP(i,x){
        temp=temp*i%MOD;
        Fact[i]=temp;
        Com[i]=LP(temp,MOD-2);
    }
}
ll MC(ll x,ll y){
    if(y==0)return 1;
    if(x<y)return 0;
    return Fact[x]*(Com[y]*Com[x-y]%MOD)%MOD;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,100010)F[i]=-1;
    REP(i,N+1){
        cin>>A[i];
        if(F[A[i]]==-1)F[A[i]]=i;
        else{
            l=F[A[i]];
            r=i;
        }
    }
    FC(N+2);
    REP(i,N+1){
        DEB(MC(N+1,i+1))DEB(MC(l+N-r,i))END
    cout<<(MC(N+1,i+1)-MC(l+N-r,i) + MOD)%MOD<<endl;
    }
    return 0;
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;

int main() {
	int arr[3];
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr, arr + 3);
	if(arr[0] + arr[1] == arr[2])cout << "Yes";
	else cout << "No";
	return 0;
}


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

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

    if((A >= 1 && A <= 9) && (B >= 1 && B <= 9)) {
        cout << A * B << "\n";
    } else {
        cout << "-1\n";
    }
}

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

using namespace std;


#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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N,K,Q;
	cin >> N>>K>>Q;
	map <int, int> order;
	vector<int>a(N,0);
	int tmp;
	rep(i, Q) {
		cin >> tmp;
		a[tmp-1]++;
	}
	rep(i, N) {
		if (K - (Q - a[i]) > 0)println("Yes");
		else println("No");
	}
	
}

Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		
		List<Integer> li = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		for(int i = 0; i < 5; i++) {
			li.add(sc.nextInt());
		}
		sc.close();
		
		Comparator<Integer> c = new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2){
				if(o1 > o2) return -1;
				else if(o1 == o2) return 0;
				else return 1;
			}
		};
		
		Collections.sort(li, c);
		showList(li);
		
	}
	
	static <E> void showList(List<E> list){
		for(int i = 0; i < list.size()-1; i++) {
			System.out.print(list.get(i) + " ");
		}
		System.out.println(list.get(list.size() - 1));
	}
}

Measured memory_bytes: 17372
#include <stdio.h>

int main(){	
	char str[25];
	scanf("%s", str);
	
	for(int i=0; str[i]!='\0'; i++){
		if(str[i]==',' || str[i]==','){
			printf(" ");
		} else {
		printf("%c", str[i]);
		}
	}
	
	puts(" ");
	return 0;
}

Measured memory_bytes: 1664