akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

void ternarysplitquicksort(int n, int *a) {
	if(n <= 0)
		return;
	int *s = malloc(sizeof(int)*n);
	int *l = malloc(sizeof(int)*n);
	int s_count = 0;
	int l_count = 0;
	int pivot = *a;
	int i;
	for(i = 0; i < n; i++)
		if(*(a + i) < pivot) {
			*(s + s_count) = *(a + i);
			s_count++;
		} else if(pivot < *(a + i)) {
			*(l + l_count) = *(a + i);
			l_count++;
		}
	for(i = 0; i < s_count; i++)
		*(a + i) = *(s + i);
	for(i = 0; i < l_count; i++)
		*(a + n - 1 - i) = *(l + i);
	for(i = 0; i < n - s_count - l_count; i++)
		*(a + s_count + i) = pivot;
	free(s);
	free(l);
	ternarysplitquicksort(s_count, a);
	ternarysplitquicksort(l_count, a + n - l_count);
}

int main(void) {
	int n, k;
	scanf("%d%d", &n, &k);
	int *h = malloc(sizeof(int)*n);
	for(int i = 0; i < n; i++)
		scanf("%d", h + i);
	ternarysplitquicksort(n, h);
	long count = 0;
	for(int i = 0; i < n - k; i++)
		count += *(h + i);
	printf("%ld\n", count);
	free(h);
	return 0;
}

Measured memory_bytes: 2032
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()
print("Yes" if "7" in N else "No")


Measured memory_bytes: 9916
# -*- coding: utf-8 -*-
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a = Counter(a)
f = 0
for i in a.most_common():
    if i[1] != 1:
        print("NO")
        f = 1
        break
if f == 0:
    print("YES")


Measured memory_bytes: 40392
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string n; cin >> n;
  rep(i, 3) cout << (n[i]=='1' ? '9' : '1');
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define pi acos(-1)
using namespace std;
int main() {
    long long x=-1000001,y=1000001,n;
    long long z=0;
    long long a[10086];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>x)x=a[i];
        if(a[i]<y)y=a[i];
        z+=a[i];
    }
    cout<<y<<" "<<x<<" "<<z<<endl;
    return 0;
}



Measured memory_bytes: 3168
n = int(input())
ls = [int(i) for i in input().split()]


from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(n):
    if i%2==0:
        d1[ls[i]]+=1
    else:
        d2[ls[i]]+=1


d1=sorted(d1.items(),key=lambda x:x[1],reverse=True)
d2=sorted(d2.items(),key=lambda x:x[1],reverse=True)


if d1[0][0] != d2[0][0]:
    print(n-d1[0][1]-d2[0][1])
else:
    if len(d1)==1 and len(d2)==1:
        print(min(n-d1[0][1],n-d2[0][1]))
    elif len(d1)==1 and len(d2)==2:
        print(min(n-d1[0][1]-d2[1][1],n-d2[0][1]))
    elif len(d1)==2 and len(d2)==1:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]))
    else:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]-d2[1][1]))


Measured memory_bytes: 65260
import java.util.*;

public class Main {
	public static void main(String[] a) {
		try (Scanner s = new Scanner(System.in)) {
			int sx = s.nextInt();
			int sy = s.nextInt();
			int tx = s.nextInt();
			int ty = s.nextInt();
			output(tx - sx, 'R');
			output(ty - sy, 'U');
			output(1, 'R');
			output(ty - sy + 1, 'D');
			output(tx - sx + 1, 'L');
			output(ty - sy + 1, 'U');
			output(tx - sx, 'R');
			output(1, 'U');
			output(tx - sx + 1, 'L');
			output(ty - sy + 1, 'D');
			output(1, 'R');
		}
	}

	static void output(int count, char c) {
		count = Math.abs(count);
		for (int i = 0; i < count; i++) {
			System.out.print(c);
		}
	}
}


Measured memory_bytes: 25604
s = input()
if len(s) != 6:
    print("No")
    exit()

f = 0
for i in range(len(s)):
    x = ord(s[i])
    if (x < 97) or (x > 122):
        f = 1
        break

