akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define ull unsigned long long
#define rep(i,a,b) for(ull (i)=(a);(i)<(b);(i)++)
#define repn(i,a,b,n) for(ull (i)=(a);(i)<=(b);(i)+=(n))
#define NUM 300000
using namespace std;
class Prime{
private:
	bool all[NUM];
	bool range[NUM];
	ull m;//nの平方根
	ull st, ed;//始点、終点
public:
	Prime(ull s,ull e);
	void e_solve();//nまでの素数の列挙
	bool e_judge();//素数判定
	void e_solve_se();//区間内素数列挙
	void set_range(ull s, ull e);
	void disp_all();
	void disp_range();
	ull get_NUM();
};

Prime::Prime(ull s,ull e){
	set_range(s, e);
	memset(all, 0, sizeof(all));
	memset(range, 0, sizeof(range));
}

void Prime::set_range(ull s, ull e){
	m = (ull)sqrt(e) + 1;
	st = s;
	ed = e;
}

void Prime::e_solve(){//nまでの素数の列挙
	all[0] = all[1] = true;
	repn(i, 4, ed, 2)all[i] = true;
	repn(i, 3, ed, 2){
		if (all[i])continue;
		repn(j, 2 * i, ed, i)all[j] = true;
		if (i >= m)break;
	}
}

bool Prime::e_judge(){//素数判定
	if (!(ed & 1) && ed != 2)return(false);
	repn(i, 3, ed, 2){
		if (ed%i==0)return(false);
		if (i >= m)return(true);
	}
	return(0);
}

void Prime::e_solve_se(){//区間内素数列挙
	all[0] = all[1] = true;
	ull x = st & 1 ? 1 : 0;
	repn(i, 4, m, 2){
		all[i] = true;
	}
	repn(i, x, ed - st, 2)range[i] = true;
	repn(i, 3, m, 2){
		if (all[i])continue;
		repn(j, 2 * i, m, i)all[j] = true;
		ull temp = (st / i) + 1;
		temp = temp*i - st;
		repn(j, temp,ed-st, i)range[j] = true;
		if (i >=m)break;
	}
}

void Prime::disp_all(){
	if (ed >= 2)cout << "2 ";
	repn(i, 3, ed, 2)
	if (!all[i])printf("%lld ", i);
	cout << endl;
}

void Prime::disp_range(){
	repn(i, 0, ed - st, 1)if (!range[i])printf("%lld ", i+st);
	cout << endl;
}
ull Prime::get_NUM(){
	if (st == 1 || st == 2)return(1);
	ull end = ed - st;
	ull sum = 0;
	repn(i, 1, end, 1)if (!range[i])sum ++;
	return(sum);
}

