akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using i64 = long long;

std::vector<std::string> three {
    "aa.",
    "..b",
    "..b"
}, three2 {
    "xxy",
    "z.y",
    "zww"
}, four {
    "abhh",
    "abgg",
    "ccef",
    "ddef"
}, five {
    "aggff",
    "axx.e",
    "b..ye",
    "b..yd",
    "cchhd"
}, seven {
    "abbcc..",
    "ad...gg",
    "ed..zz.",
    "e..hh.y",
    "ffii..y",
    "..q..rx",
    "..q..rx"
};

int main() {
    int n;
    std::cin >> n;

    std::vector<std::string> v(n, std::string(n, '.'));

    if (n == 2) {
        std::cout << -1 << std::endl;
        return 0;
    } else if (n == 3 || n == 6) {
        for (int i = 0; i < n / 3; i++) {
            for (int j = 0; j < 3; j++) for (int k = 0; k < 3; k++) {
                v[i * 3 + j][i * 3 + k] = three[j][k];
            }
        }
    } else if (n == 7) {
        v = seven;
    } else if (n == 11) {
        for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) {
            v[i][j] = five[i][j];
        }
        for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) {
            v[5 + i][5 + j] = v[8 + i][8 + j] = three[i][j];
            v[8 + i][5 + j] = v[5 + i][8 + j] = three2[i][j];
        }
    } else {
        int x = 0;
        while ((n - 4 * x) % 5) x++;
        int y = (n - 4 * x) / 5;

        for (int i = 0; i < x; i++) {
            for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k++) {
                v[4 * i + j][4 * i + k] = four[j][k];
            }
        }
        int base = 4 * x;
        for (int i = 0; i < y; i++) {
            for (int j = 0; j < 5; j++) for (int k = 0; k < 5; k++) {
                v[base + 5 * i + j][base + 5 * i + k] = five[j][k];
            }
        }
    }

    for (auto &e : v) std::cout << e << std::endl;

    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <algorithm>
#include<iostream>
#include <stdio.h>
#define INF 9e19
const int maxn=1e5+5;
using namespace std;
typedef long long ll;


int main(){
    int t;
    cin>>t;
    if(t==1)
        cout<<0<<endl;
    if(t==0)
        cout<<1<<endl;
    
}


Measured memory_bytes: 3628
import sys
if __name__ == "__main__":
    N = int(input())
    S = input()
    max = 0
    for i in range(1, N):
        s1 = S[0:i]
        s2 = S[i:N+1]
        buf = list(set(s1))
        buf2 = list(set(s2))
#        print(s1)
#        print(buf)
#        print(buf2)
        cnt = 0
        for i in range(len(buf)):
            if buf[i] in buf2:
                cnt += 1
#        print(cnt)
        if cnt > max:
            max = cnt
    print(max)

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author https://github.com/rishabhdeepsingh/competitive
 */

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma GCC target("popcnt")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           int((x).size())
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template<typename T> int sgn(T val) { return (T(0) < val) - (val < T(0));}
template<typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T> T gcd(T x, T y) { return (y == T(0)) ? x : gcd(y, x % y); }
// @formatter:on


class ERedScarf {
public:
  
