akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace AtCoderABC113
{
    class Location
    {
        public int index;
        public double height;
        public Location(int idx, double h)
        {
            index = idx;
            height = h;
        }
    }
    class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            double T = double.Parse(s[0]);
            double A = double.Parse(s[1]);
            s = Console.ReadLine().Split(' ');
            List<Location> H = new List<Location>();
            for (int i = 0; i < N; i++)
            {
                H.Add(new Location(i + 1, Math.Abs(T - double.Parse(s[i]) * 0.006 - A)));
            }
            H = H.OrderBy(x => x.height).ToList();
            Console.WriteLine(H[0].index);
        }
    }
}

Measured memory_bytes: 13420
n = int(input())
a = list(map(int,input().split()))

hight_sum = 0
for i in range(n-1):
    hight = 0
    diff = a[i+1] - a[i]
    if diff < 0:
        hight -= diff
        a[i+1] -= diff
        hight_sum += hight
print(hight_sum)

Measured memory_bytes: 32044
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int n, l;
string c[1000];

int main()
{
	cin >> n >> l;
	for (register int i = 1; i <= n; i++)
		cin >> c[i];
	sort(c + 1, c + n + 1);
	for (register int i = 1; i <= n; i++) cout << c[i];
}

Measured memory_bytes: 764
#include<iostream>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];
    int c = 0;
    rep(i, n){
        if (p[i] != i + 1) {
            c++;
        }
    }
    if (c > 2) {
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    ans = ['x' for s in S]
    print(''.join(ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main() {
  int n;
  int a[31] = {1, 1, 2};
  for (int i = 3; i < 31; i++)
    a[i] = a[i - 1] + a[i - 2] + a[i - 3];

  while (true) {
    cin >> n;
    if (n == 0) return 0;
    cout << a[n] / 10 / 365 + 1 << endl;
  }
}

Measured memory_bytes: 3072
N, M = map(int, input().split())
ab = sorted(set(map(lambda x: (x[0], x[1]) if x[0] < x[1] else (x[1],x[0]), [list(map(int, input().split())) for _ in range(M)])))

ans = 0
e = 10**6
for m in ab:
    a, b = m
    if e <= a:
        ans += 1
        e = b
    if b < e:
        e = b
print(ans + 1)

Measured memory_bytes: 39244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

vector<ll> num(45,0);

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0) return 1;
    else if(n%2 == 1) return EX(x,n-1)*x;
    else return EX(x*x,n/2);
};

vector<ll> to_k (ll n,ll k){
    vector<ll> memo(45);
    for(ll i = 44; i >= 0; i--){
        ll e = EX(k,i);
        if(e <= n){
            memo[i] = 1;
            n -= e;
        } else memo[i] = 0;
    }
    return memo;
}
vector<ll> x(45);
ll re_k (ll k){
    ll res = 0;
    for(ll i = 0; i < 45; i++){
        res += x[i]*EX(k,i);
    }
    return res;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        vector<ll> vlu = to_k(a[i],2);
        for(ll j = 0; j < 45; j++){
            if(vlu[j] == 1) num[j]++;
        }
    }
    for(ll i = 0; i < 45; i++){
        if(num[i] <= n/2) x[i] = 1;
        else x[i] = 0;
    }
    vector<ll> kd = to_k(k,2);
    bool flag = true;
    for(int i = 44; i >= 0; i--){
        if(flag && kd[i] == 1) flag = false;
        if(kd[i] == 1 && x[i] == 0) break;
        else if(kd[i] == 0 || flag) x[i] = 0;
        
    }
    ll X = re_k(2);
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += X^a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,f[100009],bo[100009];
vector <int> v[100009];
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    for(i=1; i<=a; i++) cin>>f[i];
    for(i=1; i<=b; i++){
        cin>>c>>d;
        v[c].push_back(d);
        v[d].push_back(c);
    }
    for(i=1; i<=a; i++){
        d=0;
        for(int h=0; h<v[i].size(); h++){
            if(f[i]<=f[v[i][h]]){
                d=1;
                break;
            }
        }
        if(d==0){
            e++;
        }
    }
    cout<<e;
    return 0;
}

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

