akhauriyash/Code-Regression huggingface dataset:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def main():
    n = ni()
    a = na()
    anss = [0 for i in range(n)]
    for i in a:
        anss[i-1] += 1
    for i in anss:
        print(i)
if __name__ == '__main__':
    main()



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

using namespace std;

const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    char a[n][m];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int dp[n][m];
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(a[i][j] == '#') continue;
            if(i - 1 >= 0) {
                dp[i][j] += dp[i - 1][j];
            }
            if(j - 1 >= 0) {
                dp[i][j] += dp[i][j - 1];
            }
            dp[i][j] %= mod;
        }
    }
    cout << dp[n - 1][m - 1];
    return 0;
}


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

using namespace std;

int main ()
{
  int n, m, i, j, sum = 0;
  
  cin>> n >> m;
  for (i = 0; i < m; i++) {
    cin>> j;
    sum += j;
  }
  
  if (sum >= n)
    cout<< "Yes" << endl;
  
  else
    cout<< "No" << endl;
  
  return 0;
}

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

inline bool is_leapyear(unsigned int y){
    return (y & 3) == 0 && (y % 100 != 0 || (y / 100 & 3) == 0);
}

void solve(int a, int b){
    bool flag = false;
    for(int i = a; i <= b; i++){
        if(is_leapyear(i)){
            printf("%d\n", i);
            flag = true;
        }
    }
    if(!flag) puts("NA");
}

int main(){
    int a, b;
    bool flag = false;
    while(cin >> a >> b){
        if(a == 0 && b == 0) break;
        if(flag) puts("");
        solve(a, b);
        flag = true;
    }
    return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B>C+D)
    cout << "Left" << endl;
  else if(A+B==C+D)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}


Measured memory_bytes: 256
n,t = map(int,input().split())
tl = list(map(int,input().split()))
tl.sort()
ans = 0
pre = 0
for i in range(n):
  if pre + t >= tl[i]:
    ans += tl[i] - pre
  else:
    ans += t
  pre = tl[i]
