akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_V 200

int dist[MAX_V][MAX_V];//辺が存在しない場合はINF、ただしdist[i][i] = 0とする
int V;

void warshall_floyd(){
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            if(dist[i][k] == INF) continue;
            for(int j = 0; j < V; j++){
                if(dist[k][j] == INF) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}
//負の閉路があるかないかは、dist[i][i]が負になる頂点iがあるかどうかで判別できる

signed main(){
    int n;
    cin >> n;
    V = n;
    string s[n];
    REP(i,n){
        cin >> s[i];
    }
    REP(i,n){
        REP(j,n){
            dist[i][j] = INF;
            if(i == j){
                dist[i][j] = 0;
            }
        }
    }
    vector<int> G[n];
    REP(i,n){
        REP(j,n){
            if(s[i][j] == '1'){
                G[i].push_back(j);
                dist[i][j] = 1;
            }
        }
    }
    bool imp = false;
    int d[n];
	REP(i,n){
        d[i] = INF;
    }
    queue<int> que;
	que.push(0);
	d[0] = 0;
	while(que.size()){
		int u = que.front();
		que.pop();
		for(auto v : G[u]){
            if(d[v] == INF){
                d[v] = d[u] + 1;
                que.push(v);
            }else{
                if(!(d[v] == d[u] - 1 || d[v] == d[u] + 1)){
                    imp = true;
                }
            }
        }
	}
    if(imp){
        cout << -1 << endl;
        return 0;
    }
    warshall_floyd();
    int ans = 0;
    REP(i,n){
        REP(j,n){
            if(dist[i][j] != INF){
                ans = max(ans, dist[i][j]);
            }
        }
    }
    ans++;
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    map<int,int> mp;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }

    int q;
    cin >> q;
    while(q--) {
        int x, y;
        cin >> x >> y;
        int z = mp[x];
        sum += (y - x) * z;
        mp[x] = 0;
        mp[y] += z;
        cout << sum << endl;
    }


    return 0;
}

    

Measured memory_bytes: 10388
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define mod 100000007
#define elif else if
#define str string

signed main(){
  int N,M,O,P=0,count=0,count2=0;
  double d;
  char c;
  string S,T;
  cin>>N>>M;
  vvint A(N,vint(M));rep(0,N)REP(0,M)A[i][j]=0;
  vint B(M);rep(0,M)B[i]=i+1;
  rep(0,N){
    cin>>O;
    REP(0,O){
      cin>>P;
      A[i][P-1]=P;
      P=0;
    }
    O=0;
  }
  rep(0,N){
    REP(0,A[i].size()){
      if(A[i][j]==0&&B[j]!=0){
        B[j]=0;
      }
    }
  }
  rep(0,M)if(B[i]!=0)count++;
  cout<<count<<endl;
}


Measured memory_bytes: 256
s = input()
s = s[:-1]

while len(s) > 0:
    l = len(s)
    if l%2 == 1:
        s = s[:-1]
        continue
    if s[:l//2] == s[l//2:]:
        print(l)
        break
    else:
        s = s[:-1]


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

int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

#define mp make_pair
#define fi first
#define se second
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) (((a) * (b)) / (__gcd((a), (b))))
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define setbits(x) __builtin_popcountll(x)
#define unsetend(x) __builtin_ctzll(x)
#define unsetfront(x) __builtin_clzll(x)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define ll long long
#define endl "\n"
#define Endl "\n"

// long long expo(long long a, long long b, long long mod)
// {
//     ll ret = 1;
//     while (b > 0)
//     {
//         if (b % 2 == 1)
//             ret = (((ret)%mod) * ((a)%mod))%mod;
//
//         a = ((a)%mod) * ((a)%mod)%mod;
//         b = b / 2;
//     }
//     return (ret%mod);
// }

// vector<long long> seive()
// {
//    long long i,j;
//    vector<long long> hash(1000001,1);
//    vector<long long> primes;
//
//    for(i=2;i*i<=1000000;i++)
//    {
//        if(hash[i])
//        {
//            for(j=i*i;j<=1000000;j+=i)
//            hash[j]=0;
//        }
//    }
//    for(i=2;i<1000001;i++)
//    {
//        if(hash[i])
//        primes.pb(i);
//    }
//    return primes;
// }
vector<int> g[100001];
map<pair<int, int>, int> vis;
vector<int> dp(100001, -1);

int dfs(int x)
{
    int i;
    if (g[x].size() == 0)
        return 0;
    else
    {
        for (i = 0; i < g[x].size(); i++)
        {
            int child = g[x][i];
            if (vis[{x, child}] == 0)
            {
                vis[{x, child}] = 1;
                dp[x] = max(dp[x], 1 + dfs(child));
            }
        }
    }
    return dp[x];
}

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

    int n, v, i, j;
    cin >> n >> v;
    set<int> st;
    for (i = 0; i < v; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        vis[{a, b}] = 0;
        st.insert(a);
        st.insert(b);
    }
    for (i = 1; i <= n; i++)
    {
        if (dp[i] == -1)
        {
            dp[i] = dfs(i);
        }
    }
    int ans = INT_MIN;
    for (auto ele : st)
        ans = max(ans, dp[ele]);
    cout << ans;
    // cout << dp[4];
}


