akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100005;

int N, A[MAXN];
int main(){
    scanf("%d", &N);

    int z = -1;
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
        if(A[i] == 0)z = i;
    }

    sort(A, A + N);
    reverse(A, A + N);

    if(A[0] < 0){
        int M = 0;
        for(int i = 0; i < N; i++){
            if(i == 0)M += A[i];
            else M -= A[i];
        }
        printf("%d\n", M);

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

        return 0;
    }
    if(A[N - 1] > 0){
        int M = 0;
        for(int i = 0; i < N; i++){
            if(i == N - 1)M -= A[i];
            else M += A[i];
        }
        printf("%d\n", M);

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

        return 0;
    }

    int M = 0;
    for(int i = 0; i < N; i++)
        M += abs(A[i]);
    printf("%d\n", M);

    for(int i = 1; i < N; i++){
        if(A[i] <= 0)break;
        printf("%d %d\n", A[N - 1], A[i]);
        A[N - 1] -= A[i];
    }

    for(int i = N - 1; i >= 1; i--){
        if(A[i] > 0)break;
        printf("%d %d\n", A[0], A[i]);
        A[0] -= A[i];
    }
    return 0;

}


Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<ios>

using ll = unsigned long long;
using namespace std;

int main(void) {
    int n,m;
    cin >> n >> m;

    vector<ll> p(m), y(m);
    for (int i = 0; i < m; ++i){
        cin >> p[i] >> y[i];
    }

    vector<vector<ll>> py(n);
    for(int i = 0; i < m; ++i) {
        // piを0-indexにして保存
        py[p[i]-1].push_back(y[i]);
    }

    // すべての県の所在地を設立年でソート
    for( int i = 0; i < n; ++i) {
        std::sort(py[i].begin(), py[i].end());
    }
    
    for(int i = 0; i < m; ++i) {
        // 6桁表示 prefecture id
        cout << setfill('0') << right << setw(6) << p[i];
        // city id
        cout << setfill('0') << right << setw(6) <<lower_bound(py[p[i]-1].begin(), py[p[i]-1].end(), y[i]) -  py[p[i]-1].begin() + 1<< endl;
    }

    return 0;
}

Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {
	public static long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long[] a= new long[n];
		for (int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		long[] revArray = new long[n+1];
		for (int i=0;i<=n;i++) {
			revArray[i]=rev(i);
		}
		long[] sum = new long[n+1];
		for (int i=1;i<=n;i++) {
			sum[i]=sum[i-1]+revArray[i];
		}
		long ans = 0;
		for (int i=0;i<n;i++) {
//			System.out.println(i+" "+(sum[n-i]+sum[i+1]-1));
			ans=(ans+mult(sum[n-i]+sum[i+1]-1,a[i]))%MOD;
		}
		ans = mult(ans,fact(n));
		
		System.out.println(ans);

	}
	static long mult(long n, long m) {
		return ((n%MOD)*(m%MOD))%MOD;
	}
	static long fact (long n) {
		if (n==0) {
			return 1;
		}
		return mult(n,fact(n-1));
	}
	static long power (long n, long m) {
		if (m==0) {
			return 1;
		}
		if (m%2==0) {
			long tmp = power(n,m/2);
			return mult(tmp, tmp);
		}
		return mult(power(n,m-1),n);
	}
	static long rev (long n) {
		return power(n,MOD-2);
	}
}


Measured memory_bytes: 72588
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    s = input()
    k = I()
    for i, si in enumerate(s):
        if si != '1':
            print(si)
            sys.exit()
        if i == k-1:
            break
    print(1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
inpl = lambda: list(map(int,input().split()))

def routes(start, tovisit):
	if len(tovisit) == 0:
		return 1
	else:
		ret = sum(routes(nextnode, tovisit - {nextnode}) for nextnode in neigh[start] & tovisit)
		if ret is None:
			return 0
		else:
			return ret

N, M = inpl()
neigh = [ set() for _ in range(N) ]
for _ in range(M):
	a, b = inpl()
	neigh[a-1].add(b-1)
	neigh[b-1].add(a-1)

print(routes(0,set(range(1,N))))

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

int room[4][3][10];

int main() {

  int n;
  cin >> n;

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        room[i][j][k] = 0;
      }
    }
  }
  
  
  for (int i = 0; i < n; i++) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    --b;
    --f;
    --r;
    room[b][f][r] += v;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << room[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) {
      cout << "####################" << endl;
    }
  }

  return 0;

}


Measured memory_bytes: 3100
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

S = SORO_STRING()
S = list(S)
S_ki = S[0::2]
S_gu = S[1::2]
if 'R' in S_gu:
    print('No')
    sys.exit()
if 'L' in S_ki:
    print('No')
    sys.exit()