if f == 1:
    print("No")
    exit()

if (s[2] == s[3]) and (s[4] == s[5]):
    print("Yes")

else:
    print("No")



Measured memory_bytes: 38256
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
q = [0] * 10**5
v = [[] for _ in q]
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)

Measured memory_bytes: 58468
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}

void main()
{
  string[] c; readC(2, c);
  writeln(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0] ? "YES" : "NO");
}


Measured memory_bytes: 256
input()
rates = sorted([int(x) for x in input().split()])
counts = []
for boundary in [399, 799, 1199, 1599, 1999, 2399, 2799, 3199]:
    counts.append(1 if rates and (rates[0] <= boundary) else 0)
    rates = [rate for rate in rates if rate > boundary]
higher = len(rates)
least = sum(counts)
print("{} {}".format(1 if least == 0 else least, least+higher))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int n, k; cin >> n >> k;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A.begin(),A.end(), greater<int>());
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += A[i];
    }

    cout << sum << endl;
    return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,k; cin >> n >> k;
  vector<ll> h(n+1); for(int i = 1;i<=n;i++) cin >> h[i];

  sort(h.begin(),h.end());
  
  ll ans = INF_LL;
  for(int i = 1;i<=n;i++){
    if(i+k-1>n) break;
    ans = min(ans,h[i+k-1]-h[i]);
  }

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


Measured memory_bytes: 4056
#include <stdio.h>

int insertionSort(int [1000], int N);

int main(void){
  int i, j, k, v, N;
  int A[1000];
  scanf("%d", &N);
  for (i=0; i<N; ++i)scanf("%d", &A[i]);
  insertionSort(A, N);
  return 0;
}

int insertionSort(int A[1000], int N){
  int i, j, v, k;
  for (k=0; k<N-1; ++k)printf("%d ", A[k]);
  printf("%d", A[N-1]);
  printf("\n");
  for (i=1; i<=N-1; ++i){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for (k=0; k<N-1; ++k)printf("%d ", A[k]);
    printf("%d", A[N-1]);
    printf("\n");
     
  }
}


Measured memory_bytes: 2068
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

struct C{
	double r,x,y;
	C(double r,double x,double y) : r(r) , x(x) , y(y) {}
};

bool cmp_x(const C &a,const C &b){ return a.x == b.x ? a.y < b.y : a.x < b.x ; }
bool cmp_y(const C &a,const C &b){ return a.y == b.y ? a.x < b.x : a.y < b.y ; }

double dist(const C &a,const C &b){
	double x = a.x - b.x;
	double y = a.y - b.y;
	return sqrt( x * x + y * y );
}
int main(){
	int n;
	while(cin >> n && n){
		vector<C> a,b;
		for(int i = 0 ; i < n ; i++){
			double r,x,y;
			cin >> r >> x >> y;
			a.push_back(C(r,x,y));
			b.push_back(C(r,x,y));
		}
		double ans = 1e15;
		sort(a.begin(),a.end(),cmp_x);
		sort(b.begin(),b.end(),cmp_y);
		for(int i = 0 ; i < n ; i++){
			for(int j = i+1 ; j < min(i+25,n) ; j++){
				ans = min(ans,dist(a[i],a[j])-a[i].r-a[j].r);
			}
			for(int j = i+1 ; j < min(i+25,n) ; j++){
				ans = min(ans,dist(b[i],b[j])-b[i].r-b[j].r);
			}
		}
		printf("%.7f%c",ans,10);
	}
}

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

using namespace std;
int main()
{
    char s[5];
   scanf("%s",s);
    int x=0;
    for(int i=0; s[i]; i++)
    {
        if(s[i]=='+')
            x++;
        else if(s[i]=='-')
            x--;
    }
    printf("%d\n",x);
    return 0;
}


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