Measured memory_bytes: 24840
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main()
{
	int r,d,x;
	cin>>r>>d>>x;
	int a[11];
	a[0]=x;
	for(int i=1;i<11;i++)
	{
		a[i]=r*a[i-1]-d;
	}	
	for(int i=1;i<11;i++)
		cout<<a[i]<<endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]

Glaph = [[float("inf") for i in range(H*W)] for j in range( H*W )]
for i in range(H):
  for j in range(W):
    
    if S[i][j] == ".":
 
      Glaph[i*W+j][i*W+j] = 0
      if i-1 != -1 and S[i-1][j] == ".":
        Glaph[i*W+j][(i-1)*W+j] = 1
      if i+1 != H and S[i+1][j] == ".":
        Glaph[i*W+j][(i+1)*W+j] = 1
      if j-1 != -1 and S[i][j-1] == ".":
        Glaph[i*W+j][i*W+(j-1)] = 1
      if j+1 != W and S[i][j+1] == ".":
        Glaph[i*W+j][i*W+(j+1)] = 1
        
def warshall_floyd(n) : # nは頂点数
  for i in range(n):      # 経由する頂点
    for j in range(n):    # 開始頂点
      for k in range(n):  # 終端
        Glaph[j][k] = min(Glaph[j][k], Glaph[j][i] + Glaph[i][k])
        
warshall_floyd(H*W)

ans = 0
for i in range(H*W):
  for j in range(H*W):
    if Glaph[i][j]!=float("inf"):
      ans=max(ans,Glaph[i][j])

print(ans)


Measured memory_bytes: 135176
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Coloring Edges on Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef queue<int> qi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

vpii nbrs[MAX_N];
int ps[MAX_N], pcs[MAX_N];
int ecs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

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

  int k = 0;
  ps[0] = pcs[0] = -1;

  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = ps[u], &uc = pcs[u];
    vpii &nbru = nbrs[u];

    int c = 0;
    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = vit->first, &ei = vit->second;
      if (v != up) {
	if (c == uc) c++;
	ecs[ei] = c++;
	if (k < c) k = c;

	ps[v] = u, pcs[v] = ecs[ei];
	q.push(v);
      }
    }
  }

  printf("%d\n", k);
  for (int i = 0; i < n - 1; i++) printf("%d\n", ecs[i] + 1);
  return 0;
}


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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
	int A,B,M;
	int Ap[100001];
	int Bp[100001];
	int min=2147483647;
	scanf("%d %d %d",&A,&B,&M);
	for(int x=0;x<A;x++){
		scanf("%d",&Ap[x]);
	}
	for(int x=0;x<B;x++){
		scanf("%d",&Bp[x]);
	}
	int x,y,c;
	int price;
	for(int p=0;p<M;p++){
		scanf("%d %d %d",&x,&y,&c);
		price=(Ap[x-1]+Bp[y-1]-c);
		if(price<min){
			min=price;
		}
	}
	qsort(Bp,B,sizeof(int),compare_int);
	qsort(Ap,A,sizeof(int),compare_int);
	price=Ap[0]+Bp[0];
	if(price<min){
		min=price;
	}
	printf("%d",min);
}

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

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

  sort(a,a+5);

  for(i=4; i>=0; i--){
    printf("%d",a[i]);
    if(i!=0)printf(" ");
  }
  puts("");
}

Measured memory_bytes: 1216
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, ll> P; // 重さ、価値
vector<P> vec;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, W;
  cin >> N >> W;
  ll v[N], w[N];
  FOR(i,0,N) cin >> v[i] >> w[i];
  int N2 = N / 2;
  FOR(i,0,1<<N2) {
    ll sum_v = 0, sum_w = 0;
    FOR(j,0,N2) {
      if(i&(1<<j)) {
        sum_v += v[j];
        sum_w += w[j];
      }
    }
    vec.push_back(P(sum_w, sum_v));
    //cout << sum_w << " " << sum_v << endl;
  }
  sort(vec.begin(), vec.end());
  ll max_v = 0;
  FOR(i,0,vec.size()) {
    if(vec[i].second < max_v) {
      vec[i].second = max_v;
    } else {
      max_v = vec[i].second;
    }
    // cout << vec[i].first << " " << max_v << endl;
  }
  ll ans = 0;
  FOR(i,0,1<<(N-N2)) {
    ll sum_v = 0, sum_w = 0;
    FOR(j,0,N-N2) {
      if(i&(1<<j)) {
        sum_v += v[j+N2];
        sum_w += w[j+N2];
      }
    }
    int k = upper_bound(vec.begin(), vec.end(), P(W - sum_w, 1e17)) - vec.begin();
    //cout << "upper " << W - sum_w << " " << sum_v << " " << k << endl;
    k = max(k - 1, 0);
    if(sum_w + vec[k].first <= W) {
      ans = max(ans, sum_v + vec[k].second);
    }
  }
  cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  
  s.erase(3);
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000+10
int n,a[MAXN];
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
bool f(){
    long long sum=0;
    bool flag=0;
    int num=0;
    for(int i=1;i<=n;i++){
        sum+=a[i]-1;
        if(a[i]&1)num++;
        if(a[i]==1)flag=1;
    }
    if(flag)return sum%2;
    if((n-num)%2)return 1;
    if(num==1){
        int g=0;
        for(int i=1;i<=n;i++)
            if(a[i]&1)a[i]--;
        for(int i=1;i<=n;i++)g=gcd(g,a[i]);
        for(int i=1;i<=n;i++)a[i]/=g;
        return f()^1;
    }
    return 0;

}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    if(f())printf("First");
    else printf("Second");
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll sp1[5050][5050],sp[5050],dp[5050][5050][2];