  void solveOne(istream& cin, ostream& cout) {
  
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for (auto& _a : a) cin >> _a;
    ll allXor = 0;
    for (int x: a) allXor ^= x;
    for (int x: a) {
      allXor ^= x;
      cout << allXor << " ";
      allXor ^= x;
    }
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	ERedScarf solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4012
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
//回答が整数の場合
int ans;
//整数値の入力
string n;
cin >> n;

int len=(int)(n.length());
int zero=0;
int ichi=0;
for(int i=0;i<len;i++){
  if(n[i]=='0'){zero++;}
  if(n[i]=='1'){ichi++;}

}

if(zero>ichi){ans=ichi*2;}
else{ans=zero*2;}

//回答
cout << ans << endl;
return 0;
}



Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
money = 1000
kabu = 0
for i in range(N):
    if i==N-1 or A[i] > A[i+1]:
        money += kabu*A[i]
        kabu = 0
    elif A[i] < A[i+1]:
        kabu += money//A[i]
        money %= A[i]
print(money)

Measured memory_bytes: 61728
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
map<int,int> wh;
int main(){
    int n,m; cin >> n >> m;
    int p[n];
    UnionFind UF(n);
    REP(i,n){
        cin >> p[i]; p[i]--;
        wh[p[i]] = i;
    }
    REP(i,m){
        int x,y; cin >> x >> y; x--; y--;
        UF.unionSet(x,y);
    }
    int ans = 0;
    REP(i,n){
        if(UF.findSet(i, wh[i])) ans++;
    }
    cout << ans << endl;



}

Measured memory_bytes: 5760
#ビット全探索する
# 各数字を使うか使わないか

n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
m = gets.split.map(&:to_i)

#aの要素で作れる和2^n個を全列挙する
def calc_sum(a)
  n = a.length
  memo = []
  0.upto((1 << n)-1) do |bit|
   #puts bit.to_s(2).rjust(n,"0")
     memo << (a.map.with_index { |item, i|
       item * ((bit>>i)&1)
     }.inject(:+))
  end
  return memo
end

memo = calc_sum(a)

m.each do |item|
  if memo.include?(item)
    puts "yes"
  else
    puts "no"
  end
end


Measured memory_bytes: 16208
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll r = 0;
	if (a >= k)
	{
		r = k;
		printf("%lld", r);
		return 0;
	}

	r = a;
	k -= a;

	if (b >= k)
	{
		printf("%lld", r);
		return 0;
	}

	k -= b;
	r -= k;
	printf("%lld", r);
	return 0;
}

Measured memory_bytes: 3288
S = input()
count = 0
exist = [0]*2019
flg = False
N = len(S)
sum = 0
for i, s in enumerate(reversed(S)):
    sum += (int(s) * pow(10, i, 2019)) % 2019
    exist[sum % 2019] += 1
for e in exist:
    if e > 1:
        count += e*(e-1)//2
count += exist[0]
print(count)


Measured memory_bytes: 68120
#include <iostream>

using namespace std;

int main()
{
    int c=0, n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                c++;
            }
        }
    }
    cout<<c;
    return 0;
}


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

int main()
{
    int i,j,n1,n2,max;

    char str1[300],str2[300],ch[300];

    gets(str1);
    gets(str2);

    n1 = strlen(str1);
    n2 = strlen(str2);
    if(n1>=n2){
        max = n1;
    }
    else{
        max = n2;
    }

    if(!strcmp(str1,str2)){
        printf("Yes\n");
        return 0;
    }
    else if(n1!=n2){
        printf("No\n");
        return 0;
    }

    for(i = 0; i < max;i++){
        ch[0] = str1[max-1];
        for(j = 0;j < max-1;j++){
            ch[j+1] = str1[j];
        }
        ch[j+1]='\0';
        if(!strcmp(str2,ch)){
            printf("Yes\n");
            return 0;
        }
        else{
            strcpy(str1,ch);
        }
    }

    printf("No\n");

    return 0;
}


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

int main(){
	int n,i,pt=0,ph=0;
	char ct[101],ch[101];
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%s %s",&ct,&ch);
		if (strcmp(ct,ch)>0){
			pt+=3;
		}else if (strcmp(ct,ch)<0){
			ph+=3;
		}else{
			pt++;ph++;
		}
	}
	printf("%d %d\n",pt,ph);
	return 0;
}	

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int k;
	cin >> k;

	long long a = 7;

	rep(i, k){
		if(i != 0) a = a * 10 + 7;

		if(a % k == 0){
			cout << i + 1;
			return 0;
		}

		a %= k;
	}

	cout << -1;
	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int s[500000*4+1];
