akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	scanInit()

	k := nextInt()
	sum := 0
	for i := 1; i <= k; i++ {
		for j := 1; j <= k; j++ {
			for m := 1; m <= k; m++ {
				tmp := gcd(i, j)
				sum += gcd(tmp, m)
			}
		}
	}

	fmt.Println(sum)

}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1800
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d;
   cin>>a>>b;
   c=b/a;
   d=b%a;
   if(a>=b){
       cout<<"1"<<endl;
   }
   else if(a<b&&d==0){
       cout<<c<<endl;
   }
   else{
       cout<<c+1<<endl;
   }
   }
 


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

int main(void){
    int k,q;
    cin >>k >> q;
    
    for(int i=q-k+1;i<k+q;i++){
        cout << i <<endl;
    }
    
    return 0;
}



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

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

    int res = 0;
    for (int i = 0; i < n - 2; ++i) {
        int p1 = p[i], p2 = p[i + 1], p3 = p[i + 2];

        if (p1 < p2 && p2 < p3) {
            res++;
            continue;
        }

        if (p3 < p2 && p2 < p1) {
            res++;
            continue;
        }

        if (p1 == p2 && p2 < p3) {
            res++;
            continue;
        }

        if (p3 == p2 && p2 < p1) {
            res++;
            continue;
        }
    }

    cout << res << endl;
    return 0;
}

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

const int MOD = 1e9 + 7;

struct Matrix {
	ll v[50][50];
	Matrix() {
		for (int i = 0; i < 50; i++)
			for (int j = 0; j < 50; j++)
				v[i][j] = 0;
	}
};

ll N, K;
Matrix A, I;

Matrix operator*(const Matrix& a, const Matrix& b) {
	Matrix ret;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++) {
				ret.v[i][j] += a.v[i][k] * b.v[k][j] % MOD;
				ret.v[i][j] %= MOD;
			}
	return ret;
}

Matrix pow(Matrix a, ll b) {
	if (b == 0) return I;
	if (b & 1) return a * pow(a, b - 1);
	Matrix ret = pow(a, b / 2);
	return ret * ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			cin >> A.v[i][j];
	for (int i = 0; i < N; i++) I.v[i][i] = 1;

	Matrix Ak = pow(A, K);
	ll ans = 0;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++) {
			ans += Ak.v[i][j];
			ans %= MOD;
		}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
using namespace std;
main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a>b)swap(a,c);
  if(b>c)swap(b,c);
  if(a>b)swap(a,b);
  cout<<a<<" "<<b<<" "<<c<<endl;
}
    

Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int H,W;
char field[110][110];
map<char,int> dx;
map<char,int> dy;

void make(){
  dx['^'] = 0;  dy['^'] = -1;
  dx['v'] = 0;  dy['v'] = 1;
  dx['>'] = 1;  dy['>'] = 0;
  dx['<'] = -1; dy['<'] = 0;
}

pair<int,int> func(int i, int j){
  if(field[i][j] == '.') return make_pair(i,j);
  int cnt = 0;

  while(1){
    if(i < 0 || j < 0 || i >= H || j >= W) continue;
    cnt++;
    i += dy[field[i][j]];
    j += dx[field[i][j]];
    if(field[i][j] == '.') return make_pair(i,j);
    if(cnt > 10000) break;
  }

  return make_pair(-1,-1);
}

int main(){
  int i,j,k;

  make();
  for(; ~scanf("%d %d",&H,&W); ){
    if(H == 0 && W == 0) break;

    rep(i,H) scanf("%s",&field[i]);

    pair<int,int> res = func(0,0), out(-1,-1);
    if(res == out) puts("LOOP");
    else printf("%d %d\n",res.second,res.first);
  }

  return 0;
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int i;
    int max = 0;
    for(i = 1;i < n;++i){
        if(s.at(i) == 'W'){
            ++max;
        }
    }
    int temp = max;
    for(i = 1;i < n;++i){
        if(s.at(i-1) == 'E'){
            ++temp;
        }
        if(s.at(i) == 'W'){
            --temp;
        }
        if(temp > max){
            max = temp;
        }
    }
    cout << n-1-max << endl;
    return 0;
}

Measured memory_bytes: 900
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

