akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,A;
  cin >> N >> A;
  int x[N];
  for(int i=0;i<N;i++) cin >> x[i];

  vector<int> lft;
  vector<int> rit;
  int cnt0 = 0;
  for(int i=0;i<N;i++){
    if(x[i]==A) cnt0++;
    else if(x[i]>A) rit.push_back(x[i]-A);
    else if(x[i]<A) lft.push_back(A-x[i]);
  }

  ll dpr[2501] = {};
  ll dpl[2501] = {};

  for(int i=0;i<(int)rit.size();i++){
    for(int j=2500;j>=1;j--){
      if(j - rit[i] >= 1 && dpr[j-rit[i]]!=0){
        dpr[j] += dpr[j-rit[i]];
      }
    }
    dpr[rit[i]]++;
  }
  for(int i=0;i<(int)lft.size();i++){
    for(int j=2500;j>=1;j--){
      if(j - lft[i] >= 1 && dpl[j-lft[i]]!=0){
        dpl[j] += dpl[j-lft[i]];
      }
    }
    dpl[lft[i]]++;
  }

  ll ans = 0;
  for(int i=1;i<=2500;i++){
    ans += dpl[i] * dpr[i] * (1LL << cnt0);
  }
  ans += 1LL << cnt0;
  ans -= 1;

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


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

using namespace std;
int l[100005],r[100005];
int m1=0,m2=1e9;
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>l[i]>>r[i];
		m1=max(l[i],m1);
		m2=min(r[i],m2); 
	}
	cout<<max(m2-m1+1,0);
	return 0;
} 

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

const int m=1000000007;