int main(void){
	int n,a,b,i,j,k;
	ll ans = 0ll, tmp;
	std::cin >> n >> a >> b;
	/*
	if(a==b){
		dp[0][0][0] = 1ll;
		ans = 1ll;
		for(i=0; i<n; ++i){
			mul_mod(ans,2ll);
			for(j=0; j<a; ++j){
				for(k=0; k<2; ++k){
					add_mod(dp[i+1][j+1][k],dp[i][j][k]);
					add_mod(dp[i+1][1][k^1],dp[i][j][k]);
				}
			}
		}
		for(i=0; i<a; ++i){
			add_mod(ans,MOD-dp[n][i][0]);
			add_mod(ans,MOD-dp[n][i][1]);
		}
		std::cout << ans << std::endl;
	}
	*/
	if(a>b){
		std::swap(a,b);
	}
	// std::fill(dp[0][0],dp[5050][0],0ll);
	n += 2;
	sp[1] = 1ll;
	for(i=1; i<n; ++i){
		for(j=0; j<n; ++j){
			add_mod(sp1[i+1][j+1],sp1[i][j]);
		}
		for(j=a; j<n; ++j){
			add_mod(sp[i+1],sp1[i][j]);
		}
		add_mod(sp[i+1],sp[i]);
		add_mod(sp1[i+1][1],sp[i]);
	}
	for(i=1; i<=n; ++i){
		add_mod(dp[i][0][i>b],sp[i]);
	}
	for(i=0; i<n; ++i){
		for(k=0; k<2; ++k){
			tmp = 0ll;
			for(j=0; j<a; ++j){
				add_mod(dp[i+1][j+1][k],dp[i][j][k]);
				if(j){
					add_mod(tmp,dp[i][j][k]);
				}
			}
			for(j=1; i+j<n; ++j){
				add_mod(dp[i+j][0][k||j>=b],tmp*sp[j]%MOD);
			}
			add_mod(dp[n][0][k||n-i>b],tmp*sp[n-i]%MOD);
		}
	}
	std::cout << dp[n][0][1] << std::endl;
	return 0;
}


Measured memory_bytes: 595628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, ans = 0, cnt; sc(n)
    string s; cin >> s;
    string tmp1, tmp2;
    map<char, int> mp;
    for (int i = 1; i < n; i++){
        tmp1 = s.substr(i);
        tmp2 = s.substr(0, i);
        mp.clear();
        for (int j = 0; j < tmp1.size(); j++){
            if (mp.find(tmp1[j]) == mp.end()) ++mp[tmp1[j]];
        }
        for (int j = 0; j < tmp2.size(); j++){
            if (mp.find(tmp2[j]) != mp.end()) ++mp[tmp2[j]];
        }
        cnt = 0;
        for (const auto &x :mp) if (x.second >= 2) cnt++;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
L, R = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))
L = np.array(L, dtype=int)
R = np.array(R, dtype=int)

LI = L.argsort()[::-1]
RI = R.argsort()

used = np.zeros(N, dtype=bool)
a1 = 0
n = 0
l = 0
r = 0
while True:
    while l < N and used[LI[l]]:
        l += 1
    if l >= N:
        break
    a1 += max(n, L[LI[l]]) - n
    n = max(n, L[LI[l]])
    used[LI[l]] = True

    while r < N and used[RI[r]]:
        r += 1
    if r >= N:
        break
    a1 += n - min(n, R[RI[r]])
    n = min(n, R[RI[r]])
    used[RI[r]] = True
a1 += abs(n)

used = np.zeros(N, dtype=bool)
a2 = 0
n = 0
l = 0
r = 0
while True:
    while r < N and used[RI[r]]:
        r += 1
    if r >= N:
        break
    a2 += n - min(n, R[RI[r]])
    n = min(n, R[RI[r]])
    used[RI[r]] = True

    while l < N and used[LI[l]]:
        l += 1
    if l >= N:
        break
    a2 += max(n, L[LI[l]]) - n
    n = max(n, L[LI[l]])
    used[LI[l]] = True
a2 += abs(n)

print(max(a1, a2))


Measured memory_bytes: 67272
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=10;
int N,A[MAX_N];
int main(){
	cin>>N;
	REP(i,N){cin>>A[i];
	}
	int ans=1;
	REP(i,N)ans*=3;
	int sb=1;
	REP(i,N){
		if(A[i]%2==0){
			sb*=2;
		}
	}
	cout<<ans-sb<<endl;
}

