akhauriyash/Code-Regression huggingface dataset:
#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>;

void Main()
{
  int N; cin >> N;
  vector<int> A(N);
  vector<int> ai_tasu_i(N);
  vector<int> aj_hiku_j(N);
  unordered_map<int,int> ut;
  unordered_map<int,int> uh;
  ll cnt = 0;
  rep(i,N) {
    cin >> A[i];
    
    //if (uh.find(-A[i]+i) == uh.end()) uh[-A[i]+i] = 1;
    //else uh[-A[i]+i]++;
    if (ut.find(-A[i]+i) != ut.end()) cnt += ut[-A[i]+i];
    
    ai_tasu_i[i] = A[i] + i;
    if (ut.find(A[i]+i) == ut.end()) ut[A[i]+i] = 1;
    else ut[A[i]+i]++;
    aj_hiku_j[i] = -A[i] + i;
    
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 13592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<ll> vecll;
typedef vector<ld> vecld;
typedef vector<bool> vecbl;
typedef vector<vector<ll> > matll;
typedef vector<vector<ld> > matld;
typedef vector<vector<bool> > matbl;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

// nのk乗(mod p = prime)
ll power(ll n, ll k) {
	ll p = prime;
	if (k == 1) {
		return n;
	}
	ll m = n * n;
	m %= p;
	if (k % 2 == 0) {
		return power(m, k / 2);
	}
	m = power(m, k / 2);
	m *= n;
	m %= p;
	return m;
}

// nCk(mod p = prime)
ll com(ll n, ll k) {
	// nCk
	ll p = prime;

	ll ans = 1;
	for (ll i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= p;
	}

	for (ll i = 2; i <= k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	for (ll i = 2; i <= n-k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	return ans;
}

vector<pll> pfac(ll n) {
	// prime factorization
	ll m = n;
	vecll primes;
	for (ll i = 2; i <= n; i++)
	{
		if (m % i == 0) {
			while (true) {
				primes.push_back(i);
				m /= i;
				if (m % i == 0) {
					continue;
				}
				else {
					break;
				}
			}
		}
		if (m == 1) {
			break;
		}
	}

	vector<pll> primep;
	ll pre, now, index;
	pre = -1;
	index = 0;
	for (ll i = 0; i < primes.size(); i++)
	{
		now = primes[i];
		if (pre == now) {
			primep[index].second++;
		}
		else {
			index++;
			primep.push_back(make_pair(now, 1));
			pre = now;
		}
	}

	return primep;

}

vecll divisors(vector<pll> primep) {
	vecll primes, primes2;
	for (ll j = 0; j < primep[0].second; j++)
	{
		primes.push_back(pow(primep[0].first, j));
	}

	for (ll i = 1; i < primep.size(); i++)
	{
		primes2 = vecll();
		for (ll j = 0; j < primes.size(); j++)
		{
			for (ll k = 0; k < primep[i].second; k++)
			{
				primes2.push_back(primes[j] * pow(primep[i].first, k));
			}
		}
		primes = vecll();
		for (ll i = 0; i < primes2.size(); i++)
		{
			primes[i] = primes2[i];
		}
	}

	return primes;
}

int gcd(int a1, int b1) {
	int a, b;
	a = max(a1, b1);
	b = min(a1, b1);
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

ll gcd(ll a, ll b, ll c) {
	return gcd(gcd(a, b), c);
}


int main() {
	//
	int K, gcd1, sum;
	sum = 0;
	cin >> K;
	for (int i = 1; i <= K; i++)
	{
		for (int j = 1; j <= K; j++)
		{
			gcd1 = gcd(i, j);
			if (gcd1 == 1) {
				sum += K;
				continue;
			}
			for (int k = 1; k <= K; k++)
			{
				sum += gcd(gcd1, k);
			}
		}
	}

	cout << sum << endl;

	return 0;
}


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

typedef long long ll;

int main() {
  int n; cin >> n;
  vector<ll> la(n);
  for (ll &a: la) cin >> a;
  ll x = la[0];
  for (int i = 1; i < n; ++i) { 
    if (i % 2) x -= la[i];
    else x += la[i];
  }
  cout << x;
  for (int i = 0; i < n-1; ++i) {
    x = 2*la[i]-x;
    cout << " " << x;
  }
  cout << endl;
}



Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	//freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    n *= 2;
    int l[n];
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l, l + n);
    
    int total = 0;
    for(int i = 0; i < n; i += 2){
        total += min(l[i], l[i + 1]);
    }
    
    cout << total << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(n):
  if a[i]>=b[i]:
    c+=int(b[i])
  else:
    if (a[i]+a[i+1])>=b[i]:
      c+=int(b[i])
      a[i+1]=a[i]+a[i+1]-b[i]
    else:
      c+=int(a[i]+a[i+1])
      a[i+1]=0
print(c)

Measured memory_bytes: 18476
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int[] abc = {a, b, c};
        Arrays.sort(abc);
        System.out.println(abc[0] + abc[1]);
    }
}

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

#define mem(arr,x) memset(arr,x,sizeof(arr))
#define pb push_back
#define ll long long
#define mp make_pair
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define all(x)   (x.begin(),x.end())

const double PI = 3.1415926535897932;
const int mod = 1e9 + 7;  
const int inf = 1e9 + 7;

int max(int a,int b)
{
	if(a>b)
	return a;
	return b;
}

int main()
{
	
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin>>n;
int h[n];
rep(i,n)
cin>>h[i];
vector<int>dp(n,inf);
dp[0]=0;
for(int i=0;i<n;i++)
{
	for(int j=i+1;j<=i+2;j++)
	{
		dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
	}
}
cout<<dp[n-1]<<'\n';

	
	
}


Measured memory_bytes: 4008
#include<iostream>

using namespace std;

int main()
{
	int x, y;
	int a,b;
	cin >> x >> y;

	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
	{
		a = 1;
	}
	else if (x == 4 || x == 6 || x == 9 || x == 11)
	{
		a = 2;
	}
	else if (x == 2)
	{
		a = 3;
	}
	if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
	{
		b = 1;
	}
	else if (y == 4 || y == 6 || y == 9 || y == 11)
	{
		b = 2;
	}
	else if (y == 2)
	{
		b = 3;
	}

	if (a == b)
	{
		cout << "Yes" << endl;
	}
	if (a != b)
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

const int INF = 1000000;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
	}
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		if (v[i] > c[i]) res = res + v[i] - c[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
const int INF = 1e9;
int H, W;
int C[10][10];
int ans;
int to_1_cost[10];
void dijkstra() {
	int min_cost[10];
	priority_queue<pii, vector<pii>, greater<pii>> pq;
	for (int i = 0; i < 10; ++i) {
		fill(min_cost, min_cost + 10, INF);
		min_cost[i] = 0;
		pq.push(pii(0, i));
		while (!pq.empty()) {
			pii now = pq.top(); pq.pop();
			int cost = now.first;
			int id = now.second;
			for (int j = 0; j < 10; ++j) {
				int n_cost = C[id][j];
				if (cost + n_cost < min_cost[j]) {
					min_cost[j] = cost + n_cost;
					pq.push(pii(min_cost[j], j));
				}
			}
		}
		to_1_cost[i] = min_cost[1];
	}
}
int main(void) {
	cin >> H >> W;
	for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) cin >> C[i][j];
	dijkstra();
	for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) {
		int a; cin >> a;
		if (a >= 0) ans += to_1_cost[a];
	}
	cout << ans << endl;
}

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

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

#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 REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    string S;
    cin >> N >> S;
    
    ll left = 0, right = N - 1;
    while(left < N && S[left] == '.') ++left;
    while(right >= 0 && S[right] == '#') --right;

    if(left < right) {
        vec B(N, INF), W(N, INF);
        ll c = 0;
        REP(i,left,right+1) {
            if(S[i] == '#') ++c;
            B[i] = c;   
        }
        c = 0;
        for(ll i=right; i>=left; --i) {
            if(S[i] == '.') ++c;
            W[i] = c;   
        }

        ll m = INF;
        REP(i,left,right) {
            ll a = B[i] + W[i+1];
            ll b = B[i+1] + W[i];
            m = MIN(m,MIN(a,b));
        }
        m = MIN(m,MIN(W[left],B[right]));
        PR(m);
    }
    else PR(0);

    return 0;
}

