akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
long long n, a[100002], b[100002], l[100002], r[100002], p[100002], q[100002], sum = 1;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> a[i]; }
	for (int i = 0; i < n; i++)cin >> b[i];
	for (int i = 0; i < n; i++) { l[i] = 1; r[i] = a[i]; p[i] = 1; q[i] = b[i]; }
	l[0] = a[0]; r[0] = a[0]; p[n - 1] = b[n - 1]; q[n - 1] = b[n - 1];

	bool OK = true;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] != a[i]) { l[i] = a[i]; r[i] = a[i]; }
	}
	for (int i = n - 2; i >= 0; i--) {
		if (b[i + 1] != b[i]) { p[i] = b[i]; q[i] = b[i]; }
	}
	for (int i = 0; i < n; i++) {
		int C1 = max(l[i], p[i]);
		int C2 = min(r[i], q[i]);
		if (C1 > C2)sum = 0;
		else { sum *= (C2 - C1 + 1); }
		sum %= 1000000007;
	}
	cout << sum << endl;
	return 0;
}

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

int main () {
	int sn, tn, t, l, r, m, c = 0;
	cin >> sn;
	int *s = new int[sn];
	for (int i = 0; i < sn; i++)
		cin >> s[i];
	cin >> tn;
	for (int i = 0; i < tn; i++) {
		cin >> t;
		l = 0;
		r = sn;
		while(l < r) {
			m = (l + r) / 2;
			if (s[m] == t) {
				c++;
				break;
			}
			else if (t < s[m])
				r = m;
			else
				l = m + 1;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3476
M = 10**6
p = [1]*M
p[0] = p[1] = 0
for i in range(2, 4*10**4):
    if p[i]:
        for j in range(i*i, M, i):
            p[j] = 0
C = [0]*M
for i in range(2, M):
    if p[i] and p[(i+1)//2]:
        C[i] = C[i-1] + 1
    else:
        C[i] = C[i-1]
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(C[r] - C[l-1])


Measured memory_bytes: 21108
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,i,ans = 0;cin >> n;n *= 2;
  int a[n];
  for(i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  for(i=0;i<n;i+=2) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
int  main()
{
	int n,i,ans=0,tans=0,a,t,ju=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		t=a;
		scanf("%d",&a);
		if(i==1)continue;
		if(ju)
		{
			if(t>=a)tans++;
			else ju=0;
		}
		else if(ju==0)
		{
			if(t>=a)
			{
				ans=max(ans,tans);
				tans=1;
				ju=1;
			}
		}
	}
	ans=max(ans,tans);
	printf("%d\n",ans);
}

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define 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, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/02  Problem: Nagoya_univ_contest16_a  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int x, a, b;
	cin >> x>>a>>b;
	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}
	else
		cout << "B" << endl;
	
	return 0;
}

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

int const N = 150, M = N >> 1;
int dp[N + 1][N + 1][N + 1], md, dp0[M + 1][M + 1];

inline void ad(int &x, int y) { if ((x += y) >= md)x -= md; }
inline void up(int i, int a, int b, int y) { ad(dp[i][a + M][b + M], y); }

int pw(int x, int p){
	if (p < 0)return 0;
	int an = 1;
	while (p){
		if (p & 1)an = (ll)an * x % md;
		x = (ll)x * x % md;
		p >>= 1;
	}
	return an;
}

int easy(int n, int k){
	dp0[0][0] = 1;
	f(i, 1, n + 1){
		dp0[i][0] = 0;
		f(j, 0, k + 1)ad(dp0[i][0], dp0[i - 1][j]);
		f(j, 1, k + 1)dp0[i][j] = dp0[i - 1][j - 1];
	}
	int an = 0;
	f(i, 0, k + 1)ad(an, dp0[n][i]);
	return an;
}

int main(){
	int n, k;
	scanf("%d%d%d", &n, &k, &md);
	if (k & 1){
		dp[0][M][M] = 1;
		int m = n - n / 2;
		f(i, 0, n + 1)f(f1, -M, m + 1)f(f2, -M, m + 1){
			int &d = dp[i][f1 + M][f2 + M];
			if (i & 1){
				if (-f1 >= k + 3 >> 1 && -f1 + abs(f2) >= k + 2)d = 0;
				if (f1 < 0 && i - (-f1 - 1) * 2 <= 0)d = 0;
				else if (f1 > 0 && i - k / 2 * 2 <= 0)d = 0;
			}
			else {
				if (-f2 >= k + 3 >> 1 && -f2 + abs(f1) >= k + 2)d = 0;
				if (f2 < 0 && i - (-f2 - 1) * 2 <= 0)d = 0;
				else if (f2 > 0 && i - k / 2 * 2 <= 0)d = 0;
			}
			if (d == 0 || i == n)continue;
			if (i & 1){
				if (f2 < 0){
					up(i + 1, f1, k / 2, d);
					up(i + 1, f1, max(f2 - 1, -(k + 1)), d);
				}
				else if (f2)up(i + 1, f1, f2 - 1, d);
				else {
					up(i + 1, f1, 0, d);
					f(j, 1, min(k / 2, m) + 1)up(i + 1, f1, j, d);
					up(i + 1, f1, -(k / 2 + 1), d);
				}
			}else {
				if (f1 < 0){
					up(i + 1, k / 2, f2, d);
					up(i + 1, max(f1 - 1, -(k + 1)), f2, d);
				}
				else if (f1)up(i + 1, f1 - 1, f2, d);
				else {
					up(i + 1, 0, f2, d);
					f(j, 1, min(k / 2, m) + 1)up(i + 1, j, f2, d);
					up(i + 1, -(k / 2 + 1), f2, d);
				}
			}
		}
		int an = 0;
		f(i, -M, M + 1)f(j, -M, M + 1){
			int z = dp[n][i + M][j + M];
			if (z == 0)continue;
			if (i >= 0)z = (ll)z * pw(2, k / 2 - i) % md;
			if (j >= 0)z = (ll)z * pw(2, k / 2 - j) % md;
			ad(an, z);
		}
		printf("%d\n", an);
	}else printf("%d\n", (int)((ll)easy(n >> 1, k >> 1) * easy(n - n / 2, k >> 1) % md));
}

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

int main(){

    int h,w;
    cin >> h >> w;
    vector<string> s(h);

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

    vector<vector<int>> x(w),y(h);

    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                x[j].push_back(i);
            }
        }
    }

    rep(i,w){
        rep(j,h){
            if(s[j][i]=='#'){
                y[j].push_back(i);
            }
        }
    }

    rep(i,w){
        sort(x[i].begin(),x[i].end());
    }

    rep(i,h){
        sort(y[i].begin(),y[i].end());
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]!='#'){
                int tt=0;
                auto xx=lower_bound(x[j].begin(),x[j].end(),i);
                auto yy=lower_bound(y[i].begin(),y[i].end(),j);
                if(x[j].size()==0){
                    tt+=h-1;
                }else if(xx!=x[j].begin()&&xx!=x[j].end()){
                    tt+=*xx;
                    xx--;
                    tt-=*xx+1;
                    tt--;
                    //if(i==3&&j==3)cout << tt << endl;
                }else if(xx==x[j].begin()){
                    tt+=(*xx)-1;
                }else if(xx==x[j].end()){
                    xx--;
                    tt+=h-(*xx)-2;
                }
                if(y[i].size()==0){
                    tt+=w-1;
                }else if(yy!=y[i].begin()&&yy!=y[i].end()){
                    tt+=*yy;
                    yy--;
                    tt-=*yy+1;
                    tt--;
                }else if(yy==y[i].begin()){
                    tt+=(*yy)-1;
                }else if(yy==y[i].end()){
                    yy--;
                    tt+=w-(*yy)-2;
                }
                tt++;
                //if(ans<tt){
                //    cout << i <<" " << j << endl;
                //}
                ans=max(ans,tt);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 39040
"""
B - KEYENCE String
"""
#入力処理
def simple_input():
    temp_input = input().rstrip().split(' ')
    if len(temp_input) > 1:
        return temp_input
    return temp_input[0]

#メイン処理
if __name__ == '__main__':
    #入力
    s = input()
    keyence = "keyence"

    result = "NO"
    
    matchcount = 0
    for i in range(7):
        si = s[i]
        ki = keyence[i]
        if(si == ki):
            matchcount = matchcount + 1
        else:
            break

    for i in range(7):
        i2 = i * -1 - 1
        si = s[i2]
        ki = keyence[i2]
        if(si == ki):
            matchcount = matchcount + 1
        else:
            break

    if(matchcount >= 7):
        result = "YES"
    
    #出力
    print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;


vector<P> prime_factor(int n){
    vector<P> res;
    for(int p = 2; p * p <= n; p++){
        if(n % p != 0) continue;
        int num = 0;
        while(n % p == 0) {num++; n /= p;}
        res.push_back(P(p, num));
    }
    if(n != 1) res.push_back(P(n,1));
    return res;
} 
int n;
map<int, int> sisuu;

int rec(map<int,int>::iterator p, int mul){//autoは関数引数の型には使用できない。
    if(p == sisuu.end()){
        if(mul==1) return 1;//1通り
        else return 0;//mulは作れない。
    }
    int res = 0;
    for(int i = 0; i < p->second + 1; ++i){
        //1<=a<=A+1
        if(mul % (i+1) != 0) continue;
        res += rec(++p,mul/(i+1));//次以降の素数の指数を考える
        --p;
    }
    return res;
}

int main(){
    cin >> n;
    for(int i = 2; i <= n; ++i){
        //n!を素因数分解し、指数を計算
        auto ps = prime_factor(i);
        for(auto p : ps) sisuu[p.first] += p.second;
    }
    cout << rec(sisuu.begin(), 75) << endl;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n,y;

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

  cin>>n>>y;
  // 10,5,1
  y=y/1000;
  for (int a=0; a<=n && a*10<=y; a++) {
    int x = y-a*10;
    for (int b=0; a+b<=n && b*5<=x; b++) {
      int z = x-5*b;
      if (z+a+b==n) {
	cout<<a<<" "<<b<<" "<<z<<endl;
	return 0;
      }
    }
  }

  cout<<"-1 -1 -1"<<endl;
  

  return 0;
}


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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel";
  else
    cout << "consonant";
  cout << endl;
}

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