int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	int i;
	int n=0;
	cin >> a;
	cin >> b;
	cin >> c;
	for (i = a; i < b + 1; i++) {
		if (c % i == 0) {
			n += 1;
		}
	}
	cout << n << endl;
}


Measured memory_bytes: 3080
n, q = map(int, input().split())
task = []
for _ in range(n):
    s = input().split()
    task.append([s[0], int(s[1])])
    
ans = 0
while len(task):
    t = task.pop(0)
    if t[1] - q <= 0:
        ans += t[1]
        print(t[0], ans)
    else:
        ans += q
        task.append([t[0], t[1]-q])


Measured memory_bytes: 13016
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int q,a,b,c;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>a>>b>>c;
        int cou=0;
        while(a>0&&b>0&&c>0){
            a--;
            b--;
            c--;
            cou++;
        }
        while(a>1&&b>0){
            a=a-2;
            b--;
            cou++;
        }
        while(a>2){
            a=a-3;
            cou++;
        }    
        cout<<cou<<endl;
    }
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int p[6000],c[6000];
int par[30][6000];
ll dp[30][6000],dp2[30][6000];

int main(){
	int n,K;cin>>n>>K;
	rep(i,n)scanf("%d",&p[i]),p[i]--;
	rep(i,n)scanf("%d",&c[i]);
	rep(i,30)rep(j,n)dp[i][j]=-INFL;
	rep(i,n){
		dp[0][i]=dp2[0][i]=c[p[i]];
		par[0][i]=p[i];
	}
	for(int i=1;i<30;i++)rep(j,n){
		par[i][j]=par[i-1][par[i-1][j]];
		dp2[i][j]=dp2[i-1][j]+dp2[i-1][par[i-1][j]];
		dp[i][j]=max(dp[i-1][j],dp2[i-1][j]+dp[i-1][par[i-1][j]]);
	}
	ll Max=-INFL;
	rep(i,n){
		int pos=i;
		ll score=0;
		rep(j,30){
			if(K>>j&1){
				Max=max(Max,score+dp[j][pos]);
				score+=dp2[j][pos];
				pos=par[j][pos];
			}
		}
	}
	cout<<Max<<endl;
}

