akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws IOException{
        int j = 1;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1);
        
        while(true){
            ArrayList<Integer> x = new ArrayList<>();
            ArrayList<Integer> y = new ArrayList<>();

            int n = Integer.parseInt(br.readLine());
            if(n == 0)
            {
                break;
            }
            for(int i = 0;i<n;i++)
            {
                String st = br.readLine();
                String[] num = st.split(" ",0);
                x.add(Integer.parseInt(num[0]));
                y.add(Integer.parseInt(num[1]));
            }
            int s = 0;
            for(int i = 0;i<n;i++)
            {
                if(i != n - 1)
                {
                    s += (x.get(i)*y.get(i+1) - x.get(i+1)*y.get(i));
                }else{
                    s += (x.get(i)*y.get(0) - x.get(0)*y.get(i));
                }
            }
            double S = Math.abs(s)/2.0;
            System.out.print(j+" ");
            System.out.printf("%.1f",S);
            System.out.println("");
            String musi = br.readLine();
            j++;
        }
    }
}

Measured memory_bytes: 26848
#include<stdio.h>

int d[45];

int fi(int n){
  if( n == 0 || n ==1 ) return d[n] = 1;
  if( d[n] != -1 ) return d[n];
  return d[n] = fi(n-1) + fi(n-2);
}

int main(){
  int i, n;

  for( i = 0 ; i < 45 ; i++ ) d[i] = -1;

  scanf("%d",&n);
  printf("%d\n",fi(n));

  return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <cmath>
#define lli long long int 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
lli n,k;
int result (lli *arr,lli *dp,lli i)
{
    lli t=1e10;
    if (dp[i]!=-1)
    {
        return dp[i];
    }
    if (dp[i]==-1)
    {
    for (int j=i+1;j<=i+k;j++)
    {
        if (j<n-1)
        {
            t=min(t,abs(arr[i]-arr[j])+result(arr,dp,j));
        }
        if (j==n-1)
        {t=min(t,abs(arr[i]-arr[j]));break;}
    }
    dp[i]=t;
    return dp[i];
    }
}
int main() 
{
    fio;
    cin>>n>>k;
    lli arr[n],dp[n];
    for (int i=0;i<n;i++)
    {cin>>arr[i];dp[i]=-1;}
    lli t=1e10;
    for (int i=1;i<=k;i++)
    {
        if (i<n-1)
        t=min(t,abs(arr[0]-arr[i])+result(arr,dp,i));
        if (i==n-1)
        {t=min(t,abs(arr[0]-arr[i]));break;}
    }
    cout<<t;
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define chmax(x,y) x=max(x,(y))

int N,M,Q;
vi a,b,c,d;
int ans;

void dfs(vi A){
	if(N+1 <= (int)A.size()){
		// for(auto x:A){cout<<x<<" ";}
		// puts("");
		int now = 0;
		rp(i, 0, Q){
			if(A[b[i]] - A[a[i]] == c[i]){
				now += d[i];
			}
		}
		chmax(ans, now);
		return;
	}
	A.push_back(A.back());
	while(A.back() <= M){
		dfs(A);
		A.back()++;
	}

}

int main(){
	cin>>N>>M>>Q;
	a = b = c = d = vi(Q);
	rp(i, 0, Q) cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(vi(1,1));
	cout<< ans <<endl;
}


Measured memory_bytes: 3556
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string N;
    cin>>N;
    if((N[0]=='7')||(N[1]=='7')||(N[2]=='7')){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 3628
(let ((x (read)))

  (format t "~A~%"
          (if (= x 1)
            1
            (apply #'max
                   (apply #'append
                          (loop for i from 2 to 32
                                collect (loop for j from 2 to 10
                                              when (<= (expt i j) x)
                                              collect (expt i j))))))))


Measured memory_bytes: 24428
a = int(input())
temp = int(1)
mod = int(1000000007)
temp2 = int(1)
temp3 = int(1)
ans = int(0)
if a >= 2:
    for i in range(a):
        temp = temp * 10
        temp = temp % mod
        temp2 = temp2 * 8
        temp2 = temp2 % mod
        temp3 = temp3 * 9
        temp3 = temp3 % mod
    ans = temp + temp2 - temp3*2
    ans = ans % mod
    print(ans)
else:
    print(0)

Measured memory_bytes: 9196
x = input()
p = ['+','-']
def cal(a,b,c,x):
    res = int(x[0])
    if a:res-=int(x[1])
    else:res+=int(x[1])
    if b:res-=int(x[2])
    else:res+=int(x[2])
    if c:res-=int(x[3])
    else:res+=int(x[3])
    if res == 7:
        return True
    else:return False
    
        
for i in range(2):
    for j in range(2):
        for k in range(2):
            if cal(i,j,k,x):
                print(x[0]+p[i]+x[1]+p[j]+x[2]+p[k]+x[3]+'=7')
                exit(0)

            

Measured memory_bytes: 38384
N,K = (int(x) for x in input().split())
max_e = 0.0
e = 0.0
cnt = 0
p = list(map(float,input().split()))
for i in range(N):
  n = p[i]
  p[i] = n*(n+1)/(2.0*n)
  
for i in range(N):
  cnt += 1
  e += p[i]
  if cnt == K:
    n = p[i-K+1]
    if max_e < e:
      max_e = e
    cnt = K-1
    e -= n

print(max_e)


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

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    bool can = false;
    for(int i=a; i<=b; i++) {
        if(i % k == 0) can = true;
    }
    if(can) cout<<"OK";
    else cout<<"NG";
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 +7;

int main() {
    

    
    ll n, k;
    cin >> n >> k;
    
    vector<ll> a(n);
    vector<vector<ll>> d(2, vector<ll>(n));
    
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (a[j] < a[i])
            {
                if (i < j)
                {
                    d[1][i]++;
                }
                if (i > j)
                {
                    d[0][i]++;
                }
            }
        }
    }
    
    ll ret = 0;
    for (int i = 0; i < n; ++i)
    {
        ret += ((((k * (k - 1)) / 2) % mod) * (d[1][i] + d[0][i])) % mod;
        ret %= mod;
        ret += (k * d[1][i]) % mod;
        ret %= mod;
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define mod 1000000007;
#define my_mod 2019;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b;
    cin >> a >> b;
    a <= 8 && b <= 8 ? cout << "Yay!" << endl : cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <numeric>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, const std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, const std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, const std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int A,B,T;
  cin >> A >> B >> T;
  int t = A;
  int ans = 0;
  while(t <= T) {
    t += A;
    ans += B;
  }
  cout << ans << endl;
  return 0;
}

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

void trace(int a[], int n) {
    for (int i = 0; i < n; ++i) {
        if (i) cout << ' ';
        cout << a[i];
    }
    cout << endl;
}

int selectionSort(int a[], int n) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int minj = i;
        bool flag = false;
        for (int j = i; j < n; ++j) {
            if (a[j] < a[minj]) {
                minj = j;
                flag = true;
            }
        }
        if (flag) {
            swap(a[i], a[minj]);
            cnt++;
        }
    }
    return cnt;
}

