akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Scanner;

public class Main 
{
	static class C implements Comparator<Node>
	{

		@Override
		public int compare(Node o1, Node o2) 
		{
			return o1.e.size() - o2.e.size();
		}
		
	}
	
	static class Node
	{
		int i;
		boolean visited = false;
		HashSet<Node> e = new HashSet<Node>();
		int fil;
		public Node(int i0)
		{
			i = i0;
		}
	}

	static Node[] nd;
	static int[] d;
	static int cur;
	static int[] a;
	static int scr = 0;
	
	static void go(Node n, int prev)
	{
		d[n.i] = a[cur];
		n.fil = a[cur];
		scr += Math.min(prev, n.fil);
		cur--;
		n.visited = true;
		for(Node e : n.e)
		{
			if(!e.visited)
			{
				go(e, n.fil);
			}
		}
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		nd = new Node[n];
		
		for(int i = 0; i < n; i++)
			nd[i]=new Node(i);
		
		for(int i = 0; i < n-1; i++)
		{
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			nd[a].e.add(nd[b]);
			nd[b].e.add(nd[a]);
		}
		
		C c = new C();
		Arrays.sort(nd,c);
		
		a = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextInt();
			sum += a[i];
		}
		
		d = new int[n];
		Arrays.sort(a);
		cur = n-1;
		go(nd[0], 0);
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++)
		{
			if(i>0)sb.append(" ");
			sb.append(d[i]);
		}
		System.out.println(scr);
//		System.out.println("xx " + (sum - a[n-1]));
		System.out.println(sb);
			
	}

}


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

#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define tiiii tuple<int,int,int,int>
#define popcount __builtin_popcountll

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

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return s;}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    RREP(i, d-1, -1) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    int cnt=1;
    REP(i, 0, n) {
        if (a[i] == cnt) ++cnt;
    }
    if (cnt==1) cout << -1;
    else cout << n-cnt+1;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
	class Program
	{
		static void Main(string[] args)
		{
			string data = Console.ReadLine();
			string[] arraydata = data.Split(' ');

			int n = int.Parse(arraydata[0]);
			int a = int.Parse(arraydata[1]);
			int b = int.Parse(arraydata[2]);
			bool check = true;
			if(n < 1 || n > 100)
			{
				Console.Write("Ｎは1～100までの整数です。");
				check = false;
			}
			if (a < 0 || a > n)
			{
				Console.Write("Ａは０以上でＮより小さい整数です。");
				check = false;
			}
			if (b < 0 || b > n)
			{
				Console.Write("Ｂは０以上でＮより小さい整数です。");
				check = false;
			}
			if(check)
			{
				int max = 0;
				if(a == b)
				{
					max = a;
				}
				else if (a>b) 
				{
					max = b;
				}
				else
				{
					max = a;
				}
				int min = 0;
				if(n < a+b)
				{
					min = a+b-n;	
				}
				Console.Write("{0} {1}",max,min);
			}
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[N - 1] - a[0] << endl;
}


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

#pragma GCC optimize ("O3")
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<int, int> mi;
typedef map<ll, ll> ml;
#define fr(i, n) for (int i = 0; i < n; i++)
#define frn(i, k, n) for (int i = k; i < n; i++)
#define rf(i, n) for (int i = n-1; i >= 0; i--)
#define rfn(i, k, n) for (int i = n-1; i >= k; i--)

const int N = 5e5 + 5;
const int M = 998244353;
ll fact[N], inv[N];
vector<bool> prime;
vector<int> drow4{1, -1,  0,  0};
vector<int> dcol4{0,  0, -1,  1};
vector<int> drow8{0,  1,  1,  1,  0, -1, -1, -1};
vector<int> dcol8{1,  1,  0, -1, -1, -1,  0,  1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "debug statement : " << *it << " = " << a << endl;
    err(++it, args...);
} 

ll powerModM(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res=(res * x)%M; 
        y = y >> 1; 
        x = (x *x) % M;
    } 
    return res % M; 
}