int main()
{
    int x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3600
function Main(input){
  var inputs = input.split(" ");
  var one = inputs[0].split(""), two = inputs[1].split(""),three = inputs[2].split("");
  var answer = one[0].toUpperCase() + two[0].toUpperCase() + three[0].toUpperCase();
  console.log(answer);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21192
package main

import (
	"fmt"
)

func main() {
	var n, A, B, C, D int
	fmt.Scanf("%d %d %d %d %d", &n, &A, &B, &C, &D)
	A -= 1
	B -= 1
	C -= 1
	D -= 1

	var load string
	fmt.Scan(&load)

	for i := A; i < max(C, D); i++ {
		if load[i] == []byte("#")[0] && load[i+1] == []byte("#")[0] {
			fmt.Println("No")
			return
		}
	}

	if C > D /* 追い抜く場合 */ {
		ok := false
		for i := B - 1; i < D; i++ {
			if load[i] == []byte(".")[0] && load[i+1] == []byte(".")[0] && load[i+2] == []byte(".")[0] {
				ok = true
				break
			}
		}

		if !ok {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

func max(s ...int) int {
	maxContent := s[0]
	for _, el := range s {
		if el > maxContent {
			maxContent = el
		}
	}
	return maxContent
}


Measured memory_bytes: 1664
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local mab = math.abs
local h, w = io.read("*n", "*n", "*l")
local str = ""
-- local kabe = {}
local kabe_per_row = {}
for i = 1, h do kabe_per_row[i] = {} end
local kabe_per_col = {}
for i = 1, w do kabe_per_col[i] = {} end


for i = 1, h do
  str = io.read()
  for j = 1, w do
    local iskabe = str:sub(j, j) == "#"
    if iskabe then
      table.insert(kabe_per_row[i], j)
      table.insert(kabe_per_col[j], i)
    end
    -- kabe[(i - 1) * w + j] = (str:sub(j, j) == "#")
  end
end
local score = {}
for i = 1, h * w do score[i] = -1 end
for i = 1, h do
  local kabelist = kabe_per_row[i]
  local kabenum = #kabelist
  if kabenum == 0 then
    for j = 1, w do
      local idx = (i - 1) * w + j
      score[idx] = score[idx] + w
    end
  else
    local stt = 1
    local ed = kabelist[1] - 1
    for j = stt, ed do
      local idx = (i - 1) * w + j
      score[idx] = score[idx] + ed - stt + 1
    end
    for ikabe = 1, kabenum - 1 do
      stt, ed = kabelist[ikabe] + 1, kabelist[ikabe + 1] - 1
      for j = stt, ed do
        local idx = (i - 1) * w + j
        score[idx] = score[idx] + ed - stt + 1
      end
    end
    stt, ed = kabelist[kabenum] + 1, w
    for j = stt, ed do
      local idx = (i - 1) * w + j
      score[idx] = score[idx] + ed - stt + 1
    end
  end
end

for j = 1, w do
  local kabelist = kabe_per_col[j]
  local kabenum = #kabelist
  if kabenum == 0 then
    for i = 1, h do
      local idx = (i - 1) * w + j
      score[idx] = score[idx] + h
    end
  else
    local stt = 1
    local ed = kabelist[1] - 1
    for i = stt, ed do
      local idx = (i - 1) * w + j
      score[idx] = score[idx] + ed - stt + 1
    end
    for ikabe = 1, kabenum - 1 do
      stt, ed = kabelist[ikabe] + 1, kabelist[ikabe + 1] - 1
      for i = stt, ed do
        local idx = (i - 1) * w + j
        score[idx] = score[idx] + ed - stt + 1
      end
    end
    stt, ed = kabelist[kabenum] + 1, h
    for i = stt, ed do
      local idx = (i - 1) * w + j
      score[idx] = score[idx] + ed - stt + 1
    end
  end
end
local max = 0
for i = 1, h * w do
  max = mma(max, score[i])
end
print(max)


Measured memory_bytes: 106368
#include <stdio.h>

#define BUF_SIZE 12
int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  int num;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  sscanf(line, "%d", &num);

  int cnt = 0;
  cnt += (num/25);
  num = num%25;
  cnt += (num/10);
  num = num%10;
  cnt += (num/5);
  num = (num%5);
  cnt += num;
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 2092
"""
xi,xjのペアにおいて、このペアは何通り出てくるか
sum(全通り)sum(i)sum(j){|xi-xj|+|yi-yj|}
和なので、どんな順序でもいい

sum(i)sum(j)sum(全通り){|xi-xj|}
sum(i)sum(j)sum(全通り){|yi-yj|}

あるi,jで固定して、sum(全通り){|xi-xj|}を求めるヤツ
固定したi,jが現れる回数は、

pat = NM-2_C_K-2 こいつはどこでも一緒

pat*sum(i)sum(j){|xi-xj|}を計算する
すべてのi,j(i>j)ペアにおいて、xi,xjの和は
sum(i=1,N){i*(N-i)}
"""
from math import factorial

N,M,K = map(int,input().split())
mod = 10**9+7
fa = 1
num = N*M - 2
# 固定したときの通り数
# フェルマーの小定理をつかって、mod(M)でのcombinationが高速で求まる
# http://keita-matsushita.hatenablog.com/entry/2016/12/05/184011
def mod_combination(n,r,mod):
    if n<0 or r<0 or n<r:
        return 0
    if n==0 or r == 0:
        return 1
    a = factorial(n) % mod
    b = factorial(r) % mod
    c = factorial(n-r) % mod
    return (a*pow(b,mod-2,mod)*pow(c,mod-2,mod)) % mod 

pat = mod_combination(N*M-2,K-2,mod)

n_x = M**2*((N-1)*N*(N+1))//6
n_y = N**2*((M-1)*M*(M+1))//6
print(pat*(n_x+n_y)%mod)

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

bool prime[1000003];
bool sieve() {
    memset(prime, true, sizeof(prime));
    for(int i = 2; i * i < 1000003; ++i){
        if(prime[i]){
            for(int j = 2 * i; j < 1000003; j += i){
                prime[j] = false;
            }
        }
    }
}
long long fact(int n) {
    long long ans = 1;
    for(int i = 2; i <= n; ++i) ans *= i;
    return ans;
}
int dig(long long x) {
    int ans = 0;
    long long n = x;
    while(n > 0) {
        ans += 1;
        n/=10;
    }
    return ans;
}
int main() { 
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // double time = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a, b, k;
    cin >> a >> b >> k;
    if(k > a) {
        k-=a;
        b-=min(b,k);
        cout << 0 << " " << b << endl;
    } else {
        cout << a-k << " " << b << endl;
    }
    
        
    // cout << "Execution-Time : " << (clock() - time) / CLOCKS_PER_SEC << endl;
}


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

int n, a;
int cnt[200000];

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n - 1; i++) {
		cin >> a;
		a--;
		cnt[a]++;
	}
	
	for (i = 0; i < n; i++) {
		cout << cnt[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4368
n=int(input())

hlist=list(map(int,input().split()))

counter=0
maa=100

for i in range(maa):
    hight = i+1
    flag = False
    for h in hlist:
        if not flag:
            if h>= hight:
                counter+=1
                flag = True
        if flag:
            if h < hight:
                flag = False

print(counter)	

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

int n;
LL a[N];

int main() {
	read(n);
	LL sum = 0;
	for (int i = 1; i <= n; i++) read(a[i]), sum += a[i];
	int last = 0;
	for (int i = 1; i <= n + 1; i++) {
		if (a[i] != 0) continue;
		LL tmp = 0;
		for (int j = last + 1; j <= i; j++) tmp += a[j];
		sum -= (tmp & 1LL);
		last = i;
	}
	printf("%lld\n", sum / 2);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
    cout << n + n*n + n*n*n <<endl;
    return 0;    
}


Measured memory_bytes: 3644
// Aizu Vol-1 0150: Twin Prime
// 2017.8.1

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);

#define MAX  10000
#define SQRT 100     // sqrt(MAX)

char prime[MAX + 5], *p, *q, *pmax;

int main()
{
	int n, k;
	char buf[100];

	pmax = prime + MAX;
	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2) {
		if (!*p) {
			for (q = p + k; q <= pmax; q += k) *q = 1;
		}
	}

	while (1) {
		gets(buf);
		if (!(n = atoi(buf))) break;
		if (!(n & 1)) n--;
		while (prime[n] || prime[n - 2]) n -= 2;
		printf("%d %d\n", n-2, n);
	}
	return 0;
}

Measured memory_bytes: 532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string buf;
  while(getline(cin,buf),buf!=""){
    string s=buf;
    while(getline(cin,buf),buf!="") s+=buf;
    string a;
    getline(cin,a);
    //cout<<s<<endl<<a<<endl;
    
    int n=a.size();
    vector<int> pos[n];
    for(int i=0;i<(int)s.size();i++)
      for(int j=0;j<n;j++)
	if(s[i]==a[j]) pos[j].push_back(i);

    bool f=1;
    for(int i=0;i<n;i++) f&=!!(pos[i].size());
    if(!f){
      cout<<0<<endl<<endl;
      getline(cin,buf);
      continue;
    }
    
    int idx[n];
    memset(idx,0,sizeof(idx));
    
    int ans=0,len=s.size()+1,head=0;
    for(int i=0;i<(int)s.size();i++){
      int nxt=i;
      for(int j=0;j<n;j++)
	nxt=max(nxt,pos[j][idx[j]]);

      if(nxt-i+1<len) ans=0,len=nxt-i+1,head=i;
      if(nxt-i+1==len) ans++;

      for(int j=0;j<n;j++){
	if(s[i]==a[j]) idx[j]++;
	if(idx[j]>=(int)pos[j].size()) goto LAB;
      }
    }
    
  LAB:
    string str=s.substr(head,len);
    
    cout<<ans<<endl;
    for(int i=0;i<(int)str.size();i++){
      if(i%72==0) cout<<endl;
      cout<<str[i];
    }
    cout<<endl<<endl;;
    //ready for next;
    getline(cin,buf);
  }
  return 0;
}

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

int w, h, ans;
vector<vector<int>> field;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
int start[2];

bool in(int i, int j) {
	return 0 <= i && i < h && 0 <= j && j < w;
}

void dfs(int i, int j, int move) {
	if (move == 10) return;

	for (int k = 0; k < 4; k++) {
		if(in(i + dy[k], j + dx[k]) && field[i + dy[k]][j + dx[k]] == 1) continue;

		int ni = i, nj = j;
		while (true) {
			ni += dy[k];
			nj += dx[k];
			if (!in(ni, nj)) break;
			if (field[ni][nj] == 3) {
				ans = min(ans, move + 1);
				return;
			}
			if (in(ni + dy[k], nj + dx[k]) && field[ni + dy[k]][nj + dx[k]] == 1) {
				field[ni + dy[k]][nj + dx[k]] = 0;
				dfs(ni, nj, move + 1);
				field[ni + dy[k]][nj + dx[k]] = 1;
				break;
			}
		}
	}
}

int main() {
	while (cin >> w >> h , w != 0 || h != 0) {
		ans = 100;
		field = vector<vector<int>>(h, vector<int>(w, 0));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> field[i][j];
				if (field[i][j] == 2) {
					start[0] = i;
					start[1] = j;
				}
			}
		}

		dfs(start[0], start[1], 0);

		cout << (ans == 100 ? -1 : ans) << endl;
	}
}

Measured memory_bytes: 1224
#include<cstdio>
#include<cstring>
using namespace std;
char s[100005];
int dp[100005],len;
int f(int n){
	if (dp[n]) return 1;
	if (n<5) return 0;
	char tmp[10];
	for (int i=0; i<5; i++) tmp[i]=s[i+n-5];
	tmp[5]='\0';
	if (strcmp(tmp,"dream")==0&&f(n-5)) return 1;
	else if (strcmp(tmp,"erase")==0&&f(n-5)) return 1;
	if (n<6) return 0;
	for (int i=0; i<6; i++) tmp[i]=s[i+n-6];
	tmp[6]='\0';
	if (strcmp(tmp,"eraser")==0&&f(n-6)) return 1;	
	if (n<7) return 0;
	for (int i=0; i<7; i++) tmp[i]=s[i+n-7];
	tmp[7]='\0';
	if (strcmp(tmp,"dreamer")==0&&f(n-7)) return 1;
	return 0;	
}
int main(){
	scanf("%s",s);
	len=strlen(s);
	dp[0]=1;
	for (int i=1; i<=len; i++) dp[i]=0;
	if (f(len)) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

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

    int n, k, q;
    cin >> n >> k  >> q;
    vector< int> x(n + 1);
    for (int i = 1; i <= q; i ++) {
        int p;
        cin >> p;
        x[p] ++;
    }

    for (int i = 1; i <= n; i ++) {
        if (k - q + x[i] > 0) cout << "Yes\n";
        else cout << "No\n";
    }
}

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

using namespace std;

int n,cnt,d[2001];

int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>d[i];
    sort(d+1,d+n+1);
    for(int i=1;i<=n;i++){
        int s=1,e=i-1;
        while(s<e){
            if(d[s]+d[e]>d[i]){
                cnt+=e-s;
                e--;
            }
            else s++;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#入力。参加者数N, 初期得点K ,正解数Q
N, K, Q = list(map(int,input().split()))
#入力。正解した人の番号A[i]
A = [None for _ in range(Q)]
for i in range(Q):
  A[i] = int(input())
#初期得点(hp)をリスト化。
hp = [K for _ in range(N)]
#まず他の人への攻撃力at(各人の正解数)を記録。
at = [0 for _ in range(N)]
#正解した人の攻撃力+1。
for i in range(Q):
  j = A[i]
  at[j-1] += 1
#攻撃力分の数を一度全員のhpからマイナスする。合計はfor文の外でやっておかないとTLE。
s = sum(at)
for i in range(N):
  hp[i] -= s
#各々自分の攻撃力分は本来受けないはずのダメージなのでhpに戻す(足す)。
for i in range(N):
  hp[i] += at[i]
#結果(生き残り判定)
for i in range(N):
  if hp[i] > 0:
    print('Yes')
  else:
    print('No')

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    long long n, k;
    cin >> n >>k;
    n %= k;
    cout << min(n, k - n) << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    if(s[0]==s.back()){
        if(SZ(s)%2==0) cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    else{
        if(SZ(s)%2==0) cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> a>>b>>c;
    if(c>a+b&&a*b<((c-a-b)*(c-a-b)+3)/4)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
from bisect import bisect_left

N, X = map(int, input().split())

L = [1]
P = [1]
l = 1
p = 1
for _ in range(N):
    l = 2*l+3
    p = 2*p+1
    L.append(l)
    P.append(p)
L.sort(reverse=True)
P.sort(reverse=True)
#print(L)
#print(P)
A = X
ans = 0
for n in range(0, N+1):
    if n == N:
        if A == 1:
            ans += 1
        break
    l0 = L[n]//2-1
    p0 = P[n]//2
    #print(A, l0, p0, ans)
    if A == 1:
        break
    elif  A == l0 + 2:
        ans += p0+1
        break
    elif A == 2*l0+3:
        ans += 2*p0+1
        break
    elif A < l0+2:
        A = A - 1
    elif A > l0+2:
        ans += p0+1
        A = A-l0-2
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <set>
#include <cctype>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <limits>
#include <cmath>
#include <typeinfo>

using namespace std;


int main() {	
    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;
    if(a == c and a != b){
        cout << "Yes" << endl;
        return 0;
    }
    if(c == b and c != a){
        cout << "Yes" << endl;
        return 0;
    }
    if(b == a and b != c){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

 	return 0;		
    
}

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

#define fr first
#define se second

using namespace std;

const long long N = 3e2 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int m;
int l;
int main()
{
    ios_base::sync_with_stdio(false);


    cin >> n >> m >> l;
    vector<vector<int>> a(n + 1, vector<int> (n + 1, inf));
    for(int i = 1; i <= m; i ++){
        int x, y, w;
        cin >> x >> y >> w;
        a[x][y] = a[y][x] = w;
    }
    for(int i = 1; i <= n; i ++) a[i][i] = 0;

    for(int k = 1; k <= n; k ++){
        for(int i = 1; i <= n; i ++){
            for(int j = 1; j <= n; j ++){
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
            }
        }
    }
    vector<vector<int>> d(n + 1, vector<int> (n + 1, inf));
    for(int s = 1; s <= n; s ++){
        queue<int> q;
        q.push(s);
        d[s][s] = 0;
        while(!q.empty()){
            int v = q.front();
            q.pop();
            for(int to = 1; to <= n; to ++){
                if(d[s][to] > d[s][v] + 1 && a[v][to] <= l){
                    d[s][to] = d[s][v] + 1;
                    q.push(to);
                }
            }
        }
    }
    int q;
    cin >> q;
    while(q --){
        int x, y;
        cin >> x >> y;
        if(d[x][y] == inf) d[x][y] = 0;
        cout << d[x][y] - 1 << "\n";
    }
}



Measured memory_bytes: 1280
n = int(input())
a = list(map(int,input().split()))

scr = [400,800,1200,1600,2000,2400,2800,3200,5000]
li = [0,0,0,0,0,0,0,0,0]

for i in range(n):
    for j in range(len(scr)):
        if a[i] < scr[j]:
            li[j] += 1
            break

ans = 0
for i in range(len(li)-1):
    if li[i]>0:
        ans += 1

if li[8]:
    ans_M = min(ans+li[8],10**9)
    ans_m = max(ans,1)
else:
    ans_M = ans
    ans_m = ans

print(ans_m,ans_M)

Measured memory_bytes: 3064
def main():
    N = int(input())
    num = 0
    for i in range(1, N + 1):
        if i % 2 == 1:
            count = 0
            for j in range(1, N + 1):
                if i % j == 0:
                    count += 1
            if count == 8:
                num += 1
    print(num)
main()

Measured memory_bytes: 2940
#include <iostream>
#include <iostream>
using namespace std;
int H,W,N;
int main(){
	cin >> H >> W;
	cin >> N;
	int A[N+10] = {0};
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	int C[H+10][W+10] = {{0}};
	int count = 1;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(i%2==1){
				C[i][j] = count; 
			}
			if(i%2==0){
				C[i][W-j+1] = count;
			}
			A[count]--;
			if(A[count]==0) count++;
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(j!=W) cout << C[i][j] << " ";
			else cout << C[i][j] << endl;
		}
	}
}

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

int main() {
    int n;
    vector<string> ans;
    unordered_map<string, int> m;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << m.size() << endl;
}


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

int main() {
    int n;
    cin >> n;
    int xcan = n / 1.08;
    int ncan1 = xcan * 1.08, ncan2 = (xcan + 1) * 1.08;
    cout << (ncan1 == n ? to_string(xcan) : ncan2 == n ? to_string(xcan + 1) : ":(") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, sum = 0, ans = 0;
	for (int h = 0; h < 5; h++) {
		cin >> n;
		if (n % 10 == 0) {
			ans += n;
		}
		else {
			ans += (n / 10 + 1) * 10;
			sum = max(sum, 10 - n % 10);
		}
	}
	cout << ans - sum << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=55;
int n,a[N],b[N],flag[N];
bitset<N> S[N];
int check(int x){
	for (int i=1;i<x;i++)flag[i]=1;
	for (int i=0;i<=50;i++)S[i].reset();
	for (int i=0;i<=50;i++)S[i].set(i);
	for (int i=1;i<=50;i++)
		if (flag[i])for (int j=i;j<=50;j++)S[j]|=S[j%i];
	int Flag=1;
	for (int i=1;i<=n;i++)
		if (!S[a[i]][b[i]])Flag=0;
	for (int i=1;i<x;i++)flag[i]=0;
	return Flag;	
} 
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)scanf("%lld",&b[i]);
	int ans=0;
	if (!check(51)){
		puts("-1");
		return 0;
	}
	for (int i=50;i;i--)
		if (!check(i))flag[i]=1,ans+=1ll<<i;
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2002019;
int n,ct[N];
int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<n;i++)++ct[read()];
	for(int i=1;i<=n;i++)printf("%d\n",ct[i]);
	return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1000
int n,maxm=0;
int a[MAX_N];
int t[MAX_N];


bool solve(){

  if(t[maxm]==n && maxm==1){
    if(n==2)return true;
    else return false;
  }
  
  for(int i=0;i<n;i++){
    if(a[i]<maxm/2)return false;
  }
    
  if(maxm%2==0){
    for(int i=maxm;i>maxm/2;i--){
      t[i]-=2;
      if(t[i]<0)return false;
    }
    
    t[maxm/2]--;
    if(t[maxm/2]<0)return false;

    for(int i=0;i<=maxm/2;i++){
      if(t[i]>0)return false;
    }
    
    return true;
    
  }else{

    for(int i=maxm;i>maxm/2;i--){
      t[i]-=2;
      if(t[i]<0)return false;
    }

    for(int i=0;i<=maxm/2+1;i++){
      if(t[i]>0)return false;
    }
        
    return true;
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    maxm=max(maxm,a[i]);
    t[ a[i] ]++;
  }

  if(solve())cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  

  return 0;
}


Measured memory_bytes: 256
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    string s, t; cin >> s >> t;
    print(s == t.substr(0, s.length()) ? "Yes" : "No");
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n;
    cin>>n;
    vl h(n);
    forr(i, n)  cin>>h[i];
    map<ll, ll> mp1;
    ll ans=0;
    for(ll i=0; i<n; i++)
    {
        if(mp1.find(i-h[i])==mp1.end())
        {
            mp1[h[i]+i]++;
        }
        else
        {
            ans+=mp1[i-h[i]];
            mp1[i+h[i]]++;
        }
    }
    cout<<ans;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 17000
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    string result;

    cin >> s;

    for(int i = 0; i < s.size(); i++) {
        if(i % 2 == 0) {
            result += s[i];
        }
    }

    cout << result << endl;
    
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
int N;
int ans;
std::vector<int> M;
int D[1000000];
int main(){
	std::cin>>N;
	for(int i=1;i<=N;i++){
		D[i]=100010;
	}
	int m=1;
	while(m<=N){
		for(int i=0;i<N;i++){
			D[i+m]=std::min(D[i+m],D[i]+1);
		}
		m*=6;
	}
	m=9;
	while(m<=N){
		for(int i=0;i<N;i++){
			D[i+m]=std::min(D[i+m],D[i]+1);
		}
		m*=9;
	}
	std::cout<<D[N]<<std::endl;
	return 0;
}


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

int N, M;
int S[10];
int P[10];

bool solve(int k) {
  rep(i, M) {
    int x = k & S[i];
    int cnt = 0;
    rep(j, 10) {
      cnt += (x >> j) & 1;
    }
    if (P[i] != cnt % 2) return false;
  }
  return true;
}

int main() {
  cin >> N >> M;
  rep(i, M) {
    int k;
    cin >> k;
    int x = 0;
    rep(j, k) {
      int s;
      cin >> s;
      --s;
      x += (1 << s);
    }
    S[i] = x;
  }
  rep(i, M) cin >> P[i];

  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    if (solve(i)) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

int C(const vec<int>& A, int n)
{
   rep(i, 0, SZ(A)) {
      n -= n % A[i];
   }
   return n;
}

int lower(const vec<int>& A)
{
   int l = 0, r = INF;
   int m;
   while (r - l > 1) {
      m = (l + r) / 2;
      if (C(A, m) >= 2) {
         r = m;
      } else {
         l = m;
      }
   }
   return r;
}
int upper(const vec<int>& A)
{
   int l = 0, r = INF;
   int m;
   while (r - l > 1) {
      m = (l + r) / 2;
      if (C(A, m) > 2) {
         r = m;
      } else {
         l = m;
      }
   }
   return l;
}

signed main()
{
   int K; cin >> K;
   vec<int> A(K);
   rep(i, 0, K) {
      cin >> A[i];
   }

   int L = lower(A);
   int U = upper(A);

   if (L < U) {
      printf("%lld %lld\n", L, U);
   } else {
      printf("%d\n", -1);
   }

   return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int minNumber(int n) {
  return n/5 + (n%5)/4 + (n%5%4)/3 + (n%5%4%3)/2 + (n%5%4%3%2);
}

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

  int n;
  cin >> n;

  if (n / 100 < minNumber(n%100))
    cout << 0 << endl;
  else
    cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.BitSet;

public class Main {
	public static void main(String[] args) throws IOException {
		BitSet bs = new BitSet(1000000);
		bs.set(0, 1000000);
		bs.clear(0);
		bs.clear(1);
		for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
			int val = i;
			do {
				val += i;
				bs.clear(val);
			} while (val < 1000000);
		}
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while ((s = br.readLine()) != null) {
			System.out.println(bs.get(0, Integer.parseInt(s) + 1).cardinality());
		}
	}
}

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

int a[200005], b[200005];

int fin(int x) {
    return x == a[x] ? x : a[x] = fin(a[x]);
}

void solve() {
    int n, m, maxn = 0;
    cin >> n >> m;
    for (int j = 0; j <= n; ++j)  a[j] = j, b[j] = 1;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        int fx = fin(x);
        int fy = fin(y);
        if (fx != fy) a[fx] = fy, b[fy] += b[fx];
    }
    for (int k = 1; k <= n; ++k)  if (b[k] > maxn) maxn = b[k];
    cout << maxn;
}

signed main() {
    int n = 1;
    while (n--) {
        solve();
    }
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int rec(int ix, int turn, vector<int>& A, vector<vector<int>>& memo)
{
  if (memo[ix][turn] != -1) { return memo[ix][turn]; }
  int n = A.size();
  int ret = (turn == 0) ? -INF : INF;
  for (int i = ix + 1; i < n; ++i) {
    int score = -1;
    if (i == n - 1) {
      score = abs(A[i] - A[ix]);
    }
    else {
      score = rec(i, 1 - turn, A, memo);
    }
    ret = (turn == 0) ? max(ret, score) : min(ret, score);
  }
  return memo[ix][turn] = ret;
}

int main()
{
  int N, Z, W; scanf("%d %d %d", &N, &Z, &W);
  vector<int> A(N + 1);
  A[0] = W;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
  }

  vector<vector<int>> memo(2005, vector<int>(2, -1));
  int ans = rec(0, 0, A, memo);
  printf("%d\n", ans);
  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll factorial[100050];

int main() {
    factorial[0] = 1;
    for(ll i = 1; i <= 100000; i++) {
        factorial[i] = (factorial[i - 1] * i) % mod;
    }
    //cout.precision(10);
    ll N, M;
    cin >> N >> M;
    ll factor = 1;
    if(abs(N - M) >= 2) {
        cout << 0 << endl;
        return 0;
    }
    if(N == M) factor = 2;
    //cout << factor << endl;
    cout << (factor * factorial[N] % mod) * factorial[M] % mod << endl;;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int num(int n)
{
    if(n%2==0)
        return n/2;
    else
        return 3*n+1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    vector <int> a(1000000);
    cin>>a[0];
    int i;
    for(i=1;i<a.size();++i)
    {
        a[i]=num(a[i-1]);
        if(find(a.begin(),a.begin()+i,a[i])!=a.begin()+i)
            break;
    }
    /*for(int j=0;j<=i;++j)
        cout<<a[j]<<" ";*/
    cout<<i+1;
    return 0;
}


Measured memory_bytes: 4224
local mfl, mce = math.floor, math.ceil
local mod = 1000000007
local function badd(x, y) return (x + y) % mod end
local function bmul(x, y) return (x * y) % mod end

local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end
local primes = getprimes(31623)

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local fact = {1}
for i = 2, 101000 do
  fact[i] = bmul(fact[i - 1], i)
end

local function getComb(n, k)
  return bmul(fact[n], modinv(bmul(fact[k], fact[n - k])))
end

local n, m = io.read("*n", "*n")
local tm = m
local ret = 1
if n == 1 then
  print(1)
else
  for i = 1, #primes do
    local p = primes[i]
    if tm < p * p then break end
    local cnt = 0
    while tm % p == 0 do
      tm = tm // p
      cnt = cnt + 1
    end
    if 0 < cnt then
      ret = bmul(ret, getComb(n + cnt - 1, n - 1))
    end
  end
  if tm ~= 1 then
    ret = bmul(ret, n)
  end
  print(ret)
end


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,su=0;
    string a,s,d;
    cin>>n>>a>>s>>d;
    set<char>se;
    for(i=0;i<n;i++)
    {
        se.insert(a[i]);
        se.insert(s[i]);
        se.insert(d[i]);
        su+=se.size()-1;
        se.clear();
    }
    cout<<su<<endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n;
    cin>>n;
    ll b =sqrt(n)+1;
    ll i;
    // check n
    set< ll > s;
    s.insert(n);
    FOR(i, 2, b)
    {
        ll cur = n;
        while(cur%i == 0) cur /= i;
        if(cur%i == 1) s.insert(i);
    }
    // check n-1
    if(n > 2)
    {
        s.insert(n-1);
        b = sqrt(n-1) + 1;
        FOR(i, 2, b)
        {   
            if((n-1)%i == 0)
            {
                s.insert(i);
                s.insert((n-1)/i);
            }
        }
    }
    cout<<s.size()<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 101

int main()
{
  int i,j,n,count=0,v,c,c1,v1;
  int G[N][N],col[N],d[N],pi[N],mincost,i2;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++)
      G[i][j] = -1;
  }

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d%d",&v,&c);
    for(j = 0; j < c; j++){
      scanf("%d%d",&v1,&c1);
      G[v][v1] = c1;
    }
  }

  for(i = 0; i < n; i++){
    col[i] = 0;
    pi[i] = -1;
    d[i] = 10000001;
  }

  d[0] = 0;

  while(1){
    mincost = 10000001;
    for(i = 0; i < n; i++){
      if(col[i] != 2 && d[i] < mincost){
        mincost = d[i];
        i2 = i;
      }
    }
    if(mincost == 10000001)break;

    col[i2] = 2;


    for(i = 0; i < n; i++){
      if(G[i2][i] != -1 && col[i] != 2 && (G[i2][i]+d[i2]) < d[i]){
        pi[i] = i2;
        d[i] = G[i2][i] + d[i2];
        col[i] = 1;
      }
    }
  }
  for(i = 0; i < n; i++)printf("%d %d\n",i,d[i]);
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>

using namespace std;

int main(){
	long long s;
	scanf("%lld",&s);
	int z=1e9;
	int z2=(s+z-1)/z;
	printf("%d %d %d %d %d %d\n",0,0,z,(int)(1ll*z*z2-s),1,z2);
}


Measured memory_bytes: 1724
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b, c;
	string s;
	cin>>a>>b>>s;
	bool res = s.size()==a+b+1;
	if(res) rep(i, a+b+1){
		if(i==a) res &= s[i]=='-';
		else res &= ('0'<=s[i]&&s[i]<='9');
	}
	cout<<(res?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n, k := readInt(), readInt()

	fmt.Println(min(n%k, abs(n%k-k)))
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
int N,H,W;
int y,x;
vector<int> G[2][MAX];
bool visited[2][MAX];
int flg[4],cnt[4];
 
void dfs(int f,int p){
  visited[f][p]=true;
  if(p==1)flg[f]=true;
  if(p==(f==0?H:W))flg[2+f]=true;
   
  int r=1-f;
  for(int i=0;i<(int)G[f][p].size();i++){
    int w=G[f][p][i];
    if(visited[r][w])continue;
    dfs(r,w);
  }
}
 
int main(){
  scanf("%d %d %d",&N,&H,&W);
  for(int i=0;i<N;i++){
    scanf("%d %d",&y,&x);
    G[0][y].push_back(x);
    G[1][x].push_back(y);
  }
   
  int ans=0;
  for(int i=0;i<MAX;i++){
    if(G[0][i].size()==0)continue;
    if(visited[0][i])continue;
    for(int j=0;j<4;j++)flg[j]=0;
    dfs(0,i);
    ans++;
    for(int j=0;j<4;j++)cnt[j]+=flg[j];
  }
  for(int i=1;i<4;i++)cnt[i]=max(cnt[i],cnt[i-1]);
  if(ans==1){
    cout<<N-1<<endl;
  }else{
    cout<<N+ans-1-cnt[3]<<endl;
  }
  return 0;
}

Measured memory_bytes: 10140
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  string O, E;
  cin >> O >> E;
  for (auto oi = O.begin(), ei = E.begin(); oi != O.end(); ++oi) {
    cout << (*oi);
    if (ei != E.end()) {
      cout << (*ei);
      ++ei;
    }
  }
  return 0;
}


Measured memory_bytes: 3612
n,m,x = map(int,input().split())
ca = [[int(i) for i in input().split()] for j in range(n)]
stack = [0 for i in range(n)]
cmin = 12345678
while not stack==[]:
    s = [0 for i in range(m+1)]
    for i in range(n):
        if stack[i]==1:
            for j in range(m+1):
                s[j] += ca[i][j]
    if s[0]<cmin:
        xok = True
        for i in range(1,m+1):
            if s[i]<x:
                xok = False
        if xok:
            cmin = s[0]
    for i in range(n):
        p = stack.pop()
        if p == 0:
            stack.append(1)
            for j in range(i):
                stack.append(0)
            break
        
if cmin==12345678:
    print(-1)
else:
    print(cmin)


Measured memory_bytes: 9072
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim()
{
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while (1)
    {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++)
        {
            if (minv > d[i] && color[i] != BLACK)
            {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1)
            break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++)
        {
            if (color[v] != BLACK && M[u][v] != INFTY)
            {
                if (d[v] > M[u][v])
                {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i] != -1)
            sum += M[i][p[i]];
    }

    return sum;
}

int main()
{
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim() << endl;

    return 0;
}


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

int main() {
	int n;
	double ans=0;
	cin>>n;
	vector<double>v(n);
	for(int i=0;i<n;i++)cin>>v.at(i);
	sort(v.begin(),v.end());
	for(int i=0;i<n-1;i++){
		v.at(i+1)=(v.at(i)+v.at(i+1))/2.00000;
		ans=v.at(i+1);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int k,n;cin>>k>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		int a;cin>>a;
		arr[i] = a;
	}
	sort(arr,arr+n);
	int ans=0;
	if(n==1){
		ans = arr[0]-1;	
	}
	else{
		int sum=0;
		for(int i=0;i<n-1;i++){
			sum += arr[i];
		}
		sum += arr[n-2];
		ans = max(0,arr[n-1]-arr[n-2]-(sum+1-2*arr[n-2]));
	}
	cout<<ans<<endl;
}

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

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

  long x[N];

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

  long t = -1;

  for (int i = 0; i + K - 1 < N; i++) {
    if (t == -1) {
      t = abs(x[i] - x[i + K - 1]) + abs(x[i]);
    } else {
      t = min(t, abs(x[i] - x[i + K - 1]) + abs(x[i]));
    }
    t = min(t, abs(x[i] - x[i + K - 1]) + abs(x[i + K - 1]));
  }

  cout << t << endl;
}

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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl


int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >> N;
    vector<double> v(N); cin >> v;

    sort(ALL(v));
    for (int i = 0; i < N - 1; i++)
        v[i + 1] = (v[i] + v[i + 1]) / 2;

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


Measured memory_bytes: 256