Measured memory_bytes: 256
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  ll a, b;
  ll sum = 0;
  cin >> a >> b;

  if (a >= 13)
  {
    sum += b;
  }
  else if (a >= 6)
  {
    sum += b / 2;
  }
  else
  {
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

#define oo 0xffffff
#define endl '\n'
int ten = 10;
using namespace std;

char s[1000001];

int main (){
    long long int t,n,i,j,m,res1;
    cin >> n;
    if(n==1){
        cout << "0";
        return 0;
    }
    long long int res = sqrt(n);
    int cnt=0;
    for(i=2;i*i<=n;i++){
        if(n%i==0){
            j=i;
            while(n%j==0){
                n/=j;
                j*=i;
                cnt++;
            }
            while(n%i==0){
                n/=i;
            }
        }
    }
    if(n>1) cnt++;
    cout << cnt ;

}


Measured memory_bytes: 3668
#include<stdio.h>
//小さい順にソート
int c[202][3];
void merge(int i,int j,int s[][3]){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d][0]=s[b][0];
        c[d][1]=s[b][1];
        c[d][2]=s[b][2];
        b++;
      }
      else if(j<b){
        c[d][0]=s[a][0];
        c[d][1]=s[a][1];
        c[d][2]=s[a][2];
        a++;
      }
      else if(s[a][1]<s[b][1]){
        c[d][0]=s[a][0];
        c[d][1]=s[a][1];
        c[d][2]=s[a][2];
        a++;
      }
      else{
        c[d][0]=s[b][0];
        c[d][1]=s[b][1];
        c[d][2]=s[b][2];
        b++;
      }
    }
    for(d=i;d<=j;d++){
      s[d][0]=c[d][0];
      s[d][1]=c[d][1];
      s[d][2]=c[d][2];
    }
  }
}

int main(){
  int n,max=0,countnum=0,i,j;
  scanf("%d",&n);
  int a[201][3],count[101];
  for(i=0;i<n;i++){
    a[i][0]=0;
    scanf("%d%d",&a[i][1],&a[i][2]);
  }
  for(i=n;i<2*n;i++){
    a[i][0]=1;
    scanf("%d%d",&a[i][1],&a[i][2]);
  }
  merge(0,2*n-1,a);
  for(i=0;i<2*n;i++){
    if(a[i][0]==0){
      count[countnum]=a[i][2];
      for(j=countnum;j>0;j--){
        if(count[j]<count[j-1]){
          int c=count[j];
          count[j]=count[j-1];
          count[j-1]=c;
        }
      }
      countnum++;
    }
    else{
      if(a[i][2]>count[0] && countnum>0){
        max++;
        for(j=0;j<countnum;j++)
          if(a[i][2]<count[j])
            count[j-1]=count[j];
        countnum--;
      }
    }
  }
  printf("%d\n",max);
  return 0;
}


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

int R, G, B, n, ans;

int main(){
	scanf("%d %d %d %d", &R, &G, &B, &n);
	for(int r = 0; r <= n; ++r){
		for(int g = 0; g <= n; ++g){
			int rem = n-(R*r)-(G*g);
			if(rem < 0) continue;
			if(rem%B != 0) continue;
			ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,d,e;
  cin>>a>>b;
  c=a+b;
  d=a-b;
  e=a*b;
  if(c>=d && c>=e)
    cout<<c<<endl;
  else if(d>=c && d>=e)
    cout<<d<<endl;
  else
    cout<<e<<endl;
}

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

long long add(string s, int v) {
  long long sum = 0, p = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += pow(10, i - p) * (s[s.size() - 1 - i] - '0');
    if (1 << i & v) {
      p = i + 1;
    }
  }
  return sum;
}

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

  long long sum = 0;
  for (int i = 0; i < (1 << s.size() - 1); i++) {
    sum += add(s, i);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll l;
   cin>>l;
   
   ll temp = l;
   ll lim = 0;
   while(temp>0)
   {
       temp>>=1;
       lim++;
       //cout<<"temp = "<<temp<<" and lim = "<<lim<<"\n";
   }
   
   //cout<<"lim = "<<lim<<"\n";
   
   ll curr = 0;
   vector<pair<ll,ll>> hold[lim];
   ll cnt = 0;
   
   for(ll i=lim-1;i>-1;i--)
   {
       if(i == lim-1)
       {
           //hold[0].pb(mp(lim-i,0));
           //cnt++;
           curr = 1;
           continue;
       }
       
       hold[lim-1-(i+1)].pb(mp(lim-i-1,0));
       hold[lim-i-2].pb(mp(lim-i-1,curr));
       cnt+=2;
       ll inc = 0;
       if((1ll<<i)&l)
       {
           inc++;
           hold[0].pb(mp(lim-i-1,2*curr));
           cnt++;
       }
       
       curr<<=1;
       curr+=inc;
   }
   
   cout<<lim<<" "<<cnt<<"\n";
   for(ll i=0;i<lim;i++)
   {
       for(auto it = hold[i].begin();it!=hold[i].end();it++)
            cout<<i+1<<" "<<it->first+1<<" "<<it->second<<"\n";
   }
   
   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++)
using ll = long long;

int main(){
  ll ans = 1, k = 1e18;
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
    if(a[i]==0){
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i,n){
    k /= a[i];
    if(k == 0){
      cout << -1 << endl;
      return 0;
    }

    ans *= a[i];
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#include <bitset>
#include <algorithm>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, int>;

const ll INF = 1e18;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};


int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si; --sj; --ti; --tj;

    vector<string> g(h);
    rep(i, h) cin >> g[i];

    auto toId = [&](int i, int j, int v) {
        return (i*w + j)*4 + v;
    };
    auto modCeil = [&](ll x) {
        return (x + k - 1)/k*k;
    };

    vector<ll> dist(h*w*4, INF);
    priority_queue<LP, vector<LP>, greater<LP>> q;
    auto push = [&](int i, int j, int v, ll x) {
        int id = toId(i, j, v);
        if (dist[id] <= x) return;
        dist[id] = x;
        q.emplace(x, id);
    };
    rep(v, 4) push(si, sj, v, 0);
    while (!q.empty()) {
        ll d = q.top().first;
        int id = q.top().second;
        q.pop();
        if (dist[id] != d) continue;
        int i = id/w/4;
        int j = id/4%w;
        int v = id%4;
        rep(nv, 4) push(i, j, nv, modCeil(d));

        int ni = i + di[v], nj = j + dj[v];
        if (0 <= ni && ni < h && 0 <= nj && nj < w) {
            if (g[ni][nj] == '.') {
                push(ni, nj, v, d+1);
            }
        }
    }

    ll ans = INF;
    rep(v, 4) ans = min(ans, dist[toId(ti, tj, v)]);
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        ans = modCeil(ans)/k;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 44104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] L = new long[87];
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= N; i++) {
      L[i] = L[i - 1] + L[i - 2];
    }
    System.out.println(L[N]);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int a,b; cin>>a>>b; 
  int c; 
  //compute
  if(b<10){
    c=a*10+b;
  }else if(b<100){
    c=a*100+b;
  }else{
    c=a*1000+b;
  }
  int sum=0;
  int value=0;
  for(int i=1;i*i<c+1;i++){
    value=i;
  }
  for(int i=1;i*i<c+1;i++){
    if(c==i*i){
      cout<<"Yes"<<endl;    
      break;
    }else{
      sum++;
    }
  }
  if(sum==value){
    cout<<"No"<<endl;
  }
  
}
  



