akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
ll mod = -1;
ll N;
ll ans = 0;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b, ll mod){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2, mod);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2, mod);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll dp[3005][3005];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> mod;
    init_combination();
    for(ll num = 0; num <= 3000; num++) {
        dp[num][0] = 1;
        for(ll box = 1; box <= 3000; box++) {
            if(num >= 1) dp[num][box] += box * dp[num-1][box];
            if(num >= 1) dp[num][box] += dp[num-1][box];
            if(num >= 1 and box >= 1) dp[num][box] += dp[num-1][box-1];
            dp[num][box] %= mod;
        }
    }
    for(int i = 0; i <= 5; i++) {
        for(int j = 0; j <= 5; j++) {
            //cerr << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    /*
    cerr << beki(2, beki(2, 3)) << endl;
    cerr << beki(2, 3) << endl;
    cerr << beki(2, 8) << endl;
    */
    for(ll i = 0; i <= N; i++) {
        ll now = 0;
        //cerr << "---" << i << "---" << endl;
        ll factor = beki(2, N - i, mod);
        for(ll box = 0; box <= i; box++) {
            ll tmp = dp[i][box];
            tmp *= beki(factor, box, mod);
            tmp %= mod;
            //cerr << box << " " << tmp << endl;
            now += tmp;
        }
        now %= mod;
        //cerr << now << " ";
        now *= beki(2, beki(2, N - i, mod - 1), mod);
        now %= mod;
        //cerr << now << " ";
        now *= combination(N, i);
        now %= mod;
        //cerr << now << " ";
        //cerr << endl;
        if(i % 2 == 0) ans += now;
        else ans += (mod - now);
        ans %= mod;
    }
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 305152
import sys
import math


def heigh(v):
    t = v / 9.8
    return 4.9 * t ** 2


#input_file = open(sys.argv[1], "r")

for line in sys.stdin:
    v = float(line)
    h = heigh(v)
#    print h
    n = int(math.ceil(h / 5.0) + 1.0)
    print n

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
    int a,b;
    cin>>a>>b;
    int count=0;
    for(int i=a;i<=b;i++){
        int x=i;
        vector<int>v;
        while(x>0){
            int rem=x%10;
            v.push_back(rem);
            x=x/10;
        }
        int y;
        if(v.size()%2==0)y=v.size()/2;
        else y=(v.size()+1)/2;
        int f=0;
        for(int i=0;i<y;i++){
            if(v[i]!=v[v.size()-1-i])f=1;
        }
        if(f==0)count++;
    }    
    cout<<count<<endl;
}

Measured memory_bytes: 256
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let print_chessborad h w =
  for i = 1 to h do
    let flag = ref (i mod 2 = 0) in
    for _ = 1 to w do
      if !flag = true then print_char '.'
      else print_char '#';
      flag := not !flag
    done;
    print_newline ();
  done

let rec repl () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] | [_] -> exit 1
  | h :: w :: _ ->
      if (h = 0) && (w = 0) then ()
      else begin
        print_chessborad h w;
        print_newline ();
        repl ()
      end

let () =
  try repl () with End_of_file -> ()

Measured memory_bytes: 2036
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class FenwickTree {
    public:
        FenwickTree(int n ) : N(n), data(n, 0) {

        }

        void put(int x, int v) {
            for (; x < N; x |= x + 1) {
                data[x] += v;
            }
        }
        int get(int x) {
            int res = 0;
            for (; x >= 0; x = (x & (x + 1)) - 1) {
                res += data[x];
            }
            return res;
        }

    private:
        int N;
        vector<int> data;
};


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    int q;
    cin >> n >> m;
    cin >> q;

    vector<pair<int,int>> P;
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        P.emplace_back(l, r);
    }

    vector<pair<int,int>> Q;
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        Q.emplace_back(l, r);
    }

    vector<int> res(q, 0);

    vector<int> A(m, 0);
    iota(A.begin(), A.end(), 0);
    sort(A.begin(), A.end(), [&](int l, int r) { return P[l] < P[r];});
    vector<int> B(q, 0);
    iota(B.begin(), B.end(), 0);
    sort(B.begin(), B.end(), [&](int l, int r) { return Q[l] < Q[r];});

    FenwickTree ft(n + 123);
    for (int i = m - 1, j = q - 1; j >= 0; --j) {
        int L = Q[B[j]].first;
        int R = Q[B[j]].second;
        while (i >= 0) {
            int l = P[A[i]].first;
            int r = P[A[i]].second;
            if (l >= L) {
                ft.put(r, 1);
                --i;
            } else {
                break;
            }
        }

        res[B[j]] = ft.get(R);
    }
  
    for (int i = 0; i < q; ++i) {
        cout << res[i] << '\n';
    }


    return 0;
}

