akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define alpha_size 26


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
    
    int n;
    cin >> n;
    if (n & 1)
      cout << n / 2 + 1 << endl;
    else
      cout << n / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll h,w; cin >> h >> w;
    vector<vector<ll>> a(h,vl(w)), b(h,vl(w));
    rep(i,h)rep(j,w)cin >> a[i][j];
    rep(i,h)rep(j,w)cin >> b[i][j];
    vvl sub(h,vl(w));
    rep(i,h)rep(j,w)sub[i][j] = abs(a[i][j] - b[i][j]);
    const int r_max = 13000;
    bitset<r_max> bs(0);
    vector<vector<bitset<r_max>>> dp(2,vector<bitset<r_max>>(w,bs));
    dp[0][0][sub[0][0]] = 1;
    rep(i,h)rep(j,w){
        rep(k,r_max){
            if(dp[i%2][j][k]){
                if(j+1 < w)dp[i%2][j+1][k + sub[i][j+1]] = 1;
                if(j+1 < w)dp[i%2][j+1][abs(k - sub[i][j+1])] = 1;
                if(i+1 < h)dp[(i+1)%2][j][k + sub[i+1][j]] = 1;
                if(i+1 < h)dp[(i+1)%2][j][abs(k - sub[i+1][j])] = 1;
            }
        }
        // debug(i);
        // debug(j);
        // debug(dp[i][j]);
       if(i < h-1 || j < w-1) dp[i%2][j] = bs;
    }


    ll res = r_max;
    rep(i,r_max){
        if(dp[(h-1)%2][w-1][i]){
            res = i;
            break;
        }
    }
    cout << res << endl;
}

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

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


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            double a = Math.Abs(inp[0] - inp[1]);
            double b = Math.Abs(inp[0] - inp[2]);
            Console.WriteLine(a < b ? "A" : "B");
        }
    }
}

Measured memory_bytes: 11348
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, M = in.nextInt
  val Reqs = List.fill(M)((in.nextInt, in.nextInt)).sorted

  def next(reqs: List[(Int, Int)], min: Int, breaks: Int): Int = reqs match {
    case Nil => breaks + 1
    case (l, r) :: xs =>
      if (min <= l) next(xs, r, breaks + 1)
      else next(xs, math.min(min, r), breaks)
  }

  println(next(Reqs, Int.MaxValue, 0))
}

Measured memory_bytes: 106840
package main

import (
	"bufio"
	"fmt"
	"os"
	"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
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

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

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextStr()
	for i := 2; i < len(S); i += 2 {
		last := len(S) - i
		mid := last / 2
		if S[0:mid] == S[mid:last] {
			fmt.Fprintln(wtr, last)
			wtr.Flush()
			return
		}
	}
}


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

string s[5000000+5];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s,s+n);
	long long cnt = 1;
	long long sum = 0;
	for(long long i=0;i<n;i++){
		if(s[i]!=s[i+1] && cnt!=1){
			sum+=(cnt*(cnt-1))/2;
			cnt=1;
		}
		else if(s[i]!=s[i+1]&& cnt==1){
			cnt = 1;
		}
		else cnt++;
	} 
	sum+=(cnt*(cnt-1))/2;
	cout<<sum<<endl;
}

Measured memory_bytes: 45568
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b,c = LI()
        a -= 1
        b -= 1
        v[a].append((b,c))
        v[b].append((a,c))
    bfs = [-1]*n
    q = deque([0])
    bfs[0] = 0
    ans = [0]*n
    while q:
        x = q.popleft()
        for y,c in v[x]:
            nd = bfs[x]+c
            if bfs[y] < 0:
                bfs[y] = nd
                ans[y] = nd&1
                q.append(y)
    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;

const long long INF = 1ll << 60;