Measured memory_bytes: 7044
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main(){
  stack<int> s;
  int x;
  
  while(cin>>x){
    if(x==0){
      cout<<s.top()<<endl;
      s.pop();
    }
    else{
      s.push(x);
    }
  }
  
  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,p,x,sum=0;
    vector <int>t(110);
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>t.at(i);
        sum+=t.at(i);
    }
    cin>>m;
    for (int j=0;j<m;j++){
    cin>>p>>x;
    cout<<sum+x-t.at(p-1)<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100005

int head, tail;

typedef struct {
    char name[15];
    int time;
} P;

P Q[MAX+1];

void initialize(void){
    head = tail = 0;
}

int isFull(void){
    return head == (tail + 1) % MAX;
}

int isEmpty(void){
    return head == tail;
}

int enqueue(P x){
    if (isFull()){
        printf("Overflow\n");
        exit(1);
    }else{
        Q[tail] = x;
        tail = (tail + 1) % MAX;
        return 1; 
    }
}

P dequeue(void){
    if (isEmpty()){
        printf("Underflow\n");
        exit(1);
    }else{
        P x = Q[head];
        head = (head + 1) % MAX;
        return x;
    }
}

void rrs(int n, int quantum){
    P finished, tmp;
    int fincnt = 0;
    int now = 0;
    while (fincnt < n){
        now += (Q[head].time - quantum > 0)?(quantum):(Q[head].time);
        Q[head].time = (Q[head].time - quantum > 0)?(Q[head].time - quantum):(0);
        if (Q[head].time == 0){
            finished = dequeue();
            printf("%s %d\n", finished.name, now);
            fincnt++;
        }else{
            tmp = dequeue();
            enqueue(tmp);
        }
    }

}

int main(void){
    int n;
    int quantum;
    int i;
    P tmp;

    initialize();
    
    scanf("%d %d", &n, &quantum);
    for (i = 0; i < n; i++){
        scanf(" %s %d", tmp.name, &tmp.time);
        enqueue(tmp);
    }
    rrs(n, quantum);
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, T;
	int aux1, aux2, aux3,indice, menor = 1001;
	cin >> N;
	cin >> T;
	bool valided= true;
	vector<pair<int, int>>number;
	for (int i = 0; i < N; i++) {
		pair<int, int>aux;
		cin >> aux1;
		cin >> aux2;
		aux.first = aux1;
		aux.second = aux2;
		number.push_back(aux);
	}
	for (int j = 0; j < N; j++) {
		for (int k = 0; k < number.size(); k++) {
			if (number[k].first < menor) {
				aux3 = number[k].first;
				menor = aux3;
				indice = k;
			}
		}
		if (number[indice].second <= T){
			valided = false;
			break;
	}
		else number.erase(number.begin() + indice);
		menor = 1001;
	}
	if (valided == false)
		cout << number[indice].first << endl;
	else
		cout << "TLE" << endl;
	return(0);
}

Measured memory_bytes: 256
import itertools
import math
N = int(input())
ls, val = [], 0
perm = itertools.permutations(range(N))
for i in range(N):
    x, y = map(int, input().split(' '))
    ls.append([x, y])
for i in perm:
    for j in range(N - 1):
        val += math.sqrt((ls[i[j + 1]][0] - ls[i[j]][0]) ** 2 + (ls[i[j + 1]][1] - ls[i[j]][1]) ** 2)
print(val / math.factorial(N))

Measured memory_bytes: 9108
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	string s, t;
	cin >> s >> t;
	bool tf = true;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])tf = false;
	}
	if (tf)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

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

#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   /*
   ull N,K;
   cin>>N>>K;
   vector<ull>A(N);
   for(ll i=0;i<N;i++)cin>>A[i];
   sort(rrng(A));
   ull K_ = max(K,A[0]);
   ull r=0;
   while(K_>1){
      K_/=2;
      r++;
   }
   vector<ull>memo(r+1);
   for(ll i=r;i>=0;i--){
      ll sum=0;
      for(ll j=0;j<N;j++){
        if(1&(A[j]>>i))sum++;
      }
      memo[i]=sum;
   }
   ull ans = 0;
   ull num = 0;
   for(ll i=r;i>=0;i--){
      if(2*memo[i]<N){
         if(num+pow(2,i)<=K){
            ans+=pow(2,i)*(N-memo[i]);
            num+=pow(2,i);
         }
         else{
            ans+=pow(2,i)*memo[i];
         }
      }
      else{
         ans+=pow(2,i)*memo[i];
      }
   }
   cout<<ans<<endl;
   */
   int N,M;
   cin>>N>>M;
   vector<int>X(M);
   for(int i=0;i<M;i++)cin>>X[i];
   sort(rng(X));
   vector<int>lines(M-1);
   for(int i=0;i<M-1;i++){
      lines[i]=X[i+1]-X[i];
   }
   ll ans=0;
   sort(rng(lines));
   for(int i=0;i<M-N;i++){
      ans+=lines[i];
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1024
from math import factorial
n = int(input())
a = [int(i) for i in input().split()]
sa = sorted(a,reverse=True)
m = sa[0]
sb = sa[1:]
k = [i if m - i > i else m - i for i in sb]
i = k.index(max(k))
print(m, sb[i])


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s, t;
    cin>> s>> t;

    int c=0;

    for(int i=0; i<s.size(); i++)
    {
        if(s[i]== t[i])
            c++;
    }

    cout << c;
    nl;
    return 0;
}




