akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

const int N = 3e5 + 233;
lo b[N], c[N], sumb[N], f[N];
int n, m, pre[N], id[N], vis[N];
vector <int> G[N], F[N];

inline bool cmp_c(int x, int y) {
	return c[x] < c[y];
}

inline int find(int x) {
	return pre[x] == x ? x : pre[x] = find(pre[x]);
}

inline void make(int x, int y) {
	x = find(x); y = find(y);
	if (x == y) return ;
	pre[y] = x; F[x].push_back(y);
	// cerr << x << " -> " << y << "\n";
}

inline void dfs(int u) {
	sumb[u] = b[u];
	for (int v : F[u]) {
		dfs(v);
		sumb[u] += sumb[v];
	}
	f[u] = c[u] + sumb[u];
	for (int v : F[u]) {
		lo vtotal = sumb[u] - sumb[v];
		assert(vtotal >= 0);
		f[u] = min(f[u], max(c[u], f[v]) + vtotal);
	}
	// cout << u << " " << f[u] << " " << c[u] << " " << b[u] << "\n";
}

int main(void) {
	read(n); read(m);
	rep (i, n) read(c[i]), read(b[i]), c[i] = max(0ll, c[i] - b[i]);
	rep (i, m) {
		int x, y; read(x); read(y);
		G[x].push_back(y); G[y].push_back(x);
	}
	rep (i, n) id[i] = i, pre[i] = i;
	sort(id + 1, id + n + 1, cmp_c);
	rep (i, n) {
		int u = id[i];
		vis[u] = true;
		for (int v : G[u])
			if (vis[v]) make(u, v);
	}
	dfs(find(1));
	cout << f[find(1)] << "\n";
}


Measured memory_bytes: 35452
#include <iostream>
#include<stdio.h>
#include <bits/stdc++.h>

using namespace std;

string S,T;
void input(){
    cin >> S >>T;
}

void solve(){
    T.pop_back();
    if(S==T) cout <<"Yes"<<endl;
    else cout << "No"<<endl;
}

int main(){
    input();
    solve();
    return 0;
}

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

int main() {
  int a, b, c, x, y;
  int price, pmin = INT_MAX;
  cin >> a >> b >> c >> x >> y;
  pmin = min(x, y);
  if (c * 2 < a + b) {
    price = (c * 2) * pmin;
  } else {
    price = a * pmin + b * pmin;
  }
  x -= pmin;
  y -= pmin;
  if (x != 0) {
    if (a * x < (c * 2) * x) {
      price += a * x;
    } else {
      price += (c * 2) * x;
    }
  } else {
    if (b * y < (c * 2) * y) {
      price += b * y;
    } else {
      price += (c * 2) * y;
    }
  }
  cout << price << endl;
}

Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = nextInt(scanner);
        int k = nextInt(scanner);
        int[] p = new int[n];
        long[] c = new long[n];
        for (int i = 0; i < n; i++) {
            p[i] = nextInt(scanner) - 1;
        }
        for (int i = 0; i < n; i++) {
            c[i] = nextInt(scanner);
        }

        long max = Long.MIN_VALUE;
        ArrayList<Long> scores = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            scores.clear();
            long candidateMax = 0;
            int position = p[i];
            scores.add(c[position]);

            while (position != i) {
                position = p[position];
                scores.add(scores.get(scores.size() - 1) + c[position]);
            }

            if (k <= scores.size()) {
                candidateMax = scores.subList(0, k).stream().mapToLong(x -> x).max().orElseThrow(NoSuchElementException::new);
            } else if (scores.get(scores.size() - 1) <= 0) {
                candidateMax = scores.stream().mapToLong(x -> x).max().orElseThrow(NoSuchElementException::new);
            } else {
                candidateMax = scores.get(scores.size() - 1) * (k / scores.size() - 1);
                candidateMax += scores.stream().mapToLong(x -> x).max().orElseThrow(NoSuchElementException::new);
                long candidateMax2 = scores.get(scores.size() - 1) * (k / scores.size());
                int mod = k % scores.size();
                if (mod != 0) {
                    candidateMax2 += Math.max(0, scores.subList(0, mod).stream().mapToLong(x -> x).max().orElseThrow(NoSuchElementException::new));
                }
                candidateMax = Math.max(candidateMax, candidateMax2);
            }
            max = Math.max(max, candidateMax);
        }
        System.out.println(max);
    }


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

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

    private static float nextFloat(Scanner scanner) {
        return Float.parseFloat(scanner.next());
    }

    private static double nextDouble(Scanner scanner) {
        return Double.parseDouble(scanner.next());
    }


}