print(ans + t)

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n,d; cin >> n >> d;
  static int x[30][30];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      int res = 0;
      for(int k = 0; k < d; k++){
        res += pow((x[i][k]-x[j][k]),2);
      }
      for(int k = 1; k < 1000; k++){
        if(k*k == res) ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    typedef long long ll;
     
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
    int main() { 
        string A,B;
        cin >> A;
        cin >> B;
        if (A.length() == B.length()) {
            rep(i, A.length()){
                if (A[i] < B[i]) {
                    cout << "LESS" << "\n";
                    return 0;
                } else if (A[i] > B[i]) {
                    cout << "GREATER" << "\n";
                    return 0;
                } else {
                    continue;
                }
            }
        } else {
            if (A.length() < B.length()) {
                cout << "LESS" << "\n";
                return 0;
            } else {
                cout << "GREATER" << "\n";
                return 0;
            }
        }
        cout << "EQUAL" << "\n";
     
        return 0;
    }

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

bool kouho[200009];
int ans[200009];

void f(int idx,int num){
    kouho[num]=true;
    ans[idx]=num;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,x;
    cin>>n>>x;
    
    if(x==1||x==(2*n-1)){
        cout1("No");
        return 0;
    }
    
    int idx=n-1;
    if(x==2){
        f(idx,x+1);
        f(idx+1,x);
        f(idx+2,x-1);
        f(idx+3,x+2);
    }else{
        f(idx,x-1);
        f(idx+1,x);
        f(idx+2,x+1);
        f(idx+3,x-2);
    }
    
    int num=1;
    rep1(i,2*n-1){
        if(ans[i]) continue;
        while(kouho[num]) num++;
        f(i,num);
    }
    
    cout1("Yes");
    rep1(i,2*n-1) cout1(ans[i]);
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
    {
        cout << s << endl;
    }
    else
    {
        for (ll i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

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

int main(){
    int N;
    int a[1000000];
    int max = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(max < abs(a[i]-a[j]))
            max = abs(a[i]-a[j]);
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
   int n,i,j,tot,max;
   tot=0;
   scanf("%d",&n);
   int cand[2][n];
   for(i=0;i<2;i++)
    for(j=0;j<n;j++)
    scanf("%d",&cand[i][j]);
   for(j=0;j<n;j++)
    tot=tot+cand[1][j];
   tot=tot+cand[0][0];
   max=tot;
   for(j=1;j<n;j++)
   {
       tot=tot-cand[1][j-1]+cand[0][j];
       if(tot>max) max=tot;
   }
   printf("%d",max);
   return 0;
}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()
print("YES" if X == 3 or X == 5 or X == 7 else "NO")

Measured memory_bytes: 5148
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;

  int len=s.size();
  if(len==2) cout<<s;
  else cout<<s.at(2)<<s.at(1)<<s.at(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n,p;cin >> n >>p;
    string s;cin >> s;
    if(p!=2&&p!=5){
        rev(all(s));
        vl v(s.size());
        ll tmp=0;
        rep(i,s.size()){
            tmp+=modpow(10,i,p)*(s[i]-'0');
            //cout << tmp <<endl;
            tmp%=p;
            v[i]=tmp;
        }
        //rep(i,s.size())cout << v[i] <<endl;
        vl count(p,0);
        count[0]++;
        rep(i,s.size())count[v[i]]++;
        ll ans=0;
        rep(i,p){
            ans+=count[i]*(count[i]-1)/2;
        }
        cout <<ans <<endl;
    }
    if(p==2){
        ll ans=0;
        rep(i,n){
            if((s[i]-'0')%2==0){
                ans+=i+1;
            }
        }
        cout <<ans <<endl;
    }
    if(p==5){
        ll ans=0;
        rep(i,n){
            if((s[i]-'0')%5==0){
                ans+=i+1;
            }
        }
        cout <<ans <<endl;
    }
}

Measured memory_bytes: 2180
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

fn main() {
  let n: u64 = read();
  let d: Vec<u64> = read_vec();

  let mut sum = 0;
  for i in 0..d.len()-1 {
    for j in i+1..d.len() {
      sum += d[i] * d[j];
    }
  }

  println!("{}", sum);
}

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

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	int deg[50]={};
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		deg[u]++;
		deg[v]++;
	}
	rep(u,n) printf("%d\n",deg[u]);

	return 0;
}


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

using namespace std;

int main(void){
	string s;
	cin >> s;
	if(s.length()<4){
		cout << "No" << endl;
		return 0;
	}
	if(s.at(0)=='Y' && s.at(1)=='A' && s.at(2)=='K' && s.at(3)=='I'){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            
            var d = new long[(long)Math.Pow(10, 5)];
            for (int i = 0; i < n; i++)
            {
                d[a[i]]++;
            }
            long memo = 0;
            long ans = 0;
            for (int i = 0; i < (long)Math.Pow(10,5)-2; i++)
            {
                memo = d[i] + d[i + 1] + d[i + 2];
                if (ans < memo) ans = memo;
            }
            WriteLine(ans);
            
            

            Console.Out.Flush();
        }
    }
}



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

int main () {
    ll N,K; cin >> N >> K;
    ll ans;
    if(N >= K) {
        if(N%K == 0) ans = 0;
        else ans = min(abs(N - (N/K+1) * K),abs(N-N/K*K));
    }else {
        ans = min(N,abs(N-K));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

typedef long long LL;

LL x, ans, now = 100;

int main() {
    read(x);
    while (now < x) {
        now = now + now / 100;
        ++ans;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
    int n;
    int a, b;
    cin >> n;

    if(n == 1){
        cout << "Hello World" << endl;
    }
    if(n == 2){
        cin >> a >> b;
        cout << a + b << endl;
    }
    
    return 0;

}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

//最小公倍数を素因数分解した形で持ちたい
//お互いを素因数分解して指数部が大きいやつを持っておく
//やるだけ
map<ll, ll> tPF;
void lcm(ll num){

    //素因数と指数部の並び
    map<ll, ll > PF;

    ll i = 2;

    while(num >= i * i){
        if(num % i == 0){
            PF[i]++;
            num /= i;
        }else{
            i++;
        }
    }
    //1は素因数分解できない
    if(num != 1){
        PF[num]++;
    }

    //指数部が大きい素因数だけ保持
    auto begin = PF.begin(), end = PF.end();
    for (auto iter = begin; iter != end; iter++) {
        auto it = tPF.find(iter->first);
        if(it != tPF.end()){
            tPF[iter->first] = max(it->second, iter->second);
        }else{
            tPF[iter->first] = iter->second;
        }
    }       
}

//ll pw[10001][10001];
ll fast_pow(ll a, ll n){
    if(a == 0) return 0;
    if(n == 0) return 1;
    //べき数nが奇数, aを前にだして, a^n-1の気持ちに
    if(n % 2 == 1){
        return a * fast_pow(a, n - 1) % MOD;
    }else{
        //べき数nが偶数のとき，べき数を半分にして, aをまとめる. べき数を半分にする
        return fast_pow(a * a % MOD, n / 2) % MOD;
    }
}

//逆元
pii extgcd(ll a, ll b){
    //前提：aとbが互いに素であること．
    pii x(make_pair(1,0), a);
    pii y(make_pair(0,1), b);

    ll div = 0;

    //終了条件:(GCD(a,b), 0)または(0,GCD(a,b))
    while(true){
        if(y.second == 0) return x;
        
        div = x.second / y.second;
        x.second = x.second  - div * y.second;
        x.first.first = x.first.first - div * y.first.first;
        x.first.second = x.first.second - div * y.first.second;

        if(x.second == 0) return y;

        div = y.second / x.second;
        y.second = y.second - div * x.second;
        y.first.first = y.first.first - div * x.first.first;
        y.first.second = y.first.second - div * x.first.second;
    }
}

ll modinv(ll a, ll m = MOD){
    //前提：aとmが互いに素であること．
    pii ans;
    ans = extgcd(a, m);

    ll invNum = 0;
    invNum = ans.first.first;
    invNum %= m;
    //C++特有の剰余がマイナスになってしまう対策
    if(invNum < 0) invNum += m;

    return invNum;
}

int main() {

    ll N;
    cin >> N;

    //クソ準備
    /*
    for(ll i = 0; i <= 10000; i++){
        for(ll j = 0; j <= 10000; j++){
            pw[i][j] = fast_pow(i, j);
        }        
    }
    */

    map<ll, ll> input;
    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);
        input[t]++;
        lcm(t);
    }

    ll lcm = 1;
    auto begin = tPF.begin(), end = tPF.end();
    for (auto iter = begin; iter != end; iter++) {
        lcm *= fast_pow(iter->first, iter->second);
        lcm %= MOD;
    }    
    ll ans = 0;

    for(ll i = 0; i < N; i++){
        //答え算出
        ll t_ans = lcm * modinv(vec[i]) % MOD; 
        //cout << t_ans << endl;
        ans += t_ans;
        ans %= MOD;
    }

    cout << ans << endl;

}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int A ,B ,X ;
	cin >> A >> B >> X;

	bool ans = (A+B)>=X && A<=X;

	println(((ans)? "YES":"NO"));

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> b(n-1);
	rep(i,n-1) cin >> b[i];
	vector<int> a(n,pow(10, 5));
	rep(i,n-1) {
		a[i] = min(a[i], b[i]);
		a[i+1] = min(a[i+1], b[i]);
	}
	int ans = 0;
	rep(i,n) ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007

def main():

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

    keta = [-1] * N

    flag = True
    for _ in range(M):
        s, c = map(int, input().split())
        s = s - 1

        if s == 0 and c == 0 and N > 1:
            flag = False

        if keta[s] == -1:
            keta[s] = c
        else:
            if not keta[s] == c:
                flag = False

    if keta[0] == -1:
        if N > 1:
            keta[0] = 1
        elif N == 1:
            keta[0] = 0

    for i in range(1, N):
        if keta[i] == -1:
            keta[i] = 0

    if flag:
        print(int(''.join(map(str, keta))))
    else:
        print("-1")


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const int inf = 1e9 + 7;
const int MAXN = 1e5 + 5;

	
int main(){		
	int n; cin >> n;
	vector<int> a(n), b(n), c(n-1);
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	for(int i = 0; i < n; ++i){
		cin >> b[i];
	}
	for(int i = 0; i < n-1; ++i)
		cin >> c[i];
	ll ans = 0;
	for(int i = 0; i < n; ++i){
		ans+=b[a[i]-1];
		if(a[i]+1 == a[i+1]){
			ans+=c[a[i]-1];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3604
extern crate proconio;

use proconio::*;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    let n = s.len();
    let ans = if s.as_slice() == &t[..n] { "Yes" } else { "No" };
    println!("{}", ans);
}


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

using namespace std;

void solve(int N, int D) {
  for (int i = 1; i < 20; i++) {
    int x = D * 2 * i + i;
    if (x >= N) {
      printf("%d\n", i);
      return;
    }
  }
}

int main() {
  int N, D;
  cin >> N >> D;
  solve(N, D);
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cctype>
#include<vector>
#include <ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include <math.h>
using namespace std;
int a,b,c=1,j;
vector<int> m;
int main() {
	cin >> a;
	for (size_t i = 0; i < a; i++)
	{
		cin >> b;
		m.push_back(b);
	}
	sort(m.begin(), m.end());
	m.push_back(*(m.begin()));
	sort(m.begin(), m.end());
	if (a % 2 == 1) {
	for (size_t q =0; q <= (a - a % 2) / 2; q++)
	{
		j = (a-a%2)/2 - q;
		if (m[j * 2] != j * 2 || m[j * 2 + 1] != j * 2) {
			cout << 0 << endl; goto a;
		}
	}}
	else
	{
		for (size_t j = (a - a % 2) / 2; j > 0; j--)
		{
			if (m[j * 2 - 1] != j * 2 - 1 || m[j * 2] != j * 2 - 1) {
				cout << 0 << endl; goto a;
			}
		}
	}
		for (size_t k = 0; k < (a-a%2)/2; k++)
		{
			c *= 2;
			c %= 1000000007;
		}

	cout << c << endl;
	a:
	return 0;
	}


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


const int MAX_N = 2 * 10e5;
//ll N, D, A;
//int X[MAX_N], H[MAX_N];
//pair<int, int> XH[MAX_N];


void Main() {
  int N; ll D, A; cin >> N >> D >> A;
  vector<pair<int, int>> X(N);

  rep(i, N) cin >> X[i].first >> X[i].second;

  sort(X.begin(), X.end());

  ll total = 0;
  ll ans = 0;

  queue<pair<ll, ll>> q;

  rep(i, N)
  {
    ll x = X[i].first;
    ll h = X[i].second;
    while (q.size() and q.front().first < x)
    {
      total -= q.front().second;
      q.pop();
    }

    h -= total;

    if (h > 0)
    {
      ll n_atk = (h + A - 1) / A;
      ans += n_atk;
      ll damage = n_atk * A;
      total += damage;
      q.emplace(x + 2 * D, damage);
    }
  }

  cout << ans << endl;

//  cin >> N >> D >> A;
//  vector<pair<ll, ll>> xh(N);
//  rep(i, N) {
//    cin >> xh[i].first >> xh[i].second;
//  }
//
//  sort(xh.begin(), xh.end());
//
//  ll ans = 0;
//  ll tot = 0;
//  queue<pair<ll, ll>> q;
//  rep(i, N) {
//    ll x = xh[i].first;
//    ll h = xh[i].second;
//    if (q.size() && q.front().first < x) {
//      tot -= q.front().second;
//      q.pop();
//    }
//    h -= tot;
//    if (h > 0) {
//      ll num = (h + A - 1) / A;
//      ans += num;
//      ll damage = num * A;
//      tot += damage;
//      q.emplace(x + D * 2, damage);
//    }


//    int cnt;
//    if (XH[i].second <= 0) {
//      cnt = 0;
//    } else if (XH[i].second % A == 0) {
//      cnt = XH[i].second / A;
//    } else {
//      cnt = XH[i].second / A + 1;
//    }
//    ans += cnt;
//
//    for (int j = i + 1; j < N; ++j) {
//      if (XH[j].first >= XH[i].first && XH[j].first <= XH[i].first + 2 * D)  {
//        XH[j].second -= A * cnt;
//      } else {
//        break;
//      }
//    }
//  }
//
//  cout << ans << endl;
}

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

Measured memory_bytes: 3456
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	minA, minB := nextInt(), nextInt()
	for i := 0; i < n-1; i++ {
		a, b := nextInt(), nextInt()
		if a > minA {
			minA = a
			minB = b
		}
	}
	fmt.Println(minA + minB)
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>

using namespace std;
int main(void){
  int N;
  long a[100100];
  long count[100100] = {};
  cin >> N;
  
  for (int i = 0; i < N; ++i) {
  	scanf("%d", &a[i]);
    count[a[i]]++;
  }
  int num_unique = 0;
  for (int j = 0; j<=100000; j++){
    if (count[j] >=  1) {num_unique += 1;}
    
  }
 
  if (num_unique %2 == 0) {cout << num_unique -1 << endl;}
  else cout << num_unique << endl;
}
 

 

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int ND[] = {31,29,31,30,31,30,31,31,30,31,30,31};
int f(int n, vector<bool> m) {
	int r = 0;
	switch (n) {
	case 0:return m[0] + m[1] + m[2] + m[4] + m[5] + m[6];
	case 1:return m[2] + m[5];
	case 2:return m[0] + m[2] + m[3] + m[4] + m[6];
	case 3:return m[0] + m[2] + m[3] + m[5] + m[6];
	case 4:return m[1] + m[2] + m[3] + m[5];
	case 5:return m[0] + m[1] + m[3] + m[5] + m[6];
	case 6:return m[0] + m[1] + m[3] + m[4] + m[5] + m[6];
	case 7:return m[0] + m[2] + m[5];
	case 8:return m[0] + m[1] + m[2] + m[3] + m[4] + m[5] + m[6];
	case 9:return m[0] + m[1] + m[2] + m[3] + m[5] + m[6];
	default: throw 1;
	}
	return r;
}
int main() {
	int N, K;
	cin >> N >> K;
	vector<vector<bool>> PQ(14, vector<bool>(7, true));
	for (int i = 0; i < K; ++i) {
		int p, q;
		cin >> p >> q;
		PQ[p][q] = false;
	}
	map<int, int> yy;
	map<int, int> y229;
	for (int y = 0; y < 10000; ++y) {
		int n = f(y / 1000, PQ[0]) + f(y / 100 % 10, PQ[1]) + f(y / 10 % 10, PQ[2]) + f(y % 10, PQ[3]);
		++yy[n];
		if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
			++y229[n];
		}
	}
	map<int, int> ymd;
	for (int m = 1; m <= 12; ++m) {
		int nd = ND[m-1];
		for (int d = 1; d <= nd; ++d) {
			int n = f(m / 10, PQ[4]) + f(m % 10, PQ[5]) + f(d / 10, PQ[6]) + f(d % 10, PQ[7]);
			if (m == 2 && d == 29) {
				for (auto p : y229) {
					ymd[p.first + n] += p.second;
				}
			} else {
				for (auto p : yy) {
					ymd[p.first + n] += p.second;
				}
			}
		}
	}
	map<int, int> hms;
	for (int h = 0; h < 24; ++h) for (int m = 0; m < 60; ++m) for (int s = 0; s < 60; ++s) {
		++hms[f(h / 10, PQ[8]) + f(h % 10, PQ[9]) + f(m / 10, PQ[10]) + f(m % 10, PQ[11]) +
			f(s / 10, PQ[12]) + f(s % 10, PQ[13])];
	}
	long long r = 0;
	for (auto p : ymd) {
		int m = N - p.first;
		if (hms.count(m)) {
			r += (long long)p.second * hms[m];
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 3132
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, s, n) for (int i = (s); i < (n); ++i)
#define repsr(i, n, s) for (int i = (n); i >= (s); --i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
const int64_t inf = (int64_t)1e18;

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

  int N; cin >> N;
  vector<int> as(3 * N);
  rep(i, 3 * N) cin >> as[i];
  
  priority_queue<int, vector<int>, greater<int>> pql;
  priority_queue<int> pqr;
  int64_t sum_l = 0;
  int64_t sum_r = 0;
  vector<int64_t> bs(N + 1, 0);


  rep(i, N) {
    sum_l += as[i];
    pql.push(as[i]);
  }
  bs[0] = sum_l;

  reps(i, N, 2 * N) {
    if (pql.top() < as[i]) {
      sum_l -= pql.top(); pql.pop();
      sum_l += as[i];
      pql.push(as[i]);
    }
    bs[i - N + 1] = sum_l;
  }


  reps(i, 2 * N, 3 * N) {
    sum_r += as[i];
    pqr.push(as[i]);
  }
  bs[N] -= sum_r;

  repsr(i, 2 * N - 1, N) {
    if (pqr.top() > as[i]) {
      sum_r -= pqr.top(); pqr.pop();
      sum_r += as[i];
      pqr.push(as[i]);
    }
    bs[i - N] -= sum_r;
  }

  int64_t ans = -inf;
  repe(i, N) ans = max(ans, bs[i]);
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3320
#include "bits/stdc++.h"
using namespace std;
string s;
int main()
{
    cin>>s;
    if(s.length()<2||s.length()%2){
        cout<<"No"<<endl;
        return 0;
    }
    int cnt=0;
    int i=0,flag=0,len=s.length()-1;
    while(i<len){
        if(s[i]=='h'&&s[i+1]=='i'){
            i+=2;
        }else{
            flag=1; break;
        }
    }
    if(flag)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B;
  cin>>A>>B;
  int temp = 1;
  int ans = 0;
  while(temp<B){
    temp+=A-1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF 1000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, graph[N][N], d[N];
 

void bfs(void) {
    int i, v;
    int head, tail, que[N*N], color[N];
 
    head = -1;
    tail = 1;
    for (i = 0; i < n; i++) {
        d[i] = INF;
        color[i] = WHITE;
    }
    color[0] = GRAY;
    que[++head] = 0;
    d[0] = 0;
 
    while (head != tail) {
        v = que[head++];
        for (i = 0; i < n; i++) {
            if (graph[v][i] == 1 && color[i] == WHITE) {
                color[i] = GRAY;
                que[tail++] = i;
                d[i] = d[v] + 1;
            }
        }
        color[v] = BLACK;
    }
}
void init(void) {
    int i, j;
 
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            graph[i][j] = 0;
        }
    }
    return ;
}
void print(void) {
    int i;
    for (i = 0; i < n; i++) {
        printf("%d ", i + 1);
        if (d[i] == INF) printf("-1\n");
        else             printf("%d\n", d[i]);
    }
    return ;
}

int main() {
    int i, j, l, m, in;
 
    init();
 
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d%d", &l, &m);
        for (j = 0; j < m; j++) {
            scanf("%d", &in);
            graph[l - 1][in - 1] = 1;
        }
    }
 
    bfs();
    print();
 
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  string N;
  cin >> N;
  if (N[0] == '9' || N[1] == '9')
    puts("Yes");
  else
    puts("No");
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  static Scanner scan = new Scanner(System.in);

  public static void main(String[] args) {
    Set<Integer> set = new HashSet<>();
    int n = scan.nextInt();
    int k = scan.nextInt();

    for (int i = 0; i < n; i++) {
      set.add(i + 1);
    }
    for (int i = 0; i < k; i++) {
      int d = scan.nextInt();

      for (int j = 0; j < d; j++) {
        int s = scan.nextInt();
        set.remove(s);
      }
    }

    System.out.print(set.size());
  }
}

Measured memory_bytes: 37356
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!"); template<typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) { }}; template<typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : vector<T>(n, val) { } };
inline ll mod(ll x) { return (x%MOD + MOD)%MOD; }
ll gcd(ll a, ll b, ll &x, ll &y){if(a == 0){x = 0, y = 1; return b;} ll x1, y1;  ll d = gcd(b%a, a, x1, y1); x = y1 - (b/a) * x1; y = x1; return d;}
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
void dfs(ll s, vector<ll> &arr, vector<ll> &vis, ll &start)
{
    vis[s] = 1;
    if(start > 0) return;
    ll v = arr[s];
    if(vis[v] == 0)
    {
        dfs(v,arr,vis,start);
    }
    else if(vis[v] == 1)
    {
        start = v;
        return;
    }

    vis[s] = 2;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,k;
    cin>>n>>k;
    vector<ll> arr(n+1);
    for(ll i=1;i<=n;++i) cin>>arr[i];
    vector<ll> vis(n+1);
    ll start = 0;
    dfs(1,arr,vis,start);
    ll i = 1;
    while(k>0 && i!=start)
    {
        i = arr[i];
        k--;
    }
    if(k==0)
    {
        cout<<i<<endl;
        finish;
    }
    i = start;
    ll length = 0;
    do
    {
        i = arr[i];
        length++;
    } while (i != start);
    k = k%length;
    i = start;
    for(ll j=0;j<k;++j) i = arr[i];
    cout<<i<<endl;
    
}

Measured memory_bytes: 12340
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n,k;
        cin >> n >> k;
        int i,a[n+1];
        int dp[k+1];
        for(i=1; i<=n; i++) {cin >> a[i];
        dp[a[i]]=1;
        }
        dp[0]=0;
        for(i=1; i<=k; i++){
            int b=0;
            for(int j=1; j<=n; j++){
             
                if(i-a[j] >=0){
                    if(dp[i-a[j]] ==0){
                        b=1;
                        break;
                    }
                }
            }
             if(b){
                    dp[i]=1;
                }
                else{
                    dp[i]=0;
                }
        }
        if(dp[k]) cout << "First" << '\n';
        else cout << "Second" << '\n';


        

}

Measured memory_bytes: 1024
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  long long m;
  for(;;){
    cin>>n;
    if(n==-1)
      break;
    m=0;
    for(i=10;i>=0;i--){
      m+=n/(long long)pow(4,i)*(long long)pow(10,i);
      n%=(int)pow(4,i);
    }
    cout<<m<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n;
char s[100055];
bool ans[100055];

// 0 S truth
// 1 W lie

void solve(bool a, bool b) {
	ans[0] = a;
	ans[1] = b;
	
	FOR(i, 1, n) {
		if (ans[i] == 0) {
			if (s[i] == 'o') ans[i + 1] = ans[i - 1];
			if (s[i] == 'x') ans[i + 1] = 1 - ans[i - 1];
		}
		if (ans[i] == 1) {
			if (s[i] == 'x') ans[i + 1] = ans[i - 1];
			if (s[i] == 'o') ans[i + 1] = 1 - ans[i - 1];
		}
	}
	
	if (ans[n] != ans[0]) return;
	
	if (ans[0] == 0) {
		if (s[0] == 'o' && ans[n - 1] != ans[1]) return;
		if (s[0] == 'x' && ans[n - 1] == ans[1]) return;
	}
	
	if (ans[0] == 1) {
		if (s[0] == 'x' && ans[n - 1] != ans[1]) return;
		if (s[0] == 'o' && ans[n - 1] == ans[1]) return;
	}
	
	FOR(i, 0, n) printf("%c", ans[i] ? 'W' : 'S');
	printf("\n");
	exit(0);
}

int main () {
	
	scanf("%d%s", &n, s);
	
	solve(0, 0);
	solve(0, 1);
	solve(1, 0);
	solve(1, 1);
	
	printf("-1\n");
	
	return 0;
	
}

Measured memory_bytes: 512
import java.util.HashSet;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
    public static void main (String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(br.readLine());
	String input;
	HashSet<String> dic = new HashSet<String>();
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < n; i++) {
	    input = br.readLine();
	    if (input.startsWith("i")) {
		dic.add(input.substring(7));
	    } else if (input.startsWith("f")) {
		if (dic.contains(input.substring(5))) {
		    sb.append("yes\n");
		} else {
		    sb.append("no\n");
		}
	    }
	}
	System.out.print(sb);
    }
}

Measured memory_bytes: 129012
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,int> pii;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> T _max(T a,T b){return a>b ? a : b;}
template <class T> T _min(T a,T b){return a<b ? a : b;}
template <class T> bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int LOG=60,N=100005;
ll n,m,x;
ll k;
ll a[N],b[N],c[N];
ll fa[LOG+1][N];
double ans[N];
void init()
{
    read(n);
    for (int i=1;i<=n;++i)
    {
        read(a[i]);
    }
    read(m); read(k);
    for (int i=1;i<=n;++i)
    {
        c[i]=i;
    }
    for (int i=1;i<=m;++i)
    {
        read(x);
        swap(c[x],c[x+1]);
    }
}

void solve()
{
    //outarr(c,1,n);
    for (int i=1;i<=n;++i)
    {
        fa[0][i]=c[i];
    }
    for (int i=1;i<=LOG;++i)
    {
        for (int j=1;j<=n;++j)
        {
            fa[i][j]=fa[i-1][fa[i-1][j]];
        }
    }
    for (int i=1;i<=n;++i)
    {
        ll tmp=k; int now=i;
        for (int j=LOG;j>=0;--j)
        {
            if (tmp>=(1LL<<j))
            {
                now=fa[j][now];
                tmp-=(1LL<<j);
            }
        }
        //cout<<i<<" "<<now<<endl;
        if (now) ans[i]=a[now]-a[now-1];
    }
    //outarr(a,1,n);
    for (int i=1;i<=n;++i)
    {
        ans[i]+=ans[i-1];
    }
    for (int i=1;i<=n;++i)
    {
        printf("%.1lf\n",(double)ans[i]);
    }
}

int main()
{
    init();
    solve();
    return 0;
}


Measured memory_bytes: 53748
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(M)]
parts=[i for i in range(N)]
ans=[N*(N-1)//2]
parts_dict=dict([[i,[i]] for i in range(N)])

for i in range(M-1):
    ab=AB.pop()
    if parts[ab[0]-1]==parts[ab[1]-1]:
        ans.append(ans[-1])
    else:
        a,b=sorted(ab,key=lambda x:parts[x-1])
        len_a,len_b=len(parts_dict[parts[a-1]]),len(parts_dict[parts[b-1]])
        ans.append(ans[-1]-len_a*len_b)
        parts_dict[parts[a-1]]+=parts_dict[parts[b-1]]
        for i in parts_dict[parts[b-1]]:
            parts[i]=parts[a-1]

for i in reversed(ans):
    print(i)

Measured memory_bytes: 61212
#include<iostream>
//#include<fstream>

using namespace std;

int main() {
	//??§??????:20??\
	//?°???????:19??\
	//1??´:195??\
	//3??§?????????????????´:200??\

	//ifstream fin("in.txt");

	int n = 0;
	cin >> n;

	//1000??´????????\??°
	const int allday = 196471;// = 195 * 666 + 200 * 333 + 1

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

		int y, m, d;
		cin >> y >> m >> d;

		y--;
		int ans = 590 * (y / 3) + 195 * (y % 3);

		m--;
		ans = y % 3 == 2 ? ans + 20 * m : ans + 39 * (m / 2) + 20 * (m % 2);

		ans += d;

		cout << allday - ans << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int,input().split()))
a = 0
for i in range(N):
  if A[i] == 0:
    a = 1
    break
  elif A[i] > 10**18:
    a = 2
    break

if a == 1:
  print(0)
elif a == 2:
  print(-1)
else:
  b = 0
  ans = 1
  for i in range(N):
    ans = ans*A[i]
    if ans > 10**18:
      b = 1
      break

  if b == 0:
    print(ans)
  else:
    print(-1)
      

Measured memory_bytes: 21584
# coding:utf-8

import sys
from collections import Counter, defaultdict

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, m = LI()
YP = [[y, p] for p, y in (LI() for _ in range(m))]

YP2 = sorted(YP)

P = defaultdict(int)
ans = {}
for y, p in YP2:
    P[p] += 1
    l1, l2 = len(str(p)), len(str(P[p]))
    id = '{:06d}{:06d}'.format(p, P[p])
    ans[y] = id

for y, p in YP:
    print(ans[y])


Measured memory_bytes: 42740
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}

int main(){
	string s;
	cin>>s;
	if(s=="ARC")cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
	return 0;
}

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

#define int long long

int N;

signed main()
{
    cin >> N;
    if(N & 1) cout << 0 << endl;
    else
    {
        int ans = 0;
        for(int i = 5; i * 2 <= N; i *= 5)
        {
            ans += N / (i * 2);
        }
        cout << ans << endl;        
    }
    
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(n, 0);
  rep(i, k){
    int d;
    cin >> d;
    rep(j, d){
      int in;
      cin >> in;
      in--;
      v.at(in)++;
    }
  }
  int ans = 0;
  rep(i, n){
    if(v.at(i) == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main(){

	char s[200];
	string str;

	fgets(s,200,stdin);
	
	str = s;

	for(int i = 0; i < str.size(); i++){
		cout << (char) toupper(s[i]) ;
	}

	return 0;
}

Measured memory_bytes: 1148
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int k = scan.nextInt();
    int a = scan.nextInt();
    int b = scan.nextInt();

    for (int i = a; i <= b; i++) {
      if (i % k == 0) {
        System.out.println("OK");
        return;
      }
    }
    System.out.println("NG");
  }

}

Measured memory_bytes: 35804
using System;

class ABC_136_B
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        int count = 0;
        for (int i = 1; i <= N; i++)
        {
            string s = i.ToString();
            if(s.Length%2==1) count++;
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13140
import Data.List

main = getContents >>= putStr.unlines.intersperse (replicate 20 '#').map (init.unlines.map ((' ':).unwords.map show).(j 10)).j 30.foldl' f (replicate 120 0).map (g.map read.words).tail.lines
    where g [x1,x2,x3,n] = ( (x1-1)*30 + (x2-1)*10 + x3 - 1, (+n) ) 
          f ys (n,p) = take n ys ++ [p (ys!!n)] ++ drop (n+1) ys
          j n [] = []
          j n xs = [take n xs] ++ (j n $ drop n xs)

Measured memory_bytes: 4912
N = int(input())
A  = input().split()
A = [int(x) for x in A]

c = 0 #交換回数
for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if i != minj:
        c +=1
        v = A[i]
        A[i] = A[minj]
        A[minj] = v

A = [str(x) for x in A]
print(" ".join(A))
print(c)


Measured memory_bytes: 5604
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define PER(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)((x).size()))
#define ALL(t) t.begin(),t.end()
#define clr(x) memset(x,0,sizeof(x))
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
template<class T> ostream &operator<<(ostream &os, vector<T> V){ os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]"; } 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) { return os<<"("<<P.fi<<","<<P.se<<")"; }
#define flash ios_base::sync_with_stdio(0);
#define read freopen("1.in","r",stdin);
#define write freopen("1.out","w",stdout);
inline bool EQ(ld a,ld b) {return fabs(a-b)<=(1e-7);}
const ll mod=(1e9+7);
const ld pi=(acos(-1));
//CUT BEGINS

int main() {
	map<int,int> mp;
	vi res; res.pb(0), res.pb(0);
	int n; cin>>n;
	REP(i,1,n) {
		int data; cin>>data; mp[data]++; if(mp[data]%2==0) res.pb(data);
	}
	sort(ALL(res));
	cout<<1LL*res[SZ(res)-1]*res[SZ(res)-2];
	return 0;
}

Measured memory_bytes: 4992