string tar;
void build (int id, int l, int r){
    if (l==r){
        s[id]|=(1<<(tar[l]-'a'));
        return;
    }
    int mid=l+(r-l)/2;
    build (id*2, l, mid);
    build (id*2+1, mid+1, r);
    s[id]=(s[id*2]|s[id*2+1]);
}
void update (int id, int l, int r, int pos, char val){ // REMEMBER: update only to follow one chain
    if (l==r){ //the bottomost nodes of the segment tree
        s[id]=0;
        s[id]|=(1<<(val-'a'));
        return;
    }
    int mid=l+(r-l)/2;
    if (pos<=mid) update (id*2, l, mid, pos, val);
    else update (id*2+1, mid+1, r, pos, val);
    s[id]=(s[id*2]|s[id*2+1]);
}
int query (int id, int l, int r, int L, int R){
    if (L<=l && r<=R) return s[id];
    // above is completely in range case. REMEMBER: query is dividing segment trees parts into different queries
    if (R<l || r<L) return 0;
    //above is completely out of range case. REMEMBER: return something not affecting the result
    int mid=l+(r-l)/2;
    return query (id*2, l, mid, L, R) | query (id*2+1, mid+1, r, L, R);
    //above is partially in range case.
}
int main(){
  	ios::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    int a, q, val, pos, ql, qr;
    char change;
    cin>>a>>tar>>q;
    build (1, 0, a-1);
    for (int t=0; t<q; t++){
        cin>>val;
        if (val==1){
            cin>>pos>>change;
            update(1, 0, a-1, pos-1, change);
        }
        else {
            cin>>ql>>qr;
            cout<<__builtin_popcount(query(1, 0, a-1, ql-1, qr-1))<<endl;
        }
    }
}


Measured memory_bytes: 7068
#include<stdio.h>

int main(void){

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(W-x>=r&&x>=r&&H-y>=r&&y>=r){

printf("Yes\n");

}

else{

printf("No\n");

}

return 0;

}

Measured memory_bytes: 584
#include<iostream>
#include<string>
#include<sstream>
using namespace std;

int main(){
  int a, b, count = 0;
  //stringstream ss;
  string s;
  cin >> a;
  cin >> b;
  for(int i=a;i<=b;i++){
    stringstream ss;
    ss << i;
    s = ss.str();
    if(s[0]==s[4] && s[1]==s[3]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int age, fare = 0;
    cin >> age >> fare;
    if(age>=13){
        cout << fare;
    }else if(6<=age and age <=12){
        cout << fare/2;
    }else{
        cout << 0;
    }
    
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<string> vs(n);
	for(auto& x: vs) cin >>x;
	
	char lst ='$';
	rep(i, n){
		if(lst != '$' && lst != vs[i].front()){
			puts("No"); return 0;
		}
		rep(j, n) if(i!=j) if(vs[i] == vs[j]){puts("No"); return 0;}
		lst=vs[i].back();
	}
	puts("Yes");
	return 0;
}


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

int main(){
    int num;
    string str1;

    cin >> num;
    cin >> str1;

    if(str1.length()<=num){
        cout << str1;
    }
    else{
        for (int i = 0; i < num; i++){
            cout << str1[i];
        }
        cout << "...";
    }
}


Measured memory_bytes: 3136
using System;

class Solution
{
  public static void Main(string[] args)
  {
	var input = Console.ReadLine().Split();
    var s = string.Join("", input);
    var root = Math.Floor(Math.Sqrt(int.Parse(s)));
    if ((root * root).ToString() == s) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<long long, long long> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<40)
#define MOD 1000000007

int N;
vector<P> G[1<<17];
vector<P> dp[1<<17];
vector<P> add(vector<P> seq, long long val) {
  for (P &p : seq) p._1 += val, p._2 += val;
  return seq;
}
vector<P> merge_sort(vector<P> a, vector<P> b) {
  int x = 0, y = 0;
  vector<P> ret;
  while (x < a.size() && y < b.size()) {
    if (a[x] <= b[y]) ret.pb(a[x++]);
    else ret.pb(b[y++]);
  }
  while (x < a.size()) ret.pb(a[x++]);
  while (y < b.size()) ret.pb(b[y++]);
  return ret;
}
vector<P> merge(vector<P> a, vector<P> b, long long X) {
  if (a.size() > b.size()) swap(a, b);
  if (a.empty() || b.empty()) return {};
  vector<P> seq1, seq2;
  int h = b.size()-1;
  for (P p : a) {
    long long x1 = p._1, y1 = p._2;
    while (h >= 0 && x1+b[h]._1 > X) h--;
    if (h >= 0) {
      long long y2 = b[h]._2;
      seq1.pb(P(y1, y2));
      if (y1 != y2) seq2.pb(P(y2, y1));
    }
  }
  reverse(all(seq1));
  vector<P> seq = merge_sort(seq1, seq2);
  //for (P p : seq) cout<<"("<<p._1<<","<<p._2<<"),"; cout<<"\n";
  vector<P> nseq;
  long long r = INF;
  for (P p : seq) {
    if (p._2 >= r) continue;
    r = p._2;
    nseq.pb(p);
  }
  return nseq;
}

bool f(long long X) {
  for (int x=N-1; x>=0; x--) {
    if (G[x].empty()) {
      dp[x] = { P(0, 0) };
    }
    else {
      int t1 = G[x][0]._1, t2 = G[x][1]._1;
      dp[x] = merge(add(dp[t1], G[x][0]._2), add(dp[t2], G[x][1]._2), X);
    }
  }
  //for (P p : dp[0]) if (p._1 <= X && p._2 <= X) return true;
  return !dp[0].empty();
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N-1) {
    int p, v;
    cin >> p >> v;
    p--;
    G[p].pb(P(i+1, v));
  }
  long long lo = -1, hi = INF;
  while (hi-lo > 1) {
    long long mid = (lo+hi)/2LL;
    if (f(mid)) hi = mid;
    else lo = mid;
  }
  cout << hi << "\n";
  return 0;
}


Measured memory_bytes: 37688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		if(c - a - b > 0 && (4 * a * b < (c - a - b) * (c - a - b)))
			System.out.print("Yes");
		else
			System.out.print("No");
		}
}