Measured memory_bytes: 3608
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

d, g = nm()
pc = [nl() for _ in range(d)]
costs = []
for i in range(2**d):
    binary = '0'*(d-len(bin(i)[2:])) + bin(i)[2:]
    #print(binary)
    point = 0
    num = 0
    remain = [100 * len(pc), 0]
    for j, digit in enumerate(binary):
        if digit == '1':
            point += 100 * (j + 1) * pc[j][0] + pc[j][1]
            num += pc[j][0]
        if digit == '0':
            remain = [100 * (j + 1), pc[j][0]]
    if point < g:
        num += math.ceil(min((g - point) / remain[0], remain[1]))
        point = point + min(g - point, remain[0] * remain[1])
    costs.append([point, num, binary])
    #print(binary, [point, num], remain)
costs.sort(key=lambda x: (x[1], x[0]))
#print(costs)
for value in costs:
    if value[0] >= g:
        print(value[1])
        exit()


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

int main(){
  
  int P,Q,R;
  int min =0;
  int a,b,c;
  
  cin >> a>> b>>c;
  
  
  
  if((a>=b) && (a>=c)){
    min = b+c;
  }else if((b>=a) && (b>=c)){
    min = a+c;
  }else if((c>=a) && (c>=b)){
    min = a+b;
  }
  
  cout << min << endl;
  
  
  
  
  
  
}


Measured memory_bytes: 256
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
fn main() {
    let s = str2vec(&input_line_str());
    let s = s[0];
    if s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o' {
        p("vowel");
    } else {
        p("consonant");
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  int K;
  int Q;
  cin >> N >> K >> Q;
  
  int num = Q - K + 1;
  int num2;
  
  vector<int> A(Q);
  
  for(int i = 0;i < Q;++i){
    cin >> A[i];
  }
  
  vector<int> B(N);
  
  if(Q - K < 0){
    for(int i = 0;i < N;++i){
      cout << "Yes" << endl;
    }
  }
  else{
    for(int j = 0;j < Q;++j){
      num2 = A[j] - 1;
     
      B[num2] = B[num2] + 1;
    }
    for(int i = 0;i < N;++i){
      if(B[i] >= num){
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
  }
}





Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
using namespace std;

int main(){
  int n;  cin >> n;
  int ans = 0;
  rep(i, 0, n){
    int l, r;
    cin >> l >> r;
    ans += r-l+1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import collections
hoge = collections.deque()
n = int(input())
for _ in range(n):
    commands = input().split()
    if len(commands) == 1:
        if commands[0] == 'deleteFirst':
            hoge.popleft()
        else:
            hoge.pop()
    else:
        com, x = commands
        if com == 'insert':
            hoge.insert(0, x)
        else:
            if x in hoge:
                hoge.remove(x)
print (' '.join(hoge))


Measured memory_bytes: 69732
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
  // input
  int x, y;
  cin >> x >> y;

  // processing
  int result = gcd(x, y);

  // output
  std::cout << result << '\n';

  return 0;
}



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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int h, w; cin >> h >> w;
	vector<vector<int> > a(h, vector<int>(w, 0));
	REP(i, h) REP(j, w) cin >> a[i][j];

	vector<P> l, r;
	REP(i, h) {
		REP(j, w - 1) {
			if (a[i][j] % 2) {
				a[i][j+1]++;
				l.push_back(make_pair(i+1, j+1));
				r.push_back(make_pair(i+1, j+1+1));
			}
		}
		if (i != h - 1 && a[i][w - 1] % 2) {
			a[i+1][w-1]++;
			l.push_back(make_pair(i+1, w-1+1));
			r.push_back(make_pair(i+1+1, w-1+1));
		}
	}

	int n = l.size();
	cout << n << '\n';
	REP(i, n) {
		cout << l[i].first << " " << l[i].second << " " << r[i].first << " " << r[i].second << '\n';
	}
    return 0;
}

Measured memory_bytes: 6296
var lines = [];

var readline = require('readline')
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});


