akhauriyash/Code-Regression huggingface dataset:
from collections import Counter

def main():
    N, *A = map(int, open(0).read().split())
    A.sort(reverse=True)
    C = Counter(A)
    ans = 0
    for a in A:
        if C[a] != 0:
            k = (1 << a.bit_length()) - a
            if k in C and C[k] != 0 and not (k == a and C[a] == 1):
                ans += 1
                C[a] -= 1
                C[k] -= 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 33752
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

string my_readln() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto tokens = my_readln.split;
	auto N = tokens[0].to!long;
	long[] a, b, d;
	foreach (i; 0..N)
	{
		auto tokens2 = my_readln.split;
		a ~= tokens2[0].to!long;
		b ~= tokens2[1].to!long;
		d ~= a[$-1] + b[$-1];
	}
	auto index = new ulong[](N);
	makeIndex!"a > b"(d, index);

	long ans;
	foreach (ii, i; index)
	{
		if (ii % 2 == 0)
		{
			ans += a[i];
		}
		else
		{
			ans -= b[i];
		}
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 8572
# 1回目から順に ABC001,ABC002...
# 1000 回目から 1998回目のコンテストを順に ABD001,ABD002...
# 1以上 1998以下の整数 N が与えられるので、
# N回目のコンテストの名前の最初の 3 文字を出力

N = int(input())

if N < 1000:
    print('ABC')
else:
    print('ABD')

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

class Fenwick{
    vector<ll> F;
public:
    Fenwick(int n){
        F.clear();
        F.resize(n+1);
    }
    int inline lsb(int pos){
        return pos & -pos;
    }
    void add(int x, int pos){
        pos++;
        while(pos<F.size()){
            F[pos] += x;
            pos += lsb(pos);
        }
    }
    ll get(int pos){
        pos++;
        ll res = 0;
        while(pos){
            res += F[pos];
            pos -= lsb(pos);
        }
        return res;
    }
    int kth(int k){
        int l=1, r = F.size()-1;
        while(l <= r){
            int m = (l+r)/2;
            int x = get(m);
            if (x < k){
                l = m+1;
            }
            else{
                r = m-1;
            }
        }
        return l;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<vector<int>> edges(n+1);
    FOR(i, n-1){
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }

    Fenwick F(n+1);
    vector<int> nb(n+1);
    int s = 0;
    FOR1(u, n){
        for(int v : edges[u]) {
            nb[u] += v < u;
            if (v < u)
                F.add(n-u+1, u);
        }
        s += nb[u];
    }
//    ll sol = 0;
//    FOR1(l, n){
//        int f = n-l+1;
//        sol += n - l + 1 - s;
//        for(int v : edges[l])
//            if (v > l)
//                s--;
//    }
//    cout << sol << endl;


    ll sol = 0;
    FOR1(l, n){
//        vector<int> nb(n+1);
//        int f = 0;
//        for(int r = l; r<=n; r++){
//            f += - nb[r];
//            sol += f;
//            for(int v : edges[r])
//                nb[v]++;
//        }
        sol += (n - l + 1LL) * (n - l + 2LL) / 2;
//        int x = F.get(n);
//        int y = F.get(l-1);
        sol -= F.get(n) - F.get(l-1);
        for(int v : edges[l])
            if (v > l) {
//                nb[v]--;
                F.add(-(n-v+1), v);
            }

    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 17424
from numpy import *
from scipy import *

n = array(input(), dtype=int)
d = array(input().split(), dtype=int)
h = zeros(24, dtype=int)
h[0] = 1

for x in d:
    h[x] += 1
ans = array(0, dtype=int)
if h[0] >= 2 or h[12] >= 2:
    print(ans)
    exit()
for x in h:
    if x >= 3:
        print(ans)
        exit()

for i in range(12):
    if h[i] >= 2:
        h[24-i] = 2

def dfs(depth, h):
    global ans
    r = 0
    res = inf
    for i in range(1,24):
        r += 1
        if h[i] != 0:
            res = min(res,r)
            r = 0
    res = min(res,r+1)
    ans = max(ans,res)
    if depth == 12:
        return
    if h[depth] == 1:
        h[depth], h[24-depth] = h[24-depth], h[depth]
        dfs(depth+1, h)
        h[depth], h[24-depth] = h[24-depth], h[depth]
    dfs(depth+1, h)

dfs(1, h)
print(ans)


Measured memory_bytes: 21496
from collections import deque, OrderedDict

n = int(input())
edges = [tuple(map(int, input().split())) for _ in range(n-1)]
# print(edges)
tree = [[] for _ in range(n)]
# Zero-based index. グラフを陽に持つ。
edge_color = OrderedDict()  # 辺のタプルをキーにした順序付き辞書
for e in edges:
    a = e[0] - 1
    b = e[1] - 1
    tree[a].append(b)
    tree[b].append(a)
    edge_color[(min(a, b), max(a, b))] = 0

print(max(len(v) for v in tree))

seen = [False] * n  # 踏破
que = deque()
que_append = que.append
que_popleft = que.popleft
start = 0
seen[start] = True
que_append(start)
# ある頂点に接する辺にすでに塗られた色のセット。
v_based_color = [set() for _ in range(n)]
while len(que):
    v = que_popleft()
    color_i = 1  # One-based index.
    for adj in tree[v]:
        if seen[adj]:
            continue
        seen[adj] = True
        que_append(adj)
        while color_i in v_based_color[v]:
            # その頂点からの辺で使われていない色になるまで足す。
            color_i += 1
        edge_color[(min(v, adj), max(v, adj))] = color_i
        # 辺の両端の頂点が触れている色のセットに追加。
        v_based_color[v].add(color_i)
        v_based_color[adj].add(color_i)
        color_i += 1

{print(c) for c in edge_color.values()}


Measured memory_bytes: 95084
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

#def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
# D問題なんてさっさと解いて、いっぱいすやすやしようね( ˘ω˘ )ｽﾔｧ
# ( ˘ω˘ )ｽﾔｧ ( ˘ω˘ )ｽﾔｧ ( ˘ω˘ )ｽﾔｧ ( ˘ω˘ )ｽﾔｧ ( ˘ω˘ )ｽﾔｧ
xx,yy=gsmi

if (xx+yy)%3 != 0 || (2*xx-yy)%3 != 0 || (2*yy-xx)%3 != 0 ||2*xx-yy<0||2*yy-xx<0
  putsend 0
end

#横型
ca=(2*xx-yy)/3
#縦型
cb=(2*yy-xx)/3

def C(a,b)
  if b==0||a==b
    1
  else
    b=a-b if a/2<b
    x=(a-b+1..a).inject(1){|res,i|res*i%MOD}
    y=(1..b).inject(1){|res,i|res*i%MOD}
    require 'openssl'
    yn=OpenSSL::BN.new(y).mod_inverse(MOD)
    x*yn
  end
end

puts C(ca+cb,ca)%MOD

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define pb push_back
#define INF 1000000000000000000
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100;
int cnt[MAXN];

int main()
{
    FAST_IO;

    int n, m;
    cin >> n >> m;

    FOR(i, 1, m ) {
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b+1]--;
    }

    int curr = 0;
    int ans = 0;
    FOR(i, 0, MAXN-1) {
        curr+= cnt[i];
        if (curr == m) ans++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
	unsigned int k;
	string s;

	// input
	cin >> k >> s;

	if ( k < s.length() ) {
		s = s.substr(0, k) + "...";
	}

	// output
	cout << s;
	cout << endl;

	return 0;
}


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

int N, K;
int A[100000];
int B[100000];

int msb(int n)
{
	if (n == 0) return 0;

	int keta = 0;
	while (n > 0)
	{
		keta++;
		n >>= 1;
	}
	return 1 << (keta - 1);
}

signed main()
{
	cin >> N >> K;
	REP(i, N) cin >> A[i] >> B[i];

	int cost = 0;
	REP(i, N)
	{
		if ((K & A[i]) == A[i])
		{
			cost += B[i];
		}
	}
	int max = cost;

	if (K > 0)
	{
		int kk = msb(K);
		while (true)
		{
			int n = kk - 1;

			cost = 0;
			REP(i, N)
			{
				if ((n & A[i]) == A[i])
				{
					cost += B[i];
				}
			}
			max = MAX(max, cost);

			int m = msb(K - kk);
			kk += m;
			if (m == 0)
			{
				break;
			}
		}
	}

	cout << max;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define N (int)1e5
#define F first
#define S second
typedef pair<int, int> P;
int n, m, ans;
int l[3 * N + 1], r[3 * N + 1];
P lr[3 * N + 1];
int bit[N + 1];
int sum(int i, int *b)
{
	int s = 0;
	while (i > 0)
	{
		s += b[i];
		i = i & (i - 1);
	}
	return s;
}
void add(int i, int x, int *b)
{
	while (i <= m)
	{
		b[i] += x;
		i += i & -i;
	}
}
int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> lr[i].S >> lr[i].F;
		l[i] = lr[i].S;
		r[i] = lr[i].F;
		lr[i].F = lr[i].F - lr[i].S + 1;
	}
	sort(lr, lr + n);
	int p1 = 0, p2 = 0;
	for (int i = 1; i <= m; i++)
	{
		ans = 0;
		p2 = lower_bound(lr, lr + n, make_pair(i, 0)) - lr;
		ans = n - p2;
		for (int j = p1; j < p2; j++)
		{
		    add(lr[j].S, 1, bit);
			add(lr[j].F + lr[j].S, -1, bit);
		}
		p1 = p2;
		for (int j = 0; j <= m; j += i)
		{
			ans += sum(j , bit);
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 6016
N = int(input())
A = list(map(int, input().split()))

l = len(A)
f = [0] * l


f[0] = 0
flag=0
if A[0] == 1:
    flag = 1

for i in range(1, l):
    if A[0] == 1 and f[i-1]==0:
        if A[i] == i+1:
            f[i] = 0
        else:
            f[i] = 1
    elif f[i-1] != 0:
        if A[i] == i - f[i-1] + 1:
            f[i] = f[i-1]
        else:
            f[i] = f[i-1] + 1 
    else:
        if A[i] == 1:
            f[i] = i
        else:
            f[i] = 0

if f[l-1]==0 and flag==0:
    print(int(-1))
    exit(0)

print(f[l-1])

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

const int mod = 1000000007;

int main() {
    long long N, K;
    cin >> N >> K;
    long long ans = 0;
    for (long long i = K; i < N+2; i++) {
        ans += (N-i+1)*i+1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=605;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int sq[200005];
bitset<maxn*maxn> A,B;
vector<int> child[maxn*maxn];
bitset<maxn*maxn> vis;

void dfs(int u,bool f){
	//cout<<u<<' '<<f<<endl;
	vis[u]=1;
	if(f) A[u]=1;
	else A[u]=0;
	for(int v:child[u]) if(!vis[v]){
		dfs(v,!f);
	}
}
void go(int n,int d){
	REP(i,n*n) child[i].clear();
	for(int i=0;i*i+i*i<=d;i++){
		int dx=i,dy=sq[d-i*i];
		if(dy==-1) continue;
		//cout<<dx<<' '<<dy<<endl;	
		REP(x,n) REP(y,n){
			if(0<=x+dx&&x+dx<n&&0<=y+dy&&y+dy<n){
				child[x*n+y].pb((x+dx)*n+y+dy);
				child[(x+dx)*n+y+dy].pb(x*n+y);
			}
			if(0<=x+dy&&x+dy<n&&0<=y+dx&&y+dx<n){
				child[x*n+y].pb((x+dy)*n+y+dx);
				child[(x+dy)*n+y+dx].pb(x*n+y);
			}
			if(0<=x-dx&&x-dx<n&&0<=y+dy&&y+dy<n){
				child[x*n+y].pb((x-dx)*n+y+dy);
				child[(x-dx)*n+y+dy].pb(x*n+y);
			}
			if(0<=x-dy&&x-dy<n&&0<=y+dx&&y+dx<n){
				child[x*n+y].pb((x-dy)*n+y+dx);
				child[(x-dy)*n+y+dx].pb(x*n+y);
			}
		}
	}
	//cout<<"OAO"<<endl;
	vis=0;
	REP(i,n*n) if(!vis[i]) dfs(i,0);
	//cout<<"OAO"<<endl;
}

int32_t main()
{
	REP(i,200005) sq[i]=-1;
	for(int i=0;i*i<200005;i++) sq[i*i]=i;
	int n,d1,d2;
	cin>>n>>d1>>d2;
	go(2*n,d1);
	B=A;
	go(2*n,d2);
	int cnt[4]={0};
	REP(i,4*n*n) cnt[A[i]*2+B[i]]++;
	int id=0;
	REP(i,4) if(cnt[id]<cnt[i]) id=i;

	//REP(i,16) cout<<A[i];
//	cout<<'\n';
//	REP(i,16) cout<<B[i];
//	cout<<'\n';

	int cc=n*n;

	n<<=1;
	REP(i,n*n) if(A[i]*2+B[i]==id){
		if(!cc) return 0;
		cc--;
		cout<<i%n<<' '<<i/n<<'\n';
	}
}




Measured memory_bytes: 75648
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	class B{
		int[][] a;
		String name;

		B(int[][] a, String name){
			this.a=a;
			this.name=name;
		}
	}

	int[][] A={{1, 1}, {1, 1}};
	int[][] B={{1}, {1}, {1}, {1}};
	int[][] C={{1, 1, 1, 1}};
	int[][] D={{0, 1}, {1, 1}, {1, 0}};
	int[][] E={{1, 1, 0}, {0, 1, 1}};
	int[][] F={{1, 0}, {1, 1}, {0, 1}};
	int[][] G={{0, 1, 1}, {1, 1, 0}};

	int[][] field;

	int n=8;

	void run(){
		LinkedList<B> blocks=new LinkedList<B>();
		blocks.add(new B(A, "A"));
		blocks.add(new B(B, "B"));
		blocks.add(new B(C, "C"));
		blocks.add(new B(D, "D"));
		blocks.add(new B(E, "E"));
		blocks.add(new B(F, "F"));
		blocks.add(new B(G, "G"));

		sc=new Scanner(System.in);
		for(; sc.hasNextLine();){
			field=new int[n][n];
			for(int j=0; j<n; j++){
				String s=sc.nextLine();
				for(int i=0; i<n; i++){
					if(s.charAt(i)=='1')
						field[j][i]=1;
				}
			}
			boolean f=false;
			for(int j=0; j<n; j++){
				for(int i=0; i<n; i++){
					for(B b : blocks){
						if(match(b, i, j)){
							println(b.name);
							f=true;
							break;
						}
					}
					if(f)
						break;
				}
				if(f)
					break;
			}
//			println("a");
			if(!sc.hasNextLine())
				break;
			sc.nextLine();
	//		println("b");
		}
		sc.close();
	}

	boolean match(B b, int x, int y){
		int[][] a=b.a;
		for(int j=0; j<a.length; j++){
			for(int i=0; i<a[0].length; i++){
				int x2=x+i;
				int y2=y+j;
				if(x2<0||x2>=n||y2<0||y2>=n)
					return false;
				if(a[j][i]==1&&field[y2][x2]==0)
					return false;
			}
		}
		return true;
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N,*A,i,count=0;
    scanf("%d",&N);
    A = (int*)malloc(sizeof(int)*N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    while(1){
        for(i=0;i<N;i++){
            if(A[i]%2==0){
                A[i] /= 2;
            }else{
                printf("%d\n",count);
                return 0;
            }
        }
        count++;
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>//Menagerie
using namespace std;
char dat[100005];
bool zz[100005];
int main()
{
	int n;
	scanf("%d%s",&n,dat);
	dat[0];
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<2;j++)
		{
			zz[0]=i;
			zz[1]=j;
			for(int k=1;k<n-1;k++)
			{
				zz[k+1]=zz[k-1]^zz[k]^(dat[k]=='x');
			}
			if((dat[n-1]=='x')==zz[n-2]^zz[n-1]^zz[0]&&(dat[0]=='x')==(zz[n-1]^zz[0]^zz[1]))
			{
				for(int k=0;k<n;k++)
				{
					printf("%c",zz[k]?'W':'S');
				}
				printf("\n");
				return 0;
			}
		}
	}
	printf("-1\n");
	return 0;
}

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

void Main() {
  int H, W, N;
  cin >> H >> W >> N;

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

  int m[H][W];
  int h = 0, w = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < a[i]; j++) {
      m[h][w] = i + 1;
      if (h & 1) {
        if (w == 0) h++;
        else w--;
      } else {
        if (w == W - 1) h++;
        else w++;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << m[i][j];
      if (j < W - 1) cout << " ";
    }
    cout << endl;
  }
}

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



Measured memory_bytes: 384
#include <stdio.h> 
int main(){ 
int sum = 0;
 char ch; 
while(true) { while((ch = getchar()) != '\n'){ sum += ch - '0'; 
} if(sum == 0) break;
 else{ printf("%d\n",sum); 
sum = 0; 

}

 } 
} 


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> L(n);
    for(int i = 0; i < n; i++) cin >> L[i];
    sort(L.begin(), L.end());
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            int left = abs(L[i] - L[j]);
            int right = L[i] + L[j];
            ans += lower_bound(L.begin() + j + 1, L.end(), right) - upper_bound(L.begin() + j + 1, L.end(), left);

        }
    }
    cout << ans << endl;
    return 0;
}



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


int main(){
    ll n;ll a[10001],b[10001];
    cin>>n;
    ll asum=0;ll bsum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];asum+=a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];bsum+=b[i];
    }
    ll t=0;ll g=0;
    for(int i=0;i<n;i++){
        if(a[i]>=b[i])t+=(a[i]-b[i]);
        else g+=(b[i]-a[i]+1)/2;
    }
    ll q=bsum-asum;
    if(q>=g&&q>=t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int MAXN = 1e5 + 10;
vector <int> a[MAXN];
int used[MAXN];
vector <int> v;
void dfs(int x, int p) {
	used[x] = 1;
	v.pb(x);
	for (int i = 0; i < a[x].size(); i++) { 
		int to = a[x][i];
	if (used[to] == true) {
			continue;	
		}
		dfs(to, x);
		return;
	}
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		a[x].pb(y);
		a[y].pb(x);
	}
	dfs(1, -1);
	reverse(v.begin(), v.end());
	v.pop_back();
	dfs(1, -1);
	
	printf("%d\n", v.size());
	for (auto i: v) {
		printf("%d ", i);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

bool G[10][10]; //隣接行列

int main(){
  ll N,M,i,a,b;
  ll res = 0;
  cin >> N >> M;
  for(i=0;i<=M-1;i++){
    cin >> a >> b;
    a--;
    b--;
    G[a][b] = true;
    G[b][a] = true;
  }
  ll ord[N];
  
  for(i=0;i<=N-1;i++)
    ord[i] = i;
    
  do{
    if(ord[0] != 0) break;
    bool x = true;
    for(i=0;i<=N-2;i++){
      ll from = ord[i];
      ll to = ord[i+1];
      if(!G[from][to]) x = false;
    }
    if(x) res++;
  }while(next_permutation(ord,ord+N));

  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <climits>

using namespace std;
 
int main()
{
    int X,Y,Z;
    cin >> X >> Y >> Z;
   
    int n=(int)(X-Z)/(Y+Z);
	cout<<n<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int diff = (h2 - h1) * 60 + m2 - m1;
	cout << diff - k << endl;

	return 0;
}


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

int main() {
  long a,b;
  cin >> a >> b;
  if(a*b<=0)cout << "Zero";
  else if(a<0){
    if((b-a)%2==0)cout << "Negative";
    else cout << "Positive";
  }
  else cout << "Positive";
}




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

int main()
{
    int A,B,C;
    cin >> A;
    cin >> B; 
    cin >> C;
    
    int tasty;
    if(C <= A+B+1) {
        cout << B+C;
    } else {
        cout << 1+B+A+B;
    }
}


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

#define int long long
#define fi first
#define se second
#define pb push_back

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

int mx = 1e9;
int n, k, s;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> k >> s;
	if(k == n){
		for(int i = 1; i <= n; i++) cout << s << " ";
		return 0;
	}
	for(int i = 1; i <= k; i++) cout << s << " ";
	if(s == mx) for(int i = k + 1; i <= n; i++) cout << 1 << " ";
	else for(int i = k + 1; i <= n; i++) cout << mx << " ";
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    char a; 
    cin >> a ;

    if(a>='A' && a<='Z')
     cout << 'A'<< endl ;
    else 
     cout << 'a' << endl ;

        return 0; 
}

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

#define FastIO ios::sync_with_stdio(0);cin.tie(0);

typedef long long ll;

int main()
{
    FastIO;
    string s;
    cin>>s;
    ll cnt=0;
    ll _max=0;
    for(ll i=0; i<s.size(); i++)
    {
        if(s[i]=='R')
        {
            cnt++;
        }
        else
        {
            cnt=0;
        }
        _max=max(_max,cnt);
    }
    cout<<_max<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

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


struct RangeTree{
    // xの各値がyのソート済み配列を持つ
    vector<vector<int>>seg;
    vector<int>x;
    int sz;
    RangeTree(vector<pair<int,int>> a){
        sz=1;
        while((int)a.size()>sz)sz<<=1;
        sort(begin(a),end(a));
        if(a.size())x.push_back(a[0].first);
        for(auto &p:a)if(x.back()!=p.first)x.push_back(p.first);
        while(x.size()<sz)x.push_back(INF);
        seg.resize(2*sz);
        int pos=0;
        for(auto &p:a){
            if(x[pos]!=p.first)pos++;
            seg[pos+sz].push_back(p.second);
        }
        for(int i=sz-1;i>0;i--){
            seg[i].resize(seg[2*i].size()+seg[2*i+1].size());
            merge(begin(seg[2*i]),end(seg[2*i]),begin(seg[2*i+1]),end(seg[2*i+1]),begin(seg[i]));
        }
    }
    // [x1,x2),[y1,y2)
    int count(int x1,int y1,int x2,int y2){
        int l=lower_bound(begin(x),end(x),x1)-begin(x),r=lower_bound(begin(x),end(x),x2)-begin(x);
        l+=sz,r+=sz;
        int ret=0;
        for(;l<r;l>>=1,r>>=1){
            if(l&1){
                ret+=lower_bound(begin(seg[l]),end(seg[l]),y2)-lower_bound(begin(seg[l]),end(seg[l]),y1);
                l++;
            }
            if(r&1){
                r--;
                ret+=lower_bound(begin(seg[r]),end(seg[r]),y2)-lower_bound(begin(seg[r]),end(seg[r]),y1);
            }
        }
        return ret;
    }
};

int c[500010];
map<int,int> pre;

signed main(){

    int n,q;cin>>n>>q;
    rep(i,n) cin>>c[i];

    vector<pair<int,int>> d;
    rep(i,n){
        if(pre.count(c[i])) d.push_back({i,pre[c[i]]});
       pre[c[i]]=i;
    }

    RangeTree seg(d);

    while(q--){
        int l,r;cin>>l>>r;l--;

        int ans=r-l-seg.count(l,l,r,r);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 101984
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int q = sc.nextInt();
			if ((n | q) == 0)
				break;
			UnionFind uf = new UnionFind(n);
			if (n != 1) {
				for (int i = 2; i <= n; i++) {
					int p = sc.nextInt();
					uf.par[i] = p;
				}
			}
			long ans = 0;
			for (int i = 0; i < q; i++) {
				String t = sc.next();
				int v = sc.nextInt();
				if (t.equals("M"))
					uf.mark[v] = true;
				else
					ans += uf.find(v);
			}
			System.out.println(ans);
		}
	}
}

class UnionFind {
	public int par[];
	public boolean mark[];

	UnionFind(int n) {
		par = new int[n + 1];
		mark = new boolean[n + 1];
		mark[0] = true;
		mark[1] = true;
		par[1] = 1;
	}

	public int find(int x) {
		while (true) {
			if (mark[x]) {
				return x;
			} else {
				x = par[x];
			}
		}
	}
}

Measured memory_bytes: 15000
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

#define MAXCHAR 255
#define ll long long

using namespace std;
const ll dividend = 1000000007;
const ll limit = pow(10, 18);
const ll bigNum = pow(10, 9);

ll funcComb(int n, int k)
{
	ll output = 1;
	int sum = n + k;
	vector<int> dividends;
	for (int i = 0; i < k; i++)
	{
		dividends.push_back(k - i);
	}
	for (int i = 0; i < k; i++)
	{
		output *= sum - i;
		for (auto it = dividends.begin(); it != dividends.end(); it++)
		{
			if (*it == 0)
				continue;
			if (output % *it == 0)
			{
				output /= *it;
				*it = 0;
			}
		}
		if (output > dividend)
		{
			output %= dividend;
		}
	}

	return output;
}

vector<vector<char>> inputs;
vector<vector<pair<int, int>>> xArray;
vector<vector<pair<int, int>>> coordinatesInArea;
int H, W, Ch, Cw, Dh, Dw;

void createAreaVec()
{
	for (int i = 0; i < H; i++)
	{
		int area = 0;
		xArray.push_back(vector<pair<int, int>>());
		for (int j = 0; j < W; j++)
		{
			if (inputs[i][j] == '#')
			{
				area++;
				continue;
			}
			xArray[i].push_back(pair<int, int>(j, area));
		}
	}

	for (int j = 0; j < W; j++)
	{
		for (int i = 0; i < H; i++)
		{

		}
	}
}

int calcJumps()
{
	return 0;
}

int getMinimum()
{
	return 0;
}

int main()
{
	long long a, b, c, d, e;
	cin >> a >> b >> c >> d;
	e = a*c;
	if (a*d > e)
		e = a*d;
	if (b*c > e)
		e = b*c;
	if (b*d > e)
		e = b*d;
	cout << e << endl;

	return 0;
}



Measured memory_bytes: 3628
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_list = [0] * N
ac_cnt, wa_cnt = 0, 0
for i in range(M):
    num, res = input().split(' ')
    num = int(num) - 1
    if num not in ac_set:
        if res == 'AC':
            ac_cnt += 1
            wa_cnt += wa_cnt_list[num]
            ac_set.add(num)
        else:
            wa_cnt_list[num] += 1
print(ac_cnt, wa_cnt)

Measured memory_bytes: 18064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  
  I(N);
  N %= 10;
  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
    P("hon");
  } else if (N == 0 || N == 1 || N == 6 || N == 8) {
    P("pon");
  } else {
    P("bon");
  }

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

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; }

long long N;
vector<long long> a(3), b(3);

const int MAX = 30000000;
long long dp[MAX];

long long calc(vector<long long> sei, vector<long long> obj, long long M) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < sei.size(); ++i) {
        for (int v = 0; v + sei[i] <= M; ++v) {
            chmax(dp[v+sei[i]], dp[v] + obj[i]);
        }
    }
    long long res = M;
    for (int v = 0; v <= M; ++v) chmax(res, dp[v] + M-v);
    return res;
}

long long solve() {
    N = calc(a, b, N);
    N = calc(b, a, N);
    return N;
}

int main() {
    cin >> N;
    for (int i = 0; i < 3; ++i) cin >> a[i];
    for (int i = 0; i < 3; ++i) cin >> b[i];
    cout << solve() << endl;
}

Measured memory_bytes: 234752
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#include <set>
using namespace std;
int c[505];
int s[505];
int f[505];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
        cin>>c[i]>>s[i]>>f[i];
    for(int i=1;i<=n;i++){
        int ans=0;
        for(int j=i;j<n;j++){
            if(ans<s[j])
                ans=s[j];
            if(ans%f[j]!=0)
                ans=ans+f[j]-ans%f[j];
            ans+=c[j];
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

fun main( args: Array<String> ) {
    val sc = Scanner( System.`in` )
    val a = sc.nextInt()
    val b = sc.nextInt()
    val r = find( a, b )
    val out = PrintWriter( System.out )
    out.println( "${r.size} ${r[0].size}" )
    for ( ca in r ) {
        out.println( String( ca ) )
    }
    out.close()
}

fun find( a: Int, b: Int ): ArrayList<CharArray> {
    val r = ArrayList<CharArray>()
    addColor( a - 1, '.', '#', r )
    addColor( b - 1, '#', '.', r )
    return r
}

fun addColor( cnt: Int, mc: Char, bc: Char, r: ArrayList<CharArray> ) {
    val br = CharArray(100, { bc } )
    r.add( br )
    var left = cnt
    while ( left > 0 ) {
        val row = CharArray( 100 )
        for ( i in row.indices step 2 ) {
            row[i] = if ( left > 0 ) mc else bc
            row[i + 1] = bc
            left --
        }
        r.add( row )
        r.add( br )
    }
}


Measured memory_bytes: 35964
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

queue = deque()


def main():
    k = int(input())
    queue.extend([1, 2, 3, 4, 5, 6, 7, 8, 9])

    for i in range(k-1):
        x = queue[0]
        queue.popleft()
        if x % 10 != 0:
            queue.append(10 * x + x % 10 - 1)
        queue.append(10 * x + x % 10)
        if x % 10 != 9:
            queue.append(10 * x + x % 10 + 1)
    print(queue[0])


if __name__ == '__main__':
    main()


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int n, ans = 0;
    ll d, x, y;
    cin >> n >> d;
    while (n--) {
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  if(N%2==0){cout<<N<<endl;}
  else{cout<<N*2<<endl;}
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(i != 0 && i != n-1){
      if( (p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])) {
        ans += 1;
     }
   }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string color;
  int i;
  
  for (i = 0; i < N; i++){
    cin >> color;
    if (color == "Y"){
      cout << "Four" << endl;
      break;
      }
    }
  
  if (i == N && color != "Y")
    cout << "Three" <<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() {
  string s;
  cin >> s;

  int ans = 1000;
  for(char c = 'a'; c <= 'z'; c++) {
    int cnt = 0;
    string ss = s;
    bool flg = true;
    for(int i=0;i<ss.size();i++) {
      if(ss[i] != c) flg = false;
    }
    if(flg) {
      cout << 0 << endl;
      return 0;
    };
    while(ss.size() > 0) {
      bool flg = true;
      string next = "";
      for(int i=0;i<ss.size()-1;i++) {
        char next_c = ss[i] == c ? ss[i] : ss[i+1];
        if(next_c != c) flg = false;

        next.push_back(next_c);
      }
      ss = next;
      cnt++;
      if(flg) break;
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3504
a = []
a.append(int(input()))
for i in range(1000010):
    if a[i]%2 == 0:
        buf = a[i]//2
        if buf in a:
            m = i + 2
            break
        a.append(buf)
    else:
        buf = a[i]*3 + 1
        if buf in a:
            m = i + 2
            break
        a.append(buf)
print(m)


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(int argc, char**argv){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a*b > c*d){
        cout << a*b << endl;
    }else{
        cout << c*d << endl;
    }

    return 0;
}





















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,a,b,c,ans=0,cnt=0;
string s,t;
int main(){
	cin >> a;
	if(a<1000){
		cout << "ABC" << endl;
	}else{
		cout << "ABD" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
	int N,K;
    cin >> N >> K;
    if(N%K==0){cout << 0;}else{cout << 1;};
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,b) loop(i,0,b)
using namespace std;
typedef queue<int> IntStack;
int main(){
    IntStack I;
    int n,q,sum=0;
    cin>>n>>q;
    char name[100001][10];
    int time[100001];
    rep(i,n) cin>>name[i]>>time[i];
    rep(i,n) I.push(i);
    while(!I.empty()){
        int k = I.front();I.pop();
        int &t=time[k];
        if(t>q) t-=q,sum+=q,I.push(k);
        else{
            sum+=t;
            cout<<name[k]<<" "<<sum<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
vector<int> fact, inv_fact;
int add(int x, int y) {
	x += y;
	if (x >= mod) {
		return x - mod;
	}
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) {
		return x + mod;
	}
	return x;
}
void add_self(int& x, int y) {
	x = add(x, y);
}
void sub_self(int& x, int y) {
	x = sub(x, y);
}
int mult(int x, int y) {
	return 1ll * x * y % mod;
}
int bin_pow(int x, int y) {
	if (y == 0) {
		return 1;
	}
	if (y % 2 == 0) {
		return bin_pow(mult(x, x), y / 2);
	}
	return mult(x, bin_pow(x, y - 1));
}
int inv(int x) {
	return bin_pow(x, mod - 2);
}
int C(int a, int b) {
	if (a < b) {
		return 0;
	}
	return mult(mult(fact[a], inv_fact[b]), inv_fact[a - b]);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	fact.resize(n + 1);
	inv_fact.resize(n + 1);
	fact[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fact[i] = mult(fact[i - 1], i);
	}
	for (int i = 0; i <= n; ++i) {
		inv_fact[i] = inv(fact[i]);
		assert(mult(fact[i], inv_fact[i]) == 1);
	}
	int answer = 0;
	debug(C(n, 2));
	for (int i = 0; i < n; ++i) {
		add_self(answer, mult(C(i, k - 1), a[i]));
		sub_self(answer, mult(C(n - 1 - i, k - 1), a[i]));
	}
	cout << answer << '\n';
	assert(answer >= 0 && answer < mod);
 	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
char x[100007];
ll a,b,c,ans,N,M,T,dp[100007][17],co=1000000007;
int main(){
	scanf("%s",x+1); N=strlen(x+1);
	ll p=1;
	dp[N+1][0]=1;
	for (int i=N;i>=1;i--){
		if (x[i]=='?') rep(k,0,9) rep(j,0,12) dp[i][(j+p*k)%13]=(dp[i][(j+p*k)%13]+dp[i+1][j])%co;
		else rep(j,0,12) dp[i][(j+p*(x[i]-'0'))%13]=dp[i+1][j];
		p=p*10%13;
	}
	printf("%lld\n",dp[1][5]);
	return 0;
}


Measured memory_bytes: 13568
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,L;
int A[210];
vector<P> v;

signed main(){
	cin>>N>>L;
	int sum2=0;
	REP(i,N){
		A[i]=i+L;
		sum2+=A[i];
	}
	for(int i=0;i<N;i++){
		int sum=0;
		for(int j=0;j<N;j++){
			if(i!=j){
				sum+=A[j];
			}
		}
		v.push_back(make_pair(abs(sum2-sum),sum));
	}
	sort(v.begin(),v.end());
	cout<<v[0].second<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100010
#define INF 100000010
using namespace std;
int main(){
	long long n,k,i,j,l,a[N],qdh[N],pos[N],unpos[N],maxs=-INF,mins=INF,tem,tem2;
	cin>>n>>k;
	qdh[0]=0;
	a[0]=0;
	pos[0]=0;
	unpos[0]=0;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>0)
		{
			pos[i]=pos[i-1]+a[i];
			unpos[i]=unpos[i-1];
		}
		else
		{
			unpos[i]=unpos[i-1]+a[i];
			pos[i]=pos[i-1];
		}
		qdh[i]=qdh[i-1]+a[i];
	}
	for(i=0;i+k<=n;i++)
	{
		tem=qdh[i+k]-qdh[i];
		tem2=pos[i+k]-pos[i-1];
		maxs=max(maxs,tem+pos[n]-tem2);
		tem2=unpos[i+k]-unpos[i-1];
		mins=min(mins,tem+unpos[n]-tem2);
	}
	cout<<max(maxs,qdh[n]-mins)<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000000;
int main(void){
    int n;
    cin >> n;
    set<char> s;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        s.insert(c);
    }
    string ans;
    if (s.size() == 3) ans = "Three";
    else ans = "Four";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    string w;
    cin >> w;
    map<char, int> s;
    for (int i = 0; i < w.length(); i++)
    {
        s[w[i]]++;
    }

    bool flag = true;
    for (map<char, int>::iterator y = s.begin(); y != s.end(); ++y)
    {
        if (s[y->first] % 2 == 1)
        {
            flag = false;
        }
    }
    if (flag == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){
	
}

char s[MAXN];
int a[MAXN];

int work(int p, int q){
	a[0] = p, a[1] = q;
	for(int i = 1; i <= n; i++){
		if (s[i] == 'o'){
			if (a[i]) a[i+1] = 1 - a[i-1];
			else a[i+1] = a[i-1];
		}
		else{
			if (a[i] == 0) a[i+1] = 1 - a[i-1];
			else a[i+1] = a[i-1];
		}
	}
	if (a[n] == a[0] && a[n+1] == a[1]){
		for(int i = 0; i < n; i++)
			putchar(a[i] ? 'W' : 'S');
		puts("");
		return 1;
	}
	else
		return 0;
}

void solve(int casi){
	scanf("%d", &n);
	scanf("%s", s);
	s[n] = s[0], s[n+1] = s[1];
	for(int i = 0; i <= 1; i++)
		for(int j = 0; j <= 1; j++)
			if (work(i,j))
				return ;
	puts("-1");
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




Measured memory_bytes: 2816