Measured memory_bytes: 22612
#include<cstdio>

struct union_find{
  int par[10000],rank[10000];
  union_find(int n){
    for(int i=0;i<n;i++){
      par[i] = i;
      rank[i] = 0;
    }
  }
  int find(int x){
    if(par[x]==x) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(rank[x]<rank[y]) par[x] = y;
    else{
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  bool same(int x,int y){return find(x)==find(y);}
};

int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  union_find uf(n);
  for(int i=0;i<q;i++){
    int cmd,x,y;
    scanf("%d %d %d",&cmd,&x,&y);
    if(cmd==0) uf.unite(x,y);
    else if(cmd==1){
      if(uf.same(x,y)) printf("1\n");
      else printf("0\n");
    }
  }
  return 0;
}

Measured memory_bytes: 2696
use std::io;
use std::cmp::{max,min};

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split(" ");
    let a = iter.next().unwrap().parse::<i64>().unwrap();
    let b = iter.next().unwrap().parse::<i64>().unwrap();
    let c = iter.next().unwrap().parse::<i64>().unwrap();
    let x = iter.next().unwrap().parse::<i64>().unwrap();
    let y = iter.next().unwrap().parse::<i64>().unwrap();

    if a > 2 * c {
        if b > 2 * c {
            println!("{}", 2 * max(x, y) * c);
        } else {
            println!("{}", 2 * x * c + max(0, y - x) * b);
        }
    } else if b > 2 * c {
        println!("{}", 2 * y * c + max(0, x - y) * a);
    } else if a + b > 2 * c {
        println!("{}", c * 2 * min(x, y) + if x > y {
            a * (x - y)
        } else {
            b * (y - x)
        });
    } else {
        println!("{}", a * x + b * y);
    }
}



Measured memory_bytes: 4352
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,a[100111],tot;
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)
	{
		get1(a[i]);
		tot+=a[i]&1;
	}
	if(tot&1)puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
struct abdata {
    int A; int B;
};

bool cmp(const abdata &aa, const abdata &bb) {
    return aa.B < bb.B;
}

