akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#define BELOW 1
#define NOTBELOW 0
using namespace std;
typedef long long ll;
string N;
int num[105];
int K;
int totZeros;
ll dp[105][105][2]; // digits, zeros, below or not

ll solve(int dig, int zeros, int below){
    //cout << dig << " " << zeros << " " << below << endl;
    if (dp[dig][zeros][below] != -1) return dp[dig][zeros][below];
    //if (dig == 2 && zeros == 5 && below == 1) cout << "ok" << endl;
    if (totZeros-zeros > dig+1) return dp[dig][zeros][below] = 0;
    //if (dig == 2 && zeros == 5 && below == 1) cout << "ok" << endl;
    if (dig == 0){
        if (below){
            if (zeros == totZeros) return dp[dig][zeros][below] = 9;
            if (zeros == totZeros-1) return dp[dig][zeros][below] = 1;
            else return dp[dig][zeros][below] = 0;
        }
        else {
            if (zeros == totZeros) return dp[dig][zeros][below] = num[0];
            if (zeros == totZeros-1) return dp[dig][zeros][below] = 1;
            else return dp[dig][zeros][below] = 0;
        }
    }
    ll ans = 0;
    if (below){
        ans += 9*solve(dig-1,zeros,below);
        if (zeros < totZeros) {
            //if (dig == 3 && zeros == 4 && below == 1) cout << zeros << " a " << totZeros << endl;
            ans += solve(dig-1,zeros+1,below);
        }
    }
    else {
        if (num[dig] != 0) ans += solve(dig-1,zeros,NOTBELOW);
        else ans += solve(dig-1, zeros+1, NOTBELOW);
        ans += max(0,num[dig]-1)*solve(dig-1,zeros,BELOW);
        if (zeros < totZeros && num[dig] != 0) ans += solve(dig-1, zeros+1, BELOW);
    }
    //cout << ans << " " << dig << " " << zeros << " " << below << endl;
    return dp[dig][zeros][below] = ans;
}

int main() {
    cin >> N >> K;
    int s = N.length();
    totZeros = s-K;
    //cout << totZeros << endl;
    for (int i=0; i<s; i++){
        num[s-1-i] = N[i]-'0';
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(s-1, 0, NOTBELOW) << endl;
//    for (int i=0; i<=3; i++){
//        for (int j=0; j<=3; j++){
//            for (int k=0; k<2; k++){
//                cout << dp[i][j][k] << " ";
//            }
//        }
//    }
//    cout << endl;
//    cout << dp[0][0][0] << endl;
//    cout << dp[0][0][1] << endl;
    return 0;
}


Measured memory_bytes: 384
//{
#include<bits/stdc++.h>
using namespace std;
 
#define DEBUG

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif
//}

vl parent(100005), weight(100005);

ll findset(ll u) {
    if(parent[u] == u)
        return u;
    return parent[u] = findset(parent[u]);
}

void joinset(ll u, ll v) {
    ll a = findset(u);
    ll b = findset(v);
    if(a != b) {
        parent[a] = b;
        weight[b] += weight[a];
    }
}

ll solve(ll n, ll m, vl &A, vector<pair<ll, ll> > &P) {
    FOR(i, 0, 100005) {
        parent[i] = i;
        weight[i] = 1;
    }
    
    FOR(i, 0, m) {
        ll u = P[i].F, v = P[i].S;
        joinset(u, v);
    }
    
    ll ct = 0;
    FOR(i, 0, n) {
        if(A[i] == i + 1)
            ct++;
        else {
            if(findset(i + 1) == findset(A[i]))
                ct++;
        }
    }
    
    return ct;
}

void Input() {
    rd2(ll, n, m);
    vl A(n);
    FOR(i, 0, n)
        cin >> A[i];
    vector<pair<ll, ll> > P(m);
    FOR(i, 0, m)
        cin >> P[i].F >> P[i].S;
    cout << solve(n, m, A, P);
}

int main() {
	
	fastio;

    // rd1(ll, t);
	ll t = 1;

    while(t--) {
        Input();
    }
    
	return 0;
}

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

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double E=2.718281828459045;
const double eps=1e-8;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int MOD=1e3;
const int N=1e2+5;
const ll maxn=2e5+5;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};
int n;
long long a[maxn], b[maxn];

