akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
    long long n;
    
    cin >> n;
    
    if(n==1000000000000000000){
        cout << "0 0 1000000000 0 0 1000000000\n";
        return 0;
    }
    
        long long x1=0,y2=0,y1,x2,x3,y3;
        for(long long i=1; i<=1000000000; i*=10) {
            if(n/i<1000000000) {
                    cout << 0 << " " << 0 << " " << n/i+1 << " " << 1 << " " << i-n%i << " " << i << endl;
                x1=0;
                y1=0;
                x2=n/i-1;
                y2=-1;
                x3=i-n%i;
                y3=i;
                break;
            }
        }
       // cout << (long long)(x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0; i<n; i++){
			int a=sc.nextInt();
			if(a%2==0){
				if(!(a%3==0 || a%5==0)){
					System.out.println("DENIED");
					return;
				}
			}
		}
		System.out.println("APPROVED");
	}
}


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

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

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

    int minv = value.at(0);
    int ans = -1e9;

    for(int i = 1; i < n; i++){
        ans = max(ans, value.at(i) - minv);
        minv = min(minv, value.at(i));
    }

    cout << ans << endl;

}


Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

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

#define REPI(i, a, b) for (int(i) = int(a); (i) < int(b); ++(i))

using namespace std;

int main()
{
    int Z;           //入力待ち
    int j, k;        //for文用
    string to = ","; //デバッグ用
    int e_count = 0; //演算回数を数える
    int count = 0;   //よくあるカウント
    //----------

    int n;
    cin >> n;

    int mochi[100]; //餅は100個まで

    REP(i, n)
    {
        cin >> mochi[i];
    }

    sort(mochi, mochi + n); //並び替え

    int m = mochi[0];
    int dan = 1;
    REP(i, n - 1)
    {
        if (m != mochi[i + 1])
            dan++;

        m = mochi[i + 1];
    }
    cout << dan << endl;
    //-----------
    cin >> Z;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
for i in range(n):
  if a[i] <= b[i]:
    cnt += (b[i]-a[i])//2
    continue
  else:
    cnt -= a[i]-b[i]

if cnt >= 0: print("Yes")
else: print("No")

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[11];
	char b[11];
	char c [11];
	cin>>a>>b>>c;
	if(a[0]>='a'&&a[0]<='z')
	a[0]-=32;
	if(b[0]>='a'&&b[0]<='z')
	b[0]-=32;
	if(c[0]>='a'&&c[0]<='z')
	c[0]-=32;
	cout<<a[0]<<b[0]<<c[0];
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
#include <stdio.h>
#include <stdlib.h>


using namespace std;
 
int main() {
    string a;cin>>a;
    long moto;
    moto = stol(a);
    long g=0;
    for(int i = 0;i<a.length();i++){
      int b = a[i]-'0';
      g+=b;
    }
    if(moto%g==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3496
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > 2 * b){
            System.out.println(a - 2 * b);
        }else{
            System.out.println(0);
        }
        sc.close();
    }
}

Measured memory_bytes: 35656
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll dp[85];

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

    dp[0] = 1000;
    rep(i, 1, N+1) {
        ll mx = dp[i-1];
        rep(j, 1, i) {
            ll money = dp[j];
            ll c = money / A[j];
            money += (A[i]-A[j])*c;
            mx = max(mx, money);
        }
        dp[i] = mx;
    }

    cout << dp[N] << "\n";
    return 0;
}



Measured memory_bytes: 3592
#include<stdio.h>
#define P_EDGE 200000
 
int makelist(int* list,int kazu){
    int i,j;
    for(i=0;i<kazu;i++){
        list[i]=1;
    }
    list[0]=0;
    list[1]=0;
    for(i=2;i<kazu;i++){
        if(list[i]){
            for(j=2*i;j<kazu;j+=i){
                list[j]=0;
            }
        }
    }
    return 0;
}