Measured memory_bytes: 59968
program ccc

implicit none
integer :: n, i
real(8) :: res
real(8),allocatable, dimension(:) :: v

read*, n
allocate(v(n))
read*, v

call heapsort(n,v)

v(1) = v(1)/((2.0D0)**(n-1))
res= v(1)

do i=2,n
v(i) = v(i)/((2.0D0)**(n-i+1))
res = res + v(i)
end do

write(*,'(f0.14)') res

end program


subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n
  double precision,intent(inout) :: array(1:n)
 
  integer ::i,k,j,l
  double precision :: t
 
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo

  return
end subroutine heapsort

Measured memory_bytes: 256
let input = '';

process.stdin.on('data', (chunk: any) => {
  input += chunk;
});

process.stdin.on('end', () => {
  const args = normalize(input);
  main(args[0], args[1]);
});

function main(n: number, ps: number[]) {
  const matchedList = ps.filter((p, i, self) => {
    if (i === 0 || i === n - 1) return false;
    const sorted = [self[i - 1], p, self[i + 1]].sort((a, b) => a - b);
    return sorted[1] === p;
  });
  console.log(matchedList.length);
}

function normalize(input: any): [number, number[]] {
  const inputs = input.toString().split('\n');
  const n = Number(inputs[0]);
  const ps = inputs[1].split(' ').map((p: string) => Number(p));
  return [n, ps];
}


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

using ll = long long;

int main() {
    int n;
    cin >> n;
    string ans = "No";
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int d, e;
        cin >> d >> e;
        if (d == e) ++cnt;
        else cnt = 0;
        if (cnt >= 3) ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m,v0;
int a,b,c;
vector<P> G[501];
ll dp[501][51][2];

struct data{
	int v,f;
	ll c,sp;
	data(){}
	data(int vv,ll ss,ll cc,int ff){
		v=vv;
		sp=ss;
		c=cc;
		f=ff;
	}
	bool operator<(const data &d)const{
		return c>d.c;
	}
};

ll dijkstra(){
	memset(dp,-1,sizeof(dp));
	priority_queue<data> que;
	que.push(data(1,v0,0,0));
	dp[1][v0][0]=0;
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.v][q.sp][q.f]<q.c)continue;
		if(q.v==n)q.f=1;
		if(q.v==1 && q.f==1)return q.c;
		for(int i=0;i<G[q.v].size();i++){
			int nv=(a*q.sp+b)%c;
			if(dp[G[q.v][i].first][nv][q.f]>q.c+q.sp*G[q.v][i].second){
				dp[G[q.v][i].first][nv][q.f]=q.c+q.sp*G[q.v][i].second;
				que.push(data(G[q.v][i].first,nv,dp[G[q.v][i].first][nv][q.f],q.f));
			}
			if(dp[G[q.v][i].first][nv][q.f]==-1){
				dp[G[q.v][i].first][nv][q.f]=q.c+q.sp*G[q.v][i].second;
				que.push(data(G[q.v][i].first,nv,dp[G[q.v][i].first][nv][q.f],q.f));
			}
		}
	}
	return -1;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int f,t;
		ll c;
		scanf("%d%d%lld",&f,&t,&c);
		G[f].push_back(P(t,c));
		G[t].push_back(P(f,c));
	}
	scanf("%d",&v0);
	scanf("%d%d%d",&a,&b,&c);
	printf("%lld\n",dijkstra());
	return 0;
}

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

int main() {
 int a,b,c,x;
 cin >> a >> b >> c >> x;
 int cnt = 0;
 rep(i,a+1)rep(j,b+1)rep(k,c+1)if(500*i+100*j+50*k == x) cnt++;

 cout << cnt << endl;
 } 

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


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

    int ans = 0;

    int tmp = 0;
    bool flag = false;
    for(auto c : s){
        if(c == 'R' && !flag){
            flag = true;
            tmp++;
        }
        else if(c == 'S'){
            ans = max(ans, tmp);
            flag = false;
            tmp = 0;
        }
        else if(c == 'R' && flag){
            tmp++;
        }
    }

    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1000000007;
 
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x,n,t,ans=INT_MAX,j=0;
 cin>>x>>n;
 vector<int> d(105,0);
 for(int i=0; i<n;i++){
    cin>>t;
    d[t]=1;
 }
 for(int i=0; i<=101; i++){
    if(d[i]==0){
        if(ans>abs(x-i)){ans=abs(x-i); j=i;}
    }
 }
 cout<<j;
    return 0;
}