Measured memory_bytes: 256
s = input()

for i in range(len(s)):
    if s[i] == "C":
        break
    elif i == len(s) - 1:
        print("No")

if i != len(s) - 1:
    for j in range(i, len(s)):
        if s[j] == "F":
            print("Yes")
            break
        elif j == len(s) - 1:
            print("No")

Measured memory_bytes: 3060
#!/usr/bin/perl
#abc086_c.pl
#Sun Jan 21 21:07:11 2018
#

use warnings;
use strict;

my $n = <STDIN>;
chomp $n;

my $loopnum = $n;

my $px = 0;
my $py = 0;
my $pt = 0;

my $flag = 0;

while ($loopnum > 0){
	my $stdin = <STDIN>;
	chomp $stdin;
	my @temps = split(" ",$stdin);
	my $t = $temps[0];
	my $x = $temps[1];
	my $y = $temps[2];
	if (abs($x-$px)+abs($y-$py) <= ($t-$pt) && ($t-$pt-abs($x-$px)-abs($y-$py))%2 == 0){
	}else{
		$flag = 1;
	}

	$pt = $t;
	$px = $x;
	$py = $y;

	$loopnum--;
}

if ($flag == 0){
	print "Yes\n";
}else {
	print "No\n";
}






Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
using namespace std;



