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

public class Main{
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String X = scan.next();
		String Y = scan.next();
		int intX = Character.getNumericValue(X.charAt(0));
		int intY = Character.getNumericValue(Y.charAt(0));
		if (intX < intY) {
			System.out.println("<");
		} else if (intX > intY){
			System.out.println(">");
		} else {
			System.out.println("=");
		}
	}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll t,n,a,b,c,i,j,k,f;
string s;
ll arr[2000050];
int main()
{
    scanf("%lld",&n);
    j=0;
    if(n%2==1)
    	printf("0");
    else
    {
    	n/=2;
    	a=n/5;
    	while(a>0){
    		j+=a;
    		a/=5;
    	}
    	printf("%lld",j);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;

typedef vector<double> vd;
typedef vector<vd> mat;
double eps=1e-9;
vd solve(mat a,vd b){
	int H=a.size(),W=a[0].size();
	bool used[101]={};
	rep(j,W){
		int i=0;
		while(i<H&&(used[i]||abs(a[i][j])<eps)) i++;
		if(i==H) continue;
		used[i]=1;
		double A=a[i][j];
		rep(l,W) a[i][l]/=A;
		b[i]/=A;
		rep(k,H){
			if(k==i) continue;
			double c=-a[k][j];
			rep(l,W) a[k][l]+=a[i][l]*c;
			b[k]+=b[i]*c;
		}
	}
	return b;
}
mat pro(mat a,mat b){
	int N=a.size();
	mat c(N,vd(N,0));
	rep(i,N) rep(j,N) rep(k,N) c[i][j]+=a[i][k]*b[k][j];
	return c;
}
mat ex(mat x,int p){
	int N=x.size();
	mat a(N,vd(N,0));
	rep(i,N) a[i][i]=1;
	while(p){
		if(p%2) a=pro(a,x);
		x=pro(x,x);
		p/=2;
	}
	return a;
}

double dp[11][101];
double p[101];
int main(){
	int S,n,k;
	cin>>S>>n>>k;
	if(S<0) S=-S;
	if(n==1&&S%k!=0){
		puts("-1");
		return 0;
	}
	dp[0][0]=1;
	rep(i,k) rep(j,n*k+1) rep1(l,n) if(dp[i][j]) dp[i+1][j+l]+=dp[i][j]/n;
	rep(i,n*k+1) p[i]=dp[k][i];
	int N=n*k;
	mat a(N,vd(N,0));
	vd b(N,0);
	rep1(i,N-1){
		rep1(j,N){
			a[i][abs(i-j)]+=p[j];
		}
		a[i][i]-=1;
		b[i]=-1;
	}
	a[0][0]=1,b[0]=0;
	b=solve(a,b);
	if(S<N){
		printf("%.12f\n",b[S]);
		return 0;
	}
	mat M(N+1,vd(N+1,0));
	rep(i,N) M[0][i]=p[i+1];
	M[0][N]=1;
	rep(i,N-1) M[i+1][i]=1;
	M[N][N]=1;
	reverse(all(b));
	b.pb(1);
	M=ex(M,S-N+1);
	double ans=0;
	rep(i,N+1) ans+=M[0][i]*b[i];
	printf("%.12f\n",ans);

}

Measured memory_bytes: 1816
(* べき乗 *)
let rec ( ** ) a n =
  if n = 0 then 1
  else if n mod 2 = 1 then a * a ** (n - 1)
  else let t = a ** (n / 2) in t * t

let () =
  let n = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let ans = n ** 3 in
  print_int ans;
  print_newline ()

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int h ,k;
  cin>>h>>k;
  ll sum=0;
  int arr[h];
  for(int i=0;i<h;i++)
  {
     cin>>arr[i];
  }
  sort(arr,arr+h);
  for(int i=0;i<h-k;i++)
  {
    sum+=arr[i];
  }
  cout<<sum;
  return 0;
}

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

const int INF = 1e9 + 5;

int main() {
	int n;
	cin >> n;
	int x;
	vector<int> height;
	for(int i=0; i<n; i++) {
		cin >> x;
		height.push_back(x);
	}
	vector<int> sum(n,INF);
	sum[0] = 0;
	sum[1] = abs(height[0] - height[1]);
	for(int i=2; i<n; i++) {
			sum[i] = min(
				sum[i-1]+abs(height[i] - height[i-1]) 
				,sum[i-2]+abs(height[i] - height[i-2])
				);
	}
	cout << sum[n-1];
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const lb PI=3.14159265359;

int main(){

  ll n;cin>>n;

  ll mi=INF;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ll ma=max(to_string(i).size(),to_string(n/i).size());
      chmin(mi,ma);
    }
  }

  out(mi);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	private int pat;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine() == true) {
			String str = sc.nextLine();
			if (str.equals("0 0")) break;
			
			String[] params = str.split(" ");
			int num = Integer.parseInt(params[0]);
			int sum = Integer.parseInt(params[1]);
			
			pat = 0;
			for (int i = 0; i < 10; i++) {
				calc(i, 0, (num - 1), sum);
			}
			
			System.out.println(pat);
		}
	}
	
	public void calc(int d, int t, int n, int s) {
		int tsum = d + t;
		if (tsum > s) return;

		if (n == 0) {
			if (tsum == s) pat++;
			else return;
		}
		
		for (int i = (d + 1); i < 10; i++) {
			calc(i, tsum, (n - 1), s);
		}
	}
}