signed main()
{
    string s; cin >> s;
    int n = s.size();
    if (s[n - 1] == 's') {
        cout << s << "es\n";
    } else {
        cout << s << "s\n";
    }
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
bool echeck(ll a) { return a % 2 == 0 ? 1 : 0; }
ll comb(ll n, ll m){
  ll tmp = 1;
  for(int i = n; i >= n - m + 1; i--){
    tmp *= i;
  }
  ll temp = 1;
  for(int i = 1; i <= m; i++){
    temp *= i;
  }
  return tmp / temp;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  int tmp;
  set<int>s;
  rep(i,n){
    cin >> tmp;
    s.insert(tmp);
  }
  cout << s.size() << endl;
  return 0;
} 


Measured memory_bytes: 7780
#include <iostream>
#include <set>
#include <cmath>
#define ll long long
using namespace std;
set<ll> sr,sb,sg;
int main(){
	int n; cin>>n;
	getchar();
	for(ll i=1;i<=n;i++){
		char c; c=getchar();
		if(c=='R') sr.insert(i);
		else if(c=='B') sb.insert(i);
		else sg.insert(i);
		//cout<<sr.size()<<sb.size()<<sg.size()<<endl;;
	}  //储存对应字符的位置
	ll ans=sr.size()*sb.size()*sg.size();
	
//	cout<<ans<<endl;
	for(auto it1=sr.begin();it1!=sr.end();it1++)
		for(auto it2=sb.begin();it2!=sb.end();it2++){
			int a=min(*it1,*it2),b=max(*it1,*it2);
			if(sg.find(2*b-a)!=sg.end()) ans--;
			if((a+b)%2==0&&sg.find((a+b)/2)!=sg.end()) ans--;
			if(sg.find(2*a-b)!=sg.end()) ans--;		//对应i,j,k不满足第二个条件的三种情况 
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3724
import itertools

h, w, k = map(int, input().split())
c = []
for i in range(h):
    c.append(list(input()))

del_row = lambda items, del_indexes: [
    item for index, item in enumerate(items) if index not in del_indexes
]

total = 0

for i in range(h):
    for j in range(w):
        for ic in itertools.combinations(range(h), i):
            for jc in itertools.combinations(range(w), j):
                if k == sum(
                    del_row(c[ii], jc).count("#") for ii in set(ic) ^ set(range(h))
                ):
                    total += 1

print(total)

Measured memory_bytes: 9044
#include<stdio.h>

int main () {

   int n, i, flag, swap;
   int a[100] = {0};
   int count = 0;

   scanf("%d", &n);

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

   flag = 1;

   while(flag){
      flag = 0;

      for(i = n-1; i > 0; i--){
         if(a[i] < a[i-1]){
            swap = a[i];
            a[i] = a[i-1];
            a[i-1] = swap;
            flag = 1;
            count++;
         }
      }
   }

   for(i = 0; i < n; i++){
      if(i == n-1){
         printf("%d\n",a[i]);
      } else {
         printf("%d ", a[i]);
      }
   }

   printf("%d\n", count);

   return 0;

}

     

Measured memory_bytes: 1852
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
	double p = scan.nextDouble();
double x = Math.PI * 2 * p;
double z = Math.PI * (p *p);
	System.out.printf("%f %f", z, x);
}
}



Measured memory_bytes: 28400
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

using ll = long long;
using ldb = long double;

#define forn(i, x, n) for (int i = x; i < (int)(n); ++i)
#define forcin(a, n) for (int i = 0; i < n; cin >> a[i], ++i)
#define forb(i, x, n) for (int i = (int)(x); i >= n; --i)
#define mmax(a, b, c) max(a, max(b, c))
#define mmin(a, b, c) min(a, min(b, c))
#define pb push_back
#define mp make_pair

const int N = 100500 * 3;
const long double eps = 1e-11;

set<int> s;

int main() {
    int n;
    cin >> n;
    forn(i, 0, n) {
        int num;
        cin >> num;
        s.insert(num);
    }
    cout << s.size();
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

int main() {
    int n, k;
    cin >> n >> k;

    vector<ll> p(n), c(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i, n) cin >> c[i];

    ll ans = -1e11;
    ll temp;
    int itr;
    rep(i, n) {
        temp = -1e11;
        itr = i;
        vector<ll> score(n, 0), step(n, 0);

        rep(j, n+1) {
            if (step[p[itr]] == 0) {
                step[p[itr]] = j+1;
                score[p[itr]] = score[itr] + c[p[itr]];
                temp = max(temp, score[p[itr]]);
                itr = p[itr];
            }
            else {
                if (score[itr] + c[p[itr]] < score[p[itr]]) ans = max(ans, temp);
                else {
                    ll x = (k-j-1) / (j+1-step[p[itr]]);
                    ll rate = score[itr] + c[p[itr]] - score[p[itr]];
                    temp = score[p[itr]] + rate*x;
                    int th = k - j-1 - ((x-1)*(j+1-step[p[itr]]));
                    ll now = temp;
                    itr = p[itr];
                    for (int _=0; _<th; _++) {
                        now += c[p[itr]];
                        temp = max(temp, now);
                        itr = p[itr];
                    }
                    ans = max(ans, temp);
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3776
N = int(input())
A = [int(input()) for _ in range(N)]

SA = sorted(A, reverse=True)
max_1A = SA[0]
max_2A = SA[1]

for i in range(N):
  if A[i] == max_1A:
    print(max_2A)
  else:
    print(max_1A)

Measured memory_bytes: 14088
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  string s,t; cin >> s >> t;
  rep(i, n){
    if(s[i] == t[0]){
      int j = 0;
      while (i + j < n && s[i+j] == t[j]) {
        j++;
      }
      if(i+j == n){
        std::cout << n + i << '\n';
        return 0;
      }
    }
  }

  std::cout << 2*n << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


int main(){fastio
    ll h,w;cin>>h>>w;
    string s;
    rep(i,0,h-1){
        rep(j,0,w-1){
            cin>>s;
            if(s=="snuke"){
                cout<<(char)('A'+j)<<i+1<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
A = list(map(int, input().split()))
A.sort()
DifA = A[2] - A[1]
DifB = A[2] - A[0]
#print(DifA,DifB)
if DifA % 2 == 0 and DifB % 2 == 0:
    ans = ( DifA + DifB ) // 2
elif DifA % 2 == 1 and DifB % 2 == 1:
    ans = ( DifA + DifB ) // 2
else:
    ans = ( DifA + DifB + 3 ) // 2
print(ans)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll N;
    cin >> N;
    VL a(N);
    rep(i,0,N)cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=a[a.size()-1]-a[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long ans = (x / 11) * 2;
        x = x % 11;
        if(x > 0 && x <= 6) ans++;
        else if(x > 6) ans += 2;
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
N = int(input())
S = input()
S_uniquie = ''.join(set(S))
answer = 0
for left_s in S_uniquie:
    for i in range(N):
        if S[i] == left_s:
            left_pos = i
            break
    for right_s in S_uniquie:
        for i in range(N - 1, -1, -1):
            if S[i] == right_s:
                right_pos = i
                if left_pos + 2 <= right_pos:
                    answer += len(''.join(set(S[left_pos + 1:right_pos])))
                break

print(answer)


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

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 正整数(1 <= N <= 10^9)
    """
    # 求解処理
    ans = N
    if ans % 2 != 0:
        ans *= 2

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)


Measured memory_bytes: 9116
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    int n;
    cin >> n;
    string s[n];
    int a[n];
    string t;
    rep(i,0,n)cin >> s[i] >> a[i];
    cin >> t;
    ll ans = 0;
    int i =0;
    while(s[i] != t)i++;
    i++;
    while(i < n){
	ans += a[i];
	i++;
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N],b[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int n;long long sum=0;
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<b[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 5140
import sys
K, N = map(int, sys.stdin.readline().split())
A = sorted(list(map(int, sys.stdin.readline().split())))
ans = K
A.append(K + A[0])

for i in range(N):
    d = A[i + 1] - A[i]
    dist = K - d
    ans = min(ans, dist)
print(ans)

Measured memory_bytes: 25880
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main(){
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    rep(i,n){
        ll x;
        cin >> x;
        ans+=min(abs(x),abs(k-x));
    }
    cout << 2*ans << endl;
}

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

ll res = 0;

class segment_manager { // [l, r)
	map<ll, ll> pos;
	void add(ll l, ll r) {
		if (l == r) return;
		pos[l] = r;
        
        res += r - l;
	}
	void del(ll l) {
        res -= pos[l] - l;
        
		pos.erase(l);
	}
public:
	void add_range(ll l, ll r) {
		auto it = pos.lower_bound(l);
		if (it != pos.begin() && l <= prev(it)->second) --it, l = it->first;
		while (it != pos.end() && it->first <= r) {
			r = max(r, it->second);
			auto tmp = it++;
			del(tmp->first);
		}
		add(l, r);
	}
	void del_range(ll l, ll r) {
		auto it = pos.lower_bound(l);
		if (it != pos.begin() && l < prev(it)->second) {
			auto tmp = prev(it);
			ll tl = tmp->first, tr = tmp->second;
			if (r <= tr) del(tl), add(tl, l), add(r, tr);
			else del(tl), add(tl, l);
		}
		while (it != pos.end() && it->first < r) {
			auto tmp = it; ++it;
			if (r < tmp->second) {
				ll rr = tmp->second;
				del(tmp->first), add(r, rr);
			}
			else del(tmp->first);
		}
	}
	bool contain_all(ll l, ll r) {
		auto it = pos.upper_bound(l);
		return it != pos.begin() && r <= prev(it)->second;
	}
	bool contain_one(ll l, ll r) {
		auto it = pos.lower_bound(l);
		if (it != pos.end() && it->first < r) return true;
		if (it != pos.begin() && l < prev(it)->second) return true;
		return false;
	}
};

signed main()
{
    ll N, X, D;
    cin >> N >> X >> D; X *= 2, D *= 2;
    if(X == 0 && D == 0){
        cout << 1 << endl;
        return 0;
    }
    if(D == 0){
        cout << N + 1 << endl;
        return 0;
    }
    if(D < 0){
        D = -D;
        X = -X;
    }
    vector<ll> vs(N), sum(N + 1);
    for(int i = 0;i < N;i++){
        vs[i] = X + D * i;
        sum[i + 1] = sum[i] + vs[i];
    }
    unordered_map<ll, segment_manager> sts;
    for(int i = 0;i <= N;i++){
        ll of = (sum[i] % D + D) % D;
        ll x = (sum[i] - of) / D, y = (sum[N] - sum[N - i] + D - of) / D;
        sts[of].add_range(x, y);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 33480
# from https://atcoder.jp/contests/abc132/submissions/6187293

def main():
    N, K = map(int, input().split())

    MOD = 10 ** 9 + 7
    r = int(N ** 0.5 + 1)
    z = [i for i in range(r)] + [N // i for i in range(1, r)][::-1]
    m = len(z)
    pre = [0] + [1] * (m - 1)
    for _ in range(1, K+1):
        dp = [0] * m
        for i in range(1, m):
            dp[i] = (dp[i-1] + pre[m-i] * (z[i] - z[i-1])) % MOD
        pre = dp
    print(dp[-1])


main()

Measured memory_bytes: 90240
import java.util.*;
public class Main {
    static class Node{
        List<Integer> to;
        Node(){
            to = new ArrayList<Integer>();
        }
    }
    static public class IntPair{
        int x, y;
        public IntPair(int xx, int yy){
            x = xx;
            y = yy;
        }
        @Override
        public int hashCode(){
            Long temp = new Long(x);
            temp <<= 31;
            temp += y;
            return temp.hashCode();
        }
        @Override
        public boolean equals(Object o){
            if(!(o instanceof IntPair)){
                return false;
            }
            IntPair temp = (IntPair) o;
            return x == temp.x && y == temp.y;
        }
    }
    static Node g[];
    static int ans[];
    static Map<IntPair, Integer> mp;
    public static void dfs(int s, int p, int c){
        if(p != -1){
            ans[mp.get(new IntPair(s, p))] = c;
        }
        int now = 1;
        for(Integer x : g[s].to){
            if(x == p)continue;
            if(now == c)now++;
            dfs(x, s, now++);
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        g = new Node[n];
        ans = new int[n - 1];
        mp = new HashMap<>();
        for(int i = 0; i < n; i++){
            g[i] = new Node();
        }
        for(int i = 0; i < n - 1; i++){
            Integer a = sc.nextInt() - 1;
            Integer b = sc.nextInt() - 1;
            g[a].to.add(b);
            g[b].to.add(a);
            mp.put(new IntPair(a, b), i);
            mp.put(new IntPair(b, a), i);
        }
        dfs(0, -1, 10000000);
        int mx = -1;
        for(int i : ans){
            mx = Math.max(mx, i);
        }
        System.out.println(mx);
        for(int i : ans){
            System.out.println(i);
        }
    }
}



Measured memory_bytes: 115732
#include<iostream>
using namespace std;
const int MAX = 100;
const int INF = 20000;
int n, G[MAX][MAX], dis[MAX];
bool book[MAX] = { false };
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> G[i][j];
	for (int i = 0; i < n; i++)
		dis[i] = G[0][i];
	book[0] = true;
	int sum = 0;
	for (int k = 1; k <= n - 1; k++)
	{
		int min = INF;
		int u;
		for (int j = 0; j < n; j++)
			if (!book[j] && dis[j] != -1 && dis[j] < min)
			{
				min = dis[j];
				u = j;
			}
		book[u] = true;
		sum += dis[u];
		for (int v = 0; v < n; v++)
			if (!book[v] && G[u][v] != -1)
				if (dis[v] == -1)
					dis[v] = G[u][v];
				else
					if (dis[v] > G[u][v])
						dis[v] = G[u][v];
	}
	cout << sum << endl;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int main() {
	int x;
	scanf("%d", &x);
	printf("%d\n", !x);
	return 0;
}


Measured memory_bytes: 3772
#include <stdio.h>
long long p = 1000000007;
long long n, m, x;
int main() {
	scanf("%lld%lld", &n, &m);
	if (n > m) {
		x = n;
		n = m;
		m = x;
	}
	if (n + 1 < m) {
		printf("0\n");
		return 0;
	}
	x = 1;
	if (n == m)x = 2;
	for (long long i = 1; i <= n; i++) {
		x *= i;
		x %= p;
	}
	for (long long i = 1; i <= m; i++) {
		x *= i;
		x %= p;
	}
	printf("%lld\n", x);
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int n;
  string ans;
  
  cin >> n;
  
  n %= 10;
  if(n==0 || n==1 || n==6 || n==8)
    ans = "pon";
  else if(n==3)
    ans = "bon";
  else
    ans = "hon";
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
import functools
@functools.lru_cache(maxsize=30)
def f(n):
  if n==1:
    return 1
  elif n==2:
    return 2
  elif n==3:
    return 4
  else:
    return f(n-1)+f(n-2)+f(n-3)
while True:
  n=int(input())
  if n==0:
    break
  if n<=10:
    print("1")
  else:
    if f(n)%10==0:
      if (f(n)//10)%365==0:
        print((f(n)//10)//365)
      else:
        print(((f(n)//10)//365)+1)
    else:
      if ((f(n)+1)//10)%365==0:
        print(((f(n)+1)//10)//365)
      else:
        print((((f(n)+1)//10)//365)+1)
    


Measured memory_bytes: 6280
#include <stdio.h>

int a[1000];
int tmp[1000];

int main(void)
{
	int n, q, i, b, m, e;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d%d", &b, &m, &e);
		for (i = b; i < e; i++) {
			tmp[i] = a[i];
		}
		e -= b;
		m -= b;
		for (i = 0; i < e; i++) {
			a[b + i] = tmp[b + (i + m) % e];
		}
	}
	for (i = 0; i < n; i++) {
		printf("%d%c", a[i], " \n"[i + 1 == n]);
	}
	return 0;
}



Measured memory_bytes: 2104
def inpl(): return [int(i) for i in input().split()]
mod = 10**9+7

n, m = inpl()
x = inpl()
y = inpl()
H = [(x[i+1]-x[i])*(i+1)*(n-i-1) % mod for i in range(n-1)]
W = [(y[j+1]-y[j])*(j+1)*(m-j-1) % mod for j in range(m-1)]

print(sum(H)*sum(W) % mod)

Measured memory_bytes: 19648
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int> >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int ans;

int printAns() {
    cout << ans << endl;
    return 0;
}


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int K, a, b;
    cin >> K;
    a = (K + K % 2) / 2;
    b = (K - K % 2) / 2;
    cout << a * b;
    return 0;
}


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

int main(){
  ll N, K, d, i, j, count = 0, A;
  
  cin >> N >> K;
  vector<ll> list(N, 0);
  rep(i, K){
    cin >> d;
    rep(j, d){
      cin >> A;
      list[A - 1]++;
    }
  }
  
  rep(i, N){
    if(list[i] == 0){
      count++;
    }
  }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    string s, t;
	cin >> s >> t;
	int ans = mod;
	int a = s.size(), b = t.size();
	rep(i, a-b+1){
		int now = 0;
		rep(j, b){
			if(s[i+j] != t[j])now++;
		}
		chmin(ans, now);
	}
	cout << ans << endl;
} 


Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val r = readLine()?.toDouble() ?: return
    println(String.format("%1$.6f %2$.6f", calcArea(r), calcCircumference(r)))
}

fun calcArea(r: Double) : Double {
    return r * r * Math.PI
}

fun calcCircumference(r: Double) : Double {
    return 2 * r * Math.PI
}


Measured memory_bytes: 26424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

bool isOrder(string s){
  int n = s.size();
  rep(i,n){
    if(s[i]<=s[i+1]){
      return 0;
    }
  }
  return 1;
}

int main(){
  
  string s;
  cin >> s;
  int n = s.size();
  
  string chars = "abcdefghijklmnopqrstuvwxyz";
  set<char> check;
  for(char c : s) check.insert(c);
  
  if(n<26){
    char next = 'a';
    while(check.count(next)>0){
      next ++;
    }
    cout << s << next << endl;
    return 0;
  }
  
  for(int i=n-1;i>=0;i--){
    string sub = s.substr(i,n-i);
    if(isOrder(sub)) continue;
    check = {};
    for(int j=0;j<i+1;j++){
      check.insert(s[j]);
      if(j==i){
        char next = s[j];
        while(check.count(next)>0){
          next ++;
        }
        cout << next << endl;
        return 0;
      }
      cout << s[j];
    }
  }
  
  cout << -1 << endl;
  return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

class Cube {
   public:
    int f[6];  //サイコロ
    Cube() {}  //コンストラクタ
    void roll_z() { roll(1, 2, 4, 3); }
    void roll_y() { roll(0, 2, 5, 3); }  // to W
    void roll_x() { roll(0, 1, 5, 4); }  // to N
    void roll(int i, int j, int k, int l) {
        int t = f[i];
        f[i]  = f[j];
        f[j]  = f[k];
        f[k]  = f[l];
        f[l]  = t;
    }
    void move(char ch) {
        if (ch == 'E')
            for (int i = 0; i < 3; i++) roll_y();  // Wを３回
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S')
            for (int i = 0; i < 3; i++) roll_x();  // Nを３回
    }
};

int getRight(Cube c1, int top, int front) {
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 4; j++) {
            if (c1.f[0] == top && c1.f[1] == front) return c1.f[2];
            c1.roll_z();
        }
        if (i % 2 == 0)
            c1.roll_y();
        else
            c1.roll_x();
    }
    return -1;
}

bool judgeSame(Cube c1, Cube c2) {
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 4; j++) {
            if (c1.f[0] == c2.f[0] && c1.f[1] == c2.f[1] &&
                c1.f[2] == c2.f[2] && c1.f[3] == c2.f[3] &&
                c1.f[4] == c2.f[4] && c1.f[5] == c2.f[5]) {
                return true;
            }
            c1.roll_z();
        }
        if (i % 2 == 0)
            c1.roll_y();
        else
            c1.roll_x();
    }
    return false;
}
int main() {
    Cube c[100];  // サイコロ

    // 入力
    int N;
    cin >> N;

    rep(k, N) {
        for (int i = 0; i < 6; i++) cin >> c[k].f[i];  // サイコロ 1
    }

    bool judge =
        true;  //成功することが前提でtrueをセットする。（関数化したほうがいい）
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {  // iのぶんの判断は終わっているのでi+1
            if (judgeSame(c[i], c[j])) {
                judge = false;  // 同じのが見つかったときだけfalseにセットする。
            }
        }
    }

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

    return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>
#define N 100
int main()
{
  int i,j,m,k=0,n,A[N],count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  for(i=0;i<n;i++){
    m=i;
    for(j=i;j<n;j++){
      if(A[j]<A[m]){
	m=j;
      }
    }
    k=A[i];
    A[i]=A[m];
    A[m]=k;
    if(i!=m)count++;
  }
  for(i=0;i<n-1;i++)
    printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7

N, K = lr()
floor = (K-1) * (K-2) // 2
limit = (N+(N-K+2)) * (K-1) // 2
answer = 0
for x in range(K, N+2):
    floor += (x-1)
    limit += N-x+1
    answer += limit - floor + 1

print(answer % MOD)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

bool chk(string S) {
	bool ret = true;
	if (S.size() == 4) {
		if (S[0] == 'A' && S[1] == 'G' && S[3] == 'C') ret = false;
		if (S[0] == 'A' && S[2] == 'G' && S[3] == 'C') ret = false;
		if (S[1] == 'A' && S[2] == 'G' && S[3] == 'C') ret = false;
		if (S[2] == 'A' && S[1] == 'G' && S[3] == 'C') ret = false;
		if (S[1] == 'A' && S[3] == 'G' && S[2] == 'C') ret = false;
	}
	if (S.size() == 3) {
		if (S[0] == 'A' && S[1] == 'G' && S[2] == 'C') ret = false;
		if (S[1] == 'A' && S[0] == 'G' && S[2] == 'C') ret = false;
		if (S[0] == 'A' && S[2] == 'G' && S[1] == 'C') ret = false;
	}
	return ret;
}

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


	int N;
	cin >> N;

	ll mod = 1e9 + 7;
	ll goukei = 1;
	rep(i, N) goukei = goukei * 4 % mod;

	map<string, ll> dp[101];
	dp[0][""] = 1;

	rep(i, N) {
		for (auto P : dp[i]) {
			string S = P.first;
			ll k = P.second;
			string kari = S + 'A';
			if (chk(kari)) {
				if(kari.size() == 4) kari.erase(0, 1);
				dp[i + 1][kari] += k;
				dp[i + 1][kari] %= mod;
			}
			kari = S + 'G';
			if (chk(kari)) {
				if (kari.size() == 4) kari.erase(0, 1);
				dp[i + 1][kari] += k;
				dp[i + 1][kari] %= mod;
			}
			kari = S + 'C';
			if (chk(kari)) {
				if (kari.size() == 4) kari.erase(0, 1);
				dp[i + 1][kari] += k;
				dp[i + 1][kari] %= mod;
			}
			kari = S + 'T';
			if (chk(kari)) {
				if (kari.size() == 4) kari.erase(0, 1);
				dp[i + 1][kari] += k;
				dp[i + 1][kari] %= mod;
			}
		};
	}

	ll kotae = 0;
	for (auto P : dp[N]) {
		kotae += P.second;
		kotae %= mod;
	}

	co(kotae);

	Would you please return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#define N 100000
#define Q 50000

int T[Q],S[N];
int n, c;
void BinarySearch(int);

int main() {

  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  for(i=0; i<q; i++) scanf("%d", &T[i]);

  for(i=0; i<q; i++) {
    BinarySearch(T[i]);
  }
  printf("%d\n", c);
  return 0;
}

void BinarySearch(int key){
  int left, right, mid;
  left = 0;
  right = n;
  while(left < right) {
    mid = (left + right) / 2;

    if(S[mid]==key){
      c++;
      break;
    }
    else if(key < S[mid]) right = mid;
    else left = mid + 1;
  }
}

Measured memory_bytes: 1184
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	private static boolean ispf = false;

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] systemInLine = br.readLine().split(" ");
		int provinceCount = Integer.parseInt(systemInLine[0]);
		int cityCount = Integer.parseInt(systemInLine[1]);
		pf("辖区总数:" + provinceCount + " 城市总数:" + cityCount);

		/**
		 * 所有的城市
		 */

		// 城市数组，0：省份，1：年份，2：输入顺序号，4：年份序号
		int[][] proviceCityArray = new int[cityCount][4];

		for (int i = 0; i < cityCount; i++) {
			systemInLine = br.readLine().split(" ");
			int provinceIndex = Integer.parseInt(systemInLine[0]);
			int cityCreateYear = Integer.parseInt(systemInLine[1]);
			proviceCityArray[i][0] = provinceIndex;
			proviceCityArray[i][1] = cityCreateYear;
			proviceCityArray[i][2] = i + 1;
		}
		br.close();

		/**
		 * 这次排序后辖区和年份已经排序了
		 */

		Arrays.sort(proviceCityArray, (o1, o2) -> (o1[0] == o2[0]) ? (o1[1] - o2[1]) : (o1[0] - o2[0]));

		for (int i = 0; i < proviceCityArray.length; i++) {
			if (i == 0) {
				proviceCityArray[i][3] = 1;
			} else {
				if ((proviceCityArray[i][0] == proviceCityArray[i - 1][0])) {// 于上一次比较
					proviceCityArray[i][3] = proviceCityArray[i - 1][3] + 1;
				} else {
					proviceCityArray[i][3] = 1;
				}
			}
		}

		/**
		 * 再次排序拍会回来
		 */
		Arrays.sort(proviceCityArray, (o1, o2) -> o1[2] - o2[2]);
		String[] padding = new String[] { "", "0", "00", "000", "0000", "00000" };
		for (int i = 0; i < proviceCityArray.length; i++) {
			// System.out.println(String.format("%06d",
			// proviceCityArray[i][0])+String.format("%06d", proviceCityArray[i][3]));
			System.out.println(padding[getPadingIndex(proviceCityArray[i][0])] + proviceCityArray[i][0]
					+ padding[getPadingIndex(proviceCityArray[i][3])] + proviceCityArray[i][3]);
		}

	}

	public static void pf(String s) {
		if (ispf) {
			System.out.println(s);
		}
	}

	private static int getPadingIndex(int n) {
	        if (n < 10) {
	        	return 5;
        	}else if (n < 100) {
        		return 4;
        	}else if (n < 1000) {
        		return 3;
        	}else if (n < 10000) {
        		return 2;
        	}else if (n < 100000) { 
        		return 1;
        	}else {
        		return 0;
        	}
	    }
}


Measured memory_bytes: 82196
A, B = gets.chomp.split(' ').map(&:to_i)

i = (A - B)
if (i / 2.0) == (i / 2)
  if A < B
    print A + ((A - B) / 2).abs
  else
    print B + ((A - B) / 2).abs
  end
else
  print 'IMPOSSIBLE'
end


Measured memory_bytes: 1788
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

ll a[maxn];

int main(void) {
    FAST_IO;
    
    int n;
    cin >> n;
    ll ans = 0;
    ll mi = INF;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n, [](const int &x, int const &y) {
        return x > y;
    });
    for (int i = 2; i <= n; i++) {
        ans += a[(i + 1) / 2];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5184
n,m = map(int,input().split())
list1 = [list(map(int,input().split())) for i in range(m) ]
p_list = list(map(int,input().split()))
binary_list = []
switch_count = 0
ans = 0
for i in range(2**n):
	binary_list = list(format(i,"b").zfill(n))
	switch_count = 0
	for j in range(m):
		for k in range(list1[j][0]):
			if binary_list[list1[j][k+1]-1] == "1":
				switch_count += 1
		if (switch_count % 2 == p_list[j]):
			if j == m-1:
				ans += 1
				switch_count = 0
			else:
				switch_count = 0
				continue
		else:
			break

print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<pair<int64_t, int64_t>> ba(n);
    for (auto& e : ba) cin >> e.second >> e.first;

    sort(ba.begin(), ba.end());
    for (int64_t i=1; i<n; i++) ba[i].second += ba[i-1].second;

    cout << (all_of(ba.begin(), ba.end(), [&](auto e){ return e.first >= e.second; }) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
using namespace std;
int main()
{
    double a,b,c;
    while(~scanf("%lf",&a))
    {
        a/=3;
        b=pow(a,3.0);
        printf("%.12lf\n",b);
    }
 }





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

const int Nmax=200010;
 
int main() {
	string s,t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    H, W = [int(item) for item in input().split()]
    grid = [input() for _ in range(H)]

    res = ['' for _ in range(H)]



    def cnt_bomb(i, j):
        cnt = 0        

        for n in [-1, 0, 1]:
            for m in [-1, 0, 1]:
                cnt += chk_bomb(i+n, j+m)

        return str(cnt)


    def chk_bomb(i, j):

        if i < 0 or  H <= i or j < 0 or W <= j:
            return 0
        elif grid[i][j] == '#':
            return 1
        else:
            return 0



    for i in range(H):
        for j in range(W):
            if grid[i][j] == '#':
                res[i] += '#'
            else:
                res[i] += cnt_bomb(i, j)

    for line in res:
        print(line)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 10000000000000
int dp[3001][3001];
int prefix[3001];

int solve(int i, int j) {
    if(i == j) return 0;
    if(dp[i][j] != -1) return dp[i][j];
    int least = inf;
    for(int k=i; k<j; k++) least = min(least, solve(i, k) + solve(k+1, j) + prefix[j] - prefix[i-1]);
    return dp[i][j] = least;
}

int32_t main() {
    int N; cin>>N;
    prefix[0] = 0;
    for(int i=1; i<=N; i++) {
        int tmp; cin>>tmp;
        prefix[i] = prefix[i-1] + tmp;
    }
    memset(dp, -1, sizeof dp);
    cout<<solve(1, N)<<endl;
    return 0;
}


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

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

using namespace std;
using ll = long long;

void solve();

struct RollingHash{
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<ll> hash1, hash2, power1, power2;

    RollingHash(const string &S){
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1); //power1[i] = pow(base1, i)
        power2.assign(n+1, 1);
        for(int i = 0; i < n; i++){
            hash1[i+1] = (hash1[i]*base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i]*base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }

    //S[left:right]のハッシュ値を得る left >= 0, r < N
    inline pair<ll, ll> get(int l, int r) const{
        ll res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if(res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if(res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    inline int getLCP(int a, int b) const{
        int len = min((int) hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while(high - low > 1){
            int mid = (low + high) >> 1;
            if(get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

int main(void){
    int N; cin >> N;
    string s; cin >> s; //英小文字からなる
    RollingHash rh(s);
    int ans = 0;
    for(int i = 0; i <= N; i++){
        for(int j = i+1; j <= N; j++){
            int eval = min(j-i, rh.getLCP(i, j));
            if(eval > ans) ans = eval;
        }
    }
    cout << ans << endl;
    
    return 0;
}

void solve(){}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
    double N,b;
    scanf("%lf",&N);
    if((int)N%2==0){
        b=N/(2*N);
    }
    else{
    b=((int)N+1)/(2*N);
    }
    printf("%.10lf\n",b);
    return 0;
}

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

int main() {
  long int n, a, b, c, d, e, bottle;
  cin >> n >> a >> b >> c >> d >> e;

  bottle = min(min(min(a, b), c), min(d, e));

  if (n == 1)
    cout << 5 << endl;
  else if (n % bottle == 0)
    cout << 5 + (n / bottle) - 1 << endl;
  else
    cout << 5 + (n / bottle) << endl;
}

Measured memory_bytes: 256
H, W = [int(hw) for hw in input().split()]
A = []
for h in range(H):
  a = [a for a in input()]
  if a.count("#") > 0:
    A.append(a)

for w in reversed(range(W)):
  cnt = 0
  for h in range(len(A)):
    if A[h][w] == ".":
      cnt += 1
  if cnt == len(A):
    for h in range(len(A)):
      del A[h][w]

for h in range(len(A)):
  ans = "".join(A[h])
  print(ans)

Measured memory_bytes: 3064