akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[][] B = new int[M][];
		for(var i=0;i<M;i++){
			B[i] = new int[3];
			string[] str2 = Console.ReadLine().Split();
			B[i][0] = int.Parse(str2[0]);
			B[i][1] = int.Parse(str2[1]);
			B[i][2] = i;
		}
		Array.Sort(B,(x,y)=>x[1] - y[1]);
		int[,] C = new int[M,2];
		int[] D = new int[N];
		for(var i=0;i<M;i++){
			C[B[i][2],0] = B[i][0];
			C[B[i][2],1] = D[B[i][0]-1]+1;
			D[B[i][0]-1] += 1;
		}
		string[] E = new string[M];
		for(var i=0;i<M;i++){
			string a1 = "000000"+C[i,0].ToString();
			a1 = a1.Substring(a1.Length-6,6);
			string a2 = "000000"+C[i,1].ToString();
			a2 = a2.Substring(a2.Length-6,6);
			E[i] = a1+a2;
		}		
		for(var i=0;i<M;i++){
			Console.WriteLine(E[i]);
		}
	}
}

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

int main() {
    int ans=0;
    int n;cin>>n;
    int k;cin>>k;
    vector<int> stick;
    for(int i=0;i<n;i++) {
        int l;
        cin>>l;
        stick.push_back(l);
    }
    sort(stick.rbegin(),stick.rend());
    for(auto itr=stick.begin();itr!=stick.end()-n+k;itr++) {
        ans+=*itr;
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

int main(){
    int n, W;
    cin >> n >> W;
    vector<ll> min_weight(100001, INT_MAX);
    min_weight[0]=  0;
    for(int i = 0; i < n; i++) {
        int weights, value;
        cin >> weights >> value;

        for(int j = 100001 - value; j >= 0; j--) {
            min_weight[j + value] = min(min_weight[j + value], min_weight[j] + weights);
        }
    }

    int ans = 0;
    for(int i = 0; i < 100001; i++)
        if(min_weight[i] <= W)
			ans = max(ans, i);

    cout << ans;

}


Measured memory_bytes: 3972
s = input()
nums = []
for i in s:
    nums.append(int(i))

for i in range(1 << (len(nums) - 1)):
    sum = nums[0]
    opes = []
    for j in range(3):
        if (i >> j) & 1:
            sum += nums[j+1]
            opes.append('+')
        else:
            sum -= nums[j+1]
            opes.append('-')
    if sum == 7:
        break

print('{0}{1}{2}{3}{4}{5}{6}=7'.format(nums[0], opes[0], nums[1], opes[1], nums[2], opes[2], nums[3]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
/* mt19937 mrand(random_device{}()); 
int rnd(int x) { return mrand() % x;}*/
ll powmod(ll a,ll b) {ll res=1;a%=mod;  for(;b>0;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
const int N=105;
int _;
double n,m;

int dp[N][N],a[N][N];
int main() {
		scanf("%lf",&m);
		double n=3.1415;
		printf("%.2f",m*2*n);
}

Measured memory_bytes: 3820
from itertools import permutations, combinations,combinations_with_replacement,product
import sys
input = sys.stdin.readline

n, m, q = map(int, input().replace("\n","").split())
a = [[int(j) for j in input().replace("\n","").split()] for i in range(q)]


tmp = [i for i in range(1,m+1)]
chk = list(combinations_with_replacement(tmp, n))
# print(list(chk[0]))

tmpans = 0
ans = 0

for i in range(len(chk)):
    tmpans = 0
    for j in range(q):
        # listchk = list(chk[i])
        """
        print(a[j])
        print(chk[i])
        print(listchk)
        print(a[j][1])
        print(a[j][0])
        print(listchk[a[j][1]-1])
        print(listchk[a[j][0]-1])
        print(a[j][2])
        """
        if (chk[i][a[j][1]-1] - chk[i][a[j][0]-1]) == a[j][2]:
            tmpans += a[j][3]
    if tmpans >= ans:
        ans = tmpans

print(ans)

Measured memory_bytes: 85032
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	for(;;){
		if(a>b){
			a=a%b;
			if(a==0){
				printf("%d\n",b);
				break;
			}
		}else{
			b=b%a;
			if(b==0){
				printf("%d\n",a);
				break;
			}
		}
	}
	
	return 0;
	
}

Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    int x=a-b;
    int y=c-x;

    if(y>0)
        cout<<y<<endl;
    else
        cout<<0<<endl;

    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  ll n,i,j,k;
  string s, t;

  ll ans = 0;
  cin >> n >> k;

  ll span = 2*k + 1;

  for(i = 1; i <= n;){
    i += span;
    ans++;
  }

  cout << ans << '\n';

  ktj();
}


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

int main(void) {
	int i;
	char buff[1000];
	gets(buff);
	for (i = 0; i < strlen(buff); i++) {
		if( buff[i] >= 'a' && buff[i] <= 'z')
			buff[i] = buff[i] - 'a' + 'A';
	}
	printf("%s\n", buff);
	return 0;
}

Measured memory_bytes: 520
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] num = new int[N+1];
		for(int i = 1;i <= N;i++) {
			int buf = i;
			for(int j = 2;j <=buf;j++) {
				while(buf%j==0) {
					num[j]++;
					buf /= j;
				}
			}
		}
		long ans = 1;
		long mod = 1000000007;
		for(int i = 0;i <= N;i++) {
			ans *= num[i]+1;
			ans %= mod;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int x, y;
  cin >> x >> y;

  int a = 0, b = 0;
  if(x == 2) a++;
  else if(x == 4 || x == 6 || x == 9 || x == 11) b++;

  if((a && y == 2) || (b && (y == 4 || y == 6 || y == 9 || y == 11))) cout << "Yes";
  else if(a == 0 && b == 0 && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) cout << "Yes";
  else cout << "No";
}


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

int main(){
  int N;
  cin>>N;
  vector<double> v(N);
  for(int i=0; i<N; i++){
    cin>>v[i];
  }

  sort(v.begin(), v.end(), greater<double>());

  while(v.size()>1){
    double y = v.back();
    v.pop_back();
    double z = v.back();
    v.pop_back();

    v.push_back((y+z)/2);
  }

  cout<<v.front()<<endl;
}

Measured memory_bytes: 3708
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const int big=1e9;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,i,j,ans=0;
	cin>>n;
	cout<<n/30<<" "<<2*(n%30)<<endl;
	return 0;
}

Measured memory_bytes: 3112
def solve():
    H, W = map(int,input().split())
    cost = [list(map(int,input().split())) for _ in range(10)]
    A = [list(map(int,input().split())) for _ in range(H)]
    d = []
    for i in range(10):
        d.append(dijkstra(i,10,cost))
    
    ans = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] != -1:
                ans += d[A[h][w]][1]
    
    print(ans)

def dijkstra(s,N,cost):
    d = [float("inf")] * N
    used = [False] * N
    d[s] = 0

    while True:
        v = -1
        for u in range(N):
            if not used[u] and (v == -1 or d[u] < d[v]):
                v = u
        if v == -1:
            break
        used[v] = True

        for u in range(N):
            d[u] = min(d[u], d[v] + cost[v][u])
    
    return d

if __name__ == '__main__':
    solve()

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

int main() {
	long long n, k;
	cin >> n >> k;
 
	long long  ans = 0;
	ans += (n / k)*(n / k)*(n / k);
 
	if (k % 2 == 0 && k / 2 <= n) {
		ans += ((n - k / 2) / k + 1)*((n - k / 2) / k + 1)*((n - k / 2) / k + 1);
	}
 
	cout << ans << endl;
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(r);i--)
#define se          second
#define fi          first

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 764
# coding: utf-8


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

II = lambda: int(input())
MI = lambda: map(int, input().split())


def calc_scores(ad, D):
    def calc_score(i):
        x, y = ad[i]
        xp, yp = ad[i-D]
        return abs(x-xp) + abs(y-yp)
    scores = [0] * (D + 1)
    for i in range(D + 1, len(ad) + 1):
        scores.append(scores[i-D] + calc_score(i))
    return scores


def main():
    H, W, D = MI()
    ad = {}
    for i in range(H):
        for j, a in enumerate(MI()):
            ad[a] = (i, j)
    s = calc_scores(ad, D)
    for q in range(II()):
        L, R = MI()
        print(s[R] - s[L])


if __name__ == "__main__":
    main()


Measured memory_bytes: 22620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

typedef long long ll;
typedef long double ld;
const ll INF = (ll)1e18 + 9;

template<typename Head> void print(Head head) { std::cout << head << std::endl; }
template<typename Head, typename... Tail> void print(Head head, Tail... tail) {
  std::cout << head << " ";
  print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << *it << " ";
    if ((it - begin) % 5 == 4 || it == end - 1) { std::cout << std::endl; }
  }
}