int main(void){
	while (true){
		ull st;
		cin >> st;
		if (st == 0)return(0);
		Prime p(st, 2 * st);
		//p.e_solve();
		p.e_solve_se();
		//p.disp_all();
		//p.disp_range();
		cout << p.get_NUM() << endl;
	}
	return(0);
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

int main() {
  int k, s, cnt = 0;
  cin >> k >> s;
  rep(x, k + 1) rep(y, k + 1) {
    int z = s - x - y;
    if(z >= 0 && z <= k)
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
def readInt():
    return list(map(int,input().split()))
    
n,k = readInt()
ans = 0
nusuke = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    a = readInt()
    for i in range(d):
        a[i] -= 1
    # print(a)
    for j in a:
        nusuke[j] += 1
# print(nusuke)
for m in nusuke:
    if m==0:
        ans += 1
print(ans)
    


Measured memory_bytes: 9188
#include"bits/stdc++.h"
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	bool ch=false;
	for(int i=a.size()-b.size();i>=0;--i){
		string s=a.substr(i,b.size());
		bool eq=true;
		for(int j=0;j!=s.size();++j){
			if(s[j]!='?'){
				if(s[j]!=b[j]){
					eq=false;
					break;
				}
			}
		}
		if(eq){
			ch=true;
			for(int j=i,k=0;j!=i+b.size();++j,++k)
				a[j]=b[k];
			break;
		}
	}
	if(ch){
		for(int i=0;i!=a.size();++i){
			if(a[i]=='?')
				a[i]='a';
		}
		cout<<a;
	}
	else
		cout<<"UNRESTORABLE";
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

vector<pint> edge[MAX_N];
bool reach[MAX_N];
int ans[MAX_N];

void dfs(int now,lint sum){
    if(reach[now]) return;
    reach[now]=true;
    if(sum%2) ans[now]=0;
    else ans[now]=1;
    rep(i,edge[now].size()) dfs(edge[now][i].fi,sum+edge[now][i].se);
}

int main(void){
    int N;
    cin >> N;
    rep(i,N-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--,v--;
        edge[u].push_back(pint(v,w));
        edge[v].push_back(pint(u,w));
    }
    dfs(0,0);
    rep(i,N) cout << ans[i] << endl;
}

Measured memory_bytes: 13984
#include<stdio.h>

int solve(int lst,int i,int n,int sum,int s){
  int j,su=0;
  if(i==n){
    return sum==s?1:0;
  }
  for(j=lst+1;j<10;j++){
    if(sum+j<=s)
      su+=solve(j,i+1,n,sum+j,s);
  }
  return su;
}
int main(){
  int n,s;

  do{
	scanf("%d %d",&n,&s);
	if(n==0&&s==0) break;
    printf("%d\n",solve(-1,0,n,0,s));
  }while(1);
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int K, A, B; cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return;
		}
	}
	cout << "NG" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3648
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
  /**
   * Main method.
   */
  public static void main(String[] args) throws IOException {
    Scanner s = new Scanner(System.in);
    
    final int N = s.nextInt();
    final int D = s.nextInt();
    final int X = s.nextInt();
    
    int chocolate = 0;
    for (int i = 0; i < N; i++) {
    	int a_i = s.nextInt();
    	int day = 1;
    	while (day <= D) {
    		//System.out.println(day);
    		chocolate++;
    		day += a_i;
    	}
    }
    
    System.out.println(chocolate + X);
 
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

int main(void) {

	int D;
	cin >> D;

	string ans;

	if (D == 25) {
		ans = "Christmas";
	}
	else if (D == 24) {
		ans = "Christmas Eve";
	}
	else if (D == 23) {
		ans = "Christmas Eve Eve"; 
	}
	else {
		ans = "Christmas Eve Eve Eve";
	}

	cout << ans << endl;


	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> Ps(N);
    for (auto &Pi : Ps) { cin >> Pi; }
    int min = Ps.front();
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        const int Pi = Ps[i];
        if (Pi <= min)
        {
            ++ans;
            min = Pi;
        }
    }
    cout << ans << endl;
}


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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

ll solve(ll n, ll c, ll d) {
	ll x = n / c;
	ll y = n / d;
	ll z = n / (c * d / gcd(c, d));
	return n - (x + y - z);
}

int main() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << solve(b, c, d) - solve(a - 1, c, d) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    string st;
    vector<int> a(4);
    cin >> st;
    for(int i = 0; i < 4; ++i) a[i] = int(st[i] - '0');

    unsigned int bitOp = 0;

    for(bitOp = 0; bitOp < (1 << 3); ++bitOp){
        int sum = a[0];
        if(bitOp & (1 << 0)) sum += a[1];
        else                 sum -= a[1];
        if(bitOp & (1 << 1)) sum += a[2];
        else                 sum -= a[2];
        if(bitOp & (1 << 2)) sum += a[3];
        else                 sum -= a[3];

        if(sum == 7) break;
    }
    string stOp = "";
    if(bitOp & (1 << 0)) stOp += "+";
    else                 stOp += "-";
    if(bitOp & (1 << 1)) stOp += "+";
    else                 stOp += "-";
    if(bitOp & (1 << 2)) stOp += "+";
    else                 stOp += "-";

    cout << a[0] << stOp[0]
         << a[1] << stOp[1]
         << a[2] << stOp[2]
         << a[3] << "=7" << endl;

    return 0;
}

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

using namespace std;

char arr[50][50];
int h,w;

int solve(int i,int j,int x,int y)
{
	queue<pair<int,int> > q;
	q.push(make_pair(i,j));
	bool vis[h][w];
	memset(vis,false,sizeof(vis));
	vis[i][j]=true;
	int dp[h][w],pp,qq;
	memset(dp,0,sizeof(dp));
	
	while(!q.empty())
	{
	
		pp=q.front().first,qq=q.front().second;
		q.pop();
		
		if(pp+1<h && arr[pp+1][qq]!='#' && !vis[pp+1][qq])
		{
			vis[pp+1][qq]=true;
			dp[pp+1][qq]=dp[pp][qq]+1;
			q.push(make_pair(pp+1,qq));
			
		}
		if(qq+1<w && arr[pp][qq+1]!='#' && !vis[pp][qq+1])
		{
			vis[pp][qq+1]=true;
			dp[pp][qq+1]=dp[pp][qq]+1;
			q.push(make_pair(pp,qq+1));
		}
		if(pp-1>=0 && arr[pp-1][qq]!='#' && !vis[pp-1][qq])
		{
			vis[pp-1][qq]=true;
			dp[pp-1][qq]=dp[pp][qq]+1;
			q.push(make_pair(pp-1,qq));
		}
		if(qq-1>=0 && arr[pp][qq-1]!='#' && !vis[pp][qq-1])
		{
			vis[pp][qq-1]=true;
			dp[pp][qq-1]=dp[pp][qq]+1;
			q.push(make_pair(pp,qq-1));
		}
	}
	return dp[x][y];
}


int main()
{
	
	
	
	
	cin>>h>>w;	
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>arr[i][j];
		}
	}
	vector<pair<int,int> > ans;
	
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(arr[i][j]=='.')
			{
				ans.push_back(make_pair(i,j));
			}
		}
	}
	
	
	
	int maxi=INT_MIN;
	
	for(int i=0;i<ans.size();i++)
	{
		for(int j=0;j<ans.size();j++)
		{
			maxi=max(maxi,solve(ans[i].first,ans[i].second,ans[j].first,ans[j].second));
		}
	}
	cout<<maxi<<endl;

	
	
	
	
	
}

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

