akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int X = in.i();
        int max = 1;
        for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        }
        out.println(max);
    }

    static int pow(int a, int b) {
        int c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32804
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define show(x) cerr << #x << " = " << x << "\n";
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
#define pb(x) emplace_back(x)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 998244353;
class mint {
public:
	ll x;
	mint(ll x = 0) : x((x % mod + mod) % mod) {}
	mint operator-() const { 
	  return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}
	friend ostream& operator<<(ostream& os, const mint& m){
		os << m.x;
		return os;
	}
};

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

void Main(){

	ll N;
	cin >> N;
	rep2(i, -200, 200) rep2(j, -200, 200){
		if(i * i * i * i * i - j * j * j * j * j == N){
			print2(i, j);
			return;
		}
	}

}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin >> t;
	rep(i, t) Main();
	return 0;
	
}





Measured memory_bytes: 3624
/**
*    created: 17.05.2020 12:05:05
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(b+c>a) cout << c-a+b << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
li = get_sieve_of_eratosthenes(pow(10,5)+1000)

X = int(input())
k = X
while True:
    if k in li:
        print(k)
        break
    k += 1
    
    

Measured memory_bytes: 84928
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

bonus=0

for i in range(N-1):
  if A[i+1]-A[i]==1:
    bonus+=C[A[i]-1]

print(sum(B)+bonus)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <math.h>

using namespace std;

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

  set<char> sets;
  for (int i = 0; i < 3; ++i)
  {
    sets.insert(s[i]);
  }

  if (sets.size() == 1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
n,d = map(int, input().split())
xd = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
  x1 = xd[i]
  for j in range(i+1,n):
    x2 = xd[j]
    dist = 0
    for x,y in zip(x1,x2):
      dist += (y-x) ** 2
    k = dist ** 0.5
    
    if int(k) ** 2 == dist:
      ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define N (int)2e3
#define INF 1<<30
int a[N];
int func(int s, int e, int i){
    return max(e - s + 1 - i, 0);
}
int circle(int n){
    int cnt = 1, ret = 0;
    n--;
    while(n){
        if(n >= 2){
            a[cnt] = 2;
            n -= 2;
        }
        else{
            a[cnt] = 1;
            n--;
        }
        cnt++;
    }
    for(int i = 0; i < cnt; i++){
        ret += a[i] ;   
    }
    return ret;
}
int main(){
    int n, x, y, acir;
    int ans = 0;
    cin >> n >> x >> y;
    acir = circle(y - x + 1);
    for(int i = 1; i < n; i++){
        ans = func(1, n - (y - x - 1), i);
            for(int j = 1; j < min(i, x); j++){
                ans += a[i - j];
                if((i - j) == 1)
                    ans--;
            }
            for(int j = 1; j < min(i, n - y + 1); j++){
               ans += a[i - j];
               if((i - j) == 1)
                    ans--;
           }
        if(a[i])
            ans += (a[i] * (y - x + 1)) / 2;
        if(i == 1)
            ans--;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int n = fetch<int>();
	ll c = fetch<ll>();
	ll k = fetch<ll>();

	auto a = fetch_vec<ll>(n);
	sort(a.begin(), a.end()); DBG(a);

	ll answ = 0;

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

		while(j + 1 < n && a[j + 1] - a[i] <= k && (j + 1) - i + 1 <= c) {
			++j;
		}

		answ += ((ll)(j - i + 1 + c - 1)) / c;
		i = j + 1;
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    vector<int> a(n);
    
    int xor_sum = 0;
    for (int i = 0; i < n; i++){
        cin>>a[i];
        xor_sum ^= a[i];
    }
    
    
    if(xor_sum == 0){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    
    
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define endl 			"\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define w(x)            int x; cin>>x; while(x--)
////////////////////
void iPhone() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
//////////////////
//////////////////
int32_t main()
{
	//////////////////////////////////////input/////
	//iPhone();//////////////////////////////fast/////
	//////////////////////////////////////output////
	fast
	int n;
	cin >> n;
	int k;
	cin >> k;
	int h[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	int dp[n + 1];
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	for (int i = 3; i <= n; i++) {
		dp[i] = INT_MAX;
		for (int j = i - 1; j >= i - k && j > 0; j--) {
			int temp = dp[j] + abs(h[j] - h[i]);
			dp[i] = min(dp[i], temp);
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, a, b, ans1, ans2;
	cin >> n >> a >> b;
	if (a + b <= n) ans1 = 0;
	else ans1 = a + b - n;

	ans2 = min(a, b);
	cout << ans2 << " " << ans1 << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    int n,r;
    cin >> n >> r;
    if(n >= 10) cout << r;
    else cout << r + 100 * (10-n);
}

void solve_B(){
    int n, k, ctr = 0;
    cin >> n >> k;

    while(n > 0){
        n /= k;
        ctr++;
    }
    cout << ctr;
}

int main(void){
    solve_B();
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
 
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define Sort(x) sort(x.begin(),x.end()); 
#define ll long long
int mod=1e9+7;
const int INF = 1e9;
 
using namespace std;
 
int main(void) {
	int n,m;
	cin>>n>>m;
	vector<int> v(n);
	rep(i,0,n){
	    cin>>v[i];
	}
	
	rep(j,1,m+1){
	    rep(i,0,n-1){
	        if((v[i]%j) > v[i+1]%j){
	            int swap;
	            swap=v[i];
	            v[i]=v[i+1];
	            v[i+1]=swap;
	        }
	    }
	}
	
	rep(i,0,n){
	    cout<<v[i]<<endl;
	}
	
	
	
 
 
	return 0;
}

Measured memory_bytes: 3084
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B,C = inputIL()

if A+B>=C:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 63980
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
signed main() {
	int n,m,i,j;
	vector<ll> sum;
	cin>>n>>m;
	ll a[n+1],pf[n+1];
	for(i=1;i<=n;++i) cin>>a[i];
	pf[0] = 0ll;
	for(i=1;i<=n;++i) pf[i] = pf[i-1] + a[i];
	ll maxi = 0ll;
	for(i=1;i<=n;++i) {
		for(j=i;j<=n;++j) {
			sum.push_back(pf[j]-pf[i-1]);
			maxi = max(maxi,pf[j]-pf[i-1]);
		}
	}
	vector<bool> yes(sum.size(),true);
	int max_bit = 0;
	while(maxi) {
		max_bit++;
		maxi/=2;
	}
	ll ans = 0ll;
	vector<int> x;
	for(i=max_bit;i>=0;i--) {
		int cnt = 0;
		for(j=0;j<sum.size();++j) {
			if(yes[j]==true) {
				if((sum[j] & (1ll<<i)) != 0) ++cnt;
				else x.push_back(j);
			}
		}
		if(cnt>=m) {
			ans = ans + (1ll<<i);
			for(j=0;j<x.size();++j)
				yes[x[j]] = false;
		}
		x.clear();
	}
	cout<<ans;
}

Measured memory_bytes: 8300
s = input()
rs = s[::-1]
if s != rs:
  print("No")
  exit()
n = len(s)
m = int((n-1)/2)
l = int((n+1)/2)
if s[:m] != rs[l:]:
  print("No")
  exit()
if s[l:] != rs[:m]:
  print("No")
  exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    ll n,m;
    cin>>n>>m;
    vector<P> pa(n);
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        pa[i]={a,b};
    }
    sort(pa.begin(),pa.end());
    ll ans=0,sum=0;
    for(int i=0;i<n;i++){
        if(sum+pa[i].second<m){
            sum+=pa[i].second;
            ans+=pa[i].first*pa[i].second;
        }else{
            ans+=pa[i].first*(m-sum);
            cout<<ans<<endl;
            break;
        }
    }
    return 0;
}

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

int main() {
    int n; cin>>n;
    for(int i=1; i<=n; i++){
        if(i%3==0) {
            cout<<" "<<i;
            continue;
        }
        int x = i;
        while(x>0){
            if(x%10==3) {
                cout<<" "<<i;
                break;
            }
            x/=10;
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

bool isprime(int p)
{
    if (p <= 1)
        return false;
    if (p == 2)
        return true;
    if (p % 2 == 0)
        return false;
    int lim = sqrt(p)+0.1;
    for (int q = 3; q <= lim; q+=2) {
        if (p % q == 0) {
            return false;
        }    
    }
    return true;
}

int main()
{
    int N; cin >>N;
    vector<int> a;

    for (int p = 2;; p+=5) {
        if (isprime(p)) {
            a.push_back(p);
            if (a.size()==N)
                break;
        }
    }

    cout_h(a);
}


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

fun main(args: Array<String>) = IO().exec {
    val s = string()
    var i = 0
    var j = s.length - 1
    var cnt = 0
    while (i < j) {
        if (s[i] == s[j]) {
            i++
            j--
        } else if (s[i] == 'x' && s[j] != 'x') {
            cnt++
            i++
        } else if (s[i] != 'x' && s[j] == 'x') {
            cnt++
            j--
        } else {
            cnt = -1
            break
        }
    }
    println(cnt)
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

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

using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;
    if (n % 2) cout << 0;
    else {
        int st = 10;
        int ans = 0;
        while (st <= n) {
            ans += n / st;
            st *= 5;
        }
        cout << ans;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR :kamesh_11 *
* INSTITUTION : GVPCOE *
******************************************/

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