ll comb[51][51];

void comb_table(ll N)
{
  for(int i=0; i<=N; i++) {
    for(int j=0; j<=i; j++) {
      if (j ==0 or j == i) {
	comb[i][j] = 1LL;
      } else {
	comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
      }
    }
  }
}

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

  ll N, A, B;
  std::cin >> N >> A >> B;

  comb_table(N);

  std::vector<ll> vv(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vv[i];
  }
  std::sort(vv.begin(), vv.end(), std::greater<ll>());
  //printVec(vv.begin(), vv.end());

  std::vector<ll> vsum(N+1, 0LL);
  for (ll i = 1; i <= N; i++) {
    vsum[i] = vv[i-1] + vsum[i-1];
  }

  ll x = B-1;
  ld ans = (ld)vsum[A] / A;
  for (ll i = A; i < B; i++) {
    if (((ld)vsum[i] / i) > ((ld)vsum[i+1] / (i+1)) + 1e-12) {
      x = i-1;
      break;
    }
  }
  std::cout << std::fixed << std::setprecision(6);

  print(ans);

  ll st  = x;
  ll end = x;
  for (ll i = x; i >= 0; i--) {
    if (vv[i] != vv[x]) {
      break;
    }
    st = i;
  }
  for (ll i = x; i < N; i++) {
    if (vv[i] != vv[x]) {
      break;
    }
    end = i;
  }
  ll n = end - st + 1;
  ll ans2 = 0LL;
  for (ll k = A-1; k <= x; k++) {
    ans2 += comb[n][k - st + 1];
    //print(ans2, n, k - st + 1, comb[n][k - st + 1]);
  }
  print(ans2);
  return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)