print('Yes')

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, m, s, t;
long long dist[2][max_n], ans[max_n];
vector<int> g[max_n], a[2][max_n];

void calc(int s, int tp, long long dist[]) {
    priority_queue<pair<long long, int>> q;
    for (int i = 1; i <= n; ++i) {
        dist[i] = 1e18;
        if (i == s) {
            dist[i] = 0;
        }
        q.push(make_pair(-dist[i], i));
    }
    while (!q.empty()) {
        pair<long long, int> p = q.top();
        q.pop();
        int v = p.second;
        long long d = -p.first;
        if (d != dist[v]) {
            continue;
        }
        for (int i = 0; i < g[v].size(); ++i) {
            int to = g[v][i];
            long long nd = d + a[tp][v][i];
            if (nd < dist[to]) {
                dist[to] = nd;
                q.push(make_pair(-nd, to));
            }
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d%d%d", &n, &m, &s, &t);
    for (int i = 0; i < m; ++i) {
        int u, v, x, y;
        scanf("%d%d%d%d", &u, &v, &x, &y);
        g[u].push_back(v);
        g[v].push_back(u);
        a[0][u].push_back(x);
        a[0][v].push_back(x);
        a[1][u].push_back(y);
        a[1][v].push_back(y);
    }
    calc(s, 0, dist[0]);
    calc(t, 1, dist[1]);
    for (int i = 1; i <= n; ++i) {
        ans[i] = dist[0][i] + dist[1][i];
    }
    for (int i = n - 1; i >= 1; --i) {
        ans[i] = min(ans[i], ans[i + 1]);
    }
    for (int i = 1; i <= n; ++i) {
        printf("%lld\n", 1000000000000000LL - ans[i]);
    }
    return 0;
}


Measured memory_bytes: 28924
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c;
	cin>>d;
	if(c-a<=d&&c-a>=0)cout<<"Yes";
	else if(a-c<=d&&a-c>=0)cout<<"Yes";
	else
	{
		if(c-b<=d&&b-a<=d&&c-b>=0)cout<<"Yes";
		else if(a-b<=d&&b-c<=d&&a-b>=0)cout<<"Yes";
		else cout<<"No";
	}
	return 0;
 } 

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<pair<ll,ll>> A(N);
    REP(i,0,N) {
        cin >> A[i].first;
        A[i].second = i + 1;
    }
    ASC(A);
    A.emplace_back(0, 0);
    REV(A);

    mat dp(N+1, vec(N+1, 0));
    REP(k,0,N) {
        REP(i,0,k+1) {
            ll j = k - i;
            ll p = A[k+1].second;
            ll a = A[k+1].first;
            dp[i+1][j] = MAX(dp[i+1][j],dp[i][j]+a*abs(p-i-1));
            dp[i][j+1] = MAX(dp[i][j+1],dp[i][j]+a*abs(p-N+j));
        }
    }

    ll ans = 0;
    REP(i,0,N+1) ans = MAX(ans,dp[i][N-i]);
    PR(ans);

    return 0;
}

/*



*/

Measured memory_bytes: 34640
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  int n;
  cin>>n;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  int m;
  cin>>m;
  bool f=true;
  for(int i=0;i<m;i++){
    string s;
    cin>>s;
    if(mp.count(s)){
      if(f){
        cout<<"Opened by "<<s<<endl;
        f=false;
      }else{
        cout<<"Closed by "<<s<<endl;
        f=true;
      }
    }else{
      cout<<"Unknown "<<s<<endl;
    }
  }
}



Measured memory_bytes: 3216
#include<iostream>
#include<string>
using namespace std;
int main(){
    for(;;){
    int a,c;
    char b;
    cin>>a>>b>>c;
    if(b=='+'){
		cout<<a+c<<endl;
	}
	if(b=='-'){
		cout<<a-c<<endl;
	}
	if(b=='*'){
		cout<<a*c<<endl;
	}
	if(b=='/'){
		cout<<a/c<<endl;
	}
	if(b=='?'){
		break;
	}
}
}



Measured memory_bytes: 3072
import kotlin.math.max

fun main(args: Array<String>) {
    val (n, m, q) = readLine()!!.split(' ').map(String::toInt)
    val nArray = IntArray(n + 1) { 1 }
    val aArray = IntArray(q + 1) { 0 }
    val bArray = IntArray(q + 1) { 0 }
    val cArray = IntArray(q + 1) { 0 }
    val dArray = IntArray(q + 1) { 0 }

    fun increase(i: Int = n): Boolean {
        if (nArray[i] == m) {
            if (i == 1) {
                return false
            }
            return increase(i - 1)
        } else {
            nArray[i]++
            for (j in i + 1..n) {
                nArray[j] = nArray[i]
            }
            return true
        }
    }
    for (i in 1..q) {
        val (a, b, c, d) = readLine()!!.split(' ').map(String::toInt)
        aArray[i] = a
        bArray[i] = b
        cArray[i] = c
        dArray[i] = d
    }
    fun calcScore() = (1..q).map { i ->
        if (nArray[bArray[i]] - nArray[aArray[i]] == cArray[i]) dArray[i].toLong() else 0L
    }.sum()
    var score = calcScore()
    while (increase()) {
        score = max(score,calcScore())
    }
    println(score)
}

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