int main(){
  int N;
  cin >> N;
  if (N %2 == 0) {
    cout << N/2 << endl;
  }
  else{
    cout << N/2 + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
def pm(input_list):
    calc_result = [0]
    cnt = 0
    
    for i in range(n):
        if i % 2 == 0: plus = True
        else: plus = False

        x = input_list[i] + calc_result[i]
        if plus:
            if x > 0:
                calc_result.append(x)
            
            else:
                cnt += 1 - x
                calc_result.append(1)

        else:
            if x < 0:
                calc_result.append(x)
            
            else:
                cnt += abs(-1 - x)
                calc_result.append(-1)

    return cnt

def mp(input_list):
    calc_result = [0]
    cnt = 0
    
    for i in range(n):
        if i % 2 == 0: minus = True
        else: minus = False

        x = input_list[i] + calc_result[i]
        if minus:
            if x < 0:
                calc_result.append(x)
            
            else:
                cnt += abs(-1 - x)
                calc_result.append(-1)

        else:
            if x > 0:
                calc_result.append(x)
            
            else:
                cnt += 1 - x
                calc_result.append(1)

    return cnt


n = int(input())
input_list = list(map(int, input().split()))

print(min(pm(input_list), mp(input_list)))

Measured memory_bytes: 14648
#include <bits/stdc++.h>
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
   ll T,n,m,l,b,a,k;
   string s;
   cin>>s;
   if(s=="ABC")
   {cout<<"ARC"<<endl;}
   else
   {
       cout<<"ABC"<<endl;
   }
	return 0;
}


Measured memory_bytes: 3620
<?php
//error_reporting(0);
$K = trim(fgets(STDIN));
//list($x1,$y1,$x2,$y2) = explode(" ",trim(fgets(STDIN)));
//$A = explode(" ",trim(fgets(STDIN)));

$temps=kumiawase(range(1,$K),2);
$res=0;

foreach($temps as $v) {
  if ((($v[0] % 2)==0 && ($v[1] % 2) == 1)||
     (($v[1] % 2)==0 && ($v[0] % 2) == 1))
      $res++;
}
printf("%d\n",$res);

function kumiawase($zentai,$nukitorisu){
  $zentaisu=count($zentai);
  if($zentaisu<$nukitorisu){
    return;
  }elseif($nukitorisu==1){
    for($i=0;$i<$zentaisu;$i++){
      $arrs[$i]=array($zentai[$i]);
    }
  }elseif($nukitorisu>1){
    $j=0;
    for($i=0;$i<$zentaisu-$nukitorisu+1;$i++){
      $ts=kumiawase(array_slice($zentai,$i+1),$nukitorisu-1);
      foreach($ts as $t){
        array_unshift($t,$zentai[$i]);
        $arrs[$j]=$t;
        $j++;
      }
    }
  }
  return $arrs;
}


Measured memory_bytes: 6516
#include<stdio.h>
int main(void)
{
    int l,m[12],n[12],i,sum,cnt;
    while(1){
        sum=0,cnt=0;
        scanf("%d",&l);
        if(l==0)break;
        for(i=0;i<12;i++)
        {
            scanf("%d%d",&m[i],&n[i]);
        }
        for(i=0;sum<l && i<12;i++)
        {
            sum+=m[i]-n[i];
        }
        if(sum>=l)
        printf("%d\n",i);
        else
            printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long int lli;
int main(void)
{
    lli N, K, Q;
    scanf("%lld %lld %lld", &N, &K, &Q);
    lli *A;
    A = (lli *)malloc(sizeof(lli) * Q);
    for (lli i = 0; i < Q; i++)
    {
        scanf("%lld", &A[i]);
    }
    lli *point;
    point = (lli *)malloc(sizeof(lli) * N);
    for (lli i = 0; i < N; i++)
    {
        point[i] = K;
    }
	
  lli* win;
  win = (lli*)malloc(sizeof(lli)*N);
  for(lli i=0;i<N;i++){
  	win[i] = 0;
  }
    for (lli i = 0; i < Q; i++)
    {
             win[A[i]-1]++; 
    }
  	for(lli i=0;i<N;i++){
    	point[i] += (win[i]-Q);
    }
    for (lli i = 0; i < N; i++)
    {
        if (point[i] > 0)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < n; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)

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

    ll n, k;
    cin >> n >> k;
    n = n % k;
    cout << min(n, k - n);
}

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

int main() {

	unsigned int height[10];

	for (int i = 0; i < 10; i++)
	{
		cin >> height[i];
	}

	sort(height, height + 10);

	cout << height[9] << endl;
	cout << height[8] << endl;
	cout << height[7] << endl;

	return 0;
}

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

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

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

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

    double sum = (v[0] + v[1]) / pow(2.0, n-1);
    int counter = n-2;
    for(int i=2; i<n; i++){
        sum += v[i] / pow(2.0,counter);
        counter -= 1;
    }
    cout << fixed << setprecision(10) << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_lst = []
b_lst = []
clear = 0
cnt = 0
for i in range(n):
  a, b = map(int, input().split())
  a_lst.append(a)
  b_lst.append(b)

for a, b in zip(a_lst, b_lst):
  if a == b:
    cnt += 1
  else:
    cnt = 0

  if cnt == 3:
    clear = 1
    break

if clear == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,kk;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<1<<endl;
        exit(0);
    }
    if(c>=b)
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)kk=1;
    cout<<((a-b)/(b-c)+kk)*2+1<<endl;
    return 0;
}

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

bool Search(deque<char>& rdeqc, char c) {
  for (deque<char>::iterator itc = rdeqc.begin(); itc != rdeqc.end(); itc++) {
    if(*itc == c) return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    deque<char> deq;
    for(int j = 0; j < s.size(); j++) {
      if(j == 0) deq.push_front(s[j]);
      if(j%3 == 2) {
	if(Search(deq, s[j+1])) continue;
	if(s[j] == '>') deq.push_back(s[j+1]);
	else deq.push_front(s[j+1]);
      }
    }
    
    for(int i = 0; i < deq.size(); i++) cout << deq[i];
    cout << endl;
  }
}

Measured memory_bytes: 1204
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;