ll power(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x*x;
    } 
    return res; 
}
 
void preCalcFactorial(int n){
    fact[0] = inv[0] = 1;
    for(ll i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % M;
        inv[i] = powerModM(fact[i], M - 2);
    }
}
 
ll nCr(ll n,ll r){
    ll ans = ((fact[n] * inv[r]) % M + M) % M;
    ans = ((ans * inv[n-r]) % M + M) % M;
    return ans;
}

void sieve(int n) { 
    prime.resize(n+1, true);
    prime[1] = false;
    for (int p = 2; p * p <= n; p++){ 
        if (prime[p] == true) {
            for (int i = p*p; i <= n; i += p) 
                prime[i] = false; 
        } 
    }
} 

class BIT{
public:
    int size;
    vector<int> v;
    BIT(int s){
        size = s;
        v.resize(s, 0);
    }
    void update(int i, int delta){
        while(i < size){
            v[i] += delta;
            i += i & (-i);
        }
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= i & (-i);
        }
        return s;
    }
};

void testCase(){
	int n, count = 0;
	cin >> n;
	vi v(n);
	fr(i, n) cin >> v[i];
	fr(i, n) {
		if(i % 2 == 0 && v[i] % 2 == 1) count++;
	}
	cout << count << endl;
}

int main(){
    FAST
    int t = 1;
    // cin >> t;
    while(t--){
        testCase();
    }
}


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

int main() {
	int N; cin >> N;
	int a;
	long count=0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		while (a % 2 == 0 && a > 0)count++, a /= 2;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())

S = input()
T = input()

MODN = 1000000007

# t:tate, y;yoko
pat = []
i = 0
while i < N:
  if S[i] == T[i]:
    pat.append('t')
    i += 1
  else:
    pat.append('y')
    i += 2

#print("".join(pat))

cnt = 3 if pat[0] == 't' else 6

for i in range(1,len(pat)):
  if (pat[i-1], pat[i]) == ('t', 't'):
    cnt = cnt * 2 % MODN
  elif (pat[i-1], pat[i]) == ('t', 'y'):
    cnt = cnt * 2 % MODN
  elif (pat[i-1], pat[i]) == ('y', 't'):
    cnt = cnt
  elif (pat[i-1], pat[i]) == ('y', 'y'):
    cnt = cnt * 3 % MODN
  else:
    print("Error") # impossible

print(cnt)

Measured memory_bytes: 38256
n  = STDIN.gets.to_i

a = STDIN.gets.split(" ").map do |s|
    s.to_i
end

sum = a.inject(:+)

diff = sum - 2 * a[0]
mindiff_abs = diff.abs
(1..n-2).to_a.each do |i|
    new_diff = diff - 2 * a[i]
    mindiff_abs = (new_diff.abs < mindiff_abs) ? new_diff.abs : mindiff_abs
    diff = new_diff
end

STDOUT.puts mindiff_abs


Measured memory_bytes: 16900
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ccomplex>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>


#define SZ(X) ((X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (LL I = 0; I < N; ++I)
#define REPP(I, A, B) for (LL I = (A); I < (B); ++I)
#define RI(X) scanf("%lld", &(X))
#define RII(X, Y) scanf("%lld%lld", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define DRI(X) LL (X); scanf("%lld", &X)
#define DRII(X, Y) LL X, Y; scanf("%lld%lld", &X, &Y)
#define DRIII(X, Y, Z) LL X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define IO(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout);
typedef long long LL;
typedef unsigned long long ull;
using namespace std;

LL Ar[100000],N,A,B;
bool sus(LL t){
    LL As=0;
    REP(i,N){
        if(Ar[i]-B*t<0)break;
        As+=(Ar[i]-B*t+A-1)/A;
    }return As<=t;
}