int main() {
    int a[100], n; cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int c = selectionSort(a, n);
    trace(a, n);
    cout << c << endl;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int n,q,xl,xr,res;
int a[1000010],cnt[1000010],ans[1000010];
struct Node{
	int l,r,num;
}f[1000010];
inline bool cmp(Node a,Node b){
	if(a.l/1000==b.l/1000)
		return a.r<b.r;
	return a.l<b.l;
}
inline void Add(int x){
	if(cnt[x]==0)
		res++;
	cnt[x]++;
}
inline void Delete(int x){
	if(cnt[x]==1)
		res--;
	cnt[x]--;
}
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=q;i++){
		scanf("%d%d",&f[i].l,&f[i].r);
		f[i].num=i;
	}
	sort(f+1,f+q+1,cmp);
	xl=1,xr=1,res=1;
	cnt[a[1]]=1;
	for(int i=1;i<=q;i++){
		while(xl<f[i].l){
			Delete(a[xl]);
			xl++;
		}
		while(xl>f[i].l){
			xl--;
			Add(a[xl]);
		}
		while(xr<f[i].r){
			xr++;
			Add(a[xr]);
		}
		while(xr>f[i].r){
			Delete(a[xr]);
			xr--;
		}
		ans[f[i].num]=res;
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 15456
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = Read().ToDouble();
            WriteRead(2 * r * Math.PI);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToInt64(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 18568
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()
	if s == "ABC" {
		fmt.Fprintln(wr, "ARC")
	} else {
		fmt.Fprintln(wr, "ABC")
		
	}
}


Measured memory_bytes: 1756
#include<cstdio>
#include<cctype>
const int maxn=1000010;
int n;
int a[maxn],b[maxn];
int dg[maxn];
struct Edge {
	int to,id,fl;
	Edge *ne;
}el[maxn],*la[maxn],*st[maxn],*cl=el;
int cc;
bool vv[maxn];
int ww[maxn],xx[maxn];
int In() {
	register char c;
	for(;c=getchar(),c!='-'&&!isdigit(c););
	register bool f=c=='-';
	register int s=f?0:c-'0';
	for(;c=getchar(),isdigit(c);)s=s*10+c-'0';
	return f?-s:s;
}
void ins(register int u,register int v,register int id) {
	++cc;
	*++cl=(Edge){v,id,cc,la[u]},la[u]=cl,++dg[v];
	*++cl=(Edge){u,-id,cc,la[v]},la[v]=cl,++dg[u];
}
void dfs(int x) {
	for(Edge *i=la[x];i;i=la[x]) {
		if(!vv[i->fl]) {
			if(i->id) i->id>0?ww[i->id]=1:ww[-i->id]=-1;
			vv[i->fl]=1,la[x]=la[x]->ne,dfs(i->to);
		}
		else la[x]=la[x]->ne;
	}
}
int main() {
	n=In();
	for(register int i=1;i<=n;++i)a[i]=In(),~a[i]?ins(i,a[i],i):ins(i,0,i);
	for(register int i=1;i<=n;++i)b[i]=In(),~b[i]?ins(i+n,b[i]+n,0):ins(i+n,0,0);
	for(register int i=1;i<=n;++i) {
		if((dg[i]&1)^(dg[i+n]&1)) return puts("IMPOSSIBLE"),0;
		register int z=dg[i]<dg[i+n]?dg[i]:dg[i+n];
		for(register int j=1;j<=z;++j)ins(i,i+n,0);
	}
	for(register int i=1;i<=n;++i)st[i]=la[i];
	dfs(0);
	for(register int i=1;i<=n;++i) {
		xx[i]=-ww[i];
		for(register Edge *j=st[i];j;j=j->ne)if(j->to&&j->to<=n&&j->to!=a[i]) xx[i]+=ww[j->to];
	}
	puts("POSSIBLE");
	for(register int i=1;i<=n;++i)printf("%d%c",xx[i]," \n"[i==n]);
	return 0;
}

Measured memory_bytes: 43264
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
string s;
int dp[100005][2];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  dp[0][0] = 1;
  REP(i, s.length()) {
    if(s[i] == '0') {
      dp[i + 1][1] = dp[i][1];
      dp[i + 1][0] = dp[i][0];
    } else {
      dp[i + 1][1] = (dp[i][0] + dp[i][1]) % mod;
    }

    if(s[i] == '0') {
      dp[i + 1][1] = (dp[i + 1][1] + dp[i][1] * 2 % mod) % mod;
    } else {
      dp[i + 1][0] = (dp[i + 1][0] + dp[i][0] * 2 % mod) % mod;
      dp[i + 1][1] = (dp[i + 1][1] + dp[i][1] * 2 % mod) % mod;
    }
  }
  cout << (dp[s.length()][0] + dp[s.length()][1]) % mod << endl;
}


