akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <queue>
#include <cmath>
#include <cfloat>
#include <set>
#include <map>

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, a, b, c, d, e, f);
	// water: 100*(a + b);
	// sugar: c + d;
	// thickness = 100 * water / (water + sugar)
	// sugar/water = e/100
	// <-> e <= 100*sugar/water
	// sugar + water <= f(上限)で, 
	// 濃度の最大値を求める
	// 全探索で行けそう?
	// O(100*100*100*100) = O(10^8)?
	// 枝借りした方が良さそう

	double ans = 0.0, ans_water=0, ans_sugar=0;
	REP(ai, f/a*100 + 1) {
		REP(bi, f/b*100 + 1) {
			long double water = 100.0 * (a * ai + b * bi);
			if (water > f) break;
			
			REP(ci, f/c + 1) {
				REP(di, f/d + 1) {
					long double sugar = c * ci + d * di;
					if (water + sugar > f) break;
					if (100.0 * sugar / water > e) break;

					double thickness = 100.0 * sugar /water;
					if (thickness >= ans) {
						ans = thickness;
						ans_water = water+sugar;
						ans_sugar = sugar;
					}
				}
			}
		}
	}
	OUT(ans_water)SP;OUT(ans_sugar)BR;
	
	
	
  return 0;
}


Measured memory_bytes: 256
import sys
import queue

input = sys.stdin.readline

N, M = map(int,input().split())
vy = [list(map(lambda x:int(x)-1,input().split())) for i in range(M)]
s, t = map(lambda x:int(x)-1,input().split())

nlist = [[[] for j in range(3)] for i in range(N)]
for v, y in vy:
    nlist[v][0].append([y,1])
    nlist[v][1].append([y,2])
    nlist[v][2].append([y,0])

visit = [[False]*3 for i in range(N)]

def bfs(visit):
    Q = queue.Queue()
    visit[s][0] = True
    Q.put([[s,0],0])
    while not Q.empty():
        node = Q.get()
        if node[0][0] == t and node[0][1] == 0:
            return node[1]
        for i in nlist[node[0][0]][node[0][1]]:
            if not visit[i[0]][i[1]]:
                visit[i[0]][i[1]] = True
                Q.put([[i[0],i[1]],node[1]+1])
    return -1

