akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	double n, d, x; cin >> n >> d >> x;
	vi a(n); readv(a);
	
	int res = 0;
	FOR(i, 0, n){
		res += ceil(d / a[i]);
		debug() << imie(res);
	}
	
	cout << res + x << endl;
	
	return 0;
}


Measured memory_bytes: 3844
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> a(M);
    for (ll i = 0; i < M; i++) {
        cin >> a[i];
    }

    vector<bool> ok(N + 1, true);
    for (ll i = 0; i < M; i++) {
        ok[a[i]] = false;
    }

    constexpr ll MOD = 1e9 + 7;
    ll pre1 = 1, pre2 = 0;
    vector<ll> dp(N + 1, 0);
    dp[0] = 1;
    dp[1] = (ok[1] ? 1 : 0);
    for (ll i = 2; i <= N; i++) {
        if (ok[i]) {
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
        } else {
            dp[i] = 0;
        }
    }

    cout << dp[N] << endl;
}

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

int main(){
  double a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f){
    double matrix = 1/(a*e-b*d);
    double x = matrix*(e*c-b*f);
    double y = matrix*(a*f-d*c);
    if(x==-0.0) x=0.0;
    if(y==-0.0) y=0.0;
    printf("%4.3f %4.3f\n",x,y);
  }
}

Measured memory_bytes: 1236
n, k = list(map(int, input().split()))
okasi = [False] * n
for i in range(k):
    d_len = int(input())
    d = list(map(int, input().split()))
    for j in range(d_len):
        okasi[d[j]-1] = True

s = 0
for i in range(n):
    if okasi[i]==False:
        s += 1
print(s)

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

int main() {
  string s;
  cin >> s;

  pair<int, int> ans = make_pair(-1, -1);

  for(int i=0;i<s.size()-1;i++) {
    if(s[i] == s[i+1]) {
      ans.first = i+1;
      ans.second = i+2;
      break;
    }
  }

  for(int i=0;i<s.size()-2;i++) {
    if(s[i] == s[i+2]) {
      ans.first = i+1;
      ans.second = i+3;
      break;
    }
  }

  cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 512
<?php
fscanf(STDIN,"%d",$n);
for ($i=0; $i<$n; $i++)
	fscanf(STDIN,"%d %d",$x[$i][0],$x[$i][1]);

foreach ((array) $x as $key => $value)
    $sort[$key] = $value['1'];
array_multisort($sort, SORT_ASC, $x);

$sum=0;
$result="Yes";
for ($i=0; $i<$n; $i++)
{ 
	$sum+=$x[$i][0];
	if($sum>$x[$i][1])
	{
		$result="No";
		break;
	}
}
echo($result . "\n");

Measured memory_bytes: 123756
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
print((1000 - N % 1000) % 1000)

Measured memory_bytes: 10924
A,B = gets.strip.split.map(&:to_i)
i = 1
until (i*0.08).floor==A && (i*0.10).floor==B do
  i += 1
  if i > 1250 then
    break
  end
end
if i > 1250 then
  puts "-1"
else
  puts i
end

Measured memory_bytes: 14352
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int K, C;
char S[200011];
int L[200011];

void MAIN() {
    scanf("%d%d%d", &N, &K, &C);
    scanf("%s", S);

    int cnt = 0;
    int rest = 0;
    REP (i, N) {
	if (rest) rest--;
	if (rest == 0 && S[i] == 'o') {
	    L[i] = ++cnt;
	    rest = C+1;
	}
    }

    VI ans;
    cnt = K;
    rest = 0;
    for (int i=N; i--;) {
	if (rest) rest--;
	if (rest == 0 && S[i] == 'o') {
	    if (cnt > 0 && L[i] == cnt) ans.push_back(i);
	    cnt--;
	    rest = C+1;
	}
    }

    reverse(ans.begin(), ans.end());
    EACH (e, ans) printf("%d\n", *e+1);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3444
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, d;
	cin >> n >> d;
	vector<vector<int> > vv;
	for (int i = 0; i < n; i++) {
		vector<int> v;
		for (int j = 0; j < d; j++) {
			int t;
			cin >> t;
			v.push_back(t);
		}
		vv.push_back(v);
	}

	int res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int c = 0;
			for (int k = 0; k < d; k++) {
				c += (vv[i][k] - vv[j][k]) * (vv[i][k] - vv[j][k]);
			}
			int r = pow(c, 0.5);
			if (r * r == c)
				res++;
		}
	}
	cout << res << endl;
}














Measured memory_bytes: 256
N=int(input())
U,R,D,L=[],[],[],[]
for i in range(N):
  x,y,a=input().split()
  x,y=int(x),int(y)
  if a=='U':
    U.append((x,y))
  elif a=='R':
    R.append((x,y))
  elif a=='D':
    D.append((x,y))
  elif a=='L':
    L.append((x,y))