int main(){
    RIII(N,A,B);
    A-=B;
    REP(i,N)RI(Ar[i]);
    sort(Ar,Ar+N,[=](LL a,LL b){return b<a;});
    LL l=0,r=1e9+10;
    while(l<r-1){
        (sus((l+r)/2)?r:l)=(l+r)/2;
    }
    printf("%lld\n",r);
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int h, w;
  string s;

  scanf("%d %d",&h, &w);

  int num = 0;
  REP(i, h) {
    cin >> s;
    while (s.size()) {
      int sh = s.find("#");
      if (sh != -1) {
        num++;
        s.erase(0, sh + 1);
      } else break;
    }
  }
  if (num == h + w - 1) printf("Possible\n");
  else printf("Impossible\n");

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
long long n,m,i,a[105],l;
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();
   	for(i=1;i<=n;i++)
   		a[i]=read();
   	sort(a+1,a+n+1);
   	for(i=1;i<n;i++)
   		if(a[i]+1<a[i+1]){
			printf("Impossible\n");
			return 0;
		}
   	l=a[n];
   	a[0]=-1;
   	if(l&1){
   		if(a[1]!=(l+1>>1)||a[2]==a[3]){
   			printf("Impossible\n");
   			return 0;
   		}
   		for(i=1;i<=n;i++)
   			if(a[i]!=a[i-1]&&a[i]!=a[i+1]){
   				printf("Impossible\n");	
   				return 0;
   			}
   		printf("Possible\n");
   	}
   	else{
   		if(a[1]!=(l>>1)||a[1]==a[2]){
   			printf("Impossible\n");
   			return 0;
   		}
		for(i=2;i<=n;i++)
			if(a[i]!=a[i-1]&&a[i]!=a[i+1]){
   				printf("Impossible\n");	
   				return 0;
   			}
   		printf("Possible\n");
	}
    return 0;
}

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

using namespace std;

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

  long n;
  cin >> n;

  long i = 0;
  long sum = 0;
  while (n > sum) {
    i ++;
    sum += i;
  }

  cout << i << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi =vector<vi>;

int main(){
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]) cout << "Yes" << endl;
  else cout <<"No"<<endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.ans = n*(n-1)//2
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
    
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        sx = self.size(x)
        sy = self.size(y)
        self.ans += sx*(sx-1)//2 + sy*(sy-1)//2
        self.ans -= (sx+sy)*(sx+sy-1)//2
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = UnionFind(N)
ans = [uf.ans]
pp = [list(map(int, input().split())) for i in range(M)]
for i in range(M, 1, -1):
    uf.union(pp[i-1][0]-1, pp[i-1][1]-1)
    ans.append(uf.ans)

print('\n'.join(map(str, reversed(ans))))

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

#define INF (1LL<<60)
typedef pair<long long, long long> P;

int N;
long long D;
long long X[30], Y[30];
int n2;
long long seg[1<<25];
vector<P> M1, M2;

inline void dfs(int i, int until, vector<P> &p, long long a, long long b) {
  if (i >= until) {
    p.push_back(P(a, b));
    return;
  }
  dfs(i+1, until, p, a, b);
  dfs(i+1, until, p, a-X[i], b-Y[i]);
  dfs(i+1, until, p, a+X[i], b+Y[i]);
}

inline void update(int k, long long a) {
  k += n2 - 1;
  seg[k] = a;
  while (k > 0) {
    k = (k-1) / 2;
    seg[k] = max(seg[k*2+1], seg[k*2+2]);
  }
}

inline long long query(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return -INF;
  if (a <= l && r <= b) return seg[k];
  return max(query(a, b, k*2 + 1, l, (l+r) / 2),
             query(a, b, k*2 + 2, (l+r) / 2, r));
}

int main() {
  cin >> N >> D;
  for (int i=0; i<N; i++) {
    cin >> X[i] >> Y[i];
  }
  dfs(0, N/2, M1, 0, 0);
  dfs(N/2, N, M2, 0, 0);
  sort(M1.begin(), M1.end());
  sort(M2.begin(), M2.end());

  n2 = 1;
  while (n2 < M2.size()) n2 *= 2;
  for (int i=0; i<2*n2; i++) seg[i] = -INF;
  for (int i=0; i<M2.size(); i++) update(i, M2[i].second);

  long long m = 0;
  for (auto p : M1) {
    long long x = p.first, y = p.second;
    int lo = lower_bound(M2.begin(), M2.end(), P(-x-D, -INF)) - M2.begin();
    int hi = lower_bound(M2.begin(), M2.end(), P(-x+D,  INF)) - M2.begin();
    m = max(m, y+query(lo, hi, 0, 0, n2));
  }
  cout << m << "\n";
  return 0;
}

