akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	rep(i, 0, tx - sx) {
		cout << 'R';
	}
	rep(i, 0, ty - sy) {
		cout << 'U';
	}
	rep(i, 0, tx - sx) {
		cout << 'L';
	}
	rep(i, 0, ty - sy) {
		cout << 'D';
	}
	cout << 'D';
	rep(i, 0, tx - sx + 1) {
		cout << 'R';
	}
	rep(i, 0, ty - sy + 1) {
		cout << 'U';
	}
	cout << 'L'<<'U';
	rep(i, 0, tx - sx + 1) {
		cout << 'L';
	}
	rep(i, 0, ty - sy + 1) {
		cout << 'D';
	}
	cout << 'R' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <numeric>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
 
#include <queue>
#include <cstdio>
#include <set>
using namespace std;
 
typedef long long ll;
inline int getInt(){ int s; scanf("%d", &s); return s; }
 
int main(){
  const int n = getInt();
  const int k = getInt();
 
  vector<ll> b(k);
 
  REP(i,k){
    const int m = getInt();
    REP(j,m){
      const int bunny = getInt() - 1;
      b[i] |= (1ll << bunny);
    }
  }
 
  vector<ll> d(n);
 
  const int r = getInt();
 
  REP(i,r){
    const int p = getInt() - 1;
    const int q = getInt() - 1;
 
    d[p] |= (1ll << q);
    d[q] |= (1ll << p);
  }
 
  vector<int> ret(n);
  REP(i,k){
    REP(j,n) if(b[i] & (1ll << j)){
      if(d[j] & b[i]) ret[j] = 1;
    }
  }
 
  printf("%d\n", accumulate(ret.begin(), ret.end(), 0));
 
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>

#define maxn 110
char str[maxn][maxn];
int cnt[maxn];
int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) scanf("%s", str[i] + 1);
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) ++cnt[str[i][j] - 'a'];
	if ((n & 1) && (m & 1))
	{
		int cnter = 0, cnter2 = 0;
		for (int i = 0; i < 26; ++i)
			if (cnt[i] % 4 != 0) cnt[i] % 2 == 0 ? ++cnter : ++cnter2;
		if (cnter <= (n >> 1) + (m >> 1) && cnter2 < 2) puts("Yes");
		else puts("No"); 
	}
	else if (n % 2 == 0 && m % 2 == 0)
	{
		for (int i = 0; i < 26; ++i)
			if (cnt[i] % 4 != 0) return puts("No"), 0;
		puts("Yes");
	}
	else
	{
		int lim = (n & 1) ? m >> 1 : n >> 1, cnter = 0, cnter2 = 0;
		for (int i = 0; i < 26; ++i) if (cnt[i] % 4 != 0) cnt[i] % 2 ? ++cnter2 : ++cnter;
		if (cnter <= lim && cnter2 < 2) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 30

int W, H;
bool wall[MAX][MAX][4];
/*
 3
2 0
 1
*/

//xy??§?¨???§??????????????¢?´¢
//???????????¢
int bfs(int sx, int sy, int gx, int gy) {

	queue<pii> Q;
	Q.push(pii(sx, sy));

	//???????????¢
	int d[MAX][MAX];
	memset(d, 0, sizeof(d));
	d[sx][sy] = 1;

	//?§????4?????????????????????
	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 };
	for (pii u; !Q.empty();) {
		u = Q.front(); Q.pop();
		//??´??????????????¢?´¢????????????
		if (u == pii(gx, gy))break;
		//?§????4???????????¢?´¢
		for (int i = 0; i < 4; i++) {
			int nx = u.first + dx[i], ny = u.second + dy[i];
			if (0 <= nx&&nx < W && 0 <= ny&&ny < H) {
				//?§??????§??????????????°?£???°???
				//cout << u.first << " " << u.second << endl;
				//cout << " " << i << " " << wall[u.first][u.second][i] << endl;
				if (wall[u.first][u.second][i])continue;
				//??¢?´¢???????£???°???
				if (d[nx][ny] != 0)continue;
				d[nx][ny] = d[u.first][u.second] + 1;
				Q.push(pii(nx, ny));
				//cout << "push " << nx << " " << ny << endl;
			}
		}
	}

	return d[gx][gy];
}