using namespace std;
#define ll long long
const int maxn=1e3+5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	double L;
	cin>>L;
    double a=L/double(3);
    double ans=a*a*a;
    cout<<fixed<<setprecision(10)<<ans<<'\n';










}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010];
map<ll,ll>m;
vector<ll>v;
string s,q;

int main()
{
   ll t,n,i,j,k,l,mn=0, mx=0;
   cin>>s;
   l=s.sz;
   if(s[l-1]=='s') s+="es";
   else s+='s';
   cout<<s<<endl;
}




Measured memory_bytes: 3616
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int inf = (int)1e9;

int main()
{
	int n, m, k;
	int ans = 0;
	vector<int> dist;
	vector<vector<pair<int, int> > > graph;
	vector<pair<pair<int, int>, int> > edge;
	
	scanf("%d%d%d", &n, &m, &k);
	dist.resize(n, inf);
	graph.resize(n);
	edge.reserve(m);
	for(int i = 0; i < m; ++i) {
		int a, b, l;
		scanf("%d%d%d", &a, &b, &l);
		a -= 1, b -= 1;
		edge.push_back(make_pair(make_pair(a, b), l));
		graph[a].push_back(make_pair(b, l));
		graph[b].push_back(make_pair(a, l));
	}
	
	priority_queue<pair<int, int> > q;
		
	for(int i = 0; i < k; ++i) {
		
		int s;
		scanf("%d", &s);
		s -= 1;
		
		q.push(make_pair(0, s));
	}
	
	while(!q.empty()) {
		
		int v = q.top().second;
		int c = -q.top().first;
		q.pop();
		
		if(dist[v] < c)
			continue;
		dist[v] = c;
		
		for(int i = 0; i < graph[v].size(); ++i) {
			int w = graph[v][i].first;
			int d = graph[v][i].second + c;
			q.push(make_pair(-d, w));
		}
	}
	
	//for(int i = 0; i < n; ++i)
	//	printf("[debug] %d -> %d\n", i, dist[i]);
	
	for(int i = 0; i < m; ++i) {
		
		int a = edge[i].first.first;
		int b = edge[i].first.second;
		int l = edge[i].second;
		int cost;
		
		if(dist[a] > dist[b])
			swap(a, b);
		
		if(dist[a] + l == dist[b])
			cost = dist[b];
		else
			cost = (l - (dist[b] - dist[a]) + 1) / 2 + dist[b];
		ans = max(ans, cost);
		//printf("[debug] (%d, %d) -> (%d, %d) -> %d -> %d\n", a, dist[a], b, dist[b], l, cost);
	}
	
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 7016
import sys
input = sys.stdin.readline

H, W = [int(x) for x in input().strip().split()]
C = [0 for _ in range(10)]
for i in range(10):
    C[i] = [int(x) for x in input().strip().split()]

isChanged = True
while isChanged:
    isChanged = False
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if C[i][j] > C[i][k] + C[k][j]:
                    C[i][j] = C[i][k] + C[k][j]
                    isChanged = True
    if not isChanged:
        break

ans = 0
for h in range(H):
    W = [int(x) for x in input().strip().split()]
    for w in W:
        if w == -1:
            continue
        ans += C[w][1]

print(ans)

Measured memory_bytes: 3064
N = int(input())
A = [int(_) for _ in input().split()]
mod = 10**9 + 7

f = [1] * (N + 2)
fi = [1] * (N + 2)
for i in range(2, N + 2):
    f[i] = i * f[i - 1]
    f[i] %= mod
for i in range(2, N + 2):
    fi[i] = fi[i - 1] * pow(i, mod - 2, mod)
    fi[i] %= mod


def comb(n, r):
    if 0 <= n and 0 <= r and 0 <= n - r:
        return (f[n] * fi[r] * fi[n - r]) % mod
    else:
        return 0


b = set()
for a in A:
    if a in b:
        break
    b.add(a)
c = []
for i in range(N + 1):
    if A[i] == a:
        c += [i]
i, j = c
for x in range(1, N + 2):
    print((comb(N + 1, x) - (comb(N - j + i, x - 1))) % mod)


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

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

bool isPrime(int n) {
  if( n < 2 ) return false;
  if( n == 2 ) return true;
  if( n % 2 == 0 ) return false;
  for(int d = 3; d * d <= n; d += 2 ) {
    if( n % d == 0 ) return false;
  }
  return true;
}

vector<int> primes;

int dp[1500][16];

int main() {
  for(int i = 0; i < 1120; i++)
    if( isPrime(i) )
      primes.push_back(i);

  int N = primes.size();

  memset(dp, 0, sizeof(dp));

  for(int i = 0; i < N; i++){
    for(int k = 14; k >= 0; k--) {
      for(int n = 1; n <= 1120; n++) {
        if( k == 1 && n - primes[i] == 0 ) {
          dp[n][k]++;
        }

        if( n - primes[i] > 0 ) {
          dp[n][k] += dp[n-primes[i]][k-1];
        }
      }
    }
  }

  for( int n, k; scanf("%d%d", &n, &k), (n || k); ) {
    printf("%d\n", dp[n][k]);
  }
  return 0;
}

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

int main() {
	int a, b, c;
	std::cin >> a >> b;
	switch (b / 10) {
	case 0:
		c = a * 10 + b;
		break;
	case 10:
		c = a * 1000 + b;
		break;
	default :
		c = a * 100 + b;
		break;
	}
	for (int i = 1; i <= 316; ++i) {
		if (c == i * i) { std::cout << "Yes" << std::endl; return 0; }
	}
	std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
  #include<string>
 #define rep(i, n) for(int i = 0; i < (n); i++)
  #define shosu(n) setprecision(n)
  using namespace std;
// clang-format on
int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  } else if (a >= 0 && b <= 0) {
    cout << "Zero" << endl;
  } else if (a > 0 && b > 0) {
    cout << "Positive" << endl;
  } else if (a < 0 && b < 0) {
    a *= -1;
    b *= -1;
    if ((a + b) % 2 == 0)
      cout << "Negative" << endl;
    else if ((a + b) % 2 == 1)
      cout << "Positive" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

const int64 MOD = 1e9 + 7;

const int MAX = 2e5;
//const int MOD = 1e9 + 7;
int64_t fac[MAX] = {}, inv[MAX] = {}, finv[MAX] = {};

void make_table() {
  fac[0] = 1; fac[1] = 1;
  finv[0] = 1; finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int64_t com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int n, k; cin >> n >> k;
  make_table();

  //int64 ans = 0;

  for (int i = 1; i <= k; ++i) {
    int64 ans = 0;
    (ans += com(n - k + 1, i) * com(k - 1, i - 1)) %= MOD;
    cout << ans << '\n';
  }


  return 0;
}


Measured memory_bytes: 4992
//
//  main.cpp
//  kazane
//
//  Created by h3036136 on 2017/07/27.
//  Copyright ?? 2017??´ h3036136. All rights reserved.
//1=31,2=29,3=31,4=30,5=31,6=30,7=31,8=31,9=30,10=31,11=30,12=31

#include <iostream>
#include <string>
using namespace std;
int main(){
    int a[101]={0},b,i,saihin[100]={0},c=0,saidai=0;
    while(cin>>b){
        a[b]=a[b]+1;
    }
    for(i=1;i<=100;i++){
        if(saidai<a[i]){
            saidai=a[i];
        }
    }
    for(i=1;i<=100;i++){
        if(a[i]==saidai){
            saihin[c]=i;
            c=c+1;
        }
    }
    for(i=0;i<100;i++){
        if(saihin[i]==0)break;
        cout<<saihin[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>

#define INF 10000000000
using namespace std;
using P = pair<long, long>;

int main(){
    int n;
	cin >> n;
	if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9){
		cout << "hon" << endl;
	}else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8){
		cout << "pon" << endl;
	}else{
		cout << "bon" << endl;
	}
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
	int a[60];
	long ans;
	int i, j, k, n;
	cin >> n; ans = 0;
	for (i = 1; i <= n; i++) cin >> a[i];
	for (i = 1; i < n; i++)
		for (j = i + 1; j <= n; j++) ans += a[i] * a[j];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

//public class Main {
//
//	public static void main(String[] args) {
//		// TODO ?????????????????????????????????????????????
//		Scanner s = new Scanner(System.in);
//		int a,b;
//		ArrayList<String> str = new ArrayList<String>();
//		String[] result;
//		
//		for(int i = 0;i <3;i++)
//		{
//			str.add(s.nextLine());
//
//		}
//		
//		for(int i = 0;i<3;i++)
//		{
//			result = str.get(i).split(" ");
//			a = Integer.parseInt(result[0]);
//			b = Integer.parseInt(result[1]);
//			System.out.println(String.valueOf(a+b).length());
//		}
//	}
//}
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner s = new Scanner(System.in);
		int a,b;
		ArrayList<String> str = new ArrayList<String>();
		String[] result;
		
		while(s.hasNext())
		{

			
			a = s.nextInt();
			b = s.nextInt();
			System.out.println(String.valueOf(a+b).length());
		
		}
	}
}

Measured memory_bytes: 26276
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M;
  cin >> N >> M;
  int X[N];
  ll num[100001];
  ll d[M];
  ll pa[M];
  int ans = 0;
  for (int i = 0; i < M; i++) {
    d[i] = 0;
    pa[i] = 0;
  }
  for (int i = 0; i <= 100000; i++) {
    num[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    num[X[i]]++;
    d[X[i] % M]++;
  }
  for (int i = 0; i <= 100000; i++) {
    pa[i%M] += num[i] / 2;
  }

  for (int i = 1; i < M; i++) {
    if (M % 2 != 0 || i != M/2) {
      ll a = min(d[i],d[M-i]);
      ans += a;
      d[i] -= a;
      d[M-i] -= a;
    }
  }

  for (int i = 0; i < M; i++) {
    if (i == 0) {
      ans += d[0] / 2;
      continue;
    }
    if (i == M/2 && M % 2 == 0) {
      ans += d[M/2] / 2;
      continue;
    }
    ans += min(d[i] / 2,pa[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6184
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    d = [-1]*n
    d[0] = 0
    q = deque([0])
    while q:
        x = q.popleft()
        nd = d[x]^1
        for y in v[x]:
            if d[y] < 0:
                d[y] = nd
                q.append(y)
    n1 = sum(d)
    n0 = len(d)-n1
    if n1 > n0:
        for i in range(n):
            d[i] ^= 1
        n0,n1 = n1,n0
    p = [(n+2)//3, (n+1)//3, n//3]
    k = [1,2,3]
    ans = [0]*n
    if n1 >= p[1]:
        for i in range(n):
            di = d[i]
            if not p[di]:
                di = 2
            ans[i] = k[di]
            k[di] += 3
            p[di] -= 1
    else:
        for i in range(n):
            di = d[i]
            if di == 1:
                di = 2
            while not p[di]:
                di += 1
            ans[i] = k[di]
            k[di] += 3
            p[di] -= 1
    print(*ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 95924
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Cin.Int()
    Dim s(0 To n - 1) As String
    Dim p(0 To n - 1) As Integer
    For i As Integer = 0 To n - 1
      Dim sp As String() = Cin.StrArr()
      p(i) = 100 - Integer.Parse(sp(1))
      s(i) = sp(0) & Strings.Format(p(i), "000") & Strings.Format(i + 1, "000")
    Next
    Array.Sort(s)
    For i As Integer = 0 To n - 1
      Console.WriteLine(Integer.Parse(Right(s(i), 3)).ToString())    
    Next
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define dbg(x) cout << #x << "= " << x << endl;
typedef pair <int, int> pii;
const int inf = 0x3f3f3f3f;
const ll INF = (1LL<<62)-1;
const ll mod = 1e9+7;
const int N = 1e5+5;

vector<pii >tx, ty;
int n, m, x[N], y[N];
int p[N];    //并查集的使用

const int maxm = 5e5+5;

struct edge{
    int u,v;
    ll cost;
    bool operator < (const edge& rhs)const {
        return cost < rhs.cost;
    }
}e[maxm];

int Find(int x){//查找x的父亲节点，递归调用
    return  p[x]==x?x:p[x]=Find(p[x]);
}

ll kruskal(int n,int m){  //返回最小生成树的权值
    ll ans=0;
    sort(e,e+m);
    for(int i=0 ; i<m ; i++){
        int u=e[i].u;
        int v=e[i].v;
        u=Find(u);
        v=Find(v);
        if(u!=v){   //如果不在一个集合中，合并
            ans+=e[i].cost;
            p[v]=u;
        }
    }
    return ans;
}

void addedge(int u, int v){
    e[m].u = u, e[m].v = v, e[m++].cost = min(abs(x[u]-x[v]), abs(y[u]-y[v]));
}

int  main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++)p[i] = i;
    for(int i=1; i<=n; i++){
        scanf("%d%d", &x[i], &y[i]);
        tx.pb({x[i], i});
        ty.pb({y[i], i});
    }
    sort(tx.begin(), tx.end());
    sort(ty.begin(), ty.end());
    addedge(tx[0].ss, tx[1].ss);
    addedge(ty[0].ss, ty[1].ss);
    addedge(tx[n-1].ss, tx[n-2].ss);
    addedge(ty[n-1].ss, ty[n-2].ss);
    for(int i=1; i<n-1; i++){
        addedge(tx[i-1].ss, tx[i].ss);
        addedge(tx[i].ss, tx[i+1].ss);
        addedge(ty[i-1].ss, ty[i].ss);
        addedge(ty[i].ss, ty[i+1].ss);
    }
    printf("%lld\n", kruskal(n, m));
    return 0;
}


//    lower_bound()
//    __builtin_popcount()
//    ios::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    const double eps=1e-12;
//    #pragma comment(linker,"/STACK:102400000,102400000")



Measured memory_bytes: 10988
N=int(input())
W=[]
for _i in range(N):
    W.append(input())
if(sorted(W)!=sorted(list(set(W)))):
    print("No")
else:
    for i in range(len(W)-1):
        if(W[i][-1]!=W[i+1][0]):
            print("No")
            break
    else:
        print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n),c(n);
  rep(i,n)cin >> p[i];
  rep(i,n)cin >> c[i];
  rep(i,n)p[i]--;
  ll ans = -LINF;
  rep(si,n){
    vector<int> v;
    int pos = p[si];
    ll tot = 0;
    while(true){
      v.push_back(c[pos]);
      tot+=c[pos];
      pos = p[pos];
      if(pos==p[si])break;
    }
    int l = v.size();
    ll res = 0;
    rep(i,l){
      if(i+1>k)break;
      res += v[i];
      if(tot>0)chmax(ans,res+tot*((k-(i+1))/l));
      else chmax(ans,res);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<stack>
#include<iterator>
#include<functional>
#include<string.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//namespace mp = boost::multiprecision;


int main() {
	int d; cin >> d;
	if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if(d==22){
		cout << "Christmas Eve Eve Eve" << endl;
	}
	else {
		cout << "Christmas" << endl;
	}
}




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

void question(long long x) {
    cout << "? " << x << endl;
    fflush(stdout);
}

bool response() {
    char c; cin >> c;
    return c == 'Y';
}

void answer(long long x) {
    cout << "! " << x << endl;
}

int main() {
    vector<long long> a(10, 1);
    vector<long long> b(10);
    for (int i = 0; i < 10; i++) {
        if (i) a[i] = a[i-1] * 10;
        b[i] = a[i] * 10 - 1;
    }
    vector<bool> flag(10, true);
    int cnt = 0; int last = 0; int first = 10;
    for (int i = 0; i < 10; i++) {
        question(a[i]);
        flag[i] = flag[i] * response();
        question(b[i]);
        flag[i] = flag[i] * response();
        if (flag[i]) {
            cnt++; last = max(last, i); first = min(first, i);
        }
    }
    if (cnt == 10) {
        answer(1);
        return 0;
    }
    if (cnt > 1) {
        if (flag[0]) {
            if (last == cnt-1) {
                answer(b[cnt-1]);
                return 0;
            }
        } else if (flag[9]) {
            if (first == 10-cnt) {
                answer(a[10-cnt]);
                return 0;
            }
        }
        else answer(a[10-cnt]);
    }
    long long left = a[last] * 10; 
    long long right = left * 10;
    while (right - left > 1) {
        long long mid = (right+left) / 2;
        question(mid);
        if (response()) right = mid;
        else left = mid;
    }
    answer((left+1)/10);
    return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];
int main() {
	ll n;
	cin>>n;
	int a[21];
	int b[21];
	int c[21];
	int r=0;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n-1)cin>>c[i];
	rep(i,n)r+=b[i];
	rep(i,n-1){
		if(a[i+1]==(a[i]+1))r+=c[a[i]-1];
	}
	cout<<r<<endl;	
	return 0;
}


Measured memory_bytes: 4992
def Takoyaki():
    
    data = list(map(int,input().split()))

    if data[0] <= data[1]:
        print(data[2])
            
    else:

        num = data[0] // data[1]

        if (data[0] % data[1]) != 0:
                    
            print((num+1)*data[2])

        else:
            print((num)*data[2])

if __name__ == '__main__':
    Takoyaki()



Measured memory_bytes: 9176
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	cnt := 0
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	S := []int{}
	for i := 0; i < n; i++ {
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		S = append(S, v)
	}

	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())

	for i := 0; i < q; i++ {
		sc.Scan()
		key, _ := strconv.Atoi(sc.Text())
		S = append(S, key)
		if search(S, key) {
			cnt++
		}
		S = S[:len(S)-1]
	}

	fmt.Println(cnt)
}

func search(s []int, key int) bool {
	for i := 0; i != len(s)-1; i++ {
		if s[i] == key {
			return true
		}
	}
	return false
}



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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    long N;
    long A[110000], B[110000];

    cin >> N;
    rep(i, N + 1) cin >> A[i];
    rep(i, N) cin >> B[i];

    ul killCount = 0;
    rep(i, N){
        if(A[i] >= B[i]){
            killCount += B[i];
        }else{
            killCount += A[i];
            int atack = B[i] - A[i];
            if(A[i + 1] >= atack){
                killCount += atack;
                A[i + 1] -= atack;
            }else{
                killCount += A[i + 1];
                A[i + 1] = 0;
            }
        }
    }
    cout << killCount << endl;
}

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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(ll, L);
    CIN(ll, R);

    if ( R - L > 2020 ) {
        cout << 0 << "\n";
        return 0;
    }

    ll L2019 = L / 2019;

    L -= 2019 * L2019;
    R -= 2019 * L2019;

    ll ans = 2019 * 2019;
    for (ll i = L; i <= R; i++) {
        for (ll j = i+1; j <= R; j++) {
            ans = min(ans, (i*j) % 2019);
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int n, m;
  cin >> n >> m;
  int k, input;
  vector<vector<int>> s(m, vector<int>(0));
  for (int i = 0; i < m; i++){
    cin >> k;
    for (int j = 0; j < k; j++){
      cin >> input;
      s[i].push_back(input - 1);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++)
    cin >> p[i];


  int ret = 0;
  for (int i = 0; i < (1 << n); i++){
    int ok = 1;
    for (int j = 0; j < m; j++){
      int oe = 0;
      for (int l = 0; l < s[j].size(); l++){
        if (((i >> s[j][l]) & 1) == 1)
          oe = (oe + 1) % 2;
      }

      if (oe != p[j])
        ok = 0;
    }
    if (ok)
      ret++;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll h, w;
    string s[111];

    cin >> h >> w;
    rep(i, h)cin >> s[i];

    ll dp[111][111];
    rep(i, h)rep(j, w)dp[i][j] = INF;

    if(s[0][0] == '.')dp[0][0] = 0;
    else dp[0][0] = 1;

    rep(i, h)rep(j, w){
        if(i+1 < h){
            if(s[i+1][j] == '#' && s[i+1][j] != s[i][j])dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1);
            else dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
        if(j+1 < w){
            if(s[i][j+1] == '#' && s[i][j+1] != s[i][j])dp[i][j+1] = min(dp[i][j+1], dp[i][j]+1);
            else dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
        }
    }

    cout << dp[h-1][w-1] << endl;

}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  i64 A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A > 0 && C > 0) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.14159265358979323846
using namespace std;
int main(){
	double r,cir=0;
	cin>>r;
	cir = 2 * PI * r;
	cout<<setprecision(20)<<cir<<"\n";
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  ll l,r;
  cin>>l>>r;
  if (l/2019 != r/2019) {
    cout<<0<<endl;
  } else {
    ll mn = 2019;
    FOR(i,l,r+1)FOR(j,l,i) {
      mn=min(mn, ((ll)i*j)%2019);
    }
    cout<<mn<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int c,d;
	int i,j;	
	int data[1000][1000];
	int sum[1000],sum2[1000],sum3=0;
	for(i=0;i<100;i++){
		sum[i]=0;
		sum2[i]=0;
	}
	scanf("%d %d",&c,&d);

	for(i=0;i<c;i++){
		for(j=0;j<d;j++){
			scanf("%d",&data[i][j]);
		}
	}
	for(i=0;i<c+1;i++){
		for(j=0;j<d+1;j++){
			if(i<c && j<d)printf("%d ",data[i][j]);
			if(i==c && j<d) printf("%d ",sum[j]);
			if(j==d)printf("%d",sum2[i]);
			if(i<c && j<d){
				sum[j]=sum[j]+data[i][j];
				sum2[i]=sum2[i]+data[i][j];
				sum3=sum3+data[i][j];
			}
			else {
				sum2[i]=sum2[i]+sum[j];
			}
		}printf("\n");
	}
return 0;
}

Measured memory_bytes: 1004
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, s, e) FOR(i, e, s) cout << a[i] << ' '



using namespace std;


int main()
{
    int n; cin >> n;
    int a[n], b[n], c[n];
    FOR(i, n, 0)cin >> a[i];
    FOR(i, n, 0)cin >> b[i];
    FOR(i, n - 1, 0)cin >> c[i];
    ll ans = 0;
    FOR(i, n, 0)
    {
        ans += b[a[i] - 1];
        if(i == 0)continue;
        if(a[i - 1] + 1 == a[i])ans += c[a[i - 1] - 1];
    }
    cout << ans;
    return 0;
}
//1 2 20 10 5 15 14


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N,sum,s,t;
  cin>>N;
  sum=0;
  s=0;
  t=N;
  for(int i=0;t>0;i++){
    s=t%10;
    sum+=s;
    t/=10;
  }
  if(N%sum==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
#include<vector>
#include<algorithm>
using namespace std;

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> Size;
    UnionFind(int n = 1) {
        init(n);
    }
    void init(int n = 1) {
        par.resize(n+1);
        rank.resize(n+1);
        Size.resize(n+1);
        for(int i=0;i<=n;++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }
    int root(int x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }
    int Sz(int x){
        return Size[root(x)];
    }
};
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];
    UnionFind uf(h*w);
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            for(int i=0;i<4;i++){
                int ny=y+dy[i];
                int nx=x+dx[i];
                if(ny<0||nx<0||ny>=h||nx>=w)continue;
                if(s[y][x]!=s[ny][nx]&&!uf.same(y*w+x,ny*w+nx)){
                    uf.unite(y*w+x,ny*w+nx);
                }
            }
        }
    }
    map<int,int> mb,md;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#')mb[uf.root(i*w+j)]++;
            else md[uf.root(i*w+j)]++;
        }
    }
    int res=0;
    for(auto it:mb){
        res+=it.second*(md[it.first]);
    }
    cout<<res<<endl;

}