Measured memory_bytes: 3600
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn readln<T>() -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().parse().unwrap()
}

use std::collections::BinaryHeap;
use std::cmp::Ordering;

#[derive(Clone, Copy, Eq, PartialEq)]
struct E {
    v: usize,
    d: usize,
}

impl Ord for E {
    fn cmp(&self, other: &Self) -> Ordering {
        other.d.cmp(&self.d)
    }
}

impl PartialOrd for E {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    let k = readln();

    let mut bs = vec![true; k];
    let mut q = BinaryHeap::new();
    q.push(E{
        v: 1,
        d: 1,
    });

    let mut res = 0;

    while let Some(e) = q.pop() {
        if e.v == 0 {
            res = e.d;
            break;
        }

        bs[e.v] = false;

        let j = (e.v * 10) % k;
        if bs[j] {
            q.push(E{
                v: j,
                d: e.d,
            });
        }
        let j = (e.v + 1) % k;
        if bs[j] {
            q.push(E {
                v: j,
                d: e.d + 1,
            });
        }
    }

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

Measured memory_bytes: 4476
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);

    	String N = sc.nextLine();

    	if(N.equals("A")){
    		System.out.println("T");
    	}else if(N.equals("T")){
    		System.out.println("A");
    	}else if (N.equals("C")){
    		System.out.println("G");
    	}else {
    		System.out.println("C");
    	}



}

}


Measured memory_bytes: 21972
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
    int x,a,b;
    while(~scanf("%d%d%d",&x,&a,&b)){
        int aa=abs(x-a);
        int bb=abs(x-b);
        if(aa<bb) printf("A\n");
        else printf("B\n");
    }
return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  int h,w;
  cin >> h >> w;
  if(h%3==0||w%3==0){ cout << 0 <<endl; return 0; }
  ll ans=min(h,w);
  rep(i,2){
  int w1 = w*2/3;
  int w2 = w*2/3+1;
  ll tmp[2][3];
  tmp[0][0] = h*(w-w1);
  tmp[0][1] = (h/2+h%2)*w1;
  tmp[0][2] = (h/2)*w1;
  tmp[1][0] = h*(w-w2);
  tmp[1][1] = (h/2+h%2)*w2;
  tmp[1][2] = (h/2)*w2;
  sort(tmp[0],tmp[0]+3);
  sort(tmp[1],tmp[1]+3);
  ans = min(ans,abs(tmp[0][0]-tmp[0][2]));
  ans = min(ans,abs(tmp[1][0]-tmp[1][2]));
  swap(h,w);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];
     int sum = 0;
     for(int i = 0; i < N; ++i){
       for (int j = i+1; j < N; ++j) {sum += d[i]*d[j];}
     }
 cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
    int a = 0,b = 0;
    scanf("%d %d",&a,&b);
    int num = b,n = 1;
    while(num / 10 != 0)
    {
        n = n + 1;
        num = num / 10;
    }
    double number = (double)(pow(10, n) * a + b);
    double s = sqrt(number);
    if((int)s * (int)s == (int)number)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


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

using ll = long long;

const int K = 30000000 - 1;
const ll M = ll(1e9) + 7;

int n, s[K + 1];
ll ans;