long long MOD = 1e9 + 7;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

int main() {
	long long M, N;
	cin >> M >> N;
	cout << Calc(M, N) << endl;
}


Measured memory_bytes: 3120
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N= gi();
	    int L= gi();
	    String[] S= new String[N];
	    
	    for (int i=0; i<N;i++) {
	    	S[i]=gs();
	    }

	    Arrays.parallelSort(S);

	    StringBuilder sb= new StringBuilder();
	    for (int i=0; i<N;i++) {
	    	sb.append(S[i]);
	    }	    
        System.out.print(sb.toString());
//        if (a<=c&&c<=b) {
//        	System.out.print("Yes");
//        }else{
//        	System.out.print("No");
//        }

	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 37424
#include <bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
//unordered_map<int,int> mapp;
int n,k;
int read() {
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
	while (ch >= '0' && ch <= '9') x = x*10 + ch - 48, ch = getchar();
	return x * f;
}
int main() {
    cin>>n>>k;
    int cnt=0;
    while(n){
    	n/=k;
    	cnt++;	
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, t = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()

dp = [[0 for j in range(t+1)] for i in range(n+1)]

for i in range(n):
    for j in range(t+1):
        dp[i+1][j] =  dp[i][j]
    for j in range(t):
        next = min(j + ab[i][0], t)
        dp[i+1] [next] = max(dp[i+1][next], dp[i][j] + ab[i][1])
print(max(dp[n]))


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

vector<Int> parallelbinarysearch(Int n,Int q,
				 function<void(void)> init,
				 function<void(Int)> apply,
				 function<bool(Int)> check){
  vector<vector<Int> > C(q);
  vector<Int> L(n,-1),R(n,q);
  bool flg=1;
  while(flg){
    flg=0;
    init();
    for(Int i=0;i<n;i++)
      if(L[i]+1<R[i]) C[(L[i]+R[i])>>1].emplace_back(i);
    for(Int i=0;i<q;i++){
      flg|=!C[i].empty();
      apply(i);
      for(Int j:C[i]){
	if(check(j)) R[j]=i;
	else L[j]=i;
      }
      C[i].clear();
    }
  }
  return R;
}


struct UnionFind{
  Int n;
  vector<Int> r,p;
  UnionFind(){}
  UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};


template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G,T INF){
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
	d[u]=d[v]+c;
	b[u]=v;
	q.emplace(d[u],u);
      }
    }
  }
  return d;
}