Measured memory_bytes: 4548
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  long double a,b,h,m,s;
  
  cin >> a >> b >>h >>m;
  s=sqrt(a*a+b*b-2*a*b*cos(3.14159265358979*(h+m/60)/6.0-3.14159265358979*m/30.0));
  cout << fixed << setprecision(15);
  cout << s << endl;
}

Measured memory_bytes: 4172
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

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


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;

  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    string s = to_string(N);
    long long sum = 0;
    REP(i, s.size())
        sum += s[i] - '0';
    if (N % sum) cout << NO << '\n';
    else cout << YES << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
# 今のままだと駄目
"""
ある境目を考える。境目より左が全て白、境目より右が全て黒でなくてはいけない。
ゆえに、境目より左の黒の数と境目より右の白の数を数えれば、その境目における「変更が必要な石の数」がわかる。
よって、境目を端から端まで動かしてその中で最小の「変更が必要な石の数」を求めればよい。
"""
N = int(input())
str = input()
minDistance = 0

black = "#"
white = "."
leftblack = 0
rightwhite = 0

for i in range(N):
    if str[i] == white:
        rightwhite += 1

minDistance += rightwhite

for j in range(0, N):
    if str[j] == black:
        leftblack += 1
    else:
        rightwhite -= 1
    if leftblack + rightwhite < minDistance:
        minDistance = leftblack+rightwhite