int main() {
	for (; cin >> W >> H&&W;) {
		memset(wall, 0, sizeof(wall));
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W - 1; w++) {
				bool b; cin >> b;
				wall[w][h][0] = b;
				wall[w + 1][h][2] = b;

			}
			if (h == H - 1)break;
			for (int w = 0; w < W; w++) {
				bool b; cin >> b;
				wall[w][h][1] = b;
				wall[w][h + 1][3] = b;
			}
		}
		cout << bfs(0, 0, W - 1, H - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define ll long long int

using namespace std;

ll n,k,x,y;

int main()
{
    ///freopen("INA.txt","r",stdin);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>> n >> k >> x >> y;
    if(n>=k){
         cout<< k*x+(n-k)*y << endl;
    }
    else{
        cout<< n*x << endl;
    }


    return 0;
}



Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] primeList = new int[1229];
        boolean[] p = new boolean[10000];
        int limit = 10000;
        primeList[0] = 2;
        primeList[1] = 3;
        p[3] = true;
        int count = 2;
        for (int i = 5; i <= limit; i += 2) {
            boolean wflag = true;
            for (int j = 1; primeList[j] * primeList[j] <= i; j++) {
                if (i % primeList[j] == 0) {
                    wflag = false;
                    break;
                }
            }
            if (wflag) {
                primeList[count++] = i;
                p[i] = true;
            }
        }
        for (;;) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            n = n % 2 == 0 ? n - 1 : n;
            for (int i = n; i >= 5; i -= 2) {
                if (p[i] && p[i - 2]) {
                    System.out.println(i - 2 + " " + i);
                    break;
                }
            }
        }
    }
}



Measured memory_bytes: 45060
n = int(input())
a,b = map(int,input().split())
min_b = b
min_b_a = a
for i in range(n-1):
    a,b = map(int,input().split())
    if min_b>b:
        min_b = b
        min_b_a = a
print(min_b_a+min_b)

Measured memory_bytes: 3060
#!/usr/bin/env python3

import bisect

def main():
    a, b, q = map(int, input().split())
    huge = 10 ** 18
    s = [-huge] + [int(input()) for i in range(a)] + [huge]
    t = [-huge] + [int(input()) for i in range(b)] + [huge]
    for i in range(q):
        x = int(input())
        b = bisect.bisect_right(s, x)
        d = bisect.bisect_right(t, x)
        res = huge
        for sh in s[b - 1:b + 1]:
            for te in t[d - 1:d + 1]:
                d1 = abs(sh - x) + abs(sh - te)
                d2 = abs(te - x) + abs(sh - te)
                res = min(res, d1, d2)
        print(res)


if __name__ == "__main__":
    main()


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

int main()
{
    int a,b,c,k,f=0;
    cin>>a>>b>>c>>k;

     if(c>b&&b>a)
       f=1;

    if(f==0)
    while(k)
    {
        if(c<=b)
            c=c*2;
        else if(b<=a)
            b=b*2;

        if(c>b&&b>a)
        {
            f=1;
            break;
        }
        k--;
    }
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3616
n,m=map(int,input().split())
s=[[]for i in range(n+1)]
t=[[0,0,0]for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    s[a].append(b)
c,d=map(int,input().split())
t[c][0]=0
do=0
p=[c]
while t[d][0]==0 and len(p)!=0:
    do+=1
    q=[]
    for i in p:
        for j in s[i]:
            if t[j][do%3]==0:
                t[j][do%3]=do
                q.append(j)
    p=q[:]
print(t[d][0]//3if t[d][0]>0 else -1)

Measured memory_bytes: 37768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string n;
  cin >> n;

  int sum = 0;
  rep(i, n.size()) sum += n[i] - '0';
  cout << (sum % 9 == 0 ? "Yes" : "No") << '\n';

  
  return 0;
}

Measured memory_bytes: 3756
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;
    string st;
    while(cin>>n)
    {
        n=((n+1)*n)/2;
        cout<<n<<en;
    }
}



Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
namespace Codes
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();

            int n = nm[0];
            int m = nm[1];

            var a = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();

            int sum = a.Sum();

            int answer = 0;

            if(n-sum >= 0){
                answer = n - sum;
            }
            else{
                answer = -1;
            }

            Console.WriteLine(answer);


        }
    }
}


Measured memory_bytes: 29276
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int f(int i, int n)
{
	if(i==0) return n;
	else return -n;
}

char g(int i)
{
	if(i==0) return '+';
	else return '-';
}