int reversepoland(string &exp){
	int i;
	
	vector<string> token;
	for(i=0;i<exp.length();i++)token.push_back(exp.substr(i,1));
	vector<int> resolveNumber;
	vector<string> resolveString;
	for(i=0;i<token.size();i++){
		char *p=NULL;
		double d=strtod(token[i].c_str(),&p);
		if(p-token[i].c_str()==token[i].size()){
			resolveNumber.push_back(d);
			resolveString.push_back(token[i]);
		}else{
			//if(resolveNumber.size()<2){printf("stack few\n");return;}
			int d2=resolveNumber[resolveNumber.size()-1],d1=resolveNumber[resolveNumber.size()-2];
			resolveNumber.pop_back(),resolveNumber.pop_back();
			string s2=resolveString[resolveString.size()-1],s1=resolveString[resolveString.size()-2];
			resolveString.pop_back(),resolveString.pop_back();
			int ret;
			
			if(token[i]=="+"){ret=d1+d2;}
			else if(token[i]=="-"){ret=d1-d2;}
			else if(token[i]=="*"){ret=d1*d2;}
			//else if(token[i]=="/"){ret=d1/d2;}
			//else if(token[i]=="%"){ret=d1%d2;}
			//else if(token[i]=="**"){ret=pow(d1,d2);}
			//else{printf("unknown OP %s\n",token[i].c_str());return;}
			
			resolveNumber.push_back(ret);
			resolveString.push_back("("+s1+token[i]+s2+")"); //this won't emit "optimized" expression. full of parens.
		}
	}
	//if(resolveNumber.size()!=1){printf("result stack not 1");return;}
	if(resolveNumber[0]!=10)return 0;
	printf("%s\n",resolveString[0].c_str());
	return 1;
}
// nnnnooo,nnnonoo,nnonnoo,nnnoono,nnonono
int x[][3]={{4,5,6},{3,5,6},{2,5,6},{3,4,6},{2,4,6}};
char *op="+-*";
main(){
	int a[4],i,j,k,l,L=sizeof(x)/sizeof(*x);
	string s="0000000";
	for(;scanf("%d%d%d%d",a,a+1,a+2,a+3),a[0]|a[1]|a[2]|a[3];){
		sort(a,a+4);
		do{
			for(i=0;i<L;i++){
				for(k=j=0;j<7;j++){
					if(find(x[i],x[i]+3,j)==x[i]+3)s[j]=a[k++]+'0';
				}
				for(j=0;j<3;j++){
					s[x[i][0]]=op[j];
					for(k=0;k<3;k++){
						s[x[i][1]]=op[k];
						for(l=0;l<3;l++){
							s[x[i][2]]=op[l];
							if(reversepoland(s))goto done;
						}
					}
				}
			}
		}while(next_permutation(a,a+4));
		puts("0");
		done:;
	}
}

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  int s=0;
  for(int i=0;i<n;i++){
    cin>>c.at(i);
    s+=c.at(i);
    for(int j=0;j<m;j++)
      cin>>a.at(i).at(j);
  }
  int mi=s+1;
  for(int b=0;b<(1<<n);b++){
    int bc=b;
    vector<int> d(n);
    for(int i=0;i<n;i++){
      d.at(i)=bc%2;
      bc/=2;
    }
    vector<int> sa(m,0);
    int sc=0;
    for(int i=0;i<n;i++){
      sc+=c.at(i)*d.at(i);
      for(int j=0;j<m;j++)
        sa.at(j)+=a.at(i).at(j)*d.at(i);
    }
    bool f=1;
    for(int j=0;j<m;j++)
      if(sa.at(j)<x)
        f=0;
    if(f)
      mi=min(mi,sc);
  }
  cout<<(mi!=s+1?mi:-1)<<endl;
}

Measured memory_bytes: 3636
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
  public static void main(String args[] ) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String s = "";
    int[] list = new int[100];
    while((s = br.readLine()) != null){
      int n = Integer.parseInt(s);
      list[(n-1)] += 1;
    }

    int max = 0;
    for ( int l: list) {
      if (l > max) {
        max = l;
      }
    }

    for (int i = 0; i < 100; i++) {
      if (list[i] == max) {
        System.out.println(i+1);
      }
    }

  }
}

Measured memory_bytes: 24188
#include <iostream>

using namespace std;

int main()
{
    int N, K, tmp;
    cin >> N >> K;
    for (int i = 0; i < N; ++i){
        cin >> tmp;
    }
    int res = 1;
    if (K < N){
        N -= K;
        K -= 1;
        res += N / K;
        if (N % K) res += 1;
    }
    cout << res << endl;
}

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


int main(void) {
    int N;
    scanf("%d",&N);
    int A[N+1];
    int B[N+1];
    int C[N];
  memset(A, 0, N+1*sizeof(*A));
  memset(B, 0, N+1*sizeof(*B));
  memset(C, 0, N*sizeof(*C));
    for (int i=1;i<=N;i++){
        scanf("%d",&A[i]);
    }
    for (int i=1;i<=N;i++){
        scanf("%d",&B[i]);
    }
    for (int i=1;i<N;i++){
        scanf("%d",&C[i]);
    }
    int sum=0;
    for (int i=1;i<=N;i++){
        if (A[i]==A[i-1]+1){sum+=B[A[i]]+C[A[i-1]];}
        else sum+=B[A[i]];
    }
    printf("%d",sum);



return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int h,m,s,total;
    scanf("%d",&total);
    h=total/3600;//時
    total-=h*3600;
    m=total/60;//分
    total-=m*60;
    s=total;//秒
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n);
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(cnt[p] == -1) continue;
        if(s == "AC"){
            ans1++; ans2 += cnt[p]; cnt[p] = -1;
        }else {
            cnt[p]++;
        }
    }
    cout << ans1 << " " << ans2 << "\n";
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		
		int west = 0;
		int east = 0;
		int sum = N;
		
		for(int i = 0; i < N; i++) {
			if(S.charAt(i) == 'E') {
				east++;
			}
		}
		
		for(int i = 0; i < N; i++) {
			if(S.charAt(i) == 'E') {
				east--;
			} 
			if( i > 0) {
				if(S.charAt(i - 1) == 'W') {
					west++;
				}
			}
			sum = Math.min(sum, west + east);
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 28984
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }

template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve(){
    int x, k, d;
    cin>>x>>k>>d;
    x = abs(x);
    int alpha = x / d, ans=0;
    int beta = x - alpha * d;

    if (k <= alpha) {
        ans = x - k * d;
    } else {
        if ((k - alpha) % 2 == 0) {
            ans = beta;
        } else {
            ans  = d - beta;
        }
    }
    cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}


Measured memory_bytes: 3624
a = []
for i in range(20):
    n = int(input())
    a.append(n)
x = a[0:10]
y = a[10:20]
X = sorted(x, reverse=True)
Y = sorted(y, reverse=True)
b = X[0]+X[1]+X[2]
c = Y[0]+Y[1]+Y[2]
print(b, c)


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
typedef long long ll;
const ll MOD = 1e9+7;
int main(int argc,char **argv){
    (void)argc;
    (void)argv;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,x,t;
    cin>>n>>x>>t;
    ll mod=(n%x)?1:0;
    cout<<(n/x)*t+t*mod<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>

int main(){
	int A,B,C;
	std::cin >> A >> B >> C;
	
	if((A < C) && (B > C)){
		std::cout << "Yes\n" ;
	}else if((A > C) && (B < C)){
		std::cout << "Yes\n" ;
	}else{
		std::cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
M, K = map(int, input().split())

if M==1:
    if K==0:
        print(0, 0, 1, 1)
    else:
        print(-1)
    
    exit()

if K>2**M-1:
    print(-1)
    exit()

l = [i for i in range(2**M) if i!=K]
print(*(list(reversed(l))+[K]+l+[K]))

Measured memory_bytes: 103216
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> vs(n);
    rep(i, 0, n){
        cin >> vs[i];
    }
    int ans = 0;
    int cnt[2][2] = {};
    rep(i, 0, n){
        for(int j = 0; j < vs[i].size() - 1; j++){
            if(vs[i][j] == 'A' && vs[i][j + 1] == 'B') ans++;
        }
        bool aEnd = false;
        bool bStart = false;
        if(vs[i][0] == 'B') bStart = true;
        if(vs[i][vs[i].size() - 1] == 'A') aEnd = true;
        cnt[bStart][aEnd]++;
    }
    if(cnt[1][1]){
        ans += cnt[1][1] - 1;
        if(cnt[0][1]){
            cnt[0][1]--; ans++;
        }
        if(cnt[1][0]){
            cnt[1][0]--; ans++;
        }
    }
    ans += min(cnt[0][1], cnt[1][0]);    
    cout << ans << endl;
}

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

int main () {
    while (1) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;

        int L[n];
        for (int i = 0; i < n; i++) L[i] = i + 1; 
        int C = 0;
        for (int j = 0; j < n-2; j++) {
            int a;
            a = L[j];
            for (int k = j + 1; k < n-1; k++) {
                int b;
                b = L[k];
                for (int l = k + 1; l < n; l++) {
                    int c;
                    c = L[l];
                    int Total = 0;
                    Total = a + b + c;
                    if (Total == x) {
                        ++C;
                    }
                }
            }
        }
        cout << C << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
import itertools 
n = int(input())
p = list((map(int,input().split())))
q = list((map(int,input().split())))


n_list = range(1,n+1)
n_list = itertools.permutations(n_list,n)

cnt = 0
for i ,j in enumerate(n_list):
    #print(i,j)
    j = list(j)
    if j == p:
        x = i + 1
    if j == q:
        y = i + 1
print(abs(x-y))



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, W; cin >> H >> W;
    ll a[H][W];
    rep(i, H){rep(j, W){
        char c; cin >> c;
        if (c == '#'){
            a[i][j] = 1;
        } else {
            a[i][j] = 0;
        }
    }}
    vector<ll> xcoords, ycoords;
    rep(i, H){
        ll tmp = 0;
        rep(j, W){tmp += a[i][j];}
        if (tmp != 0){ycoords.push_back(i);}
    }
    rep(j, W){
        ll tmp = 0;
        rep(i, H){tmp += a[i][j];}
        if (tmp != 0){xcoords.push_back(j);}
    }
    for (auto y: ycoords){
        for (auto x: xcoords){
            if (a[y][x]){cout << "#";} else {cout << ".";}
        }
        cout << endl;
    }
}

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


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int N, M, an1, an2;
    std::cin >> N >> M;

    an1 = N*(N-1)/2;
    if (an1<=0){
        an1=0;
    }

    
    an2 = M*(M-1)/2;
    if (an2<=0){
        an2=0;
    }

    cout << an1+an2 << endl;

}

Measured memory_bytes: 256