void sort(long long *a, long long md)
{
    int pos = n;
    for (int i = 0; i < n; i ++)
    {
        if (pos == n && a[i] >= md)
            pos = i;
        a[i] = a[i] & (md - 1);
    }
    inplace_merge(a, a + pos, a + n);
}

bool solve(long long limit)
{
    long long ans = 0;
    int that = n - 1;
    for (int i = 0; i < n; i ++)
    {
        while (that >= 0 && a[i] + b[that] >= limit)
            that --;
        ans += n - 1 - that;
    }
    return ans & 1;
}
int main()
{
    int T, cas = 0;
    cin >> n;
    for (int i = 0; i < n; i ++)
        scanf("%lld", &a[i]);
    for (int i = 0; i < n; i ++)
        scanf("%lld", &b[i]);
    sort(a, a + n);
    sort(b, b + n);
    long long ans = 0;
    for (int i = 61; i >= 0; i --)
    {
        sort(a, (long long)2 << i);
        sort(b, (long long)2 << i);
        long long res =
            solve((long long)1 << i) ^
            solve((long long)2 << i) ^
            solve((long long)3 << i);
        ans |= res << i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4212
import std.stdio, std.string, std.array, std.conv;

void main() {
    int n = readln.chomp.to!int;
    int[][] a = new int[][](n, n);
    foreach (i; 0 .. n) {
        int[] tmp = readln.chomp.split.to!(int[]);
        foreach (j; 0 .. tmp[1]) {
            a[tmp[0]-1][tmp[j+2]-1] = 1;
        }
    }
    foreach (i; 0 .. n) {
        foreach (j, x; a[i]) {
            x.write;
            if (j != n - 1) " ".write;
            else writeln;
        }
    }
}


Measured memory_bytes: 2492
def main():
    n, k = map(int, input().split())

    mod = 10 ** 9 + 7
    fact = [1]
    for i in range(1, 2001):
        fact.append(fact[-1] * i)

    def comb(l, r):
        return fact[l] // fact[r] // fact[l - r]

    for i in range(1, k + 1):
        print((comb(n - k + 1, i) * comb(k - 1, i - 1)) % mod)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr ll INF=1e18;
struct edge{
  int to;
  ll cost;
  ll time;
};

vector<edge> g[60];
ll dis[60][2525];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m;
  ll s;
  cin>>n>>m>>s;
  if(s>2500){
    s=2500;
  }
  REP(i, m){
    int u, v;
    ll a, b;
    cin>>u>>v>>a>>b;
    --u;--v;
    g[u].push_back({v, a, b});
    g[v].push_back({u, a, b});
  }
  REP(i, n){
    ll c, d;
    cin>>c>>d;
    g[i].push_back({i, -c, d});
  }
  REP(i, n){
    REP(j, 2501){
      dis[i][j]=INF;
    }
  }
  priority_queue<pair<ll, pll>, vector<pair<ll, pll>>, greater<pair<ll, pll>>> que;
  que.push(make_pair(0ll, pll(0, s)));
  while(que.size()){
    auto zxy=que.top();que.pop();
    ll z=zxy.first;
    auto xy=zxy.second;
    ll x=xy.first, y=xy.second;
    ll tmp=dis[x][y];
    if(z>=tmp){
      continue;
    }
    // DEBUG(x);
    dis[x][y]=z;
    for(auto u : g[x]){
      if(y-u.cost<0){
        continue;
      }
      if(dis[u.to][y-u.cost]<=z+u.time){
        continue;
      }
      que.push(make_pair(z+u.time, pll(u.to, min(y-u.cost, 2500ll))));
    }
  }
  FOR(i, 1, n){
    ll mi=INF;
    REP(j, 2500){
      CHMIN(mi, dis[i][j]);
    }
    cout<<mi<<'\n';
  }
  return 0;
}


Measured memory_bytes: 10412
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
    for(int i=0;i<2;i++){
    	for(int j=0;j<2;j++){
    		for(int k=0;k<2;k++){
    			int num=a;
    			if(i){
    				num+=b;
    			}else{
    				num-=b;
    			}
    			if(j){
    				num+=c;
    			}else{
    				num-=c;
    			}
    			if(k){
    				num+=d;
    			}else{
    				num-=d;
    			}
    			if(num==7){
    				cout <<s[0]<<((i)?"+":"-")<<s[1]<<((j)?"+":"-")<<s[2]<<((k)?"+":"-")<<s[3]<<"=7\n";return 0;
    			}
    		}
    	}
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> L(N, 0);
    for (int i = 0; i < N; i++) cin >> L[i];
    sort(L.begin(), L.end(), greater<int>());
    int sum = 0;
    for (int i = 1; i < N; i++) sum += L[i];
    if (L[0] < sum) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        long[] a=cin.ArrayLong(3,0);
        long n=a[0];
        long k=a[1];
        long q=a[2];
        long[] ans=new long[n];
        for(long i=0;i<q;i++)
        {
            long x=cin.nextLong();
            ans[x-1]++;
            
        }
        for(long i=0;i<n;i++)
        {
           if(ans[i]-q+k>0) Console.WriteLine("Yes");
           else Console.WriteLine("No");
        }
        
        
    }
}