int main()
{
	int done=0, a, b, c, d, x;
	cin >> x;
	d=x%10; x/=10;
	c=x%10; x/=10;
	b=x%10; x/=10;
	a=x%10;
	rep(j, 2)rep(k, 2)rep(l, 2)
	{
		if(done==0 && a+f(j, b)+f(k, c)+f(l, d)==7)
		{
			done=1;
			cout << a << g(j) << b << g(k) << c << g(l) << d << "=7" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

def Solve():
    N,K=na()
    S=[int(d) for d in input()]
    l=[]
    N=len(S)
    if(S[0]==0):
        l.append(0)
    b=S[0]
    ct=1
    for i in S[1:]:
        if(b!=i):
            l.append(ct)
            ct=1
            b=i
        else:
            ct+=1
    l.append(ct)
    len_l=len(l)
    if(len_l//2 <= K):
        return sum(l)
    ans = res = sum(l[:2*K+1])
    
    if(len_l%2==0):
        l.append(0)
        len_l+=1
    g = K * 2 + 1
    for i in range(K*2+1,len_l-1,2):
        ans -= l[i-g] + l[i-g+1]
        ans += l[i] + l[1+i]
        if(res<ans):
            res=ans
    #print(S)
    #print(l)
    #print(len_l)
    return res

print(Solve())

Measured memory_bytes: 5568
n = int(input())
s = list(input())
answer = n
left_count = 0
right_count = s.count('E')
for i in range(n):
  if i != 0 and s[i-1] == 'W':
    left_count += 1
  if s[i] == 'E':
    right_count -= 1
  total = left_count + right_count
  answer = min(answer, total)
print(answer)


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

int main(void){
        int n, i;
        scanf("%d", &n);
        int *a = (int*)malloc(n * sizeof(int));
        for(i = 0; i < n; i++) scanf("%d", &a[i]);

        printf("%d", a[n - 1]);
        for(i = n - 2; i >= 0; i--) printf(" %d", a[i]);
        puts("");

        return 0;
}


Measured memory_bytes: 2040
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	if(N<1000)
		cout<<"ABC"<<endl;
	else
		cout<<"ABD"<<endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	map<int, ll> mp;
	rep(i,n) mp[a[i]] += 1;

	ll ans = 0;
	for(auto x: mp){
		ans += x.second*(x.second-1)/2;
	}

	rep(i,n){
		cout<<ans-mp[a[i]]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include<set>
#include<string>
using namespace std;
int main(void){
    set<string> ss;
    string s,a;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="insert"){
            cin>>a;
            ss.insert(a);
        }
        else if(s=="find"){
            cin>>a;
            if(ss.find(a)==ss.end()){
                cout<<"no"<<endl;
            }
            else cout<<"yes"<<endl;
        }
    }
    return 0;
    // Your code here!
    
}

Measured memory_bytes: 32472
N = int(input())
dp = [0, 0, 0]
for i in range(N):
    a, b, c = map(int, input().split())
    tmp_a = a + max(dp[1], dp[2])
    tmp_b = b + max(dp[0], dp[2])
    tmp_c = c + max(dp[0], dp[1])
    dp = [tmp_a, tmp_b, tmp_c]
print(max(dp))


Measured memory_bytes: 9164
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]+[int(x) for x in input().split()]
c=[0]+[int(x) for x in input().split()]

ans=0

for i in range(n+1):
    ans+=b[a[i]]
    if i>0:
        if a[i-1]+1==a[i]:
            ans+=c[a[i-1]]
print(ans)

Measured memory_bytes: 61976
#include "./bits/stdc++.h"

using namespace std;

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    
    int d[N + 1];
    for (int i = 1; i <= N; i++) {
        d[i] = 0;
    }
    
    for (int i = 1; i <= N - 1; i++) {
        for (int j = i + 1; j <= N; j++) {
            int d1 = abs(j - i);    // i⇔j
            int d2 = abs(X - i) + 1 + abs(j - Y);   // i⇔X⇔Y⇔j
            int d3 = abs(Y - i) + 1 + abs(j - X);   // i⇔Y⇔X⇔j
            int d_min = min(d1, min(d2, d3));
            d[d_min]++;
        }
    }

    for (int i = 1; i <= N - 1; i++) {
        cout << d[i] << endl;
    }
    return 0;
}

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

using namespace std;

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

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

#endif

void Main() {
    ll N;
    cin >> N;
    set<ll> S;
    rep(i, N) {
        ll s;
        cin >> s;
        S.insert(s);
    }
    ll ans = 0;
    ll m;
    cin >> m;
    rep(i, m) {
        ll x;
        cin >> x;
        if (S.count(x)) {
            ans ++;
        }
    }
    cout << ans << '\n';
}

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



Measured memory_bytes: 3240
N = int(input())
values = list(map(int,input().split()))
costs = list(map(int,input().split()))
dictionary = []
for v in range(N):
  dictionary.append([values[v],costs[v]])
x,y=0,0
result = []
for i in range(N):
  if dictionary[i][0] - dictionary[i][1]>0:
    result.append(dictionary[i][0]-dictionary[i][1])
print(sum(result))

Measured memory_bytes: 3064
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 101
#define MAX_W 100001
long long dp[MAX_N][MAX_W];

int main()
{
    long long N;
    cin>>N;
    long long W;
    cin>>W;
    vector<vector<long long>>v(N,vector<long long>(2));
    for (long long i=0; i <N;i++)
    {
        cin>>v[i][0]>>v[i][1];
    }
    for(long long i=0; i<=W; i++)
    {
        dp[0][i]=0;
    }
    for(long long i=0; i<N;i++)
    {
        for(long long j=0; j<=W; j++)
        {
            if(j<v[i][1])
            {
                dp[i+1][j]=dp[i][j];
            }
            else
            {
                dp[i+1][j]=max(dp[i][j],dp[i][j-v[i][1]] +v[i][0]);
            }
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
    
}                                            
                                            
   
    
            
      


Measured memory_bytes: 11436
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int h,w,n;
	cin >>h>>w>>n;
	int a[n];
	vector<int> b;
	int f[h][w];
	for(int i=0;i<n;++i){
		cin >>a[i];
		for(int j=0;j<a[i];++j){
			b.push_back(i);
		}
	}
	for(int i=0;i<h;++i){
		if(i%2==0){
			for(int j=0;j<w;++j){
				f[i][j]=b[i*w+j];
			}
		}else{
			for(int j=0;j<w;++j){
				f[i][w-1-j]=b[i*w+j];
			}
		}
	}
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			cout<<f[i][j]+1;
			if(j==w-1){cout<<endl;}else{cout<<" ";}
		}
	}
	return 0;
}

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