int main(){
  int N; cin >> N;
  
  vector<long long> sum(N + 1);
  sum[0] = 0;
  for(int i = 1; i <= N; i++){
    int A; cin >> A;
    sum[i] = A; sum[i] += sum[i - 1];
  }
  
  long long diff = INF;
  
  int b = 1, d = 3;
  for(int c = 2; c < N - 1; c++){
    while(b + 1 < c && abs(sum[c] - 2 * sum[b]) > abs(sum[c] - 2 * sum[b + 1])){
      b++;
    }
    
    while(d <= c) d++;
    
    while(d + 1 < N && abs(sum[N] - 2 * sum[d] + sum[c]) > abs(sum[N] - 2 * sum[d + 1] + sum[c])){
      d++;
    }
    
    long long P = sum[b];
    long long Q = sum[c] - sum[b];
    long long R = sum[d] - sum[c];
    long long S = sum[N] - sum[d];
    
    diff = min(max(max(P, Q), max(R, S)) - min(min(P, Q), min(R, S)), diff);
  }
  
  cout << diff << endl;
  
  return 0;
}

Measured memory_bytes: 1792
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# 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(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int x, y, z, a[101010], b[101010], c[101010];
LL aa[101010], bb[101010];
LL ans;
int sorter[101010];
LL dp1[101010], dp2[101010];

int compare(int k1, int k2) {
	return a[k1] - b[k1] < a[k2] - b[k2];
}

int main() {
	cin >> x >> y >> z;
	int n = x + y + z;
	REP(i, n) {
		cin >> a[i] >> b[i] >> c[i];
		ans += c[i];
		a[i] -= c[i];
		b[i] -= c[i];
	}
	REP(i, n)sorter[i] = i;
	sort(sorter, sorter + n, compare);
	REP(i, n) {
		int j = sorter[i];
		aa[i] = a[j];
		bb[i] = b[j];
	}

	priority_queue<LL> que;
	REP(i, n) dp1[i] = -HLINF;
	LL sum = 0;

	REP(i, n) {
		que.push(-bb[i]);
		sum += bb[i];
		if (y < que.size()) {
			LL q = -que.top();
			sum -= q;
			que.pop();
		}
		if (que.size() == y) dp1[i] = sum;
	}
	priority_queue<LL> que2;
	REP(i, n) dp2[i] = -HLINF;
	LL sum2 = 0;

	for (int i = n - 1; i >= 0; i--) {
		que2.push(-aa[i]);
		sum2 += aa[i];
		if (x < que2.size()) {
			LL q = -que2.top();
			sum2 -= q;
			que2.pop();
		}
		if (que2.size() == x) dp2[i] = sum2;
	}

	LL maxl = -HLINF;
	REP(k, n - 1)maxl = max(maxl, dp1[k] + dp2[k + 1]);
	ans += maxl;
	cout << ans << endl;
}

Measured memory_bytes: 6264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
std::vector<ll>uni(100010,-1);
ll root(ll a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]);
}
bool connect(ll a,ll b){
    a=root(a);b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b])std::swap(a,b);
    uni[a]+=uni[b];
    uni[b]=a;
    return true;
}

using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    vector<ll>v(n);rep(i,n){cin>>v[i];v[i]--;}
    ll x,y;
    rep(i,m){
        cin>>x>>y;x--;y--;
        connect(x,y);
    }
    map<ll,vector<ll>>M;
    rep(i,n){
        M[root(i)].push_back(i);
    }
    map<ll,vector<ll>>::iterator it=M.begin();
    ll ans=0;
    while(it!=M.end()){
        vector<ll>V=(*it).S;
        vector<ll>C;rep(i,V.size())C.push_back(v[V[i]]);
        sort(all(V));sort(all(C));
        rep(i,V.size()){
            if(binary_search(all(C),V[i]))ans++;
        }
        //rep(i,V.size())cout<<V[i]<<' ';
        //cout<<endl;
        //rep(i,C.size())cout<<C[i]<<' ';
        //cout<<endl<<endl;
        it++;
    }
    cout<<ans;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	int n;
  	cin>>n;
  	vi a(n), b(n); 
  	rep(i, n){
      	cin>>a[i];
    	b[a[i]-1]=i+1;
    }
  	rep(i, n){
    	cout<<b[i]<<" ";
    }
  	cout<<endl;
}

Measured memory_bytes: 1664
n = int(input())
a = list(map(int, input().split()))
b = list(range(n))
k = 2
s = 0
for i in range(n):
  if (n/2-1) < (n-i-1):
    b[n-i-1] = a[n-i-1]
  else:
    while n > k*(n-i)-1:
      s += b[k*(n-i)-1]
      k += 1
    if s % 2 == a[n-i-1]:
      b[n-i-1] = 0
    else:
      b[n-i-1] = 1
  k = 2
  s = 0