//INSERT ABOVE HERE
signed main(){
  Int n,m,k,q;
  cin>>n>>m>>k>>q;  
  vector<Int> a(m),b(m),l(m);
  using P = pair<Int, Int>;
  vector<vector<P> > G(n+1);
  for(Int i=0;i<m;i++){
    cin>>a[i]>>b[i]>>l[i];
    a[i]--;b[i]--;
    G[a[i]].emplace_back(b[i],l[i]);
    G[b[i]].emplace_back(a[i],l[i]);
  }
  for(Int i=0;i<k;i++){
    Int x;
    cin>>x;
    x--;
    G[n].emplace_back(x,0);
  }
  const Int INF = 1e9;
  auto dist=dijkstra(n,G,INF);

  vector<Int> s(q),t(q);
  for(Int i=0;i<q;i++){
    cin>>s[i]>>t[i];
    s[i]--;t[i]--;
  }

  vector<P> v(m);
  for(Int i=0;i<m;i++) v[i]=P(a[i],b[i]);
  auto ch=[&](P a){return min(dist[a.first],dist[a.second]);};
  sort(v.begin(),v.end(),[&](P a,P b){return ch(a)>ch(b);});
  for(Int i=0;i<m;i++) tie(a[i],b[i])=v[i];
  
  UnionFind uf;  
  auto init=[&](){uf=UnionFind(n);};
  auto apply=[&](Int i){uf.unite(a[i],b[i]);};
  auto check=[&](Int i){return uf.same(s[i],t[i]);};
  auto ans=parallelbinarysearch(q,m,init,apply,check);

  for(Int i=0;i<q;i++)
    cout<<ch(v[ans[i]])<<endl;
  
  return 0;
}



