akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    H = LI()
    ans = 0
    cnt_plus_height_plus_idx = defaultdict(int)
    cnt_minus_height_plus_idx = defaultdict(int)

    for idx in range(N):
        cnt_plus_height_plus_idx[H[idx] + idx] += 1
        cnt_minus_height_plus_idx[- H[idx] + idx] += 1

    ans = 0

    for k, v in cnt_plus_height_plus_idx.items():
        if k in cnt_minus_height_plus_idx:
            ans += v * cnt_minus_height_plus_idx[k]

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

const int N = 1e5 + 50;
const int INF = 0x3f3f3f3f;

int n, k;
int arr[N];
int dp[N];

void load() {
    scanf("%d%d", &n, &k);

    for(int i = 0; i < n; ++i)
        scanf("%d", arr + i);
}

void solve() {
    dp[0] = 0;

    for(int i = 1; i < n; ++i) {
        for(int j = 1; i - j >= 0 && j <= k; ++j)
            dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
    }

    printf("%d", dp[n - 1]);
}

int main() {
    memset(dp, INF, sizeof dp);

    load();
    solve();

    return 0;
}


Measured memory_bytes: 1024
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# import collections # queue
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n,m = map(int,input().split())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i],b[i] = map(int,input().split())
    cd = [0] * m
    for i in range(m):
        cd[i] = list(map(int,input().split()))
    for i in range(n):
        ans = m+1
        l = INF
        for j in range(m):
            if abs(a[i]-cd[j][0])+abs(b[i]-cd[j][1])<l:
                ans = j+1
                l = abs(a[i]-cd[j][0])+abs(b[i]-cd[j][1])
            elif abs(a[i]-cd[j][0])+abs(b[i]-cd[j][1])==l:
                ans = min(ans,j+1)
        print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let mut ans = 0;
    for &c in s.iter() {
        if c == '+' {
            ans += 1;
        } else {
            ans -= 1;
        }
    }
    println!("{}", ans);
}


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

int main(){
  int n, debt=100000;
  cin >> n;

  while(n--){
    debt = debt*105/100;
    if(debt % 1000 != 0)
      debt+=1000;
    debt /= 1000;
    debt *= 1000;
  }
  cout << debt << endl;
  return 0;
}

Measured memory_bytes: 1160
def input_until_zero():
    rtn_list = []
    while True:
        in_value = int(input())
        if in_value == 0:
            break
        rtn_list.append(in_value)

    return rtn_list

rtn = input_until_zero()

for i in range(len(rtn)):
    print("Case " + str(i + 1) + ": " + str(rtn[i]))


Measured memory_bytes: 5908
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int count = 0;
    
    for (int i=a; i<=b; i++) {
        if (c%i == 0) {
            count++;
        }
    }
     printf("%d\n", count);
    return 0;
}



Measured memory_bytes: 2100
DBG = true
k,a,b = gets.split.map{|z| z.to_i}
if b-a <= 2 || k <= a
  puts "#{k+1}"
else # b-a>2, a<k
  x = a + (b-a)*((k-a+1)/2) + (k-a+1)%2
  puts "#{x}"
end


Measured memory_bytes: 1788
n, k = map(int, input().split())
nums = list(map(int, input().split()))

# (sums[j] - sums[i]) % K = j - i
# (sums[j] - j) % K  = (sums[i] - i) % K
# 1, 4, 2, 3, 5
# 0, 1, 5, 7, 10, 15
# 0, 0, 3, 0, 2, 2

sums = [0]
for x in nums:
  sums.append(sums[-1] + x)

a = [(sums[i] - i) % k for i in range(len(sums))]

res = 0
memo = {}
i = 0 
for j in range(len(a)):
  memo[a[j]] = memo.get(a[j], 0) + 1
  if j - i + 1 > k:
    memo[a[i]] -= 1
    i += 1
  res += memo[a[j]] - 1
print(res)