/*



*/

Measured memory_bytes: 6840
line = input().strip().split(" ")
even = int(line[0])
odd = int(line[1])

if even > 1 and odd <= 1:
    result = (even * (even - 1)) / 2
    print(int(result))
elif even <= 1 and odd > 1:
    result = (odd * (odd -1)) / 2
    print(int(result))
elif even >1 and odd > 1:
    result = (even * (even -1)) / 2 + (odd * (odd - 1)) / 2
    print(int(result))
else:
    print(0)

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int N,M,C;
  cin>>N>>M>>C;
  int A[N][M],B[M];
  rep(i,M)
    cin>>B[i];
  int ans=0;
  rep(i,N){
  int  count=0;
    rep(j,M){
      cin>>A[i][j];
      count+=A[i][j]*B[j];
	}
    if(count+C>0)
      ans++;
  }

  cout<<ans<<endl;

  return 0;
}
  


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input().strip())

C = [0 for i in range(N)]
D = {"r": 0, "s": 0, "p": 0}

for i in range(N):
    if i <= K-1:
        C[i] = 1
        D[T[i]] += 1
    else:
        if T[i] == T[i-K] and C[i-K] == 1:
            continue
        else:
            C[i] = 1
            D[T[i]] += 1

print(D["r"]*P + D["s"]*R + D["p"]*S)

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int N, M;
vector<int> paths[1000000];
int dist[1000000][2];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 2; j++) {
            dist[i][j] = 1e9;
        }
    }
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }
    dist[0][0] = 0;
    queue<i_i> que;
    que.push({0, 0});
    while(!que.empty()) {
        i_i tmp = que.front();
        que.pop();
        int now = tmp.first;
        int idx = tmp.second;
        for(auto to : paths[now]) {
            if(chmin(dist[to][1-idx], dist[now][idx] + 1)) {
                que.push({to, 1 - idx});
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 2; j++) {
            chmax(ans, dist[i][j]);
        }
    }
    if(ans == 1e9) ans = 0;
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 31404
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator> 
#include <limits>

#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define ALL(a) (a).begin(),(a).end()
#define RALL(A) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair

#define dump(x) cerr << #x << " = " << (x) << endl;

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

struct UnionFind {
    vector<int> par;
    int n, cnt;
    UnionFind(const int& x = 0) {init(x);}
    void init(const int& x) {par.assign(cnt=n=x, -1);}
    inline int find(const int& x) {return par[x] < 0 ? x : par[x] = find(par[x]);}
    inline bool same(const int& x, const int& y) { return find(x) == find(y); }
    inline bool unite(int x, int y) {
        if ((x = find(x)) == (y = find(y))) {
            return false;
        }
        --cnt;
        if (par[x] > par[y]) {
            swap(x, y);
        }
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    inline int count() const {return cnt;}
    inline int count(int x) {return -par[find(x)];}
};

int N, K, L;
const int MAX_N = 200000 + 100;

UnionFind uf1(MAX_N);
UnionFind uf2(MAX_N);
map<PII, int> group_cnt;

int main(int argc, char const* argv[])
{
    cin >> N >> K >> L;
    REP(i, K) {
        int p, q; cin >> p >> q;
        uf1.unite(p, q);
    }
    REP(i, L) {
        int r, s; cin >> r >> s;
        uf2.unite(r, s);
    }
    VI anss;
    FOR(i, 1, N + 1) {
        int dou_group_id = uf1.find(i);
        int tetu_group_id = uf2.find(i);
        if (group_cnt.count(make_pair(dou_group_id, tetu_group_id)) == 0) {
            group_cnt[make_pair(dou_group_id, tetu_group_id)] = 1;
        } else {
            group_cnt[make_pair(dou_group_id, tetu_group_id)] += 1;
        }
    }
    FOR(i, 1, N) {
        int dou_group_id = uf1.find(i);
        int tetu_group_id = uf2.find(i);
        cout << group_cnt[make_pair(dou_group_id, tetu_group_id)] << " ";
    }
    int dou_group_id = uf1.find(N);
    int tetu_group_id = uf2.find(N);
    cout << group_cnt[make_pair(dou_group_id, tetu_group_id)] << endl;

    return 0;
}


Measured memory_bytes: 13696
import java.util.Scanner;

public class Main {

	static class Knapsack {

		int n, w;
		int wt[];
		long value[];
		long dp[][];

		Knapsack(int n, int w) {

			this.n = n;
			wt = new int[n];
			value = new long[n];

			dp = new long[n][w + 1];

			for (int i = 0; i < n; i++) {
				for (int j = 0; j <= w; j++)
					dp[i][j] = -1L;
			}
		}

		long maxprofit(int i, int j) {
			
			if(i == n || j == 0)
				return 0;
			
			
			if(dp[i][j] != -1L)
				return dp[i][j];
			
			
			if(wt[i] <= j) {
				
				long left = value[i] + maxprofit(i + 1, j - wt[i]);
				long right = maxprofit(i + 1, j);
				
				return dp[i][j] = Math.max(left, right);
			}
			
			else
				return dp[i][j] = maxprofit(i + 1, j);
		}
	}

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();

		Knapsack a = new Knapsack(n, w);

		for (int i = 0; i < n; i++) {

			a.wt[i] = sc.nextInt();
			a.value[i] = sc.nextLong();
		}

		System.out.println(a.maxprofit(0, w));
		sc.close();
	}

}


Measured memory_bytes: 128696
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2002020;
int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	int n=read(),L=read();
	int ps=-1,lst=0;
	for(int i=1;i<=n;i++){
		int x=read();
		if(i>1 && x+lst>=L){ps=i-1;break;}
		lst=x;
	}
	if(ps<0)puts("Impossible");
	else{
		puts("Possible");
		for(int i=1;i<ps;i++)printf("%d\n",i);
		for(int i=n-1;i>ps;i--)printf("%d\n",i);
		printf("%d\n",ps);
	}
	return 0;
}