ans = bfs(visit)
if visit[t][0]:
    print(ans//3)
else:
    print(ans)




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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<pair<string, ll>> M(N);
    rep(i, N) {
        string s;
        ll t;
        cin >> s >> t;
        M.emplace_back(s, t);
    }
    string X;
    cin >> X;
    ll ans = 0LL;
    bool flag = false;
    iter(i, M) {
        if(flag) {
            ans += i.second;
        } else if(i.first == X) {
            flag = true;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
		int a, b;
		cin >> a >> b;
		int MAX = 0, sum = 0;
		for (int c = 0; c < b; c++) {
			int d, e;
			cin >> d >> e;
			sum += max(0, a - d);
			MAX = max(MAX, a - d);
		}
		cout << sum - MAX << endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) > abs(x-b)){
        cout << "B" << "\n";
    }else{
        cout << "A" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

const int maxn=200000;

char s[maxn+10];
int n,cnt;
long long ans;

int main()
{
  scanf("%s",s+1);
  n=strlen(s+1);
  for(int i=1; i<=n; ++i)
    {
      if(s[i]=='W')
        {
          ++cnt;
          ans+=i-cnt;
        }
    }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 384
import bisect

if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            ab = l[i] + l[j]
            ans += bisect.bisect_left(l, ab) - j - 1
    print(ans)


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
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;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int S,W;
	cin >> S >> W;
	if (S <= W){
		puts("unsafe");
	}else{
		puts("safe");
	}
}

Measured memory_bytes: 3640
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=100000;
const int MOD=1000000007;

char s[MAXLEN+1]; int n;

int cnt[26];

int solve() {
	memset(cnt,0,sizeof(cnt)); REP(i,n) ++cnt[s[i]-'a'];
	int ret=1; REP(i,26) ret=(ll)ret*(cnt[i]+1)%MOD; ret=(ret+MOD-1)%MOD; return ret;
}

void run() {
	scanf("%d",&n); scanf("%s",s); 
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define chk(a) rep(i, a.size()) cout << a[i] << " "
#define SORT(c) sort((c).begin(),(c).end())
#define ll long long
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)


using namespace std;
typedef pair<int, int> pii;
#define WARU 1000000007;

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

int main(void) {

	string str = "CODEFESTIVAL2016";
	string s;
	cin >> s;
	int res = 0;
	rep(i, str.length()) {
		if (str[i] != s[i]) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int> adj[mex];
		
int main(){
	int n;
	cin>>n;
	int y=n%10;
	if(y==2 || y==4||y==5||y==7||y==9)
	 cout<<"hon\n";
	else if(y==3)
	 cout<<"bon";
	else
	 cout<<"pon"; 
}



Measured memory_bytes: 27072
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    ll money = 1000;
    ll stock = 0;
    rep(i, n - 1)
    {
        if(a[i] < a[i + 1])
        {
            auto buy = money / a[i];
            stock += buy;
            money -= buy * a[i];
        }
        else if(a[i] > a[i + 1])
        {
            money += stock * a[i];
            stock = 0;
        }
    }
    money += stock * a[n - 1];
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3556
n = gets.to_i
as = gets.split(" ").map(&:to_i)

tmp = 0
table = {}
as.sort!
n.times do |i|
  table[as[i]] ||= 0
  table[as[i]] += 1

  if table[as[i]] == as[i]
    tmp += as[i]
  end
end

puts as.size - tmp

Measured memory_bytes: 14476
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var abc = sc.ArrayInt(3);
        WriteLine(abc.OrderBy(i => i).Take(2).Sum());
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int a[]=new int[N];
		int d[]=new int[N];
		int tmp1=0;
		int tmp2=N/2;
		if(N%2==1) {
			tmp1=N/2+1;
		}else {
			tmp1=N/2;
		}
		int b[]=new int[tmp1];
		int c[]=new int[tmp2];
		for (int i = 0; i < N; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		for(int i = 0; i < N; i++) {
			if(i<tmp1) {
				b[i]=a[i];
			}else {
				c[i-tmp1]=a[i];
			}
		}
		//
		if(N%2==0) {
			d[0]=b[tmp1-1];
			for(int i = 1; i < N; i++) {
				if(i%2==1) {
					d[i]=c[tmp2-1-i/2];
				}else{
					d[i]=b[i/2-1];
				}
			}
			
			long sum=0;
			
			for(int i = 0; i < N-1; i++) {
				sum=sum+Math.abs(d[i]-d[i+1]);
			}
			System.out.print(sum);
		}
		
		if(N%2==1) {
			d[0]=b[tmp1-1];
			for(int i = 1; i < N; i++) {
				if(i%2==1) {
					d[i]=c[tmp2-1-i/2];
				}else{
					d[i]=b[i/2-1];
				}
			}
			long sum=0;
			long sum2=0;
			long sum3=0;
			long sum4=0;
			long sum5=0;
			long sum6=0;
			long sum7=0;
			long sum8=0;
			for(int i = 0; i < N-1; i++) {
				sum=sum+Math.abs(d[i]-d[i+1]);
			}
			for(int i = 1; i < N; i++) {
				if(i%2==1) {
					d[i]=b[tmp2-1-i/2];
				}else{
					d[i]=c[i/2-1];
				}
			}			
			for(int i = 0; i < N-1; i++) {
				sum2=sum2+Math.abs(d[i]-d[i+1]);
			}
			//3
			for(int i = 1; i < N; i++) {
				if(i%2==1) {
					d[i]=b[tmp2-1-i/2];
				}else{
					d[i]=c[tmp1-i/2-1];
				}
			}			
			for(int i = 0; i < N-1; i++) {
				sum3=sum3+Math.abs(d[i]-d[i+1]);
			}
			//4
			for(int i = 1; i < N; i++) {
				if(i%2==1) {
					d[i]=c[tmp2-1-i/2];
				}else{
					d[i]=b[tmp1-i/2-1];
				}
			}
			for(int i = 0; i < N-1; i++) {
				sum4=sum4+Math.abs(d[i]-d[i+1]);
			}
			//5

			//6
			//7
			//8
			
			long max=Math.max(Math.max(sum, sum2),Math.max(sum3, sum4));
			
			System.out.print(max);
			
			
		}
		
	}
}


Measured memory_bytes: 62904
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

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

using namespace std;
using ll = long long;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N*A, B) << endl;;
	
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int X,A,B; cin >>X>>A>>B;
    int ans = X;
    ans -= A;
    ans -= (ans/B)*B;
    ANS(ans);
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

const int inf = 1 << 29;
class UnionFind {
public:
  vector<int> rank, p;
  UnionFind(int size)
  {
    rank.resize(size, -inf);
    p.resize(size, -inf);
  }
  void make(int a)
  {
    rank[a] = 0;
    p[a] = a;
  }
  void unite(int a, int b)
  {
    link(find(a), find(b));
  }
  int find(int a)
  {
    return (a == p[a]) ? a : p[a] = find(p[a]);
  }
  bool isSameSet(int a, int b)
  {
    return find(a) == find(b);
  }
  void link (int a, int b)
  {
    if (rank[a] > rank[b]) {
      p[b] = a;
    } else {
      p[a] = b;
      if(rank[a] == rank[b]) rank[b]++;
    }
  }
};

struct E {
  int src, dst, cost;
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<pair<lli, lli>> v(n);
    cin >> v;

    vector<int> a, b;
    for (int i = 0; i < n; ++i) {
      a.push_back(i);
      b.push_back(i);
    }

    sort(a.begin(), a.end(), [&] (int i, int j) { return v[i].first < v[j].first; });
    sort(b.begin(), b.end(), [&] (int i, int j) { return v[i].second < v[j].second; });

    vector<E> es;
    for (int i = 0; i + 1 < n; ++i) {
      int x = a[i];
      int y = a[i + 1];
      auto c = abs(v[x].first - v[y].first);
      es.push_back(E{x, y, c});
      es.push_back(E{y, x, c});
    }
    for (int i = 0; i + 1 < n; ++i) {
      int x = b[i];
      int y = b[i + 1];
      auto c = abs(v[x].second - v[y].second);
      es.push_back(E{x, y, c});
      es.push_back(E{y, x, c});
    }

    sort(es.begin(), es.end(), [] (auto i, auto j) { return i.cost < j.cost; });

    UnionFind uf(n);
    for (int i = 0; i < n; ++i) {
      uf.make(i);
    }

    lli sum = 0;
    each (e, es) {
      if (!uf.isSameSet(e.src, e.dst)) {
        uf.unite(e.src, e.dst);
        sum += e.cost;
      }
    }
    cout << sum << endl;
  }

  return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b) swap(a, b);
    if (a < c) swap(a, c);
    if (b < c) swap(b, c);

    cout << a + 2 * ((b - c) & 1) - b + (b - c) / 2;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
def rec(itr, a, b, c, mp):
    if itr == N:
        if a == 0 or b == 0 or c == 0:
            return 10 ** 9
        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30
    res = rec(itr + 1, a, b, c, mp)
    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10)
    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10)
    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10)
    return res