#define ll long long
#define MOD 1000000007
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define endl '\n'
#define start_clock clock_t beginn=clock()
#define end_clock clock_t endd=clock()
#define cal_exec_time double time_spent=(double)(endd-beginn)/CLOCKS_PER_SEC
#define print_exec_time cout<<endl<<time_spent<<" secs"

int LCS(string s1, string s2, int i, int j, int n, int m, vector<vector<int>>dp){
	if(i>=n || j>=m)
		return 0;
	if(dp[i][j] != -1)
		return dp[i][j];

	if(s1[i] == s2[j])
		return dp[i][j] = 1 + LCS(s1, s2, i+1, j+1, n, m, dp);

	else{
		int l = LCS(s1, s2, i+1, j, n, m, dp);
		int r = LCS(s1, s2, i, j+1, n, m, dp);
		return dp[i][j] = max(l, r);
	}
}

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

	string s1, s2;
	cin>>s1>>s2;

	int n = s1.length(), m = s2.length();

	/*vector<vector<int>>dp(n, vector<int>(m, -1));
	cout<<LCS(s1, s2, 0, 0, n, m, dp);*/

	int dp[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0 || j==0)
				dp[i][j] = 0;
			else if(s1[i-1] == s2[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}

	int i = n, j = m;
	string ans = "";
	while(i>0 && j>0){
		if(dp[i][j] == dp[i-1][j])
			i--;
		else if(dp[i][j] == dp[i][j-1])
			j--;
		else if(dp[i][j] == dp[i-1][j-1]+1){
			ans += s1[i-1];
			i--, j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans;

	return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


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

	string T = "CODEFESTIVAL2016";
	int ans = 0;
	rep(i,S.size()) ans += (S[i] != T[i]);
	
	Cout(ans);
}


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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int main()
{
	// freopen("input.in", "r", stdin);

	int n, k;
	cin >> n >> k;
	if(k == 1) cout << "0\n";
	else cout << n-k << "\n";
}

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

int main(){
  ll n, m;
  cin >> n >> m;
  ll cnt = 0;
  rep(i, m){
    ll tmp;
    cin >> tmp;
    cnt += tmp;
  }
  if(cnt <= n) cout << n - cnt << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3612
N = int(input())
n = map(int, input().split())
n = list(n)


kari = int(1)
an = 0


for i in range(N):
    if n[i] == kari:
        kari = kari +1
        
       


an = 1 + N-kari


if min(n) > 1.5 :
    ANS = -1
else:
    ANS = an

print(ANS)

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

#[fastout]
fn main() {
    input! {
        x1: isize, y1: isize,
        x2: isize, y2: isize,
    }

    let dx = -(y2-y1);
    let dy = x2-x1;
    println!(
        "{} {} {} {}",
        x2 + dx, y2 + dy,
        x1 + dx, y1 + dy,
    )
}


Measured memory_bytes: 2152
#include<iostream>
#include<algorithm>
using namespace std;
int n, a, b, c, d, e, x[1000000];
int main() {
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c >> d >> e;
			x[i] = a + b + c + d + e;
		}
		sort(x, x + n);
		cout << x[n - 1] << ' ' << x[0] << endl;
	}
}

Measured memory_bytes: 1180
#include<iostream>
using namespace std;
int main()
{
	string a;
	int i,x=0,y=0;
	cin>>a;
	for(i=0;a[i]!=NULL;i++) {
		if(a[i]=='0') {
			x++;
		}
		else {
			y++;
		}
	}
	if(x>y) {
		cout<<y*2;
	}
	else {
		cout<<x*2;
	}
	a.clear();
	return 0;
}

Measured memory_bytes: 512
using System;
class Program
{
    static void Main()
    {
        string z;
        string str = Console.ReadLine();
        string[] a = str.Split(' ');
        int W = int.Parse(a[0]);
        int H = int.Parse(a[1]);
        int x = int.Parse(a[2]);
        int y = int.Parse(a[3]);
        int r = int.Parse(a[4]);
        int UxLimit = W - r;
        int UyLimit = H - r;
        int DxLimit = r;
        int DyLimit = r;
        z = "No";
        if (x <= UxLimit)
        {
            if (y <= UyLimit)
            {
                if (DxLimit <= x)
                {
                    if (DyLimit <= y)
                    { z = "Yes"; }
                }
            }
        }
        Console.WriteLine(z);
    }
}


Measured memory_bytes: 15964
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	long long H, W;
	cin >> H>> W;
	if ((H % 2 == 1) && (W % 2 == 1)&&(H!=1)&&(W!=1)) {
		cout << (H * W / 2) + 1 << endl;
	}
	else if ((H == 1) || (W == 1)) {
		cout << 1 << endl;
	}
	else cout << (H * W / 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

const long long INF = 1LL<<60;

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    if(N == 2){
        cout << max(A[0], A[1]) << endl;
        return 0;
    }

    vector<vector<long long>> dp(N, vector<long long>(3, -INF));
    dp[0][0] = A[0];
    dp[1][1] = A[1];
    dp[2][2] = A[2];
    for(int i=0; i<N; i++){
        if(dp[i][0] != -INF){
            if(i+2<N) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + A[i+2]);
            if(i+3<N) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + A[i+3]);
            if(i+4<N) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + A[i+4]);
        }
        if(dp[i][1] != -INF){
            if(i+2<N) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + A[i+2]);
            if(i+3<N) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + A[i+3]);
        }
        if(dp[i][2] != -INF){
            if(i+2<N) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + A[i+2]);
        }
    }
    long long ans = -INF;
    if(N%2==0) ans = max(dp[N-1][1], dp[N-2][0]);
    if(N%2==1){
        ans = max(ans, dp[N-1][2]);
        ans = max(ans, dp[N-2][1]);
        ans = max(ans, dp[N-3][0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15668
#include <iostream>
#include <algorithm>
int n,a[55],k,ans;
main(){
    std::cin>>n>>k;for(register int i=1;i<=n;i++) std::cin>>a[i];std::sort(a+1,a+1+n,std::greater<int>());
    for(register int i=1;i<=k;i++) ans+=a[i];std::cout<<ans<<'\n';
    return 0;
}

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

int lcs( char *X, char *Y, int m, int n )  
{  
    if (m == 0 || n == 0)  
        return 0;  
    if (X[m-1] == Y[n-1])  
        return 1 + lcs(X, Y, m-1, n-1);  
    else
        return max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n));  
}  

int main()
{
	string a,b;cin>>a>>b;
	int str[a.size()+1][b.size()+1];
	int p=0;
	for(int i=0;i<=a.size();i++)
	{
		for(int j=0;j<=b.size();j++)
		{
			if(i==0 || j==0)
				str[i][j]=0;
			else if(a[i-1]==b[j-1])
			{
				str[i][j]=1+str[i-1][j-1];
			}
			else if(a[i-1]!=b[j-1])
			{
				str[i][j]=max(str[i-1][j],str[i][j-1]);
			}
		}
	}
	int cnt=str[a.size()][b.size()];
	string v;
	int i=a.size();
	int j=b.size();
	if(str[i][j]==0)
	{
		cout<<" ";
		return 0;
	}
	while(i>0 && j>0)
	{
		if(a[i-1]==b[j-1])
		{
			v.push_back(a[i-1]);
			i--;
			j--;
		}
		else if(str[i-1][j]>str[i][j-1])
			i--;
		else if(str[i-1][j]<=str[i][j-1])
			j--;
	}
	reverse(v.begin(),v.end());
	cout<<v;
	return 0;
}

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

bool matrix[30][30];

// Check whether a set dset of size k is a dominating set of a graph
// of n vertices.
bool is_dominating_set(int dset, int n)
{
  bool dominated[30];
  int rem = n;                  // ??????????????????????????????????????°

  for (int i=0;i<30;i++) dominated[i]=false;
  for (int v=0;v<n;v++)
  {
    int vm = 1<<v;              // ??????v?????´??°??¨???
    int im;
    if (vm & dset)              // v???dset?????????
    {
      if (!dominated[v]) { dominated[v] = true; rem--; }
      for (int i=0;i<n;i++)
        if (matrix[v][i] && !dominated[i]) { dominated[i] = true; rem--; }
    }
  }
  if (rem == 0) return true;
  else return false;
}


int main()
{
  int n, m;
  int u, v;
  while (cin >> n >> m)
  {
    bool found = false;

    if (n == 0) return 0;
    for (int i=0;i<n;i++) for (int j=0;j<n;j++) matrix[i][j]=false;
    for (int i=0;i<m;i++)
    {
      cin >> u >> v;
      matrix[u][v] = matrix[v][u] = true;
    }

    int dset;
    for (int k=1;k<=n;k++)
    {
      // {0,...,n-1}?????¨???????????§????????????k??§???????????????????????????
      // ????????°???????????°????????????????????£??¬???????????????????????§
      dset = (1 << k) - 1;
      while (dset < 1<<n)
      {
        if (is_dominating_set(dset, n))
        {
          cout << k << endl;
          found = true;
        }
        if (found) break;

        int x = dset & -dset;
        int y = dset + x;
        dset = ((dset & ~y) / x >> 1) | y;
      }
      if (found) break;
    }
  }
}

Measured memory_bytes: 1160
fun main() {
    var n= readLine()!!.toInt()
    var ans=0
    for (i in 1..n){
        var tmp=0
        if (i%2==1) {
            for (j in 1..i) {
                if (i % j == 0) {
                    tmp++
                }
            }
        }
        if (tmp==8){
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 34488
#include<bits/stdc++.h>
using namespace std;
#define MAXN	200005
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, m, k, timer, cnte, cntv;
long long ans;
vector <int> a[MAXN], b[MAXN];
long long fac[MAXN], inv[MAXN], Pow[MAXN];
int dfn[MAXN], low[MAXN];
int u[MAXN], v[MAXN];
int belong[MAXN], top, q[MAXN];
bool inq[MAXN], used[MAXN];
void update(long long &x, long long y) {
	x = (x * y) % P;
}
long long power(long long x, long long y) {
	if (y == 0) return 1;
	long long tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp % P;
	else return tmp * tmp % P * x % P;
}
long long getc(long long x, long long y) {
	return fac[x] * inv[y] % P * inv[x - y] % P;
}
long long Inv(long long x) {
	return inv[x] * fac[x - 1] % P;
}
void init(int n, int m, int k) {
	int N = m + k;
	fac[0] = 1;
	for (int i = 1; i <= N; i++)
		fac[i] = fac[i - 1] * i % P;
	inv[N] = power(fac[N], P - 2);
	for (int i = N - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % P;
	Pow[0] = 1;
	for (int i = 1; i <= m; i++)
		Pow[i] = Pow[i - 1] * k % P;
}
int gcd(int x, int y) {
	if (y == 0) return x;
	else return gcd(y, x % y);
}
long long polya(int x) {
	long long tans = 0;
	for (int i = 1; i <= x; i++)
		tans = (tans + Pow[gcd(i, x)]) % P;
	update(tans, Inv(x));
	return tans;
}
void work(int pos, int fa) {
	low[pos] = dfn[pos] = ++timer;
	inq[pos] = true;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (dfn[a[pos][i]] == 0) {
			q[++top] = b[pos][i];
			work(a[pos][i], pos);
			low[pos] = min(low[pos], low[a[pos][i]]);
			if (low[a[pos][i]] >= dfn[pos]) {
				int ttop = top, tmp = q[top--];
				int cnte = 1, cntv = 2;
				used[u[tmp]] = used[v[tmp]] = true;
				while (tmp != b[pos][i]) {
					cnte++;
					tmp = q[top--];
					if (!used[u[tmp]]) cntv++;
					if (!used[v[tmp]]) cntv++;
					used[u[tmp]] = used[v[tmp]] = true;
				}
				for (int i = top + 1; i <= ttop; i++)
					used[u[q[i]]] = used[v[q[i]]] = false;
				if (cnte == 1) update(ans, k);
				else if (cnte == cntv) update(ans, polya(cnte));
				else update(ans, getc(cnte + k - 1, k - 1));
			}
		} else if (inq[a[pos][i]] && a[pos][i] != fa) {
			low[pos] = min(low[pos], dfn[a[pos][i]]);
			q[++top] = b[pos][i];
		}
	inq[pos] = false;
}
int main() {
	read(n), read(m), read(k);
	init(n, m, k);
	for (int i = 1; i <= m; i++) {
		read(u[i]), read(v[i]);
		a[u[i]].push_back(v[i]);
		b[u[i]].push_back(i);
		a[v[i]].push_back(u[i]);
		b[v[i]].push_back(i);
	}
	ans = 1;
	for (int i = 1; i <= n; i++)
		if (dfn[i] == 0) work(i, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17408
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

const int SENTINEL = 1000000001;

struct card{
    char type;
    int num;
};

void merge(card A[], int left, int mid, int right) {
    card leftA[50001];
    for (int i = left; i < mid; i++) {
        leftA[i - left] = A[i];
    }
    leftA[mid - left] = card{'S', SENTINEL};
    int leftCur = 0;
    
    card rightA[50001];
    for (int j = mid; j < right; j++) {
        rightA[j - mid] = A[j];
    }
    rightA[right - mid] = card{'S', SENTINEL};
    int rightCur = 0;
    
    for (int i = left; i < right; i++) {
        if (leftA[leftCur].num <= rightA[rightCur].num) {
            A[i] = leftA[leftCur];
            leftCur++;
        } else {
            A[i] = rightA[rightCur];
            rightCur++;
        }
    }
}

void mergeSort(card A[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(card A[], int p, int r) {
    int i = p - 1;
    card x, t;
    x = A[r];
    for (int j = p; j < r; j++) {
        if (A[j].num <= x.num) {
            i++;
            t = A[j];
            A[j] = A[i];
            A[i] = t;
        }
    }
    t = A[i+1]; A[i+1] = x; A[r] = t;

    return i + 1;
}

void quickSort(card A[], int p, int r) {
    int q;
    if (p < r) {
        q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q + 1, r);
    }
}

int main() {
    int N, I;
    card A[100000]; card B[100000];
    char S[10];
    
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%s", S);
        scanf("%d", &I);
        A[i].type = B[i].type = S[0];
        A[i].num = B[i].num = I;
    }
    
    quickSort(A, 0, N - 1);
    mergeSort(B, 0, N);
    
    string isStable = "Stable";
    for (int i = 0; i < N; i++) {
        if (A[i].type != B[i].type) {
            isStable = "Not stable";
            break;
        }
    }
    
    cout << isStable << endl;
    
    
    for (int i = 0; i < N; i++) {
        printf("%c %d\n", A[i].type, A[i].num);
    }

    return 0;
}


Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vll vector<long long>
#define ll long long
#define pii pair<int,int>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("inputf.txt","r",stdin);
    freopen("outputf.txt","w",stdout);
#endif
    
    int n;
    cin>>n;

    long long a[n],ans=0,max;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	if(i==0){
    		max=a[i];
    	}
    	else{
    		if(a[i]<max) ans+=max-a[i];
    		else max=a[i];
    	}
    }
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 5160
#include<stdio.h>
#define N 500000

typedef struct{

  int id,k,pk,lk,rk;

} Node;

int n;
Node node[N];


void maxHeapify(Node *A , int );
void buildMaxHeap(Node *A);

int main()
{

  int i;

  scanf("%d",&n);

  for(i=1;i<=n;i++)
    scanf("%d",&node[i].k);

  for(i=1;i<=n;i++)
    {
      if(i != 1)
	  node[i].pk = node[i/2].k;

      if(2 * i <= n)
	  node[i].lk = node[2*i].k;
      else
	node[i].lk = 0;
      
      if(2 * i + 1 <= n)
	  node[i].rk = node[2*i+1].k;
      else
	node[i].rk = 0;
    }
  i = 1;
  
  buildMaxHeap(node);
  
  for(i = 1;i <= n;i++)
    printf(" %d",node[i].k);

  printf("\n");
  
  return 0;
}


void maxHeapify(Node *A , int i)
{
  int l = 2*i, r = 2*i + 1;
  int largest,swap;

  if(l <= n && A[l].k > A[i].k)
    largest = l;
  else
    largest = i;

  if(r <= n && A[r].k > A[largest].k)
    largest = r;

  if(largest != i)
    {
      swap = A[i].k;
      A[i].k = A[largest].k;
      A[largest].k= swap;
      maxHeapify(A,largest);
    }
  
}

void buildMaxHeap(Node *A)
{
  int i;
  for(i = n/2;i >= 1;i--)
    maxHeapify(A,i);
}



Measured memory_bytes: 11460
fun main(args: Array<String>) {
    val n = getInt()
    val k = getInts().filterIndexed { i, v -> i % 2 == 0}
            .filter { it % 2 == 1 }
            .count()
    println(k)
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }

Measured memory_bytes: 36460
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

var graph [][]int
var lngth []int

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,m := input.NextInts()
  graph = make([][]int,n)
  lngth = make([]int,n)
  for i:=0;i<m;i++ {
    x,y := input.NextInts()
    graph[x-1] = append(graph[x-1],y-1)
  }
  for i:=0;i<n;i++ { lngth[i] = -1 }
  max := 0
  for i:=0;i<n;i++ {
    t := dfs(i)
    if max < t { max = t }
  }
  fmt.Println(max)
}
func dfs(v int) int {
  if lngth[v] != -1 { return lngth[v] }
  max := -1
  for _,e := range graph[v] {
    t := dfs(e)
    if max < t { max = t }
  }
  lngth[v] = max+1
  return max+1
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Split(i.NextLine()," ")
  a,_ := strconv.Atoi(s[0])
  b,_ := strconv.Atoi(s[1])
  return a,b
}

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

int main(){
  string s;
  cin>>s;
  if(s[s.size()-1]=='s'){s.push_back('e');s.push_back('s');}
  else s.push_back('s');
  cout<<s<<endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <unordered_map>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
using namespace std;

int main()
{
    ll n;
    cin >> n;
    unordered_map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        stable_sort(all(s));
        auto itr = mp.find(s);
        if (itr == mp.end()){
            mp[s] = 1;
        }else{
            mp[s]++;
        }
    }
    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
	    ll num = itr->second;
        ans += num*(num-1)/2;
    }
    cout << ans << endl;

    
}

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

int main()
{
  int N, M;
  priority_queue<int> pq;
  ll res=0;
  cin >> N >> M;

  for(int i=0;i<N;i++){
    int in;
    cin >> in;
    pq.push(in);
  }


  rep(i,M){
    int tmp=pq.top();
    pq.pop();
    pq.push(tmp/2);
  }

  while(!pq.empty()){
    res += pq.top();
    pq.pop();
  }
  
  cout << res << endl;
}


Measured memory_bytes: 892
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n, a;

    cin >> n >> a;

    cout << n*n - a;



    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));  // 2次元配列初期化
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
import sys

input = sys.stdin.readline

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

X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            pass
        else:
            distance = 0
            for x in range(D):
                distance += (X[i][x] - X[j][x]) ** 2
            distance = distance ** 0.5
            if int(distance) == distance:
                ans += 1

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long

#define INF 999999999
#define MAX 1000000000

using namespace std;

// input
int n;
map<int,bool> field;

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

    int number;
    int ans = 0;

    cin >> n;

    for(int i = 0;i < n; i++){
        cin >> number;
        auto id = field.find(number);
        if(id == field.end()){
            field[number] = true;
        }
        else{
            field.erase(number); 
        }
        
    }


    cout << field.size() << "\n";
}

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

int main(){
    int N,M;

    cin >> N >> M;

    int H[N],A[M],B[M],C[N];//C[i]==1のとき良い台

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

    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        if(H[A[i]-1]==H[B[i]-1]){
            C[A[i]-1] = 0;
            C[B[i]-1] = 0;
        }else if(H[A[i]-1]>=H[B[i]-1]){
            C[B[i]-1] = 0;
        }else{
            C[A[i]-1] = 0;
        }
    }

    int sum = 0;
    for(int i=0;i<N;i++){
        if(C[i] == 1){
            sum++;
        }
    }

    cout << sum << endl;
    return 0;

}

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

int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> d(n);
  for(int i=0;i<n;i++){
    cin >> d.at(i);
  }
  int64_t m;
  cin >> m;
  vector<int64_t> t(m);
  for(int i=0;i<m;i++){
    cin >> t.at(i);
  }
  //
  sort(d.begin(),d.end());
  sort(t.begin(),t.end());
  int dcnt = 0;
  int tcnt = 0;
  bool flag = true;
  while(tcnt < m && dcnt < n){
      if(d.at(dcnt) == t.at(tcnt)){
        dcnt++;
        tcnt++;
      }else{
        dcnt++;
      }
  }
  if(tcnt >= m){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}
       
      
  


Measured memory_bytes: 3328
main(n,i){
	for(;scanf("%d",&n),~n;){
		double r=sqrt(n),th=0;
		for(i=1;i<n;i++)	th+=acos(sqrt(1.*i/(i+1)));
		printf("%f\n%f\n",r*cos(th),r*sin(th));
	}
	exit(0);
}

Measured memory_bytes: 0