Measured memory_bytes: 3732
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
PM = []
for i in range(M):
    PM.append( [i]+ list(map(int, input().split())) )

# print(PM)

city_dict = {}
ken_city_idx = {}
#年でソート
PM.sort(key=lambda x: x[2])

for i,pi,yi in PM:
    # print(ken_city_idx)
    if pi in ken_city_idx:
        ken_city_idx[pi] += 1
    else:
        ken_city_idx[pi] = 1

    city_dict[i] = "{0:0=6}{1:0=6}".format(pi,ken_city_idx[pi])

# print(city_dict)

for k, v in sorted(city_dict.items(), key=lambda x: x[0]):  # key
    print(v)


Measured memory_bytes: 51932
n, a, b = gets.strip.split.map(&:to_i)
ans = []
sum = 0
(1..n).each do |i|
  sum = 0
  num = i
  while num > 0 do
    sum += num%10
    num /= 10
  end
  ans << i if sum >=a && sum <= b
end
puts ans.inject(&:+)


Measured memory_bytes: 1916
from collections import defaultdict

march = list("MARCH")

c = defaultdict(int)
N = int(input())
for i in range(N):
    S = input()
    for a in march:
        if S[0] == a:
            c[a] += 1
            break
        else:
            continue

#print(c)

s = 0
a = [0]*3
for a[0] in march:
    for a[1] in march:
        for a[2] in march:
            if sum(map(lambda x:x in a,march)) != 3:
                continue
            s += c[a[0]] * c[a[1]] * c[a[2]]