ll pw(ll n, ll k){
	if(k == 1) return n;
	return pw(n * n % M, k / 2) * (k % 2 ? n : 1) % M;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for(int i = 1, j = 0, k = 1, t = 0; i <= K; i++){
		for(; k <= i; ){ k *= 10; j++; }
		s[i] = s[i - 1] + j;
		for(; s[i] - s[t + 1] >= n; ) t++;
		if(t >= 9999999) break;
		if(s[i] - s[t] == n) ans++;
	}
	ll t = ll(9e7);
	for(int i = 8; i <= n / 100; i++, t = t * 10 % M){
		if(n % i) continue;
		ans = (ans + t - (n / i) + 1 + M) % M;
	}
	for(int i = 1; i <= 99; i++){
		if(n % i) continue;
		if(n / i < 8) continue;
		ans = (ans + 9 * pw(10, n / i - 1) - i + 1 + M) % M;
	}
	for(int i = 8; i <= n / 2; i++){
		int q = n / i, r = n % i;
		if(q > r){
			ans = (ans + (q - r - 1) / (i + 1) + 1) % M;
			if(!r) ans = (ans + M - 1) % M;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 88320
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
    #define int long long
    int n,k;
    cin>>n>>k;
    int t[n],d[n],used[n]={};
    priority_queue<pair<int,int>>q1;
    priority_queue<int,vector<int>,greater<int>>q2;
    for(int i=0;i<n;i++){
        cin>>t[i]>>d[i];
        q1.push({d[i],t[i]-1});
    }
    long long neta=0,value=0;
    for(int i=0;i<k;i++){
        P p=q1.top();
        q1.pop();
        value+=p.first;
        if(used[p.second])q2.push(p.first);
        else{
            neta++;
            used[p.second]=1;
        }
    }
    long long m=neta*neta+value;
    while(q1.size() && q2.size()){
        P p=q1.top();
        q1.pop();
        if(used[p.second]==0){
            neta++;
            used[p.second]=1;
            value+=p.first-q2.top();
            q2.pop();
            m=max(m,neta*neta+value);
        }
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 7868
package main
 
import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}
 
func nextString() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	N := nextInt()
	if N >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int a,b;cin>>a>>b;
  if(a <= 9 && b <= 9)print(a*b);
  else print(-1);
  return 0;
} 


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

max_iter = max(X, Y) * 2
ans = float("inf")
for i in range(max_iter):
    a = max(X - i, 0)
    b = max(Y - i, 0)
    price = 2*C * i + A * a + B * b
    ans = min(ans, price)

print(ans)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include"cstdio"
#include"map"
#include"set"
#include"cmath"
#include"queue"
#include"vector"
#include"string"
#include"ctime"
#include"stack"
#include"deque"
#include"cstdlib"
#include"cstring"
#include"iostream"
#include"algorithm"

#define db double
#define ll long long
#define vl vector<ll>
#define ci(x) scanf("%d",&x)
#define cd(x) scanf("%lf",&x)
#define cl(x) scanf("%lld",&x)
#define pi(x) printf("%d\n",x)
#define pd(x) printf("%f\n",x)
#define pl(x) printf("%lld\n",x)
#define rep(i, a, n) for (int i=a;i<n;i++)
#define per(i, a, n) for (int i=n-1;i>=a;i--)
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
const int N = 3e3 + 5;
const int mod = 1e9 + 5;
const int MOD = 992353;
const db PI = acos(-1.0);
const db eps = 1e-10;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3fffffffffffffff;
int n;
int a[N];
vector<int> e[N];
int dfs(int u,int pre){
    bool ok=0;
    for(int i=0;i<e[u].size();i++){
        int v=e[u][i];
        if(v==pre) continue;
        if(a[u]>a[v]&&!dfs(v,u)) ok=1;
    }
    return ok;
}
int main() {
    ci(n);
    for(int i=1;i<=n;i++) ci(a[i]);
    for(int i=1;i<=n;i++) e[i].clear();
    for(int i=1;i<n;i++){
        int x,y;
        ci(x),ci(y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    for(int i=1;i<=n;i++) if(dfs(i,0)) printf("%d ",i);
    puts("");
    return 0;
}






Measured memory_bytes: 384
n, k = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_f)

def check(k, len, arr)
	cnt = 0
	arr.each do |a|
		cnt += (a/len).ceil - 1
	end
	return cnt <= k
end

prev = -1
l = 0
r = arr.max.to_i + 1
min = 1145148101919
while l < r
	len = [(l + r) / 2, 1].max
	ok = check(k, len, arr)
	
	#puts "len:#{len} ok:#{ok} l:#{l} r:#{r}"
	if len == prev 
		break
	elsif ok 
		r = len 
		min = len if min > len
	else
		l = len
	end
	prev = len
end

puts min

Measured memory_bytes: 29908
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    int n, r;

    cin >> n >> r;

    if (n < 10) {

        cout << r + (10 - n) * 100 << endl;
    }
    else {
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
main = do
  (a:b:c:x:y:_) <- getLine >>= return . map read . words :: IO [Int]
  
  let m = min x y
  print $ m * (min (a+b) (2*c)) + (if x>y then (x-m) * (min a (2*c)) else (y-m) * (min b (2*c)))


Measured memory_bytes: 508
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    S, W = map(int, input().split())
    if W >= S:
        print("unsafe")
    else:
        print("safe")


def main():
    solve()


if __name__ == '__main__':
    main()


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

using ll = long long;
using namespace std;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);

#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}


void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<int> v(100, 0);
vector<int> x;

void init()
{
	int a = 0;
	cin >> N;
	rep(i, N) {
		int t;
		cin >> t;
		a ^= t;
		int n = 0;
		while ((t & 1) == 0) {
			n++;
			t >>= 1;
		}
		v[n] = 1;
	}
	while (a) {
		x.PB(a & 1);
		a >>= 1;
	}
}

void solve()
{
	int res = 0;
	rrep(i, x.size()) {
		if (x[i] == 0) continue;
		if (v[i] == 0) {
			cout << -1 << endl;
			return;
		}
		res++;
		rrep(j, i) {
			x[j] = 1 - x[j];
		}
	}
	cout << res << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl '\n'
int main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "rt", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    fast
    ll n,a,b;cin>>n>>a>>b;
    ll ans=0;
    if(a==0){
    	cout<<0;return 0;
    }
    ans=ans+(n/(a+b));
    ans*=a;
    //cout<<ans<<" "<<n%(a+b)<<endl;
   // ll x=(n%(a+b))%a;
    if((n%(a+b))>0 && (n%(a+b)<=a)) ans+=(n%(a+b));
    else if((n%(a+b)>a)) ans+=a;

    cout<<ans;
#ifndef ONLINE_JUDGE
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int n; cin >> n;
  vector<ll> a(n),b(n);
  rep(i,n) {
    cin >> a[i];
  }

  rep(i,n) {
    if (i == 0) b[i] = a[i];
    else b[i] = b[i-1] + a[i];
  }
  
  ll ansp = 0;
  ll count = 0;
  rep(i,n) {
    if (i % 2 == 0) {
      if (b[i] + count <= 0) {
        ansp += 1 - b[i] - count;
        count = 1 - b[i];
      }
    } else {
      if (b[i] + count >= 0) {
        ansp += b[i] + count + 1;
        count = -1 - b[i];
      }
    }
  }

  ll ansm = 0;
  count = 0;
  rep(i,n) {
    if (i % 2 == 1) {
      if (b[i] + count <= 0) {
        ansm += 1 - b[i] - count;
        count = 1 - b[i];
      }
    } else {
      if (b[i] + count >= 0) {
        ansm += b[i] + count + 1;
        count = -1 - b[i];
      }
    }
  }

  cout << min(ansp,ansm) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll a[110];
    cin >> N;
    rep(i,0,N) cin >> a[i];
    ll cnt = 1;
    ll ans = 0;
    rep(i,1,N){
        if(a[i] == a[i-1]){
            cnt++;
        }else{
            ans += cnt/2;
            cnt = 1;
        }
    }
    ans += cnt/2;
    print(ans);

    

}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
xyas = [list(map(int, input().split())) for _ in range(n)]
min_x = 0
max_x = w
min_y = 0
max_y = h
for xya in xyas:
    if xya[2] == 1:
        min_x = max(min_x, xya[0])
    elif xya[2] == 2:
        max_x = min(max_x, xya[0])
    elif xya[2] == 3:
        min_y = max(min_y, xya[1])
    else:
        max_y = min(max_y, xya[1])
if ((max_x - min_x) < 0) or ((max_y - min_y) < 0):
    print(0)
else:
    print((max_x - min_x) * (max_y - min_y))


Measured memory_bytes: 3064
info = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
for i in range(n):
    x = list(map(int, input().split()))
    b = x[0]
    f = x[1]
    r = x[2]
    v = x[3]
    info[b-1][f-1][r-1] = info[b-1][f-1][r-1] + v

a = 1
for i in info:
    for j in i:
        print(" ", end="")
        print(*j)
    if 4 > a:
        print("####################")
    a = a + 1


Measured memory_bytes: 5628
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int gcd(int u, int v) {
	int r;
	while (0 != v) {
		r = u % v;
		u = v;
		v = r;
	}
	return u;
}

int main()
{
	vector<int> xi;
	int n;
	int x;
	cin >> n >> x;

	int a;
	cin >> a;
	a = a - x;
	for (size_t i = 1; i < n; i++)
	{
		int b;
		cin >> b;
		a = gcd(a, b - x);
	}
	cout << abs(a) << endl;
	
	return 0;
}


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

int main(){
	int N;
	ll K;
	int Q;
	cin >> N >> K >> Q;
	int score[N+1];
	rep(i,N) score[i+1] = K-Q;
	rep(i,Q) {
		int tmp;
		cin >> tmp;
		score[tmp]++;
	}
	rep(i,N) {
		if (score[i+1]>0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
		return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<char>> grid(H);
  rep(i, H)
  {
    grid[i].resize(W);
    rep(j, W)
    {
      cin >> grid[i][j];
    }
  }

  int count = 0;
  for (int i = 0; i < (1 << H); i++)
  {
    for (int j = 0; j < (1 << W); j++)
    {

      int num = 0;
      rep(h, H)
      {
        rep(w, W)
        {
          if (((1 << h) & i) != 0)
          {
            // red
            // do nothing
          }
          else if (((1 << w) & j) != 0)
          {
            // red
            // do nothing
          }
          else if (grid[h][w] == '#')
          {
            num++;
          }
        }
      }
      if (num == K)
      {
        count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3628
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto s = read!string.array;
    auto t = read!string.array;

    s.sort();
    t.sort();
    t.reverse();
    writeln(s < t ? "Yes" : "No");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        char[] n_array = String.valueOf(n).toCharArray();
        int sum = 0;

        for (char c : n_array) {
            sum += Character.getNumericValue(c);
        }

        System.out.println(n % sum == 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    cout << c << endl;
  }else if(a==c){
    cout << b << endl;
  }else{
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

string re(char c, int n) {
	string ret;
	ret.assign(n, c);
	return ret;
}

int main() {
	int n; cin >> n;
	VI data(6);
	rep(i, n) {
		double h; cin >> h;

		int a;
		if (h < 165.0)a = 0;
		else if (h < 170.0)a = 1;
		else if (h < 175.0)a = 2;
		else if (h < 180.0)a = 3;
		else if (h < 185.0)a = 4;
		else a = 5;

		data[a]++;
	}

	rep(i, 6)cout << i + 1 << ":" << re('*', data[i]) << endl;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

const int MAX_N = 1e5 + 7;


void solve()
{
        string s; cin >> s;
        set<char> st;
        forn(i, len(s)) st.insert(s[i]);
        cout << ((st.size() == s.length()) ? "yes" : "no") ;
}

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


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

int main(void){
    int n;
    cin >> n;
    
    vector<int> h(n);
    rep(i, n){
        cin >> h.at(i);
    }

    int left = 0;
    string flag = "Yes";
    rep(i, n-1){
        if(left < h.at(i)){
            left = h.at(i);
        }
        if(left - h.at(i+1) > 1){
            flag = "No";
        }
    }
    cout << flag << endl;

    return 0;
}

Measured memory_bytes: 640
MOD = 10000000000000061
def hsh(s):
    tot = 0
    pw = 1
    for c in s:
        tot = (tot*256 + ord(c))%MOD
        pw = (pw*256)%MOD
    return tot, pw

def ok(L, S):
    h, pw = hsh(S[:L])
    D = {}
    D[h] = 0
    for i in range(len(S) - L):
        j = i + 1
        h = ((h*256 - pw*ord(S[i])) + ord(S[i+L]))%MOD
        if h in D:
            if D[h] + L <= j: return True
        else:
            D[h] = j
    return False


raw_input()
S = raw_input()
lo = 0
hi = len(S)//2

while lo < hi:
    mid = (lo + hi + 1)//2
    ans = ok(mid, S)
    if ans:
        lo = mid
    else:
        hi = mid - 1
print(lo)



Measured memory_bytes: 3264
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<map>
#include<cmath>
#include<set>
#define ll long long
#define inf 0x7fffffff;
#define maxn 600005
using namespace std;
int k,a,b,n,m;
int read()
{
    int l=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        else
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        l*=10;
        l+=ch-'0';
        ch=getchar();
    }
    return l*w;
} 
int main()
{
  	k=read(),a=read(),b=read();
  	n=(int)ceil(1.0*a/k);
  	m=(int)floor(1.0*b/k);
  	if(m>=n) cout<<"OK"<<endl;
  	else cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3644
#import sys
#input = sys.stdin.readline
#template input
import bisect

def IT():
    return int(input())
def IL():
    return [int(_) for _ in input().split()]
def SL():
    return [int(_) for _ in input().split()]
def ILS(n):
    return [int(input()) for _ in range(n)]
def SLS(n):
    return [input() for _ in range(n)]
def ILSS(n):
    return [[int(_) for _ in input().split()] for j in range(n)]


"""ここからメインコード"""
def main():
    n = IT()
    ans = ""
    for i in range(32):
      if n % (2 ** (i+1)) != 0:
        n -= n % (2 ** (i+1)) * (-1) ** (i % 2)
        ans += "1"
      else:
        ans += "0"
    print(int(ans[::-1]))
main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SC second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;}


int main()
{
  int a, b, c ;
  cin >> a >> b >> c ;
  int ans = 0 ;
  if(a%2==b%2 && b%2==c%2){
    ans = 0 ;
  }
  else{
    if(a%2==b%2){
      ans++ ;
      a++ ;
      b++ ;
    }
    else if(a%2==c%2){
      ans++ ;
      a++ ;
      c++ ;
    }
    else{
      ans++ ;
      b++ ;
      c++ ;
    }
  }
  
  int d = max({a,b,c}) ;
  
  ans += (3*d-(a+b+c))/2 ;
  
  cout << ans <<endl ;


  return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e11;
const long double PI = (acos(-1));

int A, B, N;

int f(int n) {
	int a = A * n / B;
	int b = n / B;
	int c = A * b;
	return a - c;
}

signed main() {
	cin >> A >> B >> N;
	int num;
	if (N % B == 0)num = N - 1;
	else num = N;
	int ans = f(num);
	if (B - 1 <= N)ans = max(ans, f(B - 1));
	cout << ans;
}

Measured memory_bytes: 3636
n=int(input())
vl = list(map(int, input().split()))
cl = list(map(int, input().split()))
dl = []
for i in range(n):
  dl.append(vl[i] - cl[i])
  #dl[i] = vl[i] - cl[i]
ct = 0
for j in range(len(dl)):
  if dl[j] > 0:
    ct += dl[j]
print(ct)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    int h, a;
    cin >> h >> a;
    int count = 0;
    while(h > 0){
        h -= a;
        count++;
    }
    cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
N,A,B,C = gets.split.map(&:to_i)
l = []
N.times do
  l << gets.to_i
end
ans = 10**10
(4**N).times do |i|
  tmp = 0
  b = [0,0,0]
  N.times do |j|
    k = i&3
    if k < 3
      tmp += 10 if b[k] != 0
      b[k] += l[j]
    end
    i /= 4
  end
  if b.min == 0
    next
  end
  tmp += (b[0]-A).abs + (b[1]-B).abs + (b[2]-C).abs
  ans = tmp if tmp < ans
end
p ans

Measured memory_bytes: 1788
while True:
    a,op,b = map(str,input().split())
    a = int(a)
    b = int(b)
    if op == "?":
      break
    elif op == "+":
      print(a+b)
    elif op == "-":
      print(a-b)
    elif op == "*":
      print(a*b)
    elif op == "/":
      print(a//b)

Measured memory_bytes: 7628
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(std::string s) {
  s.replace(5, 1, " ");
  s.replace(13, 1, " ");
  print(s);
}

int main() {
  std::string s;
  std::cin >> s;
  solve(s);
  return 0;
}


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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

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

  int count = 0;
  for (int i = 1; i <= n; ++i) {
    if (to_string(i).length() % 2 == 1) {
      count++;
    }
  }
  cout << count << endl;
}

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

////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

////////////////////////// Solution starts below. //////////////////////////////

const int MSK = (1<<16) + 10;

int n;
int a[20][20];
ll dp[MSK];
ll eval[MSK];
bool vis[MSK], visEval[MSK];
int mskN;

ll funcEval (int msk) {
	ll &ret = eval[msk];
	if (visEval[msk]) return ret;
	visEval[msk] = true;
	for (int i = 0; i < n; i++)
		for (int j = i+1; j < n; j++)
			if ((msk&(1<<i)) and (msk&(1<<j)))
				ret += a[i][j];
			
// 	printf ("    EVAL: %d %lld\n", msk, ret);
	return ret;
}

ll solve (int msk) {
	if (msk == 0) return 0;
// 	printf ("%d\n", msk);'
	ll &ret = dp[msk];
	if (vis[msk]) return ret;
	vis[msk] = true;
	for (int s = msk; s; s = (s-1)&msk) {
		ret = max (ret, funcEval (s) + solve ((~s)&msk));
//  		printf ("  msk: %d, s: %d, ret: %lld\n", msk, s, ret);
	}
	
//  	printf ("%d %lld\n", msk, ret);
	return ret;
}

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			scanf ("%d", &a[i][j]);
	mskN = (1<<n)-1;
	printf ("%lld\n", solve (mskN));

	return 0;
}

Measured memory_bytes: 1408
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double n, m;
	cin >>n >>m;
	vector<double> arr((int)n);
	for(int i = 0; i < n; i++) {
		cin >>arr[i];
	}
	sort(arr.begin(), arr.end());
	reverse(arr.begin(), arr.end());
	double required = accumulate(arr.begin(), arr.end(), 0.0) / (4.0 * m);
	if(arr[m-1] < required) {
		cout <<"No";
	} 
	else {
		cout <<"Yes";
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m;
	scanf("%d",&n);
	m = n%10;
	
	if(m==0||m==1||m==6||m==8)
	printf("pon");
	
	else if(m==3)
	printf("bon");
	
	else
	printf("hon");
	
	
	return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N, X, Y;
	scanf("%d %d %d", &N, &X, &Y);
	
	int i, j, count[2001] = {};
	for (i = 1; i < N; i++) {
		for (j = i + 1; j <= N; j++) {
			if (j - i <= abs(i - X) + abs(j - Y) + 1) count[j-i]++;
			else count[abs(i-X)+abs(j-Y)+1]++;
		}
	}
	
	for (i = 1; i < N; i++) printf("%d\n", count[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
	int W,H,x,y,r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if ((x - r >= 0 && x + r <= W) && (y - r >= 0 && y + r <= H)) {
		printf("Yes\n");
	}
	if ((x - r < 0 || x + r > W) || (y - r < 0 || y + r > H)) {
		printf("No\n");
	}
    return 0;
}


Measured memory_bytes: 2688
x, y = map(int, input().split())

a = 0

for i in range(x):

  z1 = (i+1) * 2 + (x - i - 1) * 4
  z2 = (i+1) * 4 + (x - i - 1) * 2

  if z1 == y or z2 == y: 
    print("Yes")
    a += 1
    break

if a == 0:
  print("No")

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <string>
#define input std::cin

using lint = long long int;
using namespace std;

int main() {
  std::ios_base::sync_with_stdio(0);
  int k; input >> k;
  string s = "";
  for (int i=0; i<k; i++)
	s += "ACL";
  std::cout << s << std::endl;
}




Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,K;
    cin >> N >> K;

    long long res;
    if(K%2){
        res = pow(N / K,3);
    }else{
        res = pow((N +(K/2)) / K,3);
        res += pow(N / K,3);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
# coding: utf-8
import sys
import numpy as np
import itertools


def main(argv=sys.argv):
  
    packs = list(map(int, input().split(' ')))
    packs = sorted(packs)
    if packs[2] - packs[1] - packs[0] == 0:
        print('Yes')
    else:
        print('No')
  
    return 0


if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 12504
n,l = gets.chomp.split(" ").map(&:to_i)

sum = 0
t = l

for i in 1..n
    sum += t
    t += 1
end

if l >= 0 
    puts sum - l
else
    nl = l + n -1
    if nl > 0
        puts sum
    else
        puts sum - nl
    end
end


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;




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

	int p,q,r;cin>>p>>q>>r;

	writeln(min(p+r,min(p+q,r+q)));

}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  int N, T, A, H;
  cin >> N >>T >> A;
  int ans = 0;

  vector<int> vec(N);
  for (int i = 0; i < N; i++){
    cin >> H;
    vec.at(i) = H;
  }

  double tmp;
  double diff = 100000000;
  for (int i = 0; i < N; i++) {
    tmp = T - vec.at(i)*0.006;
    if((tmp - A)*(tmp - A) < diff){
      diff = (tmp - A)*(tmp - A);
      ans = i+1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))

ans = 0
n_p = 0
for i in range(N):
    if i == 0:
        ans += 1
        n_p = P[0]
        continue

    if P[i] <= n_p:
        ans += 1

    if n_p > P[i]:
        n_p = P[i]
        

print(ans)


Measured memory_bytes: 24744