Measured memory_bytes: 21120
def search(x, l, first, end):
    if end-first<=1:
        if x<l[first]:
            return -1
        elif x>l[end]:
            return end
        else:
            return first
    middle = (first+end)//2
    if x >= l[middle]:
        return search(x, l, middle, end)
    else:
        return search(x, l, first, middle)
A,B,Q = map(int,input().split())
INF = 10**18
s = [-INF]+[int(input()) for i in range(A)]+[INF]
t = [-INF]+[int(input()) for i in range(B)]+[INF]
s.sort()
t.sort()
answer = []
for i in range(Q):
    x = int(input())
    sk = search(x,s,0,A)
    tk = search(x,t,0,B)
    ptn1 = abs(s[sk]-x) + min(abs(t[tk]-s[sk]),abs(t[tk+1]-s[sk]))
    ptn2 = abs(s[sk+1]-x) + min(abs(t[tk]-s[sk+1]),abs(t[tk+1]-s[sk+1]))
    ptn3 = abs(t[tk]-x) + min(abs(s[sk]-t[tk]),abs(s[sk+1]-t[tk]))
    ptn4 = abs(t[tk+1]-x) + min(abs(s[sk]-t[tk+1]),abs(s[sk+1]-t[tk+1]))
    answer.append(min(ptn1,ptn2,ptn3,ptn4))