Measured memory_bytes: 713476
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            long n = in.nextLong();
            int i = 1;
            int j = 1;
            long min = 1 + n - 2;
            long aa = 0, bb = 0;
            for (int a = 2; a <= Math.sqrt(n); a++) {
                if (n % a != 0){
                    continue;
                }
                long b = n/a;
                long moves = a + b - 2;
                if (moves < min){
                    min = moves;
                    aa = a;
                    bb = b;
                }
            }
            out.println(min);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


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

bool is_right(char ch)
{
  static const char right[11] = { 'y', 'u', 'i', 'o', 'p',
                            'h', 'j', 'k', 'l',
                             'n', 'm', };
  for (int i = 0; i < 11; ++i)
  {
    if (right[i] == ch) return true;
  }
  return false;
}

int main(void)
{
  cin >> noskipws;
  char buf_ch;
  int sum = 0;
  bool now_right;
  while (true)
  {
    cin >> buf_ch;
    if (buf_ch == '#') break;

    sum = 0;
    now_right = is_right(buf_ch);
    while (true)
    {
      cin >> buf_ch;
      if (buf_ch == '\n') break;

      if (now_right xor is_right(buf_ch) )
      {
        ++sum;
        now_right = is_right(buf_ch);
      }
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

int main(){

  string sa,sb,sc;
  cin >> sa>>sb>>sc;

  map<char,int> discard;
  map<char,int> limit;

  discard['a']=0;
  discard['b']=0;
  discard['c']=0;

  limit['a']=sa.length();
  limit['b']=sb.length();
  limit['c']=sc.length();

  char turn = 'a';

  while(true){
    if(discard[turn]==limit[turn]) break;
    if(turn=='a'){turn=sa[discard[turn]];discard['a']++;}
    else if(turn=='b'){turn=sb[discard[turn]];discard['b']++;}
    else if(turn=='c'){turn=sc[discard[turn]];discard['c']++;}
  }

  if(turn=='a'){cout << 'A' <<endl;}
  else if(turn=='b'){cout << 'B' <<endl;}
  else if(turn=='c'){cout << 'C' <<endl;}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int k, q;
  cin >> k >> q;
  vl d(k);
  REP(i, k) { cin >> d[i]; }
  REP(i, q) {
    int n, x, m;
    cin >> n >> x >> m;
    vl cum(k + 1), count(k + 1);
    cum[0] = 0LL;
    count[0] = 0LL;
    REP(i, k) {
      cum[i + 1] = cum[i] + (d[i] % m);
      count[i + 1] = count[i];
      if (d[i] % m == 0) {
        count[i + 1]++;
      }
    }
    x %= m;
    ll length = x + ((n - 1) / k) * cum[k] + cum[(n - 1) % k];
    ll zero = ((n - 1) / k) * count[k] + count[(n - 1) % k];
    ll ans = n - 1 - (length / m) - zero;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <numeric>

int main()
{
    std::size_t k;
    std::cin >> k;
    std::size_t ans = {};
    for (std::size_t a=1; a <= k; ++a)
        for (std::size_t b=1; b <= k; ++b)
            for (std::size_t c=1; c <= k; ++c)
                ans += std::gcd(std::gcd(a, b), c); 
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
string s[200010];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> s[i];
	sort(s, s + n);
	int ans = 1;
	for (int i = 1; i < n; i++)
	{
		if (s[i] != s[i - 1]) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 9892
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(t, a) for (auto t : a)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T = int> inline T in() {T x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a = in(), b = in(), c = in();


  if ((a * b) % 2 * c % 2 == 0) {
    print(0);
  } else {
    print(min(a * b, min(b * c, a * c)));
  }

  return 0;
}



Measured memory_bytes: 256
sub f{my($u,$t,$p)=@_;push@$t,$u;$_-$p&&f($_,$t^R,$u)for@$u}@a=$,=$";$#a=<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f 1,b;map{$s=--$x;$s+3>$.or$a[$_]||=$s+=3for@$_}@b>$./3&@0>$./3?(0,b):(@b>@0?b:0)x2;print map$_||3*++$z,@a

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

int main(){
    int a;
    cin >> a;
    string b;
    cin >> b;
    string c,d;
    c = b.substr(0,(a/2));
    d = b.substr((a/2));
    int e;
    e = c.compare(d);
    if(e == 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
	int n, a[20], b[20], c[20], satis=0;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n-1;i++) cin>>c[i];
	
	for(int i=0;i<n;i++) satis+=b[a[i]-1];
	for(int i=0;i<n-1;i++){
		if(a[i+1]==a[i]+1) satis+=c[a[i]-1];
	}
	
	cout<<satis;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int n;
  int max=0;
  int sum=0;
  int tmp;
  scanf("%d\n",&n);
  for(int i=0; i<n;i++){
    scanf("%d",&tmp);
    if(max < tmp) max = tmp;
    sum += tmp;
  }
  sum -= max;
  printf("%s",(max<sum)?"Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;

int main(){
	long long N, M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	long long B[N],A[N];
	priority_queue<P, vector<P>, greater<P> > que;
	for (int i=0; i<N; i++) {
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
		que.push(P(A[i], B[i]));
	}
	long long nokori = M, res = 0;
	for (int i=0; i<N; i++) {
		P p = que.top(); que.pop();
		res += min(nokori, p.second)*p.first;
		nokori -= p.second;
		if (nokori<=0) break;
	}
	cout << res << "\n";

}


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

//https://atcoder.jp/contests/abc124/tasks/abc124_c

using namespace std;


int main(){

 string cad;
 cin>>cad;
 int len = cad.length();
 bool ban;
 int sum = 0;
 ( cad[0] == '1' ) ? ban = true : ban = false;
 for(int i = 1 ; i < len ; i++){
  if(ban){
   if(cad[i] != '0') sum++;
    ban = false;
  }else{
   if(cad[i] != '1') sum++;
   ban = true;
  }
 }
 cout<<sum<<endl;
 return 0;
}

Measured memory_bytes: 512
#C
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
people = [0] * n
for i in a:
    people[i-1] += 1
# print(people)
for i in people:
    if k <= q - i:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 13748
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) {
			return 0;
		} else {
			vector<double> vd;
			double mi = INF;
			REP(i, n)
			{
				ll a = i;
				ll b = n - i;
				double t = sqrt(a*a + b*b);
				mi = min(mi, fabs(t - m));
			}
			cout << mi << endl;
		}
	}
}

Measured memory_bytes: 3240
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int n1 = Integer.parseInt(s.substring(0,1));
        int n2 = Integer.parseInt(s.substring(1,2));
        int n3 = Integer.parseInt(s.substring(2,3));
        int n4 = Integer.parseInt(s.substring(3,4));
        if(n1 + n2 + n3 + n4 == 7){
        	System.out.println(n1 + "+" + n2 + "+" + n3 + "+" + n4 + "=7");
        }else if(n1 + n2 - n3 + n4 == 7){
        	System.out.println(n1 + "+" + n2 + "-" + n3 + "+" + n4 + "=7");
        }else if(n1 + n2 + n3 - n4 == 7){
        	System.out.println(n1 + "+" + n2 + "+" + n3 + "-" + n4 + "=7");
        }else if(n1 + n2 - n3 - n4 == 7){
        	System.out.println(n1 + "+" + n2 + "-" + n3 + "-" + n4 + "=7");
        }else if(n1 - n2 + n3 + n4 == 7){
        	System.out.println(n1 + "-" + n2 + "+" + n3 + "+" + n4 + "=7");
        }else if(n1 - n2 - n3 + n4 == 7){
        	System.out.println(n1 + "-" + n2 + "-" + n3 + "+" + n4 + "=7");
        }else if(n1 - n2 + n3 - n4 == 7){
        	System.out.println(n1 + "-" + n2 + "+" + n3 + "-" + n4 + "=7");
        }else if(n1 - n2 - n3 - n4 == 7){
        	System.out.println(n1 + "-" + n2 + "-" + n3 + "-" + n4 + "=7");
        }
    }
}

Measured memory_bytes: 39484
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;

using namespace std;

vector<int> ve[MAXN];
int par[MAXN];
bool notroot[MAXN], vis[MAXN];
vector<int> topo;

void dfs(int u) {
  vis[u] = 1;
  for (int v : ve[u])
    if (!vis[v])
      dfs(v);
  topo.pb(u);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int r = 1;
  for (int i = 0; i < n-1+m; i++) {
    int u, v;
    cin >> u >> v;
    ve[u].pb(v);
    notroot[v] = 1;
    while (notroot[r])
      r++;
  }
  par[0] = 0;
  dfs(r);
  reverse(all(topo));
  for (int k : topo)
    for (int v : ve[k])
      par[v] = k;
  for (int i = 1; i <= n; i++)
    cout << par[i] << '\n';
  return 0;
}

Measured memory_bytes: 12152
package main

import (
  "fmt"
)

func abs(a int) int {
  if a > 0 {
    return a
  }
  return -a
}

func main() {
  var N int
  fmt.Scan(&N)
  
  h := make([]int, N)
  dp := make([]int, N)

  for i := 0; i < N; i++ {
    fmt.Scan(&h[i])
    if i > 0 {
      dp[i] = abs(h[i-1] - h[i]) + dp[i-1]
      if i > 1 {
        if p := abs(h[i-2] - h[i]) + dp[i-2]; dp[i] > p {
          dp[i] = p
        }
      }
    }
  }
  fmt.Println(dp[N-1])
}

Measured memory_bytes: 5504
#include<iostream>
#include<cmath>
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){

  double q;

  while(cin >> q,q!=-1){
    double x=q/2;
    while(abs(x*x*x-q)>0.00001*q)
    x=x-(x*x*x-q)/(3*x*x);

    printf("%.6lf",x);
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int n,q,a[maxn],cnt[maxn];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		cnt[a[i]]++;
		sum+=a[i];
	}
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		sum+=cnt[b]*(c-b);
		cout<<sum<<endl;
		cnt[c]+=cnt[b];
		cnt[b]=0;
	}
	return 0;
}

Measured memory_bytes: 5180
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define ll long long 
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
using namespace std;
using namespace std::chrono;

int solve(int dp[],int n,int h,pii a[])
{

	if(h<=0)
		return 0;
	if(dp[h]!=-1)
		return dp[h];
	int m=INT_MAX;
	in(n)
	{
		m=min(m,a[i].S+solve(dp,n,h-a[i].F,a));
	}
	return dp[h]=m;

}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int h,n;
	cin>>h>>n;
	pii a[n];
	in(n)
	{
		cin>>a[i].F>>a[i].S;
	}
	int dp[h+1];
	memset(dp,-1,sizeof(dp));
	// in(h)
	// 	cout<<dp[i];
	// cout<<endl;
	int ans=solve(dp,n,h,a);
	cout<<ans;
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m;
    cin >> n >> m;
    int ac = 0,wa = 0;
    map<int,int> mp;
    for (int i = 0;i < m;++i) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "WA") {
            if (mp[p] >= 0) mp[p]++;
        } else {
            if (mp[p] >= 0) {
                ac++;
                wa += mp[p];
                mp[p] = -1;
            }
        }
    }
    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var s = Console.ReadLine().Split('/').Select(x => int.Parse(x)).ToArray();
        if (s[0] <= 2019)
        {
            if (s[1] <= 4)
            {
                if (s[2] <= 30)
                {
                    Console.WriteLine("Heisei");
                    return;
                }
            }
        }

        Console.WriteLine("TBD");
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    long long int a[n+2],min=1000000008;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    int i=1;
    while((i+k-1)<=n){
        if((a[i+k-1]-a[i])<min)min=(a[i+k-1]-a[i]);
        i++;
    }
    cout<<min;
}

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


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

    cout<< n/3 <<endl;


    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}