print(rec(0, 0, 0, 0, 0))


Measured memory_bytes: 9236
#include <iostream>
// #include <vector>
// #include <algorithm>
// #include <string>
// #include <map>
// #include <set>
// #include <cmath>

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;

// void p() {
//     cout << "\n";
// }
// template<class Head, class... Body>
// void p(Head head, Body... body) {
//     cout << head << ",";
//     p(body...);
// }

int main(int argc, char const *argv[]) {
    int W, a, b;
    cin >> W >> a >> b;
    if (a + W < b) {
        cout << b - (a + W) << endl;
    } else if (b + W < a) {
        cout << a - (b + W) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int a[100];//count
signed main() {
	int b; cin >> b;
	int MAX = 0;
	for (int c = 0; c < b; c++) {
		int d; cin >> d;
		a[d]++;
		MAX = max(MAX, d);
	}
	if (MAX & 1) {
		for (int i = (MAX + 1) / 2; i <= MAX; i++) {
			a[i] -= 2;
		}
		for (int i = 1; i < b; i++) {
			if (a[i] < 0) {
				puts("Impossible");
				return 0;
			}
			if (a[i]) {
				if (i < (MAX + 3) / 2) {
					puts("Impossible");
					return 0;
				}
			}
		}
		puts("Possible");
	}
	else {
		a[MAX / 2]--;
		for (int i = (MAX + 2) / 2; i <= MAX; i++) {
			a[i] -= 2;
		}
		for (int i = 1; i < b; i++) {
			if (a[i] < 0) {
				puts("Impossible");
				return 0;
			}
			if (a[i]) {
				if (i < (MAX + 2) / 2) {
					puts("Impossible");
					return 0;
				}
			}
		}
		puts("Possible");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

void go(vector<pair<double, double> >& v, vector<pair<double, double> >& vn, double& sum, int count)
{
    if (count == v.size())
    {
        for (int i = 1; i < vn.size(); i++)
        {
            sum += sqrt(pow(vn[i - 1].first - vn[i].first, 2) + pow(vn[i - 1].second - vn[i].second, 2));
        }
    }
    else
    {
        for (int i = 0; i < v.size(); i++)
        {
            bool exists = false;
            for (int j = 0; j < vn.size(); j++)
            {
                if (vn[j] == v[i])
                {
                    exists = true;
                    break;
                }
            }
            if (!exists)
            {
                vn.push_back(v[i]);
                go(v, vn, sum, count + 1);
                vn.pop_back();
            }
        }
    }
}

int main()
{
    int n;
    cin >> n;
    vector<pair<double, double> > v;
    double sum = 0;
    for (int i = 0; i < n; i++)
    {
        double a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }


    vector<pair<double, double> > vn;
    go(v, vn, sum, 0);

    double fact = 1;
    for (int i = 1; i <= n; i++)
    {
        fact *= i;
    }

    double ans = sum / fact;
    printf("%.10f", ans);
    return 0;
}


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


long long x;

long long f(long long a){
    if(a==-1) return 0;
    else return a/x+1;
}

int main(void){
    long long a,b;
    cin >> a >> b >> x;
    cout << f(b)-f(a-1) << endl;

    return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a>b){
    swap(a,b);
  }
  if(a>c){
    swap(a,c);
  }
  if(b>c){
    swap(b,c);
  }
  cout << a << ' ' << b << ' ' << c << endl; 
}



Measured memory_bytes: 3100
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2610&lang=jp
// 夏合宿2013:day3D
// Fast Division

/*
Problem.
非負整数nについて、
p(n):2^n より大きい最小の素数で、p(0) = 2 とする。
10進法でp(n)-1桁の正整数 111....1 をp(n)で割ったあまりを求めよ。

Point.
111...1はレピュニット(rep unit)数という。
111...1 = (10^p(n) - 1) / 9 と変更する。
フェルマーの少定理より、a,pが互いに素であるときa^(p-1) %p = 1
よって、
条件：10とpが互いに素であり、9とpが互いに素であるとき
(10^p(n)-1) % p(n) = 0
となる。
条件を満たすのはn>=3の全て、n<=2は手計算。
*/


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  if(n == 0) cout << 1 << endl;
  else if(n == 1) cout << 2 << endl;
  else if(n == 2) cout << 1 << endl;
  else cout << 0 << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 998244353LL;
const double eps = 1e-7;
int N, M, K, Q, T;
ll gcd(ll a, ll b) {
	if (b == 0LL) return a;
	return gcd(b, a % b);
}

ll dp[3010][3010];
int A[3010];

ll fexp(ll b, ll e) {
	ll mul = 1LL;
	while (e) {
		if (e & 1) mul = mul * b % MOD;
		e >>= 1;
		b = b * b % MOD;
	}
	return mul;
}

int main()
{
	int i, j, S;
	scanf("%d%d", &N, &S);
	for (i = 1; i <= N; ++i) {
		scanf("%d", &A[i]);
	}
	ll inv2 = fexp(2LL, MOD - 2);
	ll pow2N = fexp(2LL, (ll)N - 1);
	for (i = 1; i <= N; ++i) {
		for (j = S; j >= 1; --j) {
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
			if(j - A[i] > 0) dp[i][j] = (dp[i][j] + (dp[i - 1][j - A[i]] * inv2 % MOD))%MOD;
		}
		dp[i][A[i]] = (dp[i][A[i]] + pow2N) % MOD;
	}
	printf("%lld", dp[N][S]);
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;

Int gcd(Int a, Int b) {
    Int n = max(a, b);
    Int m = min(a, b);
    return m == 0 ? n : gcd(m, n % m);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int a, b;
    cin >> a >> b;
    dump(a * b / gcd(a, b));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  ll l[n];
  for(ll i=0;i<n;i++)cin >> l[i];

  sort(l,l+n);
  ll s=0;

  for(ll i=0;i<n-1;i++){
    for(ll j=i+1;j<n;j++){
      ll p = lower_bound(l,l+n,l[i]+l[j])-l-1;
      s+=p-j;
    }
  }

  cout << s << endl;


}

Measured memory_bytes: 3624
def factorize(n):
    fct = set()
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.add(b)
        b,e = b+1,0
    if n > 1:
        fct.add(n)
    return fct
a,b = map(int,input().split())
print(len(factorize(a)&factorize(b))+1)

Measured memory_bytes: 9056
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std;
#define ll long long

int main() {
    string a;
    cin >> a;
    int k;
    cin >> k;
    int len = a.size();
    long long e = 0;
    if (k == 1) {
        e += 9 * (len - k);
        e += a[0] - '0';
    }
    if (k == 2) {
        if (len > 1) {
            int i;
            for (i = 1; i <= len - k; i++) {
                e += 81 * i;
            }
            e += i * 9 * (a[0] - '0' - 1);
            for (int j = 1; j < len; j++) {
                if (a[j] != '0') {
                    e += a[j] - '0';
                    e += 9 * (i - j);
                    break;
                }
            }
        }
    }
    if (k == 3) {
        if (len > 2) {
            int i;
            for (i = 1; i <= len - k; i++) {
                e += 729 * (i + 1) * i / 2;
            }
            i++;
            e += (a[0] - '0' - 1) * (i - 1) * i / 2 * 81;
            for (int j = 1; j < len; j++) {
                if (a[j] != '0') {
                    e += (a[j] - '0' - 1) * (i - j) * 9;
                    for (int l = j + 1; l < len; l++) {
                        if (a[l] != '0') {
                            e += a[l] - '0';
                            e += 9 * (i - l);
                            break;
                        }
                    }
                    e += (i - j - 1) * (i - j) / 2 * 81;
                    break;
                }
            }
        }
    }
    printf("%lld\n", e);
    return 0;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

//0 1
//< >
//L R
const double EPS=1e-9;
int N,L;
int D[111],X[111];

void solve(){
    int ans=0;
    rep(i,N){
        char d;
        cin>>d>>X[i];
        if(d=='L')D[i]=0;
        else D[i]=1;
        chmax(ans,D[i]?L-X[i]:X[i]);
    }

    deque<int>d,id;
    deque<double>x;
    rep(i,N)d.pb(D[i]),id.pb(i),x.pb(X[i]);

    while(true){
        double hoge=111111111;
        rep(i,d.size()-1){
            if(d[i]==0||d[i+1]==1)continue;
            chmin(hoge,(x[i+1]-x[i])/2);
        }
        if(d[0]==0)chmin(hoge,x[0]);
        if(d.back()==1)chmin(hoge,L-x.back());
        rep(i,d.size()){
            if(d[i])x[i]+=hoge;
            else x[i]-=hoge;
        }
        rep(i,d.size()-1){
            if(d[i]==0||d[i+1]==1)continue;
            if(x[i+1]-x[i]<EPS){
                bool f=false;
                reps(j,1,L)if(abs(x[i]-j)<EPS)f=true;
                if(f){
                    d[i]=0;d[i+1]=1;
                }
                else{
                    swap(d[i],d[i+1]);
                    swap(id[i],id[i+1]);
                }
                i++;
            }
        }
        if(L-x.back()<EPS){
            if(d.size()==1){
                cout<<ans<<" "<<id[0]+1<<endl;
                return;
            }
            d.pop_back();id.pop_back();x.pop_back();
        }
        if(x.front()<EPS){
            if(d.size()==1){
                cout<<ans<<" "<<id[0]+1<<endl;
                return;
            }
            d.pop_front();id.pop_front();x.pop_front();
        }
        //rep(i,d.size())cout<<d[i]<<" ";cout<<"||";
        //rep(i,id.size())cout<<id[i]+1<<" ";cout<<endl;
    }
}

signed main(){
    while(cin>>N>>L,N||L)solve();
    return 0;
}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("ARC")){
            System.out.println("ABC");
        }else{
            System.out.println("ARC");
        }



    }


}

Measured memory_bytes: 35672
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

int n, k, m = 1e9 + 7;

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

    int h, w;
    cin >> h >> w;

    vvc a(h, vc(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    vvi dp(h, vi(w, m));
    if(a[0][0] == '.') dp[0][0] = 0;
    else dp[0][0] = 1;

    int dx[] = {1, 0}, dy[] = {0, 1};
    rep(i, h) {
        rep(j, w) {
            rep(k, 2) {
                int nx = j + dx[k];
                int ny = i + dy[k];

                if(ny >= h || nx >= w) continue;
                if(a[i][j] == '.' && a[ny][nx] == '#') {
                    dp[ny][nx] = min(dp[ny][nx], dp[i][j] + 1);
                } else {
                    dp[ny][nx] = min(dp[ny][nx], dp[i][j]);
                }
            }
        }
    }

    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    if(a[0] == 0){
        cout<<0<<endl;
        return 0;
    }

    ll ans = 1;
    for(ll i=0;i<n;i++){
        if(ans > INF / a[i]){
            cout<<-1<<endl;
            return 0;
        }
        ans *= a[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<long long> vl;

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


Measured memory_bytes: 256
A,B,C,D = list(map(int,input().split()))


if A < C:
  a = C
else:
  a = A

if B < D:
  b = B
else:
  b = D
  
if B <= C or D <= A:
  res = 0
else:
  res = (b-a)
  
print(res)



Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(void)
{
	int H=0,W=0,a=0,c=0;
	cin>>H>>W;
	char d=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>d;
			if(d=='.'&&c==0){
				cout<<"-1";
				}
			else if(d=='c'){
				cout<<"0";c=1;a=0;}
			else if(d=='.'){
				a++;cout<<a;
				}
			if(j==W-1){
				cout<<endl;
				c=0;
				a=0;
				}
			else{
				cout<<" ";
				}
		}
	}
	return 0;
}


Measured memory_bytes: 3052
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//sin(x* pi / 180)
//be careful from the multiplication while using this define 
//alot of memset may couse TLE
#define TC int t;cin>>t;while(t--)
int dx[] = { 0,0,-1,1,1,1,-1,-1 };
int dy[] = { 1,-1,0,0,1,-1,1,-1 };
//</DEFINE>
ll OO = 1e18;	
int main() {
	Fast(), File();
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	vector<vector<vector<ll>>>dp(n, vector<vector<ll>>(n, vector<ll>(2)));
	for (int i = 0; i < n; i++)dp[i][i][1] = v[i], dp[i][i][0] = -v[i];
	for (int i = 1; i < n ; i++) {
		int l = 0;
		for (int r = i; r < n; r++, l++) {
			dp[l][r][0] = OO, dp[l][r][1] = -OO;
			dp[l][r][0] = min(dp[l + 1][r][1] - v[l], dp[l][r][0]);
			dp[l][r][1] = max(dp[l + 1][r][0] + v[l], dp[l][r][1]);
			dp[l][r][0] = min(dp[l][r - 1][1] - v[r], dp[l][r][0]);
			dp[l][r][1] = max(dp[l][r - 1][0] + v[r], dp[l][r][1]);
		}
	}
	cout << dp[0][n - 1][1] << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int h, w, d;
	cin >> h >> w >> d;

	map<int, ii> info;
	rep(i, h) {
		rep(j, w) {
			int v;
			cin >> v;

			info[v] = make_pair(i, j);
		}
	}

	vector<vector<int>> dist(d, vi(h * w / d + 1));
	for (int i = 1; i <= h * w - d; ++i) {
		ii now = info[i], next = info[i + d];

		int tmp = abs(next.first - now.first) + abs(next.second - now.second);
		dist[i % d][i / d + 1] = tmp + dist[i % d][i / d];
	}

	int q;
	cin >> q;
	vi ans;
	rep(i, q) {
		int x, y;
		cin >> x >> y;
		ans.push_back(dist[y % d][y / d] - dist[x % d][x / d]);
	}
	rep(i, q) cout << ans[i] << endl;
}

Measured memory_bytes: 11512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int main() {
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200000],tmp[200000];
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		tmp[i]=a[i];
	}
	sort(tmp,tmp+n);
	for(i=0;i<n;i++)
	{
		if(a[i]<=tmp[(n+1)/2-1])
			printf("%d\n",tmp[(n+1)/2]);
		else
			printf("%d\n",tmp[(n+1)/2-1]);
	}
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	long long int v1=x,v2=x,rem1=x,
	rem2=x,ans=x;
	long long int val1=x/d;
	if(val1>k)
	{
		ans=x-k*d;
		cout<<ans;
		return 0;
	}
	if(val1<=k)
       {
       	v1=x-val1*d;
       	v1=abs(v1);
        rem1=k-val1;
       }
    if(val1+1<=k)
    {
    	val1++;
    	v2=x-val1*d;
    	v2=abs(v2);
    	rem2=k-val1;
    }
    else{
    	cout<<v1;
    	return 0;
    }
    if(v1<v2)
    {
       if(rem1%2==0)
       	ans=v1;
       else ans=v2;
    }
    else{
    	if(rem2%2==0)
    		ans=v2;
    	else ans=v1;
    }
    cout<<ans;
}

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

bool match( const string& s, int pos, const string& pat ) {
	int len = s.size();

	for( int i = 0; i < pat.size(); ++i ) {
		int x = (pos + i) % len;

		if( s.at( x ) != pat.at( i ) ) {
			return false;
		}
	}

	return true;
}

int main() {
	string s, p;
	getline( cin, s );
	getline( cin, p );

	string result = "No";

	for( int i = 0; i < s.size(); ++i ) {
		if( match( s, i, p ) ) {
			result = "Yes";
			break;
		}
	}

	cout << result << endl;
}



Measured memory_bytes: 3200
n = input()
a = list(map(int, input().split()))
c = 0
def han(a):
    b = list(map(lambda x: x % 2, a))
    c = 0
    for i in b:
        if i == 0:
            c += 1
        else:
            c -= 1
    if c == len(b):return 1
    else: return 0

while True:
    if han(a) == 1:
        a = list(map(lambda x: x / 2, a))
        c += 1
    if han(a) == 0: 
        break
        c = 0

print(c)

        

Measured memory_bytes: 3064
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 4e5 + 10, mod = 998244353;

vector<pii> g[N];
int color[N];
ll cnt[N], p2[N];

ll solve(int d, int n, string x);
bool assign(int u, int col);

int main() {
	// int n = 6;
	// for (int i = 0; i < (1 << n); ++i) {
	// 	int cpy = i, steps = 0;
	// 	while (true) {
	// 		if (cpy % 2 == 0) {
	// 			cpy = (cpy / 2) + (1 << (n - 1));
	// 		} else {
	// 			cpy = (cpy - 1) / 2;
	// 		}
	// 		++steps;
	// 		if (cpy == i) {
	// 			break;
	// 		}
	// 	}
	// 	cout << i << ' ' << steps << endl;
	// }
	// return 0;
	fast_cin();
	int n; cin >> n;
	string x; cin >> x;
	// reverse(x.begin(), x.end());
	vector<int> divisors;
	int sq = sqrt(2 * n);
	for (int i = 1; i <= sq; ++i) {
		if ((2 * n) % i == 0) {
			divisors.pb(i);
			if (i * i != 2 * n) {
				divisors.pb((2 * n) / i);
			}
		}
	}
	p2[0] = 1;
	for (int i = 1; i < N; ++i) {
		p2[i] = (2 * p2[i - 1]) % mod;
	}
	sort(divisors.begin(), divisors.end());
	ll ans = 0;
	for (auto &d : divisors) {
		cnt[d] += solve(d, n, x);
		cnt[d] %= mod;
		// cout << d << ' ' << cnt[d] << endl;
		for (int i = 2 * d; i <= 2 * n; i += d) {
			cnt[i] += (mod - cnt[d]);
			cnt[i] %= mod;
		}
		ans += d * cnt[d];
		ans %= mod;
	}
	cout << ans << endl;
}

ll solve(int d, int n, string x) {
	for (int i = 0; i < n; ++i) {
		g[i].clear();
	}
	for (int i = 0; i < n; ++i) {
		if (i + d < n) {
			g[i].pb({i + d, 0});
			g[i + d].pb({i, 0});
		} else if (d != 2 * n) {
			g[i].pb({(i + d) % n, 1});
			g[(i + d) % n].pb({i, 1});
		} else {
			// g[i].pb({(i + d) % n, 0});
			// g[(i + d) % n].pb({i, 0});
		}

	}
	memset(color, -1, sizeof(color));
	ll components = 0;
	for (int i = 0; i < n; ++i) {
		if (color[i] == -1) {
			if (!assign(i, 0)) {
				return 0;
			}
			++components;
		}
	}
	memset(color, -1, sizeof(color));
	// cout << "comp " << d << ' ' << components << endl;
	ll ans = 0, left = components;
	for (int i = 0; i < n; ++i) {
		// if (d == 2 * n) {
		// 	cout << i << ' ' << x[i] << ' ' << color[i] << ' ' << left << endl;
		// }
		if (x[i] == '0') {
			if (color[i] == 1) {
				break;
			} else if (color[i] == -1) {
				assign(i, 0);
				--left;
			}
		} else {
			if (color[i] == -1) {
				assign(i, 1);
				--left;
				ans += p2[left];
				ans %= mod;
			} else if (color[i] == 0) {
				ans += p2[left];
				ans %= mod;
				break;
			}
		}
		if (i == n - 1) {
			++ans;
			ans %= mod;
		}
	}
	return ans;
}

bool assign(int u, int col) {
	if (color[u] != -1) {
		return color[u] == col;
	}
	color[u] = col;
	for (auto &e : g[u]) {
		int v = e.first, type = e.second;
		if (!assign(v, col ^ type)) {
			return false;
		}
	}
	return true;
}

Measured memory_bytes: 30356
import java.util.*;
 
public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){   
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int ans = a+b;
            if(ans<10){
                System.out.println("1");
            }
            if(ans<100 && ans>9){
                System.out.println("2");
            }
            if(ans<1000 && ans>99){
                System.out.println("3");
            }
            if(ans<10000 && ans>999){
                System.out.println("4");
            }
            if(ans<100000 && ans>9999){
                System.out.println("5");
            }
            if(ans<1000000 && ans>99999){
                System.out.println("6");
            }
            if(ans<10000000 && ans>999999){
                System.out.println("7");
            }
        }
    }
 
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

