akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
int mod = 1000000007;
const int N = 1e6+10;

int main() 
{
  //  freopen("in.txt", "r", stdin);
   int a, b,c;
   while (~scanf("%d%d%d", &a, &b, &c))
   {
        printf("%d\n", a^b^c);
   }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
    int N;
    vector<int> a;
    
    cin >> N;
    for (int i=0;i<N;i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    
    int sum = 0;
    for (int i=0;i<N;i++) {
        sum += a[i] - 1;
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())
tan = 30 * H + (30 * (M / 60))
tyo = 6 * M
kakudo = abs(tan - tyo)
ans = pow(A, 2) + pow(B, 2) - 2 * A * B * math.cos(math.radians(kakudo))
print(pow(ans, 0.5))

Measured memory_bytes: 9520
from math import sqrt, factorial
N = int(input())
x_y = {}
for i in range(N):
    x, y = map(int, input().split())
    x_y[i] = (x, y)

c = 0
d = 0
for i in range(N):
    _d = 0
    for j in range(N):
        if i != j:
            _x = (x_y[i][0] - x_y[j][0]) ** 2
            _y = (x_y[i][1] - x_y[j][1]) ** 2
            d += sqrt(_x + _y)
            c += 1

print(d * (N-1)/c)

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

int main() {
  int a, b, k,count=0;
  cin >> a >> b >> k;
  for(int i = 100;i > 0; i--){
    if(a%(i)==0&&b%(i)==0) count++;
    if(count==k){
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int a, b;
    cin >> a >> b;

    int res = a + b;
    if ( res >= 10 ) {
        cout << "error" << endl;
    } else {
        cout << res << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  long long int n,k;
  cin>>n>>k;
  long long int a[n],i,sum=0;
  for(i=0;i<n;i++)
  cin>>a[i];
  sort(a,a+n);
  for(i=0;i<k;i++)
  {
      sum=sum+a[i];
  }
  cout<<sum<<"\n";
}

Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

// https://qiita.com/hkrutknouch/items/48d65643c62676725ed2

int main(void) {
    int n, q;
    string s;
    cin >> n >> q;
    cin >> s;

    int *l = new int[q];
    int *r = new int[q];

    for(int i = 0;  i < q; ++i) {
        cin >> l[i] >> r[i];
    }

    // 一つ多くする
    int *a = new int[s.size()+1];
    a[0] = 0;
    int cum = 0;

    // 累積和
    for(size_t i = 0; i < s.size(); ++i) {
        if(i+1 < s.size() && s[i] == 'A' && s[i+1] == 'C') {
            a[i+1] = a[i]+1;
        } else {
            a[i+1] = a[i];
        }
    }

    for(int i = 0; i < q; ++i) {
        cout << a[--r[i]] - a[--l[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

typedef long long i64;

const int nmax = 1e5 + 5;
const int mod = 1e9 + 7;
int f[nmax + 1];
i64 fact[nmax + 1], inv[nmax + 1];

i64 lgput (i64 b, int p) {
    i64 ans = 1;
    while (p > 0) {
        if (p & 1) {
            ans = ans * b % mod;
        }
        p >>= 1;
        b = b * b % mod;
    }
    return ans;
}

i64 C (int x, int y) {
    if (x < y) return 0;
    return fact[ x ] * inv[ y ] % mod * inv[x - y] % mod;
}

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

    int cate = n;
    for (int i = 1; i <= n + 1; ++ i) {
        int x;
        cin >> x;
        if (f[ x ] == 0) f[ x ] = i;
        else cate = n + 1 - (i - f[ x ] + 1);
    }

    fact[ 0 ] = 1;
    for (int i = 1; i <= nmax; ++ i) fact[ i ] = fact[i - 1] * i % mod;

    inv[ nmax ] = lgput(fact[ nmax ], mod - 2);
    for (int i = nmax - 1; i >= 0; -- i) {
        inv[ i ] = inv[i + 1] * (i + 1) % mod;
    }

    for (int i = 1; i <= n + 1; ++ i) {
        i64 ans = C(n + 1, i) - C(cate, i - 1);
        if (ans < 0) ans += mod;
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3200
fn read_split<T : std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn main() {
    let input : Vec<i32> = read_split();
    let watch = input[1] * 2 + 1;
    let mut ans = input[0] / watch;
    if (input[0] % watch) > 0{
        ans += 1;
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG //提出時に消す
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  ull a;
  double b;
  cin >> a >> b;
  ull bint = b * 100.1;
  //cout << bint << endl;
  cout << (a * bint) / 100 << endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=100010;
int n,m,a[N],ql[N],qr[N],id[N];
ll tot=0,val[N];
bool vis[N];

int main()
{
	n=rd();m=rd();
	fo(i,1,n)a[i]=rd(),ql[i]=rd(),qr[i]=rd(),val[i]=1ll*(m-a[i])*qr[i]+1ll*a[i]*ql[i],tot-=1ll*ql[i]*a[i];
	fo(i,1,n)id[i]=i;
	sort(id+1,id+n+1,[](int a,int b){return val[a]>val[b];});
	ll sum=0,ans;int hh=0;
	fo(i,1,n){
		sum+=val[id[i]];
		if(sum+tot>=0){sum-=val[id[i]];hh=i-1;ans=1ll*i*m;break;}
		vis[id[i]]=1;
	}
	fo(i,1,n){
		ll tmp=sum+tot;
		if(vis[i]){tmp-=val[i];tmp+=val[id[hh+1]];}
		int l=0,r=m;
		while(l<=r){
			int mid=(l+r)>>1;
			ll hhh=tmp+1ll*a[i]*ql[i];
			if(mid<a[i])hhh-=1ll*(a[i]-mid)*ql[i];
			else hhh+=1ll*(mid-a[i])*qr[i];
			if(hhh>=0)r=mid-1;else l=mid+1;
		}++r;
		if(r<=m)ans=min(ans,1ll*hh*m+r);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  string s;
  cin>>s;
  bool f=0;
  f|=(s[0]==s[1]&&s[1]==s[2]);
  f|=(s[1]==s[2]&&s[2]==s[3]);
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 764
using System;

namespace Beginner086_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            args = Console.ReadLine().Split(' ');
            a = int.Parse(args[0]);
            b = int.Parse(args[1]);
            int hoge = a * b;
            if (hoge % 2 == 0)
            {
                Console.Write("Even");
            }
            else
            {
                Console.Write("Odd");
            }
        }
    }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

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

    return 0;
}


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

signed main(void)
{
	char a, b;
	cin >> a >> b;
	if ((a == 'H' && b == 'H')|| (a == 'D' && b == 'D'))
		cout << 'H' << endl;
	else
		cout << 'D' << endl;
	return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);
		String s = input.readLine( );
		String t = input.readLine( );
		int answer = n * 2;

		for(int i=0; i<n; i++){
			if(s.substring(i).equals(t.substring(0, n-i))){
				answer = answer - (n-i);
				break;
			}
		}

		System.out.println(answer);

	}
}


Measured memory_bytes: 21204
// https://atcoder.jp/contests/abc088/tasks/abc088_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }
PII mv[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    PII start = {1, 1}, goal = {h, w}, now;
    vector<vector<char>> s(h + 2, vector<char>(w + 2, '#'));
    int bcnt = 0;
    REP(i, h) REP(j, w) {
        cin >> s[i + 1][j + 1];
        if (s[i + 1][j + 1] == '#')
            bcnt++;
    }

    queue<PII> q;
    q.push(start);
    vector<vector<int>> dist(h + 2, vector<int>(w + 2, INF));
    dist[start.first][start.second] = 0;
    bool ok = false;
    while (!q.empty()) {
        now = q.front();
        q.pop();
        if (now == goal) {
            ok = true;
            break;
        }
        int dist_n = dist[now.first][now.second];
        for (auto x : mv) {
            if (s[now.first + x.first][now.second + x.second] == '.' &&
                dist[now.first + x.first][now.second + x.second] == INF) {
                q.push({now.first + x.first, now.second + x.second});
                dist[now.first + x.first][now.second + x.second] = dist_n + 1;
            }
        }
    }

    if (ok)
        cout << h * w - bcnt - dist[goal.first][goal.second] - 1 << endl;
    else
        cout << "-1\n";
    // for (auto x : s) {
    //     cout << x << endl;
    // }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int LL;
vector<pair<int,int> > v1;
int s[200005];

int main(){
	int n;
	int a,b,c;
	int i,j,k;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(make_pair(a,i));
	}
	sort(v1.begin(),v1.end());
	for(i=0;i<n;i++){
		if(i<n/2)a=n/2;
		else a=n/2-1;
		s[v1[i].second]=v1[a].first;
	}
	for(i=0;i<n;i++){
		cout<<s[i]<<endl;
	}
	return 0;
}
	


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

using namespace std;

int main(){
    int H,W,ans=0;
    char S[52][52]={};
    int checkx[8] = {-1,0,1,-1,1,-1,0,1}, checky[8] = {1,1,1,0,0,-1,-1,-1};

    cin >> H >> W;
    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            cin >> S[i][j];
        }
    }

    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            if(S[i][j] == '#'){}
            else{
                for(int k= 0; k < 8; k++){
                    if(S[i+checkx[k]][j+checky[k]] == '#'){
                        ans += 1;
                    }
                }
                S[i][j] = '0' + ans;
                ans = 0;
            }
        }
    }

    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            cout << S[i][j];
        }
        cout << '\n';
    }
}

Measured memory_bytes: 256
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
auto main() -> int {
	ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b, c, d; cin >> a >> b >> c >> d;
    int cur = 1;
    while (a > 0 && c > 0) {
        if (cur & 1) c -= b;
        else a -= d;
        cur ^= 1;
    }
    if (a > 0) cout << "Yes\n";
    else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3652
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
    mut a:[i64],
    }
    a.sort_by(|x, y| x.cmp(y).reverse());
    let ans = a[0] +
        if (a.len() - 1) % 2 == 1 {
            2 * a[1..=(a.len() - 1) / 2].iter().sum::<i64>()
        } else {
            2 * a[1..=(a.len() - 1) / 2].iter().sum::<i64>() - a[(a.len() - 1) / 2]
        };
    println!("{:?}", ans);
}


Measured memory_bytes: 6168
import sys
import math,bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,OrderedDict
def I(): return int(sys.stdin.readline())
def neo(): return map(int, sys.stdin.readline().split())
def Neo(): return list(map(int, sys.stdin.readline().split()))
mod = 10**9+7
N = I()
p,q,r = 1,1,1
if N == 1:
    print(0)
    exit()
for i in range(N):
    p = (p*10)%mod
    q = (q*9)%mod
    r = (r*8)%mod
print((p-2*q+r)%mod)


Measured memory_bytes: 9472
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/
 
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()
 
const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
 
template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}
 
int h, w, a, b;
int f[MXN];
 
inline int Add(int a, int b) {
	a += b;
	if(a > mod) a -= mod;
	if(a < mod) a += mod;
	return a;
}
 
inline int Mul(int a, int b) {
	return (a*1ll*b)%mod;
}
 
inline int Pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b&1) res = Mul(res,a);
		b >>= 1;
		a = Mul(a,a);
	}
	return res;
}
 