print(s // 6)

Measured memory_bytes: 3316
/*Points to be noted :
1)Don't be afraid to fail.
2)Never give up easily,keep trying.
3)Don't care about other ppl's progress.
4)Spend much time on each problem & keep trying. I WILL DO IT!💯*/

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
int binomialCoeff(int n,int k)
{
    int dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=min(i,k);j>0;j--)
        dp[j]=(dp[j]+dp[j-1])%mod;
    }
    return dp[k]%mod;
    
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int n;
    cin>>n;
    if(n>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cassert>
#include <map>
using namespace std;
int x;
struct Subj {
  int64_t b, l, r;

  int64_t GetSum() const {
    return b * 1ll * l + r * 1ll * (x - b);
  }

  int64_t GetSum(int64_t cnt) const {
    if (cnt <= b) {
      return l * cnt;
    } else {
      return l * b + r * (cnt - b);
    }
  }
};
int64_t ans = 1e18;
void RelaxAnswer(int64_t d) {
  ans = min(ans, d);
}

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

  int n;
  cin >> n >> x;
  vector<Subj> subj(n + 1);
  vector<int64_t> sums(n + 1);
  int64_t cur_sum = 0;
  int sm_b = 0;
  for (int i = 0; i < n; i++) {
    cin >> subj[i].b >> subj[i].l >> subj[i].r;
    cur_sum -= subj[i].l * subj[i].b;
    sm_b += subj[i].b; 
  }
  if (sm_b == 0) {
    cout << 0 << endl;
    return 0;
  }
  subj[n].b = 0;
  subj[n].l = 0;
  subj[n].r = 0;
  n++;

  sort(subj.begin(), subj.end(), [](const Subj& lhs, const Subj& rhs) {
      return lhs.GetSum() < rhs.GetSum();
  });
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      sums[i] = subj[i].GetSum();
    } else {
      sums[i] = subj[i].GetSum() + sums[i - 1];
    }
  }
  auto get_on_on = [&](int l, int r) {
    if (l > r) {
      return (int64_t)0;
    }
    int64_t ll = l >= 1 ? sums[l - 1] : 0ll;
    return (int64_t)(sums[r] - ll);
  };
  auto get_on = [&](int l, int id, int64_t val, int r) {
    if (id < l || id > r) {
      return get_on_on(l, r) + val;
    }
    return get_on_on(l, id - 1) + get_on_on(id + 1, r) + val;
  };

  {

    auto can_m = [&](int64_t check_val) {

      for (int i = n - 1; i >= 0; i--) {

        auto i_sum = subj[i].GetSum((check_val % x));
        if (i_sum + cur_sum >= 0) {
          return true;
        }

        int l = 0;
        int r = n - 1;

        auto check_bin = [&](int m) {
          if (get_on(n - 1 - m, i, i_sum, n - 1) + cur_sum >= 0) {
            return true;
          } else {
            return false;
          }
        };

        while (r - l > 1) {
          int m = (l + r) / 2;
          if (check_bin(m)) {
            r = m;
          } else {
            l = m;
          }
        }
        for (int v : {l, r}) {
          if (check_bin(v)) {
            int64_t id_sum = (v + 1) * 1ll * x;
            if (n - v - 1 <= i) {
              id_sum -= (x - (check_val % x));
            }
            if (id_sum <= check_val) {
              return true;
            }
          }
        }
      }
      return false;
    };



    int64_t l = 0;
    int64_t r = 1e11;



    while (r - l > 1) {
      int64_t m = (l + r) / 2;
      if (can_m(m)) {
        r = m;
      } else {
        l = m;
      }
    }
    RelaxAnswer(r);
  }

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