class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 16096
#!/usr/bin/env python3
def num2alpha(num):
    if num <= 26:
        return chr(64+num)
    elif num % 26 == 0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num % 26)


n = int(input())
ans = num2alpha(n)
print(ans.lower())


Measured memory_bytes: 9156
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int Pow(int n, int m);
int Max(int N[], int n);
int Min(int N[], int n);
int Sum(int N[], int n);




int main()
{
	int N = 0, M = 0, X = 0, Y = 0;
	scanf("%d%d%d%d", &N, &M, &X, &Y);

	int x[100] = { 0 };
	int y[100] = { 0 };

	for (int i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}

	for (int i = 0; i < M; i++) {
		scanf("%d", &y[i]);
	}

	if (Max(x, N) < Min(y, M) && Max(x, N) < Y && X < Min(y, M)) printf("No War");
	else printf("War");

	return 0;

}

int Pow(int n, int m) {
	int ret = 1;

	for (int i = 0; i < m; i++) {
		ret *= n;
	}

	return ret;
}

int Max(int N[], int n) {
	int max = N[0];

	for (int i = 0; i < n; i++) {
		max = max < N[i] ? N[i]: max;
	}

	return max;
}

int Min(int N[], int n) {
	int min = N[0];

	for (int i = 0; i < n; i++) {
		min = min > N[i] ? N[i] : min;
	}

	return min;
}

int Sum(int N[], int n) {
	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += N[i];
	}
  
	return 0;
}

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