fn main() {
    let input = read_input();
    
    let data = input.split_whitespace().map(
        |x| {
            match x.parse::<u32>() {
                Ok(v) => v,
                Err(_) => 0,
            }
        }
    ).collect::<Vec<u32>>();
    
    let detoxify = data[0] + data[1];
    let poison = data[2];
    
    let answer = if poison <= 1 + detoxify {
        // 全部の毒クッキーを食べられる。
        data[1] + poison
    } else {
        // 全部の毒クッキーは食べられない。
        detoxify + 1 + data[1]
    };
    
    println!("{}", answer);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct FPT{
	int n;
	static const int MAX=3005;
	static const int DMAX=50;
	vector<int> G[MAX];
	bool used[MAX];
	bool flag=false;
	vector<int> vec[DMAX];

	void restore(int v){
		used[v]=false;
		for(int i=0;i<G[v].size();i++){
			int nv=G[v][i];
			G[nv].push_back(v);
		}
	}

	void remove(int v){
		used[v]=true;
		for(int i=0;i<G[v].size();i++){
			int nv=G[v][i];
			for(int j=0;j<G[nv].size();j++){
				if(G[nv][j]==v){
					G[nv][j]=G[nv].back();
					G[nv].pop_back();
					break;
				}
			}
		}
	}

	vector<int> branchcut(int& k,int dep){
		vector<int> ret;
		while(k>0){
			bool update=false;
			for(int j=0;j<vec[dep].size();j++){
				int v=vec[dep][j];
				if(update || used[v] || G[v].size()<=k)continue;
				k--;
				remove(v);
				ret.push_back(v);
				update=true;
			}
			if(!update)break;
		}
		return ret;
	}
	bool isok(int k,int dep){
		int edgerest=0;
		priority_queue<int,vector<int>,greater<int> > que;
		for(int i=0;i<vec[dep].size();i++){
			int v=vec[dep][i];
			if(!used[v]){
				edgerest+=G[v].size();
				que.push((int)G[v].size());
				if(que.size()>k)que.pop();
			}
		}		
		edgerest/=2;
		int canuse=0,maxdeg=0;
		while(que.size()){
			int q=que.top();
			que.pop();
			canuse+=q;
			maxdeg=q;
		}
		if(edgerest>k*maxdeg || edgerest>canuse)return false;
		return true;
	}

	void seeyou(vector<int>& bra){
		for(int i=0;i<bra.size();i++){
			restore(bra[i]);
		}
	}

	void getvec(int dep){
		if(dep>0){
			vec[dep].clear();
			for(int i=0;i<vec[dep-1].size();i++){
				int v=vec[dep-1][i];
				if(!used[v] && G[v].size()>0){
					vec[dep].push_back(v);
				}
			}
		}
	}

	void dfs(int k,int dep){
		if(flag)return;
		getvec(dep);
		if(vec[dep].size()==0){
			flag=true;
			return;
		}
		vector<int> bra=branchcut(k,dep);
		if(!isok(k,dep)){
			seeyou(bra);
			return;
		}
		int v=-1;
		for(int i=0;i<vec[dep].size();i++){
			if(!used[vec[dep][i]] && G[vec[dep][i]].size()>0){
				if(v==-1)v=vec[dep][i];
				else if(G[vec[dep][i]].size()>G[v].size())v=vec[dep][i];
			}
		}
		vector<int> tmp;
		for(int i=0;i<G[v].size();i++){
			int nv=G[v][i];
			tmp.push_back(nv);
			remove(nv);
		}
		dfs(k-tmp.size(),dep+1);
		for(int i=0;i<tmp.size();i++){
			restore(tmp[i]);
		}
		if(G[v].size()>1){
			remove(v);
			dfs(k-1,dep+1);
			restore(v);
		}
		seeyou(bra);
	}

	// check you can cover all edges by at most k nodes
	bool build(int k){
		flag=false;
		vec[0].clear();
		for(int i=0;i<n;i++){
			vec[0].push_back(i);
		}
		dfs(k,0);
		return flag;
	}
};

FPT fpt;
int a[30005],b[30005];

int main(void){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]--;
		b[i]--;
	}
	fpt.n=n;
	int l=0,r=k+1;
	while(l+1<r){
		int mid=(l+r)/2;
		for(int j=0;j<n;j++){
			fpt.G[j].clear();
		}
		for(int j=0;j<m;j++){
			fpt.G[a[j]].push_back(b[j]);
			fpt.G[b[j]].push_back(a[j]);
		}
		memset(fpt.used,0,sizeof(fpt.used));
		if(fpt.build(mid)){
			r=mid;
		}else{
			l=mid;
		}
	}
	if(r==(k+1))printf("Impossible\n");
	else printf("%d\n",r);
	return 0;
}