Measured memory_bytes: 55668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {}, b[200005] = {};
    ll z = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    b[0] = b[n]; b[n + 1] = b[1];
    for (int t = 0; t < 328; t++) {
        int c[200005] = {};
        for (int i = 1; i <= n; i++) {
            if (b[i] > b[i - 1] && b[i] > b[i + 1]) {
                if (b[i] % (b[i - 1] + b[i + 1]) >= a[i]) {
                    z += b[i] / (b[i - 1] + b[i + 1]);
                    c[i] = b[i] % (b[i - 1] + b[i + 1]);
                } else {
                    int d = (b[i] - a[i]) / (b[i - 1] + b[i + 1]);
                    z += d;
                    c[i] = b[i] - d * (b[i - 1] + b[i + 1]);
                }
            } else c[i] = b[i];
        }
        for (int i = 1; i <= n; i++) b[i] = c[i];
        b[0] = b[n]; b[n + 1] = b[1];
        //for (int i = 1; i <= n; i++) cout << b[i] << ' '; cout << '\n';
    }
    for (int i = 1; i <= n; i++) if (a[i] != b[i]) {
        cout << -1;
        return 0;
    }
    cout << z;
    /*
     111 122 133 256 3810
     a b c
     a+b+c b c
     a+2b+2c b c
     a+2b+2c a+3b+3c c
     2a+5b+6c a+3b+3c c
     */
}


Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 2e5+100;
char s[N];
int dp[N][3],n;
int main(){
    scanf("%s",s); n=strlen(s);
    dp[0][0]=1; dp[0][1]=0; dp[0][2]=0;
    for(int i=1;i<n;++i){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+1;
        if(s[i-1]!=s[i]&&dp[i-1][0]) dp[i][0]=max(dp[i][0],dp[i-1][0]+1);
        
        if(i<2) continue;
        dp[i][1]=max(dp[i-2][0],dp[i-2][2])+1;
        if(s[i-3]!=s[i-1]||s[i-2]!=s[i]) dp[i][1]=max(dp[i][1],dp[i-2][1]+1);

        if(i<3) continue;
        dp[i][2]=max(dp[i-3][0],dp[i-3][1])+1;
        if(s[i-5]!=s[i-2]||s[i-4]!=s[i-1]||s[i-3]!=s[i]) dp[i][2]=max(dp[i][2],dp[i-3][2]+1);
    }
    printf("%d\n",max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 2688
/*    特徴    */

/*    教訓    */

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //


// - library ------------- //



// --------- library end - //




int main(){

  ll a = il();
  ll b = il();

  cout << a*b << endl;



}

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

int main(){
  int n;
  cin >> n;
  int x=0;
  int a=n;
  while (n!=0){
    x=n%10+x;
    n=n/10;
  }
  if (a%x==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int x, y;
    cin >> x >> y;
    string ans = "No";
    for (int kame = 0; kame <= x; kame++) {
        if (kame * 4 + (x - kame) * 2 == y) ans = "Yes";
    }
    cout << ans << endl;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct edge{
  int u, v, c;
  edge(int a, int b, int c) : u(a), v(b), c(c) {}
  bool operator < (const edge& e) const {
    return c < e.c;
  }
};
typedef vector<edge> node;
typedef vector<node> graph;

bool used[1000];
void dfs(int u, int b, graph& G, vector<int>& h){
  used[u] = true;
  REP(i, G[u].size()){
    edge& e = G[u][i];
    if(!used[e.v] && h[e.v] > b){
      dfs(e.v, b, G, h);
    }
  }
}
struct UF{
  vector<int> data;
  UF(int N) : data(N, -1) {}
  bool uni(int x, int y){
    x = rank(x); y = rank(y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int rank(int x){
    if(data[x] < 0) return x;
    return data[x] = rank(data[x]);
  }
};

int main(){
  int N, M;
  while(cin >> N >> M && N){
    vector<int> h(N);
    REP(i, N) cin >> h[i];
    vector<int> day = h;
    day.push_back(0);
    sort(day.begin(), day.end());
    day.erase(unique(day.begin(), day.end()), day.end());
    vector<edge> es;
    graph G(N);
    REP(i, M){
      int a, b, c;
      cin >> a >> b >> c;
      a--; b--;
      es.push_back(edge(a, b, c));
      G[a].push_back(edge(a, b, c));
      G[b].push_back(edge(b, a, c));
    }
    sort(es.begin(), es.end());
    int END = day.size();
    for(int i = 0; i < day.size(); i++){
      int C = 0;
      memset(used, 0, sizeof used);
      REP(u, N) if(!used[u] && h[u] > day[i]){
        dfs(u, day[i], G, h);
        C++;
      }
      if(C != 1){
        END = i;
        break;
      }
    }
    int ans = 0;
    UF uf(N);
    for(int i = END - 1; i >= 0; i--){
      REP(j, es.size()){
        edge& e = es[j];
        if(h[e.u] > day[i] && h[e.v] > day[i] && uf.uni(e.u, e.v)){
          ans += e.c;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2156
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


def main():
    K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += gcd(i, j, k)
    print(ans)
main()


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }

    string ans;
    for (int c = 0; c < 26; c++) {
        int size = 50;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int l = 0; l < (int)s.at(i).size(); l++) {
                if (s.at(i).at(l) == (char)('a' + c)) cnt++;
            }

            size = min(size, cnt);
        }

        for (int s = 0; s < size; s++) {
            ans += (char)('a' + c);
        }
    }

    cout << ans << endl;
}   

Measured memory_bytes: 256
s = input()
n = len(s)

ops = None
for i in range((n-1)**2):
  tmp = int(s[0])
  for j in range(0, n-1):

    if (i>>j)&1:
      tmp += int(s[j+1])
    else:
      tmp -= int(s[j+1])

  if tmp == 7:
    ops = i
    break

res = ""
for i in range(n):
  res += s[i]
  if i < n-1:
    if (ops>>i)&1:
      res += "+"
    else:
      res += "-"

print(res+"=7")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
const int INF = 2100000000;

class Heap{
  public:
    vector<int> a;
    int N;
    Heap(int n){
      N = n;
      a.resize(N, INF);
    }

    int get_parent(int x){
      return a[(x)/2];
    }

    int get_left(int x){
      if(x*2 < N){
        return a[x*2];
      }
      return INF;
    }

    int get_right(int x){
      if(x*2+1 < N){
        return a[x*2+1];
      }return INF;
    }
};


int main(void){
  int n, a;
  cin >> n;
  n++;
  Heap hp(n);

  for(int i = 1; i < n; i++){
    cin >> a;
    hp.a[i] = a;
  }
  for(int i = 1; i < n; ++i){
    cout << "node " << i << ": key = " << hp.a[i];
    if(hp.get_parent(i) != INF){
      cout << ", parent key = " << hp.get_parent(i);
    }
    if(hp.get_left(i) != INF){
      cout << ", left key = " << hp.get_left(i);
    }
    if(hp.get_right(i) != INF){
      cout << ", right key = " << hp.get_right(i);
    }
    cout << ", " << endl;
  }
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define SZ(x) (long long)x.size()
#define endl '\n'
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define tc                                                                     \
  int tc;                                                                      \
  cin >> tc;                                                                   \
  while (tc--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define REPO(i, b, a) for (int i = b - 1; i >= a; i--)
#define REPI(i, a, b) for (int i = a; i <= b; i++)
#define MOD 1000000007

int32_t main() {
  FAST;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("output.txt", "w", stderr);
#endif
  int n, k;
  cin >> n >> k;
  vector<int> s(n);
  int l;
  REP(i, 0, n) { cin >> s[i]; }
  sort(s.begin(), s.end());
  int i = 0, ss = 0;
  for (auto l : s) {
    if (!k)
      break;
    ss += l;
    k--;
  }
  cout << ss;
  return 0;
}

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

int a, b;

int main() {
  cin >> a >> b;
  string s(b, '0' + a), t(a, '0' + b);
  cout << min(s, t) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		sc.close();

		long hp = h;
		long num = 1;
		long attack = 0;

		while (hp > 0) {
			attack = attack + num;
			num = num * 2;
			hp = hp / 2;
		}

		print(attack);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 22612
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;

//----------------------------------------------------------------
signed main(){

	ll n;
	cin >> n;
	vll a(n),b(n),c(n-1);
	rep(i,n){
		cin >> a[i];a[i]--;
	}
	rep(i,n)cin >> b[i];
	rep(i,n-1)cin >> c[i];

	ll ans = b[a[0]];
	rep(i,n-1){
		ans += b[a[i+1]];
		if(a[i+1] == a[i]+1){
			ans += c[a[i]];
		}
	}
	cout << ans << endl;

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc140.contest.atcoder.jp/tasks/abc140_a

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<ll,ll,ll,ll> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c&&c<=b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}











Measured memory_bytes: 256
let ar = Array.make 100001 0
let scan_words () = Scanf.scanf "%d %d\n" (fun a b -> a, b)

let n, k = scan_words ()

let rec init_ar n =
  if n <= 0 then ()
  else
    (let a, b = scan_words () in
     ar.(a) <- ar.(a) + b;
     init_ar (pred n))

let rec solve i k =
  let k' = k - ar.(i) in
  if k' <= 0 then i
  else solve (succ i) k'

let () =
  init_ar n;
  solve 1 k |> Printf.printf "%d\n"

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <string>
using namespace std;
int main(){
    int N,count = 0;
    cin >> N;
    vector<int> a(N);
    for(int i = 0;i < N;i ++){
        cin >> a.at(i);
        while(a.at(i)%2 == 0){
            a.at(i) /= 2;
            count ++;
        }
    }
    cout << count << endl;

}

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

int main(){
    int n;
    cin>>n;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j==n)cout<<"Yes",exit(0);
        }
    }
    cout<<"No";
return 0;
}



Measured memory_bytes: 256
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

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


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    ll N, Y;
    cin >> N >> Y;
    bool judge = 0;
    ll x = 0, y = 0, z = 0;
    rep(i, N + 1) {
        rep(j, N + 1) {
            ll k = N - i - j;
            ll Z = Y - i * 10000 - j * 5000;
            if (k >= 0 && Z / 1000 == k && Z % 1000 == 0) {
                judge = 1;
                x = i, y = j, z = k;
                break;
            }
        }
    }

    if (judge)
        cout << x << " " << y << " " << z << endl;
    else
        cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	int n; cin >> n;
	vector<int>a(n + 1);
	rep1(i, n)cin >> a[i];
	int ans = 0;
	rep1(i, n)
	{
		int k = a[i];
		if (a[k] == i)ans++;
	}
	co(ans / 2);
	return 0;
}


Measured memory_bytes: 640
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long 
using namespace std;

const int maxn = 510000;

int n,L;
struct node{double x,y;}a[maxn<<1]; int head,tail;

double multi(node x,node y,node z)
{
	x.x-=z.x; x.y-=z.y;
	y.x-=z.x; y.y-=z.y;
	return x.x*y.y-x.y*y.x;
}

int main()
{
	scanf("%d%d",&n,&L); n--;
	a[head=maxn]=(node){0.0,0.0};
	ll x,y;
	tail=head+1; scanf("%lld%lld",&y,&x);
	printf("%lf\n",(double)y); a[tail].y=(double)x*y; a[tail].x=x;
	
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&y,&x); y*=x;
		node now=(node){a[head].x-(double)x,a[head].y-(double)y};
		while(head+1<=tail&&a[tail-1].x-now.x>=L) tail--;
		if(head!=tail)
		{
			double pt=(a[tail].y-a[tail-1].y)/(a[tail].x-a[tail-1].x);
			if(a[tail].x-now.x>L)
			{
				a[tail].y=a[tail-1].y+(L-(a[tail-1].x-now.x))*pt;
				a[tail].x=now.x+L;
			}
			while(head+1<=tail&&multi(a[head],a[head+1],now)>=0) head++;
		}
		a[--head]=now;
		double kk=a[tail].y-now.y;
		printf("%lf\n",kk/(double)L);
	}
	
	return 0;
}


Measured memory_bytes: 16640
readInt() = parse(Int,readline())

function solve()
    ans = 0
    N = readInt()
    f = fill(0, N)
    for i in 1:N
        j = i
        while j <= N
            f[j] += 1
            j += i
        end
        ans += i*f[i]
    end
    println(ans)
end

solve()

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

using namespace std;

int main(){
  

  while(1){
    int n,r;
    cin>>n>>r;

    if(n==0 && r==0)break;
    
    int x[n];

    int p,c,k=0;


    for(int i=0;i<n;i++){
      k++;
      x[i]=k;
    }

    for(int j=1;j<=r;j++){
      
      cin>>p>>c;
      int y[p];
      int z[c];
      
      for(int i=0;i<p-1;i++){
	y[i]=x[n-p+1+i];
      }
      
      for(int i=0;i<c;i++){
	z[i]=x[n-p-c+1+i];
      }
      
      for(int i=0;i<c;i++){
	x[n-c+i]=z[i];
      }
      
      for(int i=0;i<p-1;i++){
	x[n-c-p+1+i]=y[i];
      }
    
      
    }
    
    
    cout<<x[n-1]<<endl;
    
    
  }
}



Measured memory_bytes: 2960
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin>> s;
    rep(i,0,SZ(s)){
        if(i == 4){
            cout << " ";
        }
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3544
s1=[1,0]*5*10**4
s0=[0,1]*5*10**4
s=list(input())
a1,a0=0,0
for i in range(len(s)):
    a1+=abs(int(s[i])-s1[i])
    a0+=abs(int(s[i])-s0[i])
print(min(a0,a1))

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

N, M, X = map(int, input().split())
CA = [[int(i) for i in input().split()] for _ in range(N)]

ret = float('inf')
for mask in range(1 << N) :
  tot = [0] * (M + 1)
  for i in range(N) :
    if mask & (1 << i) :
      for j in range(M + 1) :
        tot[j] += CA[i][j]
        
  if min(tot[1:]) >= X :
    ret = min(ret, tot[0])
    
if ret == float('inf') :
  print(-1)
else :
  print(ret)

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

typedef long long ll;
typedef unsigned long long ull;

void solves(vector<ll> &v, vector<vector<pair<ll, ll>>> &vw, ll parent, ll pos, ll c) {
  v[pos] = c;
  
  for (ll i = 0; i < vw[pos].size(); ++i) {
    ll nextPos = vw[pos][i].first;
    if (nextPos == parent) continue;

    ll nextC = c;
    if (vw[pos][i].second % 2 != 0) nextC = 1 - c;

    solves(v, vw, pos, nextPos, nextC);
  }
}

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

  vector<vector<pair<ll, ll>>> vw(n);
  for (ll i = 0; i < n-1; ++i) {
    ll v1, v2, w;
    cin >> v1 >> v2 >> w;
    v1--;
    v2--;
    vw[v1].push_back(pair<ll, ll>(v2, w));
    vw[v2].push_back(pair<ll, ll>(v1, w));
  }

  vector<ll> v(n, -1);
  solves(v, vw, -1, 0, 0);
  
  for (ll i = 0; i < n; ++i) {
    cout << v[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 11520
n = gets.to_i
vl = []
gets.split(" ").each do |line|
    vl.push(line.to_i)
end
cl = []
gets.split(" ").each do |line|
    cl.push(line.to_i)
end

res = 0
for i in 0..(n - 1) do
    sa = vl[i] - cl[i]
    if sa > 0
        res += sa
    end
end
puts res

Measured memory_bytes: 14268
N,K=map(int,input().split())
V=list(map(int,input().split()))
Vrev=V[::-1]
# 左からA個取る
# 右からB個取る
# A+B<=min(N,K)
# K-(A+B)個詰め直す。負の数で絶対値の大きいものから順に。

# A,Bを、0からA+B=min(N,K)まで全探索
MAX=min(N,K)
ans=0
for a in range(MAX+1):
  for b in range(MAX-a+1):
    jewels=V[:a]+Vrev[:b]
    jewels=sorted(jewels)
    drop=K-(a+b)
    for i in range(drop):
      if i>=len(jewels):
        break
      if jewels[i]>=0:
        break
      else:
        jewels[i]=0
    if ans<sum(jewels):
      ans=sum(jewels)
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long K;
    long long X, Y;

    cin >> K;
    cin >> X >> Y;

    for(long long i = X; i < Y + 1; i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}

Measured memory_bytes: 3636
///f. fizzbuzz sequence
#include <stdio.h>
#include <math.h>

int main()
{
    long long int n;
    scanf("%lld",&n);
    long long int d3,d5,d15;
    d3=n/3; d5=n/5; d15=n/15;

    long long sum = (n*(n+1)-3*d3*(d3+1)-5*d5*(d5+1)+15*d15*(d15+1))/2;
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 1700
/*
  Here we will do it in O(NlogN)
  User:- sanyam
*/

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

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)
#define base(i,val) memset(i, val, sizeof(val))

const ll inf = 1e18;

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
  #endif
  return;
}


/* ---------------------From here main coding part starts--------------------  */


ll solve_using_DP_with_Optimizations(vector<pll> &flowers, ll n){
  ll dp[n+1];
  map<ll, ll>meaningful_predecessors;

  dp[1] = flowers[0].second;
  meaningful_predecessors[flowers[0].first] = dp[1];

  ll ans = dp[1];
  // cout<<dp[1]<<endl;
  for(ll i=2; i<=n; i++){
    dp[i]=flowers[i-1].second;
    //we are searching for one whose height just less than current height and
    //the beauty for it will be such that after adding the overall beauty at
    //current index increases.
    auto reqd_previous = meaningful_predecessors.lower_bound(flowers[i-1].first);
    if(reqd_previous!=meaningful_predecessors.begin()) {
      reqd_previous--;
      dp[i] += reqd_previous->second; 
    }

    meaningful_predecessors[flowers[i-1].first] = dp[i];

    //Now removing all the unnecesary ones from map, these are whose height is
    //more than the current one and dp[i]/answer is less.
    auto not_reqd_ones = meaningful_predecessors.upper_bound(flowers[i-1].first);

    while(not_reqd_ones!=meaningful_predecessors.end() && not_reqd_ones->second <= dp[i]) {
      auto temp = not_reqd_ones;
      temp++;
      meaningful_predecessors.erase(not_reqd_ones);
      not_reqd_ones = temp;
    }

    // cout<<dp[i]<<endl;
    ans = max(ans, dp[i]);
    // cout<<dp[i]<<" "<<ans<<endl;
  }

  return ans;
}

void solve(){
  ll n; cin>>n;
  vector<pll> flowers;

  loop(i, 0, n){
    ll height;  cin>>height;
    flowers.push_back(mp(height, 0));
  }
  loop(i, 0, n){
    ll beauty;  cin>>beauty;
    flowers[i] = mp(flowers[i].first, beauty);
  }

  // loop(i, 0, n){
  //   cout<<flowers[i].first<<" "<<flowers[i].second<<", ";
  // }cout<<endl;

  cout<<solve_using_DP_with_Optimizations(flowers, n)<<endl;
  return;
}

int main(){

  fastIO;
  //take_fileIO();
  solve();

  return 0;
}

Measured memory_bytes: 17516
f = [0  for i in range(0, 10001)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= 10000:
                f[n] += 1 
N = int(input())
for n in range(1, N+1):
    print(f[n])

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

int n, k, a[200005];

bool pos(int l){
    if (l == 0) return false;
    int cnt = 0;
    for (int i = 0; i < n; ++i){
        cnt += (a[i] + l - 1) / l - 1;
    }
    if (cnt > k) return false;
    return true;
}

int main(){
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }
    int lo = 0, hi = 1000000000, ans = hi;
    while (lo <= hi){
        int mid = (hi + lo) / 2;
        //printf("%d %d\n", mid, pos(mid));
        if (pos(mid)){
            ans = mid;
            hi = mid - 1;
        }
        else{
            lo = mid + 1;
        }
    }
    printf("%d", ans);
}


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

using namespace std;

#define PI M_PI
#define EPS 1e-9

int main(){
  double R;
  while(cin >> R, R > 0){
    double n = 0,d = 1;
    while(true){
      if(fabs(PI-n/d) <= R+EPS){
        cout << (int)n << "/" << (int)d << endl;
        break;
      }else{ R+n/d < PI ? n++ : d++; }
    }
  }
  return 0;
}

Measured memory_bytes: 1224
fun main(args: Array<String>) {
  val N = readString()
  println(if (N.contains('7')) "Yes" else "No")
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 35664
#include <stdio.h>
#include <stdlib.h>

struct Node{
    int key;
    struct Node *right;
    struct Node *left;
    struct Node *parent;
};
struct Node *root;

void inorder(struct Node *);
void preorder(struct Node *);
struct Node *find(int);
void insert(int);

int main(){
    int n,x;
    char com[20];

    scanf("%d", &n);

    for (int i = 0; i < n; i++ ){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d",&x);
            insert(x);
        } 
        else if(com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } 
        else if (com[0] == 'f'){
            scanf("%d", &x);
            struct Node *t = find(x);
            if(t != NULL) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}

void inorder(struct Node *A){
    if(A == NULL)return;
    inorder(A->left);
    printf(" %d",A->key);
    inorder(A->right);
}

void preorder(struct Node *A){
    if(A == NULL)return;
    printf(" %d",A->key);
    preorder(A->left);
    preorder(A->right);
}

void insert(int key){
    struct Node *y = NULL;
    struct Node *x = root;
    struct Node *z = malloc(sizeof(struct Node));
    z->key = key;
    z->left = z->right = z->parent = NULL;

    while(x != NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }

    z->parent = y;

    if(y == NULL){
        root = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else{
        y->right = z;
    }
}

struct Node *find(int x){
    struct Node *t;
    t = root;
    while(t != NULL){
        if(t->key > x){
            t = t->left;
        }
        else if(t->key < x){
            t = t->right;
        }
        else break;
    }
    return t;
}


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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    long long N;
    cin >> N;
    long long g = 0;
    for (int i = 0; i < N; ++i) {
        long long a; cin >> a;
        g = GCD(g, a);
    }
    cout << g << endl;
}


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

using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define lli long long int
#define all(c) (c.begin(),c.end())
#define sz(c) c.size()
const int MOD = 1000000007;
const int MX = 2e5 + 5;
const lli INF = 1e18;


void solve() {
	int n;
	cin >> n;
	lli arr[n];
	lli sto[n];
	cin >> arr[0];
	sto[0] = 0;
	lli sum = 0;
	for (int i = 1; i < n; i++) {
		cin >> arr[i];
		if (arr[i] < arr[i - 1] + sto[i - 1])sto[i] = (arr[i - 1] + sto[i - 1]) - arr[i];
		else sto[i] = 0;
		sum += sto[i];
	}

	cout << sum << endl;


}


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

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--) {
	solve();
	// }



	return 0;
}

Measured memory_bytes: 6696
num = list(map(int, input().split()))

maximum = max(num)
dif = [maximum - n for n in num]

counter = 0
odd = 0
for d in dif:
    q, r = divmod(d, 2)
    counter += q
    odd += r

if odd == 0:
    pass
elif odd == 1:
    counter += 2
else:
    counter += 1

print(counter)

Measured memory_bytes: 3064