int main() {
    cin >> n;
    vector<abdata> AB(n);
    for(int i = 0; i < n; ++i) {
        cin >> AB.at(i).A >> AB.at(i).B;
    }

    sort(AB.begin(), AB.end(), cmp);
    int now = 0;
    bool flg = true;
    for(int i = 0; i < n; ++i) {
        now += AB.at(i).A;
        if(now > AB.at(i).B) {
            flg = false;
            break;
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, m;
	cin >> n >> m;
	priority_queue<double>que;

	rep(i, n) {
		double x;
		cin >> x;
		que.push(x);
	}

	rep(i, m) {
		double now = que.top();
		que.pop();
		que.push(now / 2);
	}
	int ans = 0;
	rep(i, n) {
		double x = que.top();
		que.pop();
		int now = floor(x);
		ans += now;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1400
N,K = list(map(int,input().split()))
h = list(map(int,input().split()))

INF = float('inf')

DP = [INF]*N

DP[0] = 0

for i in range(N-1):
    for j in range(min(i+1,K)):
        DP[i+1] = min(DP[i+1],DP[i-j]+abs(h[i+1]-h[i-j]))

print(DP[N-1])

Measured memory_bytes: 55008
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef pair<int, int> p;

int d,g;
vector<p> v;

int t[10];

int dfs(int k, int c){
  if(k > 0 && k < d+1)t[k-1] = c;
  if(k == d+1){
    int ans = 0;
    int count = 0;
    int maxi = 0;
    for(int i = d-1; i >= 0; i--){
      if(t[i] == 1){
        ans += (i+1)*100*v[i].first + v[i].second;
        count += v[i].first;
      }
      else if(maxi <= i) maxi = i;
    }
    int rem = v[maxi].first;
    while(ans < g){
      if(rem){
        rem--;
        ans += (maxi+1)*100;
        count++;
      }
      else break;
    }
    if(ans >= g)return count;
    else return 1e10;
  }
  int a = dfs(k+1, 1);
  int b = dfs(k+1, 0);
//  cout << k << " " << c << " " << min(a,b) << endl;;
  return min(a,b);
}

int main(){
  cin >> d >> g;
  for(int i = 0; i < d; i++){
    int a,b;
    cin >> a >> b;
    v.push_back(p(a, b));
  }
  //sort(v.begin(), v.end());
  int ans = dfs(0,0);
  cout << ans << endl;
}


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

void update_alphabet_num(string str, vector <int> &table)//??±???????????????????????¢???????????????????????°?????°????????´??°??????
{	
	
		
	int len = str.length();
	int table_num = 0;//vector table ???????´???°
	
	for(int i = 0; i < len; i++){
		
		table_num = str[i];

		if(str[i] >= 'A' && str[i] <= 'Z'){
			table_num = str[i] + ('a' - 'A');
		}
		
		table[table_num] += 1;
	}
}
void print_answer(vector<int> table)
{
	for(int i = 'a'; i <= 'z'; i++){
		printf("%c : %d\n", i, table[i]);
	}
}
int main(void)
{
	vector<int> table(127,0);//ASCII??????????????°
	
	string str;
	
	while(getline(cin, str)){//??????????????????
	
		update_alphabet_num(str, table);
	}
	
	print_answer(table);
	
	return 0;
}

Measured memory_bytes: 3208
use std::io::{stdin, stdout, BufReader, BufRead, StdinLock, Write, BufWriter};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut br = BufReader::new(std_in.lock());
    let mut bw = BufWriter::new(std_out.lock());
    
    let n = rn::<usize>(&mut br);
    
    let mut res = 0;
    for i in 1..n+1 {
        let mut x = i;
        let mut cnt = 0;
        while x > 0 {
            cnt += 1;
            x /= 10;
        }
        res += cnt % 2;
    }
    writeln!(&mut bw, "{}", res);
}


//////////////////////////////////////////////////////////////////////////////////
#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
ll mod = 1e9 + 7;

ll modpow(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}

	return res;
}

ll modinv(ll a, ll m) {
	return modpow(a, m - 2, m);
}

ll modkaijo(ll n) {
	ll res = 1;
	while(n > 1) {
		res = (res % mod) * (n % mod);
		n--;
	}

	return res;
}

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

	ll H, W, A, B;
	cin >> H >> W >> A >> B;

	ll fact[H + W], invfact[H + W];
	fact[0] = invfact[0] = 1;
	rep(i, 1, H + W) {
		fact[i] = (fact[i - 1] * i) % mod;
		invfact[i] = modinv(fact[i], mod);
	}


		
	ll res = 0;
	rep(i, B + 1, W + 1) {
		ll h = H - A - 1, w = i - 1;
		ll tmp = fact[h + w] * invfact[h] % mod * invfact[w] % mod;
		h = A - 1, w = W - i;
		tmp *= (fact[h + w] * invfact[h] % mod * invfact[w] % mod);
		res += tmp % mod;
	}

	cout << res % mod << endl;

}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b; cin>>a>>b;
  string s; cin>>s;
  for(char c:s.substr(0,a)) if('0'>c||c>'9'){
    cout<<"No"; return 0;
  }
  if(s.substr(a,1)!="-"){
    cout<<"No"; return 0;
  }
  for(char c:s.substr(a+1,b)) if('0'>c||c>'9'){
    cout<<"No"; return 0;
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();

      int max = Math.max(a,b);

      if(a==b){
        System.out.println(a+b);
        System.exit(0);
      }
      System.out.println(max + max-1);
  }
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1
{
    class ITP1_7_A_ex
    {
        static void Main(string[] args)
        {
            int m, f, r;
            int[] inputLine;
            char result;

            // var dataSet = new List<(int m, int f, int r)>();
            // var dataSet = new (int m, int f, int r)[50];
            var dataSet = new int[50][];

            for (int i = 0; i < dataSet.Length; i++)
            {
                dataSet[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

                if (dataSet[i].All(value => value == -1))
                {
                    break;
                }
            }

            for (int i = 0; i < dataSet.Length; i++)
            {
                result = Check(dataSet[i]);
                if (result == 'Q')
                {
                    break;
                }
                Console.WriteLine(result);
            }
            Console.ReadLine();
        }

        private static char Check(int[] dataSet)
        {
            int m, f, r;
            char result;

            m = dataSet[0];
            f = dataSet[1];
            r = dataSet[2];

            if (m == -1 && f == -1 && r == -1)
            {
                result = 'Q';
            }
            else if (m == -1 || f == -1)
            {
                result = 'F';
            }
            else if (m + f >= 80)
            {
                result = 'A';
            }
            else if (m + f >= 65)
            {
                result = 'B';
            }
            else if (m + f >= 50 || r >= 50)
            {
                result = 'C';
            }
            else if (m + f >= 30)
            {
                result = 'D';
            }
            else
            {
                result = 'F';
            }
            return result;
        }
    }
}



Measured memory_bytes: 18472
N = int(input())
W = [0 for i in range(N)]
for i in range(N):
    W[i] = input()
shiritori = True
S = set(W)
if len(S) != N:
    shiritori = False


for i in range(N-1):
    length = len(W[i])
    if W[i][length-1] != W[i+1][0]:
        shiritori = False

if shiritori:
    print('Yes')
else:
    print('No')


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

using namespace std;

int main() {
	long long int N, M;
	cin >> N >> M;
	vector<vector<int>>D( N, vector<int>( N ) );
	for( size_t i = 0; i < M; i++ ) {
		long long int a, b;
		cin >> a >> b;
		a--; b--;
		D[a][b] = D[b][a] = 1;
	}
	vector<long long int>xx( N );
	for( size_t i = 0; i < N; i++ ) {
		xx[i] = i;
	}
	long long int count = 0;
	do {
		bool f = true;
		for( size_t i = 0; i < N - 1; i++ ) {
			if( !D[xx[i]][xx[i + 1]] ) {
				f = false;
				break;
			}
		}
		if( f ) {
			count++;
		}
	} while( next_permutation( xx.begin() + 1, xx.end() ) );
	cout << count << endl;
}

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

struct SHOPINFO
{
public:
	long long drincNum;
	long long drincPrice;
	SHOPINFO()
	{
		drincNum = 0;
		drincPrice = 0;
	}
	SHOPINFO(int num, int price)
	{
		drincNum = num;
		drincPrice = price;
	}
};


bool priceLow(SHOPINFO A, SHOPINFO B)
{
	if (A.drincPrice < B.drincPrice)
	{
		return true;
	}
	return false;
}

int main(void)
{
	long long resultNum = 0;
	int shop_N, need_M;

	cin >> shop_N >> need_M;


	vector<SHOPINFO> vShopInfo;
	for (int i = 0; i < shop_N; ++i)
	{
		SHOPINFO info;
		cin >> info.drincPrice >> info.drincNum;
		vShopInfo.push_back(info);
	}

	std::sort(vShopInfo.begin(), vShopInfo.end(), priceLow);

	int buyNum = 0;
	long long buyPrice = 0;
	for (int i = 0; i < vShopInfo.size(); ++i)
	{
		// 必要数以上になる
		if (buyNum + vShopInfo.at(i).drincNum > need_M)
		{
			//
			int wantNum = need_M - buyNum;
			buyPrice += wantNum * vShopInfo.at(i).drincPrice;
			break;
		}
		// すべて買う
		else
		{
			buyPrice += vShopInfo.at(i).drincNum * vShopInfo.at(i).drincPrice;
			buyNum += vShopInfo.at(i).drincNum;
		}
	}

	cout << buyPrice<< endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstring>
#include <vector>
#include <string>

using namespace std;

int W, H;
vector<string> map;
int ans;

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

void dfs(int x, int y) {
	map[y][x] = '*';
	ans++;
	
	for (int d=0; d<4; d++) {
		if (!(0 <= y + dy[d] && y + dy[d] < H && 0 <= x + dx[d] && x + dx[d] < W)) continue;
		if (map[ y + dy[d] ][ x + dx[d] ] == '.') {
			dfs(x + dx[d], y + dy[d]);
		}
	}
}

int main() {
	while (1) {
		cin >> W >> H; if (W == 0 && H == 0) break;
		map.assign(H, "");
		
		int sx, sy;
		for (int i=0; i<H; i++) {
			cin >> map[i];
			for (int j=0; j<W; j++) if (map[i][j] == '@') { sx = j; sy = i; }
		}
		
		ans = 0;
		dfs(sx, sy);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int,int>> vii;
#define rep(i,n) for (int i=0;i<n;i++);

ll mod = 1e9+7;

int main(){
    int a,b;
    cin >> a >> b;
    if (a<10 && b<10) cout << a*b << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{    
    
    public void slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int l = int.Parse(inputs[1]);
        int[] rope = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int lastIndex;
        try{
            lastIndex = Enumerable.Range(0, n - 1).First(x => rope[x + 1] + rope[x] >= l);
        }
        catch(InvalidOperationException e){
            System.Console.WriteLine("Impossible");
            return;
        }
        int[] result = 
            Enumerable.Range(0, lastIndex)
            .Concat(Enumerable.Range(0, n - 1).Skip(lastIndex + 1).Reverse())
            .Concat(Enumerable.Range(lastIndex, 1))
            .Select(x => x + 1)
            .ToArray();
        System.Console.WriteLine("Possible");
        System.Console.WriteLine(string.Join("\n", result));
    }
    
    static void Main(string[] args)
    {
        new Program().slove();
    }
}


Measured memory_bytes: 31836
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
char S[MAXN], T[MAXN];
int hashT[MAXN], hashS[MAXN];

int main() {
    scanf("%s", S + 1);
    scanf("%s", T + 1);
    int lenS = strlen(S + 1), lenT = strlen(T + 1);
    for (int i = 1; i <= lenS; i++) {
        int cur = 1;
        if (S[i] == 'B') cur = 2;
        hashS[i] = (hashS[i - 1] + cur) % 3;
    }
    for (int i = 1; i <= lenT; i++) {
        int cur = 1;
        if (T[i] == 'B') cur = 2;
        hashT[i] = (hashT[i - 1] + cur) % 3;
    }
    int Q;
    scanf("%d", &Q);
    for (int i = 0; i < Q; i++) {
        int a, b, c, d;
        scanf("%d %d %d %d", &a, &b, &c, &d);
        int s = (hashS[b] - hashS[a - 1] + 3) % 3;
        int t = (hashT[d] - hashT[c - 1] + 3) % 3;
        if (s == t) puts("YES");
        else puts("NO");
    }
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
using namespace std;
long long n, m, sum, mx=-9e20, a[1005][3], s[1005];
int main() {
	int i, j, k;
	cin>>n>>m;
	for(i=0; i<n; i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
	for(k=0; k<8; k++) {
		for(i=0; i<n; i++) {
			s[i] = 0;
			for(j=0; j<3; j++) s[i] += (k>>j&1 ? a[i][j] : -a[i][j]);
		}
		sort(s, s+n);
		sum = 0;
		for(i=n-1; i>=n-m; i--) sum += s[i];
		mx = max(mx, sum);
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 256
// g++ -std=gnu++1y -O2 xxx.cpp

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int A[3][3];
    rep (i,3) rep(j,3) cin>>A[i][j];
    int N;cin>>N;
    rep (i,N) {
        int b;cin>>b;

        rep (i,3) rep(j,3) {
            if (A[i][j]==b) {
                A[i][j]=0;
            }
        }
    }

    rep(i,3) {
        int sum=0;
        rep(j,3) {
            sum += A[i][j];
        }
        if (sum==0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(j,3) {
        int sum=0;
        rep(i,3) {
            sum += A[i][j];
        }
        if (sum==0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (A[0][0]+A[1][1]+A[2][2]==0 ||
        A[2][0]+A[1][1]+A[0][2]==0) {
            cout << "Yes" << endl;
            return 0;
    }

    cout << "No" << endl;

    return 0;
}

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

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

using namespace std;

typedef long long ll;

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

  int n; cin >> n;

  for (int x = 0; x <= 50000; x++) {
    if ( int(x * 1.08) == n ) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N, T , A;
	scanf("%d%d%d",&N ,&T ,&A);
	T *= 1000;
	A *= 1000;
	int H[N];
	for(int i=0;i<N;i++){
		scanf("%d",&H[i]);
	}
	int x[N];
	int min = 0;
	for(int j=0;j<N;j++){
		x[j] = T - H[j]*6;
		if((x[j]>A?x[j]-A:A-x[j]) < (x[min]>A?x[min]-A:A-x[min])){
			min = j;
		}
	}
	printf("%d",min+1);
	return 0;
}	


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

//int a[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
   // cin>>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
       // b-=1;
       
        ll divc=b/c - (a-1)/c;
        ll divd=b/d - (a-1)/d;
        ll lcm=(c)/__gcd(c,d) *d;
        ll divcd=b/lcm - (a-1)/lcm;
       // printf("%lld %lld %lld\n", divc,divd,divcd);
        printf("%lld\n", b-a +1 - divc -divd +divcd);

        //printf("Case %d: ",++te);
    }
    return 0;
}




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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    ll sum = 0;
    for(i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 5 == 0);
        else sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int a[1050];
int main() {
  ll n=read(),i,j,k,ans=0;
  for (i=1;i<=n;++i) a[i]=read();
  for (i=1;i<=n;++i)
    for (j=i+1;j<=n;++j)
      for (k=j+1;k<=n;++k) 
        if (a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&a[i]^a[j]&&a[i]^a[k]&&a[j]^a[k])
          ++ans;
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
def travel(k, n, al):
    min = 10**6+1
    for i in range(n):
        if i==0:
            if al[i-1]-al[i] > k/2.0:
                if min > al[i-1]-al[i]:
                    min = al[i-1]-al[i]
            else:
                if min > k-(al[i-1]-al[i]):
                    min = k-(al[i-1]-al[i])
        else:
            if al[i]-al[i-1] >= k/2.0:
                if min > al[i]-al[i-1]:
                    min = al[i]-al[i-1]
            else:
                if min > k-(al[i]-al[i-1]):
                    min = k-(al[i]-al[i-1])
    print(min)

k, n = [int(i) for i in input().split()]
al = [int(i) for i in input().split()]

travel(k, n ,al)

Measured memory_bytes: 26444
using System;
using System.Collections.Generic;

namespace AtCoder
{
	public class Program
	{
		// ABC108-C ng
		static void Main(string[] args)
		{
			string[] sv = Console.ReadLine().Split();
			int N = int.Parse(sv[0]);
			int K = int.Parse(sv[1]);
			long c1 = 0, c2 = 0;
			for (int i = 1; i <= N; i++) {
				if (i % K == 0) {
					c1++;
					//System.Diagnostics.Debug.WriteLine(i);
				} else if (K % 2 == 0 && i % K == K / 2) {
					c2++;
					//System.Diagnostics.Debug.WriteLine(i);
				}
			}
			Console.WriteLine(c1 * c1 * c1 + c2 * c2 * c2);
		}
	}
}


Measured memory_bytes: 13140
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) {
		String str1 = "", str2;
		int c = 0, count[], num1, num2, i = 0;
		char ch;
		count = new int[26];
		InputStreamReader isr = new InputStreamReader(System.in);
		try {
			while (true) {
				c = isr.read();
				if (c == -1) {
					break;
				}
				ch = (char) c;
				if (ch <= 'z' && ch >= 'a') {
					num1 = ch - 'a';
					++count[num1];
				} else if (ch <= 'Z' && ch >= 'A') {
					num2 = ch - 'A';
					++count[num2];
				}
				str2 = String.valueOf(ch);
				str1 = str1 + str2;
			}
			for (i = 0; i < 26; ++i) {
				num1 = i + 'a';
				ch = (char) num1;
				System.out.println(ch + " : " + count[i]);
			}
			isr.close();

		} catch (IOException e) {

		}
	}

}



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

int main(){
  int n, k;
  cin >> n >> k;
  int p[n];
  for (int i = 0; i < n; i++){
    cin >> p[i];
  }
  sort(p, p + n);
  int sum = 0;
  for (int i = 0; i < k; i++){
    sum += p[i];
  }
  cout << sum;
}

Measured memory_bytes: 3620