Measured memory_bytes: 3456
#include <iostream>
#include <string>

using namespace std;

int main() {
	string abc = "abcdefghijklmnopqrstuvwxyz";
	
	string s;
	cin >> s;


	bool h = true;
	for (int i = 0; i < abc.size(); i++) {
		if (s.find(abc[i]) == -1) {
			cout << abc[i] << endl;
			h = false;
			break;
		}
	}
	if (h) {
		cout << "None" << endl;
	}

	return 0;
}

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

int main(){
  int l[10];
  int v1,v2, d;
  double t, dis;
  char c;
  while( cin>>l[0] && l[0] ){
    d=l[0];
    for( int i=1;i<10;i++ ){
      cin >> c >> l[i];
      d += l[i];
    }
    cin >> c >> v1 >> c >> v2;

    if( v1==0 )
      cout << 1 << endl;
    else if( v2==0 )
      cout << 10 << endl;
    else{
      t = (double)d/(v1+v2);
      dis = v1*t;
      d=0;
      for( int i=0;i<10;i++ ){
	d += l[i];
	if( 1.0e-8 > dis - d ){
	  cout << (i+1) << endl;
	  break;
	}
	if( i==9 )
	  cout << 10 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
//AtCoder ABC097 A - Colorful Transceivers
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool ans= abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d);
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

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

int main(){
  string s,t;cin >> s >> t;
  ll ans = 0;
  rep(i,s.size()){
    if( s.at(i) != t.at(i) ) ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;

#define MAX_V 300
int d[MAX_V][MAX_V];
int V;
int h, w;
void warshall_floyd() {
	rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

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

  cin >> h >> w;
  rep(i, 0, 10) rep(j, 0, 10) d[i][j] = INF;
  rep(i, 0, 10) rep(j, 0, 10) {
    int c;
    cin >> c;
    d[i][j] = c;
  }

  V = 10;
  warshall_floyd();
  int rsl = 0;
  rep(i, 0, h) rep(j, 0, w) {
    int a;
    cin >> a;
    if(a == -1) continue;
    rsl += d[a][1];
  }
  cout << rsl << endl;

}



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

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> a(m);
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        a[i].resize(k);
        for(int j=0;j<k;j++){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int p[m];
    for(int i=0;i<m;i++) cin >> p[i];
    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        bool flag=true;
        for(int j=0;j<m;j++){
            int c=0;
            for(int id:a[j]){
                if(bit&(1<<id)) c++;
            }
            if(c%2!=p[j]) flag=false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
str = input()
yes = True
if len(str) % 2 == 1:
  yes = False
for i in range(len(str)):
  if (i % 2 == 0 and str[i] != 'h') or (i % 2 == 1 and str[i] != 'i'):
    yes = False
    break
print("Yes" if yes else "No")


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
	int N, M, i;
	cin >> N;
	int a[N], x, t;
	for (i = 0; i < N; i++) 
		cin >> a[i];

	cin >> M;
	int temp;
	while (M--)
	{
		
		cin >> x >> t;
		while (x < t-1)
		{
			temp = a[x];
			a[x] = a[t-1];
			a[t-1] = temp;
			x++;
			t--;
		}
	}

	for (i = 0; i < N; i++)
	{
		if(i) cout << " ";
		cout << a[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3108
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

tot = np.sum(A)
if N < tot:
	print(-1)
else:
	print(N-tot)

Measured memory_bytes: 27772
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int h[n];
    rep(i, n) {
        cin >> h[i];
    }

    int t = h[0];
    int cnt = 0;
    int ans = 0;
    for(int i = 1; i < n; i++) {
        if(i == n-1) {
            if(t >= h[i]) {
                cnt++;
            }
            ans = max(ans, cnt);
            break;
        }

        if(t >= h[i]) {
            t = h[i];
            cnt++;
        }
        else {
            t = h[i];
            ans = max(ans, cnt);
            cnt = 0;
        }
    }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define pb push_back
#define pr pair<int,int>
using namespace std;
using ll = long long;
// using mod = 1000000000 + 7;
void self_max(int &a,int b){
	a = max(a,b);
}

void self_min(int &a,int b){
	a = min(a,b);
}
int main(){
	int n; cin>> n;
	cout << n*n*n << endl;
	return 0;
}



Measured memory_bytes: 3104
package main

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

const MAX = 2000001

type Heap struct {
	tail      int
	container [MAX]int
}

func (h *Heap) add(v int) {
	h.tail++
	h.container[h.tail] = v
}

func (h *Heap) swap(i, j int) {
	h.container[i], h.container[j] = h.container[j], h.container[i]
}

func (h *Heap) getKey(i int) int {
	if i <= h.tail {
		return h.container[i]
	} else {
		return -1
	}
}

func (h *Heap) insert(v int) {
	h.add(v)
	i := h.tail
	for h.getKey(i/2) < h.getKey(i) {
		h.swap(i, i/2)
		i /= 2
	}
}

func (h *Heap) extract() int {
	max := h.container[1]
	h.container[1] = h.container[h.tail]
	h.tail--
	h.rebuild(1)
	return max
}

func (h *Heap) rebuild(i int) {
	left := i * 2
	right := i*2 + 1

	largest := i
	if h.getKey(left) > h.getKey(largest) {
		largest = left
	}
	if h.getKey(right) > h.getKey(largest) {
		largest = right
	}

	if largest != i {
		h.swap(largest, i)
		h.rebuild(largest)
	}
}

var H = Heap{}
var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	H.container[0] = 2000000001
}

func main() {
	for {
		command := scanString()
		switch command {
		case "insert":
			num := scanInt()
			H.insert(num)
		case "extract":
			max := H.extract()
			fmt.Println(max)
		case "end":
			return
		}
	}
}



Measured memory_bytes: 15148
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=2e5+5;
ll ct[M],a[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	int n=sz(s);
	s = "$"+s;
	for(int i=1;i<=n;i++)
		a[i] = s[i]-'0';
	ll c=1;
	ll z=2019;
	ct[0]=1;
	ll ans=0;
	for(int i=n;i>=1;i--)
	{
		a[i]=(a[i]*c+a[i+1])%z;
		c=(c*10)%z;
		ans += ct[a[i]];
		ct[a[i]]++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 5364
def slove(n, a_list):

    dp = [[0]*(n+1) for i in range(n+1)]
    for i in range(n):
        for j in range(n-i):
            dp[i+1][j] = max(dp[i+1][j],
                         dp[i][j]+a_list[i+j][0]*abs(a_list[i+j][1]-i))
            dp[i][j+1] = max(dp[i][j+1],
                         dp[i][j]+a_list[i+j][0]*abs((n-1-j)-a_list[i+j][1]))

    return max([max(i) for i in dp])

if __name__ == "__main__":
    n = int(input())
    k = sorted([(int(x),i) for i,x in enumerate(input().split())], reverse=True)
    print(slove(n, k))


Measured memory_bytes: 100168
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
P v[4][200001]={};

int main() {

	int n,r,c;
	cin>>r>>c>>n;
	int vn[6]={};
//	int x1[100],x2[100],y1[100],y2[100];
	for(int i=0;i<n;++i){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if((((x1==0)||(x1==r))||((y1==0)||(y1==c)))&&(((x2==0)||(x2==r))||((y2==0)||(y2==c)))){
			if(x1==0&&y1<c){
				v[0][vn[0]]=P(y1,i);
				vn[0]++;
			}
			if(y1==c&&x1<r){
				v[1][vn[1]]=P(x1,i);
				vn[1]++;
			}
			if(x1==r&&y1>0){
				v[2][vn[2]]=P(y1,i);
				vn[2]++;
			}
			if(y1==0&&x1>0){

				v[3][vn[3]]=P(x1,i);
				vn[3]++;
			}
			if(x2==0&&y2<c){
				v[0][vn[0]]=P(y2,i);
				vn[0]++;
			}
			if(y2==c&&x2<r){
				v[1][vn[1]]=P(x2,i);
				vn[1]++;
			}
			if(x2==r&&y2>0){
				v[2][vn[2]]=P(y2,i);
				vn[2]++;
			}
			if(y2==0&&x2>0){
				v[3][vn[3]]=P(x2,i);
				vn[3]++;
			}
		}
	}
	sort(v[0],v[0]+vn[0]);
	sort(v[1],v[1]+vn[1]);
	sort(v[2],v[2]+vn[2],greater<P>());
	sort(v[3],v[3]+vn[3],greater<P>());
	stack<int> t;
	for(int j=0;j<4;++j){
		for(int i=0;i<vn[j];++i){
			if(t.empty()||(t.top()!=v[j][i].second)){
				t.push(v[j][i].second);
			}else{
				t.pop();
			}
		}
	}


	if(t.empty()){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}


	return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back

int mod=1e9+7;

main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,m;
	cin>>n>>m;
	int arr[n+1];
	for(int i=0;i<=n;i++)
		arr[i]=0;
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x;
		arr[x]=1;
	}

	for(int i=2;i<=n;i++)
	{
		if(arr[i]==1 and arr[i-1]==1)
		{
			cout<<0;
			return 0;
		}
	}

	int dp[n+1];
	for(int i=0;i<=n;i++)
		dp[i]=0;

	if(arr[1]==0)
		dp[1]=1;
	if(arr[2]==0)
	{
		dp[2]=1;
		if(arr[1]==0)
			dp[2]++;
	}

	for(int i=3;i<=n;i++)
	{
		if(!arr[i])
			dp[i]=(dp[i-1]+dp[i-2])%mod;
	}

	cout<<dp[n];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g;}
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	int k,t; cin >> k >> t;
	vi a(t);
	int ma = 0, sum = 0;
	rep(i, t)
	{
		cin >> a[i];
		chmax(ma, a[i]);
		sum += a[i];
	}
	int x = sum - ma;
	co(max(0,ma - x - 1));
	return 0;
}


Measured memory_bytes: 256
#![allow(unused)]

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;


//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//入力マクロここまで

fn main() {
    input! {
        n: usize,
        x: [i64;n],
    }

    let mut x = x;
    x.sort();

    let b = x[0] as usize;
    let e = x[x.len() - 1] as usize;

    let mut ans = 10000000000000;

    for p in b..e+1 {
        let mut now = 0;
        for i in 0..n {
            now += (x[i] - p as i64) * (x[i] - p as i64);
        }

        if now < ans {
            ans = now;
        }
    }

    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    string s;
    ll k;
    cin >> s >> k;
    bool is1=true;
    for(int i=0; i<k; i++){
        //1以外の要素が出てきたらそれを記録してbreak
        if(s[i] !='1'){
            cout << s[i] << endl;
            return 0;
        }
        //文字列の最後まで来たらbreak
        if(i == s.size()-1){
            break;
        }
    }

    cout << 1 << endl;
    return 0;
    

}

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

#define INT_MIN -2147483648
#define MAX_N 100010
int N, K;
int S[MAX_N];

int main() {
  while (true) {
  cin >> N >> K;
  if (N == 0 && K == 0) break;
  int ans = INT_MIN;
  for (int i=0; i<N; i++) cin >> S[i];

  for (int i=0; i<=N-K; i++) {
    int t = 0;
    for (int j=0; j<K; j++) t += S[i+j];
    ans = max(ans, t);
  }
  cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 3468
#include <iostream>
#include <vector>
using namespace std;
int main(void){

  int n;
  cin >> n;
  
  int sum = 0;
  int next = 0;
  
  vector<int> A;
  vector<int> B;
  vector<int> C;
  
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    A.push_back(a);    
  }
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    B.push_back(a);    
  }
  for(int i = 0; i < n-1; i++){
    int a;
    cin >> a;
    C.push_back(a);    
  }
  
  
  for(int i = 0; i < n; i++){
    sum += B[i];
    
    if(A[i] == next){
      
      sum += C[A[i-1] - 1];    
     // cout << "c++" << sum << endl;
    }
    
    next = A[i] + 1;
    //cout << next << endl;
    
    
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n; cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0; i<n; i++) cin >> s[i] >> t[i];
  string x; cin >> x;
  int ans = 0;
  bool f = false;
  for(int i=0; i<n; i++) {
    if (f) ans += t[i];
    if (s[i] == x) f = true;
  }
  cout << ans << endl;

  return 0;
}

// EOF

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

int main() {
	int h, w;
	cin >> h >> w;
	int a[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	vector<vector<int>> o;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			if (a[i][j] % 2) {
				o.push_back( { i + 1, j + 1, i + 1, j + 2 });
				a[i][j + 1]++;
			}
		}
	}
	for (int i = 0; i < h - 1; i++) {
		if (a[i][w - 1] % 2) {
			o.push_back( { i + 1, w, i + 2, w });
			a[i + 1][w - 1]++;
		}
	}
	cout << o.size() << endl;
	for (int i = 0; i < (int) o.size(); i++) {
		for (int j = 0; j < 4; j++) {
			cout << o[i][j] << (j < 3 ? " " : "\n");
		}
	}
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int imp = int.Parse(Console.ReadLine());
            if(imp<1200)
            {
                Console.Write("ABC");
            }
            else if(imp<2800)
            {
                Console.Write("ARC");
            }
            else
            {
                Console.Write("AGC");
            }
            //System.Threading.Thread.Sleep(1000);
        }
    }
}


Measured memory_bytes: 13140
//
// Created by yuu on 2019-06-30.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;

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

    return gcd(b, a % b);
}

//int lcm(int a, int b) {
//    return a * b / gcd(a, b);
//}
//
//
//long long c_lcm(long a, long b){
//    long long x = a *b;
//    long long tmp, r;
//    if(a<b){
//        tmp = a;
//        a = b;
//        b = tmp;
//    }
//
//    r = a % b;
//    while(r!=0){
//        a = b;
//        b = r;
//        r = a % b;
//    }
//
//    return x/b;
//}


int A[100010];
int main(void){
    int N;
    cin>>N;

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

//    sort(A,A+N);

//    int min = A[0];
//    if(min>lcm(A[0], A[1])){
//        min = lcm(A[0], A[1]);
//    }
    int temp = A[0];
    for (int i = 1; i < N; ++i) {
        temp = gcd(temp,A[i]);
//        cout<<A[i]<<endl;
//        if(min>temp && temp > 0){
//            min =  temp;
//        }
    }

    cout<<temp<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e10;
const ll MOD = 1000000007;

int main() {
    string s;
    bool out;
    int ans = 0,c = 0;
    cin >> s;
    s += 'B';
    char t[4] = {'A','G','C','T'};
    rep(i,s.length()+1){
        out = 0;
        rep(j,4){
            if (s[i] == t[j]) out = 1;
        }
        if (!out){
            chmax(ans,c);
            c = 0;
        }
        else c++;
    }
    PRINT(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int mx = a.back();
    int ans = a[0];
    int df = 1<<30;
    for(int i=0; i<n-1; i++){
        if(n % 2 == 1){
            if(abs(mx/2-a[i]) < df){
                ans = a[i];
                df = abs(mx/2-a[i]);
            }else if(abs(mx/2+1-a[i]) < df){
                ans = a[i];
                df = abs(mx/2+1-a[i]);
            }
        }else{
            if(abs(mx/2-a[i]) < df){
                ans = a[i];
                df = mx/2-a[i];
            }
        }
    }
    cout << mx << " " << ans << endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;

	cin >> s;

	cout << s[0] << (int)s.size()-2 << s[(int)s.size()-1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int D;
    cin >> D;

    switch (D)
    {
    case 22:
        cout << "Christmas Eve Eve Eve";
        break;

    case 23:
        cout << "Christmas Eve Eve";
        break;

    case 24:
        cout << "Christmas Eve";
        break;

    case 25:
        cout << "Christmas";
        break;

    default:
        break;
    }
    /* code */
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int q, c[101],a[101],n[101];
	int i, j, l;
	int cnt = 0,manp=0;
	cin >> q;

	for (i = 0; i < q; i++) {

		cin >> c[i] >> a[i] >> n[i];

		while (manp == 0) {

			if (c[i] >= 1 && a[i] >= 1 && n[i] >= 1) {

				c[i] -= 1; a[i] -= 1; n[i] -= 1;
				cnt += 1;

			}

			else if (c[i] >= 2 && a[i] >= 1) {

				c[i] -= 2; a[i] -= 1;
				cnt += 1;

			}
			else if (c[i] >= 3) {

				c[i] -= 3;
				cnt++;

			}

			else {

				manp += 1;

			}

		}

		cout << cnt << endl;
		cnt = 0;
		manp = 0;

	}

	return 0;
}


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

int main()
{
	string str; cin >> str;
	int q; cin >> q;

	string cmd;
	while(q-- && cin >> cmd) {
		int q, a, b;
		cin >> a >> b;

		if(cmd == "replace") {
			string rpl; cin >> rpl;
			auto s = str.begin()+a;
			for(auto r : rpl) *s++ = r; 
		} else if(cmd == "reverse") {
			reverse(str.begin()+a, str.begin()+b+1);
		} else if(cmd == "print") {
			cout << str.substr(a,b-a+1) << '\n';
		}
	}

	return 0;
}



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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, K;
  cin >> N >> K;
  vector<PLL> xs(N);
  REP(i,N) cin >> xs[i];

  VL xss, yss;
  REP(i,N) xss.PB(xs[i].FF);
  SORT(xss);
  UNIQ(xss);
  
  REP(i,N) yss.PB(xs[i].SS);
  SORT(yss);
  UNIQ(yss);

  LL ans = 5e18;
  REP(lxi,SZ(xss)) FOR(uxi,lxi,SZ(xss)){
	LL lx = xss[lxi], ux = xss[uxi];
	REP(lyi,SZ(yss)){
	  LL ly = yss[lyi];
	  LL lbyi = lyi, ubyi = SZ(yss);
	  while(ubyi - lbyi > 1){
		LL myi = (lbyi + ubyi) / 2;
		LL my = yss[myi];
		
		int cnt = 0;
		REP(k,N){
		  if(lx <= xs[k].FF && xs[k].FF <= ux &&
			 ly <= xs[k].SS && xs[k].SS <= my)
			++cnt;
		}

		if(cnt >= K){
		  mini(ans, (ux - lx) * (my - ly));
		  ubyi = myi;
		}
		else
		  lbyi = myi;
	  }

	  FOR(myi,lbyi,ubyi){
		LL my = yss[myi];
		int cnt = 0;
		REP(k,N){
		  if(lx <= xs[k].FF && xs[k].FF <= ux &&
			 ly <= xs[k].SS && xs[k].SS <= my)
			++cnt;
		}
		if(cnt >= K)
		  mini(ans, (ux - lx) * (my - ly));
	  }
	}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256