vector<int>E[100];
bool used[200];
int match[200];

bool dfs(int u) {
	used[u] = true;
	for (int v : E[u]) {
		int w = match[v];
		if (w == -1 || (!used[w] && dfs(w))) {
			match[u] = v; match[v] = u;
			return true;
		}
	}
	return false;
}
int x[100], y[100], z[100], a[100], b[100];
double d[100][100];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)scanf("%d%d%d", &x[i], &y[i], &z[i]);
		rep(i, m)scanf("%d%d", &a[i], &b[i]);
		rep(i, n)rep(j, m)d[i][j] = hypot(x[i] - a[j], y[i] - b[j]) / z[i];
		double l = 0, r = 100000;
		rep(i, 100) {
			double t = (l + r) / 2;
			rep(j, n) {
				E[j].clear();
				rep(k, m) {
					if (d[j][k] <= t)E[j].push_back(n + k);
				}
			}
			int cnt = 0;
			memset(match, -1, sizeof(match));
			rep(j, n) {
				if (match[j] == -1) {
					memset(used, 0, sizeof(used));
					cnt += dfs(j);
				}
			}
			if (cnt == m)r = t;
			else l = t;
		}
		printf("%.14lf\n", l);
	}
}

Measured memory_bytes: 3308
N,W=map(int,input().split())
I=[[*map(int,input().split())]for _ in[0]*N]
I=[0]+I
C=[[0]*-~W for _ in[0]*-~N]
G=[[0]*-~W for _ in[0]*-~N]
for i in range(1,N+1):
 for w in range(1,W+1):
  C[i][w]=C[i-1][w]
  if I[i][1]>w:continue
  if I[i][0]+C[i-1][w-I[i][1]]>C[i-1][w]:
   C[i][w]=I[i][0]+C[i-1][w-I[i][1]]
   G[i][w]=1
m=C[N][W]
w=W
D=[]
for i in range(N,0,-1):
 if G[i][w]:
  D+=[i]
  w-=I[i][1]
print(C[N][W])