int main(){
  int a,b,c,d,x,y;
  cin>>a>>b>>c>>d;
  if(a<=b)x=a;
  else x=b;

  if(c<=d)y=c;
  else y=d;
  cout<<x+y;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w,i,j,k;
  scanf("%d %d",&h,&w);
  for(i=0;;i++){
    for(j=0;j<h;j++){
      for(k=0;k<w;k++){
        if(k>0&&k<w-1&&j!=0&&j!=h-1){
          printf(".");
        }else{
        printf("#");
        }
        if(j==h-1&&k==w-1){
          printf("\n");
        }
      }
      printf("\n");
    }
    h=0;
    w=0;
    scanf("%d %d",&h,&w);
    if(h==0&&w==0){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 2140
while True:
    num = input()
    if int(num) == 0: break
    if len(set(num)) == 1:
        print("NA")
        continue
    cnt = 0
    while num != "6174":
        cnt += 1
        L = ''.join(sorted(num))
        S = ''.join(reversed(sorted(num)))
        num = str(int(S) - int(L)).zfill(4)
    print(cnt)



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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int k;
    string s,c;
    cin>>k;
    cin>>s;
    if(k>=s.size())
        cout<<s<<nl;
    else
    {
        for(int i=0; i<k; i++)
            c+=s[i];
        cout<<c;
        cout<<"..."<<nl;
    }
    return 0;
}


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

namespace d
{
    class Program
    {
        const long MOD = 1000000007;

        static void Main(string[] args)
        {
            var nmstr = Console.ReadLine().Split(' ');
            var n = int.Parse(nmstr[0]);
            var m = int.Parse(nmstr[1]);

            var xstr = Console.ReadLine().Split(' ');
            var x = new long[n];
            for (var i = 0; i < n; i++)
            {
                x[i] = long.Parse(xstr[i]);
            }

            var ystr = Console.ReadLine().Split(' ');
            var y = new long[m];
            for (var i = 0; i < m; i++)
            {
                y[i] = long.Parse(ystr[i]);
            }

            var xsum = 0L;
            for (var i = 0; i < n; i++)
            {
                xsum += ((2 * i - n + 1) * x[i]);
            }
            xsum %= MOD;

            var ysum = 0L;
            for (var i = 0; i < m; i++)
            {
                ysum += ((2 * i - m + 1) * y[i]);
            }
            ysum %= MOD;

            var totalArea = (xsum * ysum) % MOD;

            Console.WriteLine(totalArea);
        }
    }
}


Measured memory_bytes: 35792
#include<stdio.h>

int graph[101][101];
int n;

void init(){
	int i, j;
	int u, k, v;
	scanf("%d", &n);
	for( i = 1; i <= n; i++ ){
		for( j = 1; j <= n; j++ ){
			graph[i][j] = 0;
		}
	}
	for( i = 1; i <= n; i++ ){
		scanf("%d", &u);
		scanf("%d", &k);
		for( j = 0; j < k; j++ ){
			scanf("%d", &v);
			graph[i][v] = 1;
		}
	}
	return;
}

void print(){
	int i, j;
	for( i = 1; i <= n; i++ ){
		for( j = 1; j < n; j++ ){
			printf("%d ", graph[i][j]);
		}
		printf("%d\n", graph[i][n]);
	}
	return;
}

int main(){
	init();
	print();
	return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

class UnionFind {
public:
  UnionFind(int size) : size(size) {

    par = vector<int>(size, -1);
  }

  int GetRoot(int v) {
    int root = v;
    while (par[root] >= 0) {
      root = par[root];
    }
    if (root != v) {
      par[v] = root;
    }
    return root;
  }

  bool IsUnion(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    return ra == rb && ra >= 0;
  }

  int GetUnionSize(int a) {
    return -par[GetRoot(a)];
  }

  void Unite(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    if (ra == rb) return;

    if (GetUnionSize(ra) > GetUnionSize(rb)) {
      par[ra] += par[rb];
      par[rb] = ra;
    }
    else {
      par[rb] += par[ra];
      par[ra] = rb;
    }
  }

protected:

  // 親がいれば、親のindexを入れる
  // 親がいなければ、グループのサイズを負にして入れておく（一人なら-1）
  vector<int> par;

  int size;
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> as(M);
  F0R(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    as[i] = { a,b };
  }
  UnionFind uf(N);
  vector<i64> rs(M);
  i64 r = (i64)N * (N - 1) / 2;
  RF0(i, M) {
    rs[i] = r;
    if (!uf.IsUnion(as[i].first, as[i].second)) {
      r -= (i64)uf.GetUnionSize(as[i].first) * uf.GetUnionSize(as[i].second);
      uf.Unite(as[i].first, as[i].second);
    }
  }
  F0R(i, M) {
    cout << rs[i] << newl;
  }
}
#endif


Measured memory_bytes: 5244
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

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

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    if (A == B) {
        cout << A << endl;
        return 0;
    }
    if (A == 0) {
        ll bd = 0;
        while (B >> bd) ++bd;
        ll bxor = 0;
        rep (i, bd) {
            ll n = (1ll << i) * (B / (2ll << i)) + max(0ll, (B % (2ll << i) - (1ll << i) + 1));
            if (n % 2 != 0) {
                bxor |= 1ll << i;
            }
        }
        cout << bxor << endl;
        return 0;
    }
    --A;
    ll ad = 0;
    while (A >> ad) ++ad;
    ll axor = 0;
    rep (i, ad) {
        ll n = (1ll << i) * (A / (2ll << i)) + max(0ll, (A % (2ll << i) - (1ll << i) + 1));
        if (n % 2 != 0) {
            axor |= 1ll << i;
        }
    }
    ll bd = 0;
    while (B >> bd) ++bd;
    ll bxor = 0;
    rep (i, bd) {
        ll n = (1ll << i) * (B / (2ll << i)) + max(0ll, (B % (2ll << i) - (1ll << i) + 1));
        if (n % 2 != 0) {
            bxor |= 1ll << i;
        }
    }
    cout << (bxor ^ axor) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  for(int i=0;i<ty-sy;++i)cout << 'U';
  for(int i=0;i<tx-sx;++i)cout << 'R';
  for(int i=0;i<ty-sy;++i)cout << 'D';
  for(int i=0;i<tx-sx+1;++i)cout << 'L';
  for(int i=0;i<ty-sy+1;++i)cout << 'U';
  for(int i=0;i<tx-sx+1;++i)cout << 'R';
  cout << "DR";
  for(int i=0;i<ty-sy+1;++i)cout << 'D';
  for(int i=0;i<tx-sx+1;++i)cout << 'L';
  cout << 'U' << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
//
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int n=sc.nextInt();
		int paper = n/2;
		if (n%2==1) {
			paper ++;
		}
		
		System.out.println(paper);
		
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
	//----------------------------------------
	//置き場

	//----------------------------------------
}

Measured memory_bytes: 23252
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;



int main(){
  bool flag=false;
  int n;
  cin>>n;
  for(int i=0;i<=n/4;i++){
    if((n-4*i)%7==0) flag=true;
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

const int INF = 10000000;

int main(){
    int n;
    int X[105];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> X[i];
    }
    int ans = INF;
    for(int p = 1; p <= 100; p++){
        int nans = 0;
        for(int i = 0; i < n; i++){
            nans += (X[i] - p) * (X[i] - p);
        }
        ans = min(ans, nans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll r; cin >> r;
  cout << double(3.1415)*2*r << endl;
}


Measured memory_bytes: 3788
// C - Triangular Relationship

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	ll ans;

	if (K % 2 == 1) {
		ans = pow(N / K, 3);
	} else {
		int m = K / 2;
		int t = N / K;
		if (N % K >= m) t++;
		ans = pow(N / K, 3) + pow(t, 3);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3912
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7

#define MOD (LONG)(10e8 + 7)



int main(void) {
	LONG X, K, D;
	cin >> X >> K >> D;
//	X = -7;
//	K = 1;
//	D = 1000;
	X = abs(X);

	LONG wari = X / D;
	LONG wari2 = wari + 1;

	LONG ans = X - wari*D;
	LONG ans2 = abs(X - wari2*D);

	LONG fin;
	if (K <= wari) {
		fin = X - K*D;
	}
	else {
		if ((K-wari) % 2 == 0) {
			fin = X - wari*D;
		}
		else {
			fin = X - wari2*D;
		}
	}

	cout << abs(fin) << endl;

	return 0;
}



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

using namespace std;
#define inc(x, y, i) for (int i = x; i <= y; i++)
#define dec(x, y, i) for (int i = x; i >= y; i--)
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
int main(){
    fastio;
    int r;
    cin >> r;
    double pi = acos(-1);
    cout << 2*pi*r << endl;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
    int N, ans=-1e9;
    cin >> N;
    int F[N][10], P[N][11];

    for(int i=0; i<N; i++){
	for(int j=0; j<10; j++){
	    cin >> F[i][j];
	}
    }

    for(int i=0; i<N; i++){
	for(int j=0; j<11; j++){
	    cin >> P[i][j];
	}
    }

    for(int k=1; k<1024; k++){
	int tmp3=0;
    	for(int i=0; i<N; i++){
	    int tmp=k;
	    int tmp2=0;
    	    for(int j=0; j<10; j++){
    		if((tmp&1) && F[i][j]==1)
		    tmp2++;
    		tmp = tmp>>1;
    	    }
	    tmp3+=P[i][tmp2];
    	}
	ans = max(ans, tmp3);
    }
    cout << ans << endl;
} 



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,cmp;
int main(){
	n=d;
	f(i,1,n){
		ll x=d,y=d;
		if(x==y)cmp++;
		else cmp=0;
		if(cmp==3){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  int value=700;
  if(s[0]=='o')value+=100;
  if(s[1]=='o')value+=100;
  if(s[2]=='o')value+=100;
  P(value);
  return 0;
}


Measured memory_bytes: 256
s = input()

if s[0] != "A":
	print("WA")
	exit(0)

if s[2:len(s)-1].count('C') > 1 or s[2:len(s)-1].count('C') < 1:
	print("WA")
	exit(0)

s = s[1:]
s = s[0] + s[1:len(s)-1].replace("C", "") + s[len(s)-1]

if s.islower():
	print("AC")
else:
	print("WA")

Measured memory_bytes: 3064
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
string S[100001];
map<string,int> ans;
int main(){
	int N;

	scan(N);
	rep(i,N){
		scan(S[i]);
		ans[S[i]]++;
	}
	cout << "AC x "<< ans["AC"]<<endl;
	cout << "WA x "<< ans["WA"]<<endl;
	cout << "TLE x "<< ans["TLE"]<<endl;
	cout << "RE x "<< ans["RE"]<<endl;

	return 0;
}


Measured memory_bytes: 6704
n, k = map(int, input().split())
mod = 10**9 + 7

res = 0
z = n*(n+1)//2
for x in range(k, n+2):
    min_ = (x-1)*x//2
    max_ = z - (n-x)*(n+1-x)//2
    res += max_ - min_ + 1
    res %= mod

print(res)


Measured memory_bytes: 9088
#include <iostream>

using namespace std;

int main() {
	int N;
	while ( cin >> N, N ) {
		bool m[100][100] = {0};
		for (int i = 0; i < N; ++i) {
			int M; cin >> M;
			for (int j = 0; j < M; ++j) {
				int p; cin >> p;
				m[i][p-1] = true;
			}
		}

		bool leak[100] = {0};
		int K; cin >> K;
		for (int i = 0; i < K; ++i) {
			int p; cin >> p;
			leak[p-1] = true;
		}

		int ans = -1;
		for (int i = 0; i < N; ++i) {
			bool f = true;
			for (int j = 0; j < N; ++j) {
				if (leak[j] && !m[i][j]) {
					f = false;
					break;
				}
			}
			if (f) {
				if (ans != -1) {
					ans = -1;
					break;
				}
				ans = i+1;
			}
		}
		cout << ans << endl;
	}
}

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

int main()
{
 	int n;cin>>n;int a[n];
  for(int i = 0; i < n; i++)	cin>>a[i];
  
  int sum = 0;for(int i = 0; i < n; i++)	sum+=a[i];
  int m;cin>>m;
  for(int i = 0; i < m; i++)
  {
    int p,x;cin>>p>>x;
    p--;
    sum-=a[p];
    
    sum+=x;
    cout<<sum<<"\n";
    sum-=x;
    sum+=a[p];
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
ll fac[1000005];
void ok(){
	fac[0] = 1;
	for(int i = 1;i<1000005;i++){
		fac[i] = (fac[i-1]*(i))%N;
	}
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 

        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 

ll nCrModPFermat(ll  n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll i,t,m,c,j,x,y,l,n,k;
    cin>>n;
    cin>>k;
    ll a[n+5];
    for(i=1;i<=n;i++){
    	cin>>a[i];
	}
	ok();
	sort(a+1,a+n+1);
	ll ans = 0;
	for(i=n;i>0;i--){
		if(i-1 >= k-1){
			ll temp = ((a[i]%N)*(nCrModPFermat(i-1,k-1,N))%N)%N;
			ans = (ans%N + temp%N)%N;
//			cout<<ans<<endl;
		}
	}
	for(i=1;i<=n;i++){
		if(n-i >= k-1){
			ll temp = ((a[i]%N)*(nCrModPFermat(n-i,k-1,N))%N)%N;
			ans = (ans%N - temp%N + N)%N;
//			cout<<ans<<temp<<endl;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 8832
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  auto input = readln.split.to!(int[]);
  auto N = input[0], D = input[1];

  auto r = 2*D + 1;
  ((N + r -1) / r).writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> mtn(n);
    
    for (int i = 0; i < n; i++) cin >>mtn[i];
    
    int h_m = mtn[0];
    int ans = 0;
    
    for (int i = 1; i < n; i++){
        if (mtn[i] >= h_m) {
            h_m = mtn[i];
            ans++;
        }
    }
    
    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#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 n, k;
  cin >> n >> k;
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  string s;
  cin >> s;
  vector<int> ctoi(256);
  ctoi['r'] = 2;
  ctoi['c'] = 0;
  ctoi['p'] = 1;
  int ans = 0;
  rep(i, k) {
    vector<int> x;
    for (int j = i; j < n; j += k) {
      x.push_back(ctoi[s[j]]);
    }
    vector<int> dp(2);
    int pre = -1;
    for (int nx : x) {
      vector<int> p(2);
      swap(dp, p);
      dp[0] = max(p[0], p[1]);
      if (pre == nx) {
        dp[1] = p[0] + a[nx];
      } else {
        dp[1] = max(p[0], p[1]) + a[nx];
      }
      pre = nx;
    }
    ans += max(dp[0], dp[1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main()
{
	int n, t, x, y, cur_t = 0, cur_x = 0, cur_y = 0;
	bool answer = true;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> t >> x >> y;

		int dt = abs(t - cur_t);
		int dx = abs(x - cur_x);
		int dy = abs(y - cur_y);

		if (dx + dy > dt) {
			answer = false;
		}

		if ((dx + dy) % 2 != dt % 2) {
			answer = false;
		}
		cur_t = t;
		cur_x = x;
		cur_y = y;
	}

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

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1000000;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;

int main()
{
	boost;
	int n, x;
	cin >> n >> x;
	n = 2 * n - 1;
	if (x == 1 || x == n) OUT("No");
	cout << "Yes\n";
	int half = (n + 1) / 2, prze = half - x;
	if (prze < 0) prze = n + prze;
	int st = n - prze + 1;
	for (int i=1; i<=prze; ++i) cout << st + i - 1 << "\n";
	FOR(i, 1, st-1) cout << i << "\n";
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

	int n,m;
	cin >> n >> m;
	vector<string> a(n),b(m);
	rep(i,n)cin >> a[i];
	rep(i,m)cin >> b[i];

	if(n == m && a == b){
		cout <<  "Yes" << endl;
		return 0;
	}

	rep(i,n-m){
		rep(j,n-m){
			int f = 1;
			rep(ii,m){
				rep(jj,m){
					if(b[ii][jj] != a[ii+i][jj+j])f = 0;
				}
			}
			if(f){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc054.contest.atcoder.jp/tasks/abc054_b

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, int> P;

const int MAX_N = (int) 1e5 + 5;
int N, M;
P D[MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> N >> M;
    for(int i=0;i<N;i++) cin >> D[i].first >> D[i].second;

    sort(D, D+N);

    lint ans = 0;
    for(int i=0;i<N && M;i++){
        ans += D[i].first * min(D[i].second, M);
        M -= min(D[i].second, M);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define CloseIO std::ios::sync_with_stdio(false)
const int N = 4000 + 200;
const ll Mod = 100;
const ll INF = pow(2,32)-1;
int main(){
  int n,k;
  cin>>n>>k;
  int t1,t2 = n/k;
  t1 = t2;
  if(n%k != 0){
    t2+=n%k;
  }
  cout<<abs(t1-t2)<<endl;


  return 0;
}
//abc

Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

const val MOD = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val (a, v) = readLs()
  val (b, w) = readLs()
  val t = readL()
  if (w * t + abs(a - b) <= v * t) {
    println("YES")
  } else {
    println("NO")
  }
}


Measured memory_bytes: 36432
# input

N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(N - 1):
    if a[i] > x:
        ans += a[i] - x
        a[i] = x
    if a[i] + a[i + 1] > x:
        ans += a[i] + a[i + 1] - x
        a[i + 1] -= a[i] + a[i + 1] - x

print(ans)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll res = 0;
    if(a >= k){
        res += k;
    }else{
        res += a;
        k -= a;
        if(b >= k){
            
        }else{
            k -= b;
            if(c >= k){
                res -= k;
            }
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7748
n=gets.to_i
array=gets.split.map(&:to_i).sort
dif=array[-1]-array[0]
border=array[0]
array2=[]
(dif+1).times{
       i=0
       answer=0
       n.times{
           answer+=(border-array[i])**2
           i+=1}
    array2<<answer
     border+=1}

puts array2.min

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

#define M 1000000007
#define int long long int
#define endl "\n"
#define pb push_back
int dp[100001][2];
vector<int> v[100001];

void Indset(int n, int p){
    dp[n][0]=1;
    dp[n][1]=1;
    for(auto c : v[n]){
        if(c!=p){
            Indset(c,n);
            dp[n][0]=(dp[n][0]*(dp[c][1]+dp[c][0]))%M;
            dp[n][1]=(dp[n][1]*dp[c][0])%M;
        }
    }
}

int32_t main(){
    int n,x,y;
    cin>>n;
    for(int i=0; i<n-1; i++){
        cin>>x>>y;
        --x, --y;
        v[x].pb(y);
        v[y].pb(x);
    }
    Indset(0,-1);
    cout<<(dp[0][0]+dp[0][1])%M;
    return 0;
}


Measured memory_bytes: 17356
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define FOR(i, m, n) for(int i = m;i < n;i++)
using LL = long long;
using ULL = unsigned long long;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    int N,x1,c=1;
     cin >> N >>x1;
      rep(i,N-1){
          int x2;
          cin >> x2;
        if (x1 <= x2){
          x1=x2;
        c++;
      }
    }
  cout <<c;
}

Measured memory_bytes: 256
n=int(input())
lista=[0 for i in range(n)]
lista=input().split()
n2=int(input())
listb=[0 for i in range(n2)]
listb=input().split()
cnt=0
for i in range(n2):
    x=0
    
    for j in range(n):
        if listb[i]==lista[j] and x==0:
            x=1
            cnt+=1

print(cnt)


Measured memory_bytes: 6204
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int n , alpha , beta;
	string s,org;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;++i){
		getline(cin , s);
		org=s;
		while(1){
				for(alpha=3;alpha<26;++alpha){
						if(alpha){
							if(26%alpha==0) continue;
						}
					for(beta=0;beta<=26;++beta){
						if (org.find("this" ,0)!=string::npos || org.find("that" , 0)!=string::npos) {
							cout << org << endl;
							goto skip;
						} else {
							for(int k=0;k<26;++k){
							if((s[0]-'a')==(alpha*k+beta)%26){
								for(int l=0;l<s.length();++l){
									for(int m=0;m<26;++m){
										if(isalpha(s[l])){
											int t=s[l]-'a';
											org[l]=(alpha*t+beta)%26+'a';
											}
										}
									}
								}
							}
						}
						
					}
				}	
		}
		skip:;
	}
	return 0;
}

Measured memory_bytes: 1216
while True:
  n, t = input().split()
  if t == "X":
    break

  if "_" in n:
    names = n.split("_")
  else:
    n = list(n)
    for i, c in enumerate(n):
      if c.isupper():
        if i:
          n[i] = "#" + c.lower()
        else:
          n[i] = c.lower()
    names = "".join(n).split("#")

  if t == "U":
    print(*[name.title() for name in names], sep="")
  elif t == "L":
    print(*[name.title() if i !=  0 else name for i, name in enumerate(names)], sep="")
  else:
    print(*names, sep="_")


Measured memory_bytes: 5576
#include <iostream>

using namespace std;

int main(){
  int a,b,c,k,flag;

  cin >> a >> b >> c >> k;
  if(a > b && a > c) flag = 1;
  else if(b > a && b > c) flag =2 ;
  else flag =3 ;

  for(int i;i < k;i++){
    if(flag == 1)a = a * 2;
    else if(flag == 2)b = b * 2;
    else if(flag == 3)c = c * 2;
  }

  cout << a + b + c << endl;
}


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

int cnt[100000];

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n;
    cin>>n;

    for (int i=1; i<100; i++){
        for (int j=1; j<100; j++){
            for (int k=1; k<100; k++){
                cnt[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }

    for (int i=1; i<=n; i++){
        cout<<cnt[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3996