int main(){
	int plist[P_EDGE];
	int n,c;
	long long int ans;
	int i;
	makelist(plist,P_EDGE);
	while(1){
		c=0;
		ans=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<P_EDGE;i++){
			if(plist[i]!=0){
				c++;
				ans+=i;
				if(c==n){
					break;
				}
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1380
#include <vector>
#include <numeric>
#include <iostream>
 
using namespace std;
 
int main()
{
    int n, m, k;
     
    scanf("%d", &n);
    scanf("%d", &m);
     
    vector<int> v(n * 2); iota(v.begin(), v.end(), 1);
     
    for(int i = 0; i < m; i++)
    {
        scanf("%d", &k);
         
        vector<int> v2;
         
        if(k == 0)
        {
            for(int j = 0; j < n; j++)
            {
                v2.push_back(v[j]);
                v2.push_back(v[n+j]);
            }
        }
        else
        {
            for(int j = k; j < 2 * n; j++)
            {
                v2.push_back(v[j]);
            }
             
            for(int j = 0; j < k; j++)
            {
                v2.push_back(v[j]);
            }
        }
         
        v = v2;
    }
     
    for(int i = 0; i < 2 * n; i++)
    {
        printf("%d\n", v[i]);
    }
     
    return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t, a;
    cin >> n >> t >> a;
    double ans_h = INT_MAX;
    int ans = 0;
    REP(i, n) {
        int h;
        cin >> h;
        if(ans_h >= abs(a * 1000 - t * 1000 + h * 6)) {
            ans = i + 1;
            ans_h = abs(a * 1000 - t * 1000 + h * 6);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, L;
    cin >> N >> L;
    int aji[N];
    int min_aji = abs(L);
    int aji1 = L;
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        aji[i] = L + i;
        if (min_aji > abs(aji[i]))
        {
            min_aji = abs(aji[i]);
            aji1 = aji[i];
        }
        sum += aji[i];
    }
    cout << sum - aji1 << endl;
}

Measured memory_bytes: 256
import sys
from itertools import permutations

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, C = map(int, readline().split())
    D = [0] * C
    for i in range(C):
        D[i] = list(map(int, readline().split()))
    G = [0] * N
    for i in range(N):
        G[i] = [int(s) - 1 for s in readline().split()]

    cost = [[0] * C for _ in range(3)]
    for x in range(N):
        for y in range(N):
            color = G[x][y]
            cost_current = cost[(x + y) % 3]
            for i in range(C):
                cost_current[i] += D[color][i]

    ans = INF
    for c1, c2, c3 in permutations(range(C), 3):
        if ans > cost[0][c1] + cost[1][c2] + cost[2][c3]:
            ans = cost[0][c1] + cost[1][c2] + cost[2][c3]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 76384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

constexpr ll mod = 1e9+7;

ll mod_pow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

vector<ll> yakusu(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i++){
        if(n % i != 0) continue;
        ret.push_back(i);
        if(i*i != n) ret.push_back(n/i);
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<VP> acc(K+1);
    VL rec(K+1,0);
    ll ans = 0;
    for(ll i = K; i > 0; i--){
        ll n = K/i;
        rec[i] = mod_pow(n, N, mod);
        for(ll j = 2; j * i <= K; j++){
            rec[i] -= rec[i*j];
        }
    }
    rep(i, 1, K+1){
        ans += i * rec[i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6404
import java.io.*;

class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] div = str.split(" ");
		int a =  Integer.parseInt(div[0]);
		int b =  Integer.parseInt(div[1]);
		if (a < b){
			System.out.println("a < b");
		}
		else if (a > b){
			System.out.println("a > b");
		}
		else if (a == b){
			System.out.println("a == b");
		}
	}	
}

Measured memory_bytes: 16892
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

int main(void)
{
	int n, m;
	scanf("%d %d", &n, &m);
	int total = 0;
	int ignore = 0;
	for (int i = 0; i < m; ++i)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		if (n > a)
		{
			int diff = n - a;
			total += diff;
			ignore = max(ignore, diff);
		}
	}
	printf("%d\n", total - ignore);
	return 0;
}

Measured memory_bytes: 3208
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    println!("{}", N*(N+1)/2);
}


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

int main()
{
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i=0;i<n;i++){
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  for (int i=0;i<n;i++){
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
N = int(input())
H = [0] + [int(h) for h in input().split()]
dp = [999999999 for _ in range(N + 1)]
dp[0] = 0
dp[1] = 0
dp[2] = abs(H[2] - H[1])
for i in range(3, N + 1):
    dp[i] = min(dp[i], dp[i - 1] + abs(H[i - 1] - H[i]), dp[i - 2] + abs(H[i - 2] - H[i]))

print(dp[N])


Measured memory_bytes: 13976
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();

        long ans = 0;

        if (k == 0) {
            System.out.println(n * n);
            sc.close();
            return;
        }

        for (long b = 1; b <= n; b++) {
            long p = n / b;
            long r = n - p * b;
//            long r = n % b;
            ans += p * Math.max(0, b - k);
            ans += Math.max(0, r - k + 1);
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;


bool cmp(pair<string, pair<int,int>> a, pair<string, pair<int,int>>b)
{
  if(a.first != b.first){
    return a.first > b.first;
  }
  else{
    return (a.second).first < (b.second).first;

  }
}


int main() {
  int N;
  cin >> N;
  pair<string, pair<int,int>> p[N];
  string S[N];
  int P[N];
  for(int i=0; i<N; i++){
    string tmp;
    cin >> tmp >> P[i];
    for (auto itr = tmp.begin(), end_ = tmp.end(); itr != end_; itr++) {
      S[i].push_back(*itr);
    }
    p[i]=make_pair(S[i], make_pair(P[i], i+1));
  }

  sort(p, p+N ,cmp);//比較関数cmpを使用してsort     
  for(int i=N-1; i >=0; i--){
    cout  << (p[i].second).second << endl;
  }

  return 0;
   

}


Measured memory_bytes: 256
class SegTree():
    def __init__(self, A):
        n_ = len(A)
        self.n = 1
        while self.n < n_:
            self.n *= 2
        self.tree = [float('inf') for _ in range(2 * self.n - 1)]
        for k, a in enumerate(A):
            self.update(k, a)
    def update(self, k, a):
        k += self.n - 1
        self.tree[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.tree[k] = min(self.tree[k * 2 + 1], self.tree[k * 2 + 2])
    def query(self, l, r):
        l += self.n - 1
        r += self.n - 2
        res = float('inf')
        while r-l>1:
            if l&1 == 0:
                res = min(res,self.tree[l])
            if r&1 == 1:
                res = min(res,self.tree[r])
                r -= 1
            l = l//2
            r = (r-1)//2
        if l == r:
            res = min(res,self.tree[l])
        else:
            res = min(min(res,self.tree[l]),self.tree[r])
        return res


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

pii = []

for i, pi in enumerate(p):
    pii.append([pi, i])

pii.sort(reverse=True)

INF = 10 * n

st_r = SegTree([n] * (n+1))
st_l = SegTree([1] * (n+1))

ans = 0

for pi, i in pii:
    # print("###")
    # print(pi, i)
    # print(st_r.tree)
    if pi < n:
        l = -st_l.query(0, i)
        r = st_r.query(i+1, n)
        # print(l, r)
        if l != -1:
            l2 = l - 1
            if l > 0:
                l2 = -st_l.query(0, l)
            ans += (l - l2) * (r - i) * pi
        if r != n:
            r2 = r + 1
            if r < n - 1:
                r2 = st_r.query(r+1, n)
            ans += (i - l) * (r2 - r) * pi

    st_r.update(i, i)
    st_l.update(i, -i)

    
print(ans)


Measured memory_bytes: 129388
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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()
{
    int64_t N;
    cin >> N;
    int64_t sum = 0;
    int64_t ans = 0;
    for (int64_t i=1; i<=N; i++) {
        sum += i;
        if (sum >= N) {
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int setNum = in.nextInt();
		for (int i = 0; i < setNum; i++) {
			int blockNum = in.nextInt();
			int max = 0;
			int min = 0;
			int pre = in.nextInt();
			for (int n = 1; n < blockNum; n++) {
				int now = in.nextInt();
				int d = now - pre;
				max = Math.max(max, d);
				min = Math.max(min, -d);
				pre = now;
			}
			System.out.print(max);
			System.out.print(" ");
			System.out.println(min);
		}
	}

}

Measured memory_bytes: 12000
#include<stdio.h>
#define SIZE 100

int main(void)
{
    int i, j, minj, n, tmp, cnt, a[SIZE];
    
    scanf("%d", &n);
    for ( i=0; i<n; ++i)
        scanf("%d", &a[i]);
    
    cnt = 0;
    for ( i=0; i<n; ++i) {
        minj = i;
        for ( j=i; j<n; ++j) {
            if ( a[minj] > a[j])
                minj = j;
        }
        if ( i != minj) {
            tmp = a[i];
            a[i] = a[minj];
            a[minj] = tmp;
            ++cnt;
        }
    }
    
    for ( i=0; i<n; ++i) {
        printf("%d", a[i]);
        if ( i != n-1)
            putchar(' ');
    }
    putchar('\n');
    printf("%d\n", cnt);
    
    return 0;
}


Measured memory_bytes: 2104
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, a, b = sc.nextInt

  var sum = 0
//  for(i <- 0 to n) {
//    val s = i.toString.toList
//    val tmp = s.map(_.asDigit).sum
//    if(tmp >= a && tmp <= b) sum += i
//  }
  for(i <- 0 to n) {
    val v = findSumOfDigits(i)
    if(v >= a && v <= b) {
      sum += i
    }
  }
  println(sum)


  def findSumOfDigits(n: Int): Int = {
    var sum = 0
    var tmp = n
    while(tmp > 0) {
      sum += tmp % 10
      tmp = tmp / 10
    }
    sum
  }
}

Measured memory_bytes: 27060
n = gets.to_i
an = gets.strip.split.map(&:to_i).sort.reverse

memo = {}
two = []
four = []
an.each do |a|
  if memo[a].nil?
    memo[a] = 1
  else
    memo[a] += 1
  end
  if memo[a] == 2
    two << a
  end
  if memo[a] == 4
    four << a
  end
end

if four.size > 0
  if two.size >= 2
    puts [four[0] * four[0], two[0] * two[1]].max
  else
    puts four[0] * four[0]
  end
else
  if two.size >= 2
    puts two[0] * two[1]
  else
    puts 0
  end
end


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

int main() {
	string s;
	int k = 700;
	cin >> s;
	for(int i = 0;i < 3;i++)
	{
		if(s.at(i) == 'o')
		{
			k += 100;
		}
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
int main() {
  int n;
  cin >> n;
  int f[110][15];
  int p[110][15];
  rep(i,n){
    rep(j,10){
      cin >> f[i][j];
    }
  }
  rep(i,n){
    rep(j,11){
      cin >> p[i][j];
    }
  }
  ll ans=-1000000000000000;
  for(int bit=0; bit<(1<<10); bit++){
    ll cc=0;
    if(bit==0) continue;
    for(int i=0; i<n; i++){
      int c=0;
      for(int j=0; j<10; j++){
        if(bit&1<<j && f[i][j]) c++;
      }
      cc+=p[i][c];
    }
    //cout << cc << endl;
    ans=max(ans,cc);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
S = list(map(int,input().split()))
N = S[0]
T = S[1]
c = 0
for x in range(0,N):
    C = list(map(int,input().split()))
    if T < C[1]:
        continue
    else:
        if c == 0:
            c = C[0]
        if c > C[0]:
            c = C[0]
if c == 0:
    print('TLE')
else:
    print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  VI a(3); for (int i = 0; i < 3; i++) cin >> a[i];
  VI c(3);
  for (int i = 0; i < 3; i++) c[i] = abs(a[i] - a[(i + 1) % 3]);
  sort(c.begin(), c.end());
  cout << c[0] + c[1] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

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

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

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

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

  sort(value.begin(), value.end(), greater<int>());

  int ans = 0;
  for(int i = 0; i < n; i++){
    if(value[i] > 0){
      ans += value[i];
    } else {
      cout << ans << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 256
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll h,w;
    cin>>h>>w;
    if(h==1 || w==1){
        cout<<"1\n";
        return;
    }
    ll ans=(h*w);
    ans/=2LL;
    if((h*w)&1LL){
        ++ans;
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    ll n,m;
    cin >> n >> m;
    ll ans = n/__gcd(n,m)*m;
    string s,t;
    cin >> s >> t;
    bool flag = (s[0]==t[0]);
    for(ll i = 1; i <= n-1; i++){
        if((m*i)%n==0){
            ll j = m*i/n;
            if(s[i]!=t[j])flag = false;
        }
    }
    if(flag)cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define R(i,a,n) for(int i=a;i<n;i++)
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int ddx[]={0,1,1,1,0,-1,-1,-1};
int ddy[]={-1,-1,0,1,1,1,0,-1};
#define pb push_back
map<int,int>m;
signed main(){
  int n;
  cin>>n;
  int a[n];
  r(i,n)cin>>a[i];
  for(int i=n-1;i>=0;i--){
    if(a[i]==0){
      int p=i;
      m[i]=i+1;
      for(;i>=0;i--){
        if(a[i]!=0)break;
        m[i]=p+1;
      }
      i++;
    }
  }
  int sum=n;
  r(i,n){
    int x=a[i];
    for(int j=i+1;j<n;j++){
      if(a[j]==0){
        int nex=m[j];
        sum+=(nex-j);
        j=nex-1;
        continue;
      }
      int p=x|a[j];
      if(p==x+a[j])sum++;
      else break;
      x+=a[j];
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 16384
def main(s: int):
    t = set([s])
    n = s
    i = 1

    while True:
        i += 1

        if n % 2 == 0:
            n /= 2
        else:
            n = 3 * n + 1

        if n in t:
            print(i)
            return
        else:
            t.add(n)


if __name__ == "__main__":
    s = int(input())

    main(s)


Measured memory_bytes: 3188
c = [list(map(int,input().split())) for _ in range(3)]
a = c[0][1]-c[0][0]
b = c[0][2]-c[0][1]
cc = c[1][0]-c[0][0]
d = c[2][0]-c[1][0]
for i in range(1,3):
    if not (c[i][1]-c[i][0])==a or not (c[i][2]-c[i][1])==b:
        print('No')
        exit()
    if not c[1][i]-c[0][i]==cc or not c[2][i]-c[1][i]==d:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s[i];

    sort(all(s));

    int sum = accumulate(all(s), 0);
    if (sum % 10 != 0) {
        put(sum);
        return 0;
    }

    rep (i, s.size()) {
        if (s[i] % 10 != 0) {
            sum -= s[i];
            break;
        }
    }

    put((sum % 10 == 0 ? 0 : sum));

    return 0;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        String s = scanner.next();
        int[] n = Arrays.stream(s.split("/")).mapToInt(Integer::parseInt).toArray();
        if (n[0] > 2019 || (n[0] == 2019 && n[1] > 4)) {
            System.out.println("TBD");
        } else {
            System.out.println("Heisei");
        }
    }

}



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

int main(){
	int n,k,a=0;
	cin>>n>>k;
	int x[n];
	for(int i=0;i<n;i++){
		cin>>x[i];
		a+=min(x[i],max((k-x[i]),(x[i]-k)));
	}
	cout<<a*2;

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int n;
vector<int> a, b;

bool floyd_warshall(set<int> st){
    auto edge = initVec2<int>(51, 51, INF);
    rep(i, 51){
        edge[i][i] = 0;
    }
    for(int k : st){
        rep(i, 51){
            edge[i][i%k] = 1;
        }
    }

    rep(k, 51){
        rep(i, 51){
            rep(j, 51){
                edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j]);
            }
        }
    }

    rep(i, n){
        if(edge[a[i]][b[i]] == INF){
            return false;
        }
    }
    return true;
}

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

    cin >> n;
    a = vector<int>(n);
    b = vector<int>(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    set<int> st;
    rep(i, 50){
        st.insert(i + 1);
    }

    if(not floyd_warshall(st)){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    for(int k = 50; k > 0; k--){
        st.erase(k);
        if(not floyd_warshall(st)){
            ans += (1LL << k);
            st.insert(k);
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 888
#D
from collections import deque
H,W = map(int,input().split())
S = [list(str(input())) for i in range(H)]

MAX = 0
for i in range(H):
    for j in range(W):
        s = [i,j]
        if S[i][j] == "#":
            continue
        dist = [[-1 for a in range(W)] for b in range(H)]
        
        dist[i][j] = 0
        de = deque([s])
        while de:
            d = de.popleft()
            h,w = d
            di = dist[h][w]
            if h > 0:
                if S[h-1][w] == "." and dist[h-1][w] < 0:
                    dist[h-1][w] = di+1
                    de.append([h-1,w])
            if h < H-1:
                if S[h+1][w] == "." and dist[h+1][w] < 0:
                    dist[h+1][w] = di+1
                    de.append([h+1,w])
            if w > 0:
                if S[h][w-1] == "." and dist[h][w-1] < 0:
                    dist[h][w-1] = di+1
                    de.append([h,w-1])
            if w < W-1:
                if S[h][w+1] == "." and dist[h][w+1] < 0:
                    dist[h][w+1] = di+1
                    de.append([h,w+1])
                    
        for h in range(H):
            for w in range(W):
                MAX = max(MAX,dist[h][w])
                
print(MAX)
        
        
        


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#define dff 1e-19
using namespace std;
int main(){
  double a[10],v[2];
  for(;;){
    if(scanf("%lf,",&a[0]) == EOF) break;
    for(int i=1; i<10; i++) scanf("%lf,",&a[i]);
    scanf("%lf,%lf",&v[0],&v[1]);
    double x=0,t;
    for(int i=0; i<10; i++) x+=a[i];
    t = x/(v[0]+v[1]);
    x = t*v[0];
    for(int i=0; i<10; i++){
      x-=a[i];
      if(x<=dff){cout <<i+1<<endl;break;}
    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)

bool dp[10001];
int main()
{
	int N, sum=0;
	vector<int> s;
	cin >> N;
	REP(i, 0, N) {
		int point;
		cin >> point;
		s.push_back(point);
		sum += point;
	}

	REP(j, 0, sum + 1) dp[j] = false;
	dp[0] = true;
	REP(i, 0, N) {
		RREP(j, 0, sum) {
			if (dp[j]) dp[j + s[i]] = true;
		}
	}

	int ans = 0;
	RREP(j, 0, sum + 1) {
		if (dp[j]) {
			if (j % 10 != 0) {
				ans = j;
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

ll sum(ll n){
	ll ans=1;
	for(int i=1;i<=n;i++) ans=(ans*i)%MOD;
	return ans;
}

int main(){
	int n,m;cin>>n>>m;
	if(abs(n-m)>1){
		cout<<0<<"\n";
	}
	else if(n==m){
		cout<<(sum(n)*sum(m)%MOD)*2%MOD<<"\n";
	}
	else {
		cout<<sum(n)*sum(m)%MOD<<"\n";
	}
}

Measured memory_bytes: 256
program prob2
    implicit none
    character(len=100005) :: S
    integer :: l, cnt, ans, i
    read(*,*) S

    l = len_trim(S)

    cnt = 0
    do i = 1, l
        if(mod(i,2) == 1) then
            if(S(i:i) == '1') then
                cnt = cnt + 1
            end if
        else
            if(S(i:i) == '0') then
                cnt = cnt + 1
            end if
        end if
    end do

    ans = cnt
    cnt = 0

    do i = 1, l
        if(mod(i,2) == 0) then
            if(S(i:i) == '1') then
                cnt = cnt + 1
            end if
        else
            if(S(i:i) == '0') then
                cnt = cnt + 1
            end if
        end if
    end do

    ans = min(ans, cnt)

    write(*,*) ans

    stop
contains
end program prob2

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc124_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

ll solve(vector<int> &c) {
  vector<int> d(c.begin(), c.end());
  ll ret = 0;
  rep(i, c.size() - 1) {
    if (d[i] == d[i + 1]) {
      d[i + 1] = !d[i];
      ret++;
    }
  }
  return ret;
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  cin >> S;
  int N = S.size();
  
  vector<int> c(N);
  rep(i, N) {
    c[i] = S[i] - '0';
  }

  ll ans = solve(c);
  c[0] = !c[0];
  ans = min(ans, solve(c) + 1);

  cout << ans << endl;
}

Measured memory_bytes: 1232
n,a,b,c = map(int,input().split())
la = [a,b,c]
lt = [int(input()) for i in range(n)]

import itertools as it
ans = 3000
for p in it.product(range(4),repeat=n):
  ll = [0]*4
  lc = [0]*4
  for i in range(n):
    ll[p[i]] += lt[i]
    lc[p[i]] += 1
  if lc[0]*lc[1]*lc[2] > 0:
    mp = 10*(sum(lc[:3])-3) + sum(abs(ll[i]-la[i]) for i in range(3))
    ans = min(ans, mp)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() 
{   
long long int n,W;
  scanf("%lld %lld",&n,&W);
long long int v[n],w[n];
for(long long int i=0;i<n;i++)
{scanf("%lld %lld",&w[i],&v[i]);
    
}
long long int dp[W+1];
memset(dp,0,sizeof(dp));
for(long long int i=0;i<n;i++)
{


  for(long long int j=W;j>=w[i];j--)
  {

dp[j]=max(dp[j],dp[j-w[i]]+v[i]);


  }
}

printf("%lld\n",dp[W]);

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int K;
  cin>>K;
  for(int i=0,j=7%K;i<=K;i++,j=(j*10+7)%K){
    if(j==0){
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
   int a[t];
   int k=1;
   int i;
   for(i=0;i<t;i++)
   {
       cin>>a[i];
   }
   int j=a[0];
   for(i=1;i<t;i++)
   {
       if(j>a[i])
       {
        k++;
        j=a[i];
       }
   }
   cout<<k<<endl;
   return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

	string a = S.substr(0, (S.length() - 1) / 2);
	string b = S.substr((S.length() + 3) / 2 - 1);

	cout << (a == b ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3104
s = input()
s1 = int(s[:2])
s2 = int(s[2:])

if(s1>=1 and s1<=12):
  if(s2>=1 and s2<=12):
    print("AMBIGUOUS\n")
  else:
    print("MMYY\n")
else:
  if(s2>=1 and s2<=12):
    print("YYMM\n")
  else:
    print("NA\n")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	int n;
	cin >> n;
	int a[n];
	vector<int> f;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
		if(a[i] == i) f.push_back(i);
	}
	int s = 0;
	int ans = 0;
	while(s < f.size()){
		if(s + 1 == f.size()){
			ans++;
			break;
		}
		if(f[s] + 1 == f[s+1]){
			ans ++;
			s += 2;
		} else {
			ans++;
			s += 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1148
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int N;


bool cmp(P a, P b) {
	if (a.second < b.second) return true;
	else return false;
}

int main(){
	cin >> N;
	vector<P> AB(N);
	for (int i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		AB[i].first = a; AB[i].second = b;
	}

	sort(AB.begin(), AB.end(), cmp);

	ll consumeTime = 0;
	for (int i = 0; i < N; i++) {
		if (AB[i].second-consumeTime>=AB[i].first) {
			consumeTime += AB[i].first;
		}
		else {
			print("No");
			return 0;
		}
	}



	print("Yes");

	return 0;
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var AB = new Tuple<int, int>[N];
        for (int i = 0; i < N; i++)
        {
            AB[i] = Tuple.Create(sc.ReadInt(), sc.ReadInt());
        }
        AB = AB.OrderBy(t => t.Item2).ToArray();

        var ok = true;
        var now = 0;
        for (int i = 0; i < N; i++)
        {
            now += AB[i].Item1;
            if (now > AB[i].Item2)
            {
                ok = false;
                break;
            }
        }
        Console.WriteLine(ok ? "Yes" : "No");
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 31916
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin>>S;
  for(int i=0;i<3;i++) {
  	if(S[i]==S[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout<<"Good"<<endl;
  return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll dest[200005];
ll am[200005];

int main() {
  ll N, K;
  scanf("%lld %lld", &N, &K);

  for (ll i = 1; i <= N; i++) {
    ll a;
    scanf("%lld", &a);

    dest[i] = a;
  }

  fill_n(am, 200005, -1);

  ll city = 1;

  ll a = 0;
  for (;;) {
    if (am[city] >= 0) {
      break;
    }

    am[city] = a;
    a++;
    // cout << "city:" << city << endl;
    // cout << "am[city]:" << am[city] << endl;

    city = dest[city];
  }

  // count to beginning city
  ll beginning_city = city;
  city = 1;
  ll count_to_beginning = 0;
  for (;;) {
    if (city == beginning_city) {
      break;
    }
    count_to_beginning++;
    city = dest[city];
  }

  ll ans = 0;

  if (K <= count_to_beginning) {
    ll num = K % a;
    for (ll i = 1; i <= N; i++) {
      if (am[i] == num) {
        ans = i;
        break;
      }
    }
  } else {
    for (ll i = 1; i <= N; i++) {
      am[i] -= count_to_beginning;
    }

    ll num = (K - count_to_beginning) % (a - count_to_beginning);
    for (ll i = 1; i <= N; i++) {
      if (am[i] == num) {
        ans = i;
        break;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6888
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*3)

dp = [[0]*3 for _ in range(N)]
for i, (a, b, c) in enumerate(A):
    if i == 0:
        dp[i] = [a, b, c]
        continue

    da, db, dc = dp[i-1]
    dp[i][0] = max(dp[i][0], max(db, dc)+a)
    dp[i][1] = max(dp[i][1], max(dc, da)+b)
    dp[i][2] = max(dp[i][2], max(da, db)+c)

print(max(dp[-1]))


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

ll INF = 500;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    a.insert(a.begin(), INF);
    a.push_back(0);
    
    ll ans = 1000, stock = 0, last = INF;
    for(int i = 1; i <= n; i++)
    {
        if(a[i] <= a[i-1] && a[i] < a[i+1])//極小
        {
            stock = ans / a[i];
            ans %= a[i];
            last = a[i];
        }
        if(a[i] > a[i-1] && a[i] >= a[i+1])//極大
        {
            ans += stock * a[i];
            stock = 0;
        }
    }
    cout << ans + stock * last << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	char a; cin >> a;
	a -= 'a';
	if (a < 0)cout << 'A' << endl;
	else cout << "a" << endl;
}

Measured memory_bytes: 3560
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

template <typename T>
using vec = vector<T>;

template <typename T>
using vec2 = vector<vector<T>>;

template <typename T>
using vec3 = vector<vector<vector<T>>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    Int a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    Int vt = v * t, wt = w * t;

    bool ans = false;

    if (b < a) {
        if (b - wt >= a - vt) {
            ans = true;
        }
    } else if (a < b) {
        if (b + wt <= a + vt) {
            ans = true;
        }
    }

    if (ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>


int IsConclude3(int in){
	int flag = 1;
	for (int n = in; n > 2; n /= 10) {
		if ( n==3 ) {
			flag = 0;
			break;
		}
		else if (n % 10 == 3) {
			flag = 0;
			break;
		}
	}
	return flag;
}

int main() {
	int n, flag=0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		if ((i % 3) == 0) { printf(" %d", i); continue; }
		else if (IsConclude3(i) == 0) {
			printf(" %d", i); continue;
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
int main()
  {int K; cin >> K;
  int ans = 0;
  for (int a = 1; a <= K; ++a)
    {for (int b = 1; b <= K; ++b)
      {for (int c = 1; c <= K; ++c) ans += gcd(gcd(a, b), c);}}
  cout << ans << endl;}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
using namespace std;
int main()
{
	double L;
	cin>>L;
	double mid = L / 3;
	double one = L - 2 * mid;
	cout<<fixed<<setprecision(10);
	cout<<mid * mid * one<<endl;
	return 0;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(size_t i=0; i<(n); i++)
#define REPj(n) for(size_t j=0; j<(n); j++)
#define REPinit(i,a,n) for(size_t i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(size_t j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;

    vector<ull> H(N, 0);
    REPinit(i, 0, N) cin >> H[i];

    vector<int> hcomp(N, 0);
    int A,B;
    REPinit(i,0,M) {
        cin >> A >> B;
        if (H[A - 1] > H[B - 1]) {
            hcomp[B - 1] += 1;
        }
        if (H[A - 1] < H[B - 1]) {
            hcomp[A - 1] += 1;
        }
        if (H[A - 1] == H[B - 1]) {
            hcomp[A - 1] += 1;
            hcomp[B - 1] += 1;
        }
    }

    int ans = 0;
    REPinit(i, 0, N) {
        if (hcomp[i] == 0) ans++;
    }

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


Measured memory_bytes: 4500