print("{}".format(minDistance))


Measured memory_bytes: 3496
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

int main(){
    ll N; cin >> N;
    map<string, ll> mp;
    ll mx = 0;
    rep(i,N){
        string s; cin >> s;
        mp[s]++;
        mx = max(mp[s],mx);
    }
    
    for(auto p : mp){
        if(p.second == mx) print(p.first);
    }
    
    return 0;
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < 1000; i++){
        int p, q, r;
        p = i % 10;
        r = i / 100;
        q = (i % 100) / 10;
        bool a, b;
        int id1, id2;
        id1 = -1;
        a = false;
        b = false;
        for(int j = 0; j < n; j++){
            if(!a && s.at(j) - '0' == r && id1 == -1){
                a = true;
                id1 = j;
                continue;
            }
            if(!b && a && s.at(j) - '0' == q && id1 != j){
                b = true;
                id2 = j;
                continue;
            }
            if(b && s.at(j) - '0' == p && id2 != j){
                ans ++;
                //cout << i << endl;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < t.size(); ++i) {
		cout << s[i] << t[i];
	}
	if (s.size() > t.size()) {
		cout << s[s.size() - 1];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: i64, m: usize, a: [i64; m]);
    let r = n - a.iter().sum::<i64>();
    let r = if r < 0 { -1 } else { r };
    println!("{}", r);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2200
<?php
list($sx, $sy, $gx, $gy) = explode(" ", trim(fgets(STDIN)));
$dx = $gx - $sx;
$dy = $gy - $sy;

echo str_repeat("U", $dy);
echo str_repeat("R", $dx);
echo str_repeat("D", $dy);
echo str_repeat("L", $dx);

echo str_repeat("L", 1);
echo str_repeat("U", $dy+1);
echo str_repeat("R", $dx+1);
echo "DR";
echo str_repeat("D", $dy+1);
echo str_repeat("L", $dx+1);
echo str_repeat("U", 1);



Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define forn(i,n) for(int i=0;i<(int) n;i++)
#define Forn(i,n) for(int i=1;i<=(int) n;i++)

int main()
{
   int a,ans;
   cin>>a;
   ans=a+(a*a)+(a*a*a);
   cout<<ans;





}






Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	int e, f, g, h; cin >> e >> f >> g >> h;
	int hi = a*e + (a / 10)*g + b*f + (b / 20)*h;
	int k = c*e + (c / 10)*g + d*f + (d / 20)*h;
	if (hi > k)cout << "hiroshi\n";
	else if (hi < k)cout << "kenjiro\n";
	else cout << "even\n";
}

Measured memory_bytes: 3068
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, _t: i64,
        a: [i64; n]
    }

    let mut profit = vec![0; n];
    let mut least = 1i64<<50;
    let mut earn = 0;
    for i in 0..n {
        if a[i] < least {
            least = a[i];
        } else {
            profit[i] = a[i] - least;
            earn = max(earn, profit[i]);
        }
    }
    let ans = profit.into_iter().filter(|v| *v == earn).count();
    println!("{}", ans);
}


Measured memory_bytes: 4524
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using llong = long long;
const int MOD=1000000007;

int main(int argc, char**argv){
    int a, b, t;
    cin >> a >> b >> t;
    cout << b * (t/a) << endl;
    return 0;
}


Measured memory_bytes: 768
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def f(num):
    front = num
    back = num
    while front >= 10:
        front //= 10
    while back >= 10:
        back %= 10
    
    return front, back

def Main():
    n = read_int()
    cnt = [[0] * 10 for _ in range(10)]
    for x in range(1, n + 1):
        front, back = f(x)
        cnt[front][back] += 1
    
    ans = 0
    for x in range(10):
        for y in range(10):
            ans += cnt[x][y] * cnt[y][x]
    print(ans)

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//constexpr long long MOD = 1e9 + 7;
//constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

const ll MAX = 500000000;
const ll MOD = 1000000007;