int solve(int N, ll x, vector<ll>& a) {
    sort(ALL(a));
    rep(i,N) {
        if (x < a[i]) return i;
        x -= a[i];
    }
    return x ? N-1 : N;
}

int main() {
    int N, x; cin >> N >> x;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    cout << solve(N,x,a) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        
        if(n > k){
            n = n % k;
        }
        n = Math.min(n, k-n);

        System.out.println(n);
    }
}


Measured memory_bytes: 21716
import sys
input = sys.stdin.readline
 
x, y, z, k = map(int, input().split())
a = sorted(int(i) for i in input().split())
b = sorted(int(i) for i in input().split())
c = sorted(int(i) for i in input().split())
 
#a.sort(reverse=True)
#b.sort(reverse=True)
#c.sort(reverse=True)
 
ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]
 
print(*abc[:k], sep="\n")

Measured memory_bytes: 162704
# -*- coding: utf-8 -*-


def get_input() -> int:
    """
    標準入力の取得

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    求解処理.

    Args:\n
        N (int): 整数（N <= 999）
    """
    """
    Nの1桁目で場合分け.
    """
    result = str()
    first_place = N % 10
    if first_place in [2, 4, 5, 7, 9]:
        result = "hon"
    elif first_place in [0, 1, 6, 8]:
        result = "pon"
    else:
        result = "bon"

    # 求解処理
    print(result)


if __name__ == "__main__":
    N = get_input()
    main(N)


Measured memory_bytes: 9140