for i in answer:
    print(i)

Measured memory_bytes: 16880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] nmq = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nmq[0];
			int m = nmq[1];
			int q = nmq[2];

			int[,] lr = new int[n + 1, n + 1];
			for (int i = 0; i < m; i++) {
				int[] lrtemp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				lr[lrtemp[0], lrtemp[1]]++;
			}

			for (int i = 1; i < n + 1; i++) {
				for (int j = 1; j < n + 1; j++) {
					lr[i, j] = lr[i, j] + lr[i, j - 1] + lr[i - 1, j] - lr[i - 1, j - 1];
				}
			}

			var sb = new StringBuilder();
			for (int i = 0; i < q; i++) {
				int[] pq = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				int l = pq[0] - 1;
				int r = pq[1];
				int ans = lr[r, r] - lr[r, l] - lr[l, r] + lr[l, l];
				sb.AppendLine(ans.ToString());
			}

			Console.WriteLine(sb.ToString());
		}
	}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/27  Problem: ABC 135 B / Link: http://abc135.contest.atcoder.jp/tasks/abc135_b  ----- */


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	LL N; cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	VL  b = a;
	SORT(b);
	bool ok = a == b;
	FOR(i, 0, N) {
		FOR(j, i + 1, N) {
			swap(a[i], a[j]);
			ok |= a == b;
			swap(a[i], a[j]);
		}
	}

	cout << (ok ? "YES" : "NO") << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;
#include <algorithm>
#include <stack>
#include <vector>
#include <array>
#include <queue>


int main(){

  int N;
  int count = 0;
  cin >> N;
  for(int i=1;i<=N;i++){
    string s = to_string(i);
    if(s.length()%2==1){
      count += 1;
    }
  }
  cout << count;

  return 0;

}


Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
    }
    let mut ans = 0;
    for i in 1..n {
        if n - i > i {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector <int> d(N);
  for (int i = 0; i < N; i++) cin >> d[i];
  
  sort(d.begin(), d.end());
  int l = d[N/2-1];
  int r = d[N/2];
  cout << r-l << endl;
  return 0;
}


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

		int n = (int)Math.ceil((double)h/(double)a);

		// 出力
		System.out.println(n);
	}
}

Measured memory_bytes: 22740