template<typename T>
T gcd(T a, T b) {
    T c = 1;
    while (c != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}


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

    //int h, w, k, a, b, c;

    ll n, k;
    cin >> n >> k;

    ll ans;
    if (n > k) {
        ans = n % k;
        if (ans > k / 2) {
            ans = k - ans;
        }
    }
    else if (n == k) {
        ans = 0;
    }
    else {
        ll c = abs(n - k);
        ans = min(c, n);
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  int N;
  long long ans=0;
  cin>>N;
  map<string,ll> s;
  for(int i=0;i<N;i++) {string ss;
                        cin>>ss;
                        sort(ss.begin(),ss.end());
                        ans+=s[ss]++;
                       }
  cout<<ans<<endl;
}

Measured memory_bytes: 11136
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
cnt_plus=0
cnt_zero=0
cnt_minus=0
arr_plus=[]
arr_minus=[]
for i in range(n):
  if arr[i]>0:
    cnt_plus+=1
    arr_plus.append(arr[i])
  elif arr[i]<0:
    cnt_minus+=1
    arr_minus.append(-arr[i])
  else:
    cnt_zero+=1
if cnt_plus+cnt_minus<k:
  print(0)
  exit()
if k==n:
  if cnt_zero!=0:
    print(0)
  else:
    ans=1
    for i in range(cnt_plus):
      ans*=arr_plus[i]
      ans%=mod
    for i in range(cnt_minus):
      ans*=arr_minus[i]
      ans%=mod
    if cnt_minus%2==0:
      print(ans)
    else:
      print((-ans)%mod)
  exit()
if cnt_plus==0 and k%2==1:
  if cnt_zero!=0:
    print(0)
  else:
    arr_minus=sorted(arr_minus)
    tmp=1
    for i in range(k):
      tmp*=arr_minus[i]
      tmp%=mod
    print((-tmp)%mod)
  exit()
else:
  arr_plus=sorted(arr_plus,reverse=True)
  arr_minus=sorted(arr_minus,reverse=True)
  if k%2==0:
    ans=1
    pos_plus=0
    pos_minus=0
    cnt=0
    while cnt<k:
      cand1=0
      if pos_plus<=cnt_plus-2:
        cand1=arr_plus[pos_plus]*arr_plus[pos_plus+1]      
      cand2=0
      if pos_minus<=cnt_minus-2:
        cand2=arr_minus[pos_minus]*arr_minus[pos_minus+1]
      if cand1>=cand2:
        pos_plus+=2
        ans*=cand1
        ans%=mod
      else:
        pos_minus+=2
        ans*=cand2
        ans%=mod
      cnt+=2
    print(ans)
  else:
    ans=arr_plus[0]
    pos_plus=1
    pos_minus=0
    cnt=1
    while cnt<k:
      cand1=0
      if pos_plus<=cnt_plus-2:
        cand1=arr_plus[pos_plus]*arr_plus[pos_plus+1]      
      cand2=0
      if pos_minus<=cnt_minus-2:
        cand2=arr_minus[pos_minus]*arr_minus[pos_minus+1]
      if cand1>=cand2:
        pos_plus+=2
        ans*=cand1
        ans%=mod
      else:
        pos_minus+=2
        ans*=cand2
        ans%=mod
      cnt+=2
    print(ans)
  exit()

Measured memory_bytes: 31696
from math import sqrt, factorial
from itertools import permutations

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
distance = {}
for i in range(N):
    for j in range(N):
        if i!=j:
            distance[str(i)+str(j)] = sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)
ans = 0

for S in list(permutations([i for i in range(N)], N)):
    for i in range(N-1):
        key = str(S[i]) + str(S[i+1])
        ans += distance[key]
print(ans/factorial(N))

Measured memory_bytes: 7996
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a % 2 == 0 || b % 2 ==0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };


int main()
{
	int H, W;
	cin >> H >> W;
	H+=2; W+=2;
	for(int i = 0; i < H; i++)
	{
		for(int j = 0; j < W; j++)
		{
			if(i == 0 || i == H - 1 || j == 0 || j == W - 1)
			{
				cout << '#';
			}
			else
			{
				char s;
				cin >> s;
				cout << s;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vector<int> > 
#define vl vector<long long>
#define vc vector<char> 
#define vvc vector<vector<char> > 
#define vpi vector<pair<int,int> >
#define ll long long 
#define sz(a) int(a.size())
#define forn(i,n) for(int i = 0 ; i < int(n) ; i++)
#define all(x) x.begin(),x.end()
#define vpl vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define len(s) s.length()
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
#define modulo 998244353ll
#define mod 1000000007ll
#define MAXN  1000001 
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll gcd(ll a,ll b){if(a==0 || b == 0) return max(a,b);if(a == 1 || b == 1)return 1;return gcd(max(a,b)%min(a,b),min(a,b));}


void solve()
{
    int n;
    cin>>n;
    vi a(n,0);
    vi b(n,0);
    forn(i,n)
    cin>>a[i];
    forn(i,n)
    cin>>b[i];
    reverse(b.begin(),b.end());
    int i = n;
    int j = -1;
    // i and j are the indices which are th endpoints
    // of the equal segment
    for(int k = 0 ; k < n ; k++)
    {
        if(a[k] == b[k])
        {
            i = k;
            break;
        }
    }    
    for(int k = n-1 ; k >= 0 ; k--)
    {
        if(a[k] == b[k])
        {
            j = k;
            break;    
        }
    }
    if(i == -1 && j == n)
    {
        cout<<"YES"<<endl;
        for(auto u : b)
        {
            cout<<u<<" ";
        }
        cout<<endl;
        return;
    }
    int c = a[i];
    // curr is the index which needs to be swapped
    int curr = i;
    // looking for b[k] values where k < i ans
    // (a[k] != c && b[k] != c) is satisfied
    for(int k = 0 ; k < i && curr <= j ; k++)
    {
        if(a[k] != c && b[k] != c)
        {
            swap(b[k],b[curr]);
            curr++;
            continue;
        }
        if(a[k] == c || b[k] == c)
        break;
    }
    // looking for b[k] values where k > j ans
    // (a[k] != c && b[k] != c) is satisfied
    for(int k = n-1 ; k > j && curr <= j ; k--)
    {
        if(a[k] != c && b[k] != c)
        {
            swap(b[k],b[curr]);
            curr++;
            continue;
        }
        if(a[k] == c || b[k] == c)
        break;
    }
    // checking if there still exist a index where a[k] == b[k]
    for(int k = 0 ; k < n ; k++)
    {
        if(a[k] == b[k])
        {
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
    for(auto u : b)
    cout<<u<<" ";
    cout<<endl;
}


int main()
{
    fast();
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4764
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	long H;
	long result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		H = Long.parseLong(in.readLine());
	}

	Deque<Long> sub(long val) {
		if (val == 1) {
			Deque<Long> deque = new ArrayDeque<>();
			deque.addFirst(val);
			return deque;
		} else {
			long next = val / 2;
			Deque<Long> deque = sub(next);
			deque.addFirst(val);
			return deque;
		}
	}

	void calc() {
		Deque<Long> deque = sub(H);
		long addVal = 1;
		while (!deque.isEmpty()) {
			Long val = deque.pollFirst();
			result += addVal;
			addVal *= 2;
		}

	}

	void showResult() {
		System.out.println(result);
	}
}


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

using namespace std;

int main(void)
{
	bool check[8]={false,};
	int n,t;
	int Min=0,Max=0;

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

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		int a = t/400;
		if(a>=8)
		{
			Max++;
		}
		else
		{
			if(check[a]==false)
			{
				check[a]=true;
				Min++;
				Max++;
			}
		}
	}

	if(Min==0)
	{
		cout << 1 << ' ' << Max << '\n';
	}
	else
	{
		cout << Min << ' ' << Max << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans,x,n,c,y;
	cin>>n;
	ans=n;
	for(int i=0;i<=n;i++)
	{
		c=0;
		x=i;
		while(x)
		{
			c+=x%9;
			x=x/9;
		}
		y=n-i;
		while(y)
		{
			c+=y%6;
			y=y/6;
		}
		ans=min(ans,c);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

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

    int height[100005];
    for (int i = 0; i < n; i++) {
        scanf("%d", &height[i]);
    }

    int dp[100005];
    dp[0] = 0;
    dp[1] = abs(height[1] - height[0]);

    for (int i = 2; i < n; i++) {
        dp[i] = min(abs(height[i] - height[i - 2]) + dp[i - 2],abs(height[i] - height[i - 1]) + dp[i - 1]);
    }
    printf("%d\n", dp[n-1]);
    return EXIT_SUCCESS;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, K;
    double ans = 0.0;
    cin >> N >> K;
    REP(int,i,1,N+1){
        double score = (double)i;
        double CoinCount = 0;
        while( score < K ){
            score *= 2.0;
            CoinCount += 1.0;
        }
        double A = pow(0.5,(double)CoinCount);
        ans += A / N;
    }
    printf("%.12f\n", ans);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    
    vector<int> P(N);
    vector<int> Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    
    vector<int> array(N);
    rep(i, N) array[i] = i+1;
    
    int countP=0;
    int countQ=0;
    int ansP=0;
    int ansQ=0;
  
    do{
        countP++;
        for(int i=0; i<N; i++){
          if((int)array[i] != P[i]) break;
          if(i==N-1){
            ansP = countP;
            break;
          }
            //cout<<array[i];
            //if(i!=N-1)cout<<" ";
        }
        //cout<<endl;
    }while(next_permutation(array.begin(),array.end()));
  
    do{
        countQ++;
        for(int i=0; i<N; i++){
          if((int)array[i] != Q[i]) break;
          if(i==N-1){
            ansQ = countQ;
            break;
          }
            //cout<<array[i];
            //if(i!=N-1)cout<<" ";
        }
        //cout<<endl;
    }while(next_permutation(array.begin(),array.end()));
    
    //cout << ansP << " " << ansQ << endl;
    
    if(ansQ >= ansP) cout << ansQ-ansP << endl;
    else cout << ansP-ansQ << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define db double
#define pb push_back
#define mpr make_pair
#define andl "\n"
#define f first
#define s second
#define mset(x,y) memset(x,y,sizeof(x))
#define fr(i,n) for(long long int i=0;i<n;i++)
#define trace(it,x) for(auto it = (x).begin(); it != (x).end(); it++)
#define mod 1000000007
#define fastio ios::sync_with_stdio (false); cin.tie (0); cout.tie (0);
#define runtime cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
using namespace std;
 
// convert number to string to_string(x);
// convert string to number stoi();
 
// ll mulmod(ll x,ll y)
// {
//     return ((x%mod)*(y%mod))%mod;
// }
 
// ll binpow(ll x, ll y)
// {
//     ll z = 1;
//     while(y > 0)
//     {
//         if(y % 2 == 1)
//             z = mulmod(z, x);
//         x = mulmod(x, x);
//         y /= 2;
//     }
//     return z;
// }
 
// ll ncr(ll n,ll r)
// {
//     return mulmod(fact[n],binpow(mulmod(fact[n-r],fact[r]),mod-2));
// }
 
// ll pwr(ll n,ll m)
// {
//   if(n==1 || m==0)
//     return 1;
 
//   ll x=pwr(n,m/2);
//   if(m%2==0)
//     return x*x;
//   else
//     return n*x*x;
// }
 
// ll pwr(ll n,ll m,ll b)
// {
//   if(n==1 || m==0)
//     return 1;
 
//   ll x=pwr(n,m/2,b);
//   if(m%2==0)
//     return ((x%b)*(x%b))%b;
//   else
//     return ((n%b)*(((x%b)*(x%b))%b))%b;
// }
 
void solve()
{
  return ;
}
 
int main()
{
  fastio
  
  ll t;
  cin >> t;
  cout << !t;
 
  runtime
}

Measured memory_bytes: 3760
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    int plusCount=0,minusCount=0;
    rep(i,N){
        if(A[i]-B[i]>0) plusCount+=abs(A[i]-B[i]);
        if(A[i]-B[i]<0) minusCount+=abs(A[i]-B[i])/2LL;
    }
    if(minusCount>=plusCount) cout << "Yes" << nn;
    else cout << "No" << nn;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define abs(a) ((a)>(0)?(a):-(a))
int n,A,B,C;
int min(int a,int b,int c,int d){
  int min=a;
  if(b<min)min=b;
  if(c<min)min=c;
  if(d<min)min=d;
  return min;
}
int dfs(int a,int b,int c,int d,int *l){
  if(d==n&&(a*b*c>0)) return abs(a-A)+abs(b-B)+abs(c-C)-30;
  else if(d==n)return 1e9;
  else{
     int r1=dfs(a,b,c,d+1,l);
     int r2=dfs(a+l[d],b,c,d+1,l)+10;
     int r3=dfs(a,b+l[d],c,d+1,l)+10;
     int r4=dfs(a,b,c+l[d],d+1,l)+10;
    return min(r1,r2,r3,r4);
  }
}
int main(){
  int i;
  scanf("%d%d%d%d",&n,&A,&B,&C);
  int l[n];
  for(i=0;i<n;i++)scanf("%d",&l[i]);
  printf("%d",dfs(0,0,0,0,l));
}

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

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			double m = 100000;
			foreach(var i in Enumerable.Range(1, int.Parse(Console.ReadLine())))
			{
				m *= 1.05;
				m = (double)Math.Ceiling((decimal)m / 1000) * 1000;
			}
			Console.WriteLine(m);
		}
	}
}

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

vector<int> Sort(vector<int> A, int i){
	int j = i - 1;
	while(j >= 0 && A[j] > A[j+1]){
		int v = A[j+1];
		A[j+1] = A[j];
		A[j] = v;
		j--;
	}
	return A;
}

int main(){
	int N;
	cin >> N;
	vector<int> A;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		A.push_back(a);
	}
	for(int i = 0; i < N; i++){
		A = Sort(A, i);
		for(int j = 0; j < N-1; j++) cout << A[j] << ' ';
		cout << A[N-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
program ABC153E
    implicit none
    integer(8)::H,N,div,i,j
    integer(8),allocatable,dimension(:)::A,B
    integer(8),allocatable,dimension(:,:)::dp

    read(5,*)H,N
    allocate(A(N))
    allocate(B(N))
    allocate(dp(H,N))

    do i=1,N
        read(5,*)A(i),B(i)
    end do

    do i=1,N
        do j=1,H
            if(i==1)then
                div=j/A(i)
                if(mod(j,A(i))/=0)then
                    div=div+1
                end if
                dp(j,i)=B(i)*div
            else
                if(j<=A(i))then
                    dp(j,i)=min(dp(j,i-1),B(i))
                else
                    dp(j,i)=min(dp(j,i-1),dp(j-A(i),i)+B(i))
                end if
            end if
        end do
    end do
    print'(i0)',dp(H,N)
end program ABC153E

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=22;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,to[1<<(N+5)][2],id[22][1<<20],tt;
pii ans;
vi f[1<<N],new_f[1<<N];
char s[1<<N];

bool cmp(int x,int y,int len) {
	for(int i=0;i<len;i++) {
		int a=(x>>i&1),b=(y>>i&1);
		if(a!=b) return a<b;
	}
	return 0;
}

int main() {
	cin>>n>>m;
	//n=m=20;
	for(int i=0;i<=n;i++)
		for(int j=0;j<(1<<i);j++) id[i][j]=tt++;
	f[0].resize((1<<(n+1))-1);
	for(int i=0;i<=n;i++) {
		scanf("%s",s);
		//for(int j=0;j<(1<<i);j++) s[j]='1';
		for(int j=0;j<(1<<i);j++)
			if(s[j]=='1') {
				int rev=0;
				for(int k=0;k<i;k++) rev|=(j>>k&1)<<(i-k-1);
				++f[0][id[i][rev]];
			}
	}
	for(int i=0;i<=n;i++)
		for(int j=0;j<(1<<i);j++) {
			int s=id[i][j];
			for(int k=0;k<2;k++) {
				int p=0;while(p<i&&(j>>p&1)!=k) ++p;
				if(p==i) to[s][k]=-1;
				else to[s][k]=id[i-p-1][j>>(p+1)];
			}
		}
	//exit(0);
	for(int i=0;i<=n;i++) {
		//s的长度为i->i+1
		//cerr<<i<<'\n';
		for(int j=0;j<(1<<N);j++) {
			vi emp;
			new_f[j].swap(emp);
		}
		for(int j=0;j<(1<<(i+1));j++) new_f[j].resize((1<<(n-i))-1);
		//cerr<<i<<'\n';
		for(int j=0;j<(1<<i);j++) {
			int sum=0;
			for(int k=0;k<sz(f[j]);k++) {
				sum+=f[j][k];
			}
			if(sum>=m) {
				if(ans.fi!=i||!cmp(ans.se,j,i)) ans=mp(i,j);
			}
			if(i<n) {
				for(int k=0;k<sz(f[j]);k++) {
					if(!f[j][k]) continue;
					for(int l=0;l<2;l++)
						if(~to[k][l]) {
							new_f[j|(l<<i)][to[k][l]]+=f[j][k];
						}
				}
			}
		}
		swap(f,new_f);
	}
	for(int i=0;i<ans.fi;i++) cout<<(ans.se>>i&1);
	return 0;
}


Measured memory_bytes: 314740