Measured memory_bytes: 3888
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] xDifference = new int[n];
		// 整数nの数だけ標準入力
		for(int i = 0; i < n; i++) {
			xDifference[i] = Math.abs(x - sc.nextInt());
		}
		Arrays.sort(xDifference);
		// 整数xとの最小差との剰余が0であるか
		for(int i = 0; i < n; i++) {
			if(xDifference[i] % xDifference[0] != 0) {
				while(true) {
					xDifference[0] = xDifference[0] - 1;
					if(xDifference[i] % xDifference[0] == 0) {
						break;
					}
				}
			}
		}
		System.out.println(xDifference[0]);
		sc.close();
	}
}

Measured memory_bytes: 47912
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    cunt1=0
    cunt2=0
    for ss in s:
        if ss=='1':cunt1+=1
        else:cunt2+=1
    print(min(cunt1,cunt2)*2)

if __name__=='__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int main() {
  int n;
  cin >> n;
  cout << n / 2 + n % 2 << endl;
}

Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<algorithm>

using namespace std;

typedef long long ll;

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	if (K == 0) return !printf("%lld\n", (ll)N*N);
	ll ans = 0;
	for (int i = K+1; i <= N; i++) {
		int p = N % i;
		ans += N / i * (i - K) + max(0, p-K+1);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
lista=[]
t=0
ch=0
e=0
d=0
tflag=1
while True:
    try:
        lista.append(list(map(int,input().split())))
    except:
        break;

def func01(a,b,c):
    global t
    global ch
    global e
    global d
    global tflag
    if a+b>c:
        t+=1
        if a**2+b**2==c**2:
            ch+=1
        elif a**2+b**2>c**2:
            e+=1
        elif a**2+b**2<c**2:
            d+=1
    else:
        tflag=0
        
i=0
for i in range(len(lista)):
    if len(lista)==i:
        break
    x=sorted(lista[i])
    func01(x[0],x[1],x[2])
    if tflag==0:
        break
    i+=1
print(t,ch,e,d)


Measured memory_bytes: 5608
N = input()

if N[len(N)-1] == "2" or  N[len(N)-1] == "4" or N[len(N)-1] == "5" or N[len(N)-1] == "7" or N[len(N)-1] == "9":
    print("hon")
elif N[len(N)-1] == "0" or  N[len(N)-1] == "1" or N[len(N)-1] == "6" or N[len(N)-1] == "8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9136
#include<stdio.h>

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

int main(void) {
    int i, j;
    int v = 0, n = 0;
    int a[1000];

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

    printresult(n, a);

    for(i = 1; i < n; i++) {
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        printresult(n, a);
    }
}



Measured memory_bytes: 2112
fun main() {
    val l = readLine()!!.split(' ').map { it.toInt() }
    var k = l[3]
    var max = 0
    if (k < l[0]) {
        max = k
    } else {
        max = l[0]
        k -= l[0]
        if (k > l[1]) {
            k -= l[1]
            max -= k
        }
    }
    println(max)
}


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

int main() {

  int N,H;
  cin >> N >> H;

  vector<int> a(N),b(N);
  for(int i = 0 ;i < N;i++) {
    cin >> a.at(i) >> b.at(i);
  }

  sort(a.begin(),a.end());
  sort(b.begin(),b.end(),greater<int>());

  int A = a.at(N-1),ans = 0;
  for(int i = 0;i < N;i++) {
    if(b.at(i) < A) break;
    H -= b.at(i);
    ans++;
    if(H <= 0) {
      cout << ans << endl;
      return 0;
    }
  }

  ans += (H + A -1) / A;
  cout << ans << endl;


}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF (1<<30)
#define LINF (1ll<<60ll)
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload4(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload4(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
#define d(a) cerr<<#a<<":"<<a<<endl
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl


int main(){
    int n,m;
    set<pair<int, P>> pref;
    cin>>n>>m;
    char out[m][13];
    REP(i,m){
        int p,y;
        cin>>p>>y;
        pref.insert({p,make_pair(y,i)});
    }
    int x;
    int b=0;
    for (pair<int, P> p : pref)
    {
        if(p.first!=b){
            x=1;
            b=p.first;
        }
        sprintf(out[p.second.second],"%06d%06d",p.first,x);
        x++;
    }
    REP(i,m){
        cout<<out[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define deb(x) cerr << #x" = "<<x <<endl;
using namespace std;
const int maxn=2020;

int n;
int siz[maxn],son[maxn];
int fa[maxn],top[maxn];
int a[maxn],dep[maxn];
vector<int>G[maxn];
vector<int>member[maxn];
int topdeg[maxn];
void dfs(int u){
	siz[u]=1;
	for(auto v:G[u]){
		dep[v]=dep[u]+1;
		dfs(v);
		siz[u]+=siz[v];
		if(siz[v]>siz[son[u]])
			son[u]=v;
	}
}
void build(int u,int tp){
	top[u]=tp;
	member[top[u]].push_back(u);
	if(son[u])build(son[u],tp);
	for(auto v:G[u])if(v!=son[u]){
		build(v,v);
		//topdeg[son[u]]++;
		topdeg[top[u]]++;
	}
}



vector<int>Oper;
void rot(int v){

//	cerr<<"rot "<<v<<endl;
	vector<int>path;
	int u=v;
	while(u){
		path.push_back(u);
		//cerr<<"path "<<u<<endl;
		u=fa[u];
	}
	static int b[maxn];
	for(int i=0;i<path.size();i++)
		b[i]=a[path[i]];
	for(int i=0;i<path.size();i++)
		a[path[i]]=b[(i+path.size()-1)%path.size()];


	Oper.push_back(v);
}

int hole[maxn],done[maxn],ind[maxn];
vector<int>cur[maxn];
bool bydep(int x,int y){
	return dep[x] != dep[y]  ? dep[x]<dep[y] : x<y;
}

struct cmp{
	bool operator()(int x,int y)const{return bydep(x,y);}	
};
set<int,cmp>bc;
void insert(int x){
	int tp=top[x];
	int t=cur[tp].size();
	for(int i=0;i<cur[tp].size();i++){
		if(ind[cur[tp][i]]>ind[x]){
			t=i;
			break;
		}
	}
	int pos=(int)member[tp].size()-1-cur[tp].size()+t;
	rot(member[tp][pos]);

	int y=(member[tp][(int)member[tp].size()-1-cur[tp].size()]);
	if(bc.count(y))bc.erase(y);
	cur[tp].insert(cur[tp].begin()+t,x);
}


void work(){
	int t=n;

	memset(hole,0,sizeof hole);
	bc.clear();
	int cnt=0,holes=0;

	for(int i=1;i<=n;i++)if(top[i]==i&&!done[i]){
		if(topdeg[i]==0){
			topdeg[top[fa[i]]]--;
			for(auto v:member[top[i]]){
				hole[v]=1;
				holes++;
				//cerr<<"hole "<<v<<endl;
			}
		}
	}
	
	for(int i=1;i<=n;i++)if(!done[i]){
		bc.insert(i);
	}
	

	while(cnt<holes){
//		cerr<<"a[1] = "<<a[1]<<endl;

//		for(auto x: bc)cerr<<x<<",";cerr<<endl;
		if(hole[a[1]]){
			cnt++;
			done[a[1]]=1;
			insert(a[1]);
		}else{
			rot(*bc.rbegin());	
			bc.erase(*bc.rbegin());
		}
	}
}

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

	static int per[maxn];
	for(int i=1;i<=n;i++)per[i]=i-1;random_shuffle(per+1,per+1+n);


	for(int i=2;i<=n;i++){
		scanf("%d",&fa[i]);
		fa[i]++;
		G[fa[i]].push_back(i);
	}


	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]++;
	}
	dfs(1);
	build(1,1);
	for(int i=1;i<=n;i++){
		for(int j=0;j<member[i].size();j++)
			ind[member[i][j]]=j;
	}


	while(1){
		int ok=1;
		for(int i=1;i<=n;i++)if(a[i]!=i){
			ok=0;
			break;
		}
		if(ok)break;

		work();

	//	break;//TODO
	}

	cout<<Oper.size()<<endl;
	for(auto x:Oper)
		printf("%d\n",x-1);

	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int t,n;
    REP(i,4){
        cin >> t >> n;
        if(t==1)cout << n*6000 << endl;
        else if(t==2)cout << n*4000 << endl;
        else if(t==3)cout << 3000*n<< endl;
        else cout << 2000*n << endl;
    }
}



Measured memory_bytes: 3092
#include <stdio.h>
 
int main(void) {
  int n,k,m,i,j,ans;
  if(scanf("%d %d", &n, &k)==1);
  int num[n],s[n];
  for (i=0; i<n; ++i) {
    if(scanf("%d", &num[i])==1);
  }
  for(i=0; i<n; i++){
    for(j=i+1; j<n; j++){
      if(num[i] > num[j]){
        m = num[i];
        num[i] = num[j];
        num[j] = m;
      }
    }
  }
  ans=0;
  for (i=0; i<k; ++i) {
    ans+=num[i];
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1684
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)170 * 80;


int main(void) {
   string S;
   cin>>S;
   ll a[2] = {};
   rep(i,0,S.size()) {
      if (S[i]=='o') a[0]++;
      else a[1]++;
   }
   // cout<<a[0]<<" "<<a[1]<<endl;
   if (a[0] + (15-a[1]-a[0]) >= 8) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;

   


   return 0;
}

Measured memory_bytes: 256
a = map(int, raw_input().split())

if a[0] == 1 :
    a[0] = 14
if a[1] == 1 :
    a[1] = 14

if a[0] == a[1] :
    print 'Draw'
elif a[0] > a[1] :
    print 'Alice'
else :
    print 'Bob'

Measured memory_bytes: 2568
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int a[100000];
signed main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;){
		int j=i;
		while(j<n&&a[i]==a[j]){
			j++;
		}
		int sum=j-i;
		if(a[i]<=sum){
			ans+=sum-a[i];
		}
		else{
			ans+=sum;
		}
		i=j;
	}
	cout<<ans<<endl;
}


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

int main() {
  double L;
  cin >> L;
  cout << fixed << setprecision(10);
  cout << pow(L, 3) / 27 << endl;
  return 0;
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int M, T, P, R;
    while (cin >> M >> T >> P >> R, M|T|P|R) {
        vector<pair<pii, int>> score(T);
        REP(i, T) {
            score[i] = {{0, 0}, i+1};
        }

        vvi penalty(T, vi(P));
        REP(i, R) {
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            t--;
            p--;
            if (j == 0) {
                score[t].first.first++;
                score[t].first.second -= m + 20 * penalty[t][p];
            } else {
                penalty[t][p]++;
            }
        }

        RSORT(score);
        printf("%d", score[0].second);
        FOR(i, 1, SZ(score)) {
            if (score[i-1].first.first == score[i].first.first &&
                score[i-1].first.second == score[i].first.second) {
                printf("=");
            } else {
                printf(",");
            }
            printf("%d", score[i].second);
        }
        printf("\n");
    }
}

Measured memory_bytes: 3268
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		Array.Sort(nums);
		int changedCount = 0;
		long answer = 0;

		long[][] vertexes = new long[m][];//数字と個数
    for(long i = 0; i < m; i++)
    {
      long[] numsa = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
			vertexes[i] = new long[2];
      vertexes[i][0] = numsa[1];
      vertexes[i][1] = numsa[0];
    }
		Array.Sort(vertexes, (a, b) => b[0].CompareTo(a[0]));

		for(int i = 0; i < m; i++)
		{
			for(int j = 0; j < vertexes[i][1]; j++)
			{
				if(changedCount == n) break;
				
				if(vertexes[i][0] > nums[changedCount])
				{
					nums[changedCount] = vertexes[i][0];
					changedCount++;
				}else break;
			}
		}

		for(int i = 0; i < n; i++)
		{
			//Console.WriteLine(answer);
			answer += nums[i];
		}
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 32460
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n = int(input())
p = make_divisors(n)
ans = 1000000

for i in range((len(p)+1)//2):
    x = p[i]
    y = p[-1-i]
    z = max(len(str(x)),len(str(y)))
    if z < ans:
        ans = z

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
	int n, h;
	cin >> n >> h;
	int a, b[100001] = {};
	int ma = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b[i];
		ma = max(ma, a);
	}
	sort(b, b + n, greater<int>());
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		if (b[i] > ma && h > 0) {
			h -= b[i];
			ans++;
		}
	}
	if (h > 0) ans += (h + ma - 1) / ma;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
n = int(input())
if n%2 == 0:
    print(n*(n-1)//2 - n//2)
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if i + j != n+1:
                print(i,j)
else:
    print(n*(n-1)//2 - (n-1)//2)
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if i + j != n:
                print(i,j)

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

using namespace std;

int n;
double a[100];

void Process()
{
    sort(a + 1, a + n + 1);

    for (int i=2; i<=n; i++)
        a[i] = (double) (a[i] + a[i-1]) / 2;

    cout << setprecision(10) << fixed << a[n];
}

void Input()
{
    ios_base::sync_with_stdio(0);   cin.tie(0);

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

int main()
{
    Input();
    Process();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
    string s;
    int b;
    cin>>s;
    int k=0;
    for (int i=0; i<s.length(); ++i)
        if (s[i]=='C'&& k==0){
            ++k; b=i;
            break;
        }
    for (int i=b; i<s.length(); ++i)
        if (s[i]=='F'&& k==1){
            ++k;
            break;
        }
        if (k==2) printf("Yes\n");
        else
        printf("No\n");     
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll l; cin>>l;
	double d=(double)l/3;
	printf("%0.12f\n",(d*d*d));
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
N, M = map(int, input().split())


class WeightedUnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.diff_weight = [0 for i in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            root = self.find(self.par[x])
            self.diff_weight[x] += self.diff_weight[self.par[x]]
            self.par[x] = root
            return root

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

    def union(self, x, y, w):
        w += self.weight(x)
        w -= self.weight(y)
        x = self.find(x)
        y = self.find(y)
        if x != y:
            self.par[y] = x
            self.diff_weight[y] = w

    def weight(self, x):
        self.find(x)
        return self.diff_weight[x]

    def diff(self, x, y):
        return self.weight(y) - self.weight(x)


uf = WeightedUnionFind(N)
ans = 'Yes'
for _ in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    if uf.is_same(L, R):
        if uf.diff(L, R) != D:
            ans = 'No'
            break
    else:
        uf.union(L, R, D)
print(ans)

Measured memory_bytes: 9128
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), L = sc.nextInt();
		Map<Integer, Integer> map = new TreeMap<>();
		int sum = 0;
		for(int i = 1; i <= N; i++) {
			sum += L+i-1;
			map.put(Math.abs(L+i-1),i);
		}
		int le = 0;
		for(Map.Entry<Integer, Integer> entry : map.entrySet()) {
			le = entry.getValue();
			break;
		}
		sum -= L+le-1;
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        String ans = "NG";
        for (int i = a; i < b + 1; i++) {
            if (i % k == 0) {
                ans = "OK";
                break;
            }
        }

        System.out.println(ans);
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    double R;
    cin >> R;
    cout << 2.0 * M_PI * R << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3784
# @author 

import sys

class BUnevenNumbers:
    def solve(self):
        n = int(input())
        ans = 0
        for i in range(1, n + 1):
            if len(str(i)) % 2 == 1:
                ans += 1
        
        print(ans)
                

solver = BUnevenNumbers()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 39792
#include "bits/stdc++.h"
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
#define rep(i, n) for(int i=0;i<(n);i++)
int n;
double x, y;

xy_t P[110];
int main() {
	cin >> n;
	rep(i,n) { 
		cin >> x >> y;
		P[i] = xy_t(x, y);
	}

	double sum = 0.0;
	for (int i = 0; i + 2 < n; i++) {
		xy_t a = P[0], b = P[i + 1], c = P[i + 2];
		sum += cross_product(b - a, c - a) / 2;
	}
	printf("%.1f\n", abs(sum));
}



Measured memory_bytes: 3276
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
    static const double pi = 3.141592653589793238;
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double zi,hun;
    zi = (pi*(h+(m/60)))/6;
    hun = (m*pi)/30;
    double rad = zi-hun;
    if(rad>pi){
        rad = 2*pi - rad; 
    }
    double ans;
    ans = (a*a)+(b*b)-2*a*b*cos(rad);
    double c = sqrt(ans);
    printf("%.10f",c);
    return 0;
}

Measured memory_bytes: 4124
main = do
  s <- readLn
  print $ f s [] 1
f x y z
  | x `elem` y = z
  | x `mod` 2 == 0 = f (x `div` 2) (y++[x]) (z+1)
  | otherwise = f (3*x+1) (y++[x]) (z+1)

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A,B,H,M;
    cin >> A >> B >> H >> M;
   
    float deg;
    deg = 6*M - (30*H + 0.5*M);

    double power_len,ans;
    power_len = A*A + B*B - 2 * A * B * cos(M_PI*((double)deg/180.0));
    
    ans = sqrt(power_len);

    printf("%.10f",ans);
    return 0;
}


Measured memory_bytes: 4180
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
   
    /////////////////////
    // Write code below /
    /////////////////////
    int numberOfCards;
    cin >> numberOfCards;
    vector<int> cardNumbers(numberOfCards);
    
    for (int card_i = 0; card_i < numberOfCards; card_i++) {
        cin >> cardNumbers.at(card_i);
    }
    
    sort(cardNumbers.begin(), cardNumbers.end());       // 昇順にソート
    reverse(cardNumbers.begin(), cardNumbers.end());    // 降順に変更
    
    int difference = 0;
    int sign = 1;
    for (int card_i = 0; card_i < numberOfCards; card_i++) {
        difference += sign * cardNumbers.at(card_i);
        sign *= -1;
    }
    
    cout << difference << endl;
    
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8


def run():
    N = int(input())
    S_ = []

    for i in range(N):
        s = input()
        s = [ord(ss)-96 for ss in s] * 2
        S_.append(s)

    #for s in S_:
    #    print(s)
    S = []
    for s in S_:
        S.append(s)
    for s in S_:
        S.append(s)

    #for s in S:
    #    print(s)


    axises = [(i, 0) for i in range(N)]
    for i in range(1, N):
        axises.append((0, i))

    ans = 0

    #print(axises)
    for axis in axises:
        ci, cj = axis
        done = False
        for i in range(N):
            if done:break
            for j in range(i, N):
                if S[ci+i][cj+j] == S[ci+j][cj+i]:continue
                else:
                    #print((ci, cj), (i, j))
                    done=True
                    break
        if not done:
            ans += min(N-ci, N-cj)


    print(ans)

if __name__ == "__main__":
    run()


Measured memory_bytes: 75344
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int N, K;
  cin >> N >> K;
  int A[N];
  rep(i,N) cin >> A[i];
  sort(A, A+N);

  COMinit();

  int ans = 0;
  for(int i=0;i<N;i++){
    ans += COM(i, K-1) * A[i];
    ans %= MOD;
  }
  for(int i=0;i<N;i++){
    ans += MOD;
    int W = (COM(N-i-1, K-1) * A[i]);
    W %= MOD;
    ans -= W;
    ans %= MOD;
  }

  cout << ans << endl;

}

Measured memory_bytes: 13056
#include <iostream>
#include <cassert>
#include <string>
#include <map>
using namespace std;

map<string,int> list;
string S;
size_t cur=0;
bool flag=true;

int digit();
int number();
string letter();
int atom();
int molecule();

int digit(){
	assert(isdigit(S[cur])); 
	int n = S[cur] - '0'; 
	cur++; 
	return n;
}

int number(){
	int n=digit();
	if(cur <S.size() && isdigit(S[cur]))
		n=n*10+digit();
	return n;
}

string letter(){
	string n;
	n=S[cur];
	cur++;
	return n;
}

int atom(){
	string a = letter();
	if(cur <S.size() &&islower(S[cur]))
		a+=letter();
	int at=0;
	if(list.find(a) == list.end())
		flag=false;
	else
		at=list[a];
	return at;
}


int molecule(){
	int mol=0;
	if(S[cur]=='('){
		cur++;
		int tmp=molecule();
		cur++;
		int num=number();
		mol+=(tmp*num);
	}else if(cur <S.size() &&isupper(S[cur])){
		int tmp=atom();
		int num=1;
		if(cur <S.size() && isdigit(S[cur]))
			num=number();
		mol+=(tmp*num);
	}
	if( cur <S.size()&&S[cur] != ')')
		mol+=molecule();
	return mol;
}


int main(void){
	string sin;
	int iin;
	while(cin >> sin, sin !="END_OF_FIRST_PART"){
		cin >> iin;
		list[sin]=iin;
	}
	while(cin >> S,S != "0"){
		flag=true;
		cur=0;
		int r;
		r=molecule();
		if(flag)
			cout << r << endl;
		else 
			cout << "UNKNOWN" << endl;
	}
return 0;
}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> vh(n);
  for (int i = 0; i < n; ++i) {
    cin >> vh[i];
  }

  ll l = 1, r = pow(10, 9) + 1;
  while (l != r) {
    ll mid = (r + l) / 2;
    ll m = mid;
    for (int i = 0; i < n && m >= 0; ++i) {
      ll hp = vh[i] - mid * b;
      m -= max(0ll, hp / (a - b) + (hp % (a - b) > 0));
    }

    if (m < 0) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }

  cout << r << '\n';
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s[0]==s[1] && s[1]==s[2] && s[0]=='R') {
    cout << 3 << '\n';
  } else if(s[0]==s[1] && s[0]=='R') {
    cout << 2 << '\n';
  } else if(s[1]==s[2] && s[1]=='R') {
    cout << 2 << '\n';
  } else if(s[0]=='R' || s[1]=='R' || s[2]=='R') {
    cout << 1 << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_A
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();
		// 出力
		int times = (N-1)/ X + 1;
		System.out.println(times * T);
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


Measured memory_bytes: 35664