G={}
for x,y in U:
  if x not in G:
    G[x]=[(y,'U')]
  else:
    G[x].append((y,'U'))
for x,y in D:
  if x not in G:
    G[x]=[(y,'D')]
  else:
    G[x].append((y,'D'))  

time=10**10
for i in G.values():
  a=len(i)
  i=sorted(i)
  for j in range(a-1):
    if i[j][1]=='U' and i[j+1][1]=='D':
      t=(i[j+1][0]-i[j][0])*5
      time=min(t,time)
G={}
for x,y in R:
  if y not in G:
    G[y]=[(x,'R')]
  else:
    G[y].append((x,'R'))
for x,y in L:
  if y not in G:
    G[y]=[(x,'L')]
  else:
    G[y].append((x,'L'))  

for i in G.values():
  a=len(i)
  i=sorted(i)
  for j in range(a-1):
    if i[j][1]=='R' and i[j+1][1]=='L':
      t=(i[j+1][0]-i[j][0])*5
      time=min(t,time)
#UとR
G={}
for x,y in U:
  if x+y not in G:
    G[x+y]=[(y,'R')]
  else:
    G[x+y].append((y,'R'))
for x,y in R:
  if x+y not in G:
    G[x+y]=[(y,'U')]
  else:
    G[x+y].append((y,'U'))
for i in G.values():
  a=len(i)
  i=sorted(i) 
  for j in range(a-1):
    if i[j][1]=='R' and i[j+1][1]=='U':
      t=(i[j+1][0]-i[j][0])*10
      time=min(t,time)
#DとR
G={}
for x,y in D:
  if x-y not in G:
    G[x-y]=[(y,'D')]
  else:
    G[x-y].append((y,'D'))
for x,y in R:
  if x-y not in G:
    G[x-y]=[(y,'R')]
  else:
    G[x-y].append((y,'R'))
for i in G.values():
  a=len(i)
  i=sorted(i) 
  for j in range(a-1):
    if i[j][1]=='R' and i[j+1][1]=='D':
      t=(i[j+1][0]-i[j][0])*10
      time=min(t,time)
#DとL
G={}
for x,y in D:
  if x+y not in G:
    G[x+y]=[(y,'D')]
  else:
    G[x+y].append((y,'D'))
for x,y in L:
  if x+y not in G:
    G[x+y]=[(y,'L')]
  else:
    G[x+y].append((y,'L'))
for i in G.values():
  a=len(i)
  i=sorted(i) 
  for j in range(a-1):
    if i[j][1]=='L' and i[j+1][1]=='D':
      t=(i[j+1][0]-i[j][0])*10
      time=min(t,time)
#最後UL
G={}
for x,y in U:
  if x-y not in G:
    G[x-y]=[(y,'U')]
  else:
    G[x-y].append((y,'U'))
for x,y in L:
  if x-y not in G:
    G[x-y]=[(y,'L')]
  else:
    G[x-y].append((y,'L'))
for i in G.values():
  a=len(i)
  i=sorted(i) 
  for j in range(a-1):
    if i[j][1]=='U' and i[j+1][1]=='L':
      t=(i[j+1][0]-i[j][0])*10
      time=min(t,time)
if time==10**10:
  print('SAFE')
else:
  print(time)


Measured memory_bytes: 90432
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

#define MOD 1000000007

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);
  for(int i=0;i<N;i++)  cin >> B.at(i);
  for(int i=0;i<N;i++)  cin >> C.at(i);
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());

  long long ans=0;
  for(int i=0;i<N;i++){
    int b=B.at(i);
    ans+=distance(A.begin(),lower_bound(A.begin(),A.end(),b))*distance(upper_bound(C.begin(),C.end(),b),C.end());
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
string s[200010];
vector<string> ans[200010];
int main(){
    int n;
    cin >> n;
    rep(i, 0, n) cin >> s[i];
    sort(s, s + n);
    int max_cnt = 0, cnt = 0;
    string now = s[0];
    rep(i, 0, n){
        if(now == s[i]){
            cnt++;
        }else{
            ans[cnt].push_back(now);
            max_cnt = max(cnt, max_cnt);
            now = s[i];
            cnt = 1;
        }
    }
    ans[cnt].push_back(now);
    max_cnt = max(cnt, max_cnt);

    rep(i, 0, ans[max_cnt].size()){
        cout << ans[max_cnt][i] << endl;
    }
    return 0;
}

Measured memory_bytes: 20596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		out.println(sc.nextInt()*sc.nextInt()%2==0?"Even":"Odd");
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 20436
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    if((10*g+b)%4==0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		while(true){
			int x = scan.nextInt();
			int y = scan.nextInt();

			if(x == 0 && y == 0){
				break;
			}else{
				if(y < x){
					int a;
					a = x;
					x = y;
					y = a;
					System.out.println(x + " " + y);
				}else{
					System.out.println(x + " " + y);
				}
			}
		}
	}
}