Measured memory_bytes: 113920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS1_2_D
{
    class ShellSort
    {
        public static int cnt = 0;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }
            A = ShellSort_F(A, N);
            Print(A, N);
        }

        public static int[] InsertionSort(int[] A, int N, int g)
        {
            for (int i = g; i <= N - 1; i++)
            {
                var v = A[i];
                var j = i - g;
                while (j >= 0 && A[j] > v)
                {
                    A[j + g] = A[j];
                    j -= g;
                    cnt++;
                }
                A[j + g] = v;
            }

            return A;
        }

        public static int[] ShellSort_F(int[] A, int N)
        {
            cnt = 0;

            var G = new List<string>();
            for (int h = 1; ;)
            {
                if (h > N)
                {
                    break;
                }
                G.Add(h.ToString());
                h = 3 * h + 1;
            }
            var m = G.Count;
            Console.WriteLine(m);
            PrintSt(G, m);

            var Gint = G.ConvertAll(int.Parse);
            for (int i = m - 1; i >= 0; i--)
            {
                A = InsertionSort(A, N, Gint[i]);
            }
            Console.WriteLine(cnt);

            return A;
        }

        public static void Print(int[] A, int N)
        {
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(A[i]);
            }
        }

        public static void PrintSt(List<string> A, int N)
        {
            var prt = "";
            for (int i = N - 1; i >= 0; i--)
            {
                if (i == 0)
                {
                    prt += A[i];
                }
                else
                {
                    prt += A[i] + " ";
                }
            }
            Console.WriteLine(prt);
        }
    }
}



Measured memory_bytes: 23460
/*
 ID: swagchicken1
 PROG:
 LANG: C++11
 */

#include <iostream>
#include <tuple>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <vector>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cctype>
#include <climits>
#include <chrono>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector <int> > vvi;
typedef pair<int, int> pii;
typedef pair < pair < int, int >, int > piii;
typedef pair < pair <int, int > , pair <int, int> > piiii;

#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define RFOR(i,a,b) for(int i = a-1; i >= b; i --)

//#define endl '\n';

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 998244353;

long double PI = 4*atan(1);
long double eps = 1e-12;



int main() {
    //auto start = chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);cin.tie(0);
    //ofstream cout("output.txt");
    //ifstream cin("input.txt");
    int n; cin >> n; cout << 2 * PI * n << endl;
    
    
    
    //auto stop = chrono::high_resolution_clock::now();
    //auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
    //cout << duration.count() << endl;
    //cin.close();
    //cout.close();
}


Measured memory_bytes: 3784
#include<iostream>

using namespace std;

int main(void) {
	int a, b, c, d, n, res;

	while(!cin.eof()) {
		cin >> n;
		res = 0;
		for(d = 0; d < 10; d++) {
			for(c = 0; c < 10; c++) {
				for(b = 0; b < 10; b++) {
					for(a = 0; a < 10; a++) {
						if(a+b+c+d == n) { res++; }
					}
				}
			}
		}
		if(!cin.eof()) { cout << res << endl; }
	}

	return 0;
}