const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool check_prime(int n)
{
    if(n<2)
        return false;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

int setbits(int n)
{
    int count=0;
    while(n)
    {
        if(n%2==1)
            count++;
        n>>=1;
    }
    return count;
}

int lcm(int a,int b)
{
    return (a*b)/__gcd(a,b);
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    vector <int> a(5);
    loop(i,0,5)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<i+1;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


class Graph{
    struct edge{
        int vertice;
        ll weight;
    };

    vector<vector<edge>> g;
    unsigned int n;

public:
    Graph(unsigned int n): n{n}{
        g.resize(n);
    }

    void add_edge(int u, int v){
        g[u].emplace_back(edge{v, 1});
    };

    void add_edge(int u, int v, ll w){
        g[u].emplace_back(edge{v, w});
    }

    vector<edge>& get_edge(int v){
        return g[v];
    }

    unsigned int get_num_vertices() const{
        return n;
    }

    unsigned int size() const{
        return n;
    }

    vector<edge>& operator[](int v){
        return get_edge(v);
    }
};


/**
 * prim法 (O(|E|log(|V|))のアルゴリズム)
 * @param g 連結グラフ
 * @return 連結グラフの最小域木をグラフとして返す
 */
Graph prim2_g(Graph g){
    // Ptmp.fsが今の部分木からのコスト、Ptmp.ｓｃ.fsが次の頂点、Ptmp.sc.scが次の頂点に辺を伸ばす部分木の頂点
    typedef pair<ll, pair<int, int>> Ptmp;

    unsigned int n = g.size();

    Graph mst(n);   // minimum spanning tree
    vector<ll> used(n, false);
    priority_queue<Ptmp, vector<Ptmp>, greater<Ptmp> > que;

    used[0] = true;
    for(auto e: g[0]){
        que.push(Ptmp(e.weight, pair<int, int>(e.vertice, 0)));
    }

    while(!que.empty()){
        Ptmp p = que.top(); que.pop();
        int to = p.second.first, from = p.second.second;
        if(used[to]) continue;

        used[to] = true;
        mst.add_edge(from, to, p.first);
        mst.add_edge(to, from, p.first);

        for(auto e: g[to]){
            if(!used[e.vertice]){
                que.push(Ptmp(e.weight, pair<int, int>(e.vertice, to)));
            }
        }
    }

    return mst;
}


ll prim2(Graph g){
    unsigned int n = g.size();
    Graph mst = prim2_g(g);

    ll res = 0;
    for(int i = 0; i < n; i++){
        for(auto e: mst[i]){
            res += e.weight;
        }
    }

    return res / 2;
}



int main(){
    int n;   cin >> n;
    Graph g(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int x;  cin >> x;
            if(x != -1){
                g.add_edge(i, j, x);
            }
        }
    }

    cout << prim2(g) << endl;

    return 0;
}



Measured memory_bytes: 3448
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;
int main() {
	string str;
	cin >> str;
	while (str[0] != '0') {
		int i, o = 0;
		for (i = 0; i < str.size(); i++) {
			o += str[i] - '0';
		}
		cout << o << endl;
		cin >> str;
	}
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, W;
  cin >> N >> W;

  ll max_value = 10000 * N;
  vll dp(max_value, INF);

  rep(i, N) {
    ll w, v;
    cin >> w >> v;
    vll next = dp;
    if (i == 0) {
      rep(j, v + 1) {
        next[j] = min(next[j], w);
      }
    } else {
      rep(j, v + 1) {
        next[j] = min(next[j], w);
      }
      rep(j, max_value) {
        if (dp[j] == -1) break;
        next[j + v] = min(next[j + v], dp[j] + w);
      }
    }
    dp = next;
  }

  repr(i, max_value - 1) {
    if (dp[i] <= W) {
      COUT(i);
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 18820
// usage
// cat test.txt | node main.js

var fs = require("fs");

function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

//--
var input = main(fs.readFileSync(process.stdin.fd, "utf8"));





Measured memory_bytes: 21956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,s;
  cin >> k >> s;
  int count = 0;
  for(int x=0;x<k+1;x++){
    int target = s-x;
    if(target>=0){
      if(target < k*2+1){
        for(int y=0;y<k+1;y++){
          int check = target-y;
          if(check>=0){
            if(check<k+1){
              count += 1;
            }
          }else{
              break;
          }
        }
      }
      
    }else{
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>

using namespace std;

#define endl '\n'

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

    int n;
    cin >> n;

    vector<vector<int>> adj(n);

    for (int i = 1; i < n; ++i)
    {
        int p;
        cin >> p;
        --p;

        adj[p].push_back(i);
    }

    function<int(int)> solve = [&](int u) {
        int answer = 0;

        vector<int> d;
        for (auto v : adj[u])
        {
            d.push_back(solve(v));
        }

        sort(d.begin(), d.end());
        reverse(d.begin(), d.end());

        int i = 0;
        for (auto x : d)
        {
            answer = max(answer, x + ++i);
        }

        return answer;
    };

    cout << solve(0) << endl;

    return 0;
}

Measured memory_bytes: 13568
#include<iostream>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>

using namespace std;

int n, m;
map<int, int> data;

void solve(int sum, int n_){
  for(int i=1; i<=m; ++i){
    if(n_ == n) ++data[sum+i];
    else solve(sum+i, n_+1);
  }
}

int main(){
  int k;
  double ans, all;
  while(1){
    cin >> n >> m >> k;
    if(!n && !m && !k) break;
    data.clear();
    for(int i=n; i<n*m; ++i) data.insert(make_pair(i, 0));
    solve(0, 1);
    ans = 0;
    all = pow((double)m, n);
    for(map<int, int>::iterator it=data.begin(); it!=data.end(); ++it){
      if(it->first - k <= 1)
	ans += (it->second / all);
      else
	ans += ((it->first - k) * it->second / all);
    }
    printf("%0.8f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1696
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Control.Monad

main = do
  li <- BS.getLine
  let Just (n,_) = BS.readInt li
  li <- BS.getLine
  let xs = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n xs
  mapM_ print ans

compute :: Int -> [Int] -> [Int]
compute n xs = [ if x <= xi then xj else xi | x <- xs ]
  where
    (xi:xj:_) = drop (div n 2 - 1) $ sort xs

{-
ちょうど真ん中の両側を xi xj (j=i+1) とする。
xi以下の要素を抜いた系列の中央値はxj
xj以上の要素を抜いた系列の中央値はxi
-}


Measured memory_bytes: 49616
N,W = map(int, input().split())
weight = [0]*N
value = [0]*N
for i in range(N):
  weight[i],value[i]=map(int, input().split())
  
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
  for j in range(W+1):
    if j-weight[i-1] >= 0:
      dp[i][j] = max(dp[i-1][j-weight[i-1]] + value[i-1], dp[i-1][j])
    else:
      dp[i][j] = dp[i-1][j]
print(max(dp[N]))

Measured memory_bytes: 171656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll N, A, B;
  ll res = 0;
  cin >> N >> A >> B;

  ll S = A + B;
  ll n = N / S;
  ll m = N % S;

  res = n * A;
  res += min( A, m );

  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
        a[i]%=2;
    }
    int ans = pow(3, n);
    int rmv=1;
    //cout<<n;
    for (int i = 0;i<n;i++){
        if (a[i]==0){
            rmv*=2;
        }
    }
    cout<<ans-rmv;
}


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

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i > (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

string s;

int solve() {
  int len = s.length();
  if (len == 1) return 0;
  int p = len / 2;
  int j = 1;
  int c = 0;
  if (len % 2 == 1) {
    j = 2;
    p++;
  }
  irep(i, p, len) {
    if (s[i - j] != s[i]) {
      s[i - j] = s[i];
      c++;
    }
    j += 2;
  }
  return c;
}

int main() {
  cin >> s;
  cout << solve() << endl;
  return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

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

    double x;
    cin >> x;
    x/=3.0;
    cout << fixed << setprecision(10) << x*x*x;
    return 0;
}


Measured memory_bytes: 256
N,A,B,C,D = list(map(int, input().split()))
S = [0]+[0 if s=='.' else 1 for s in input()]
can_jump = [0] + [1-S[i]*S[i+1] for i in range(1,N-1)]
can_change = [0] + [(1-S[i])*(1-S[i+1])*(1-S[i+2]) for i in range(1,N-2)]

def Solution():
  if not all(can_jump[A:C]):
    return False
  if not all(can_jump[B:D]):
    return False
  
  if C<D:
    return True
  if C>D:
    if any(can_change[B-1:D]):
      return True
    else:
      return False

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


Measured memory_bytes: 9236
<?php
fscanf(STDIN, '%d %d', $cnt, $cho);
$ans = 0;
$mod = 1000000007;
for ($i=$cho; $i <= $cnt+1; ++$i) { 
    $ans += sum($cnt-$i+1, $cnt) - sum(0, $i-1) + 1;
    $ans %= $mod;
}
echo $ans;

function sum($left, $right) {
    return ($left+$right) * ($right-$left+1) / 2;
}

Measured memory_bytes: 16172
import scala.io.Source

object Main{
  def main(args: Array[String]){
    var list = List[String]()
    for(in <- Source.stdin.getLines.toList){
      list = in :: list
    }

    for(i <- 1 to list.length){
      if(list(list.length - i) != "0"){
        println("Case " + i + ": " + list(list.length - i))
      }
    }
  }
}

Measured memory_bytes: 56416
N = gets.to_i
A = gets.split.map &:to_i

bits_count = (0..60).map{|i| A.count{|a| a[i] == 1}}
ans_bin = bits_count.map{|count| (count * (N - count)) % (10**9 + 7)}
ans = 0
ans_bin.each_with_index do |x, i|
    ans = (ans + (x << i)) % (10**9 + 7)
end
p ans

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		int[] arr = {a,b,c};
		Arrays.parallelSort(arr);
		if(arr[2]==arr[1]+arr[0]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 23252
def gen_d_prim(n):
    D = [0,0] + [-1] * (n-1)
    for i in range(2, n+1, 2): D[i] = 2
    for i in range(3, n+1, 2):
        if D[i] > 0: continue
        for j in range(i, n+1, i): D[j] = i
    return D

def is_pairwise(A):
    D = gen_d_prim(10**6)
    past = set()
    for a in A:
        now = set()
        while a != 1:
            # 素数 D[a]: 今回は未済 & 過去で済
            if not D[a] in now and D[a] in past: return False
            now.add(D[a])
            past.add(D[a])
            a //= D[a]
    return True

def gcd_all(A):
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    return g

def solve():
    if is_pairwise(A): return 0
    if gcd_all(A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


Measured memory_bytes: 127388
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    #トポロジカルソート
    N,M = MI()
    edge = [[]for _ in range(N)]
    indegree = [0]*N #入次数
    for _ in range(M+N-1):
        a,b = MI_()
        edge[a].append(b)
        indegree[b] += 1
    #print(indegree)
    #入次数が0の点からあれしていく
    queue = deque() 
    for i,x in enumerate(indegree):
        if not x:
            queue.append(i)
    
    pop = queue.popleft
    topological_index = [] #トポロジカルソート順
    ans = [0]*N
    while queue:
        v = pop()
        topological_index.append(v)
    
        for to in edge[v]:
            indegree[to] -= 1
            if not indegree[to]:
                queue.append(to)
                ans[to]=v+1
    # print(*topological_index,sep="\n")
    print(*ans,sep="\n")    
if __name__ == '__main__':
    main()


Measured memory_bytes: 90720
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

import pdb

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    D, G = LI()
    p, c = [], []
    for _ in range(D):
        _p, _c = LI()
        p.append(_p)
        c.append(_c)

    min_num_solved = inf
    
    for i in range(1 << D):
        point = 0
        num_solved = 0
        unsolved_max = 0
        for j in range(D):
            solve_all = (i >> j) & 1
            if solve_all:
                point += (j+1) * 100 * p[j] + c[j]        
                num_solved += p[j]
            else:
                unsolved_max = max(unsolved_max, j)
         
        if point < G:
            residue = G - point
            p_num = p[unsolved_max]
            while residue > 0 and p_num > 0:
                residue -= (unsolved_max+1) * 100 
                p_num -= 1
                num_solved += 1
            if residue > 0:
                continue
        min_num_solved = min(min_num_solved, num_solved)
    print(min_num_solved)    



main()



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

int main() {
 string s;cin >>s;
  vector<int> cnt(100);
  for(int i=0;i<s.size();i++){
   int al=s[i]-'a';
   cnt[al]++;
  }
  int stl=0;
  for(int i=0;i<26;i++){
   if(cnt[i]==0){
    char ans=i+'a';
     cout << ans << endl;
     return 0;
   }
   else stl++;
  }

  if(stl==26)cout << "None" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>

using namespace std;

bool restore(char a, char b)
{
    if((a == b) || (a == '?'))
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

int main()
{
    char s[50], t[50], s0[50];
    int ls, lt, ls0, pos;
    int i, j, flag = 0;
    cin>>s;
    cin>>t;
    ls = strlen(s);
    lt = strlen(t);
    ls0 = ls;
//    cout<<"ls = "<<ls<<endl;
//    cout<<"lt = "<<lt<<endl;
    for(i = ls - 1; i >= 0; i--)
    {
        for(j = lt -1; j >= 0; j--)
        {
            if(restore(s[i-(lt-1-j)], t[j]))
            {
//                cout<<"s = "<<s[i-(lt-1-j)]<<endl;
//                cout<<"t = "<<t[j]<<endl;
                flag++;
            }
            else
            {
                flag = 0;
                break;
            }
        }
        if(flag != 0)
        {
            pos = i;
//            cout<<"pos = "<<pos<<endl;
            break;
        }
    }
    if(flag == 0)
    {
        cout<<"UNRESTORABLE"<<endl;
    }
    else
    {
        for(i = ls0-1; i >= 0;i--)
        {
            if(i == pos)
            {
                for(j = lt -1; j >= 0; j--)
                {
                    s0[i] = t[j];
                    i--;
                }
                i++;
            }
            else if(s[i] == '?')
            {
                s0[i] = 'a';
            }
            else
            {
//                cout<<"i = "<<i<<endl;
                s0[i] = s[i];
            }
        }
        for(i = 0; i < ls0; i++)
        {
            cout<<s0[i];
        }
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.Collections;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int list[]  = new int[n];
		double sum = 0;
		boolean flag = true;

		for(int i=0; i < n; i++){
			list[i] = scan.nextInt();
			sum += list[i];
		}
		double line = sum / (4 * m);
		int con = 0;
		for(int i=0; i < n; i++){
			if (line <= list[i]) con++;
		}
		if(con < m)flag=false;
		if(flag){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        ++mp[a];
    }
    int ans = 0;
    for (auto p: mp) {
        if (p.second % 2 == 1) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8136
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x,y = map(int,read().split())

answer = 0
for t in [x,y]:
    if t == 1:
        answer += 3
    elif t == 2:
        answer += 2
    elif t == 3:
        answer += 1
if x == y == 1:
    answer = 10

answer *= (10**5)
print(answer)

Measured memory_bytes: 3064
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    A = list(map(int, input().split()))
    a = sorted(A, reverse=1)
    res1 = 0
    res2 = []
    for i in range(N-3):
        if a[i]==a[i+1]==a[i+2]==a[i+3]:
            res1 = a[i]
            break
    for i in range(N-1):
        if a[i]==a[i+1] and not a[i] in res2:
            res2.append(a[i])
        if len(res2)==2:
            break
    if len(res2)==0:
        print(0)
    elif len(res2)==1:
        print(res1**2)
    else:
        print(max(res1**2, res2[0]*res2[1]))



if __name__ == '__main__':
    main()

Measured memory_bytes: 14764
N = int(input())
alist = list(map(int,input().split()))

neg_cnt = 0
abs_min = 999999999999999
for an in alist:
  if an < 0:
    neg_cnt += 1
  if abs_min > abs(an):
    abs_min = abs(an)
 
ans = 0
for i in range(N):
  ans += abs(alist[i])
  
if neg_cnt%2 == 0:
  print(ans)
else:
  print(ans-2*abs_min)

Measured memory_bytes: 14284
using System;
class aoj
{
    static void Main()
    {
        int []c=new int[50];
        int k=0;
        for (;;)
        {

        
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a))
            {
                break;
            }
            int b = int.Parse(a);
            
            for(int i = 0; i < 10; i++)
            {
                for(int j = 0; j < 10; j++)
                {
                    for(int x = 0; x < 10; x++)
                    {
                        for(int y = 0; y < 10; y++)
                        {
                            if (i + j + x + y == b) { 
                            c[k]++;
                            }
                            
                        }
                    }
                }
            }
            k++;
        }
        for(int i = 0; i < k; i++)
        {
            Console.WriteLine(c[i]);
        }
    }
}

Measured memory_bytes: 9088
object Main extends App {
  val n = io.StdIn.readInt
  val table = Array.ofDim[Int](9)
  io.StdIn.readLine.split(" ").map(_.toInt)
    .foreach(i => {
    i match {
      case i if i <  400 => table(0) += 1
      case i if i <  800 => table(1) += 1
      case i if i < 1200 => table(2) += 1
      case i if i < 1600 => table(3) += 1
      case i if i < 2000 => table(4) += 1
      case i if i < 2400 => table(5) += 1
      case i if i < 2800 => table(6) += 1
      case i if i < 3200 => table(7) += 1
      case i if i < 4801 => table(8) += 1
    }
  })

  val e07 = table.init.count(_ > 0)
  val e8  = table(8)
  val min = if(e07 != 0) e07 else 1
  val max = if(e07 != 0) min + e8 else e8
  val ans = min + " " + max
  println(ans)
}

Measured memory_bytes: 27080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  if(n == 0) cout << 0 << endl;
  stack<int> sta;
  while(n != 0){
    sta.push(abs(n%2));
    n = (n-abs(n%2))/(-2);
  }
  while(!sta.empty()){
    cout << sta.top();
    sta.pop();
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

#include <vector>

/*	verified : 2020/07/18
		AOJ, Disjoint Set: Union Find Tree
		http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
*/

struct union_find {
	long long N;					// the number of nodes
	long long M;					// the number of trees
	std::vector<long long> parent;	// parent[i] := the direct parent of i
	std::vector<long long> size;	// size[i] := the number of nodes in the tree rooted to i
	vector<ll> white_cnt;
	vector<ll> black_cnt;

	union_find(long long n) : N(n), M(n) {
		parent.resize(n, -1);
		size.resize(n, 1);
		white_cnt.resize(n, 0);
		black_cnt.resize(n, 0);
	}

	long long root(long long i) {
		if (parent[i] == -1) return i;
		else return parent[i] = root(parent[i]);
	}

	bool is_united(long long i, long long j) {
		return (root(i) == root(j));
	}

	// true : unite succeeded
	bool unite(long long i, long long j) {
		i = root(i); j = root(j);
		if (i == j) return false;
		if (size[i] < size[j]) std::swap(i, j);
		parent[j] = i;
		size[i] += size[j];
		white_cnt[i] += white_cnt[j];
		black_cnt[i] += black_cnt[j];
		M--;
		return true;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, m;
	cin >> n >> m;
	for (ll i = 0; i < (m + 1) / 2; i++) {
		cout << n - i << ' ' << n - (m + 1) / 2 * 2 + 1 + i << '\n';
	}
	for (ll i = 0; i < m / 2; i++) {
		cout << i + 1 << ' ' << m / 2 * 2 + 1 - i << '\n';
	}
}

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> v(n+1, 0);

    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '#') {
            sum++;
            v[i+1] = sum;
        }
        
        else v[i+1] = sum;
        //if (s[i] == '#' && s[i+1] == '.') cnt++;
    }
    
    int minv = (int)1e6;
    for (int i = 0; i <= n; i++) {
        int n_black_left = v[i];
        int n_white_right = n-(i+1)+1 - (v[n]-v[i]);
        minv = min(n_black_left + n_white_right, minv);
    }
     
    cout << minv << endl;

    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long X,count,ans;cin>>X;count=ans=0;
    for(long long i=0;i<pow(10,8);i++){
        count+=i;
        if(count>=X){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3676
import java.io.*;
import java.util.*;
public class Main {
	
	public static boolean isLeap(int year) {
		
		if (year % 400 == 0) {
			return true;
		} else if (year % 100 == 0) {
			return false;
		} else 
			return year % 4 == 0;
		
	}
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> ans = new ArrayList<String>();
		
		while (true) {
			
			boolean nan_flag = true;
			StringTokenizer st = new StringTokenizer(br.readLine()," ");
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			if (a == 0 && b == 0) break;
			for (; a <= b; a++) {
				if (isLeap(a)) {
					ans.add(String.valueOf(a));
					nan_flag = false;
				}
			}
			if (nan_flag) ans.add("NA");
			ans.add("");
			
		}
		
		for (int i = 0; i < ans.size() - 1; i++) {
			if (ans.get(i).equals("")) {
				System.out.println();
				continue;
			}
			System.out.println(ans.get(i));
		}
	}

}

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

int h[10],c[10];
int main(){
	int w,d;
	while(scanf("%d%d",&w,&d),w){
		int sum=0;
		rep(i,w){scanf("%d",&h[i]);sum+=h[i];}
		rep(i,d){scanf("%d",&c[i]);sum+=c[i];}
		rep(i,w){
			rep(j,d){
				if(h[i]==c[j]){
					sum-=c[j];
					c[j]=INT_MAX;
					break;
				}
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	ll T = min(n, m / 2);
	ans += T;
	n -= T;
	m -= T * 2;
	ans += m / 4;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <vector>
using namespace std;
 
 
int main(){
   
  int h,w,n,big;
  cin>>h>>w>>n;
  big=max(h,w);
  if(n%big==0)cout<<n/big<<endl;
  else cout<<n/big+1<<endl;
   
    
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String S = scan.next();

		if (S.contentEquals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}

	}

}

Measured memory_bytes: 35516
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] NK = ReadLineParseIntArray();
        int[] A = ReadLineParseIntArray();
        int[] counts = new int[NK[0]];
        for(int i = 0; i < NK[0]; i++)
        {
            counts[A[i] - 1]++;
        }
        var ans = counts.Where(x => x > 0).ToArray();
        Array.Sort(ans);
        int sum = 0;
        for(int i = 0; i < ans.Length - NK[1]; i++)
        {
            sum += ans[i];
        }
        WriteLine(sum);
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

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


int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	
	ll s[10000000];
	s[0]=0;
	s[1]=abs(a[1]-a[0]);
	s[2]=min(s[0]+abs(a[2]-a[0]),s[1]+abs(a[2]-a[1]));
	for(ll i=3;i<n;i++)
	{
		s[i]=min(s[i-2]+abs(a[i]-a[i-2]),s[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<s[n-1]<<" ";

	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
 
  for(int i = 0; i < k; i++) {
    if(max({a,b,c}) == a) a *= 2;
    if(max({a,b,c}) == b) b *= 2;
    if(max({a,b,c}) == c) c *= 2;
  }
  cout << a + b + c << endl; 
}

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        PrintWriter out = new PrintWriter(System.out);


        try {


    		String str = br.readLine();
    		String [] strArr = str.split(" ");

    		int intN = Integer.parseInt(strArr[0]);
    		int intK = Integer.parseInt(strArr[1]);


    		System.out.println(intN - intK + 1);

            out.flush();


        } catch (IOException e) {

        }


    }

}

Measured memory_bytes: 22484