int main() {
	int n;
	int card[4][14] = {0};
	cin >> n;
	for (int i = 0; i< n; i++) {
		char suit;
		int num;
		int suitn;
		cin >> suit >> num;
		switch (suit) {
		case 'S':
			suitn = 0;
			break;
		case 'H':
			suitn = 1;
			break;
		case 'C':
			suitn = 2;
			break;
		case 'D':
			suitn = 3;
			break;
		default:
			throw "input error";
		}
		card[suitn][num] = 1;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 1; j <= 13; j++) {
		char suitc[4] = { 'S','H','C','D', };
			if (card[i][j] == 0) {
				cout << suitc[i] << ' ' << j << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    string S;
    cin>>S;
    int ans=0;

    for(int i=0;i<S.size();i++){
        if(S[i]=='1'){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;


int main()
{
	long long A, B, C, K, ans = 0, x = -1;

	cin >> A >> B >> C >> K;

	//ans = pow(x, K) * (A - B);
	if (K%2 == 1) {
		ans = B - A;
	}
	else {
		ans = A - B;
	}
	if (abs(ans) > 1000000000000000000) {
		cout << "Unfair";
	}
	else {
		cout << ans;
	}

	char qq;
	cin >> qq;
	return 0;
}

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  int res = -1;
  for (int i = 1; i < n; i++) {
    int t = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      if (find(s.begin(), s.begin() + i, c) != s.begin() + i and find(s.begin() + i, s.end(), c) != s.end()) t++;
    }
    res = max(res, t);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    int n,m,kd;
    cin>>n>>m>>kd;
    string s[n];
    int black=0;
    for(int i=0;i<n;++i){
        cin>>s[i];
        for(int j=0;j<m;++j){
            if(s[i][j]=='#'){++black;}
        }
    }
    int ans=0;
    for(int mask1=0;mask1<(1<<n);++mask1){
        for(int mask2=0;mask2<(1<<m);++mask2){
            string ss[n];
            for(int i=0;i<n;++i){ss[i]=s[i];}
            for(int i=0;i<n;++i){
                if((mask1&(1<<i))!=0){
                    for(int j=0;j<m;++j){ss[i][j]='~';}
                }
            }
            for(int j=0;j<m;++j){
                if((mask2&(1<<j))!=0){
                    for(int i=0;i<n;++i){ss[i][j]='~';}
                }
            }
            int count=0;
            for(int i=0;i<n;++i){
                for(int j=0;j<m;++j){
                    if(ss[i][j]=='#'){++count;}
                }
            }
            if(count==kd){++ans;}
        }
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 3656
N, X, Y = map(int, input().split(' '))

res = [0] * (N)

for i in range(N):
    for j in range(i+1, N):
        dist = min(abs(i - j), abs(i - X + 1) + 1 + abs(j - Y + 1))
        res[dist] += 1

for i in range(1, N):
    print(res[i])


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

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int>> G(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> dist(n,-1);
  queue<int> que;
  int ans[n];
  dist[0]=0;
  que.push(0);
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for(int nv:G[v]){
      if(dist[nv]!=-1) continue;
      dist[nv]=dist[v]+1;
      que.push(nv);
      ans[nv]=v;
    }
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<n;i++){
    cout<<ans[i]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 10648
def cut_and_count(s)
  l_hash = {}
  r_hash = {}

  s.chars.each do |c|
    if r_hash[c] == nil
      r_hash[c] = 1
    else
      r_hash[c] += 1
    end
  end

  ans = 0
  count = 0

  s.chars.each do |c|
    if l_hash[c] == nil
      l_hash[c] = 1
      count += 1
    end

    r_hash[c] -= 1
    count -= 1 if r_hash[c] == 0
    ans = count if count > ans
  end

  ans
end

n = gets.chomp.to_i
s = gets.chomp

puts cut_and_count(s)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<17;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }
#define DUMP(a) \
    do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) \
    do { std::cout << #a " = " << (a) << std::endl; } while(false)

ll modpow(ll a, int k) {
    if(k == 0) return 1;
    if(k & 1) return (modpow(a, k - 1) * a) % MOD;
    else { ll t = modpow(a, k / 2LL); return (t * t) % MOD; }
}

ll mod_inverse(ll a) {
    return modpow(a, MOD - 2);
}

ll memo[MAXN];
// calc(k) := k桁以下で a + b = a xor b となる(a, b)の総数
ll calc(int k) {
    if(k == 0) return 1;
    if(memo[k]) return memo[k];
    // DUMPLN(ret);
    return memo[k] = (3LL * calc(k - 1)) % MOD;
}

int n;
string L;

ll solve(int pos) {
    if(pos == n) return 1;
    if(L[pos] == '0') return solve(pos + 1);
    return (2LL * solve(pos + 1) + calc(n - pos - 1)) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> L;
    n = SZ(L);
    cout << solve(0) << endl;
    return 0;
}


Measured memory_bytes: 7436
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)         cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)      cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)   cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int N = 300000 , mod = 1000000007;
int main()
{
    fastio;
    int x,n;
    cin>>x>>n;
    int a[n];
    map<int,int>mp;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    int ans = -1;
    for(int i=x;i<=101;i++)
    {
        if(mp.count(i)==0)
        {
            ans = i;
            break;
        }
    }
    for(int i=x;i>=-1;i--)
    {
        if(mp.count(i)==0)
        {
            if(abs(x-i)<=abs(ans-x))
            {
                ans = i;
            }
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
N = int(input())
S = list(map(str, input()))
ret = float("inf")
west = [0 for _ in range(N + 2)]
east = [0 for _ in range(N + 2)]

for i in range(1, N + 1):
	if S[i - 1] == "W":
		west[i] = west[i - 1] + 1
	else:
		west[i] = west[i - 1]
for i in range(N, 0, -1):
	if S[i - 1] == "E":
		east[i] = east[i + 1] + 1
	else:
		east[i] = east[i + 1]
	ret = min(east[i] + west[i] - 1, ret)

print(ret)

Measured memory_bytes: 77796
import java.util.*;
import java.io.*;

public class Main {

  private static void solve() {
    long k = nextInt();
    long A = nextInt();
    long B = nextInt();

    long ans = k + 1;
    if (A < B && k >= A - 1) {
      k -= A - 1;
      long diff = B - A;
      ans = Math.max(ans, A + (k % 2 == 0 ? (k / 2) * diff : ((k - 1) / 2) * diff + 1));
    }

    System.out.println(ans);
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

  private static int nextInt() {
    return Integer.parseInt(next());
  }

  private static long nextLong() {
    return Long.parseLong(next());
  }

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 22100
A, B, C, X, Y = list(map(int, input().split()))

count = 0
if 2*C < A + B:
	count += min(X, Y) * 2*C
	if X > Y:
		if 2*C < A:
			count += (X - Y) * 2*C
		else:
			count += (X - Y) * A
	else:
		if 2*C < B:
			count += (Y - X) * 2*C
		else:
			count += (Y - X) * B
else:
	count += A*X + B*Y

print(count)



Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  int N,K;
  scanf("%d %d",&N,&K);
  char S[N];
  scanf("%s",S);
  if(S[K-1]=='A'){
    S[K-1]='a';
  }
  if(S[K-1]=='B'){
    S[K-1]='b';
  }
  if(S[K-1]=='C'){
    S[K-1]='c';
  }
  printf("%s",S);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    String[] W;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        N = sc.nextInt();
        W = new String[N];
        for (int i=0; i<N; i++) {
        	W[i] = sc.next();
        }
    }
    
    //解答処理
    private boolean solve() {
        boolean answer = true;
        
        for (int i=1; i<N; i++) {
        	if (!(W[i-1].charAt(W[i-1].length()-1) == W[i].charAt(0))) {
        		answer = false;
        		break;
        	}
        	for (int j=0; j<i; j++) {
        		if (W[i].equals(W[j])) {
        			answer = false;
            		break;
        		}
        	}
        }
        
        return answer;
    }
    
    //出力
    public void show(boolean answer) {
        if (answer) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
    }

}


Measured memory_bytes: 35856
#include <iostream>
using namespace std;
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)

int main(){
	int sx,sy, tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int dx=tx-sx, dy=ty-sy;
	
	string ans="";
	rep(i, dx) ans+="R";
	rep(i, dy) ans+="U";
	rep(i, dx) ans+="L";
	rep(i, dy) ans+="D";
	ans += "D";
	rep(i, dx+1) ans+="R";
	rep(i, dy+1) ans+="U";
	ans += "LU";
	rep(i, dx+1) ans+="L";
	rep(i, dy+1) ans+="D";
	ans += "R";
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  unordered_set<int> us;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      us.emplace(i * j);
    }
  }
  bool flg = true;
  if (us.find(n) == us.end()) flg = false;

  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main(){
    IOS;
    ll a[105];
    ll n, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> a[i];
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			for (int k = j + 1; k < n; ++k) {
				if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k])continue;
				ll sum = a[i] + a[j] + a[k];
				ll mx = max(a[i], max(a[j], a[k]));
				if (sum - mx > mx)++cnt;
			}
		}
	}
	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

void trace(int A[], int N){
	int i;
	for(i = 0; i < N; i++){
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N){
	int j, i, v;
	for(i = 1; i < N; i++){
		v = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main(){
	int N, i;
	int A[100];
	
	scanf("%d", &N);
	for(i = 0; i < N; i++) scanf("%d", &A[i]);
	
	trace(A, N);
	insertionSort(A, N);
	
	return 0;
}


Measured memory_bytes: 2088
n = int(input())
s = list(map(int,input().split()))
n2 = int(input())
t = list(map(int,input().split()))
count = 0

def binarySearch(a,b):
    left = 0
    right = n
    
    while left < right:
        middle = (left + right)//2
        if b[middle] == a:
            return 1
        elif b[middle] < a:
            left = middle + 1
        elif b[middle] > a:
            right = middle 
    return 0

            
for a in t:
    count += binarySearch(a, s)

print(count)

Measured memory_bytes: 18688
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 2019;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(ll n, ll k) {
  mint x = 1, y = 1;
  for(ll i=0; i<k; i++) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

void solve(string &S){
  ll n = S.size();
  vector<mint> v(n);
  vector<ll> vv(2019, 0);
  ll ans = 0;
  v[n-1] = S[n-1]-'0';
  for(int i=1; i<n; i++) v[n-(i+1)] = mint(10).pow(i)*(S[n-(i+1)]-'0')+v[n-i];
  vv[0] = 1;
  rep(i,n) vv[v[i].x]++;
  rep(i,2019) ans += (vv[i]*(vv[i]-1)) / 2;
  std::cout << ans << std::endl;
}

int main(){
  string S;
  cin>>S;
  solve(S);
  return 0;
}



Measured memory_bytes: 4528
n=int(input())-1
A=list(map(int,input().split()))
i=0
for j in range(n):
 if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1
A[i],A[n]=A[n],A[i]
print(" ".join(map(str,A[:i]))+" ["+str(A[i])+"] "+" ".join(map(str,A[i+1:])))


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vi p(n);
  REP(i, n) cin >> p[i];

  vi a(n), b(n);
  REP(i, n) {
    a[i] = i * n + 1;
  }
  REP(i, n) {
    b[i] = (i + n) * n + 1;
  }
  
  reverse(ALL(b));

  REP(i, n) {
    b[p[i]-1] += i;
  }

  REP(i, n) {
    cout << a[i];
    if(i == n-1) cout << endl;
    else cout << " ";
  }
  REP(i, n) {
    cout << b[i];
    if(i == n-1) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 1e6+55;
int const inf = 2e16;
int a[N];
int b[N];

void solve(){
    int i,j,l;  
    int x,n;
    cin>>x>>n;
    map<int, int> m1;
    for(i=0;i<n;i++){
        int y;cin>>y;
        m1[y]++;
    }
    int lt = x;
    int rt = x;

    while(m1[lt] != 0 && m1[rt] != 0){
        lt--;
        rt++;
    }

    if(m1[lt] == 0) cout<<lt<<endl;
    else cout<<rt<<endl;
}               


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*


*/

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

using namespace std;
typedef long long ll;

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> fr[100010], bl[100010];
	UnionFind tree(N);
	int ans[100010];
	rep(i,N) ans[i]=0;
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		fr[a].emplace_back(b);
		fr[b].emplace_back(a);
		tree.merge(a,b);
	}
	rep(i,K){
		int c, d;
		cin >> c >> d;
		c--; d--;
		if(tree.issame(c,d)){
			bl[c].emplace_back(d);
			bl[d].emplace_back(c);
		}
	}
	rep(i,N){
		ans[i]=tree.size(i)-1-fr[i].size()-bl[i].size();
	}
	rep(i,N-1) cout << ans[i] << " ";
	cout << ans[N-1] << endl;

	return 0;
}

Measured memory_bytes: 13816
program b613
 
implicit none
integer :: a, b, v, w, t
integer(16) :: z, y
 
read *, a, v
read *, b, w
read *, t
 
z = abs(b - a)
y = abs(v - w)
 
if(v <= w) then
 print *, 'NO'
else if(z > t * y) then
 print *, 'NO'
else
 print *, 'YES'
end if
 
end program b613

Measured memory_bytes: 2908
N = int(input())
A = [int(input())-1 for _ in range(N)]
       
ans = 0
n = 0 
s = set()
while True:
    if n == 1:
        print(ans)
        break
    if n in s:
        print(-1)
        break
    ans += 1
    s.add(n)
    n = A[n]


Measured memory_bytes: 56024
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, k;
    while(cin >> n >> k, n|k){
        vector<ll> v(n+1, 0);
        for (int i = 0; i < n; ++i) {
            scanf("%lld", &v[i+1]);
        }
        partial_sum(v.begin(), v.end(), v.begin());
        ll ans = -INF<ll>;
        for (int i = 0; i < n-k+1; ++i) {
            ans = max(ans, v[i+k]-v[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}



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

long long a[100010][3];
long long dp[100010][3];

int main() {
    int N; cin >> N;
    
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long res = 0;
    for (int j = 0; j < 3; ++j) {
        chmax(res, dp[N][j]);
    } 
    cout << res << endl;
}

Measured memory_bytes: 4992
//in the name of GOD//

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie();
#define sz(s) s.size()

int main(){
  fast;
  int n,ans = 0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    if((i + 1) == a[a[i] - 1]){
      ans++;
    }
  }
  cout << ans / 2;
}


Measured memory_bytes: 640
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int, int> Pair;

int n;
int a, v;
Pair ans(-1, -1);

int main() {
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d%d", &a, &v);
    ans = max(ans, Pair(v, -a));
  }

  printf("%2$d %1$d\n", ans.first, -ans.second);
}

Measured memory_bytes: 2732
#include <iostream>

#include<algorithm>
#include<vector>
#include<queue>
#include<string>

using namespace std;

int main()
{
	int n,r;
	cin >> n >> r;;
	if (n < 10)cout << r + 100 * (10 - n) << endl;
	else cout << r << endl;

}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool B[100005];
ll dp[100005];

int main()
{
    ll N, M;
    cin >> N >> M;
    memset(B, 0, sizeof(B));
    REP(i, M)
    {
        ll a;
        cin >> a;
        B[a] = true;
    }
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    REP(i, N)
    {
        if (B[i + 1])
            continue;
        dp[i + 1] += dp[i];
        if (i > 0)
            dp[i + 1] += dp[i - 1];
        dp[i + 1] %= MOD;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll gcd (ll x,ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
ll lcm (ll x,ll y) {
    return x/gcd(x, y)*y;
}

int main() {
    ll a,b;
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;


//int main(){
//  set<string> str;
//  string s;
//  cin>>s;
//  int x;
//  cin>>x;
//  str.insert(s);
//
//  for(int i=0; i<s.size(); i++){
//    for(int j=0; i+j<s.size(); j++){
//      string st;
//      int y=0;
//      cout<<"i = "<<i<< "  J = "<<j<<en
//      for(int k=i; k<=i+j; k++){
//        st[y++]=s[k];
//        cout<<"st["<<y-1<<"] = "<<s[k]<<en
//      }
//      string sst=st.substr(i,j);
//      str.insert(sst);
//    }
//  }
//
//  int i=0;
//  for(set<string>::iterator it=str.begin(); it!=str.end(); it++){
//    i++;
//    string ss=*it;
//    cout<<"ss = "<<ss<<en
//    if(i==x) {
//      cout<<ss<<en
//      break;
//    }
//  }
//}


int main(){
  int a,b;
  cin>>a>>b;
  
  int c=a+b;
  int d=a*b;
  int e=a-b;
  int f=max(c, d);
  int ans=max(f,e);
  cout<<ans<<en
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int n = in.nextInt();
			if (n > 0) {
				int[] ageCounter = new int[7];
				for (; n > 0; n--) {
					
					int age = in.nextInt();
					if (age < 10) {
						ageCounter[0]++;
					} else if (age < 20) {
						ageCounter[1]++;
					} else if (age < 30) {
						ageCounter[2]++;
					} else if (age < 40) {
						ageCounter[3]++;
					} else if (age < 50) {
						ageCounter[4]++;
					} else if (age < 60) {
						ageCounter[5]++;
					} else {
						ageCounter[6]++;
					}
				}
				for (int count : ageCounter) {
					System.out.println(count);
				}
			} else {
				break;
			}
		}
	}
}

Measured memory_bytes: 12000
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

def DIVISORS(n):
    divisors = []
    i = 1
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if n // i != i:
                divisors.append(n // i)
        i += 1
    divisors.sort()
    return divisors


N = int(input())

divisors = DIVISORS(N)

ans = 0
for x in divisors:
    m = x - 1
    if m <= 0:
        continue
    if N // x == N % m:
        ans += m


print(ans)


Measured memory_bytes: 3704
#include<cstdio>
#define MAXN 10000
#define LL long long
LL a[MAXN+5],b[MAXN+5];
LL suma,sumb,c;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	for(int i=0;i<n;i++)
		scanf("%lld",&b[i]);
	for(int i=0;i<n;i++)
	{
		suma+=a[i];
		sumb+=b[i];
		if(b[i]>a[i])
			c+=(b[i]-a[i]+1)/2;
	}
	if(sumb<suma) printf("No\n");
	else if(sumb==suma)
	{
		if(c==0) printf("Yes\n");
		else printf("No\n");
	}
	else
	{
		if(c<=sumb-suma) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int H,N;
int main(){
	cin>>H>>N;
	for(int i=0;i<N;i++){
		int x,y;cin>>x>>y;
		int r=min(x-1,min(y-1,min(H-x,H-y)));
		cout<<r%3+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector L(N, 0LL);
  for (ll i = 0; i < N; i++) cin >> L[i];
  sort(L.begin(), L.end());

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      ll t = L[i] + L[j];
      auto it1 = lower_bound(L.begin(), L.end(), t);
      auto it2 = upper_bound(L.begin(), L.end(), L[j]);
      ll y = it1 == L.end() ? N : it1 - L.begin();
      ll x = j + 1;
      if (x < y) ans += y - x;
    }
  }
  cout << ans << endl;

  return 0;
}



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

int main() {
    
    ios::sync_with_stdio(false);
    
    int x; cin >> x;
    vector<int> xs;
    while(x--) {
        int n; cin >> n;
        xs.push_back(n);
    }

    int total = 0;
    for(int i = 2; i < xs.size(); i++) {
        if (xs[i-2] < xs[i-1] && xs[i] > xs[i-1]) {
            total++;
        }
        if (xs[i-2] > xs[i-1] && xs[i] < xs[i-1]) {
            total++;
        }
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[8]={0,1,0,-1,1,1,-1,-1};
ll dy[8]={1,0,-1,0,1,-1,1,-1};
bool ok(ll n,vll &a,vll &f,ll cu,ll k){
  ll kk=0;
  rep(i,n){
    if(a[i]*f[i]>cu){
      kk+=a[i]-(cu)/f[i];
    }
  }
  if(kk<=k){
    return true;
  }
  return false;
}     
int main(){
  ll n,k;
  cin>>n>>k;
  vll a(n),f(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>f[i];
  sort(all(a));
  sort(rall(f));
  ll l=-1;
  ll r=1e12;
  while(l+1<r){
    ll mid=(l+r)/2;
    if(ok(n,a,f,mid,k)){
      r=mid;
    }
    else l=mid;
  }
  COUT(r);
}

Measured memory_bytes: 3328
n = gets.to_i
c = 0
s = gets
s.gsub!(/(\d)\1\1+/, '\1\1\1')
10.times {|l|
  10.times {|m|
    10.times {|r|
      next  unless i = s.index(l.to_s)
      next  unless i = s.index(m.to_s,i+1)
      next  unless s.index(r.to_s,i+1)
      c += 1
} } }
p c

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <stack>
#include <map>
#include <ctype.h>

using namespace std;

#define loop(i,n) for (i = 0; i < n; ++i) 
#define loop2(i,k,n) for (i = k; i <= n; ++i) 
#define loopb(i,k,n) for (i = k; i >= n; --i)
#define remove_space(x) x.erase(remove(x.begin(), x.end(), ' '), x.end())
typedef long long ll;

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

    int n;
    string s;

    cin >> n >> s;

    string s1;
    string s2;
    for(int i=0; i<n/2; i++){
    	s1 += s[i];
    }

    for(int i=n/2; i<n; i++){
    	s2 += s[i];
    }

    if (s1 == s2)
    {
    	cout << "Yes";
    }

    else{
    	cout << "No";
    }
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
       int num=sc.nextInt();
       //List<Integer>list=new ArrayList<>();
       int count=0;
       for(int i=0;i<num;i++){
        int a=sc.nextInt();
        if((i+1)%2!=0&&a%2!=0)count++;
       }
       System.out.println(count);
       sc.close();
    }
} 

 


Measured memory_bytes: 35724
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

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

int main()
{
  int X, A; cin >> X >> A;
  if(X < A){ cout << 0 << endl; }
  else{ cout << 10 << endl;}
  return 0;
}

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

int main() {
  ll q;
  cin>>q;
  priority_queue <ll> small;
  priority_queue<ll, vector<ll>, greater<ll> > large;
  ll cnt=0;

  rep(i,q){
    int a1;
    cin>>a1;

    if (a1==1){
      ll a,b;
      cin>>a>>b;
      cnt+=b;
      small.push(a);
      large.push(a);
      ll A=small.top();
      ll B=large.top();
      small.pop();
      large.pop();
      if (A>B){
        swap(A,B); cnt+=abs(A-B);
      }
      small.push(A);
      large.push(B);
    }

    if (a1==2){
      ll ans=small.top();
      cout<<ans<<' '<<cnt<<endl;
    }
  }

}


Measured memory_bytes: 4588
# 入力
h,n = gets.chomp.split.map(&:to_i)
waza = gets.chomp.split.map(&:to_i)

# 技の合計をだす
s = 0
waza.each{ |i| s += i }

# 出力
if h - s > 0
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 8708
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  if(S.at(0)==S.at(1) && S.at(1)==S.at(2) && S.at(2)==S.at(3)){
    cout<<"No"<<endl;
  }
  else if((S.at(0)==S.at(1) && S.at(2)==S.at(3)) || S.at(0)==S.at(2) && S.at(1)==S.at(3) || S.at(0)==S.at(3) && S.at(1)==S.at(2)){
    cout<<"Yes"<<endl;
  }
          else {
            cout<<"No"<<endl;
          }
          
          return 0;
          }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)


int main(){
  ll x;
  cin >>x;
  ll t=0,res=0;
  rep(i,100004){
    t++;
    res+=t;
    if(res>=x)break;
  }
  cout << t << endl;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int main()
{
  int n;
  cin>>n;
  while(n--)
  {
    int t, x, y;
    cin>>t>>x>>y;
    int total = x + y;
    t = t - total;
    if(t < 0)
    {
      puts("No");
      return 0;
    }
    if(t & 1 == 1)
    {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,sum=0;
  cin >> n;
  ll b[n-1];
  for(int i=0;i<n-1;i++){
    cin >> b[i];
  }
  sum+=b[0];
  for(int i=0;i<n-2;i++){
    sum += min(b[i],b[i+1]);
  }
  sum += b[n-2];
  cout << sum << endl;
}


Measured memory_bytes: 256