Measured memory_bytes: 0
import math
s = input()
def check(st):
  l = len(st)
  if l%2 == 0:
    front = list(st[:l//2])
    back = list(st[l//2:])
  else:
    front = list(st[:l//2])
    back = list(st[l//2+1:])  
    
  back.reverse()
  #print(front,back)
  if front == back:
    return True
  else:
    return False
  
if check(s):
  l = len(s)
  half = s[:l//2]
  if check(half):
    print("Yes")
  else:
    print("No")
else:
  print("No")
  
    
  
  


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

ll n,m;
vvll a;

void solve(){
  cin >> n >> m;
  a.resize(n,vll(m));
  rep(i,0,n){
   rep(j,0,m) {
     cin >> a[i][j];
     a[i][j]--;
   }
  }
  
  vll flag(m,1);
  ll res=1e3;
  ll index=m;
  while(index--){
   vll num(m,0);
  rep(i,0,n){
   rep(j,0,m){
    if(flag[a[i][j]]) {
      num[a[i][j]]++;
     break;
    }
   }
  }
     ll x=0;
    rep(j,0,m) if(num[j]>num[x]) x=j;   
    res=min(res,num[x]);
    flag[x]=0;  
  } 
     
    
  cout << res << endl;

   
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve(); 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[100001];
ll b[100001];

ll getmin(ll a, ll b)
{
	if(a%b==0) return 0;
	return (((a+b-1)/b)*b - a);
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i = 0; i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	ll sum = 0;
	for(int i = n - 1; i >= 0; i--)
	{
		a[i]+=sum;
		sum+=getmin(a[i],b[i]);
	}
	cout<<sum<<'\n';
}


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

using namespace std;

int main()
{
    int N, current = 0;
    long long int K, i = 0;
    cin >> N >> K;
    long long int C[200000][2]= {0};

    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i]--;
    }

    while (K != 0)
    {
        if(C[current][0]==0){
            C[current][0] = 1;
            C[current][1] = i;
        }else if (C[current][0] == 1)
        {  
            long long int dif = i - C[current][1];
            K %= dif;
            for (int j = 0; j < K; j++)
                current = A[current];
            break;
        }
        
        current = A[current];
        K--;
        i++;
    }

    cout << current + 1 << endl;
    return 0;
}


Measured memory_bytes: 7220
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()

int n, W;
int v[105], w[105];

int32_t main(){
    cin >> n >> W;
    loop(n) cin >> w[i] >> v[i];
    int max_val = 0;
    loop(n) max_val += v[i];
    // deb(max_val);
    vin dp(max_val+5, 1e12);

    dp[0] = 0;
    loop(n){

        for(int j = max_val; j >= v[i]; j--){
            dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
        }
    }
    for(int i = max_val; i > 0; i--){
        if(dp[i] <= W) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    vector<int> x(5);
    for(int i=0;i<5;i++){
        cin >> x.at(i);
        if(x.at(i)==0){
            cout << i+1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 3592
use std::io::{Read, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();

    loop{
        let h = iter.next().unwrap().parse().unwrap();
        let w = iter.next().unwrap().parse().unwrap();
        if h==0 {break}
        for y in 0..h {
            for x in 0..w {
                let c = if y==0||y==h-1||x==0||x==w-1 {b"#"} else {b"."};
                out.write(c).unwrap();
            }
            out.write(b"\n").unwrap();
        }
        out.write(b"\n").unwrap();
    }
}



Measured memory_bytes: 5020
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=210;
int n;
vector<ll> p,dp;
ll a,k,r,fin;
int main(){
    scanf("%lld",&n);
    for(ll i=0;i<n;i++) {
        scanf("%lld%lld",&a,&k);
        //a=i,k=10;
        //printf("a:%lld k:%lld ",a,k);
        //r[i]=-1;
        if(k==1) r=a;
        else if(a==0) r=0;
        else{
            p.push_back(0);
            ll t,t1,t2,t3,da=a;
            do{
                dp.push_back((p[p.size()-1])/(k-1)+1);
                p.push_back((dp[dp.size()-1]*(k-1)-1-p[p.size()-1])/dp[dp.size()-1]*dp[dp.size()-1]+p[p.size()-1]+dp[dp.size()-1]);
                //printf("%lld %lld\n",dp[dp.size()-1],p[p.size()-1]);
            }while(p[p.size()-1]<=a);
            da=(da-p[p.size()-2])%dp[dp.size()-1]+p[p.size()-2];
            while(da-da/k!=(da-1)-(da-1)/k&&(da-1)/k>0){
                da-=da/k+1;
                p.pop_back(),dp.pop_back();
                da=(da-p[p.size()-2])%dp[dp.size()-1]+p[p.size()-2];
            }
            r=t2-1-(da-da/k-1)+(da-t2);
            p.clear(),dp.clear();
        }
        //printf("%lld\n",r);
        fin=r^fin;
    }
    if(fin==0ll) printf("Aoki\n");
    else printf("Takahashi\n");
}


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

int main(){
    int A, B, C, N, M ,K;
    int sum = 0;
    int t = 0;
    char s, s1;
    cin >> N;
    vector<char> S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
    }
    cin >> K;

    s1 = S.at(K-1);
    for(int i = 0; i < N; i++){
        if(S.at(i) != s1) S.at(i) = '*';
    }
    for(int i = 0; i < N; i++){
    cout << S.at(i);
    }
    cout << endl;
//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N;
    cin >> N;
    map<ll, ll> mp;
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }

    // resolve
    ll ans =0;
    for (auto kv: mp) {
      if (kv.second < kv.first) ans += kv.second;
      else ans += (kv.second -kv.first);
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6272
using System;

namespace AtCoderMake.ABC162
{
    class ABC162C
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            int res=0;
            int tmp;
            for(int a = 1; a <= k; a++)
            {
                for (int b = 1; b <= k; b++)
                {
                    tmp = gcb(a, b);
                    for (int c = 1; c <= k; c++)
                    {
                        res += gcb(c, tmp);
                    }
                }
            }
            Console.WriteLine(res);

        }

        static int gcb(int x,int y)
        {
            if (x > y)
            {
                return alg(x, y);
            }
            else
            {
                return alg(y, x);
            }

        }

        static int alg(int x, int y)
        {
            int suplus = x % y;
            if (suplus == 0)
            {
                return y;
            }
            else
            {
                return alg(y, suplus);
            }
        }
    }
}


Measured memory_bytes: 27540
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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 mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};




int main(){
    int a,b;cin >> a >> b;
    if(a>b) swap(a,b);
    for (int i = 0; i < b; i++) {
        cout << a;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> V;
  for (int i=0; i<N; ++i) {
    int v;
    std::cin >> v;
    V.push_back(v);
  }
  
  int max_so_far = 0;
  for (int i=0; i<N; ++i) {
    int c;
    std::cin >> c;
    int s = V[i] - c;
    if (s > 0) {
      max_so_far += s;
    }
  }
  std::cout << max_so_far;
  
  return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys


def main():
    sin = sys.stdin.buffer
    H, W = map(int, sin.readline().split())
    a = np.frombuffer(sin.read(H * (W + 1)), dtype='B') == ord('.')
    a = a.reshape((H, W + 1))[:, :-1]

    L = np.empty((H, W), dtype='i4')
    R = np.empty((H, W), dtype='i4')
    T = np.empty((H, W), dtype='i4')
    B = np.empty((H, W), dtype='i4')
    T[0] = a[0]
    for i in range(1, H):
        T[i] = (T[i - 1] + 1) * a[i]
    B[-1] = a[-1]
    for i in range(H - 2, -1, -1):
        B[i] = (B[i + 1] + 1) * a[i]
    L[:, 0] = a[:, 0]
    for i in range(1, W):
        L[:, i] = (L[:, i - 1] + 1) * a[:, i]
    R[:, -1] = a[:, -1]
    for i in range(W - 2, -1, -1):
        R[:, i] = (R[:, i + 1] + 1) * a[:, i]

    print((T + B + L + R - 3).max())


main()

Measured memory_bytes: 109956
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>

const int MAX = 30;

int n;
int par[MAX];
int left[MAX];
int right[MAX];
int depth[MAX];
int heigh[MAX];
int sib[MAX];
int degree[MAX];

void init() {
    for (int i = 0; i < n; i++) {
        par[i] = -1;
        left[i] = -1;
        right[i] = -1;
        depth[i] = 0;
        heigh[i] = 0;
        sib[i] = -1;
        degree[i] = 0;
    }
}

int findRoot() {
    for (int i = 0; i < n; i++) {
        if (par[i] == -1) return i;
    }
    return -1;
}


void dfs(int r) {
    if (r == -1) {
        left[r]=-1; right[r]=-1;
        heigh[r]=-1;
        return ;
    }
    if (par[r] == -1) {
        depth[r] = 0;
        sib[r] = -1;
    } else {
        int parent = par[r];
        depth[r] = depth[parent] + 1;
        sib[r] = (left[parent]==r)?right[parent]:left[parent];
    }
    dfs(left[r]); dfs(right[r]);
    heigh[r] = std::max(heigh[left[r]], heigh[right[r]]) + 1;
}

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    init();
    for (int i = 0; i < n; i++) {
        int p, l, r, cnt = 0;
        scanf("%d%d%d", &p, &l, &r);
        left[p] = l; right[p] = r;
        par[l] = p; par[r] = p;
        if (l != -1) cnt++;
        if (r != -1) cnt++;
        degree[p] = cnt;
    }
    int root = findRoot();
    dfs(root);
    for (int i = 0; i < n; i++) {
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, par[i], sib[i], degree[i], depth[i], heigh[i]);
        if (par[i] == -1) printf("root\n");
        else if (heigh[i] == 0) printf("leaf\n");
        else printf("internal node\n");
    }
    return 0;
}

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

int main(){
	unordered_map<long long,int> ma;
  	vector<long long> A;
  	long long N;
  	cin >> N;
  	for (int i = 0; i < N; ++i){
    	long long tmp;
      	cin >> tmp;
      	A.push_back(tmp);
    }
  	long long ans = 0;
  	for (int i = 0; i < N; ++i){
    	ans += ma[i - A[i]];
      	++ma[A[i] + i];
    }
  	cout << ans << endl;
}


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

using namespace std;

int main() {
  long long n;
  cin>>n;
  long long m=n;
  long long ans=0;
  
  for (long long i = 2; i*i<= m; ++i) {
    long long a=0;
    long long b=1;
    while(n%i==0){
      a++;
      if(a==b){
        a=0;
        b++;
        ans++;
      } 
      n/=i;
    }
    if(n==1){
      break;
    }
    if((i+1)*(i+1)>m){
      ans++;
    }
    
  }
  if(n!=1&&ans==0){
    ans++;
  }
  cout<<ans<<endl;
  
  
  
}


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

double crs(double x1, double y1, double x2, double y2) {
    return x1 * y2 - y1 * x2;
}

int main() {
    double x[4], y[4];
    char c;
    while (cin>>x[0]>>c>>y[0]>>c>>x[1]>>c>>y[1]>>c>>x[2]>>c>>y[2]>>c>>x[3]>>c>>y[3]) {
        int sum = 0;
        for (int i=0; i<4; ++i) {
            sum += 0 < crs(x[(i+1)%4] - x[i], y[(i+1)%4] - y[i], x[(i+2)%4] - x[(i+1)%4], y[(i+2)%4] - y[(i+1)%4]);
        }
        cout << (sum % 4 == 0 ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
d,target = map(int,input().split())
problem = []
for i in range(d):
    problem.append(list(map(int,input().split())))

ans = []
for i in range(2**d):
    score = target
    ans_temp = 0
    for j in range(d-1,-1,-1):
        if score <= 0:
            break
        if (i >> j) & 1:
            for k in range(problem[j][0]):
                score -= 100*(j+1)
                ans_temp += 1
                if score <= 0:
                    break
            score -= problem[j][1]
    if score <= 0:
        ans.append(ans_temp)
print(min(ans))

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

int main () {
    int a, b, c;

    cin >> a >> b >> c;

    // if ((a < b) < c) cout << "Yes" << endl;    // ????????§???????????????
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

int main(){
    std::ios::sync_with_stdio(false);

    int A, B, K;
    cin >> A >> B >> K;

    int i;
    if( B - A + 1<= 2*K) 
	f(i , A, B+1) cout << i << endl;
    else {
     f(i,A,A+K) cout << i << endl;
     f(i,B-K+1,B+1) cout << i << endl;
    }

    return 0;
    
}


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


int main() {
  int a,b,c;
  cin >> a >> b >>c;
  if(a<=b*c){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int[] slimes = new int[n+2];

		for(int i = 0; i < n; i++){
			slimes[i] = sc.nextInt();
		}
		slimes[n] = 10001;
		slimes[n+1] = 10212;

		int nowcolor = slimes[0];
		int ans = 0;
		int count = 1;
		for(int i = 1; i <= n; i++){
			if(nowcolor == slimes[i]){
				count++;
			}else{
				ans += count / 2;
				count = 1;
				nowcolor = slimes[i];
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 22484
#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)

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;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int A[100010];

int main()
{
    int N=in(), T=in();

    int mi = inf;
    int diffmax = -1;
    int cnt = 1;

    rep(i, N) {
        int a = in();

        chmin(mi, a);

        if (chmax(diffmax, a - mi)) {
            cnt = 1;
        } else if (diffmax == a - mi) {
            cnt++;
        }
    }

    printf("%d\n",cnt);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a,i,sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d",&a);
        sum+=a;
    }
    (n-sum)<0?cout<<"-1":cout<<n-sum;
    return 0;
}


Measured memory_bytes: 3756
#import sys

#input = sys.stdin.readline



def main():
#    h,w,a,b = map(int, input().split())
    n=int(input())
    d=list(map(int,input().split()))
    c=0
    for i in range(n-1):
        for j in range(i+1,n):
            c+=d[i]*d[j]
    print(c)






if __name__ == "__main__":
    main()

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

#define s(n)                        scanf("%d",&n)
#define ss(n)                       scanf("%s",n)
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define fill(a,v)                   memset(a, v, sizeof a)
#define fi              freopen("input.txt", "rt", stdin)
#define fo              freopen("output.txt", "wt", stdout)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

void solve(){
	

    int a[3];
    forall(i,0,3)
    cin>>a[i];

    sort(a, a+3);

    if(a[0]==5&&a[1]==5&&a[2]==7)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=307;
int n;
char s[N][N];
char b[N][N];
ll ans=0;
int main(){
	cin>>n;
	for(int i = 1;i<=n;i++){
		scanf("%s",s[i]+1);
	}
	for(int i = 0;i<n;i++){
		for(int j = 1;j<=n;j++){
			for(int k = 1;k<=n;k++){
				b[j][(k+i<=n)?(k+i):(k+i-n)]=s[j][k];
			}
		}
		int jud=1;
		for(int j = 1;j<=n;j++){
			for(int k = j+1;k<=n;k++){
				if(b[j][k]!=b[k][j]) jud=0;
			}
		}
		if(jud) ans++;
	}
	cout<<ans*n<<endl;
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MAXN = 110000;

vector<int> g[MAXN];
vector<int> w[MAXN];

ll ans = 0;
int n;

int id1 = -1, id2 = -1;

int dfs(int v, int p = -1) {
  int size = 1;
  bool have_big = 0;
  for (int i = 0; i < (int)g[v].size(); i++) {
    if (g[v][i] == p) continue;
    int s = dfs(g[v][i], v);
    if (s > n / 2) have_big = true;
    size += s;
    ans += 2LL * w[v][i] * min(s, n - s);
  }
  if (n - size > n / 2) have_big = true;
  if (!have_big) {
    if (id1 == -1) {
      id1 = v;
    } else if (id2 == -1) {
      id2 = v;
    } else {
      assert(0);
    }
  }
  return size;
}

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
  freopen("d.out", "w", stdout);
#endif

  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --a, --b;
    g[a].push_back(b); w[a].push_back(c);
    g[b].push_back(a); w[b].push_back(c);
  }

  dfs(0);

  assert(id1 != -1);
  eprintf("%d %d\n", id1, id2);
  if (id2 == -1) {
    ans -= *min_element(w[id1].begin(), w[id1].end());
  } else {
    int id = find(g[id1].begin(), g[id1].end(), id2) - g[id1].begin();
    assert(id != (int)g[id1].size());
    ans -= w[id1][id];
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 18304
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str>>str2;
	if(str>str2){
		cout<<">";
	}else if(str<str2){
		cout<<"<";
	}else{
		cout<<"=";
	}







	cout<<endl;
} 


Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[10000000000 for i in range(n+1)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(n+1):
    for j in range(i+1,i+k+1):
        if(j<n):
            dp[j]=min(dp[i]+abs(h[j]-h[i]),dp[j])

print(dp[n-1])


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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int l = 0, r = n-1;
  while (s[l] != 'A') l++;
  while (s[r] != 'Z') r--;
  cout << r - l + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
n, k = list(map(int, input().split()))

counter = 0
x_min = n
x = n
while not counter == 3:
    x = x % k
    if x_min > x:
        x_min = x
        counter = 1
    elif x_min == x:
        counter = counter + 1
    x = k - x

print(x_min)


Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    prev = A[0]
    ans = 0
    for a in A[1:]:
        if prev == a:
            ans += 1
            prev = -1
        else:
            prev = a

    print(ans)


    

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
using ll = long long;
int main() {
	int N; cin >> N;
	string S; cin >> S;
	int ans = 0;
	int x = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') x++;
		else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(void){
  int A[N],i,j,n;
  int t,count=0;
  int min;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(A[j] < A[min]) min = j;
    }
    if(A[i]!=A[min]) count++;
    t = A[i];
    A[i] = A[min];
    A[min] = t;
  }

  for(i=0;i<n-1;i++) printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
typedef pair<int, int> ii;

const int mod = 1e9 + 7;

int n, m;
string a, b;

map<int, char> mymap;

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> m;
    cin >> a >> b;
    int gcd = __gcd(n, m);
    int lcm = (n * m) / gcd;
    for(int i = 0; i <= (n - 1); i++)
        mymap[i * lcm / n + 1] = a[i];
    for(int i = 0; i <= (m - 1); i++) {
        if(mymap.count(i * lcm / m + 1)) {
            if(mymap[i * lcm / m + 1] == b[i])
                continue;
            else {
                cout << "-1\n";
            exit(0);
            }
        }
        else {
            mymap[i * lcm / m + 1] = b[i];
        }
    }
    cout << lcm;
}


Measured memory_bytes: 10880
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

int H, W;
int s[101][101];
int dp[101][101];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      char sij;
      cin >> sij;
      if (sij == '.') {
        s[i][j] = 0;
      } else {
        s[i][j] = 1;
      }
    }
  }

  fill(dp[0], dp[101], INF);
  if (s[1][1] == 0) {
    dp[1][1] = 0;
  } else {
    dp[1][1] = 1;
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s[i][j] == 0) {
        dp[i][j] = min(dp[i][j], dp[i][j - 1]);
        dp[i][j] = min(dp[i][j], dp[i - 1][j]);
      } else {
        if (s[i][j - 1] == 0) {
          dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
        } else {
          dp[i][j] = min(dp[i][j], dp[i][j - 1]);
        }

        if (s[i - 1][j] == 0) {
          dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
        } else {
          dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
      }
    }
  }

  cout << dp[H][W] << endl;
  return 0;
}


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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  int i;
  for(i = 0; i < h; i++)
  {
    cin >> a.at(i);
  }
  for(i = 0; i < w+2; i++)
  {
    cout << '#';
  }
  cout << endl;
  for(i = 0; i < h; i++)
  {
    cout << '#' << a.at(i) << '#' << endl;
  }
  for(i = 0; i < w+2; i++)
  {
    cout << '#';
  }
  cout << endl;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> L(M,0);
  vector<int> R(M,0);
	for(int i=0;i<M;i++){
      cin >> L.at(i) >> R.at(i);
    }
  
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  
  if((R.at(0)-L.at(M-1))<0){
    cout << 0 <<endl;
  }else{
  cout << R.at(0)-L.at(M-1)+1 <<endl;
  }
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    string s;
    cin>>s;
    int n=s.size();
    if(s[0]==s[n-1]){
        if(n%2)
        cout<<"Second";
        else cout<<"First";
    }
    else {
        if(n%2) cout<<"First";
        else cout<<"Second";
    }
    return 0;
}


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

int N, M;

vector<int> rifuru(vector<int> card) {
	vector<int> ret;
	int ac[256];
	int bc[256];
	for(int i = 0; i < N; i++) {
		ac[i] = card[i];
		bc[i] = card[i + N];
	}
	for(int i = 0; i < N; i++) {
		ret.push_back(ac[i]);
		ret.push_back(bc[i]);
	}
	return ret;
}


vector<int> cat(vector<int> card, int k) {
	vector<int> ret;
	int ac[256];
	int bc[256];
	for(int i = 0; i < k; i++) {
		ac[i] = card[i];
	}
	for(int i = 0; i < 2 * N - k; i++) {
		bc[i] = card[i + k];
	}
	for(int i = 0; i < 2 * N - k; i++) {
		ret.push_back(bc[i]);
	}
	for(int i = 0; i < k; i++) {
		ret.push_back(ac[i]);
	}
	return ret;
}

int main() {
	cin >> N;
	vector<int> card;
	for(int i = 0; i < 2 * N; i++) {
		card.push_back(i + 1);
	}
	cin >> M;
	for(int i = 0; i < M; i++) {
		int t;
		cin >> t;
		if(t == 0) card = rifuru(card);
		else card = cat(card, t);

	}

	for(unsigned int i = 0; i < card.size(); i++) {
		cout << card[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//int  t,nr,ng,nb;
ll sq(int x){return 1ll*x*x;}
#define mod 1000000007
/*void solve(vector<int>a,vector<int>b,vector<int>c)
{
  for(auto x:a)
  {
   auto y=lower_bound(b.begin(),b.end(),x);
   auto z=upper_bound(c.begin(),c.end(),x);
   if(y==b.end()||z==c.begin())
        continue;
   z--;
   ans=min(ans,sq(x-*y)+sq(*y-*z)+sq(x-*z));
  }

}*/
int main()
{ios_base::sync_with_stdio(false);
double r;
cin>>r;
double c=2*3.14*r;
cout<<c<<endl;
}


Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n = 3;
    vp in(n);
    rep(i,n){
        cin >> in[i].first;
        in[i].second = i;
    }
    sort(all(in));
    cout << char('A' + in.back().second) << endl;

}



Measured memory_bytes: 3084
N = int(input())
A = list(map(int,input().split()))
def gcd(x,y):
    return gcd(y,x%y) if y else x 
L = [0]*(N+1)
R = [0]*(N+1)
for i in range(N):
    L[i+1] = gcd(L[i],A[i])
    R[N-1-i] = gcd(R[N-i],A[N-1-i])
ans = 0
for i in range(N):
    ans = max(ans,gcd(L[i],R[i+1]))
print(ans)

Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
/*int lcslen(string x,string y,int m,int n)
{
	if(m==0||n==0)
	return 0;
	if(x[m-1]==y[n-1])
	{
		return (lcslen(x,y,m-1,n-1)+1);
	}
		return max(lcslen(x,y,m,n-1),lcslen(x,y,m-1,n));
}*/
void printlcs(string s1,string s2,int m,int n)
{
	int L[m+1][n+1];
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(i==0||j==0)
			L[i][j] = 0;
			else if(s1[i-1]==s2[j-1])
			L[i][j] = L[i-1][j-1]+1;
			else
			L[i][j] = max(L[i][j-1],L[i-1][j]);
		}
	}
	int l = L[m][n];
	int i=m,j=n;
	char r[l+1];
	r[l] = '\0';
	while(i>0&&j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			r[--l] = s1[i-1];
			i--;
			j--; 
		}
		else if(L[i-1][j]>L[i][j-1])
		{
			i--;
		}
		else 
		j--;
	}
	cout<<r<<endl;
}
int main()
{
	string a,b;
	cin>>a>>b;
	//int k=lcslen(a,b,a.length(),b.length());
	//cout<<k<<endl;
	printlcs(a,b,a.length(),b.length());
	return 0;
}

Measured memory_bytes: 35456
/**
 * Author: Behradm
 * Created: 27-04-2020 20:46:36
 * In the Name of God
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define LOCAL

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout.tie(0);
	cout.precision(6);
	int s, w;
	cin >> s >> w;
	if (w >= s)
		cout << "unsafe\n";
	else
		cout << "safe\n";
	return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);i++)
#define ar_len(ARR) (sizeof(ARR) / sizeof((ARR)[0]))

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

	int N;
	cin >> N;

	double v[N];
	rep(i, N)
		cin >> v[i];

	sort(v, v + ar_len(v));

	for(int i = 0; i < N-1; i++)
		v[i+1] = (v[i] + v[i+1]) / 2;

	cout << fixed << setprecision(9);
	cout << v[N-1] << endl;

	return 0;
}

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

int main() {
  int n, d, sum;
  cin >> n >> d;
  sum = 0;

  // ここにプログラムを追記
  rep (i, n) {
    long x, y;
    cin >> x >> y;
    if (sqrt(x * x + y * y) <= d) {
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			PriorityQueue<Double> queue = new PriorityQueue<Double>();
			for(int i = 0; i < N; i++) {
				queue.add(sc.nextDouble());
			}
			
			while(queue.size() > 1) {
				final double x1 = queue.poll();
				final double x2 = queue.poll();
				
				queue.add((x1 + x2) / 2);
			}
			
			final double answer = queue.poll();
			System.out.printf("%.10f\n", answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int a, b, c;
  cin >> a >> b >> c;

  ll ans = 0;
  if (a == b && b == c) {
    ans = a % 2 == 0 && b % 2 == 0 && c % 2 == 0 ? -1 : 0;
  } else {
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
      int ta = a / 2;
      int tb = b / 2;
      int tc = c / 2;
      a = tb + tc;
      b = ta + tc;
      c = ta + tb;
      ans++;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256