rl.on('line', (x) => {
    lines.push(x)
});

rl.on('close', () => {
    var N = Number(lines[0]); lines.shift();
    var s = []; var p = [];

    for (var i = 0; i < N; i++) {
        var m = lines[i].split(" ");
        s.push([m[0], Number(m[1]), i]);
    }

    for (var i = 0; i < N; i++) {
        for (var j = 0; j < N - 1; j++) {
            var a = s[j][0]; var b = s[j + 1][0];
            var c = s[j][1]; var d = s[j + 1][1];
            var e = s[j][2]; var f = s[j + 1][2];

            if (a > b || (a === b && a.length > b.length)) {
                var y = b; s[j + 1][0] = a; s[j][0] = y;
                var z = d; s[j + 1][1] = c; s[j][1] = z;
                var w = f; s[j + 1][2] = e; s[j][2] = w;
            }
        }
    }

    for (var i = 0; i < N; i++) {
        for (var j = 0; j < N - 1; j++) {
            var a = s[j][1]; var b = s[j + 1][1];
            var c = s[j][0]; var d = s[j + 1][0];
            var e = s[j][2]; var f = s[j + 1][2];
            if (c !== d) { continue; }
            if (a < b || (a === b && a.length < b.length)) {
                var y = b; s[j + 1][1] = a; s[j][1] = y;
                var z = d; s[j + 1][0] = c; s[j][0] = z;
                var w = f; s[j + 1][2] = e; s[j][2] = w;
            }
        }
    }
    for (var i = 0; i < N; i++)
        console.log(s[i][2] + 1)

});

