akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int5(a, b, c, d, e);
    int res = 0;
    if(a * b < 0)res += d;
    if(a < 0){
      res += abs(a) * c + b * e;
    }else res += (b - a) * e;

    pri(res);

/*/

//*/ break;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int sum = 0;
  int max = 0;
  
  vector<int> l(n);
  for (int i=0; i<n; i++){
    cin >> l.at(i);
    sum += l.at(i);
    if (max < l.at(i)) max = l.at(i);
  }
  
  if (sum-max > max) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, K;
    cin >> N >> K;
    vector<long long> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    sort(H.begin(), H.end());
    long long ans = 0;
    for (int i = 0; i < N - K; i++) {
        ans += H[i];
    }
    cout << ans << endl;
}

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

int q;
string s, depan, belakang;
bool balik;

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

	cin >> s >> q;
	while (q--) {
		int op;
		cin >> op;

		if (op == 1) {
			balik = !balik;
		} else {
			char c;
			cin >> op >> c;

			if (!balik) {
				if (op == 1) depan += c;
				else belakang += c;
			} else {
				if (op == 1) belakang += c;
				else depan += c;
			}
		}
	}

	reverse(depan.begin(), depan.end());
	s = depan + s + belakang;
	if (balik) {
		reverse(s.begin(), s.end());
	}

	cout << s << '\n';

	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	set<int>s;
	int ct1=1;
	int j=b;
	for(int i=a;i<=b;i++)
	{
		if(ct1<=k)
		{
			s.insert(i);
			s.insert(j);
			j--;
			ct1++;
		}
	}
	/*
	int ct=1;
	for(int j=b;j>=a;j--)
	{
		if(ct<=k)
		{
			s.insert(j);
			ct++;
		}
	}
	*/
	set<int>::iterator it;
	for(it=s.begin();it!=s.end();it++)
	{
		cout<<*it<<"\n";
	}
}

Measured memory_bytes: 256
n = int(input())
t = tuple(map(int,input().split()))
m = int(input())
px = [tuple(map(int,input().split())) for _ in range(m)]