Measured memory_bytes: 36504
#include <stdio.h>

void swap(int *x,int *y) {
	int tmp = *x;
	*x = *y;
	*y = tmp;
}
int main(void) {
	int x, y, z;
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &z);
	swap(&x, &y);
	swap(&x, &z);

	printf("%d %d %d", x, y, z);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 250

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=0;i<H;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<H;i++){
    printf("node %d: key = %d, ",i+1,A[i]);

    if(i){
      printf("parent key = %d, ",A[(i+1)/2-1]);
    }

    if(2*i+1 < H){
      printf("left key = %d, ",A[2*i+1]);
    }
    if(2*i+2 < H){
      printf("right key = %d, ",A[2*i+2]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2048
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        //モンスターの体力
        int H = Integer.valueOf(s.next());
        //魔法の種類
        int N = Integer.valueOf(s.next());
        //体力減少
        int[] HPdown = new int[N+1];
        //魔法減少
        int[] MPcost = new int[N+1];

		for(int i = 0; i < N; i++) {
			HPdown[i] = Integer.valueOf(s.next());
			MPcost[i] = Integer.valueOf(s.next());
        }
    
		//動的
        long[] dp = new long[20000];
        //整頓
        Arrays.fill(dp, 100000001);
        //初期値(0)設定
		dp[0] = 0;
        //魔法の種類だけくり返す
		for(int i = 0; i < N; i++) {
            //i=0
            //10^4繰り返す
			for(int j = 0; j < 10000; j++) {
                    //あるHP値への到達方法に対して
                    //既存の方法と、新しい方法、より低コストな方を選択
                    dp[j+HPdown[i]] =
                    Long.min(dp[j+HPdown[i]], dp[j] + MPcost[i]);
			}
        }
        //目標値以上の到達方法のなかから、最小のものを選択
		for(int i = 10001; i >= 0; i--) {
			dp[i] = Long.min(dp[i], dp[i+1]);
		}
		System.out.println(dp[H]);
    }
}
    


    

Measured memory_bytes: 39196
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=1)
B.sort(reverse=1)
C.sort(reverse=1)

#print(len(A),len(B),len(C))
# print(A[:20])
# print(B[:20])
# print(C[:20])

def d4(p):
    co = 0
    for i in range(x):
        if A[i] + B[0] + C[0] < p:
            break
        else:
            for j in range(y):
                if A[i] + B[j] + C[0] < p:
                    break
                else:
                    for l in range(z):
                        #print(i,j,l)
                        # if i==14 and l==0 and j==0:
                        #     print("t",A[i] + B[j] + C[l])
                        if A[i] + B[j] + C[l] < p:
                            break
                        else:
                            #D.append([A[i] + B[j] + C[l], i, j, l])
                            co += 1
                            if co == k:
                                return True
    return False

ri = A[0]+B[0]+C[0] + 1
le = 0
mid = (le + ri) // 2

#lr = []

while ri - le > 1:
    #D = []
    #print("le",le,"mid",mid,"ri",ri)
    d4bool = d4(mid)
    if d4bool:
        le = mid
    else:
        ri = mid
    mid = (le + ri) // 2
    #lr.append([le,ri])

D = []

p = le
for i in range(x):
    if A[i] + B[0] + C[0] < p:
        break
    else:
        for j in range(y):
            if A[i] + B[j] + C[0] < p:
                break
            else:
                for l in range(z):
                    if A[i] + B[j] + C[l] < p:
                        break
                    else:
                        D.append(A[i] + B[j] + C[l])


D.sort(reverse=1)

#dd = len(D)

while len(D) < k:
    D.append(le)

# fa = open("d4.txt", "w")

for i in range(k):
    #fa.write(str(i)+" "+str(D[i])+"\n")
    print(D[i])

# fa.close()

# coo = 0
# for i in range(len(D)):
#     if D[i] >= 2977:
#         coo += 1
# print(coo)
# print(dd)
# print(lr)