ans = b.count(1)
print(ans)
for i in range(n):
  if b[i] == 1:
    print(i+1, end=" ")

Measured memory_bytes: 13520
level = {'0':'light fly','48':'fly','51':'bantam','54':'feather','57':'light','60':'light welter',
'64':'welter','69':'light middle','75':'middle','81':'light heavy','91':'heavy'}
weight = [eval(x) for x in list(level.keys())]
weight.sort()
weight.reverse()
while True:
	try:
		w = eval(input())
		for i in range(len(weight)):
			if w > weight[i]:
				print(level[str(weight[i])])
				break
	except EOFError:
		break;

Measured memory_bytes: 7424
#include<stdio.h>
#include<limits.h>

int main(){
  int n;
  int i;
  long max = LONG_MIN;
  long min = LONG_MAX;
  long sum = 0;
  int num;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &num);

    if(num < min){
      min = num;
    }

    if(num > max){
      max = num;
    }

    sum += num;
  }

  printf("%ld %ld %ld\n", min, max, sum);

  return 0;
}


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

int main() {
  int x; cin >> x;
  int ans = 0;
  for (int i = 1; i <= x; i++) {
    for (int j = 2; j <= 10; j++) {
      int power = pow(i, j);
      if (power > x) break;
      ans = max(ans, power);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//AOJ-GRL-3-C
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

struct SCC{
    int n;
    vector<vector<int>> G,R;
    vector<int> vs, cmp;
    vector<bool> used;

    SCC(int n) : n(n), G(n), R(n), used(n), cmp(n){}

    int operator [] (int k) { return cmp[k]; };

    void add_edge(int u, int v){
        G[u].emplace_back(v);
        R[v].emplace_back(u);
    }

    void dfs(int v){
        used[v] = true;
        for(int u : G[v]){
            if(!used[u]) dfs(u);
        }
        vs.emplace_back(v);
    }

    void rdfs(int v, int k){
        used[v] = true;
        cmp[v] = k;
        for(int u : R[v]){
            if(!used[u]) rdfs(u, k);
        }
    }

    int build(){
        for(int v = 0; v < n; v++){
            if(!used[v]) dfs(v);
        }
        fill(used.begin(), used.end(), false);
        int k = 0;
        for(int i = n - 1; i >= 0; i--){
            if(!used[vs[i]]){
                rdfs(vs[i], k);
                k++;
            }
        }
        return k;
    }
};

signed main(){
    int V,E;
    cin >> V >> E;
    SCC scc(V);
    REP(i,E){
        int s,t;
        cin >> s >> t;
        scc.add_edge(s,t);
    }
    scc.build();
    int q;
    cin >> q;
    while(q--){
        int u,v;
        cin >> u >> v;
        cout << (scc[u] == scc[v]) << endl;
    }
    return 0;
}


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

int main(){
    while(true){
        int h,w;
        cin >> h >> w;
        if(h==0 && w==0)break;
        for(int i=0;i<h;i++){
            if(1<=i&&i<h-1){
                cout << "#";
                for(int j=0;j<(w-2);j++)cout<< ".";
                cout << "#";
            }else{
                for(int j=0;j<w;j++)cout<< "#";
            }
            cout << endl;
        } 
        cout << endl;  
    }
return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef pair<ll,ll> p;

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

ll lcm(ll a, ll b)
{
  ll g = gcd(a, b);
  return a / g * b;
}

int main()
{
  int n, x;
  cin >> n >> x;
  vector<int> v(n, 0);

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

  ll res = v[0];
  for (int i = 1; i < n; i++) {
    res = gcd(res, v[i]);
  }

  cout << abs(res) << endl;
}

Measured memory_bytes: 640
from itertools import combinations
N,X,Y=(int(x) for x in input().split())
result={x:0 for x in range(1,N)}
for i in combinations(range(1,N+1),2):
	result[min(abs(i[0]-X)+abs(i[1]-Y)+1,i[1]-i[0])] += 1
for i in range(1,N):
  print(result[i])

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  long long cnt = 1000;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n-1; i++){
    long long ans = 0;
    if(a[i] < a[i+1]) ans  = cnt/a[i];
    cnt += (a[i+1] - a[i]) * ans;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
 
int n, q;
vector<int> et[200000];
int p, x;
int val[200000];
 
void dfs(int p, int v) {
	int i;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		val[nv] += val[v];
		dfs(v, nv);
	}
}
 
signed main() {
	int i;
	
	cin >> n >> q;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	rep(i, q) {
		cin >> p >> x;
		p--;
		val[p] += x;
	}
	dfs(-1, 0);
	
	rep(i, n) {
		cout << val[i];
		if (i + 1 < n) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long int N,K;
    cin >> N >> K;
    cout << N-K+1;
    return 0;
}

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

int main() 
{
    int N;
    cin >> N;
    const int AMAX = sqrt(N);
    long count = 0;
    for (int A = 1; A <= AMAX; ++A) {
        for (int B = A + 1; A * B < N; ++B) {
            ++count;
        }
    }
    count *=2;
    for (int A = 1; A <= AMAX; ++A) {
        if (A * A < N) {
            ++count;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main() {
	long long n;cin>>n;

	long long ans=0;
	set<long long> s;
	for(int i=1;i<=sqrt(n);i++){
		if(n%i==0){
			if(i<n)s.insert((n/i)-1);
			if(n/i < n)s.insert(i-1);
		}
	}
	for(auto itr=s.begin();itr!=s.end();itr++){
		if(n/(*itr) == n%(*itr)){
			ans+=(*itr);
			//cout<<(*itr)<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,i;
    cin>>n;
    pair<long long, long long> p[n];
    for(i=0;i<n;i++)
    {
        cin>>p[i].first;
        p[i].second=i+1;
    }
    sort(p,p+n);
    for(i=0;i<n;i++)
    {
        cout<<p[i].second<<" ";
    }
    return 0;
}

Measured memory_bytes: 5104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int N;
	int four=0;
	int two=0;

	scanf("%d",&N);
	for(int i=0;i<N;i++){
		long long a;
		scanf("%lld",&a);
		if(a%4==0){
			four++;
		}else if(a%2==0){
			two++;
		}
	}

	if(two > 0){
		if( (N-two) <= four * 2){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		if( (N-two-1) <= four * 2){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}


	return 0;
}


Measured memory_bytes: 128
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 10e8+7LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs
 
void solve()
{
    IN(n, k);
    ll a = 0;
    for (ll i = k; i <= n+1; ++i)
    {
        ll s = i*(i-1LL)/2LL % MOD;
        ll s2 = (s + (n-i+1LL)*i % MOD) % MOD;
        a = (a + (s2 - s + 1LL + MOD) % MOD) % MOD;
    }
    cout << a % MOD << endl;
}
 
int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);
 
    solve();
 
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// 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 = 1000000007;
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint mpow(mint x, ll y){
  if(y == 0){
    return 1;
  }
  if(y % 2 == 0){
    mint a = mpow(x, y / 2);
    return a * a;
  }
  else{
    mint a = mpow(x, y / 2);
    return a * a * x;
  }
}

int main()
{
    ll N;
    cin >> N;
    cout << mpow(10, N)-(mpow(9,N)*2-mpow(8,N)) << endl;
}

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

int main(){
    ll n; cin >> n;
    vector<int> a(100000, 0);
    int inc = 1;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int initial=0;
    for(int i=1; i<n; i++){
        initial++;
        if(a[i] != a[0]){
            if(a[i] > a[0]) inc = 1;
            if(a[i] < a[0]) inc = -1; 
            break;
        }
    }
    
    int cnt = 0;
    for(int i=initial+1; i<n; i++){
        if(inc==0){
            if(a[i]==a[i-1]) continue;
            if(a[i]>a[i-1]) inc=1;
            if(a[i]<a[i-1]) inc=-1;
        }else if(inc == 1){
            if(a[i]<a[i-1]){
                inc=0; cnt++;
            }
        }else if(inc == -1){
            if(a[i]>a[i-1]){
                inc=0; cnt++;
            }
        }
    }
    cout << cnt+1 << endl;
    return 0;
}

Measured memory_bytes: 3776
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	int N, M;
	cin >> N >> M;
	
	vector<ll> a(M);
	vector<ll> b(M);
	vector<ll> c(M);
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
	}

	vector<ll> v(N, -LINF);

	v[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			v[b[j]] = max(v[b[j]], v[a[j]] + c[j]);
		}
	}

	ll ans1 = v[N-1];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			v[b[j]] = max(v[b[j]], v[a[j]] + c[j]);
		}
	}

	ll ans2 = v[N-1];

	if (ans1 == ans2) cout << ans1 << endl;
	else cout << "inf" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{
    char x;cin>>x;
    x++;
    if(x>'z')x='a';cout<<x<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 2*100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
using namespace std;


int main()
{
	fast;
	ll a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}

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

namespace CircleinaRectangle
{
    class CircleinaRectangle
    {
        public static void Main()
        {
            string[] s = Console.ReadLine().Split(' ');
            int W = int.Parse(s[0]);
            int H = int.Parse(s[1]);
            int x = int.Parse(s[2]);
            int y = int.Parse(s[3]);
            int r = int.Parse(s[4]);

            if (x >= r && y >= r && x + r <= W && y + r <= H)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> a[i];
    }
    Int res = 0;
    for (Int i = 0; i < (Int)n; i++) {
        while (a[i] % 2 == 0) {
            res++;
            a[i] /= 2;
        }
    }
    print(res);
    return 0;
}

Measured memory_bytes: 384
n = int(input())
A = [int(input()) for _ in range(n)]
ans = A[0] - 1
tmp = 1
for a in A[1:]:
    if a <= tmp:
        pass
    elif a - 1 == tmp:
        tmp = a
    else:
        ans += (a - 1) // (tmp + 1)
print(ans)

Measured memory_bytes: 81352
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

//前計算で計算量を減らす

ll l[2010][2010], r[2010][2010], u[2010][2010], d[2010][2010];

int main() {
  ll H, W; cin >> H >> W;
  Vs s(H);
  rep(h, 0, H) cin >> s[h];

  rep(h, 0, H){
    ll cnt = 0;
    rep(w, 0, W){
      if(s[h][w] == '#'){
        cnt = 0;
      }else{
        cnt++;
        l[h][w] = cnt;
      }
    }
  }

  rep(h, 0, H){
    ll cnt = 0;
    for(int w = W-1; w >= 0; w--){
      if(s[h][w] == '#'){
        cnt = 0;
      }else{
        cnt++;
        r[h][w] = cnt;
      }
    }
  }

  rep(w, 0, W){
    ll cnt = 0;
    rep(h, 0, H){
      if(s[h][w] == '#'){
        cnt = 0;
      }else{
        cnt++;
        u[h][w] = cnt;
      }
    }
  }

  rep(w, 0, W){
    ll cnt = 0;
    for(int h = H-1; h >= 0; h--){
      if(s[h][w] == '#'){
        cnt = 0;
      }else{
        cnt++;
        d[h][w] = cnt;
      }
    }
  }

  ll ans = 0;
  rep(h, 0, H){
    rep(w, 0, W){
      if(s[h][w] == '#') continue;
      ll cnt = l[h][w]+r[h][w]+u[h][w]+d[h][w]-3;
      ans = max(ans, cnt);
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  string o, e;
  cin >> o >> e;

  REP(i, o.size()) {
    cout << o[i];
    if(i < e.size()) {
      cout << e[i];
    }
  }
  cout << endl;

  return 0;
}


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

int n,a,b,ans;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>a>>b;
	for(int i=1;i<=n;++i){
		int t=0,j=i;
		while(j!=0){
			t+=j%10;
			j/=10;
		}
		if(t>=a&&t<=b) ans+=i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())

A = []
for i in range(h):
    a = list(input())
    if '#' in a:
        A.append(a)
        
for j in range(w - 1, -1, -1):
    for i in range(len(A)):
        if A[i][j] == '#':
            break
    else:
        for k in range(len(A)):
            del A[k][j]
            
for i in range(len(A)):
    print(''.join(A[i]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  string S;
  cin>>S;
  
  int x=0;
  
  int ans=0;
  
  
  for(int i=0;i<N;i++){
    if(S[i]=='I'){
      x++;
    }
    else{
      x--;
    }
    ans=max(ans,x);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int h= 0,n=1;
	cin>>h>>n;
  int a[n];

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

for(int i =0;i<n;i++)
	h=h-a[i];
if(h<=0)
  cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 640
function seach(x){
   var flag=true;
   var cnt=0;
   var sum=0;
   for(var i=0;i<ary.length;i++){
      if(x<ary[i]){
         flag=false;
         break;
      }else if(sum+ary[i]==x){
         sum=0;
         if(i!=ary.length-1)cnt++;
      }else if(sum+ary[i]>x){
         sum=ary[i];
         cnt++;
      }else if(sum+ary[i]<x){
         sum+=ary[i];
      }
      if(cnt==m){
         flag=false;
         break;
      }
   }
   return flag;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var mn=arr.shift();
   if(mn=="0 0")break;
   mn=mn.split(" ").map(Number);
   var m=mn[0];
   var n=mn[1];
   var ary=[];
   while(n--)ary.push(arr.shift()-0);
   var L=0;
   var R=1500000
   while(true){
      var middle=Math.floor((L+R)/2);
      var flag=seach(middle);
      if(flag){
         R=middle-1;
      }else{
         L=middle+1;
      }
      if(L>R){
         if(flag)console.log(R+1);
         else console.log(L);
         break;
      }
   }
}

Measured memory_bytes: 16084
N, M = map(int, input().split())
mise = [[int(x) for x in input().split()] for y in range(N)]
mise.sort()
m = 0
ans = 0
for val, hon in mise:
    zan = M - m
    if zan <= 0:
        break

    if zan > hon:
        m += hon
        ans += val * hon
    else:
        m += zan
        ans += zan * val

print(ans)

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

int main(void) {
    int64_t N,K,Q,a;
    cin >> N >> K >> Q;

    vector<int64_t> A(N,K);
    for(int i=0;i<Q;i++) {
        cin >> a;
        A[a-1]++;
    }

    for(int i=0;i<N;i++) {
        if((A[i]-Q) > 0) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int a,b;
    cin>>a>>b;
    if(a>b){
        REP(i,a)cout<<b;
        cout<<endl;
    }else{
        REP(i,b)cout<<a;
        cout<<endl;
    }
}

Measured memory_bytes: 256
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    //int a[100005],b[100005],c[100005];
    //bool flag=false,d[100005];
    int a,b,n,ans=1;
   
    cin >> a >> b;
    //for(int i=0;i<n-1;i++) cin >> a[i] >> b[i];
    
    n = a+b;
    if(n==3) ans=3;
    else if(n==4) ans=2;

    
    //cout << (!flag ? "Yes" : "No");
    cout << ans;
    //cout << s;
    //printf("%.10f",ans_d);
    cout << endl;
}


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

//080-B
int main()
{
	int n,s=0,t;
	cin>>n;
	t=n;
	while(t!=0){
		s+=t%10;
		t=t/10;
	}
	if(n%s==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

void putQueen(int);

char A[N][N],k,X[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1],con=0;;    

int main()
{
  int r,c,i,j;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      X[i][j] = '.';
      row[j] = FREE;
      col[j] = FREE;
    }
  }

  for(i = 0; i < 2*N-1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }

  scanf("%d",&k);

  for(i = 0; i < k; i++){
    scanf("%d %d",&r,&c);
    A[r][c] = 'Q';
  }

  putQueen(0);

  return 0;
}

void putQueen(int i){
  int j,k;

  if(i == N){
    for(j = 0; j < N; j++){
      for(k = 0; k < N; k++){
	if(A[j][k] == 'Q'){
	  if(row[j] != k)return;
	}
      }
    }
    for(j = 0; j < N; j++){
      for(k = 0; k < N; k++){
	printf("%c",X[j][k]);
      }
      printf("\n");
    }
 
    return;
  }

    for(j = 0; j < N; j++){
      if(NOT_FREE == col[j] ||
	 NOT_FREE == dpos[i + j] ||
	 NOT_FREE == dneg[i - j + N - 1])continue;

      X[i][j]='Q';
      row[i] = j;
      col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
      
      putQueen(i + 1);

      row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
      X[i][j]='.';
    }
}



Measured memory_bytes: 2112
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))

#define equal equalll
#define less lesss
const int N = -1;
const long long INF = 1e9 + 19;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int n;

void read() {
}

void ret(int flag, bool rev) {
    if (rev)
        flag = 3 - flag;
    if (flag == 1) {
        puts("First");
    }
    else if (flag == 2) {
        puts("Second");
    }
    else 
        assert(false);
    exit(0);
}

void go(vector<int> a, bool rev) {

    ll sum = 0;
    for (auto x: a)
        sum += x;

    if ((sum - n) % 2 == 1) {
        ret(1, rev);
    }
    for (auto x: a)
        if (x == 1)
            ret(2, rev);

    vector<int> pos; 
    for (int i = 0; i < n; i++)
        if (a[i] % 2 != 0)
            pos.pb(i);

    if (pos.size() == 1) {
        a[pos[0]]--;
        int g = a[0];
        for (auto x: a)
            g = __gcd(g, x);

        assert(g >= 2);
        for (auto& x: a)
            x /= g;
        go(a, rev ^ 1);
    }
    else
        ret(2, rev);
}

void solve() {
    vector<int> a;
    scanf("%d", &n);
    a.resize(n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    if (n == 1) {
        assert(a[0] == 1);
        ret(2, 0);
    } 
    go(a, 0);
}

void stress() {

}

int main(){
#ifdef HOME 
    freopen("in", "r", stdin);
#endif
    if (1) {
        read();
        solve();
    }
    else {
        stress();
    }

    return 0;
}



Measured memory_bytes: 9984
import java.util.*;
import java.lang.*;

class Main
{
	public static void main (String[] args)
	{
		for(int i = 1 ; i < 10 ; i++)
		{
			for(int j = 1 ; j < 10 ; j++)
			{
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}
}

Measured memory_bytes: 24168
#include "bits/stdc++.h"

using namespace std;

int A,B,C,K ;
int nRet = 0;

void input() {
	cin >> A >> B >> C >> K;
}

void solve() {
	if (K > A) {
		nRet += A;
		K -= A;
	}
	else {
		nRet += K;
		return;
	}

	if (K > B) {
		K -= B;
	}
	else {
		return;
	}
	if (K > C) {
		nRet -= C;
		K -= C;
	}
	else {
		nRet -= K;
		return;
	}
}


int main() {
	input();
	solve();
	cout << nRet << endl;
	return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;

void yes(){
    cout<<"Yes"<<endl;
}

void no(){
    cout<<"No"<<endl;
}

void solve(){
    string s;
    cin>>s;
    int n=s.length();
    int l=0, r = n-1;
    while(l<=r && s[l]==s[r]){
        l++;r--;
    }
    if(l<r){
        no();
        return;
    }else{
        l=0;
        r=(n-1)/2-1;
        while(l<=r && s[l]==s[r]){
            l++;r--;
        }
        if(l<r){
            no();
            return;
        }else{
            yes();
            return;
        }
    }
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


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

class Main {

    public static void p_one(int rep, Double[] a, Double[] b) {
        Double sum = 0.0;
        for (int i = 0; i < rep; i++) {
            sum += Math.abs(a[i] - b[i]);
        }
        System.out.printf("%.5f\n", sum);
    }

    public static void p_two(int rep, Double[] a, Double[] b) {
        Double sum = 0.0;
        for (int i = 0; i < rep; i++) {
            sum += Math.pow(Math.abs(a[i] - b[i]), 2);
        }
        System.out.printf("%.5f\n", Math.sqrt(sum));
    }

    public static void p_three(int rep, Double[] a, Double[] b) {
        Double sum = 0.0;
        for (int i = 0; i < rep; i++) {
            sum += Math.pow(Math.abs(a[i] - b[i]), 3);
        }
        System.out.printf("%.5f\n", Math.pow(sum, 1.0 / 3.0));
    }

    public static void p_four(int rep, Double[] a, Double[] b) {
        Double max = 0.0;
        Double tmp;
        for (int i = 0; i < rep; i++) {
            tmp = Math.abs(a[i] - b[i]);
            if (max <= tmp)
                max = tmp;
        }
        System.out.printf("%.5f\n", max);
    }

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n;
        Double[] x;
        Double[] y;
        String[] data;
        try {
            n = Integer.parseInt(br.readLine());
            x = new Double[n];
            y = new Double[n];

            data = br.readLine().split(" ");
            for (int i = 0; i < n; i++)
                x[i] = Double.parseDouble(data[i]);
            data = br.readLine().split(" ");
            for (int i = 0; i < n; i++)
                y[i] = Double.parseDouble(data[i]);

            p_one(n, x, y);
            p_two(n, x, y);
            p_three(n, x, y);
            p_four(n, x, y);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24912
<?php

fscanf(STDIN, "%d %d", $n, $m);
$inputs = [];
for ($i = 0; $m > $i; $i++) {
    $input = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $inputs[] = $input;
}

$ans = array_pad([], $n, '-');

#var_dump($ans);
foreach ($inputs as $input) {
    $index = $input[0] -1;
    $num   = $input[1];

    if ($n > 1 && $index == 0 && $num == 0) {
        echo -1;
        exit;
    }
    if (isset($ans[$index])) {
        if ($ans[$index] != '-' && $ans[$index] != $num) {
            echo -1;
            exit;
        }
        $ans[$index] = $num;
    }
}
#var_dump($ans);

if ($n > 1 && $ans[0] == '-') $ans[0] = 1;
$ans = str_replace('-', '0',$ans);

$x = intval(join('', $ans));
#var_dump($x);
$len = strlen($x);
if ($len == $n) {
    echo $x;
} else {
    echo -1;
}


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

int main()
{
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z_ = s - x - y;
            if (0 <= z_ && z_ <= k) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

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

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

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> d(10, vector<ll>(10));
    rep(i, 10) {
        rep(j, 10) {
            ll c; 
            cin >> c;
            d[i][j] = c;
        }
    }
    rep(i, 10) {
        rep(j, 10) {
            rep(k ,10) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    ll cnt = 0;
    rep(i, H) {
        rep(j, W) {
            ll A;
            cin >> A;
            if (A != -1) {
                cnt += d[A][1];
            }
        }
    }
    print(cnt);
    return 0;
}

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

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

    vector<tuple<long long int,long long int>> drink(n);
    int a,b;
    for(int i=0; i<n; i++){
        cin >> a >> b;
        drink.at(i)=make_tuple(a,b);
        //cout << get<0>(drink.at(i)) << ' ' << get<1>(drink.at(i)) << endl;
    }
    sort(drink.begin(), drink.end());

    int i=0;
    long long int count=m;
    long long int price=0;
    while(1){
        if(get<1>(drink.at(i))<count){
            price+=get<0>(drink.at(i))*get<1>(drink.at(i));
            count-=get<1>(drink.at(i));
            i++;
        }
        else{
            price+=get<0>(drink.at(i))*count;
            break;
        }
    }
    cout << price << endl;
}

Measured memory_bytes: 4808
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define ld                 long double
#define ff                 first
#define ss                 second
#define P                 pair<int,int>
#define pb                 push_back
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
const int N = 3005;//change it when needed
string s, p;
int dp[N][N];
void go() {
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 1; i <= s.size(); i++) {
        for (int j = 1; j <= p.size(); j++) {
            if (s[i - 1] == p[j - 1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            }
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    string res = "";
    int i = s.size(), j = p.size();
    while (i > 0 and j > 0) {
        if (s[i-1]==p[j-1]) {
            res = s[i - 1] + res;
            i--; j--;
        }
        else if (dp[i - 1][j] > dp[i][j - 1]) {
            i--;
        }
        else {
            j--;
        }
    }
    cout << res << endl;

}
void solve() {
    cin >> s >> p;
    go();
}

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t; cin >> t; while (t--)
    solve();
    return 0;
}

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

int main(void){
	int i,j,d,n,m,store[100004],k,sum;

	while(cin>>d && d){
		cin>>n>>m;

		store[0] = 0;
		for(i=1;i<n;i++) cin>>store[i];
		store[i] = d;

		sort(store+1,store+n);

		for(i=sum=0;i<m;i++){
			cin>>k;
			for(j=0;store[j]<=k;j++);
			if(store[j]-k < k-store[j-1])
				sum += store[j]-k;
			else
				sum += k-store[j-1];
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1252