inline int Div(int a, int b) {
	return Mul(a,Pow(b,mod-2));
}
 
inline int Cnk(int n, int k) {
	return Div(f[n],Mul(f[k],f[n-k]));
}
 
int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> h >> w >> a >> b;
	f[0] = 1;
	rep(i,1,200050) f[i] = Mul(f[i-1],i);
	ull cur = Cnk(h+w-2,h-1), res = 0;
	rep(i,0,b-1) res = (res+Mul(Cnk(h-a+i-1,h-a-1),Cnk(w+a-i-2,a-1)))%mod;
	cout << (cur-res+mod)%mod << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
 
void solve(){
	cin >> n >> k;
	if(n*4<k || n*2>k || k%2!=0){
		cout << "No";
		return;
	}	
	cout << "Yes";
 
}
 
int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    n--;
    long long p=26,d=1;
    while(n-p>=0){
        n-=p;
        d++;
        p*=26;
    }
    char name[d];
    for(int i=0;i<d;i++){
        name[d-i-1]=char('a'+n%26);
        n/=26;
    }
    for(int i=0;i<d;i++)cout<<name[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ULL unsigned long long
using namespace std;
int read(){
    int f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
    return f*x;
}
#define MAXN 10000
#define Mod 100007
#define INF 0x3f3f3f3f
struct node{int pos;ULL val;};
vector<node> H[Mod+5];
int n;
char S[MAXN+5];
ULL p[MAXN+5]={1},Hash[MAXN+5];
ULL GetHash(int l,int r){return Hash[r]-Hash[l-1]*p[r-l+1];}
bool Hash_Find(ULL val,int pos,int len){
	int tmp=val%Mod;
	for(int i=0;i<int(H[tmp].size());i++){
		node Now=H[tmp][i];
		if(Now.val==val&&Now.pos+len<=pos)
			return 1;
	}
	return 0;
}
void Hash_Insert(ULL val,int pos){
	H[val%Mod].push_back((node){pos,val});
	return ;
}
bool check(int len){
	for(int i=0;i<Mod;i++)
		H[i].clear();
	for(int i=1;i+len-1<=n;i++){
		if(Hash_Find(GetHash(i,i+len-1),i,len))
			return 1;
		Hash_Insert(GetHash(i,i+len-1),i);
	}
	return 0;
}
int main(){
	for(int i=1;i<=MAXN;i++)
		p[i]=p[i-1]*107;
	n=read();
	scanf("%s",S+1);
	for(int i=1;i<=n;i++)
		Hash[i]=Hash[i-1]*107+(S[i]-'a');
	int L=0,R=n+1;
	while(L+1<R){
		int Mid=(L+R)>>1;
		if(check(Mid))
			L=Mid;
		else R=Mid;
	}
	printf("%d\n",L);
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(a) signed(a.size())
using namespace std;

void solve(){
	ll n;
	cin >> n;
	vector<ll> ar(n+1,0);
	for(ll i=1;i<=n;i++){
		cin >> ar[i];
	}
	ll ans = 0;
	for(ll i=2;i<=n;i++){
		if(ar[i]<ar[i-1]){
			ans += ar[i-1] - ar[i];
			ar[i] = ar[i-1];
		}
	}
	cout << ans << "\n";
}

int main() {
    FAST;
    ll t=1;
    //cin>>t;
    while(t--) solve();	
    return 0;
}



Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h;
  cin>>h;
  int a=1;
  while(1){
    if(h<pow(2,a))break;
    a++;
  }
  long long ans=powl(2,a)-1;
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int hs[n];
    for (int i = 0; i < n; i++) cin >> hs[i];
    sort(hs, hs+n, greater<int>());
    long long cnt = 1;
    for (int i = 0; i < n; i++) 
        cnt += max(hs[i] - i/4, 0);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1172
//abc177_d.cpp
//Sat Aug 29 20:53:41 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	vector<int> g[n];
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int> visited(n,-1);
	int group = 0;
	rep(i,n){
		if (visited[i]==-1){
			queue<int> q;
			q.push(i);
			visited[i] = group;
			while(!q.empty()){
				int cur = q.front();q.pop();
				rep(j,g[cur].size()){
					int next = g[cur][j];
					if(visited[next]==-1){
						visited[next] = visited[cur];
						q.push(next);
					}
				}
			}
			group++;
		}
	}
	vector<int> z(group+10,0);
	rep(i,n){
		z[visited[i]]++;
	}
	int ans = 0;
	rep(i,group+10){
		ans = max(ans,z[i]);
	}
	cout << ans << endl;
}

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

int N;
long long a[405], pre[405];
long long dp[405][405];

// dp[i][j] = min cost to combine from i to j index

long long rec(int i, int j)
{
    if (i == j)
        return dp[i][j] = 0;

    if (j == i + 1)
        return dp[i][j] = a[i] + a[j];

    if (dp[i][j] != -1)
        return dp[i][j];

    dp[i][j] = LLONG_MAX;
    for (int k = i; k < j; k++)
        dp[i][j] = min(dp[i][j], rec(i, k) + rec(k + 1, j));

    if (i > 0)
        dp[i][j] += pre[j] - pre[i - 1];
    else
        dp[i][j] += pre[j];

    return dp[i][j];
}

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

    pre[0] = a[0];
    for (int i = 1; i < N; i++)
        pre[i] = pre[i - 1] + a[i];

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            dp[i][j] = -1;

    long long ans = rec(0, N - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1536
MOD = 1000000007

def fpow(x, n):
    e = 1
    while n > 1:
        if n & 1: e = (e*x) % MOD
        x = (x*x) % MOD
        n >>=1
    return (x*e)%MOD

N = int(input())
print((fpow(10, N) - 2*fpow(9, N) + fpow(8, N))%MOD)

Measured memory_bytes: 9184
A, B, K = [int(i) for i in input().split()]

if (B - A) < 2*K-1:
    for i in range(A, B+1):
        print(i)
else:
    C = set(range(A, A+K))
    for i in range(B-K+1, B+1):
        C.add(i)
    C = list(C)
    C.sort()
    for i in C:
        print(i)

Measured memory_bytes: 3060
import collections
import bisect
s = input()
t = input()
if not set(t).issubset(set(s)): print(-1)
else:
    d = collections.defaultdict(list)
    for i, letter in enumerate(s):
        d[letter].append(i+1)
    prev = 0
    cnt = 0
    for target in t:
        li = d[target]
        idx = bisect.bisect_left(li, prev+1)
        if idx == len(li):
            cnt += 1
            prev = li[0]
        else:
            prev = li[idx]
    print(cnt * len(s) + prev)

Measured memory_bytes: 7924
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define PI 3.1415926535

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
  ll N; cin >> N;
  vector<ll> A(N);
  ll x = 0;
  rep(i,N){
    cin >> A[i];
    if(i % 2 == 0) x += 2*A[i];
    else x -= 2*A[i];
  }
  vector<ll> ans(N);
  ans[0] = x/2;
  repr(i,1,N){
    ans[i] = 2*A[i-1] - ans[i-1];
  }  
  rep(i,N-1){
    cout << ans[i] << " ";
  }
  cout << ans[N-1] << endl;
  
}
   

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25


int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> oks(n+1, true);
    rep(i, m){
        int t; cin >> t;
        oks[t] = false;
    }
    vector<ll> dp(n+1);
    dp[0] = 1;
    for(int now = 0; now < n; now++){
        for(int next = now+1; next <= min(n, now+2); next++){
            if(oks[next]){
                dp[next] += dp[now];
                dp[next] %= MOD;
            }
        }
    }
    cout << dp[n] << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
 
    if (A<=B && C<=D){
        cout << A+C << endl;
    }
    else if (A<=B && D<=C){
        cout << A+D << endl;
    }
    else if (B<=A && C<=D){
        cout << B+C << endl;
    }
    else if (B<=A && D<=C){
        cout << B+D << endl;
    }
    return 0;    
}