Measured memory_bytes: 21320
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define min(a,b) (((a)>(b))?(b):(a))
#define max(a,b) (((a)>(b))?(a):(b))
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int res[n+1];
	if(n%2==0){
		for(int i=1;i<=n;i++){
			if(i%2==1){
				res[n/2+1+i/2]=a[i];
			}else{
				res[n/2+1-i/2]=a[i];
			}
		}
	}else{
		for(int i=1;i<=n;i++){
			if(i%2==1){
				res[n/2+1-i/2]=a[i];
			}else{
				res[n/2+1+i/2]=a[i];
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(i!=1)cout<<" ";
		cout<<res[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3712
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion

int main(void)
{
	int  i, cnt = 0;
	int  x,a[101],n;

	scanf("%d%d",&n,&x);
	i_cins(n, a);
	qsort(a,n,sizeof(int),s_asort);
	
	for (i = 0; i < n; i++) {
		cnt++;
		x -= a[i];
		if (x <= 0)break;
	}

	(x) ? printf("%d\n",cnt-1) : printf("%d\n",cnt);
	
	return 0;
}



Measured memory_bytes: 1636
a[5000];main(i,j,n,t,r){for(;scanf("%d",&n),n;printf("%d\n",r))for(r=-1<<31,i=n;i--;)for(t=!scanf("%d",a+i),j=i-1;++j<n;r=r>t?r:t)t+=a[j];exit(0);}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 402;

int n;
int a[N];
ll sum[N];
ll dp[N][N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	MMS(dp, '?');
	for (int i = 0; i < n; i++)
		dp[1][i] = 0;
	for (int len = 2; len <= n; len++) {
		for (int st = 0; st < n && st + len <= n; st++) {
			for (int i = 1; st + i < n && i < len; i++) {
				dp[len][st] = min(dp[len][st], dp[i][st] + dp[len - i][st + i] + sum[st + len] - sum[st]);
			}
		}
	}
	cout << dp[n][0] << endl;
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	map<int, int> m;
	rep(i, n){
		int a; cin >> a;
		m[a]++;
	}
	vi v, sum(1), ans(n);
	for(auto i : m) v.pb(i.second);
	sort(all(v), greater<int>());
	for(int i : v) sum.pb(sum[sum.size() - 1] + i);
	
	for(int hako = n, prev = 0; hako > 0; hako--){
		
		int cnt = 0;
		rep(i, v.size()){
			if(v[i] <= hako){
				cnt += sum[v.size()] - sum[i];
				break;
			}
			cnt += hako;
		}
		cnt /= hako;
		while(cnt > prev) ans[prev++] = hako;
	}
	for(int i : ans) cout << i << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, x; cin >> n >> x;
    if (1 < x && x < 2*n-1) {
        cout << "Yes" << endl;
        if (n == 2) {
            rep(i, 3) cout << i+1 << endl;
        }
        else {
            set<ll> s;
            rep(i, 1, 2*n) {
                s.insert(i);
            }
            vector<ll> ans(2*n-1, -1);
            ans[n-1] = x; s.erase(x);
            ans[n-2] = 1; s.erase(1);
            ans[n] = 2*n-1; s.erase(2*n-1);
            if (x > 2) {
                ans[n+1] = 2; s.erase(2);
            }
            else {
                ans[n-3] = 2*n-2; s.erase(2*n-2);
            }
            rep(i, ans.size()) {
                if (ans[i] >= 0) {
                    cout << ans[i] << endl;
                }
                else {
                    cout << *s.begin() << endl;
                    s.erase(*s.begin());
                }
            }
        }
    }
    else {
        cout << "No" << endl;
    }
}


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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define forn(i,n) for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 

int t;

void solve(){
	int k;
	cin >> k;
	queue<ll> q;
	fori(i,1,10)
		q.push(i);
	while(k--){
		ll x = q.front(); q.pop();
		if (k == 0){
			cout << x;
			return;
		} 
		if(x%10)
			q.push(10*x + x%10 - 1);
		q.push(10*x + x%10 );
		if(x%10 != 9)
			q.push(10*x + x%10 + 1);
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	while(t--)
		solve();
	return 0;
}

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

int main(){

    char xin;
    cin >> xin;

    char x[] = {'a', 'e', 'i', 'o', 'u'};
    vector<char> v(x, x+sizeof(x));

    size_t n_count = count(v.begin(), v.end(), xin);
    if(n_count != 0){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N = 1e3+5;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			int sum = a[i] + a[j];
			int diff = a[j] - a[i];
			int idx = lower_bound(a.begin(), a.end(), sum) - a.begin();
			int idy = upper_bound(a.begin(), a.end(), diff) - a.begin();
			idx--;
			if(idx > n || a[idx] >= sum) continue;
			if(a[idy] <= diff) continue;
			ans += (idx-idy+1);
			if(i>=idy && i<=idx) ans--;
			if(j>=idy && j<=idx) ans--;
		}
	}	
	cout << ans/3;
	return 0;
}


Measured memory_bytes: 256
class UnionFindWithSize:
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.size = [1]*size
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[y] = x
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def sizeofset(self, x):
        return self.size[self.find(x)]
if __name__ == "__main__":
    N,M = map(int,input().split())
    edges = [tuple(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
    ans = 0
    for i in range(M):
        uf = UnionFindWithSize(N)
        for j in range(M):
            if j != i:
                a,b = edges[j]
                uf.unite(a,b)
        if uf.sizeofset(0) != N:
            ans += 1
    print(ans)

Measured memory_bytes: 9268
#python 3.5.2

N, M = [int(i) for i in input().split()]
As = [int(i) for i in input().split()]
BCs = [[int(j) for j in input().split()] for i in range(M)]
BCs += [[1, a] for a in As]
BCs = sorted(BCs, key=lambda x: x[1], reverse=True)
cnt = 0
sum = 0
for b, c in BCs:
    if N < cnt + b:
        sum += (N - cnt)*c
        break
    else:
        sum += b*c
        cnt += b
print(sum)

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

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

    if(b == "A"){
        cout << "T" << endl;
    }
    if(b == "C"){
        cout << "G" << endl;
    }
    if(b == "G"){
        cout << "C" << endl;
    }
    if(b == "T"){
        cout << "A" << endl;
    }
}



Measured memory_bytes: 256
import sys 
from collections import Counter
from math import factorial

def combinations_count(n, r):
  return factorial(n) // (factorial(n - r) * factorial(r))
 
def main():
  inpurt = sys.stdin.readline
  N = int(input())
  texts = [''.join(sorted(list(input().rstrip()))) for _ in range(N)]
  c = Counter(texts)
  cnt = 0
  for t in c.values():
    if t > 1:
      cnt += combinations_count(t, 2)
  print(cnt)
 
if __name__ == '__main__':
  main()

Measured memory_bytes: 19848
from collections import deque
n, m = map(int, input().split())
to = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b)
    to[b].append(a)
q = deque()
visited = [0 for _ in range(n)]
pre = [-1 for _ in range(n)]
q.append(0)
visited[0] = 1
while q:
    # visitした
    v = q.popleft()
    for u in to[v]:
        if visited[u] == 1: continue
        visited[u] = 1
        pre[u] = v
        q.append(u)
print("Yes")
for p in pre[1:]:
    p += 1
    print(p)

Measured memory_bytes: 35624
#include <iostream>

using namespace std;

int main()
{
    long long N, A, B;
    long long groupCount, rest;
    long long numA = 0;

    cin >> N >> A >> B;

    groupCount = N / (A + B);
    rest = N % (A + B);

    numA = groupCount * A;
    numA += min(A, rest);

    cout << numA << endl;

    return 0;
}

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

typedef long long llt;

const int MaxN = 100 + 5, MaxW = 100000 + 5;

int N, W;
int w[MaxN]; llt v[MaxN];
llt dp[MaxW];

void init() {
  scanf("%d %d", &N, &W);
  for (int i = 1; i <= N; ++i)
    scanf("%d %lld", &w[i], &v[i]);
}

void solve() {
  for (int i = 1; i <= N; ++i)
    for (int j = W; j >= w[i]; --j)
      dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
  llt ans = 0;
  for (int i = 1; i <= W; ++i) ans = max(ans, dp[i]);
  cout << ans << endl;
}

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

Measured memory_bytes: 1024
n, m = map(int, input().split())
table = {}
ac = 0
pena = 0
pena_arr = [0 for _ in range(n + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a in table:
        continue
    if b == "AC":
        ac += 1
        table[a] = True
    elif b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, n + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)


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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
	lli N,ans=INF;
	string s, t;
  
	cin >> N >> s >> t;
	rep(i, N){
		for (lli j = 0; i + j < N;j++){
			if (s[i+j] != t[j])break;
			if (i + j == N - 1)ans = min(ans,N + i);
		}
	}

	cout << ((ans == INF) ? 2 * N : ans )<< endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

func NextStringsLine() []string {
	strs := []string{}
	stringsStr := NextLine()
	tmp := strings.Split(stringsStr, " ")
	for _, s := range tmp {
		strs = append(strs, s)
	}
	return strs
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// DeleteElement returns a *NEW* slice, that have the same and minimum length and capacity.
// DeleteElement makes a new slice by using easy slice literal.
func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}
	// appendのみの実装
	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

// Concat returns a *NEW* slice, that have the same and minimum length and capacity.
func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

// copy function
//a = []int{0, 1, 2}
//b = make([]int, len(a))
//copy(b, a)

/*******************************************************************/

var a, b string

func main() {
	tmp := NextStringsLine()
	a, b = tmp[0], tmp[1]
	var answer string
	if a == "H" {
		if b == "H" {
			answer = "H"
		} else {
			answer = "D"
		}
	} else {
		if b == "H" {
			answer = "D"
		} else {
			answer = "H"
		}
	}
	fmt.Println(answer)
}


Measured memory_bytes: 640
#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()
{
  int X;
  cin >> X;
  int ans = 0;
  int devide_500 = X / 500;
  if (devide_500 > 0) {
    ans += devide_500 * 1000;
    X -= devide_500 * 500;
  }
  int devide_5 = X / 5;
  if (devide_5 > 0) {
    ans += devide_5 * 5;
    X -= devide_5 * 5;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        -- a[i];
    }

    int ans = 0;
    if(a[0] == 0){
        swap(a[0], a[1]);
        ++ ans;
    }
    if(a[n-1] == n-1){
        swap(a[n-2], a[n-1]);
        ++ ans;
    }

    for(int i=1; i<n-1; ++i){
        if(a[i] == i){
            ++ ans;
            if(a[i+1] == i+1)
                ++ i;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;





int main() {
	
	int s;
	cin >> s;
	VI v;
	v.push_back(s);
	int res = 2;
	while (true) {
		if (s % 2) {
			s = 3 * s + 1;
		}
		else s /= 2;


		REP(i, v.size()) {
			if (v[i] == s) {
				cout << res << endl;
				return 0;
			}
		}

		v.push_back(s);
		res++;

	}

	return 0;
}

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

int main(void){
    long long n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;
    
    long long l = (n*m)/__gcd(n,m);

    long long i=0, j=0;
    while(i<n && j<m){
        if(s[i] != t[j]){
            cout << -1 << endl;
            return 0;
        }
        i += l/m;
        j += l/n;
    }

    cout << l << endl;

    return 0;
}

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

using namespace std;

int main() {

    int N, Y;
    cin >> N >> Y;

    const int YUKICHI = 10000;
    const int HIGUCHI = 5000;
    const int NOGUCHI = 1000;

    int x = -1;
    int y = -1;
    int z = -1;

    int total;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N - i; ++j) {
            // 1000円札の枚数は N - i - j 枚のみ
            total = YUKICHI * i + HIGUCHI * j + NOGUCHI * (N - i - j);
            if (total == Y) {
                x = i;
                y = j;
                z = N - i - j;
            }
        }
    }

    cout << x << " " << y << " " << z << " " << endl;

}


Measured memory_bytes: 256
//******************************************************************************
// File Name: C.cpp
// Author: Shili_Xu
// E-Mail: shili_xu@qq.com
// Created Time: Sat 29 Sep 2018 08:03:59 PM CST
//******************************************************************************

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int MAXN = 1e5 + 5;

int n;
int aa[MAXN], a[MAXN], v[MAXN];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
    int ans = 0x3f3f3f3f, x = 0, y = 0, p = 0, q = 0;
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; i += 2) a[v[i]]++;
    for (int i = 1; i <= 1e5; i++)
        if (a[i] > a[x]) {
            y = x;
            x = i;
        }
        else{
            if (a[i] > a[y]) y = i;
        }
    memset(aa, 0, sizeof(aa));
    for (int i = 2; i <= n; i += 2) aa[v[i]]++;
    for (int i = 1; i <= 1e5; i++)
        if (aa[i] > aa[p]) {
            q = p;
            p = i;
        }
        else {
            if (aa[i] > aa[q]) q = i;
        }
    if (x != p) ans = min(ans, n / 2 - a[x] + n / 2 - aa[p]);
    if (x != q) ans = min(ans, n / 2 - a[x] + n / 2 - aa[q]);
    if (y != q) ans = min(ans, n / 2 - a[y] + n / 2 - aa[p]);
    if (y != q) ans = min(ans, n / 2 - a[y] + n / 2 - aa[q]);
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1408
// file creato da gio il 2020-04-12 16:32:10.576145

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define S second
#define F first
#define PB push_back
using namespace std;



int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	int n;
	cin >> n;
	long long sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=__gcd(__gcd(i,j),k);
			}
		}
	}
	cout <<sum<<"\n";
}

Measured memory_bytes: 3588