Measured memory_bytes: 5104
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())

graph = defaultdict(set)

for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].add(b)
    graph[b].add(a)

arr = [0] * (n + 1)

for i in range(q):
    p, x = map(int, input().split())
    arr[p] += x


def solve():
    stack = [1]
    visited = [True] * 2 + [False] * (n - 1)

    while stack:
        curr = stack.pop()
        for leaf in graph[curr]:
            if visited[leaf]:
                continue
            stack.append(leaf)
            visited[leaf] = True
            arr[leaf] += arr[curr]

    return arr


arr = solve()

print(*arr[1:])

Measured memory_bytes: 93512
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

X,N=map(int,input().split())
p=set(list(map(int,input().split())))
ans=INF
for x in range(-100,1000):
    if not x in p and abs(X-x)<abs(ans-X):
        ans=x
print(ans)

Measured memory_bytes: 63528
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
 
typedef long long ll;


int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool> AC(n, false);
    vector<int> cnt_WA(n, 0);
    while(m--) {
        int p;
        string verd;
        cin >> p >> verd;
        --p;
        if (AC[p]) continue;
        if (verd == "AC") {
            AC[p] = true;
        } else {
            ++cnt_WA[p];
        }
    }
    int ans_AC = 0, ans_WA = 0;
    for (int i = 0; i < n; ++i) {
        if (AC[i]) {
            ++ans_AC;
            ans_WA += cnt_WA[i];
        }
    }
    cout << ans_AC << ' ' << ans_WA << '\n';
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int dfs(int day,int tmt,int cream,int bazil);
int dfsmem[105][3][3][3];
int n,k;
int mem[105];
main(){
  cin>>n>>k;
  memset(mem,-1,sizeof(mem));
  memset(dfsmem,-1,sizeof(dfsmem));
  for(int i=0;i<k;i++){
    int a,b;
    cin>>a>>b;
    mem[a]=b;
  }
  cout<<dfs(1,0,0,0)<<endl;
}
int dfs(int day,int tmt,int cream,int bazil){
  if(tmt>=3||cream>=3||bazil>=3){
    return 0;
  }
  else if(day>n){
    return 1;
  }
  else if(dfsmem[day][tmt][cream][bazil]!=-1){
    return dfsmem[day][tmt][cream][bazil];
  }
  else if(mem[day]!=-1){
    if(mem[day]==1){
      return dfsmem[day][tmt][cream][bazil]=dfs(day+1,tmt+1,0,0)%10000;
    }
    else if(mem[day]==2){
      return dfsmem[day][tmt][cream][bazil]=dfs(day+1,0,cream+1,0)%10000;
    }
    else if(mem[day]==3){
      return dfsmem[day][tmt][cream][bazil]=dfs(day+1,0,0,bazil+1)%10000;
    }
  }
  else{
    int paturn=0;
    paturn+=dfs(day+1,tmt+1,0,0)%10000;
    paturn+=dfs(day+1,0,cream+1,0)%10000;
    paturn+=dfs(day+1,0,0,bazil+1)%10000;
    return dfsmem[day][tmt][cream][bazil]=paturn%10000;
  }
}

Measured memory_bytes: 1180
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <cfloat>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

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

  ll a, b, c;
  cin >> a >> b >> c;
  ll right = (c - (a + b)) * (c - (a + b));
  ll left = a * b * 4;

  if (c - (a + b) > 0 && right - left > 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int h,n;
const int N=1e3+2,M=1e4+2;
vector<pair<int, int>>a;
int dp[N][M];

int sol(int ind,int remain)
{
	d(ind,remain);
	if(remain<=0)
	{
		return 0;
	}

	if(ind>=n)
	{
		return INT_MAX;
	}

	if(dp[ind][remain]!=-1)
	{
		return dp[ind][remain];
	}

	int take=a[ind].ss+sol(ind,remain-a[ind].ff);
	int notake=sol(ind+1,remain);

	return dp[ind][remain]=min(take,notake);
}

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	cin>>h>>n;

	a.resize(n);

	for(i=0;i<n;i++)
	{
		cin>>a[i].ff>>a[i].ss;
	}

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

	cout<<sol(0,h);


	
}