s = sum(t)
for i in range(m):
  p,x = px[i]
  p -= 1
  print(s-t[p]+x)

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    char a;
    cin >>a;
    if(a>=97 && a<=122)
    {
        cout<<'a'<<"\n";
    }
    else
    {
        cout<<'A'<<"\n";
    }
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3600
n = int(input())
d = [0] * n
present = [[] for i in range(n)]
for i in range(n - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    if u > v:
        u, v = v, u
    d[v] += 1
    present[u].append(v)
ans = 0
cur = 0
for v in range(n):
    cur += (n - v) * d[v]
for l in range(n):
    ans += (l + 1) * (l + 2) // 2
    ans -= cur
    for v in present[l]:
        cur -= (n - v)
print(ans)


Measured memory_bytes: 37568
A, B, C, X, Y = list(map(int, input().split()))
if X == Y:
    print(min(A + B, 2 * C) * X)
elif X < Y:
    print(min(A + B, 2 * C) * X + min(B, 2 * C) * (Y - X))
else:
    print(min(A + B, 2 * C) * Y + min(A, 2 * C) * (X - Y))


Measured memory_bytes: 9104
#include <iostream>
using namespace std;
int main()
{
	int a, b, i, m;
	char c;
	while (1)
	{
		m = 0;
		for (i = 0; i < 5; i++)
		{
			cin >> a >> b;
			if (a == 0 && b == 0) return 0;
			if (a+b > m)
			{
				m = a+b;
				c = 'A' + i;
			}
		}
		cout << c << " " << m << endl;
	}
}

Measured memory_bytes: 0
# https://onlinejudge.u-aizu.ac.jp/problems/NTL_1_E
# 拡張ユークリッドの互除法

a, b = map(int, input().split())

def extgcd(a, b):
    d = a
    if b != 0:
        d, xprime, yprime = extgcd(b, a % b)
        x = yprime
        y = xprime - (a // b) * yprime
    else:
        x = 1
        y = 0
    return d, x, y

_, x, y = extgcd(a, b)
print(f"{x} {y}")



Measured memory_bytes: 5612
#include<iostream>
#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> b(n);
  vector<int> a;
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  int l=n;
  while(b.size()){
    bool t=true;
    for(int i=l;i>0;i--){
      if(i==b[i-1]){
        a.push_back(i);
        t=false;
        for(int j=i-1;j<l-1;j++){
          b[j]=b[j+1];
        }
        b.pop_back();
        break;;
      }
    }
    l=b.size();
    if(t)break;
    //cout << l << " " << a[n-l-1] << endl;
    //for(int i=0;i<l;i++)cout << b[i] <<" ";
    //cout << endl;
  }
  if(b.size()){puts("-1");
               return 0;}
  reverse(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout << a[i] << endl;;
    //a.pop();
  }
  return 0;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  let r, g, b =
    Array.fold_left (fun (r, g, b) -> function
      | 'R' -> r + 1, g, b
      | 'G' -> r, g + 1, b
      | 'B' -> r, g, b + 1) (0, 0, 0) @@
    Array.init (String.length s) @@ String.get s in
  let ignore =
    Array.fold_left (Array.fold_left ( + )) 0 @@
    Array.init (String.length s / 2) @@ fun w ->
      Array.init (String.length s - 2 * (w + 1)) @@ fun i ->
        if s.[i] = s.[i + w + 1] || s.[i + w + 1] = s.[i + 2 * (w + 1)] || s.[i] = s.[i + 2 * (w + 1)]
        then 0
        else 1 in
  Printf.printf "%d\n" @@ r * g * b - ignore

Measured memory_bytes: 35612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  a[4],b,c;
    for(int i=0;i<3;i++)
     scanf("%lld",&a[i]);
    int d;
    scanf("%d",&d);
    sort(a,a+3);
    for(int i=0;i<d;i++)
        a[2]*=2;
    printf("%lld",a[0]+a[1]+a[2]);
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
for i in range((n//2)):
  if(s[i] != s[-(i+1)]):
    print("No")
    exit()
for i in range(((n//2)//2)):
  if((s[i] != s[((n//2)-1)-i]) and (s[((n+3)/2) != s[-(i+1)]])):
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc097/tasks/arc097_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect

# Union find
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]  # 負の値の場合根を表す。絶対値はツリーの高さ 正の値は次の要素を返す、根まで続く
        self.size = [1 for _  in range(size)]

    #集合の代表を求める
    def find(self,x):
        while self.table[x] >= 0:
            #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    #併合
    def union(self,x,y):
        s1 = self.find(x)#根のindex,table[s1]がグラフの高さ
        s2 = self.find(y)
        if s1 != s2:#根が異なる場合
            if self.table[s1] != self.table[s2]:#グラフの高さが異なる場合
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                    self.size[s1] += self.size[s2]
                else:
                    self.table[s1] = s2
                    self.size[s2] += self.size[s1]
            else:
                #グラフの長さが同じ場合,どちらを根にしても変わらない
                #その際,グラフが1長くなることを考慮する
                self.table[s1] += -1
                self.table[s2] = s1
                self.size[s1] += self.size[s2]
        return

    def group_size(self, x):
        return self.size[self.find(x)]


def main():
    N, M = map(int, input().split())
    P = list(map(int, input().split()))

    uf = UnionFind(N+1)
    for _ in range(M):
        a, b = map(int, input().split())
        uf.union(a, b)

    ans = 0
    for i in range(N):
        if uf.is_same(i + 1, P[i]):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14196
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char s[MAX];
  scanf("%s", s);
  int n = strlen(s);
  char f = s[0];
  rep(i, 1, n) {
    if (f >= s[i]) continue;
    f = s[0] + 1;
    break;
  }
  rep(i, 0, n) {
    printf("%c", f);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//太特么厉害了,逆天了
//这个也能二分,太巧妙了,
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

ll x[maxn],k[maxn];
ll n,a,b;

bool check(ll t)
{
    memcpy(k,x,sizeof(x));
    for(ll i=1; i<=n; i++)
    {
        k[i] -= t*b;
    }
    ll more = (a-b),cnt=0;
    for(ll i=1; i<=n; i++)
    {
        if(k[i]>0) cnt += (k[i]%more==0) ? (k[i]/more) : (k[i]/more+1);
    }
    return cnt <= t;
}

int main()
{
    cin >> n >> a >> b;
    for(int i=1; i<=n; i++)
    {
        x[i] = read();
    }

    ll ans,L=1,R=1e9;
    while(L<=R)
    {
        ll mid = (L+R)/2;
        if(check(mid)) ans=mid,R=mid-1;
        else L=mid+1;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1792
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
a.sort()

diff = True
for i in range(n-1):
    if a[i] == a[i+1]:
        diff = False
if diff:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 78676
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    vector<ll> v(4);
    for(int i = 0; i < 4; i++) cin >> v[i];
    ll ans = -2e18;
    for(int i = 0; i < 2; i++){
        for(int j = 2; j < 4; j++){
            ans = max(ans, v[i] * v[j]);
        }
    }
    cout << ans << '\n';



    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}


ll n, k, fw, ans;
ll a[5000+10], dp[5005][5005];

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

    sort(a, a+n);
    ll l = -1, r = n;
    ll mid = (l+r)/2;
    bool flag;

    while(r-l>1){
        mid = (r+l)/2;
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= k; j++){
                dp[i][j] = 0;
            }
        }

        dp[0][0] = 1;
        for(ll i = 0; i < n; i++){
            for(ll j = 0; j < k; j++){
                if(dp[i][j] == 1){
                    if(mid != i)  dp[i+1][minll(j+a[i], k)] = 1;
                    dp[i+1][j] = 1;
                }
            }
        }
        
        flag = false;
        if(a[mid] >= k){
            flag = true;
        }
        else{
            for(ll i = k-a[mid]; i < k; i++){
                if(dp[n][i] == 1){
                    flag = true;
                    break;
                }
            }
        }
        if(flag)    r = mid;
        else    l = mid;
    }

    cout << l+1 << endl;
}
    

Measured memory_bytes: 195840
S = gets.chomp
front = S[0, 2]
rear = S[2, 2]
case
when front.to_i >= 1 && front.to_i <= 12 && rear.to_i >= 13
  puts "MMYY"
when front.to_i >= 1 && front.to_i <= 12 && rear.to_i === 0
  puts "MMYY"
when front.to_i >= 1 && front.to_i <= 12 && rear.to_i >= 1 && rear.to_i <= 12
  puts "AMBIGUOUS"
when rear.to_i >= 1 && rear.to_i <= 12 && front.to_i >= 13
  puts "YYMM"
when rear.to_i >= 1 && rear.to_i <= 12 && front.to_i === 0
  puts "YYMM"
else
  puts "NA"
end


Measured memory_bytes: 1788
import sys
import math
import copy

input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
A2 = sorted(A, reverse=True)
for i in range(N):
    if A[i] == A2[0]:
        print(A2[1])
    else:
        print(A2[0])


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif

    int x,y;
    cin>>x>>y;
    int ans=0;
    if(x==3)
    	ans+=100000;
    else if(x==2)
    	ans+=200000;
    else if(x==1)
    	ans+=300000;

    if(y==3)
    	ans+=100000;
    else if(y==2)
    	ans+=200000;
    else if(y==1)
    	ans+=300000;

    if(x==1&&y==1)
    	ans+=400000;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(x: usize);

    let mut bool_array = vec![true; 100005];
    let max_f = 100000.0_f64;

    for i in 2..max_f.sqrt().floor() as usize {
        if !bool_array[i] {
            continue;
        }
        for j in 0..100005 {
            if i == j {
                continue;
            }
            if j % i == 0 {
                bool_array[j] = false;
            }
        }
    }

    for i in x..100005 {
        if bool_array[i] {
            println!("{}", i);
            break;
        }
    }
}


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

int main(){
  string s; cin >> s;
  bool bad = false;
  for(int i = 0; i < 3; i++){
    if(s[i] == s[i+1]) bad = true;
  }
  if(bad) cout << "Bad";
  else cout << "Good";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

int main() {
  int N,K;
  cin >> N >> K ;
  int i= 0;
  int x,a,b;
  int ans =0;
  REP(i,N) {
    cin >> x;
    (abs(x)>abs(x-K))?ans+=abs(x-K):ans+=abs(x);
  }
  cout << 2*ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);

  if(N == 1) {
    printf("Hello World\n");
    
  } else if(N == 2) {
    int A, B;
    scanf("%d %d", &A, &B);
    printf("%d\n", A + B);
  }

  return 0;
}


Measured memory_bytes: 128
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool compare(const string& s1, const string& s2){
    int l = min(s1.size(), s2.size());
    for (int i = 0; i < l; ++i) {
        if(s1[i] < s2[i]) return true;
        else if(s1[i] > s2[i]) return false;
    }
    if(s1.size() < s2.size()) return true;

    return false;
}

int main() {
    int N, L;
    cin >> N >> L;

    //
    vector<string> strs(N);
    for (int i = 0; i < N; ++i) {
        cin >> strs[i];
    }

    //
    std::sort(strs.begin(), strs.end(), compare);
    for (int i = 0; i < N; ++i) {
        cout << strs[i];
    }
    cout << endl;

    
    return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
string s;
void input(){
    cin>>s;
}
void src(){
    int n=stoi(s);
    if(n==10 or n==100 or n==1000 or n==10000 or n==100000){
        cout<<10;
    }else{
        n=0;
        rep(i,s.length()){
            n += (s[i]-'0'); 
        }
        cout<<n;
    }
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define wMAX 10000
#define nMAX 100
using namespace std;

int n, w, dp[wMAX + 1][nMAX + 1];
vector<pair<int, int> > items;

void solve(){
  //init
  for ( int i = 0; i <= n; i++){
    for ( int k = 0; k <= w; k++){
      dp[k][i] = 0;
    }
  }
  for ( int i = 1; i <= n; i++){
    for ( int k = 1; k <= w; k++){
      if ( k >= items[i].second){
        dp[k][i] = max(dp[k - items[i].second][i-1] + items[i].first, dp[k][i-1]);
      } else {
        dp[k][i] = dp[k][i-1];
      }
    }
  }
}

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

  int a, b;
  items.push_back(make_pair(0, 0));
  for ( int i = 1; i <= n; i++){
    cin >> a >> b;
    items.push_back(make_pair(a, b));
  }

  solve();

  cout << dp[w][n] << endl;
  return 0;
}


Measured memory_bytes: 7056
use std::collections::BTreeMap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut map = BTreeMap::new();
    for i in 1..(n + 1) {
        let head = get_head(i);
        let tail = i % 10;
        *map.entry((head, tail)).or_insert(0) += 1;
    }

    let mut ans = 0;
    for head in 1..10 {
        for tail in 1..10 {
            let a = map.get(&(head, tail)).cloned().unwrap_or(0);
            let b = map.get(&(tail, head)).cloned().unwrap_or(0);
            ans += a * b;
        }
    }

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

fn get_head(mut v: usize) -> usize {
    while v > 0 {
        if v < 10 {
            return v;
        }
        v /= 10;
    }
    unreachable!()
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
def game():
	s1 = input()
	s2 = input()
	s3 = input()
	x = s1[0]
	while len(s1)>=0 and len(s2)>=0 and len(s3)>=0:
		if x=='a':
			if len(s1)==0:
				print("A")
				return
			x = s1[0]
			s1 = s1[1:]
		if x=='b':
			if len(s2)==0:
				print("B")
				return
			x = s2[0]
			s2 = s2[1:]
		if x=='c':
			if len(s3)==0:
				print("C")
				return
			x = s3[0]
			s3 = s3[1:]
		
game()

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

bool solve() {
	int N; cin >> N;
	string li = "aeiou";
	if (N == 0) return (false);
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		S[i] += s[0];
		for (int j = 0; j < s.size() - 1; j++) {
			for (int k = 0; k < 5; k++) {
				if (li[k] == s[j]) { S[i] += s[j+1]; break; }
			}
		}
	}

	for (int k = 1; k <= 50; k++) {
		set<string> st;
		for (int i = 0; i < N; i++) {
			if (S[i].size() < k) st.insert(S[i]);
			else st.insert(S[i].substr(0, k));
		}
		if (st.size() == N) {
			cout << k << endl;
			return (true);
		}
	}
	cout << -1 << endl;
	return (true);
}
int main() {
	while (solve());
	return (0);
}


Measured memory_bytes: 3148
require 'prime'

dp = 14.times.map{ [0] * 1121 }
primes = Prime.each.take_while{ |p| p < 1120 }
cnt = 0
primes.each do |p|
  ndp = dp.map(&:dup)
  ndp[0][p] = 1
  cnt.times do |i|
    (2..1120 - p).each do |k|
      ndp[i + 1][k + p] += dp[i][k]
    end
  end
  cnt += 1 if cnt < 13
  dp = ndp
end

loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  puts dp[k - 1][n]
end

Measured memory_bytes: 26736
#include <iostream>

using namespace std;

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0){return 0;}

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

    int sum = 0;
    int max = -1;
    int min = 1001;
    for(int i = 0 ; i < n ; i++){
      if(max < point[i]){max = point[i];}
      if(min > point[i]){min = point[i];}

      sum += point[i];
    }

    cout << (int)(sum - max - min)/(n - 2) << endl;
  }

}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

const int MOD = 1000000007;
int main() {
    int N;
    cin >> N;
    long long res = 1;
    vector<int> num(110000, 0);
    num[0] = 3;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a; ++a;
        if (num[a-1] <= num[a]) res = 0;
        res = res * (num[a-1] - num[a]) % MOD;
        num[a]++;
    }
    cout << res << endl;
}


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

N = int(input())

D = [list(map(int, input().split())) for _ in range(N)]

count = 0

for x, y in D:
    if x == y:
        count += 1
    else:
        count = 0
    if count == 3:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 62040
/*
  AUTHOR:SOURABH
  CREATED:22:07:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pair<int, int> , null_type, less< pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll n,i,c,ans=0;
    cin>>n;
    vll a(n);
    fn(i,n)
    cin>>a[i];
    c=0;
    fn(i,n-1)
    {
        if(a[i]>=a[i+1])
            c++;
        else
            {ans=max(ans,c);
            c=0;}
    }
    ans=max(ans,c);
    cout<<ans;
    return 0;
}





















Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,P;
    cin>>N>>P;
    if(N==1){cout<<P<<endl;return 0;}
    else{
        long long int ans=1;
        for(int i=2;i<=1000000;i++){
            long long int A;
            A=pow(i,N);
            if( P % A ==0){
                ans=i;
            }
            
        }
        cout<<ans<<endl;
        return 0;
    }
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  n--;
  vector<PSI> ans,ans2;
  string a="a";
  ans.push_back(make_pair(a,(int)1));
  rep(i,n){
    rep(j,ans.size() ){
      char x;
      rep(k,ans[j].S){
	x='a'+k;
	ans2.push_back(make_pair(ans[j].F+x,ans[j].S));
      }
      x='a'+ans[j].S;
      ans2.push_back(make_pair(ans[j].F+x,ans[j].S+1));
    }
    ans.clear();
    ans=ans2;
    ans2.clear();
  }
  rep(i,ans.size() ){
    cout<<ans[i].F<<endl;
  }

  return 0;
}


Measured memory_bytes: 12068
#include <bits/stdc++.h>
using namespace std;
 
string str;
 
int main( void ) {
    
    cin >> str;
    
    int ans = 0; char chr = str[0];
    for( char ch : str ) {
        if( chr != ch ) {
            chr = ch;
            ans ++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n,m,x,y=map(int,input().split())
xn=list(map(int,input().split()))
yn=list(map(int,input().split()))
sxn=sorted(xn,reverse=True)
syn=sorted(yn,reverse=True)
if sxn[0]<syn[-1] and sxn[0]<y and x<syn[-1]:
    print("No War")
else :
    print("War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int N;
    char S;
    char tmp;
    int ans = 0;
    cin >> N;
    REP(i, N)
    {
        cin >> S;
        if (i == 0)
        {
            tmp = S;
            ans++;
        }
        else
        {
            if (tmp != S)
            {
                ans++;
            }
            tmp = S;
        }
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define for(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) for(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    string s;
    cin>>s;

    bool flag=false;

    ll diff=sz(s)-7;
    if(diff<0)
    {
        cout<<"NO\n";
        return;
    }

    f(i,sz(s))
    {
        string kk="";
        ll ind=0;
        while(ind<i)
        {
            kk+=s[ind];
            ind++;
        }
        ind+=diff;

        while(ind<sz(s))
        {
            kk+=s[ind];
            ind++;
        }

        if(kk=="keyence")
        {
            flag=true;
            break;
        }
    }


    if(flag)
    {
        cout<<"YES\n";
        return;
    }
    else cout<<"NO\n";

    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b,c; cin>>a>>b>>c;
  int ans=a+b+c;
  ans-=max({a,b,c});
  cout<<ans<<endl;

  return 0;
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int h[100001],a[100001],b[100001];
map <int,bool> mp;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m,cnt=0,i; cin >>n >>m;
	for (i=1;i<=n;i++) cin >>h[i];
	for (i=1;i<=m;i++) {
		cin >>a[i] >>b[i];
		if (h[a[i]]>=h[b[i]]) mp[b[i]]=1;
		if (h[a[i]]<=h[b[i]]) mp[a[i]]=1;
	}
	for (i=1;i<=n;i++) {
		if (mp[i]==0) cnt++;
	}
	cout <<cnt;
	return 0;
}
/******************************************************************************
******************************************************************************/


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

signed main(){
	int n;
	cin >> n;
	vector<tuple<int,int,int>> points;
	for(int t = 0;t < 2;t++){
		for(int i = 0;i < n;i++){
			int x,y;
			cin >> x >> y;
			points.emplace_back(x,y,t);
		}
	}
	sort(points.begin(),points.end());
	set<int> st;
	int ans = 0;
	for(int i = 0;i < n * 2;i++){
		int x,y,isBlue;
		tie(x,y,isBlue) = points[i];
		if(isBlue){
			auto it = st.lower_bound(y);
			if(it != st.begin()){
				it--;
				st.erase(it);
				ans++;
			}
		}else{
			st.insert(y);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  vs s(4);
  for (int i = 0; i < 4; ++i) cin >> s[i];
  sort(s.begin(), s.end());
  if (s[0] + s[3] + s[2] + s[1] == "1974") {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[]
while len(a)>1:
  c=min(a)
  b.append(c)
  for m in a:
    d= m % c
    if d>0:
      b.append(d)
  a=b[:]
  b.clear()
print(a[0])
  

Measured memory_bytes: 20000
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
       Scanner cin = new Scanner(System.in);
       int n;
       int p = 0;
       int ne = 0;
       int c = 0;
       n = cin.nextInt();
       int sk;
       for(int j = 0;j<n;j++){
           sk = cin.nextInt();
           if(sk%4==0){
               c++;
           }
           else if(sk%2==0){
               p++;
           }
           else{
               ne++;
           }
       }
       if(p%2==0){
           n-=p;
       }
       else{
           if(c>0){
               n-=p;
               n--;
               c--;
           }
           else if(p != n){
               System.out.println("No");
               return;
           }
       }
       if(n%2==0){
           if(c>=ne){
               System.out.println("Yes");
           }
           else{
               System.out.println("No");
           }
       }
       else{
           if(c+1 >= ne){
               System.out.println("Yes");
           }
           else{
               System.out.println("No");
           }
       }
    }
    
}


Measured memory_bytes: 49700
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

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

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL A, B;
	cin >> A >> B;

	O(max((LL)0, A - B * 2));


	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

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



int main() {
	int n;
	long double ans=0;
	cin >> n;
	vector<double> a(n);
	rep(i, n) {
		cin >> a.at(i);
		a.at(i) = 1 / a.at(i);
	}
	rep(i, n) {
		ans += a.at(i);
	}
	cout << 1 / ans << endl;
	return 0;
}

Measured memory_bytes: 3824
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
n = int(input())
E = [[] for _ in range(n)]
C = [0 for i in range(n-1)]
for i in range(n-1):
    a,b = map(int, input().split())
    E[a-1].append([b-1, i])
    E[b-1].append([a-1, i])
c = 1
def dfs(cur, pre, pre_c):
    c = 1
    for e, i in E[cur]:
        if e != pre:
            if c == pre_c:
                c += 1
            C[i] = c
            dfs(e, cur, c)
            c += 1

dfs(0, -1, 0)
print(max(C))
for item in C:
    print(item)


Measured memory_bytes: 111388
#include<iostream>

using namespace std;

int main(){

	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if ( x - r < 0 || x + r > W || y - r < 0 || y + r > H ) cout << "No" << endl;

	else if ( x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H ) cout << "Yes" << endl;

	return 0;

}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<(N); i++)
typedef long long ll;
const ll mod=1e9+7;

ll H,A;

int main(){ 

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

cin>>H>>A;

if(H%A==0){
	cout<<H/A<<endl;
}else{
	cout<<H/A+1<<endl;
}


}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for i in a:
    d[i] += 1

maxcnt = len(d)
total = 0
for v, c in d.items():
    if c != 1:
        total += c - 1

if total % 2 == 0:
    print(maxcnt)
else:
    print(maxcnt - 1)

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

long n,s,gyakugen,ans=0,mod=998244353;

long modpow(long modpow_x,long modpow_y) {
  long modpow_return=1;
  for(long i=1;i<=modpow_y;i*=2) {
    if(modpow_y/i%2==1) modpow_return=modpow_return*modpow_x%mod;
    modpow_x=modpow_x*modpow_x%mod;
  }
  return modpow_return;
}

int main() {
  cin >> n >> s;
  gyakugen=modpow(2,mod-2);
  vector<long> a(n);
  vector<long> wa(s-1);
  for(long i=0;i<n;i++) cin >> a[i];

  for(long i=0;i<n;i++) {
    ans=ans*2%mod;
    for(long j=s-1;j>0;j--) wa[j-1]=wa[j-1]*2%mod;
    for(long j=s-1;j>0;j--) {
      if(a[i]+j<s) wa[a[i]+j-1]=(wa[j-1]*gyakugen%mod+wa[a[i]+j-1])%mod;
      else if(a[i]+j==s) ans=(wa[j-1]*gyakugen%mod+ans)%mod;
    }
    if(a[i]<s) wa[a[i]-1]=(wa[a[i]-1]+modpow(2,i))%mod;  
    else if(a[i]==s) ans=(ans+modpow(2,i))%mod;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)
int main(){
    int n; cin>>n;
    int k; cin>>k;
    string s; cin>>s;
    s[k-1] = s[k-1]-('A'-'a');
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string N; bool A=false;
 cin>>N;
    for(int i=0;i<3;i++){
        if(N.at(i)=='7') A=true;
    }
    if(A) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;typedef long double lf;typedef double fl;typedef string str;
typedef vector<int> vi;typedef vector<vector<int>> vvi;typedef vector<fl> vf;typedef vector<ll> vl;typedef vector<lf> vlf;typedef vector<char> vc;typedef vector<str> vs;

#define bre(a,b) if(a==b)break
#define ts to_string
#define con cout<<"\n"
#define w(a) while(a--)
#define wt while(true)
#define f(i,a,b,c) for(ll i=a;i<b;i+=c)
#define fd(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define pb push_back
#define mp make_pair
#define len(a) a.size()
#define lenv(a) int(a.size())
#define be(a) a.begin(),a.end()
#define eb(a) a.rbegin(),a.rend()
#define ft first
#define se second
#define ctoi(a) (a-'0')
#define rei rd<int>
#define indexc index<char>
#define indexi index<int>

//NÃO ESQUEÇA DE ATRIBUIR O VETOR AO VETOR RESULTANTE DE RD()
template<class T>vector<T> rd(vector<T> ns, int n){f(i,0,n,1){T nn;cin>>nn;ns.push_back(nn);}return ns;}
template<class T>vector<vector<T>> rdm(vector<vector<T>> ns,int l,int c){f(i,0,l,1){vector<T> auau;f(j,0,c,1){T nn;cin>>nn;auau.push_back(nn);}ns.push_back(auau);}return ns;}
template<class T>int index(vector<T> ns,T n){f(i,0,lenv(ns),1){if(ns[i]==n)return i;}return -1;}
int isalf(char p){return (toupper(p)>='A' and toupper(p)<='Z') ? 1 : 0;}
vc tasc(vc ns){f(i,32,255,1)ns.push_back(i);return ns;}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.precision(2);cout.setf(ios::fixed);

    int n1=0,n2=0,x,n;cin>>x>>n;
    int num1=x,num2=x;
    vi ns;
    ns=rei(ns,n);
    while(index(ns,num1)!=-1)++num1;
    while(index(ns,num2)!=-1)--num2;
    n1=num1;n2=num2;
    int auau2=abs(abs(n2)-x),auau1=abs(n1-x);
    if(auau1==auau2)cout<<min(n1,n2)<<"\n";
    else if(auau1<auau2)cout<<n1<<"\n";
    else cout<<n2<<"\n";

}
//SE O PROBLEMA EXIGIR MATEMÁTICA OU GEOMETRIA, VERIFIQUE SE NÃO EXISTE A FUNÇÃO NA REFERÊNCIA C++
/*CASO ESTIVER DANDO ERRO:
    -REVEJA SINTAXE;
    -VERIFIQUE ERROS MATEMÁTICOS;
    -TENTE NÃO USAR O RD;
    -SITES AJUDANTES: CPLUSPLUS, GEEK FOR GEEKS, CURSOS DO NEPS;
    -REVEJA FUNÇÕES AJUDANTES;
    -MANTENHA O CÓDIGO ORGANIZADO PARA MELHOR ENTENDIMENTO;
    -CASOS DE TESTE EXTRAS: 1 OU 0; OU ATÉ MESMO LIMITES DE MATRIZES, VETORES E CASOS DE TESTE COM ESTOURO EX.:64BITS PARA UM INT;
    -MANTENHA A CALMA E NUNCA DESISTA DE UM PROBLEMA ATOA, OLHE-O POR OUTRA PERSPECTIVA, VEJA SE EXISTEM PADRÕES OU FÓRMULAS E VÊ SE VOCÊ PODE IMPLEMENTÁ-LOS;
*/


Measured memory_bytes: 3660
n,x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
answer = 0
if a[0]>x:
	answer += a[0]-x
	a[0] = x
for i in range(n-1):
	if a[i]+a[i+1]>x:
		answer += a[i+1]-(x-a[i])
		a[i+1] = x-a[i]
print(answer)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		long m=1000000007;
		
		int n=s.nextInt();
		
		long[] arr=new long[n];
		
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextLong();
		}
		
		long sum=0;
		for(int i=0;i<n;i++)
		{
		sum=(sum%m+arr[i]%m)%m;
		}
		
		sum=(sum%m*sum%m)%m;
		
		long g=0;
		
		for(int i=0;i<n;i++)
		{
			g=(g%m+(arr[i]%m*arr[i]%m)%m)%m;
		}
		
		long ans=((sum%m-g%m+m)%m*power(2,m-2,m)%m)%m;
		
		System.out.println(ans);
		
	}
	
	public static long power(long a,long b,long m)
	{
		long res=1;
		
		while(b>0)
		{
			if(b%2!=0)
			{
				res=(res%m*a%m)%m;
			}
			
			b=b/2;
			a=(a%m*a%m)%m;
		}
		
		return res;
	}
	
}

Measured memory_bytes: 62312