akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
const int MOD = 1000000007;
const int N_MAX = 200000;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

long long inverse[N_MAX+1];
long long factorial[N_MAX+1];
long long factorial_inverse[N_MAX+1];

void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}

long long comb(long long n, long long k) {
	return factorial[n] * (factorial_inverse[k] * factorial_inverse[n-k] % MOD) % MOD;
}

int main() {
	long long n, k;
	cin >> n >> k;
	if (k > n-1) k = n-1;
	calc(n);
	long long ans = 0;
	ans++;
	for (int i = 1; i <= k; i++) {
		ans = mod(ans + comb(n,i) * comb(n-1,i) % MOD);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
import Foundation

let o = readLine()!.map { String($0) }
let e = readLine()!.map { String($0) }
var ans = ""
let n = e.count
for i in 0..<n {
  ans += o[i] + e[i]
}
if o.count != n {
  ans += o.last!
}
print(ans)

Measured memory_bytes: 12984
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main() {
  int n, x;
  cin >> n >> x;

  vector<int> v;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }

  sort(v.begin(), v.end());

  int cnt = 0;
  int acc = 0;
  for(int y : v) {
    if(acc + y > x) break;
    acc += y;
    cnt++;
  }

  if(cnt < n) {
    cout << cnt << endl;
  } else {
    if(acc == x) cout << n << endl;
    else cout << n-1 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int N;
  int p[10];
  cin >>N;
  for(int i=0; i<N ; i++)
    cin>> p[i];
  int max=0;
  int index=20;
  for(int i=0; i<N;i++ ){
    if(p[i]>max){ max=p[i]; index=i;}
  }
  int sum=0;
  for(int i=0; i<N ; i++){
    if(i==index) sum+=max/2;
    else sum+=p[i];
  }
  cout<<sum<<endl;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> vec(N + 1, 0);
    for (ll i = 1; i <= N; i++){
        for (ll j = 1; j * i <= N; j++){
            vec[i * j]++;
        }
    }
    ll ans = 0;
    rep(i,N + 1){
        ans += vec[i] * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81328
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 62

type Point struct {
	x, y int
}

type ByX []Point

func (a ByX) Len() int           { return len(a) }
func (a ByX) Less(i, j int) bool { return a[i].x < a[j].x }
func (a ByX) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	X := make([]int, N)
	Y := make([]int, N)
	P := make([]Point, N)
	for i := 0; i < N; i++ {
		x, y := sc.nextInt(), sc.nextInt()
		X[i] = x
		Y[i] = y
		P[i] = Point{x, y}
	}
	sort.Ints(X)
	sort.Ints(Y)
	sort.Sort(ByX(P))
	ans := INF
	for y1 := 0; y1 < N; y1++ {
		for y2 := y1; y2 < N; y2++ {
			for x1 := 0; x1 < N; x1++ {
				target := []Point{}
				for i := 0; i < N; i++ {
					p := P[i]
					if X[x1] <= p.x && Y[y1] <= p.y && p.y <= Y[y2] {
						target = append(target, p)
					}
				}
				count := 0
				idx := 0
				for x2 := x1; x2 < N; x2++ {
					for idx < len(target) && target[idx].x <= X[x2] {
						count++
						idx++
					}
					if count == K {
						x := max(1, X[x2]-X[x1])
						y := max(1, Y[y2]-Y[y1])
						//fmt.Fprintln(wtr, "equal K", X[x2], X[x1], Y[y2], Y[y1], x*y)
						if x*y < ans {
							ans = x * y
						}
						break
					}
				}
			}
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b < c) {
    cout << b + b + a + 1 << endl;
    return 0;
  } else {
    cout << b + c << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

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

    int ans=0;
    rep(i,0,n-2){
        // cout<<s.substr(i,3)<<endl;
        if(s.substr(i,3)=="ABC") ans++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;

int main(){
	int N; cin >> N ;
	vector<int> R(N);
	rep(i,N) cin >> R[i];
	int a = R[0];
	int count = 1;
	rep(i,N-1){
		if(a > R[i+1]){
			a = R[i+1];
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef long long ll;
using namespace std;
int main()
{
    int n;
    cin>>n;
    ll a[n];
    ll cnt=0;

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

    for(int i=1;i<n;i++)
    {
        if(a[i-1]>a[i])
        {
            cnt+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    cout<<cnt<<endl;

return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, a[100000], o = 0, t = 0, f = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (!(a[i] % 4)) {
      f++;
    } else if (!(a[i] % 2)) {
      t = 1;
    } else {
      o++;
    }
  }
  o += t;
  cout << (o - f > 1 ? "No\n" : "Yes\n");
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int a[N],b[N];
vector<int>v;
int f[N];
int getid(int x){ return lower_bound(all(v),x)-v.begin()+1;}
int main()
{
	ll n,m,q,k;
	int ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		v.pb(a[i]);
		v.pb(b[i]);
	}
	sort(all(v));
	//v.erase(all(v),v.end());
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	if(n&1) cout<<b[(n+1)/2]-a[(n+1)/2]+1;
	else cout<<b[n/2]+b[n/2+1]-a[n/2]-a[n/2+1]+1;
}


Measured memory_bytes: 6620
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int x;
    scanf("%d", &x);
    printf("%d\n", x ^ 1);
}

Measured memory_bytes: 3820
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int dx[]={1,1,0,0,-1,-1};
int dy[]={1,0,1,-1,0,-1};
int ban[200][200];
int bfs[200][200];
int main(){
    int a,b;
    while(scanf("%d%d",&a,&b),a){
        for(int i=0;i<200;i++)for(int j=0;j<200;j++)ban[i][j]=bfs[i][j]=0;
        for(int i=0;i<b;i++){
            int c,d;
            scanf("%d%d",&c,&d);
            c+=100;
            d+=100;
            ban[c][d]=1;
        }
        int p,q;
        scanf("%d%d",&p,&q);
        p+=100;
        q+=100;
        queue<pair<int,int> > Q;
        Q.push(make_pair(p,q));
        bfs[p][q]=a+1;
        while(Q.size()){
            int row=Q.front().first;
            int col=Q.front().second;
            Q.pop();
            if(bfs[row][col]==1)break;
            for(int i=0;i<6;i++){
                if(!bfs[row+dx[i]][col+dy[i]]&&!ban[row+dx[i]][col+dy[i]]){
                    bfs[row+dx[i]][col+dy[i]]=bfs[row][col]-1;
                    Q.push(make_pair(row+dx[i],col+dy[i]));
                }
            }
        }
        int ret=0;
        for(int i=0;i<200;i++)for(int j=0;j<200;j++)if(bfs[i][j])ret++;printf("%d\n",ret);
    }
}


Measured memory_bytes: 2964
import sys
input = sys.stdin.readline
N,K = map(int,input().split())
A = [int(input()) for i in range(N)]

class SegTree:
    def __init__(self,arr,func,unit):
        self.func = func
        self.unit = unit
        n = 1
        while n < len(arr):
            n *= 2
        self.n = n
        nodes = [unit]*(2*n-1)
        nodes[n-1:n-1+len(arr)] = arr
        for i in range(n-2,-1,-1):
            nodes[i] = func(nodes[2*i+1],nodes[2*i+2])
        self.nodes = nodes

    def update(self,i,val):
        i += self.n-1
        self.nodes[i] = val
        while i >= 0:
            i = (i - 1) // 2
            self.nodes[i] = self.func(self.nodes[2*i+1], self.nodes[2*i+2])

    def query(self,l,r):
        l += self.n
        r += self.n
        s = self.unit
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(self.nodes[r-1], s)
            if l & 1:
                s = self.func(s, self.nodes[l-1])
                l += 1
            l >>= 1
            r >>= 1
        return s

segt = SegTree([0]*300001, lambda x,y:max(x,y), 0)
for a in A:
    l = max(0,a-K)
    r = min(300001,a+K+1)
    m = segt.query(l,r)
    segt.update(a,m+1)

print(segt.query(0,300001))

Measured memory_bytes: 124192
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0)ans++; 
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        int max = 0;
        for (int i = 0; i < N; i++) {
            int num = sc.nextInt();
            A[i] = num;
            max = Math.max(num, max);
        }
        int gcd = A[0];
        for (int i = 1; i < N; i++) {
            gcd = gcd(A[i],gcd);
        }
        if(K<=max && (max-K) % gcd == 0)
        System.out.println("POSSIBLE");
        else
        System.out.println("IMPOSSIBLE");

    }

    
    static int gcd(int m, int n) {
        if (m < n)
            return gcd(n, m);
        if (n == 0)
            return m;
        return gcd(n, m % n);
    }

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


Measured memory_bytes: 59456
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int A[100000], B[100000], H, N;
int main(){
  int i, mx, res;
  rd(N);
  rd(H);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
      rd(B[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = A[0];
      for(KL2GvlyY=1;KL2GvlyY<N;KL2GvlyY++){
        Q5VJL1cS = max_L(Q5VJL1cS, A[KL2GvlyY]);
      }
    }
    mx =Q5VJL1cS;
  }
  sort(B,B+N);
  res = divup_L(H,mx);
  for(i=0;i<N;i++){
    H -= B[N-i-1];
    if(H <= 0){
      chmin(res, i+1);
      break;
    }
    chmin(res, i+1 + (divup_L(H,mx)));
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180107-1

// --- original code ---
// int N, H, A[100000], B[100000];
// {
//   int i, mx;
//   int res;
//   
//   rd(N,H,(A,B)(N));
//   mx = max(A(N));
//   sort(B,B+N);
// 
//   res = H /+ mx;
//   rep(i,N){
//     H -= B[N-i-1];
//     if(H <= 0){
//       res <?= i+1;
//       break;
//     }
//     res <?= i+1 + (H /+ mx);
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>

using namespace std;
const long long int MAX = -1000000000;

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

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

    int minv = r[0];
    int maxv = MAX;

    for(int j=1;j<n;j++){
        int tmp = r[j] - minv;
        maxv = max(tmp, maxv);
        minv = min(minv, r[j]);
    }

    cout << maxv << endl;
}


Measured memory_bytes: 3612
/**
 *    author:  tourist
 *    created: 20.11.2019 08:57:54       
**/
#include <bits/stdc++.h>

using namespace std;

class matching {
 public:
  vector<vector<int>> g;
  vector<int> pa;
  vector<int> pb;
  vector<int> was;
  int n, m;
  int res;
  int iter;

  matching(int _n, int _m) : n(_n), m(_m) {
    assert(0 <= n && 0 <= m);
    pa = vector<int>(n, -1);
    pb = vector<int>(m, -1);
    was = vector<int>(n, 0);
    g.resize(n);
    res = 0;
    iter = 0;
  }

  void add(int from, int to) {
    assert(0 <= from && from < n && 0 <= to && to < m);
    g[from].push_back(to);
  }

  bool dfs(int v) {
    was[v] = iter;
    for (int u : g[v]) {
      if (pb[u] == -1) {
        pa[v] = u;
        pb[u] = v;
        return true;
      }
    }
    for (int u : g[v]) {
      if (was[pb[u]] != iter && dfs(pb[u])) {
        pa[v] = u;
        pb[u] = v;
        return true;
      }
    }
    return false;
  }

  int solve() {
    while (true) {
      iter++;
      int add = 0;
      for (int i = 0; i < n; i++) {
        if (pa[i] == -1 && dfs(i)) {
          add++;
        }
      }
      if (add == 0) {
        break;
      }
      res += add;
    }
    return res;
  }

  int run_one(int v) {
    if (pa[v] != -1) {
      return 0;
    }
    iter++;
    return (int) dfs(v);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  const int N = (int) 1e7 + 10;
  vector<bool> prime(N, true);
  for (int i = 2; i < N; i++) if (prime[i]) for (int j = i + i; j < N; j += i) prime[j] = false;
  prime[1] = false;
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[x] ^= 1;
    mp[x + 1] ^= 1;
  }
  vector<int> x, y;
  for (auto& p : mp) {
    if (p.second == 1) {
      if (p.first % 2 == 0) x.push_back(p.first);
      else y.push_back(p.first);
    }
  }
  int xn = (int) x.size();
  int yn = (int) y.size();
  matching mat(xn, yn);
  for (int i = 0; i < xn; i++) {
    for (int j = 0; j < yn; j++) {
      if (prime[abs(x[i] - y[j])]) {
        mat.add(i, j);
      }
    }
  }
  int u = mat.solve();
  int ans = u;
  xn -= u;
  yn -= u;
  ans += xn / 2 * 2;
  ans += yn / 2 * 2;
  if (xn % 2 == 1) {
    ans += 3;
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;
// using P = pair<long, long>;
using P = pair<double, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

vector<int> G[200005];

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

  int a;
  cin >> a;

  bool canDo = false;
  rep(i, 50000) {
    if (i * 108 / 100 == a) {
      cout << i << endl;
      canDo = true;
      break;
    }
  }

  if (!canDo) {
    cout << ":(" << endl;
  }

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


int main() {
	int r, d, x; CI r >> d >> x;
	int tmp = x;
	REP(i, 10) {
		tmp = tmp*r-d;
		CO tmp EN;
	}

	return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    converter = {}
    for _ in range(n):
        k, v = input().split()
        converter[k] = v

    m = int(input())
    ans = []
    for _ in range(m):
        v = input().strip()
        try:
            ans.append(converter[v])
        except:
            ans.append(v)

    print("".join(ans))



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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, ini[MX], fin[MX], lvl[MX], cn, sz[MX], c[MX], f[MX];
ll res;
vi adj[MX], pos[MX];
set<int> st;

void dfs (int u, int p = -1) {
	ini[u] = ++cn;
	f[cn] = u;
	sz[u] = 1;

	for (int v : adj[u])
		if (v != p) {
			lvl[v] = lvl[u] + 1;
			dfs(v, u);
			sz[u] += sz[v];
		}

	fin[u] = cn;
}

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

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> c[i];
		pos[c[i]].pb(i);
	}

	forn (i, n - 1) {
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	dfs(1);

	for (int i = 1; i <= n; i++) {
		if (pos[i].empty()) {
			cout << 0 << endl;
			continue;
		}

		res = 1ll * n * (n + 1) / 2;

		sort(all(pos[i]), [&] (int i, int j) {
			return lvl[i] > lvl[j];
		});

		for (int u : pos[i])
			st.insert(ini[u]);

		for (int u : pos[i]) {
			for (int v : adj[u]) {
				if (c[v] == c[u] || lvl[v] < lvl[u]) continue;
				ll x = sz[v];

				auto it = st.upper_bound(ini[v]);

				while (it != st.end() && *it <= fin[v]) {
					x -= sz[f[*it]];
					it++;
				}

				res -= x * (x + 1) / 2;
			}

			auto it = st.upper_bound(ini[u]);

			while (it != st.end() && *it <= fin[u]) {
				auto aux = it;
				it++;
				st.erase(aux);
			}
		}

		if (st.size()) {
			ll x = n;

			for (int w : st)
				x -= sz[f[w]];

			res -= x * (x + 1) / 2;
		}

		cout << res << endl;

		st.clear();
	}

	return 0;
}


Measured memory_bytes: 43856
N=int(input())
S=["a"]*N
T=[0]*N

for i in range(N):
  S[i],T[i]=input().split()
X=input()
flag=0
x=0
for i in range(N):
  if flag==1:
    x+=int(T[i])
  elif X==S[i]:
    flag=1
print(x)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

template <class X> map<X,int> prime_factorize(X a){
    int b = 2;
    map<X,int>cnt;
    while(a >= b * b){
        if(a % b == 0){
            cnt[b]++;
            a /= b;
        }else b++;
    }
    cnt[a]++;
    return cnt;
}

int main(){
    int N;
    cin >> N;
    int P;
    cin >> P;
    vector<int> A(N);
    bool odd = false;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if(a % 2) odd = true;
    }
    if(!odd){
        if(P) puts("0");
        else cout << (ull)pow(2, N) << endl;
    }else cout << (ull)pow(2, N - 1) << endl;
}

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

using namespace std;

#define ll long long

void solve() {
	int a, b;
	cin >> a >> b;
	cout << a*a-b << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



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

using namespace std;

int n, m, x, ans = 1e9;
int a[13][13], c[13], level[13];

void dfs(int cur, int money) {
    if (cur == n + 1) {
        for (int i = 1; i <= m; i++)
            if (level[i] < x) return;
        ans = min(ans, money);
        return;
    }
    for (int i = 1; i <= m; i++)
        level[i] += a[cur][i];
    dfs(cur + 1, money + c[cur]);
    for (int i = 1; i <= m; i++)
        level[i] -= a[cur][i];
    dfs(cur + 1, money);
}

int main() {
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
        for (int j = 1; j <= m; j++) 
            cin >> a[i][j];
    }
    dfs(1, 0);
    cout << (ans == 1e9 ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>

int main(void)
{
	int P, Q, R;
	int sum[6];
	int sum_min = 0;
	scanf("%d %d %d", &P, &Q, &R);

	sum[0] = P + Q;
	sum[1] = P + R;
	sum[2] = Q + P;
	sum[3] = Q + R;
	sum[4] = R + P;
	sum[5] = R + Q;

	sum_min = sum[0];
	for(int i = 0; i < 6; i++){
		if(sum[i] < sum_min){
			sum_min = sum[i];
		}
	}

	printf("%d\n", sum_min);

	return 0;
}


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int X;
  CIN(X);
  bool happy = false;
  if (X == 3)
    happy = true;
  if (X == 5)
    happy = true;
  if (X == 7)
    happy = true;

  if (happy) {
    COUT("YES");
  } else {
    COUT("NO");
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

ll N;

ll a[2005];

ll f(ll A, ll B);
ll min(ll A, ll B);

ll b[2005][2005];

int main() {


	ll x;

	scanf("%lld %lld",&N,&x);

	ll i,k;

	for (i = 0; i < N; i++) {
		scanf(" %lld",&a[i]);
	}
	for (i = 0; i < N; i++) {
		b[i][0] = f(i, 0);
		for (k = 0; k < N - 1; k++) {
			if (i - k - 1 < 0) { b[i][k + 1] = min(b[i][k], a[i - k - 1 + N]); }
			else {
				b[i][k + 1] = min(b[i][k], a[i - k - 1]);
			}
		}
	}
	ll ans = (1ll << 60);
	for (k = 0; k < N; k++) {
		ll sum = k*x;
		for (i = 0; i < N; i++) {
			sum += b[i][k];
		}
		ans = min(ans, sum);
	}
	printf("%lld\n",ans);

	return 0;
}
ll f(ll A, ll B) {
	int i;
	ll r = (1ll << 60);
	for (i = 0; i <= B; i++) {
		if (A - i < 0) {
			r = min(r, a[A - i + N]);
		}
		else {
			r = min(r, a[A - i]);
		}
	}
	return r;
}
ll min(ll A, ll B) {
	if (A >= B) { return B; }
	else { return A; }
}

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

int main() {
  int N,a;
  cin>>N;
  vector <int> s(0);
  for (int i=0;i<N;i++){
    cin>>a;
    s.push_back(a);
  }
  sort(s.begin(),s.end());
  reverse(s.begin(),s.end());
  int p,q;
  p=0;
  q=0;
  for (int i =0;i<N;i++){
    if (i % 2==0){
      p+=s.at(i);
    }
    else{
      q += s.at(i);
    }
  }
  cout << p-q << endl;    
  
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;
 
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int N = 2010;
const int mod = 1e9 + 7;
int n, arr[N];
ll k, f[N], p[N];
ordered_set s;

ll bigmod(ll a, ll n, ll M) {
  ll res = 1LL;
  while (n) {
    if (n & 1) res = (res * a) % M;
    a = (a * a) % M;
    n >>= 1;
  }
  return res % M;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  int ptr = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    s.insert({arr[i], ptr++});
    p[i] = (i - s.order_of_key({arr[i] + 1, 0}));
  }
  for (int i = 1; i <= n; ++i) f[i] = (n - (s.order_of_key({arr[i] + 1, 0})));
  ll inv = bigmod(2, mod - 2, mod);
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ll val = (k*(((2LL*p[i] + (k - 1)*f[i]) % mod)*inv % mod) % mod) % mod;
    ans = (ans + val) % mod;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3804
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s;
    cin >> s;
    bool f = false;
    rep(i, (int)s.sz){
        if(s.substr(i, 2) == "AC"){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



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

int main() {
  int res = 0;
  int a;

  while(cin >> a) {
    res += a;
  }

  if(res >= 22) {
    cout << "bust" << endl;
  }
  else {
    cout  << "win" << endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
using namespace std;
int l,r,d,ans;
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d%d%d",&l,&r,&d);
	ans=r/d-l/d;
	if (l%d==0) ans++;
	printf("%d",ans); 
	return 0;
}

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

int main(){
    int N, D[100000];
    cin >> N;
    for(int i=0; i<N; i++) cin >> D[i];
    sort(D, D+N);
    int ans = D[N/2] - D[N/2-1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

bool IsPrime( int x ){
    bool ans = true;
    if( x > 2 ){
        // even
        if( x % 2 == 0 ) ans = false;
        // odd
        else{
            int div = 3;
            while( div < sqrt(x)+1 ){
                if( x%div == 0 ){
                    ans = false;
                    break;
                }
                div += 2;
            }
        }
    }
    return ans;
}

int main(){
    // input
    int X, y, ans;
    cin >> X;

    // calc
    ans = X;
    while( IsPrime( ans ) == false ){
        ans++;
    }

    // out
    cout << ans << endl;;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    vector<ll> Sum(N + 1);
    for(int i = 0;i < N;i++) {
        Sum.at(i + 1) = Sum.at(i) + vec.at(i);
    }
    vector<ll> positive(N + 1);
    for(int i = 0;i < N;i++) {
        if(vec.at(i) >= 0) {
            positive.at(i + 1) = positive.at(i) + vec.at(i);
        }
        else {
            positive.at(i + 1) = positive.at(i);
        }
    }
    ll ret = 0;
    for(int i = 0;i < N - K + 1;i++) {
        ll Sum2 = Sum.at(i + K) - Sum.at(i);
        ll p = positive.at(N) - positive.at(i + K) + positive.at(i);
        ret = max(ret,max(p,p + Sum2));
    }
    cout << ret << endl;
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;
class Main
{
	static boolean visited[];
	static long dp[][][];
	static long MOD=1000000007L;
	static Hashtable<String , Long>hash=new Hashtable<>();
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			// String h[]=inp.readLine().split(" ");
			// String h[]=inp.readLine().split(" ");

			String h[]=inp.readLine().split(" ");
			System.out.println(Integer.parseInt(h[0])*Integer.parseInt(h[1]));
			
	}
	static int[] gg(String aa)
	{
		int a[]=new int[aa.length()];
		for(int i=0;i<aa.length();i++)
		{
			a[i]=(int)aa.charAt(i)-(int)'0';
		}
		return a;
	}
	static long get(int a[], int d, int sum, int tight, int i)
	{
		if(i==a.length){if(sum%d==0 && sum!=0){return 1;}return 0;}
		// if(dp[i][sum][tight]!=-1){return dp[i][sum][tight];}
		String s=i+" "+sum+" "+tight;
		if(hash.containsKey(i+" "+sum+" "+tight) && tight!=1){return hash.get(i+" "+sum+" "+tight);}
		long ans=0;
		
		int limit=(tight==0?9:a[i]);
			for(int j=0;j<=limit;j++)
			{
				int newt=(a[i]==j?tight:0);

				ans=(ans%MOD+get(a,d,sum+j,newt,i+1)%MOD)%MOD;
			}
			// dp[i][sum%d][tight]=ans;
			hash.put(s,ans);
			return ans;	
	}


	
	static long bfs(int src, ArrayList<ArrayList<Integer>>arr)
	{
		Queue<Pair>q=new LinkedList<>();
		q.add(new Pair(src,1,1));
		visited[src]=true;
		long ans=0;
		while(q.size()!=0)
		{
			ans=0;
			int size=q.size();
			for(int j=0;j<size;j++)
			{
				Pair t=q.poll();
				ans=(ans%MOD+(t.b%MOD+t.c%MOD)%MOD)%MOD;
				for(Integer node:arr.get(t.a))
				{
					if(!visited[node])
					{
						visited[node]=true;
						q.add(new Pair(node,t.b+t.c,t.b));
					}
				}
			}
		}
		return ans%MOD;
	}
}
class Pair
{
	int a;
	long b;
	long c;
	Pair(int e, long f, long h)
	{
		a=e;
		b=f;
		c=h;
	}
}

Measured memory_bytes: 32556
/*
Looking from a window above
It's like a story of love
Can you hear me?
Came back only yesterday
I'm moving further away
Want you near me
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you
Sometimes when I think of her name
When it's only a game
And I need you
Listen to the words that you say
It's getting harder to stay
When I see you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you
Uh uh uh only you, only you
Only you, only you, only you
This is going to take a long time
And I wonder what's mine
Can't take no more
Wonder if you'll understand
It's just the touch of your hand
Behind a closed door
And all I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
Only you
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)(x.size()))
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 3e18;
const int N = 5e5 + 100;




int32_t main(){ 
   FAST;
   string s;
   cin >> s;
   int n = sz(s);
   while(n--)  cout << 'x';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll x;
    cin >>x;
    ll s=100;
    ll count =0;
    while(s<x){
        s+=s/100;
        count++;
    }
    cout <<count <<endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct arr
{
	int x,y;
	bool operator <(const arr &a)
	{
		return x-y<a.x-a.y;
	}
}a[5];
int n,i,j,k,x,y,z;
ll ans=0,s;
int main()
{
	scanf("%d%d%d%d%d%d%d",&n,&a[1].x,&a[2].x,&a[3].x,&a[1].y,&a[2].y,&a[3].y);
	sort(a+1,a+4);
	if ((a[1].x>=a[1].y) || (a[3].x<=a[3].y))
	{
		for (i=0;i<=n;i++)
			for (j=0;i+j<=n;j++)
			{
				x=i,y=j,z=n-i-j;
				s=n+abs(a[1].x-a[1].y)*(x/min(a[1].x,a[1].y))+abs(a[2].x-a[2].y)*(y/min(a[2].x,a[2].y))+abs(a[3].x-a[3].y)*(z/min(a[3].x,a[3].y));
				ans=max(ans,s);
			}
	}
	else if (a[2].x<=a[2].y)
	{
		for (i=0;i<=n;i++)
		{
			x=i,y=n-i;
			s=1LL*n+1LL*(a[1].y-a[1].x)*(x/a[1].x)+1LL*(a[2].y-a[2].x)*(y/a[2].x);
			s+=1LL*(a[3].x-a[3].y)*(s/a[3].y);
			ans=max(ans,s);
		}
	}
	else
	{
		k=n+(a[1].y-a[1].x)*(n/a[1].x);
		for (i=0;i<=k;i++)
		{
			y=i,z=k-i;
			s=1LL*k+1LL*(a[2].x-a[2].y)*(y/a[2].y)+1LL*(a[3].x-a[3].y)*(z/a[3].y);
			ans=max(ans,s);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int[] A = new int[N];
    int[] P = new int[Q];
    Arrays.fill(A, K - Q);
    for (int i = 0; i < Q; i++) {
      A[sc.nextInt() - 1]++;
    }
    for (int i = 0; i < N; i++) {
      if (A[i] > 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}


Measured memory_bytes: 63000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));


signed main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    //dp[i][j]=i:bit j:bool
    ll dp[50][2];
    rep(i,50)rep(j,2)dp[i][j]=-1;
    dp[49][0]=0; //kと同じ
    for(int bit=48;bit>=0;bit--){
        ll pl=(1ull<<bit);
        ll cnt=0;
        rep(i,n) if(a[i]&pl) cnt++;
        if(pl&k){
            if(dp[bit+1][0]>=0) dp[bit][0]=dp[bit+1][0]+(n-cnt)*pl;
            if(dp[bit+1][0]>=0) dp[bit][1]=dp[bit+1][0]+pl*cnt;
            if(dp[bit+1][1]>=0) chmax(dp[bit][1],dp[bit+1][1]+pl*max(n-cnt,cnt));
        }else{
            if(dp[bit+1][0]>=0) dp[bit][0]=dp[bit+1][0]+cnt*pl;
            if(dp[bit+1][1]>=0){
                chmax(dp[bit][1],dp[bit+1][1]+pl*max(n-cnt,cnt));
            }
        }
    }
    cout << max(dp[0][0],dp[0][1]) << endl;
}




Measured memory_bytes: 3892
a,v = map(int,input().split())
b,w = map(int,input().split())

t = int(input())

dis = abs(a-b)

if dis == 0:
    print("YES")
else:
    vdiff = v-w

    if vdiff <= 0:
        print("NO")
    else:
        if vdiff *t >= dis:
            print("YES")
        else:
            print("NO")

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	int n, q;
	cin >> n >> q;
	vi v(n + 1, -INF);
	priority_queue<pii> que;
	
	REP(i, q) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (v[a] == -INF)
			v[a] = b;
		else
			v[a] += b;
		que.push(pii(v[a], -a));
		
		pii ans;
		while (true) {
			ans = que.top();
			if (ans.first == v[-ans.second]) break;
			que.pop();
		}
		printf("%d %d\n", -ans.second, ans.first);
	}
	return 0;
}

Measured memory_bytes: 6040
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: u32 = read();
    let a: u32 = read();
    let b: u32 = read();
    let mut left = x - a;
    while left >= b {
        left -= b;
    }
    println!("{}", left);
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec s(n);
    cin>>s;

    ll sum = 0;
    rep(i,n)sum += s[i];
    ll ans=sum;

    if(sum%10!=0){
        //
    }else{
        sort(ALL(s));
        rep(i,n){
            if(s[i]%10!=0){
                ans -= s[i];
                goto aa;
            }
        }
        ans = 0;
    }
    aa:
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;

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

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

    map<pair<int,int> ,int> fox;
    for(int i=0; i<n; i++){
        int x,y,w;
        cin >> x >> y >> w;
        fox[make_pair(x,y)] = w;
    }

    int ans=0;
    map<pair<int,int> ,int>::iterator itr;
    for(itr=fox.begin(); itr!=fox.end(); itr++){
        int x=itr->first.first;
        int y=itr->first.second;
        int w=itr->second;
        for(int i=0; i<8; i+=2){
            int sub=w;
            for(int j=0; j<3; j++){
                if(fox.count(make_pair(x+dx[(i+j)%8], y+dy[(i+j)%8])) != 0){
                    sub += fox[make_pair(x+dx[(i+j)%8], y+dy[(i+j)%8])];
                }
            }
            ans = max(ans, sub);
        }
    }

    cout << ans << " / 1" << endl;
    return 0;
}

Measured memory_bytes: 9316
#include<bits/stdc++.h>
    #define dbug printf("I am here\n");
    #define Fast ios_base::sync_with_stdio(false); cin.tie(0);
    #define vs            v.size()
    #define ss             s.size()
    #define be            v.begin(),v.end()
    #define pii             pair<int,int>
    #define ll               long long
    #define pb             push_back
    #define mpp            make_pair
    using namespace std;

    int main(){

    ll int a,b,c,d,n,k;
    int tst;
    string s;
    char ch,cc;
    cin>>n>>k;
    int cnt = 0;
    for(int i=0;i<n;i++){
            cin>>a;
        if(a>=k)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
    }


Measured memory_bytes: 3604