Measured memory_bytes: 82404
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	for x := 'a'; x <= 'z'; x++ {
		if !strings.Contains(s, string(x)) {
			fmt.Println(string(x))
			return
		}
	}

	fmt.Println("None")
}


Measured memory_bytes: 1280
N = int(input())
sX = input()

origin_count = sX.count('1')
one_r_count = origin_count -1
zero_r_count = origin_count +1

one_mod = 0
zero_mod =0
for b in sX:
    if one_r_count != 0:
        one_mod = (one_mod * 2 + int(b) )% one_r_count
    zero_mod = (zero_mod * 2  + int(b) )% zero_r_count

f = [0] * 220000
pop = [0]* 220000

for i in range(1,220000):
    pop[i] = pop[i//2] + i%2
    f[i] = f[i % pop[i]] + 1

onepow = [1] * 220000
zeropow = [1]* 220000

for i in range(1,220000):
    if one_r_count != 0:
        onepow[i] = onepow[i-1] * 2 % one_r_count
    zeropow[i] = zeropow[i-1] * 2 % zero_r_count

for i in range(1,N+1):
    if sX[i-1] == '1':
        if one_r_count != 0:
            Xi_n = one_mod - onepow[N-i]
            Xi_n %= one_r_count
            print(f[Xi_n]+1)
        else:
            print(0)
    else:
        Xi_n = zero_mod + zeropow[N-i]
        Xi_n %= zero_r_count
        print(f[Xi_n]+1)

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

string s[101];

int main(){
    int n,l;
    cin >> n >> l;
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }  
    sort(s, s + n);
    
    for(int i = 0; i < n; i++){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define sec second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
const ll INF=LLONG_MAX,MOD=1e9+7;
const int L=17,N=1<<L;

ll n,a[101];
vector<char> s;

int main(){
	ios::sync_with_stdio(false);
	string t;cin>>t;n=t.size();
	ll ans=0;
	for(int i=0,j=n-1;i<j;){
		if(t[i]==t[j]){
			i++;j--;continue;
		}
		if(t[i]=='x'){
			i++;ans++;continue;
		}
		if(t[j]=='x'){
			j--;ans++;continue;
		}
		return cout<<-1,0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#162a
import math
#数字の各桁の抽出,桁抽出
N = int(input())

#Nを下の桁から取る
while N!=0:
    ketasu = int(math.log10(N)//1 + 1)
    top_keta = N // 10**(ketasu-1)
    #print(top_keta)
    if top_keta == 7:
        print("Yes")
        break
    N = N - top_keta*10**(ketasu-1)
else:
    print("No")

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

int main() {

  int A[128][128];
  int r, c;
  int temp;

  std::cin >> r >> c;
  for(int i = 0; i < r; ++i) {
    for(int j = 0; j < c; ++j) {
      std::cin >> A[i][j];
    }
  }

  for(int i = 0; i < r; ++i) {
    temp = 0;
    for(int j = 0; j < c; ++j) {
      temp += A[i][j];
    }
    A[i][c] = temp;
  }

  for(int i = 0; i <= c; ++i) {
    temp = 0;
    for(int j = 0; j < r; ++j) {
      temp += A[j][i];
    }
    A[r][i] = temp;
  }

  for(int i = 0; i <= r; ++i) {
    for(int j = 0; j < c; ++j) {
      std::cout << A[i][j] << " ";
    }
    std::cout << A[i][c] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int n = S.size();
  if (S.at(n - 1) == 's') {
    cout << S << "es" << endl;
  }
  else {
    cout << S << "s" << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

struct Edge {
    int to;
    int dist;
    Edge (int _t, int _d) {
        to = _t;
        dist = _d;
    }
};

int N,M;
vector < Edge > G[100010];
map < int, ll > dist;
bool flag;

void dfs (int v, ll depth)
{
    if (!flag) return;
    if (dist.find(v) != dist.end() && dist[v] != depth) {
        flag = false;
        return;
    }
    if (dist.find(v) != dist.end() && dist[v] == depth) {
        return;
    }
    dist[v] = depth;
    REP(i,G[v].size()) {
        dfs(G[v][i].to, G[v][i].dist + depth);
    }
}

int main ()
{
    cin >> N >> M;
    REP(i,M) {
        int L,R,D;
        cin >> L >> R >> D;
        G[L].push_back(Edge(R, D));
        G[R].push_back(Edge(L, -D));
    }

    flag = true;
    for (int i = 1; i <= N; i++) {
        if (dist.find(i) == dist.end()) {
            dfs(i, 0);
        } else {
            dfs(i, dist[i]);
        }
    }

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

    return 0;
}


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

#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

string s;

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>s;
    rep(i,1,s.size()/2){
        string t=s.substr(0,s.size()-2*i);
        if(t.substr(0,t.size()/2)==t.substr(t.size()/2,t.size()/2)){
            cout<<t.size()<<endl;
            return 0;
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}

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

using namespace std;

void Main() {
    long long N;
    cin >> N;
    vector<long long> A(N, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> A[i];
    }

    long long S = 0LL;
    long long C = 1000LL;
    for (long long i = 0; i < N; ++i) {
        if (i == N - 1) {
            C += A[N - 1] * S;
            S -= S;
        }
        else if (A[i] < A[i + 1]) {
            long long nStock = C / A[i];
            S += nStock;
            C -= nStock * A[i];
        }
        else if (A[i] > A[i + 1]) {
            long long cash = A[i] * S;
            S -= S;
            C += cash;
        }
        else {
            // do nothing
        }
    }
    cout << C << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3596
n, m, q = map(int, input().split())
trnum = [[0 for _ in range(n+1)] for _ in range(n+1)]
cnum = [[0 for _ in range(n+1)] for _ in range(n+1)]
for _ in range(m):
  l, r = map(int, input().split())
  trnum[l][r] += 1

for i in range(1, n+1):
  for j in range(1, n+1):
    trnum[i][j] += trnum[i][j-1]

for i in range(1, n+1):
  for j in range(1, n+1):
    trnum[i][j] += trnum[i-1][j]


for _ in range(q):
  l, r = map(int, input().split())
  print(trnum[r][r] + trnum[l-1][l-1] - trnum[l-1][r] - trnum[r][l-1])


Measured memory_bytes: 15576
use std::io;


fn main() {
    let (n, k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    if n % k == 0 { println!("0"); }
    else { println!("1"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define FOR(i,x,n) for(int i=x;i<n;i++)
#define all(a) a.begin(),a.end()
ll mod=1e9+7;
using namespace std;
int main(){
    boost;
    int n,d;
    cin>>n>>d;
    int k=n/(2*d+1);
    if(k*(2*d+1)==n);
    else k++;
    cout<<k;
 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(a[a[i]-1] == i+1){
                ans++;
            }
        }
        System.out.println(ans/2);
    }
}


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: 33564
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int i = 0;
  while (i<100000){
    if (0 <= i*1.08-N && i*1.08-N < 1){
      cout << i;
      break;
    }
    i++;
  }
  if (i > 60000) cout << ":(";
}

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};


int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    bool f[26][26]{};
    for(int i=0;i<n;i++){
        f[s[i]-'a'][t[i]-'a'] = true;
    }
    bool ok = true;
    for(int i=0;i<26;i++){
        int cnt = 0;
        for(int j=0;j<26;j++){
            if(f[i][j]) cnt++;
        }
        ok &= cnt <= 1;
    }
    for(int i=0;i<26;i++){
        int cnt = 0;
        for(int j=0;j<26;j++){
            if(f[j][i]) cnt++;
        }
        ok &= cnt <= 1;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, a[100010], ta, mu;

signed main() {
	cin >> n;
	vector<int> rin(100010);
	rep(i, n) {
		cin >> a[i];
		rin[a[i]]++;
	}
	rep(i, rin.size()) {
		if (rin[i] % 2 == 1)ta += rin[i] - 1;
		else if (rin[i] > 0) {
			ta += rin[i] - 2;
			mu++;
		}
	}
	if (mu % 2 == 1)ta += mu + 1;
	else ta += mu;
	cout << n - ta << endl;
	ggr
}

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

class Dice{
  public:
    int face[6];
    int temp;

  Dice(int f[6]){
    for(int i = 0; i < 6; i++){
      face[i] = f[i];
    }
  }

  void north(){
    temp = face[0];
    face[0] = face[1];
    face[1] = face[5];
    face[5] = face[4];
    face[4] = temp;
  }

  void south(){
    temp = face[0];
    face[0] = face[4];
    face[4] = face[5];
    face[5] = face[1];
    face[1] = temp;
  }

  void west(){
    temp = face[0];
    face[0] = face[2];
    face[2] = face[5];
    face[5] = face[3];
    face[3] = temp;
  }

  void east(){
    temp = face[0];
    face[0] = face[3];
    face[3] = face[5];
    face[5] = face[2];
    face[2] = temp;
  }

  void roll(char order){
    if(order == 'N') north();
    if(order == 'S') south();
    if(order == 'W') west();
    if(order == 'E') east();
  }

  void spin(){
    temp = face[1];
    face[1] = face[2];
    face[2] = face[4];
    face[4] = face[3];
    face[3] = temp;
  }

  void rightSide(int top, int front){
    string findTop = "NNNWNNN";
    for(int i = 0; i < 7; i++){
      if(face[0] == top) break;
      roll(findTop[i]);
    }
    while(face[1] != front){
      spin();
    }
    cout << face[2] << endl;
  }
};

int main(){
  int input[6], n, top, front;

  for(int i = 0; i < 6; i++){
    cin >> input[i];
  }
  Dice dice(input);
  cin >> n;
  while(n--){
    cin >> top >> front;
    dice.rightSide(top, front);
  }
}

Measured memory_bytes: 1204
n,k=map(int,input().split())
d=list(map(int,input().split()))
while True:
    m=n
    f=False
    while m>0:
        if m%10 in d:
            f=True
            break
        m=int(m/10)
    if f:
        n+=1
    else:
        print(n)
        break

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int N;
    long long a,b,c,i;
    a=1;
    b=2;
    scanf("%d",&N);
    for(i=0;i<N-1;i++){
        c=a;
        a=a+b;
        b=c;
    }
    printf("%lld\n",a);
    return 0;
}

Measured memory_bytes: 128
import fractions
a,b,c,d = map(int,input().split())
k = c*d//fractions.gcd(c,d)
sc = b//c-(a-1)//c
sd = b//d-(a-1)//d
sk = b//k-(a-1)//k
print(b-a+1-sc-sd+sk)

Measured memory_bytes: 5048
#include<stdio.h>
#include<ctype.h>

int main(){

char ch;
while(1){
scanf("%c",&ch);
if(ch=='\n')break;
if(islower(ch)){
	ch=toupper(ch);
	printf("%c",ch);
}else if(isupper(ch)){
	ch=tolower(ch);
	printf("%c",ch);
}else printf("%c",ch);

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

Measured memory_bytes: 524
#include<iostream>
#include<cstdint>
#include<algorithm>

int64_t calc(int64_t a1, int64_t a2, int64_t b1, int64_t b2, int lv, int64_t L) {
  if(lv == 0) return 0;
  int64_t Lb = L/3;
  int64_t bi_a1 = a1/Lb;
  int64_t bi_a2 = a2/Lb;
  int64_t bi_b1 = b1/Lb;
  int64_t bi_b2 = b2/Lb;
  if(bi_a1 == bi_b1 && bi_a2 == bi_b2) {
    return calc(a1%Lb, a2%Lb, b1%Lb, b2%Lb, lv-1, Lb); // same block
  }
  if(bi_a2 == bi_b2) { std::swap(a1, a2); std::swap(b1, b2); }
  // bi_a2 != bi_b2
  while(Lb > 0) {
    bi_a1 = a1/Lb;
    bi_b1 = b1/Lb;
    if(bi_a1 != bi_b1) return std::abs(a1-b1) + std::abs(a2-b2);
    if(bi_a1 == 1 && std::abs(a2/Lb - b2/Lb) > 1) {
      a1 %= Lb;
      b1 %= Lb;
      return std::abs(a2 - b2) + std::min(a1+b1+2, Lb*2-a1-b1);
    }
    a1 %= Lb;
    b1 %= Lb;
    Lb /= 3;
  }
  return std::abs(a2 - b2);
}

int main() {
  int64_t L = 1;
  for(int i = 0; i < 30; ++i) L *= 3;
  int Q; std::cin >> Q;
  for(int i = 0; i < Q; ++i) {
    int64_t a, b, c, d; std::cin >> a >> b >> c >> d;
    std::cout << calc(a-1, b-1, c-1, d-1, 30, L) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False


a = list(input())
b = list(input())
co = 0

for i in range(3):
    if a[i] == b[i]:
        co += 1
print(co)




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

using namespace std;
typedef long long ll;

int arr[200100];

int main()
{
    ios_base::sync_with_stdio(0);

    int N, K;
    cin >> N >> K;

    for (int i = 0; i < N; i++)
        cin >> arr[i];
    double res = 0.0;

    double ct = 0;
    for (int i = 0; i < N; i++)
    {
        ct += (arr[i] + 1.) / 2;
        if (i >= K) ct -= (arr[i-K] + 1.) / 2;
        res = max (res, ct);
    }
    cout << fixed << setprecision(10);
    cout << res << "\n";
}

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

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

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(1000000)
input = sys.stdin.readline
# from bisect import *
from collections import *
# from heapq import *
# INF = 500000
mod = 10**9+7

def primes(n):
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1, int(n**0.5)//3+1):
        if sieve[i]:
            k = 3*i+1|1
            sieve[k*k//3::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2, 3] + [3*i+1|1 for i in range(1, n//3-correction) if sieve[i]]

N = int(input())
A = [int(x) for x in input().split()]
ps = primes(int(max(A)**0.5)+1)
dic = defaultdict(lambda : 0)
for a in A:
    for i in ps:
        if a < i:
            break
        if a % i == 0:
            c = 0
            while a % i == 0:
                c += 1
                a //= i
            if dic[i] < c:
                dic[i] = c
    if a > 1 and dic[a] == 0:
        dic[a] = 1
MAX = 1
for k in dic:
    MAX = MAX * pow(k, dic[k], mod) % mod
ans = 0
for a in A:
    ans += MAX * pow(a, mod-2, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 43996
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
const int maxn = 1e5 + 20;
struct Node {
    int cnt, val;
    bool operator < (const struct Node & rhs) const {
        return cnt < rhs.cnt;
    }
    void init() {
        while (val % 2 == 0) {
            cnt++;
            val /= 2;
        }
    }
}a[maxn];
int cnt[maxn];
void work() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].val;
        a[i].init();
        if (a[i].cnt >= 2) cnt[2]++;
        else cnt[a[i].cnt]++;
    }
    int lef = n;
    int pre = 2;
    while (cnt[0] || cnt[1] || cnt[2]) {
        if (pre == 2) {
            if (cnt[0]) {
                cnt[0]--;
                pre = 0;
            } else if (cnt[1]) {
                cnt[1]--;
                pre = 1;
            } else if (cnt[2]) {
                cnt[2]--;
                pre = 2;
            }
        } else if (pre == 1) {
            if (cnt[1]) {
                cnt[1]--;
                pre = 1;
            } else if (cnt[2]) {
                cnt[2]--;
                pre = 2;
            } else if (cnt[0]) {
                printf("No\n");
                return;
            }
        } else if (pre == 0) {
            if (cnt[2]) {
                cnt[2]--;
                pre = 2;
            } else {
                printf("No\n");
                return;
            }
        }
    }
    printf("Yes\n");
    return;
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


Measured memory_bytes: 1024
a,b=input().split()

apple=[int(x+1) for x in range(int(a))]
taste=[int(int(b)+x+1-1) for x in range(int(a))]

if 0 in taste:
    taste.pop(taste.index(0))
    print(sum(taste))
elif taste[0]<0:
    taste.pop(-1)
    print(sum(taste))
else:
    taste.pop(0)
    print(sum(taste))

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

#define PI 3.1415926535897932384626
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,a,b) for(i=a;i<b;i++)
#define ll long long
#define pb push_back
#define popb pop_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define mod 1000000007

using namespace std;

typedef pair<int, int>	pi;
typedef pair<int,pi>    pii;
typedef pair<ll, ll>	pl;
typedef pair<ll,pl>     pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pi>		vpi;
typedef vector<pii>     vpii;
typedef vector<pl>		vpl;
typedef vector<pll>     vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const ll INF=(ll)1e18+5;

void min_self(ll &a,ll b){
	a=min(a,b);
}



void solve(){
	
	ll n,w,valSum,i,value_already;
	
	cin>>n>>w;
	
	ll val[n],weight[n];
	for(i=0LL;i<n;i++){
		cin>>weight[i]>>val[i];
	}
	valSum=accumulate(val,val+n,0);
	vl dp(valSum+1,INF);
	dp[0]=0;
	for(i=0LL;i<n;i++){
		for(value_already=valSum-val[i];value_already>=0;value_already--){
			min_self(dp[value_already+val[i]],dp[value_already]+weight[i]);
		}
	}
	ll ans=0LL;
	for(i=0LL;i<=valSum;i++){
	//	cout<<dp[i]<<" ";
		if(dp[i]<=w){
			ans=max(ans,i);
		}
	}
	cout<<ans;



}



int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
return 0;
}

Measured memory_bytes: 3916
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

ll MOD;

vector<ll> fact(200010,0), factinv(200010,0);

ll exp(ll b, ll e) {
    ll ans = 1;
    while (e) {
        if (e&1) ans = ans * b % MOD;
        e >>= 1;
        b = b * b % MOD;
    }
    return ans;
}

void pp(void) {
    fact[0] = 1;
    for (ll i=1;i<=200000;i++) {
        fact[i] = fact[i-1] * i % MOD;
    }
    factinv[0] = 1;
    factinv[1] = 1;
    for (ll i=2;i<=200000;i++) {
        factinv[i] = exp(fact[i],MOD-2) % MOD;
    }
}

int main(void) {
    int p;
    vector<int> a(3000,0);
    cin >> p;
    for (int i=0;i<p;i++) cin >> a[i];

    MOD = p;
    pp();
    vector<int> j;
    vector<int> b(p,0);
    if (a[0]) {
        b[0] = 1;
        b[p-1] = p-1;
    }
    for (int i=1;i<p;i++) {
        if (a[i]) j.push_back(i);
    }
    for (int i=0;i<p;i++) {
        ll k = 0;
        for (auto itr: j) {
            k += exp(-itr,p-1-i);
        }
        b[i] -= k * fact[p-1] % MOD * factinv[p-1-i] % MOD * factinv[i] % MOD;
        while (b[i]<0) b[i] += MOD;
        b[i] %= MOD;
    }
    b[0] = (b[0] + j.size()) % MOD;
    for (int i=0;i<p;i++) {
        cout << b[i];
        if (i<p-1) cout << " ";
        else cout << endl;
    }

    return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll x;
  cin >> x;
  double cur = 100.0;
  ll curi;
  ll ans = 0;
  while (cur < x) {
    curi = cur;
    cur = curi;
    cur *= 1.01;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using namespace std;
int x[3],y[3];
int isin(int px,int py){
	bool ok=true;
		for(int i=0;i<3;i++){
			bool plus=false;
			if(x[(i+1)%3]==x[(i+2)%3]){
				if(x[i]>x[(i+1)%3])plus=true;
			}
			else{
				int a,b;
				a=(x[i]-x[(i+1)%3])*(y[(i+2)%3]-y[(i+1)%3]);
				b=(y[i]-y[(i+1)%3])*(x[(i+2)%3]-x[(i+1)%3]);
				if(a>b)plus=true;
			}
			bool pnt=false;
			if(x[(i+1)%3]==x[(i+2)%3]){
				if(px>x[(i+1)%3])pnt=true;
			}
			else{
				int a,b;
				a=(px-x[(i+1)%3])*(y[(i+2)%3]-y[(i+1)%3]);
				b=(py-y[(i+1)%3])*(x[(i+2)%3]-x[(i+1)%3]);
				if(a>b)pnt=true;
			}
			if(pnt!=plus)ok=false;
		}
		if(ok)return 1;
		else return 0;
}
int main(){
	int n;
	cin>>n;
	for(int u=0;u<n;u++){
	for(int i=0;i<3;i++)cin>>x[i]>>y[i];
	int px,py,gx,gy;
	cin>>px>>py>>gx>>gy;
	if(isin(px,py)==isin(gx,gy))cout<<"NG"<<endl;
	else cout<<"OK"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

int main () {
	int a,b,c;
	cin >> a >> b >> c;
	if(a + b + c >= 22) cout << "bust";
	else cout << "win";
 
return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<int> v(n);
	for (auto& x : v) cin >> x;
	sort(v.begin(), v.end());
	cout << v.back() - v.front() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    string s;
    cin>>a>>b>>s;
    if (s.size()!=a+b+1) {
        cout<<"No"<<endl;
    } else {
        int flag=0;
        for (int i=0;i<s.size();i++) {
            if (i!=a&&s.at(i)=='-') {
                cout<<"No"<<endl;
                flag=1;
                break;
            } else if (i==a&&s.at(i)!='-') {
                cout<<"No"<<endl;
                flag=1;
                break;
            }
        }
        if (flag==0) {
            cout<<"Yes"<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<math.h>
#include<string.h>
#include<queue>

using namespace std;

#define M  100000+100
#define mod 998244353
typedef long long ll;

string str;
int main()
{
    int len;
    cin>>len;
    cin>>str;
    int flag=0;
    if(len%2==1) cout<<"No";
    else
    {
        int j=len/2;
        for(int i=0;i<len/2;i++,j++)
        {
            if(str[i]!=str[j])
            {
                flag=1;
                break;
            }
        }
        if(!flag) cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())
r = set([n])
if n%2==0:
    s_next = n/2
else:
    s_next = n*3+1
i=2
while s_next not in r:
    r.add(s_next)
    if s_next%2==0:
        s_next = s_next/2
    else:
        s_next = s_next*3+1
    i+=1

print(i)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int range_x = sc.nextInt(), range_y = sc.nextInt();
        int center_x = sc.nextInt(), center_y = sc.nextInt(), radius = sc.nextInt();
        if (center_x >= radius && center_y >= radius && (range_x - center_x) >= radius && (range_y - center_y) >= radius) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 26412
#include <iostream>
#include <algorithm>

using namespace std;

int A[100001],B[1000][1000];

int main(){
  int i,j,N,f=0;
  cin >> N;
  A[0]=0;
  for (i=1;i<1000;++i) {
    A[i] = A[i-1]+i;
    if (N==A[i]) {
      f=i;
      break;
    }
  }
  if (f==0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << f+1 << endl;
  int k=1;
  for (i=0;i<f+1;++i) {
    for (j=i+1;j<f+1;++j) {
      B[i][j]=k;
      k++;
    }
  }
  for (i=0;i<f+1;++i) {
    cout << f;
    for (j=0;j<i;++j) {
      cout << " " << B[j][i];
    }
    for (j=i+1;j<f+1;++j) {
      cout << " " << B[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define repr(i,j,x) for(int i = j; i < x; i++)
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
    int n; cin >> n;
    vector<ll> e(n+10,0);

    auto prime = [&](int x){
        bool ok = true;
        rep(i,x){
            if(i <= 1)continue;
            if(x%i == 0){ok = false;break;}
        }
        return ok;
    };
    repr(i,2,n+1){
        int cur = i;
        repr(j,2,i+1){
            if(!prime(j))continue;
            while(cur % j == 0){
                e[j]++;
                cur /= j;
            }
        }
    }

    // print(e);
    ll count = 0;
    rep(i,e.size()){
        if(!e[i])continue;
        rep(j,e.size()){
            if(!e[j])continue;
            if(i >= j)continue;
            rep(k,e.size()){
                if(!e[k])continue;
                if(j >= k)continue;
                if(e[i] >= 4 && e[j] >= 4 && e[k]>= 2)count++;
                if(e[i] >= 4 && e[j] >= 2 && e[k]>= 4)count++;
                if(e[i] >= 2 && e[j] >= 4 && e[k]>= 4)count++;
            }
        }
    }

    rep(i,e.size()){
        if(!e[i])continue;
        rep(j,e.size()){
            if(!e[j])continue;
            if(i >= j)continue;
            if(e[i] >= 24 && e[j] >= 2)count++;
            if(e[i] >= 2 && e[j] >= 24)count++;
            if(e[i] >= 14 && e[j] >= 4)count++;
            if(e[i] >= 4 && e[j] >= 14)count++;
        }
    }

    rep(i,e.size()){
        if(!e[i])continue;
        if(e[i] >= 74) count++;
    }

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {	
		Scanner sc = new Scanner(System.in);
		String s;
		double x = 0, y = 0;
		double rad = 90 * Math.PI / 180;
		while(true) {
			s = sc.next();
			if(s.equals("0,0")) break;
			String[] st	= s.split(",");
			int len = Integer.parseInt(st[0]);
			int deg = Integer.parseInt(st[1]);
			x += len * Math.cos(rad);
			y += len * Math.sin(rad);
			rad -= deg * Math.PI / 180;
		}
		System.out.println((int)x);
		System.out.println((int)y);
	}
}

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

int main(){
	
	int n , m , q=0 ;
	int p[] = { 10000 , 1000 , 100 , 10 , 1 } ;
	
	while(1){
		cin >> n ;
		if( cin.eof() ) break ;
		
		if( q!=0 ) cout << endl ;
		else q++ ;
		
		char s[8][5] = {} ;
		
		for( int i=0 ; i<5 ; i++ ){
			m = n / p[i] ;
			n -= m * p[i] ;
			
			s[2][i] = '=' ;
			if( m/5 == 0 ){
				s[0][i] = '*' ;
				s[1][i] = ' ' ;
			}else {
				s[0][i] = ' ' ;
				s[1][i] = '*' ;
			}
			for( int j=3 ; j<8 ; j++ ){
				if( m%5 == j-3 ) s[j][i] = ' ' ;
				else s[j][i] = '*' ;
			}
		}
		
		for( int i=0 ; i<8 ; i++ ){
			for( int j=0 ; j<5 ; j++ ){
				cout << s[i][j] ;
			}
			cout << endl ;
		}
	}
	
return 0 ;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int n,k; cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end(),greater<int>());
  
  ll ans = 0;
  for(int i = k; i < n; i++) ans += h[i];
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024