Measured memory_bytes: 33188
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	double r;
	cin >> r;

	cout << 2.0 * 3.141592 * r << endl;
	return 0;
}


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

char map[100][100];

int main(){
    int h, w;

    while(cin >> h >> w, h != 0 || w != 0){
        int x, y;
        bool loop = false;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> map[j][i];
            }
        }
        x = 0;
        y = 0;
        for(int i=1; i<=10000; i++){
            if(map[x][y] == '!'){
                loop = true;
                break;
            }
            if(map[x][y] == '.'){
                break;
            }
            if(map[x][y] == '>'){
                map[x][y] = '!';
                x++;
            }
            else if(map[x][y] == '<'){
                map[x][y] = '!';
                x--;
            }
            else if(map[x][y] == 'v'){
                map[x][y] = '!';
                y++;
            }
            else if(map[x][y] == '^'){
                map[x][y] = '!';
                y--;
            }
        }
        if(loop) cout << "LOOP" << endl;
        else cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 0
input()
a=map(int,input().split())
b=map(int,input().split())
i=next(a)
r=0
for j,k in zip(a,b):
	s=min(i,k)
	k-=s
	t=max(min(j,k),0)
	j-=t
	i=j
	r+=s+t
print(r)

Measured memory_bytes: 18624
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };

int main() {
	int n, a;
	std::cin >>n >> a;
	int b=0;
	n %= 500;
	b += n;
	if (b <= a)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll c[20][20];

int main(){
  int H,W; cin>>H>>W;
  CINA2(c,10,10);
  for(int k = 0;k<10;++k){
    for(int i=0;i<10;++i){
      for(int j=0;j<10;++j){
        c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  
  ll ans = 0;
  int a;
  for(int i=1;i<=H;++i){
    for(int j=1;j<=W;++j){
      cin >> a;
      if(a>=0){
        ans += c[a][1];
      }
    }
  }
  cout << ans <<"\n";
}

Measured memory_bytes: 256
let n = Scanf.scanf " %d " (fun x -> x)


let odd, four =
  let rec count two odd four n =
    if n = 0 then (two,odd,four)
    else
      let x = Scanf.scanf " %d " (fun n -> n) in 
      if x mod 2 = 1 then count two (odd+1) four (n-1)
      else if x mod 4 = 0 then count two odd (four+1) (n-1)
      else count (two+1) odd four (n-1)
  in
  let two, odd, four = count 0 0 0 n in 
  if two > 0 then (odd + 1, four) else (odd, four)


let () = 
  print_endline (if (four + 1) >= odd then "Yes" else "No")

Measured memory_bytes: 2688
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
arr = [a,b,c,d,e]

def five_antennas(arr, k)
  for i in 0..3 do
    for j in i+1..4
      if (arr[j] - arr[i]) > k
        return ":("
      end
    end
  end
  "Yay!"
end

puts five_antennas(arr, k)


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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i));
            var n = input.ElementAt(0);
            var k = input.ElementAt(1);
            if (n % k == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;

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

    int vec[40];
    for (int i = 0; i < 40; i++)vec[i] = i;
    for (int i = 0; i < n; i++){
        int a, b;
        char com;
        cin >> a >> com >> b;
        int t = vec[a];
        vec[a] = vec[b];
        vec[b] = t;
    }
    for (int i = 1; i <= w; i++){
        cout << vec[i] << endl;
    }
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    string s;
    cin >> s;

    ll size = s.size();
    ll ans = 0;
    int count = 0;

    rep(i, size){
        if(s[i] == 'W'){
            ans += (i - count);
            count++;
        }
    }

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


Measured memory_bytes: 3716
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto s = sread();
    auto s_len = s.length;
    // writeln(s_len);
    foreach (i; 0 .. s_len)
    {
        write('x');
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n, k; ll a; ll x[100000]; ll csum = 0; ll psum = 0;
	cin >> n >> k;
	int i;
	for (i = 0; i < n; i++) {
		cin >> a; x[i] = a;
		if (i < k)csum += a;
		else if (i >= k && a > 0)psum+=a;
	}
	ll ma = max(csum,(ll)0)+psum;
	for (i = 1; i <= n - k; i++) {
		csum -= x[i - 1]; csum += x[i + k - 1];
		if (x[i - 1] > 0)psum += x[i - 1]; if (x[i + k - 1] > 0)psum -= x[i + k - 1];
		ma = max(ma, max(csum,(ll)0) + psum);
	}
	cout << ma << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n, m;
  cin >> n >> m;

  int side = n + m - 1;
  cout << (n * m) - side << "\n";

  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
mini = min(A)
i = 0
cnt = 0
f = False
while(i < N - 1):
    if f and A[i + 1] == mini:
        i += 1
        continue
    if not f and min(A[i:min(N, i + K)]) == mini:
        f = True
    i += K - 1
    cnt += 1
print(cnt)

Measured memory_bytes: 13880
#include<stdio.h>

int main(void)

{

int a,b,c;


scanf("%d %d %d",&a,&b,&c);


if(a>b){


int t;


t=a;


a=b;


b=t;


}


if(b>c){


int t;


t=b;


b=c;


c=t;


}


if(a>b){


int t;


t=a;


a=b;


b=t;


}


printf("%d %d %d\n",a,b,c);


return 0;


}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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 T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll A,B,C;
    cin  >> A>> B >> C;
    cout << (((A<C) && (C<B))||((A>C) && (C>B)) ? "Yes"  : "No")  << endl;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; n >= p * p; p++) {
        if (n % p != 0) continue;
        
        int num = 0;
        while (n % p == 0) {
            n /= p;
            num++;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

int main() {
    ll a, b; cin >> a >> b;
    auto v = prime_factorize(gcd(a, b));
    cout << v.size() + 1 << endl;
}



Measured memory_bytes: 256
#include <iostream>
                        #include<cmath>
                        #include<string>
                        using namespace std;
                        int main()
                        {
                           string s,d,u;
                          int a,b;
                          cin>>s>>d>>a>>b>>u;
                          if(u==s)
                            cout<<a-1<<" "<<b;
                          else
                            cout<<a<<" "<<b-1;
                            
                        }

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int q; cin >> q;
    bitset<64> Bit(0);
    for(int i = 0; i < q; i++){
        int n; cin >> n;
        if (n == 0){
            int m; cin >> m;
            cout << Bit[m] << endl;
        } else if (n == 1){
            int m; cin >> m;
            Bit[m] = 1;
        } else if (n == 2){
            int m; cin >> m;
            Bit[m] = 0;
        } else if (n == 3){
            int m; cin >> m;
            Bit[m] = Bit[m]^1;
        } else if (n == 4){
            cout << Bit.all() << endl;
        } else if (n == 5){
            cout << Bit.any() << endl;
        } else if (n == 6){
            cout << Bit.none() << endl;
        } else if (n == 7){
            cout << Bit.count() << endl;
        } else {
            cout << Bit.to_ulong() << endl;
        }
    }
}


Measured memory_bytes: 3068
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Main main = new Main ();
		main.solve();
	}

	private void solve() {

		Scanner sc = new Scanner (System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();

		int[] list = new int[n];
		int count = 0;

		for (int index=0; index+1<n; index++) {
			if (s.charAt(index)=='A'&&s.charAt(index+1)=='C') {
				count++;
			}
			list[index+1] = count;
		}

		for (int index=0; index<q; index++) {
			int first = sc.nextInt();
			int last = sc.nextInt();

				System.out.println(list[last-1]-list[first-1]);
		}
	}
}

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

#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >  
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    float a,b;
    a=arr[0];
    b=arr[1];
    float
     ans=(a+b)/2;
    for(int i=2;i<n;i++)
    {
    ans=(ans+arr[i])/2;
    }
    cout<<ans<<endl;
    
}



Measured memory_bytes: 3796
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll amax = 0;
    ll ans = 0;
    rep(i, n){
        if(amax <= a[i]){
            amax = a[i];
        }
        else{
            ans += amax - a[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	string S; 
	cin >> S; 
	int N = S.size(); 
	int Z = 0; int O = 0; 
	for(int i = 0; i < N; i++){
		if(S.at(i) == '0') O ++; 
		else Z ++; 
	} 
	cout << min(O, Z) * 2 << endl; 	
}

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

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


int main(){
    int A,B;
    cin >> A >>B;
    if(A == 2 || B == 2)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  rep(i,n) {
    cin >> a[i].second >> a[i].first;
  }
  sort(a.begin(),a.end());
  int time = 0;
  rep(i,n) {
    time += a[i].second;
    if(time > a[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

int main(){
  int N; cin>>N;
  int a_l[N];
  for (int i = 0; i < N; i++) {
    cin>>a_l[i];
  }
  bool flg=true;
  for (int i = 0; i < N; i++) {
    if(a_l[i]%2==0&&a_l[i]%3!=0&&a_l[i]%5!=0){
        flg=false;
    }
  }
  if(flg) cout<< "APPROVED"  << "\n";
  else cout<< "DENIED"  << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int main(){
    for(;;){
        char S[110];
        gets(S);
        if(S[0]=='.')break;
        int m=0,k=0;
        int n = strlen(S);
        stack<int> h;
        h.push(0);
        for (int i=0; i<n; i++) {
            if(S[i]=='('){
                m++;
                h.push(1);
            }
            if(S[i]==')'){
                if(h.top()==2 or h.top()==0){
                    m=-1;
                    break;
                }
                h.pop();
                m--;
            }
            if(S[i]=='['){
                k++;
                h.push(2);
            }
            if(S[i]==']'){
                if (h.top()==1 or h.top()==0){
                    k=-1;
                    break;
                }
                h.pop();
                k--;
            }
            if (m<0 or k<0) {
                break;
            }
        }
        if(m==0 and k==0){
            cout <<"yes"<<endl;
        }else{
            cout << "no"<<endl;
        }
    }
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>


int main(void) {
    long N,K;
    std::cin >> N >> K;
    long h[100000]={};
    for(long i=0; i<N; i++){
        std::cin >> h[i];
    }
    long count=0;
    for(long i=0; i<N; i++){
        if(h[i]>=K){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  char c;
  cin>>c;
  char ans='a'+(c-'a'+1);
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	int k;
	cin>>n>>k;
	double ans=0.0;
	for(int i=1;i<=n;++i)
	{
		double res=(double)(1.0/n);
		int sum=i;
		while(sum<k)
		{
			sum*=2;
			res*=0.5;
		}
		ans+=res;
	}
	cout<<fixed<<setprecision(12)<<ans<<endl;
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
 
    vector<pair<ll,int>> fs;
    for(ll i = 2; i*i <= n; i++){
        int x = 0;
        while(n%i == 0){
            n /= i;
            x++;
        }
        fs.emplace_back(i,x);
    }
    if(n != 1) fs.emplace_back(n,1);

    int ans = 0;
    for(auto p : fs){
        int x = p.second;
        int b = 1;
        while(b <= x){
            x -= b;
            b++;
            ans++;
        }
    }
  
    cout << ans << endl;
    return 0;
}

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

int a[60];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	long long ans = 0;
	for (int x = 0; x <= n; x++){
		for (int y = 0; x + y <= n && x + y <= k; y++){
			vector <int> v;
			long long sum = 0;
			for (int i = 0; i < x; i++){
				v.push_back(a[i]);
				sum += a[i];
			}
			for (int i = n - 1; i > n - 1 - y; i--){
				v.push_back(a[i]);
				sum += a[i];
			}
			sort(v.begin(), v.end());
			int i = 0;
			while (i < v.size() && i < k - x - y && v[i] < 0) sum -= v[i], i++;
			ans = max(ans, sum);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define debug(x) cout<<"x :"<<x<<endl;
#define case(t,ans) cout<<"Case #"<<t<<": "<<ans<<endl;
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long 
//typedef long long ll;
//typedef vector<int> vi;
//typedef pair<int,int> pi;

using namespace std;

void solve();
ll cal(ll n)
{
    if(n==1) return 1;
    return (2*cal(n/2)+1);
}
int main(){
  //  #ifndef ONLINE_JUDGE
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  //  #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
  //  int t;
  //  cin>>t;
   // while(t--)
       solve();
    
    
    return 0;
}

void solve()
{
    ll h;
    cin>>h;
    
    cout<<cal(h)<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    cin >> m;
    vector<int> t(m);
    rep(i,m) cin >> t[i];
    sort(d.begin(),d.end());
    sort(t.begin(),t.end());
    int j=0;
    bool flag=1;
    rep(i,m) {
        if (j==n) break;
        while (d[j]<t[i]) {
            ++j;
            if (j==n) {
                flag=0;
                break;
            }
        }
        if (j==n) break;
        if (d[j]!=t[i]) {
            flag=0;
            break;
        } else ++j;
    }
    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
   
    return 0;  
}

Measured memory_bytes: 4812