Measured memory_bytes: 256
n,y = map(int,input().split())

for i in range(min(y//10000+1,n+1)):
    for j in range(min((y-10000*i)//5000+1,n-i+1)):
        k=n-i-j
        if i*10000+j*5000+k*1000==y and i+j+k==n:
            print(i,j,k);exit()
else:
    print(-1,-1,-1)

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

const int N = 2e5 + 1;

int a[N], b[N], c[N];
int lb[N], rb[N];

int main () {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
		scanf("%d", a + i);
	for (int i = 1; i <= n; i ++)
		scanf("%d", b + i);

	for (int i = 1; i <= n; i ++)
		rb[a[i]] = i;
	for (int i = n; i >= 1; i --)
		lb[b[i]] = i;

	int sh = 0;
	for (int i = 1; i <= n; i ++) if (lb[i] && rb[i])
		sh = max(sh, rb[i] - lb[i] + 1);

	for (int i = 1; i <= n; i ++)
		c[(i + sh > n) ? (i + sh - n) : (i + sh)] = b[i];

	int ok = 1;
	for (int i = 1; i <= n; i ++) if (a[i] == c[i])
		ok = 0;

	if (ok) {
		puts("Yes");
		for (int i = 1; i <= n; i ++)
			printf("%d%c", c[i], "\n "[i != n]);
	} else {
		puts("No");
	}
}

Measured memory_bytes: 7680
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict,deque


## input
N,Q = map(int, input().split())
cnt = [0 for _ in range(N)]
route = defaultdict(lambda:set([]))
for _ in range(N-1):
  a,b = map(int, input().split())
  route[a-1].add(b-1)
  route[b-1].add(a-1)
for _ in range(Q):
  p,x = map(int, input().split())
  cnt[p-1] += x

## solve
stk = deque([0])
cost = [-1 for _ in range(N)]
cost[0] = cnt[0]
while len(stk) > 0:
  p = stk.pop()
  for q in route[p]:
    if cost[q] >= 0:
      continue
    cost[q] = cost[p] + cnt[q]
    stk.append(q)

print(*cost)


Measured memory_bytes: 123724
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> A(n);
    rep(i,n) {
        cin >> A[i];
    }
    int cnt = 0;
    rep(i,n) {
        int j=1;
        while(j<=d) {
            cnt++;
            j += A[i];
        }
    }
    cnt += x;
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def perm(n,a,R):
    return (fact[n]*modinv2(fact[n-a],R))

def comb(n,a,R):
    return (fact[n]*modinv2(fact[n-a]*fact[a],R))

def factinit(n,R):
    global fact
    fact = [1]*(n+1)
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%R

n,m = inm()
factinit(m,R)
x = 0
for k in range(n+1):
    inc = comb(n,k,R)*((-1)**k)*perm(m,k,R)* \
          pow(perm(m-k,n-k,R),2,R)
    inc %= R
    x = (x+inc)%R
    #ddprint(f"{k=} {inc=} {x=}")
print(x%R)


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

#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)

using ll = long long;
#define INF 1e9


int main(){
  int n;
  cin >> n;
  vector<int> a(n), b;
  REP(i, n){
    cin >> a[i];
    if(i % 2 == 0){
      b.push_back(a[i]);
    }
    else{
      b.insert(b.begin(), a[i]);
    }
  }

  if(n % 2){
    reverse(b.begin(), b.end());
  }
  REP(i, n){
    cout << b[i] << " ";
  }
  cout << endl;
  



  return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

struct State {
  int city;
  ll remaining;
  ll refueling;
  bool operator<(const State& dp) const {
    if (refueling != dp.refueling) {
      return refueling < dp.refueling;
    }
    return remaining > dp.remaining;
  }
  bool operator>(const State& dp) const {
    return dp < *this;
  }
};

ll dist[301][301];
State seens[301][301];

int main() {
  ll n, m, l;
  scanf("%lld %lld %lld", &n, &m, &l);

  rep(i, m) {
    ll a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);
    if (c <= l) {
      dist[a][b] = dist[b][a] = c;
    }
  }

  rep(i, n) {
    int city = i + 1;
    State init = {city, l, 0};

    State* seen = seens[city];
    seen[city] = init;

    priority_queue<State, vector<State>, greater<State>> que;
    que.push(init);

    while (!que.empty()) {
      State here = que.top();
      que.pop();
      if (seen[here.city] < here) continue;
      rep(j, n) {
        State there = here;
        there.city = j + 1;
        if (here.city == there.city) continue;
        ll d = dist[here.city][there.city];
        if (d == 0) continue;
        there.remaining -= d;
        if (there.remaining < 0) {
          there.remaining = l - d;
          ++there.refueling;
        }
        State& s = seen[there.city];
        if (s.city == there.city && !(there < s)) continue;
        s = there;
        que.push(there);
      }
    }
  }
  ll q;
  scanf("%lld", &q);
  rep(i, q) {
    ll s, t;
    scanf("%lld %lld", &s, &t);
    State& st = seens[s][t];
    if (st.city == 0) {
      out(-1);
    } else {
      out(st.refueling);
    }
  }
}


Measured memory_bytes: 4572
from collections import deque
N,M=map(int,input().split())
S=[list(input()) for i in range(N)]
V=N*M+2
G=[[] for i in range(V)]
L=[0]*V
I=[0]*V
INF=10**15
def ae(fr,to,ca):
  global G
  G[fr].append([to,ca,len(G[to]),0])
  G[to].append([fr,0,len(G[fr])-1,0])

def bfs(s):
  global INF,L,V,G
  L=[-1]*V
  Q=deque()
  L[s]=0
  Q.append(s)
  while(len(Q)):
    x=Q.popleft()
    for i in range(len(G[x])):
      if G[x][i][1]>0 and L[G[x][i][0]]<0:
        L[G[x][i][0]]=L[x]+1
        Q.append(G[x][i][0]) 

def dfs(v,t,f):
  global I,G,V
  if v==t:
    return f
  for i in range(I[v],len(G[v])):
    if G[v][i][1]>0 and L[v]<L[G[v][i][0]]:
      d=dfs(G[v][i][0],t,min(f,G[v][i][1]))
      if d>0:
        G[v][i][1]-=d
        G[v][i][3]+=d
        G[G[v][i][0]][G[v][i][2]][1]+=d
        G[G[v][i][0]][G[v][i][2]][3]-=d
        return d
    I[v]+=1
  return 0

def mf(s,t):
  global L,I,INF,V
  fl=0
  while(True):
    bfs(s)
    if L[t]<0:
      break
    I=[0]*V
    f=0
    while(True):
      f=dfs(s,t,INF)
      if f<=0:
        break
      fl+=f
  return fl

w4x=[0,1,0,-1]
w4y=[1,0,-1,0]
v=0
for i in range(N):
  for j in range(M):
    if (i+j)&1:
      ae(i*M+j,V-1,1)
      continue
    ae(V-2,i*M+j,1)
    if S[i][j]=='#':
      continue
    for k in range(4):
      v=[i+w4y[k],j+w4x[k]]
      if min(v)<0 or v[0]==N or v[1]==M:
        continue
      if S[v[0]][v[1]]=='.':
        ae(i*M+j,v[0]*M+v[1],1)
print(mf(V-2,V-1))
for i in range(N*M):
  for j in range(len(G[i])):
    if G[i][j][3]>0:
      v=G[i][j][0]
      if v>=N*M:
        continue
      if i+M==v:
        S[i//M][i%M]='v'
        S[i//M+1][i%M]='^'
      elif i-M==v:
        S[i//M-1][i%M]='v'
        S[i//M][i%M]='^'
      elif i+1==v:
        S[i//M][i%M]='>'
        S[i//M][i%M+1]='<'
      elif i-1==v:
        S[i//M][i%M-1]='>'
        S[i//M][i%M]='<'
for i in range(N):
  print(''.join(S[i]))

Measured memory_bytes: 85336
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };

vector<int>e[10];
int used[10];
int n, m;

int dfs(int now,int sum) {
	if (sum == n)return 1;
	int ret = 0;
	fore(x,e[now]) {
		if (used[x] == 0) {
			used[x] = 1;
			ret += dfs(x,sum+1);
			used[x] = 0;
		}
	}
	return ret;
}


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

	rep(i, 0, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		e[a].pb(b);
		e[b].pb(a);
	}

	used[0] = 1;
	cout << dfs(0, 1) << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

def check_signature(str_1, str_2):
    dict_s = {}
    dict_t = {}
    for s_, t_ in zip(s, t):
        if s_ not in dict_s:
            dict_s[s_] = t_
        if t_ not in dict_t:
            dict_t[t_] = s_
        if dict_s[s_] != t_ or dict_t[t_] != s_:
            return False
    else:
        return True

print('Yes' if check_signature(s, t) else 'No')

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,C;
  cin>>N>>C;
  vector<vector<int>> A(C,vector<int>(C)),B(3,vector<int>(C));
  for(int i=0;i<C;i++)
    for(int &j:A[i])cin>>j;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++){
      int a;
      cin>>a;
      B[(i+j)%3][a-1]++;
    }
  int ans=1000000000000000000;
  for(int i=0;i<C;i++)
    for(int j=0;j<C;j++){
      if(i==j)continue;
      for(int k=0;k<C;k++){
        if(i==k || j==k)continue;
        int cnt=0;
        for(int l=0;l<C;l++)cnt+=A[l][i]*B[0][l]+A[l][j]*B[1][l]+A[l][k]*B[2][l];
        ans=min(ans,cnt);
      }
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    string s,t;cin>>s>>t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3620
using System;
using System.Linq;

class prog{
  static void Main(){
    string s1 = Console.ReadLine();
    string s2 = Console.ReadLine();
    
    Console.WriteLine(s1[0] == s2[2]&&s1[1] == s2[1]&&s1[2] == s2[0] ? "YES" : "NO");
    
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int x[5];
    rep(i,5){
        cin >> x[i];
        if(x[i] == 0){
            cout << i + 1 << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3636
// IN the name of GOD

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M = 1e9 + 7;

void solve () {
    vector <int> a(5);
    int ans;
    for (int i = 0; i < 5; ++i) {
        cin >> a[i];
        if (a[i] == 0)
            ans = i + 1;
    }
    cout << ans;

}

int main () {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
        // scanf("%d", &tt);
    while (tt--)
        solve();
 
}

Measured memory_bytes: 3608
import bisect
while True:
    n = int(input())
    if n == 0:
        break
    card_set = [sorted(int(input()) for _ in range(n)), []]
    card_set[1] = sorted({i for i in range(1, 2*n+1)}.difference(card_set[0]))
    card = turn = 0
    flag = 1
    ba = []
    while flag:
        if len(ba) == 0:
            card = card_set[turn].pop(0)
            ba.append(card)
            flag = 0 if len(card_set[turn])==0 else 1
            turn = 0 if turn else 1
            continue
        last_card = ba[-1]
        x = bisect.bisect_left(card_set[turn], last_card)
        try:
            card = card_set[turn].pop(x)
            ba.append(card)
        except IndexError:
            ba = []
        flag = 0 if len(card_set[turn])==0 else 1
        turn = 0 if turn else 1
    print(*[len(cet) for cet in card_set[::-1]], sep='\n')

Measured memory_bytes: 7760
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;

signed main()
{
  int D, G;
  cin >> D >> G;

  vector<int> P(D);
  vector<int> C(D);
  for( int i = 0; i < D; i++ ) cin >> P.at(i) >> C.at(i);

  int ans = 10000;
  for (int bit = 0; bit < (1 << D); ++bit){
    int now = 0;
    int num = 0;
    for (int i = 0; i < D; ++i){
      if (bit & (1 << i)){ // i番目のbitが立っていれば
        now += (i+1)*100*P.at(i) + C.at(i);
        num += P.at(i);
      }
    }
    //中途半端に足す数について求める
    if( now < G ){
      for( int j = D-1; j >= 0; j-- ){
        if (bit & (1 << j)) continue;
        else{
          for( int k = 1; k < P.at(j); k++ ){
            if( now + k*(j+1)*100 >= G ){
              num += k;
              now += k*(j+1)*100;
              break;
            }
          }
          break;
        }
      }
    }
    if( now >= G && num < ans ) ans = num;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define ld double
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define len length()
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

void solve() {
    int h, n, sum = 0, x;
    cin >> h >> n;
    loop(i, n) {
        cin >> x;
        sum += x;
    }
    cout << (sum >= h ? "Yes" : "No");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)



int main(){
    int a,b;
    cin >> a >> b ;
    cout << (a-1)*(b-1) << endl;
    return 0;
}


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

S = []
for _ in range(H):
    S.append(input())

ans = H * W

for c in range(2**(H-1)):
    num_lines = 0

    g = {}
    tmp = c
    g_index = 0
    for h in range(H):
        g[h] = g_index 
        num_groups = g_index 
        if tmp % 2 == 1:
            g_index += 1
        tmp //= 2

    num_groups += 1

    num_lines = num_groups - 1 

    g_sum = [0] * num_groups

    for w in range(W):
        tmp = g_sum[:]

        ok = True
        ok2 = True
        for h in range(H):
            tmp[g[h]] += int(S[h][w])
        
            if tmp[g[h]] > K :
                # modoru
                ok = False
                if g_sum[g[h]] == 0:
                    ok2 = False

        if ok :
            g_sum = tmp
        else:
            if ok2:
                g_sum = [tmp[gi] - g_sum[gi] for gi in range(num_groups)]
                num_lines += 1
            else:
                break

    if not ok2:
        continue

    if ans > num_lines:
        ans = num_lines


print(ans)


Measured memory_bytes: 44764
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,a,b,ans=0,i;
	cin>>n>>a>>b;
	for (i=1;i<=n;i++){
		int t=i,s=0;
		while (t>0){
			s+=t%10;
			t/=10;
		}
		if (a<=s&&s<=b){
			ans+=i;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  sort(all(A), greater<ll>());
  vector<ll> B(N);
  int a = 1;
  int b = 0;
  rep(i, N / 2) {
    B[a] = A[b++];
    a += 2;
  }

  if (N % 2)
    B[N - 1] = A[b++];

  a = 0;
  rep(i, N / 2) {
    B[a] = A[b++];
    a += 2;
  }

  ll ans_1 = 0;
  rep(i, N - 1) {
    ans_1 += abs(B[i] - B[i + 1]);
  }

  sort(all(A));
  a = 1;
  b = 0;
  rep(i, N / 2) {
    B[a] = A[b++];
    a += 2;
  }

  if (N % 2)
    B[N - 1] = A[b++];

  a = 0;
  rep(i, N / 2) {
    B[a] = A[b++];
    a += 2;
  }

  ll ans_2 = 0;
  rep(i, N - 1) {
    ans_2 += abs(B[i] - B[i + 1]);
  }

  ll ans = max(ans_1, ans_2);

  // rep(i, N) {
  //   cout << B[i] << ' ';
  // }
  // cout << endl;

  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int sx = scanner.nextInt();
		int sy = scanner.nextInt();
		int tx = scanner.nextInt();
		int ty = scanner.nextInt();
		char direction[] = {'U','D','L','R'};
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= tx-sx; i++) {
			sb.append(direction[3]);
		}
		for (int i = 1; i <= ty-sy; i++) {
			sb.append(direction[0]);
		}
		for (int i = 1; i <= tx-sx; i++) {
			sb.append(direction[2]);
		}
		for (int i = 1; i <= ty-sy; i++) {
			sb.append(direction[1]);
		}
		sb.append(direction[1]);

		for (int i = 1; i <= (tx-sx)+1; i++) {
			sb.append(direction[3]);
		}
		for (int i = 1; i <= (ty-sy)+1; i++) {
			sb.append(direction[0]);
		}

		sb.append(direction[2]);
		sb.append(direction[0]);

		for (int i = 1; i <= (tx-sx)+1; i++) {
			sb.append(direction[2]);
		}
		for (int i = 1; i <= (ty-sy)+1; i++) {
			sb.append(direction[1]);
		}

		sb.append(direction[3]);

		System.out.println(sb.toString());
 	}
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A == B) cout << "Draw" << endl;
	else {
		if (A == 1 || B == 1) cout << (A == 1 ? "Alice" : "Bob") << endl;
		else cout << (A > B ? "Alice" : "Bob") << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll c[30],s[400][30],las[30];

int main()
{
	int D;
	cin >> D;
	rep(i,26)
	{
		cin >> c[i];
	}
	rep(i,D)
	{
		rep(j,26)
		{
			cin >> s[i][j];
		}
	}
	ll tmp = 0;
	rep(i,D)
	{
		ll best = -1 * 1e10;
		ll bestv = 1;
		rep(j,26)
		{
			ll tmp = 0;
			tmp += s[i][j];
			rep(k,26)
			{
				if (k != j)
				{
					tmp -= c[k] * (i+1 - las[k]);
				}
			}
			if (tmp > best)
			{
				best = tmp;
				bestv = j+1;
			}
		}
		cout << bestv << endl;
		las[bestv] = i+1;
	}
	return 0;
}

Measured memory_bytes: 3720
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
long long sum[N];
map<long long, long long> m;
int main() {
	int n;
	cin >> n;
	for (int j = 0; j < n; ++j)
		cin >> sum[j + 1], sum[j + 1] += sum[j];
	long long cnt = 0;
	for (int j = 0; j <= n; ++j)
		cnt += (m[sum[j]]++);
	cout << cnt << endl;
}






Measured memory_bytes: 14336
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    sc.close();
    int best = a;
    int[] arr = new int[]{ a + b, a - b, a * b};
    for(int i = 0; i < arr.length; i++) best = Math.max(best, arr[i]);
    System.out.println(best);
  }
 }
    

Measured memory_bytes: 23764