Measured memory_bytes: 187500
#include <iostream>
using namespace std;
int main(void)
{
    int x, a, b;
    int A, B;
    cin >> x >> a >> b;
    if(a-x > 0){
        A = a-x;
    }else{
        A = x-a;
    }
    if(b-x > 0){
        B = b-x;
    }else{
        B = x-b;
    }

    if(A < B){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;

// Graph.h start--------------------------------------------
#pragma once

#include <vector>

using Weight = long long;

struct Vertex;
using Vertices = std::vector<Vertex *>;
struct Edge;
using Edges = std::vector<const Edge *>;

struct Vertex {
	const int id;
	Edges edges;
	Vertex(int id);
	void add_edge(const Edge *const p_e);
	void add_edge(const Edges &es);
};

struct Edge {
	Vertex *p_src, *p_dst;
	Weight weight;
	
	Edge(Vertex *p_src, Vertex *p_dst, Weight weight);
	Edge(const Edge &e);
	Edge& operator = (const Edge &de);
};

struct Graph {
	Vertices vertices;
	Edges edges;
	Graph(int nvertices);
	Graph();
	~Graph();
	void add_edge(Edge *p_edge);
	void add_edge(int edge_src, int edge_dst, Weight w);
};

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

using namespace std;

Vertex::Vertex(int id) : id(id) { }
void Vertex::add_edge(const Edge *const p_e) {
	edges.push_back(p_e);
}
void Vertex::add_edge(const Edges &es) {
	for (const auto &p_e : es) {
		add_edge(p_e);
	}
}

Edge::Edge(Vertex *p_src, Vertex *p_dst, Weight weight) : p_src(p_src), p_dst(p_dst), weight(weight) { }
Edge::Edge(const Edge &e) : Edge(e.p_src, e.p_dst, e.weight) {}
Edge& Edge::operator = (const Edge &e) {
	p_src = e.p_src;
	p_dst = e.p_dst;
	weight = e.weight;
	return *this;
}
bool operator < (const Edge &e1, const Edge &e2) {
	return e1.weight != e2.weight ? e1.weight > e2.weight : // !!INVERSE!!
		e1.p_src != e2.p_src ? e1.p_src->id < e2.p_src->id : e1.p_dst->id < e2.p_dst->id;
}

Graph::Graph(int nvertices) {
	for (int id = 0; id < nvertices; id++) {
		vertices.push_back(new Vertex(id));
	}
}
Graph::Graph() : Graph(0) {}
Graph::~Graph() {
	for (auto &p_vertex : vertices) {
		delete p_vertex;
	}
	for (auto &p_edge : edges) {
		delete p_edge;
	}
}
void Graph::add_edge(Edge *p_edge) {
	vertices[p_edge->p_src->id]->add_edge(p_edge);
	edges.push_back(p_edge);
}
void Graph::add_edge(int edge_src, int edge_dst, Weight w) {
	add_edge(new Edge(vertices[edge_src], vertices[edge_dst], w));
}

// Graph.h end----------------------------------------------
vector<bool> is_filled;

void fill(int s, int d, Graph& g) {
	is_filled[d] = true;
	for (const auto &p_e : g.vertices[d]->edges) {
		int nd = p_e->p_dst->id;
		if (is_filled[nd])
			continue;
		fill(d, nd, g);
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> x(M), y(M);
	for (int i = 0; i < M; i++)
	{
		int dummyz;
		cin >> x[i] >> y[i] >> dummyz;
	}
	Graph g(N + 1);
	for (int i = 0; i < M; i++)
	{
		g.add_edge(x[i], y[i], 0);
		g.add_edge(y[i], x[i], 0);
	}

	is_filled = vector<bool>(N + 1, false);
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		if (is_filled[i])
			continue;
		fill(0, i, g);
		ans++;
	}

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


Measured memory_bytes: 22128
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
long long int modp(lld a,lld p,lld n)
{
   lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

//lld fac[100001]; 
/*
void solve2()
{
   lld p=1000000007;
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}
*/
lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;
//vector< vector <lld > > v(100001);
/*
void bfs(lld x , vector<lld>& d)
{
    d[x]=0;
    q.pu(x);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            y=v[x][i];
            if(d[y]==INF) 
            {
                d[y] = d[x]+1;
                q.pu(y);
            }       
        }
    }

}
/*

lld DFS(lld a ,lld x)
{
    visited[a] =true;
    sub_size[a]=1;
 //   if(a==x) 
   //     cont[a] =true;
    lld l= v[a].size();
    for(lld i=0;i<l;i++)
    {
        if(visited[v[a][i]] == false)
        {
            sub_size[a]+= DFS(v[a][i],b);
//            if(cont[v[a][i]] ==true ) cont[a]=true;
        }
    }
    return sub_size[a];

}
*/

void solve()
{
    cin>>x;
    n=0;
    for(i=-200;i<=200;i++)
    {
        for(j=-200;j<=200;j++)
        {
            n=(i*i*i*i*i)-(j*j*j*j*j);
            if(n==x)
            {
                cout<<i<<" "<<j;
                return;
            }
        }
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
 //   cin>>t;
 //   solve2();
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
        solve();
    //    cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3612
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <iostream>
using namespace std;
long long int n, a[100010], b[100010], cnt = 0;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = n; i > 0; i--) {
		if ((cnt + a[i]) % b[i]) {
			cnt += b[i] - ((cnt + a[i]) % b[i]);
		}
	}
	cout << cnt << endl;
	return 0;
}


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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

double n, a, x, y, z;
double dp[301][301][301];

double calc(int i, int j, int k){
	if(dp[i][j][k]!=-1) return dp[i][j][k];
	if(i==0 && j==0 && k==j) return 0;
	double ans=1;
	int z = n-(i+j+k);
	if(i) ans+=(double)i/(double)n*(dp[i-1][j][k]=calc(i-1, j, k));
	if(j) ans+=(double)j/(double)n*(dp[i+1][j-1][k]=calc(i+1, j-1, k));
	if(k) ans+=(double)k/(double)n*(dp[i][j+1][k-1]=calc(i, j+1, k-1));
	ans*=(double)n/(double)(n-z);
	return dp[i][j][k]=ans;
}

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cout << setprecision(9) << fixed;
  x=0; y=0; z=0;
  cin >> n;
  rep(i, 1, n){
  	cin >> a;
  	if(a==1) x++;
  	else if(a==2) y++;
  	else z++;
  }
  rep(i, 0, n){
  	rep(j, 0, n){
  		rep(k, 0, n){
  			dp[i][j][k]=-1;
  		}
  	}
  }
  cout << calc(x, y, z);
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	string s,t; cin >> s >> t;
	vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
	repp(i,0,s.size()) repp(j,0,t.size()){
		dp[i+1][j+1] = max(dp[i][j]+(s[i]==t[j]?1:0),max(dp[i+1][j],dp[i][j+1]));
	}
	stack<char> ans;
	int x = s.size(), y = t.size();
	while(x > 0 && y > 0){
		if(s[x-1]==t[y-1] && dp[x][y] == dp[x-1][y-1]+1){
			ans.push(s[x-1]);
			--x; --y;
		} else if(dp[x][y] == dp[x-1][y]){
			--x;
		} else{
			--y;
		}
	}
	while(ans.size() != 0){cout << ans.top(); ans.pop();}
	cout << endl;
	return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979

//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    rep(i, 1, 10){
        rep(j, 1, 10){
            if (i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){ 
  int n;
  cin >> n;
  string s;
  cin >> s;
  set<string> w;
  set<string> a;
  for (char cur: s){
    w = a;
    for (auto c: w){
      if (len(c) < 3){
        a.insert(c+cur);
      }
    }
    string t;
    t += cur;
    a.insert(t);
  }
  int ans = 0;
  for (auto c: a){
    if (len(c) == 3) ans++;
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 



9 8 7 10 5 6 3 4 2 1 * 9 8 7 10 5 6 3 4 2 1 * 9 8 7 10 5 6 3 4 2 1

 */

Measured memory_bytes: 512
#include <stdio.h>

void fibo(int);
  
int main()
{
  int n;

  scanf("%d",&n);

  fibo(n);

  return 0;
}

void fibo(int n)
{
  int F[n+1],i;

  F[0]=1;
  F[1]=1;
  
  for(i=2;i<=n;i++)
    {
      F[i]=F[i-2]+F[i-1];
    }

  printf("%d\n",F[n]);
}



Measured memory_bytes: 2088
//============================================================================
// Name        : Atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int management(){
	int N;
		cin >> N;

		int A[N];
		int B[N] = {0};

		for(int i = 1;i < N;i++){
			cin >> A[i];
			B[A[i] - 1]++;
		}

		for(int i = 0;i < N;i++){
			cout << B[i] << "\n";
		}

		return 0;
}


int main() {
	//homework();
	management();
}

Measured memory_bytes: 5036
/* ***************************************************
 *	Author        :mutinner
 *	Created Time  :Sat 05 May 2018 08:12:42 PM CST
 *	File Name     :20:12:42.cpp
 *************************************************** */

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

int main() {
	int n, m;	cin >> n >> m;
	vector< string > cnt( n );
	vector< vector<int> > vis( n );
	for ( auto & it : cnt ) {
		cin >> it;
	}
	for ( auto & it : vis ) {
		it.assign( m, 0 );
	}
	auto judge = [&]( int x, int y ) {
		if ( x < 0 || y < 0 || x >= n || y >= m || vis[ x ][ y ] || cnt[ x ][ y ] == '.' ) {
			return false;
		}
		return true;
	};
	function< int ( int, int ) > dfs = [&]( int x, int y ) {
		if ( !judge( x, y ) ) {
			return 0;
		}
		vis[ x ][ y ] = 1;
		return dfs( x + 1, y ) + dfs( x, y + 1 ) + dfs( x - 1, y ) + dfs( x, y - 1 ) + 1;
	};
	int flag = 0;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < m; j++ ) {
			if ( cnt[ i ][ j ] == '#' && dfs( i, j ) == 1 ) {
				flag = 1;
			}
		}
	}
	cout << ( flag == 0 ? "Yes" : "No" ) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

signed main()
{
    int n;
    vector<int> p;

    cin >> n;

    p.resize(n);

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

    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            vector<int> pp = p;
            swap(pp[i], pp[j]);

            bool isSorted = true;
            for(int k = 1; k < n; ++k)
            {
                if(pp[k] < pp[k - 1])
                {
                    isSorted = false;
                }
            }

            if(isSorted)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;

    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var l = int.Parse(Console.ReadLine());

        double a = (double)l / 3;

        double result = a * a * a;

        Console.WriteLine(string.Format("{0:0.000000000000}", result));
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <string.h>
#include<algorithm>
#include <numeric>      // std::accumulate
#include <iomanip>      // std::setprecision


using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define v           vector <int>
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define EPS			 1e-9
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;

bool cmp(const pair<int, int>& a, const pair<int, int>& b)
{
    return (a.second < b.second);
}

int gcd(int a, int b) 
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
long long power(ll n, ll k) 
{
    if (k == 0) return 1;
    ll sq = (power(n, k / 2));
    sq = (sq * sq);
    if (k % 2 == 1)
        sq = (sq * n);
    return sq;
}
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
string to_binary(int x) 
{
    string s;
    while (x > 0) 
    {
        s += (x % 2 ? '1' : '0');
        x /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
bool isPerfect(ll x)
{
    if (x < 1) 
        return false;
    ll root(round(sqrt(x)));
    return x == root * root;
}
void solve()
{
    int n, k;
    cin >> n >> k;
    
    v kind(n);

    lp(i, 0, n)
        cin >> kind[i];

    sort(all(kind));
    int ans = 0;
    lp(i , 0 , k)
    {
        ans += kind[i];
    }

    cout << ans << "\n";

}

int main()
{
    IOS;    
    
    int tt;
    tt = 1;
    // cin >> tt;
    while (tt--)
    {
        solve();
    }
    
}
       

Measured memory_bytes: 3148
fun main(args:Array<String>){
  var (n,k) = readLine()!!.split(" ").map(String::toInt)
  var dice:Double = 1.0/n
  var count = 0.0
  var coin = 0.5
  var par = 0.0
  for(i in n downTo 1){
    var o = i
    while(true){
      if(o >= k)break
      o *= 2
      count++
    }
    par += dice * Math.pow(coin,count)
    count = 0.0
  }
  println(par)
}

Measured memory_bytes: 37736
import sys
from collections import deque

while True:
    W, H = map(int, input().split())
    if W == 0:
        break
    (xs, ys), (xg, yg) = map(int, input().split()), map(int, input().split())
    square = [[0]*(W+2) for _ in [0]*(H+2)]
    visited = [[0]*(W+2) for _ in [0]*(H+2)]
    visited[ys][xs] = 1
    N = int(input())
    for c, d, from_x, from_y in (map(int, sys.stdin.readline().split()) for _ in [0]*N):
        to_x, to_y = (from_x+4, from_y+2) if d == 0 else (from_x+2, from_y+4)
        for y in range(from_y, to_y):
            square[y][from_x:to_x] = [c]*(to_x-from_x)

    color = square[ys][xs] or -1
    dq = deque([(ys, xs)])
    popleft, append = dq.popleft, dq.append
    while dq:
        y, x = popleft()
        if y == yg and x == xg:
            print("OK")
            break
        for ny, nx in ((y+1, x), (y-1, x), (y, x+1), (y, x-1)):
            if not visited[ny][nx] and square[ny][nx] == color:
                visited[ny][nx] = 1
                append((ny, nx))
    else:
        print("NG")


Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int f, s;
  cin >> f >> s;
  if (f % 500 != 0){
    if (f - 500*(f / 500) <= s){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "Yes" << endl;
  }
}

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

int main()
{
int i;
int x;
int N;
int K;
int iH;
int iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;

	iH = K / 2;
	iSum = 0;
	for( i = 0; i < N; i++ )
	{
		cin >> x;
		
		if( iH < x )
			iSum += K - x;
		else
			iSum += x;
	}

	cout << iSum * 2 << endl;

	return 0;
}






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

int main(){
	string s;
	cin >> s;
	
	vector<int> sumi(s.size(),0);
	
	reverse(s.begin(),s.end());
	
	int tmp = 10;
	sumi[0] = s[0] -'0';
	vector<int> cnts(2019,0);
	cnts[sumi[0]]++;
	cnts[0] ++;
	int res = 0;
	for(int i=1;i<s.size();++i){
		//cout << i <<endl;
		int a = (s[i] - '0') * tmp;
		//cout << " " << sumi[i-1] << " + " << a << " " << a * tmp <<endl;
		sumi[i] = (sumi[i-1] + a)%2019;
		//cout << sumi[i] << endl;
		res += cnts[sumi[i]];
		cnts[sumi[i]]++;
		tmp = tmp * 10 % 2019; 
	}
	
	cout << res  << endl;

	return 0;
}


Measured memory_bytes: 3892
#include <iostream>
#include <array>
#include <cstdio>
using namespace std;
int main(int argc, char *argv[]){
  int a[3];
  int tmp, i;
  cin >> a[0];
  cin >> a[1];
  cin >> a[2];
  for(i = 0; i <= 3;i++){
  tmp = a[0];
  if(a[0] < a[1]){
  }else{
    a[0] = a[1];
    a[1] = tmp;
    
  }
  tmp = a[1];
  if(a[1] < a[2]){
  }else{
    a[1] = a[2];
    a[2] = tmp;
  }
  }
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
long long n;
map<long long,long long>q;
map<long long,long long>::iterator it;
long long  modl(long long a, long long b, long long c)        //快速幂取余a^b%c
{
    long long res, t;
    res = 1 % c;
    t = a % c;
    while (b)
    {
        if (b & 1)
        {
            res = res * t % c;
        }
        t = t * t % c;
        b >>= 1;
    }
    return res;
}
long long mod=1e9+7;
int main()
{
    q.clear();
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        long long num;
        cin>>num;
        q[num]++;
    }
    if(q[0]>1)
    {
        cout<<"0"<<endl;
    }
    else if(q[0]==1||q[0]==0)
    {
        int num=0;
        for(it=q.begin();it!=q.end();it++)
        {
            if(it->second==2)
            {
                num++;
            }
            else if(it->second>2)
            {
                cout<<"0"<<endl;
                return 0;
            }
        }
        cout<<modl(2,num,mod)%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int ans = 0;
vector<int> v(50), c(50);
int n;
void dfs(int x, int y, int depth)
{
    if(depth > n) return;
    ans = max(ans, x - y);
    dfs(x, y, depth + 1);
    dfs(x + v[depth], y + c[depth], depth + 1);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> v[i];
    for(int i = 0; i < n; i++) cin >> c[i];
    int x = 0, y = 0;
    dfs(x, y, 0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int INF = (int)1e6;
const int N = 2020;
int n;
int ans = INF;
int a[N], b[N];
char s[N];
int toL[N], toR[N];
int m;
pii c[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < n; i++)
		a[i] = (int)(s[i] == '1');
	scanf("%s", s);
	for (int i = 0; i < n; i++)
		b[i] = (int)(s[i] == '1');

	bool allEq = true, allZ = true;
	for (int i = 0; i < n; i++) {
		allEq &= (a[i] == b[i]);
		allZ &= (b[i] == 0);
	}
	if (allEq) {
		printf("0\n");
		return 0;
	}
	if (allZ) {
		printf("-1\n");
		return 0;
	}

	toR[n] = INF;
	for (int i = n - 1; i >= 0; i--) {
		toR[i] = toR[i + 1];
		if (b[i] == 1)
			toR[i] = i;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (toR[i] != INF) break;
		toR[i] = n + toR[0];
	}
	toL[0] = (b[0] == 1 ? 0 : INF);
	for (int i = 1; i < n; i++) {
		toL[i] = toL[i - 1];
		if (b[i] == 1)
			toL[i] = i;
	}
	for (int i = 0; i < n; i++) {
		if (toL[i] != INF) continue;
		toL[i] = toL[n - 1] - n;
	}

	/*
	for (int i = 0; i < n; i++)
		printf("%d %d\n", toL[i], toR[i]);
	*/

	for (int sh = -n; sh <= n; sh++) {
		int res = abs(sh);
		m = 0;
		for (int i = 0; i < n; i++) {
			int q = (i + sh + n) % n;
			if (a[i] == b[q]) continue;
			res++;
			if (sh <= 0) {
				if (i - toL[i] <= -sh) continue;
				c[m].first = toR[i] - i;
				c[m].second = q - toL[q];
				m++;
			} else {
				if (toR[i] - i <= sh) continue;
				c[m].first = i - toL[i];
				c[m].second = toR[q] - q;
				m++;
			}
		}
		c[m++] = mp(0, 0);
		sort(c, c + m);
		int bst = c[m - 1].first;
		int mx = 0;
		for (int i = m - 1; i > 0; i--) {
			mx = max(mx, c[i].second);
			bst = min(bst, c[i - 1].first + mx);
		}
		ans = min(ans, res + 2 * bst);
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
Program ABC125B

integer n,max
integer,allocatable::v(:),c(:)

read(*,*) n
allocate(v(n))
allocate(c(n))
read(*,*) v
read(*,*) c

max=0

do i=1,n
 if (v(i)>=c(i)) then
  max=max+v(i)-c(i)
 end if
end do

write(*,*) max

stop
end

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define LL long long
const int maxn = 205;
const LL mo = 998244353;
using namespace std;
int x[maxn], y[maxn], n;
LL ans = 0, pw[maxn];
int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", x + i, y + i);
	pw[0] = 1; for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * 2 % mo; 
	ans = (pw[n] - 1 - n + mo) % mo;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++){
			int tmp = 0;
			for (int k = 1; k <= n; k++){
				if (x[k] >= min(x[i], x[j]) && x[k] <= max(x[i], x[j]) && y[k] >= min(y[i], y[j]) && y[k] <= max(y[i], y[j])){
					if ((y[k] - y[i]) * (x[j] - x[k]) == (x[k] - x[i]) * (y[j] - y[k])) ++tmp;
				}
			}
			ans = (ans - pw[tmp - 2] + mo) % mo;
		}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    int n,k;
    cin>>n>>k;
    double dice[n];
    for(int i=0; i<n; i++) cin>>dice[i];

    for(int i=0; i<n; i++) {
        dice[i] = (dice[i]+1)/2;
    }

    double sum = 0;
    for(int i=0; i<k; i++) {
        sum += dice[i];
    }

    if(n==k) {
        cout<<sum<<endl;
        return 0;
    }

    double ans = sum;
    for(int i=1; i<n-k+1; i++) {
        sum = sum + dice[i+k-1] - dice[i-1];
        if(sum>ans) ans = sum;
    }

    cout<<fixed<<setprecision(8)<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#define int long long int
signed main()
{
    int n;
    cin >> n;
    int sum1 = n * (n + 1) / 2;
    int sum3 = (n / 3) * (6 + ((n / 3) - 1) * 3) / 2;
    int sum5 = (n / 5) * (10 + ((n / 5) - 1) * 5) / 2;
    int sum15 = (n / 15) * (30 + ((n / 15) - 1) * 15) / 2;
    int ans = sum1 - sum3 - sum5 + sum15;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
def is_good(mid, key):
    return sum(count_cuts(a, mid) for a in A) <= key


def binary_search(key):
    bad, good = 0, 2 * 10 ** 14 + 1
    while good - bad > 1:
        mid = (bad + good) // 2
        if is_good(mid, key):
            good = mid
        else:
            bad = mid
    return good


def count_cuts(a, unit):
    return (a + unit - 1) // unit - 1


N, K, *A = map(int, open(0).read().split())
print(binary_search(K))


Measured memory_bytes: 31412
class Combination():
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fact = self.make_fact(n)
        self.fact_inv = self.make_fact_inv(n)
    def make_fact(self, n):#0~nの階乗を求める
        res = [1]*(n+1)
        for i in range(1, n+1):
            res[i] = res[i-1]*i%self.mod
        return res
    def make_fact_inv(self, n):#0~nの階乗のmodに関する逆元を求める
        fact_inv = [1]*(n+1)
        fact_inv[n] = pow(self.fact[n], self.mod-2, self.mod)#フェルマーの小定理
        for i in range(n, 0, -1):
            fact_inv[i-1] = fact_inv[i]*i%self.mod
        return fact_inv
    def c(self, m, k):
        return self.fact[m]*self.fact_inv[k]*self.fact_inv[m-k]%self.mod
    def p(self,m,k):
        return self.fact[m]*self.fact_inv[m-k] %self.mod
mod = 10**9+7

n,m=map(int,input().split())
com = Combination(m,mod)

ans=0
for i in range(n+1):
    ans += com.c(n,i) * (-1)**i * com.p(m,i) * (com.p(m-i,n-i))**2
    ans %= mod
    
print(ans)

Measured memory_bytes: 95828
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cstdio>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POSSIBLE(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Possible(i) cout<<(i?"Possible":"Impossible")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
//
int main(){
	long long N,M,D;
	cin>>N>>M>>D;
	long long c=0;
	if(D==0){
		c=N;
	}else{
		c=(N-D)*2;
	}
	double ans=(double)c*(M-1)/(N*N);
	printf("%.9f\n",ans);
	return 0;
}

Measured memory_bytes: 256