Measured memory_bytes: 26284
m = int(input())

import math


s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		if (i+1) not in s:
			s.append(i+1)
		if m//(i+1) not in s:
			s.append(m//(i+1))
s.sort()

n = math.floor(math.log10(m))
a = 0
b = 0

for i in range(len(s)):
	a = math.floor(math.log10(s[i]))
	b = math.floor(math.log10(m//s[i]))
	n= min(n,max(a,b))


print(n+1)


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math/big"
)

func main() {
	var N int
	fmt.Scanf("%v", &N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%v", &A[i])
	}

	numR := 0
	numG := 0
	numB := 0
	
	if A[0] != 0 {
		fmt.Printf("0\n")
		return
	}

	// 最初の一人はRとする
	numR = 1
	//var pat uint64 = 3
	var pat = big.NewInt(3)
	for i := 1; i < N; i++ {
		cand := 0
		var candp *int
		if A[i] == numR {
			cand++
			candp = &numR
		}
		if A[i] == numG {
			cand++
			candp = &numG
		}
		if A[i] == numB {
			cand++
			candp = &numB
		}
		if cand == 0 {
			fmt.Printf("0\n")
			return
		}
		//fmt.Printf("cand=%v\n", cand)
		pat.Mul(pat, big.NewInt(int64(cand)))
		*candp++
	}

	fmt.Printf("%v\n", pat.Mod(pat, big.NewInt(1000000007)))

}


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

int main(void)
{
    long long int a;
    long long int cnt = 0;
    cin >> a;
    for (long long int i = 1; i <= a; i++) {
        if (i % 15 != 0 && i % 5 != 0 && i % 3 != 0) cnt += i;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <stack>
#include <deque>
#include <queue>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
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; }

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

	int n;
	cin >> n;
	vector<ll> a(n+1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<ll> b(n + 1);
	b[0] = 0;
	for (int i = 0; i < n; i++) {
		b[i + 1] = 2 * a[i] - b[i];
	}
	vector<ll> ans(n);
	ans[0] = (b[0] + b[n]) / 2;
	for (int i = 0; i < n-1; i++) {
		ans[i + 1] = 2 * a[i] - ans[i];
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3712
#include <stdio.h>

#define min(a, b) ((a) > (b) ? (b) : (a))

int main(void) {
  int coins_500, coins_100, coins_50;
  int target;
  FILE *fp;
  fp = stdin;
  char line[7];
  if(!fgets(line, 7, fp)) return 0;
  sscanf(line, "%d", &coins_500);
  if(!fgets(line, 7, fp)) return 0;
  sscanf(line, "%d", &coins_100);
  if(!fgets(line, 7, fp)) return 0;
  sscanf(line, "%d", &coins_50);
  if(!fgets(line, 7, fp)) return 0;
  sscanf(line, "%d", &target);
  int i;
  int cnt = 0;
  int max_500 = min(target/500, coins_500);
  for(i = max_500; i>=0; i--) {
    int res = target - i*500;
    int max_100 = min(res/100, coins_100);
    int min_50 = (res - max_100*100)/50;
    if(coins_50 < min_50) continue;
    cnt += min(max_100, (coins_50 - min_50)/2)+1;
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
const ll MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);

	string k;
	ll d;
	cin >> k >> d;

	vector<vvl> dp;
	dp.assign(sz(k), vvl(d, vl(2, 0)));
	ll curr = ll(k[0] - '0');
	FOR(n,0,curr) {
		dp[0][(n)%d][0] += 1;
	}
	dp[0][curr%d][1] += 1;

	FOR(i,1,sz(k)) {
		FOR(j,0,d) {
			FOR(x,0,2) {
				curr = ll(k[i] - '0');
				if (x == 0) {
					// x = 0: alles fine
					FOR(n,0,10) {
						dp[i][(j+n)%d][0] += dp[i-1][j][0];
						dp[i][(j+n)%d][0] %= MOD;
					}
				} else {
					// x = 1: nix fine
					FOR(n,0,curr) {
						dp[i][(j+n)%d][0] += dp[i-1][j][1];
						dp[i][(j+n)%d][0] %= MOD;
					}
					dp[i][(j+curr)%d][1] += dp[i-1][j][1];
					dp[i][(j+curr)%d][1] %= MOD;
				}
			}
		}
	}

	cout << (dp[sz(k)-1][0][0] + dp[sz(k)-1][0][1] - 1 + MOD) %MOD << endl;

	return 0;
}


Measured memory_bytes: 55424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const int N = (1e3) + 3;
int memo[N][N];
char M[N][N];
int n, m;

int DP(int r, int c) {
	if (r == 1 and c == 1) return 1;
	if (r == 0 or c == 0 or M[r - 1][c - 1] == '#') return 0;
	int &ret = memo[r][c];
	if (ret != -1) return ret;
	ret = (DP(r - 1, c) + DP(r, c - 1)) % MOD;
	return ret;
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			scanf(" %c", &M[i][j]);
		}
	}
	memset(memo, -1, sizeof memo);
	int ans = DP(n, m);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5248
import itertools
import numpy as np

n,m,x=map(int,input().split())

book=[]

mincost=10**12

for i in range(n):
    l=list(map(int,input().split()))
    book.append(l)

nl=np.array(book)

for i in range(2**n):
    bag=np.array([0]*(m+1))
    for j in range(n):
        if((i>>j)&1):
            bag+=nl[j]
    flag=True
    for j in range(1,m+1):
        if bag[j]<x:
            flag=False
    if flag and bag[0]<mincost:
        mincost=bag[0]

if mincost==10**12:
    mincost=-1
    
print(mincost)

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    auto v = map<string, ll>();

    REP(i, n) {
        int    q;
        string k;
        cin >> q >> k;
        if (q == 0) {
            int x;
            cin >> x;
            v[k] = x;
        } else if (q == 1) {
            cout << v[k] << endl;
        } else if (q == 2){
            v.erase(k);
        }
    }

    return 0;
}



Measured memory_bytes: 25840
import java.math.BigDecimal;
import java.util.Scanner;

class Main{


	public static void main(String[] a){

		Scanner sc = new Scanner(System.in);


		int gankin = 100000;

		int n = sc.nextInt();

		for(int i = 0; i < n; i++) {

			double rishi = gankin * 0.05;

			double newGankin = gankin + rishi;

			BigDecimal bd = new BigDecimal(newGankin);
			bd = bd.setScale(-3, BigDecimal.ROUND_UP);

			gankin = (int)bd.doubleValue();
		}

		System.out.println(gankin);

		sc.close();
	}


}

Measured memory_bytes: 26352
import heapq
from itertools import islice

def substrings(s):
    heap = [s[i:] for i in range(len(s))]
    heapq.heapify(heap)
    popSet = set()

    while True:
        sub = heapq.heappop(heap)
        for i in range(1, len(sub) + 1):
            subi = sub[:i]
            if subi not in popSet:
                yield subi
                popSet.add(subi)


if __name__ == "__main__":
    s = input()
    k = int(input())
    print(list(islice(substrings(s), k))[k - 1])


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

int main() {
	int n, k;
	cin >> n >> k;
	if (k > (n - 1)*(n - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	cout << n * (n - 1) / 2 - k << '\n';
	for (int i = 1; i < n; i++)
		cout << i << ' ' << n << '\n';
	k = (n - 1)*(n - 2) / 2 - k;
	for (int i = 1; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (!k--) goto p;
			cout << i << ' ' << j << '\n';
		}
	}
p:
	cout << flush;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int x;
	cin >> x;
	if(x > 0) cout << 0 << newl;
	else cout << 1 << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[]L = new int[N];

    int all = 0;
    for(int i=0; i<N; i++){
        L[i] = sc.nextInt();
        all += L[i];
    }   
    Arrays.sort(L);
    int max = L[N-1];
    int hoka = all-max;

    if(max<hoka){
    System.out.println("Yes");     
    }else{
    System.out.println("No");    
    }
  }
}


Measured memory_bytes: 35744
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll n, k;
  cin >> n >> k;
  ll x, y;
  map<ll, ll> a;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    a[x] += y;
  }
  for (auto i : a) {
    if (k > i.second) k -= i.second;
    else {
      cout << i.first << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 4224
#include<iostream>
#include<cmath>

using namespace std;

double bx,by;
double ra,rb;

double integ(double r,double a){
  return r*r*(acos(0)-asin(a/r)-.5*sin(2*asin(a/r)));
}

double f(double y,double x){
  double X=hypot(y-by,x-bx);
  if(X>ra+rb)return 0;
  if(X+ra<=rb)return ra*ra*acos(0)*2;
  return integ(ra,(X*X+ra*ra-rb*rb)/2/X)+integ(rb,(X*X+rb*rb-ra*ra)/2/X);
}

int main(){
  for(int UW,UH,A,B,ACAPB;cin>>UW>>UH>>A>>B>>ACAPB,UW|UH|A|B|ACAPB;){
    bool rev=false;
    if(A>B){
      rev=true;
      swap(A,B);
    }
    ra=sqrt(A/acos(0)/2),rb=sqrt(B/acos(0)/2);
    if(2*rb>min(UW,UH))goto fail;
    cout.precision(9);
    if(A==ACAPB){
      cout<<fixed<<rb<<' '<<rb<<' '<<(rev?rb:ra)<<' '<<rb<<' '<<rb<<' '<<(rev?ra:rb)<<endl;
    }else{
      bx=UW-rb,by=UH-rb;
      double lax=ra,lay=ra;
      if(f(lay,lax)>ACAPB)goto fail;
      {
	double hax=bx,hay=by;
	for(int i=0;i<10000;i++){
	  double mdax=(lax+hax)/2,mday=(lay+hay)/2;
	  if(f(mday,mdax)>ACAPB){
	    hax=mdax;
	    hay=mday;
	  }else{
	    lax=mdax;
	    lay=mday;
	  }
	}
	if(!rev){
	  cout<<fixed<<lax<<' '<<lay<<' '<<ra<<' '<<bx<<' '<<by<<' '<<rb<<endl;
	}else{
	  cout<<fixed<<bx<<' '<<by<<' '<<rb<<' '<<lax<<' '<<lay<<' '<<ra<<endl;
	}
      }
    }
    continue;
  fail:
    cout<<"impossible"<<endl;
  }
}

	
  

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

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        Tuple<int, int>[] students = new Tuple<int, int>[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                int num = int.Parse(words[i]);
                students[i] = Tuple.Create(i, num);
            }
        }

        students = students.OrderBy(t => t.Item2).ToArray();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++)
        {
            sb.Append(" " + (students[i].Item1 + 1));
        }

        Console.WriteLine(sb.ToString().Trim());
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void solve() {
  int n, c, k;
  cin >> n >> c >> k;
  queue<int> q;
  {
    vector<int> v;
    v.resize(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    for(int out: v) q.push(out);
  }
  int ret = 0;
  while(!q.empty()) {
    ret++;
    int timeLeave = q.front() + k;
    int have = c;
    while(have-- && !q.empty()) {
      if(q.front() <= timeLeave) q.pop();
      else break;
    }
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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

using namespace std;

int main() {
  string s;
  while (cin >> s) {
    vector<int> v(26);
    for (int i = 0; i < s.length(); ++i) {
      v[s[i] - 'a']++;
    }
    bool ok = true;
    for (auto e : v) {
      if (e % 2 == 1) 
	ok = false;
    }

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


Measured memory_bytes: 256
#include<cstdio>
#define N 1003

int n,m;
int arm[50];
int x[N],y[N];
bool odd[2];

inline int Abs(int x) {
	if(x>-x) return x;return -x;
}
void Print(int x,int y) {
	for(int i=1;i<=m;i++) {
		if(Abs(x)<Abs(y)) {
			if(y>0)
				printf("U"),y-=arm[i];
			else printf("D"),y+=arm[i];
		} else {
			if(x>0)
				printf("R"),x-=arm[i];
			else printf("L"),x+=arm[i];
		}
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d %d",&x[i],&y[i]);
		odd[Abs(x[i]+y[i])%2]=true;
	}
	if(odd[0]&&odd[1]) {
		printf("-1");
		return 0;
	}
	/******************/
	m=32;arm[31]=arm[32]=1;
	if(odd[1]) m--;
	for(int i=30;i>=1;i--)
		arm[i]=2*arm[i+1];
	printf("%d\n",m);
	for(int i=1;i<m;i++)
		printf("%d ",arm[i]);
	printf("%d\n",arm[m]);
	/******************/
	for(int i=1;i<=n;i++)
		Print(x[i],y[i]),puts("");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

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

string S;

int main(){
    cin>>S;
    for(int i=0;i<S.length();i+=2){
        cout<<S[i];
    }
    out("");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int n, m, x; cin >> n >> m >> x;
	vector<int> c(n);
	int p[n][m];
	for( int i = 0; i < n; ++i ){
		cin >> c[i];
		for( int j = 0; j < m; ++j ){
			cin >> p[i][j];
		}
	}
	int ans = inf;
	for( int cond = 0; cond < (1<<n); ++cond ){
		int v = 0;
		vector<int> check_a(m, 0);
		for( int i = 0; i < n; ++i ){
			if( cond & (1<<i) ){
				v += c[i];
				for( int j = 0; j < m; ++j ){
					check_a[j] += p[i][j];
				}
			}
		}
		bool flag = true;
		for( int j = 0; j < m; ++j ){
			if( check_a[j] < x ) flag = false;
		}
		if( flag ){
			ans = min(ans, v);
		}
	}
	if( ans == inf ) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 110;
const int inf = 0x0fffffff;

void mini(int &a, int b) { a = min(a, b);}
int a[maxn][26], c[26];

int main()
{
	int i, j, n;
	string s, ans;
	ans.clear();
	cin >> n;
	for (i = 0; i < n; i ++)
	{
		cin >> s;
		for (j = 0; j < s.size(); j ++)
			a[i][s[j] - 'a'] ++;
	}
	for (j = 0; j < 26; j ++)
		c[j] = a[0][j];
	for (i = 1; i < n; i ++)
		for (j = 0; j < 26; j ++)
			c[j] = min(c[j], a[i][j]);
	for (j = 0; j < 26; j ++)
		for (i = 0; i < c[j]; i ++)
			ans.push_back(j + 'a');

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#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 <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

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

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

  int h, w;
  cin >> h >> w;
  vector<string> grid(h); // 実質vector<vector<char>>
  rep(i,h) cin >> grid[i];

  int res = -1;
  // 二重ループでスタート地点を全探索してBFS
  rep(sh, h) {
    rep(sw, w) {
      if(grid[sh][sw] == '#') continue; // 壁はスタートにしない
      queue<pair<int, int>> que; // pair<int, int>のqueueで座標を持つ
      vector<vector<int>> dist(h, vector<int> (w, -1)); // h * wのint型の二次元配列を-1で初期化(=未探索)
      dist[sh][sw] = 0;
      que.push({sh, sw});
      // BFS
      while(!que.empty()) {
        int vh = que.front().fi;
        int vw = que.front().se;
        que.pop();
        //四方向
        rep(dir, 4) {
          int nvh = vh + dy[dir];
          int nvw = vw + dx[dir];

          // いつもの範囲外をはじくやつ
          if(nvh < 0) continue;
          if(nvw < 0) continue;
          if(nvh >= h) continue;
          if(nvw >= w) continue;
          if(dist[nvh][nvw] != -1) continue;
          if(grid[nvh][nvw] == '#') continue;

          dist[nvh][nvw] = dist[vh][vw]+1;
          que.push({nvh, nvw});
        }
      }
      // 配列を縦に舐めて列ごとに*max_elementで更新
      rep(i, h) rep(j, w) res = max(res, dist[i][j]);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    string W[100];
    for(int i=0;i<N;i++){
        cin >> W[i];
    }
    int check = 0;
    
    //しりとりのチェック
    for(int i=0;i<N-1;i++){
        reverse(W[i].begin(),W[i].end());
        if(W[i][0]!=W[i+1][0]){
            check++;
    }
    }
    reverse(W[N-1].begin(),W[N-1].end());
    //重複のチェック
    sort(W,W+N);
    for(int i=0;i<N-1;i++){
        if(W[i]==W[i+1]){
            check++;
        }
    }
        if(check==0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
a,b = LS()
if a == b:
    print("H")
else:
    print("D")
"""

#B
w,a,b = LI()
print(max(max(a,b)-min(a,b)-w,0))
#C
"""

x = I()
a = 0
i = 1
while a < x:
    a += i
    i += 1
print(i-1)
"""

#D
"""
n,k = LI()
a = LI(n)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin >> n;
	Matrix a(n, Array(60, 0));

	Array max(n, 0);
	REP(i, n) {
		ll aa;
		cin >> aa;
		ll j = 0;
		while (aa > 0) {
			if ((aa & 1) != 0) {
				a[n - 1 - i][j] = 1;
				max[n - 1 - i] = j;
			}
			j++;
			aa /= 2;
		}
	}
	/*
	for (auto i : max) {
		cout << i << " ";
	}
	cout << endl;
	*/
	Matrix sum1(n+1, Array(60, 0));
	Matrix sum0(n + 1, Array(60, 0));
	REP(i, n) {
		REP(j, 60) {
			sum1[i + 1][j] = a[i][j] + sum1[i][j];
			sum0[i + 1][j] =sum0[i][j];
			if (max[i] > j&& a[i][j] == 0) sum0[i+1][j]++;
		}
	}
	/*
	for (auto i : sum1) {
		for (auto j : i) {
			cout << j <<" ";
		}
		cout << endl;
	}
	cout << endl;

	for (auto i : sum0) {
		for (auto j : i) {
			cout << j << " ";
		}
		cout << endl;
	}
	cout << endl;
	*/
	ll ans = 0;
	REP(i,n) {
		REP(j, 60) {
			if (j <= max[i]) {
				if (a[i][j] == 0) {
					ans += (((1LL << j)%MOD) * sum1[i][j])%MOD;
				}
				else {
					ans += (((1LL << j)%MOD) * (i - sum1[i][j]))%MOD;
				}
				ans %= MOD;
			}
			else {
				if (a[i][j] == 0) {
					ans += (((1LL << j)%MOD) * sum1[i][j])%MOD;
				}
				else {
					ans += (((1LL << j)%MOD) * sum0[i][j])%MOD;
				}
				ans %= MOD;
			}
		}
		//cout << ans << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 459648
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    string S; cin>>S;

    string a = S.substr(0, N/2);
    string b = S.substr(N/2, N/2);
    if(N%2==0){
        if(a==b){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    } else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
a = []
loss = 0
ans = 0
for i in range(5):
    a.append(int(input()))
    t = 10 - a[i] % 10
    if t != 10 and t > loss: loss = t
for i in range(5):
    ans += (a[i] + 9) // 10 * 10
print(ans - loss)


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll count = 0;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll a;
        cin >> a;
        if(a % 4 == 0) count += 2;
        else if(a % 2 == 0) count++;
    }
    cout << ((N % 2 ? N - 1 : N) <= count ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        mut h: isize,
        a: isize,
    }
    
    // わざわざループで解いてみる。
    let mut i = 0;
    
    while h > 0 {
        h -= a;
        i += 1;
    }
    
    println!("{}", i);
}


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

int main() {
  int n,c,k;
  cin >>n>>c>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int kotae=1;
  int count=0;
  int jikoku=0;
  int start=a[0];
  for(int i=0;i<n;i++){
    if(a[i]<=start+k&&count<c){
      start=min(start,a[i]);
      count++;
    }else{
      kotae++;
      count=1;
      jikoku=start+k;
      start=a[i];
    }
    //cout<<start<<" "<<jikoku<<" "<<count<<endl;
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define int LL
#define upto(a, b, i) for(int i = (a), b_ = (b); i <= b_; ++i)
#define uptil(a, b, i) for(int i = (a), b_ = (b); i < b_; ++i)
#define downto(a, b, i) for(int i = (a), b_ = (b); i >= b_; --i)
#define downtil(a, b, i) for(int i = (a), b_ = (b); i > b_; --i)
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n)-1, 0, i)

#define sp <<" "
#define ln <<endl
#define size(x) ((int)x.size())
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;

void solve() {
  int N,D; cin>>N>>D;
  vvec<int> X(N,vec<int>(D));
  times(N, i) times(D, k) cin >> X[i][k];
  int ans = 0;
  times(N, i) times(i, j) {
    int s = 0;
    times(D, k) s += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
    int r = (int)sqrt(s);
    ans += r * r == s;
  }
  cout << ans ln;
}

signed main() {
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(6);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    string x;
    ll scnt = 0,ans;
    cin >> x;
    ans = x.size();
    rep0(i, x.size()){
        if (x[i] == 'S') {
            ++scnt;
        }else if (scnt > 0){
            --scnt;
            ans -= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

#define INF 10000000
#define MAX_P 1000
typedef pair<double, double> Pt;

int N;
double dp[MAX_P][MAX_P];
vector<Pt> xy;

double ptdist(Pt p, Pt q) {
  return sqrt(pow(p.first-q.first,2) + pow(p.second-q.second,2));
}

double solve() {
  for (int i=0;i<N;++i) {
    for (int j=0;j<N;++j) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  for (int i=1;i<N;++i) {
    dp[0][i] = dp[0][i-1] + ptdist(xy[i-1],xy[i]);
  }
  for (int i=1;i<N;++i) {
    for (int j=i;j<N;++j) {
      if (i<j-1) {
        dp[i][j] = dp[i][j-1] + ptdist(xy[j-1],xy[j]);
      } else {
        for (int k=0;k<i;++k) {
          dp[i][j] = min(dp[i][j], dp[k][i]+ptdist(xy[k],xy[j]));
        }
      }
      // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    }
  }
  return dp[N-1][N-1];
}

int main () {
  cin>>N;
  for(int i=0;i<N;++i) {
    double x,y;
    cin>>x>>y;
    xy.push_back(make_pair(x,y));
  }
  cout<<fixed<<setprecision(8)<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 11132
x1, y1, x2, y2 = map(int, input().split())

x = x1 - x2
y = y1 - y2

x3 = x2 + y
y3 = y2 - x
x4 = x1 + y
y4 = y1 - x

print(x3, y3, x4, y4)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
int n,r,i,j,a[100];
main(){
scanf("%d",&n);
for(;i<n;)scanf("%d",a+i++);
for(i=0;i<n;i++){
for(j=0;j<i;){
if(a[i]<a[j++])r++;
}
}
std::sort(a,a+n);
for(i=0;i<n;){if(i)printf(" ");printf("%d",a[i++]);}
printf("\n%d\n",r);
}

Measured memory_bytes: 3236
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

int N;
VI G[100010];


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

	cin >> N;
	int K = -1;
	VI ans(N - 1);
	map<pii, int>mp;
	REP(i, N - 1) {
		int a,b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
		chmax(K, (int)G[a].size());
		chmax(K, (int)G[b].size());
		mp[pii(a, b)] = mp[pii(b, a)] = i;
	}

	queue<int>Q;
	Q.push(0);
	vector<bool>vis(N, false);
	vis[0] = 1;
	vector<VI>no(N);

	while (!Q.empty()) {
		int now = Q.front();
		Q.pop();
		int co = 1;
		fore(to, G[now]) {

			if (vis[to])continue;
			//if ((no[now].size() > 0 && no[now][0] != co) || no[now].empty()) {
			if (no[now].size() > 0 && no[now][0] == co) co++;
				ans[mp[pii(now, to)]] = co;
				Q.push(to);
				vis[to] = 1;
				no[to].push_back(co);
			
			co++;
		}
	}



	cout << K << endl;
	REP(i, N - 1)cout << ans[i] << endl;

	return 0;
}



Measured memory_bytes: 25344
L = input().strip()
t = L.count('1')
N = len(L)
L = [1 if l == '1' else 0 for l in L]
mod = 10**9+7
pre = 0
ans = pow(2, t, mod)
for i, l in enumerate(L):
    if not l:
        continue
    ans = (ans + pow(2, pre, mod)*pow(3, N - i - 1, mod)) % mod
    pre += 1
print(ans)

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

int main() {
  int x, y, z; cin >> x >> y >> z;
  auto f = [&](int n) {
    return (y + z) * n <= x - z;
  };
  int l = 0, r = x / y + 10;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (f(m)) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int N,ptr,res;
int A[100000];
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",&A[i]);
	sort(A,A+N);
	while(ptr<N)
	{
		int cc=A[ptr],f=0;
		while(ptr<N&&A[ptr]==cc)f++,ptr++;
		res+=f%2;
	}
	printf("%d\n",res);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
 string S; cin>>S;
 if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]){
 cout<<"Yes"<<endl;

 }
 else if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1]){
 cout<<"Yes"<<endl;

 }
 else if(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1]){
 cout<<"Yes"<<endl;

 }
 else{cout<<"No"<<endl;}

}



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

char hexa(int n1)
{
    int a;
    char b = 'A';
    for(a = 10; a < n1; a++)
    {
        b++;
    }

    return b;
}

int main() {
    long int k, n, aux;
    int i, j;
    char res[1000000], charac[1000];

    scanf("%ld %ld", &n, &k);

    aux = n;
    i = 0;
    while(n > 0)
    {
        aux = n%k;
        if(aux > 9)
        {
            aux = hexa(aux);
            charac[i] = 1;
        }

        res[i] = aux;
        i++;
        n = n/k;
    }

    printf("%d\n", i);
}

Measured memory_bytes: 128
D, G = gets.split.map(&:to_i)
p_i = Array.new(D+1,0)
c_i = Array.new(D+1,0)
D.times do |i|
  p_i[i+1], c_i[i+1] = gets.split.map(&:to_i)
end

answer = 2 ** 100
complete_points = Array.new(D+1,0)
(1..D).each do |i|
  complete_points[i] = i * 100 * p_i[i] + c_i[i]
end

[0, 1].repeated_permutation(D) do |bits|
  #p bits
  count = 0
  point = 0
  bits_reverse = bits.reverse
  if bits_reverse.include?(0)
    max_point_reverse = bits_reverse.find_index {|n| n == 0}
    max_point_index = D - max_point_reverse
  end

  (1..D).each do |i|
    if bits[i-1] == 1
      count += p_i[i]
      point += complete_points[i]
    end
  end

  if bits_reverse.include?(0)
    if point <= G
      point_required = G - point
      max_point = max_point_index * 100
      count_required = point_required / max_point
      if point_required % max_point != 0
        count_required += 1
      end
      if count_required > p_i[max_point_index]
        next
      end
    else
      count_required = 0
    end
  else
    count_required = 0
  end

  count_sum = count_required + count
  #p  "count=#{count}"
  #p  "count_required=#{count_required}"
  #p  "count_sum=#{count_sum}"
  if answer > count_sum
    answer = count_sum
  end
end
p answer


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define N 100
#define INF 1e9 + 5
#define MO 1e9+7
#define LINF 1e18 + 5

using namespace std;
using ll = long long;
int h,w;
const ll mod = 1e9+7;
char s[1002][1002];
ll dp[1002][1002];

ll solve(int y, int x){
    if(s[y][x]=='#'||s[y][x]==0) return 0; //이건 삑사리 났을 때
    ll& res = dp[y][x];
    if(res!=-1) return res; //이미 계산했다면 리턴
    res = (solve(y+1,x) + solve(y,x+1))%mod;
    return res;
}

int main()
{
    cin>>h>>w;
    memset(dp, -1, sizeof(dp));
    dp[h][w]=1;
    for(int i=1;i<=h;i++){
        scanf("%s", s[i]+1);
    }
    cout<<solve(1,1);
    
    return 0;
}

Measured memory_bytes: 9216
import sys
input = sys.stdin.readline

M = 10**6
child = [[0] * 26 for _ in range(M)]
is_end = [False] * M
nxt = 1

N = int(input())
S = [input().rstrip()[::-1] for _ in range(N)]
paths = [[] for _ in range(N)]
for i, s in enumerate(S):
    node = 0
    for c in s:
        c = ord(c) - ord('a')
        paths[i].append(node)
        if child[node][c] == 0:
            child[node][c] = nxt
            nxt += 1
        node = child[node][c]
    is_end[node] = True

ans = 0
for i, s in enumerate(S):
    suffix = set()
    for j in range(len(s) - 1, -1, -1):
        suffix.add(ord(s[j]) - ord('a'))
        node = paths[i][j]
        for c in suffix:
            ans += is_end[child[node][c]]
print(ans - N)

Measured memory_bytes: 433912
_n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = a.inject(:+).to_f / (4 * m)

cnt = 0
a.each do |ai|
  cnt += 1 unless ai < b
end
if cnt >= m
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

	int a;
	cin >> a;
	cout << a+a*a+a*a*a<<endl;


	return 0;
}

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

#define N 100

int n;
long long x;
int a[N];

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

	sort( a, a + n );
	long long sum = 0;
	for( int i = 0; i < n; i++ ) {
		sum += a[i];
	}
	int ans = n;
	if( sum == x ) {
	}
	else if( sum < x ) {
		for( int i = n - 1; i >= 0; i-- ) {
			if( x <= sum ) {
				break;
			}
			x -= a[i];
			ans--;
		}
	}
	else if( sum > x ) {
		for( int i = n - 1; i >= 0; i-- ) {
			if( x >= sum ) {
				break;
			}
			sum -= a[i];
			ans--;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var a = cin.ArrayLong(n);

            Console.WriteLine((a.Sum() - a.Max() - a.Max()) > 0 ? "Yes" : "No");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

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

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

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

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


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

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
 ll n,m;
 cin>>n>>m;
 vector<vector<char>> a(n,vector<char>(m));
 for(ll i=0;i<n;i++){
  for(ll j=0;j<m;j++){
   cin>>a[i][j];
  }
 }
 vector<vector<ll>> dp(n,vector<ll>(m));
 dp[n-1][m-1]=(a[n-1][m-1]=='.');
// cout<<dp[n-1][m-1]<<endl;
 for(ll i=n-2;i>=0;i--){
  dp[i][m-1]=dp[i+1][m-1];
  if(a[i][m-1]=='#') dp[i][m-1]=0;
 }
 for(ll j=m-2;j>=0;j--){
  dp[n-1][j]=dp[n-1][j+1];
  if(a[n-1][j]=='#') dp[n-1][j]=0;
 }
 for(ll i=n-2;i>=0;i--){
  for(ll j=m-2;j>=0;j--){
   dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
   if(a[i][j]=='#') dp[i][j]=0;
  }
 }
 cout<<dp[0][0]<<endl;
 return 0;
}

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  for (int C = 1; C <= N;C+=2){
    int div = 0;
    for (int X = 1; X <= C;++X){
      if (C%X==0){
        ++div;
      }
    }
    if (div == 8 ){
      ++ans;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256