Measured memory_bytes: 2700
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	a, b, n = map(int, sys.stdin.readline().split())
	if n < b:
		print(int((n/b - int(n/b))*a))
	else:
		print(int(((b-1)/b - int((b-1)/b))*a))

	


main()

Measured memory_bytes: 9908
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long gcd(long long a,long long b){if(b==0)return a;return gcd(b,a%b);}
long long lcm(long long a,long long b){return a*b/gcd(a,b);}
int mod_pow(long long a,long long n,long long p){if(n == 1){return a%p;}if(n%2==1){return(a*mod_pow(a,n-1,p))%p;}long long t=mod_pow(a,n/2,p);return (t*t)%p;}
long long mod(long long v,long long p){long long res=v%p;if(res<0){res+=p;}return res;}

template < typename T > void coutVector(vector<T> v){for(int i=0;i<int(v.size());++i){if(i>0)cout<<" "<<v[i];else cout<<v[i];}cout<<endl;}
template < typename T > void coutVectorWithEndl(vector<T> v){for(int i=0;i<int(v.size());++i){cout<<v[i]<<endl;}}
template < typename T > vector<T> cinVector(int n) {vector<T> res(n);for(int i=0;i<n;++i){cin>>res[i];}return res;}
const int MAX = 510000;
const ll MOD = 1e9+7;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
/*
4/N = 1/i + 1/j + 1/k
4ijk = jkN + kiN + ijN
k(4ij - jN - iN) = ijN
k = ijN / (4ij - jN - iN)
*/
int main() {
    int N; cin >> N;
    for (ll i = 1; i < 3501; ++i) {
        for (ll j = 1; j < 3501; ++j) {
            ll p = i * j * N;
            ll q = (4*i*j - j*N - i*N);
            if (q == 0) continue;
            ll k = p/q;
            if (k <= 0) continue;
            if (4*i*j*k == j*k*N + k*i*N + i*j*N) {
                cout << i << " " << j << " " << k;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                       *
 *          Fortis Fortuna Adiuvat                                       * 
 *                          "Fortune Favours the bold"                   *
 *                                                                       *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define vll vector<int>
#define pb push_back
#define pll pair<int, int>
#define w(t) int t; cin >> t; while(t--)
#define print(x,y) cout << x << " " << y << endl
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define setbits(x) __builtin_popcountll(x)
#define endl "\n"

template <typename T>
void write(vector<T> &a) {        
    for(auto it = a.begin(); it != a.end(); it++)
        cout << *it << " ";
    cout << endl;}
void random(int nMin, int nMax, int n){
    srand(time(0));
    for(int i = 0; i < n; i++){
        double var = nMin + (int)((double)rand() / ((double)RAND_MAX+1) * (nMax-nMin+1));cout << var << " ";}cout << endl;
}
///////////Helper Functions///////////


////////////Main Method///////////////
int32_t main()
{
//////////////////////////////////////////////////////////
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cout << setprecision(15);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
//////////////////// Code Here ///////////////////////////    
{
    double n, d; cin >> n >> d; 
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        double x, y; cin >> x >> y;

        double dist = ( (x*x) + (y*y) ) ;
        dist = sqrt(dist) ;

        if(dist <= d) 
            count++ ;
    }
    cout << count << endl;
}    
return 0 ;
}

Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    for(int i=0; i < q; i++){
        cin >> a.at(i);
    }
    vector<int> h(n, k - q);
    for(int i = 0; i<q; i++){
        h.at(a.at(i) - 1) += 1;
    }
    for(int i=0; i<n; i++){
        if(h.at(i) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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 INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
ll comb(ll n, ll r){
  if (r*2>n) r=n-r;
  ll x=1, y=1;
  reps(i,1,r+1){ x *= (n-i+1); y *= i; }
  return x / y;
}


int main(){
  int n, m; cin >> n >> m;
  vector<int> in(n,0), out(n,0);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    if(a==1) in[b]=1;
    if(b==1) in[a]=1;
    if(a==n) out[b]=1;
    if(b==n) out[a]=1;
  }
  rep(i,n) if(in[i]==1 && out[i]==1){ cout << "POSSIBLE"; return 0; }
  cout << "IMPOSSIBLE";
  
  return 0;
}


Measured memory_bytes: 1792
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        (mut a,b,mut c,d): (usize, usize, usize, usize)
    };

    loop {
        if c <= b {
            println!("Yes");
            return;
        }
        c -= b;

        if a <= d {
            println!("No");
            return;
        }

        a -= d;
    }
}


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

using namespace std;

typedef long long int64;
const int mod = 1e9 + 9;

typedef vector< int > vec;
typedef vector< vec > mat;

mat operator*(const mat A, const mat B)
{
  mat ret(A.size(), vec(B[0].size(), 0));
  for(int i = 0; i < A.size(); i++) {
    for(int j = 0; j < B[0].size(); j++) {
      for(int k = 0; k < B.size(); k++) {
        (ret[i][j] += 1LL * A[i][k] * B[k][j] % mod) %= mod;
      }
    }
  }
  return (ret);
}

mat operator^(mat A, int64 n)
{
  mat ret = mat(A.size(), vec(A.size(), 0));
  for(int i = 0; i < A.size(); i++) ret[i][i] = 1;
  while(n > 0) {
    if(n & 1) (ret = ret * A);
    A = A * A;
    n >>= 1LL;
  }
  return (ret);
}

int main()
{
  int64 W, H, N;
  int cc = 1;
  while(cin >> W >> H >> N, W) {
    map< int64, vector< int > > vs;
    vs.emplace(H, vector< int >());
    for(int i = 0; i < N; i++) {
      int64 x, y;
      cin >> x >> y;
      vs[y].push_back(x);
    }
    mat ma(W, vec(W, 0));
    for(int i = 0; i < W; i++) {
      for(int j = max(0, i - 1); j < min(W, i + 2LL); j++) ma[i][j] = 1;
    }
    mat beet(W, vec(1, 0));
    beet[0][0] = 1;
    int64 rev = 1;
    for(auto &p : vs) {
      beet = (ma ^ (p.first - rev)) * beet;
      for(auto &q : p.second) beet[q - 1][0] = 0;
      rev = p.first;
    }
    cout << "Case " << cc++ << ": " << beet[W - 1][0] << endl;
  }
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(ll X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[15];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int main() {


	int A = getint(), B = getint(), Q = getint();
	ll s[100100], t[100100];
	s[0] = -1e12;
	t[0] = -1e12;
	s[A + 1] = 1e12;
	t[B + 1] = 1e12;
	rep1(i, A) s[i] = getint();
	rep1(i, B) t[i] = getint();

	rep(i, Q) {
		ll x = getint();

		auto sp = lower_bound(s, s + A + 2, x);
		ll s1 = *(sp - 1);
		ll s2 = *sp;
		auto tp = lower_bound(t, t + B + 2, x);
		ll t1 = *(tp - 1);
		ll t2 = *tp;

		ll saishou = 1e13;
		saishou = min(saishou, abs(min(s1, t1) - x));
		saishou = min(saishou, abs(max(s2, t2) - x));
		ll k1 = abs(s1 - x);
		ll k2 = abs(t2 - x);
		saishou = min(saishou, k1 + k2 + min(k1, k2));
		ll k3 = abs(t1 - x);
		ll k4 = abs(s2 - x);
		saishou = min(saishou, k3 + k4 + min(k3, k4));

		putint(saishou);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4096