akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;
//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b;
  cin >> a >> b;
  cout << max(a+b,max(a-b,a*b)) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(com[0] == 'f') {
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 20456
import queue

n,m=map(int,input().split())

G=[[] for i in range(n)]

for _ in range(m):
 y,yy=map(int,input().split())
 y-=1
 yy-=1
 G[y].append(yy)
 G[yy].append(y)

q=queue.Queue()

vis=[0]*n
mae=[-1]*n

q.put([0,0])
while q.empty()==False:
 r=q.get()
 if vis[r[0]]==1:
  continue
 vis[r[0]]=1
 mae[r[0]]=r[1]
 for v in G[r[0]]:
  if vis[v]==0:
   q.put([v,r[0]])

print("Yes")
for i in range(1,n):
 print(mae[i]+1)

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    vector<int> ans;
    while(true){
        int res = -1;
        int N, M; cin >> N >> M;
        if(N == 0) break;
        vector<int> A(N);
        rep(i, N) cin >> A[i];
        for(int i = 0; i < N; i++){
            for(int j = i+1; j < N; j++){
                int val = A[i] + A[j];
                if(val <= M) res = max(res, val);
            }
        }
        if(res == -1) cout << "NONE" << endl;
        else cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int size = sc.nextInt();

        List<Integer> numbers = new ArrayList<>();

        for (int i = 0; i < size; i++) {
            numbers.add(sc.nextInt());
        }

        boolean approved = true;
        for (int i = 0; i < numbers.size(); i++) {
            if (numbers.get(i) % 2 != 0) {
               // numbers.remove(i);
            } else {
                if (numbers.get(i) % 3 == 0 || numbers.get(i) % 5 == 0) {
                    //System.out.println("APPROVED");
                } else {
                    approved = false;
                    break;
                }
            }
        }
        if (approved) {
            System.out.println("APPROVED");
        } else {
            System.out.println("DENIED");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	int a,b;
  	cin >> a >> b;
  	
	int temp = a+b;
  	int ans;
  
  	if(temp % 2 == 0)
    {
      	ans = (a+b)/2;
    }
  	else
    {
  		ans = (a+b+1)/2;
	}
      
    cout << ans <<endl;
}


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

int n;

int main() {
  cin >> n;
  vector<int> w(n);
  for(int i = 0; i < n; i++){
    cin >> w[i];
  }
  int mini = 100 * 100;
  for(int i = 0; i < n; i++){
    int left = 0;
    int right = 0;
    for(int j = 0; j <= i; j++){
      left += w[j];
    }
    for(int k = i + 1; k < n; k++) {
      right += w[k];
    }
    mini = min(mini, abs(left - right));
  }
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 256
x,k,d=map(lambda x:abs(int(x)),input().split())

p = x//d
m = k - p
ans = 0
if k<p:
    ans = x - d*k
else:
    ans = x - d*p
    k = k - p
    if (k%2 ==1):
        ans = abs(ans) - d
print(abs(ans))

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

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

    long long n;
    cin >> n;

    map<long long, int> mp;
    long long tmp = n;

    for(long long i = 2; i <= (long long)sqrt(n); i++){
        int cnt = 0;
        while(tmp % i == 0){
            cnt++;
            tmp /= i;
        }
        if(cnt > 0){
            mp[i] = cnt;
        }
    }
    if(tmp != 1) mp[tmp] = 1;


    vector<int> OK;
    int diff = 3;
    OK.push_back(2);
    for(int i = 0; i < 1000; i++){
        OK.push_back(OK[i] + diff);
        diff++;
    }

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

    // for(int i = 0; i < 10; i++){
    //     cout << OK[i] << ' ';
    // }
    // cout << endl;

    long long ans = 0;
    for(auto &x: mp){
        ans++;

        int idx = upper_bound(OK.begin(), OK.end(), x.second - 1) - OK.begin();
        ans += idx;
    }

    cout << ans << endl;

    return 0;
}

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








int main(){
  int n,m;
  cin>>n>>m;
  int ma=INT_MIN,mi=INT_MAX;
  while(m--){
    int l,m;
    cin>>m>>n;
    ma=max(m,ma);
    mi=min(n,mi);

  }
  if(mi-ma+1 >0)cout<<mi-ma+1<<endl;
  else cout<<0<<endl;
}




  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100001;
int n,D;
int main()
{
	scanf("%d %d",&n,&D);
	int t=2*D+1;
	if(n%t==0)
		printf("%d\n",n/t);
	else
		printf("%d\n",n/t+1);
	return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
a=list(map(int, input().split()))
ave = sum(a)/n
if math.ceil(ave)-ave > ave-math.floor(ave):
    t = math.floor(ave)
else:
    t = math.ceil(ave)
total = 0
for v in a:
    total += (t-v) ** 2
print(total)

Measured memory_bytes: 3064
# ABC141d
import sys
import heapq
import math
import fractions
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())
cd = []


def prime_decomposition(n):
    i = 2
    table = set()
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.add(i)
        i += 1
    if n > 1:
        table.add(n)
    return table


print(len(prime_decomposition(a).intersection(prime_decomposition(b)))+1)
exit()

for i in range(1, fractions.gcd(a, b) + 1):
    if (a % i != 0 or b % i != 0):
        continue
    flag = True
    for j in cd:
        if (j == 1):
            continue
        if (i % j == 0):
            flag = False
            break
    if (flag):
        cd.append(i)
print(len(cd))


Measured memory_bytes: 5308
#include<queue>
#include<cctype>
#include<cstdio>

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

using namespace std;

typedef pair<int , int > pii;


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

int h,w;
char grid[1010][1010];

int shortestDistance(int sx,int sy,int gx,int gy)
{
	static bool visited[1010][1010];
	rep(i,h)rep(j,w)  visited[i][j] = false;
	visited[sy][sx] = true;
	
	queue< pair< int ,pii > > qu;
	qu.push(mp(0,mp(sy,sx)));
	while(1)
	{
		pair<int ,pii> a = qu.front();
		qu.pop();
		int d = a.first,x = a.second.second,y = a.second.first;
		if(x == gx && y == gy) return d;
		
		rep(i,4)
		{
			int xx = x + dx[i], yy = y + dy[i];
			 if(0<=xx && xx<w && 0<=yy && yy<h && grid[yy][xx]!='X' && !visited[yy][xx])
			{
                visited[yy][xx]=true;
                qu.push(mp(d+1,mp(yy,xx)));
            }

		}
	}
}



int main(){
    int n;  scanf("%d%d%d",&h,&w,&n);
    int cx[10],cy[10];
    rep(i,h){
        scanf("%s",grid[i]);
        rep(j,w){
            if(grid[i][j]=='S')     cx[0]=j,cy[0]=i;
            if(isdigit(grid[i][j])) cx[grid[i][j]-'0']=j,cy[grid[i][j]-'0']=i;
        }
    }
 
    int cost=0;
    rep(i,n)    cost+=shortestDistance(cx[i],cy[i],cx[i+1],cy[i+1]);
    printf("%d\n",cost);
 
    return 0;
}

Measured memory_bytes: 4604
// AOJ 1145: The Genome Database of All Space Life
// 2017.11.13 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

typedef struct { char *p; int n; } S;
S stack[102]; int top;
char buf[102];
char ans[1000003];

int main()
{
	int w, W, n, m, k;
	char *bp, *p, *q;

	while (scanf("%s%d", bp=buf, &w) && *bp != '0') {
		n = 0, p = ans, top = 0, W = w++;
		while (*bp) {
			if (isdigit(*bp)) {
				n = 0; while (isdigit(*bp)) n = (n<<3) + (n<<1) + (*bp++ & 0xf);
			} else if (*bp == '(') {
				bp++;
				stack[top].p = p, stack[top++].n = n;
				n = 0;
			} else if (*bp == ')') {
				bp++;
				q = stack[--top].p, k = p-q, m = stack[top].n;
				while (--m) {
					if (w - k < 0) k = w;
					memcpy(p, q, k), p += k; w -= k;
					if (w < 0) goto done;
				}
			} else {
				if (n > 0) { w -= n; while (n--) *p++ = *bp; bp++; }
				else while (isalpha(*bp)) *p++ = *bp++, w--;
				if (w < 0) goto done;
				n = 0;
			}
		}
done:	if (p-ans <= W) putchar('0');
		else putchar(ans[W]);
		putchar('\n');
	}
	return 0;

}

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

using namespace std;
int main() {
	string S;
	cin >> S;
	int x = 0;
	
	if( S.find("AC")!=string::npos ){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;
#define FOR(t, a, b) for (int t = (a); t < (b); ++t)
#define REP(t, n) FOR(t, 0, n)

int main()
{
    int x;
    cin >> x;
    int maxb = sqrt(x);
    int ans = 1;
    for (int i = maxb; i >= 2; i--)
    {
        for (int j = 0;; j++)
        {
            int temp = pow(i, j);
            if (temp > x)
                break;
            else
            {
                if (temp > ans)
                    ans = temp;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<string> s(n);
  vector<int> a(n);
  for(int i=0;i<n;++i)cin>>s[i]>>a[i];
  vector<int> ord(n);
  iota(ord.begin(),ord.end(),0);
  sort(ord.begin(),ord.end(),[&](int x,int y){
    if(s[x]==s[y])return a[x]>a[y];
    return s[x]<s[y];
  });
  for(auto e:ord)cout<<e+1<<endl;
  return 0;
}

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

typedef long long ll;

string s;
int n;


int solve(int i, bool a, bool b, bool c, bool up) {
    if (i == n) {
        if (a && b && c)
            return 1;
        return 0;
    }
    if (up) {
        int u = s[i] - '0';
        if (u < 3) return 0;
        if (u == 3) return solve(i + 1, true, b, c, true);
        if (u < 5) return solve(i + 1, true, b, c, false);
        if (u == 5) return solve(i + 1, true, b, c, false) + solve(i + 1, a, true, c, true);
        if (u < 7) return solve(i + 1, true, b, c, false) + solve(i + 1, a, true, c, false);
        if (u == 7) return solve(i + 1, true, b, c, false) + solve(i + 1, a, true, c, false)
            + solve(i + 1, a, b, true, true);
        return solve(i + 1, true, b, c, false)
        + solve(i + 1, a, true, c, false)
        + solve(i + 1, a, true, c, false);
    } else {
        if (a && b && c) {
            return pow(3, n - i);
        }
        return solve(i + 1, a, b, true, false) + solve(i + 1, a, true, c, false) +
            solve(i + 1, true, b, c, false);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    n = s.length();
    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += solve(i, false, false, false, i == 0);
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 3996
n = gets.to_i
hi = gets.split.map(&:to_i)

ans = 0

$m = {}

def memo(a)
    if $m[a] == nil
        $m[a] = 1
    else
        $m[a] += 1
    end
    #puts "$m #{a} #{$m[a]}"
    return $m[a]
end

memo(1 + hi[0] )

2.upto(n) do |a|
    sa = a - hi[a-1]
    ans += $m[sa] if $m[sa]
    #puts "#{a} b - hi[b] == xx  #{a} - #{hi[a-1]} ** #{$m[sa]}"
    
    #b - a == hi[a-1] + hi[b-1]
    #6 - a == hi[a-1] + 1
    #6 - 1 == hi[a-1] + a
    
    #b - hi[b] == 3
    memo(a + hi[a-1])
end

puts ans

Measured memory_bytes: 37148
import statistics
n=int(input())
box=list(map(int,input().split()))
box_another=sorted(list(y-(x+1) for x,y in enumerate(box)))
median=int(statistics.median(box_another))
count=0
for x,y in enumerate(box):
    count +=abs(y-(x+1+median))
print(count)

Measured memory_bytes: 27308
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<int> a(m);
	for(int i = 0; i < m; i++) scanf("%d", &a[i]);
	sort(begin(a), end(a));
	
	if(n >= m) {
		printf("0\n");
		return 0;
	}
	
	i64 ans = 0;
	std::vector<i64> vec;
	for(int i = 0; i < m - 1; i++) {
		vec.push_back(std::abs(a[i + 1] - a[i]));
		ans += vec.back();
	}
	sort(begin(vec), end(vec)); reverse(begin(vec), end(vec));
	
	for(int i = 0; i < n - 1; i++) ans -= vec[i];
	printf("%lld\n", ans);
	return 0;
}


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


int main(){
    ll n;
    cin >> n;
    ll ans = pow(10, 12) + 9;
    ll nn = floor(sqrt(n));
    for(ll i = nn+1; i >= 1; i--){
        if(n%i == 0){
            //cout << i << endl;
            ll j = n / i;
            ans = min(ans, i + j - 2);
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  if(n % 2 == 0)
    cout << (double)((double)1 / (double)2);
  else {
    cout << (double)((double)(n / 2 + 1) / (double)n);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define x first
#define y second
#define pii pair<int,int>
//#define int long long 
using namespace std;
map<int,int>::iterator itr1;
map<int,map<int,int> >::iterator itr2;
int d;
int query(map<int,int> &mp,int l,int r){//[l,r]
	int ret=0;
	itr1=mp.lower_bound(l);
	if(itr1==mp.end()||(*itr1).first>r) return 0;
	ret-= (*itr1).second;
	itr1=mp.upper_bound(r);
	ret+= itr1==mp.end()? mp.size()+1LL:(*itr1).second;
	return ret;
}
int query(map<int,map<int,int> > &mp,int val,int y){
	int ret=0;
	itr2=mp.find(val);
	if(itr2!=mp.end()) ret+=query((*itr2).second,y,y+d);
	return ret;
}
map<int,map<int,int> > x1,x2,x3,x4;
set<pii >st;

#define check(x,y) (st.find(make_pair(x,y))!=st.end()) 
int calc(pii p){
	int ret=0;
	ret+=query(x1,p.x+p.y-d,p.y-d);
	ret+=query(x1,p.x+p.y+d,p.y);
	ret+=query(x2,p.x-p.y-d,p.y);
	ret+=query(x2,p.x-p.y+d,p.y-d);
	if(check(p.x,p.y+d)) ret--;
	if(check(p.x,p.y-d)) ret--;
	if(check(p.x+d,p.y)) ret--;
	if(check(p.x-d,p.y)) ret--;
	return ret;
}

int n,a,b;
pii p[N];
int val[N];

void del(pii v){
	x3[v.x+v.y].erase(v.y);
	x4[v.x-v.y].erase(v.y);
}
void expand(queue<int> &q,map<int,int> &mp,int l){
	for(itr1=mp.lower_bound(l);itr1!=mp.end()&&(*itr1).first<=l+d;itr1++)
		q.push((*itr1).second);
}
void clear(queue<int> &fr,queue<int> &to){
	while(!fr.empty()){
		int u=fr.front();fr.pop();
		del(p[u]);to.push(u);
	}
}

map<int,int> temp;
queue<int> q,tp;
int main(){
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&p[i].x,&p[i].y);
		if(x1.find(p[i].x+p[i].y)==x1.end()) x1[p[i].x+p[i].y]=temp;
		x1[p[i].x+p[i].y][p[i].y]=i;
		if(x2.find(p[i].x-p[i].y)==x2.end()) x2[p[i].x-p[i].y]=temp;
		x2[p[i].x-p[i].y][p[i].y]=i;
		st.insert(p[i]);
	}
	x3=x1,x4=x2;
	int cnt;
	for(itr2=x1.begin(),cnt=0;itr2!=x1.end();itr2++,cnt=0)
		for(itr1=(*itr2).second.begin();itr1!=(*itr2).second.end();itr1++)
			(*itr1).second=++cnt;
	for(itr2=x2.begin(),cnt=0;itr2!=x2.end();itr2++,cnt=0)
		for(itr1=(*itr2).second.begin();itr1!=(*itr2).second.end();itr1++)
			(*itr1).second=++cnt;
	
	d=abs(p[a].x-p[b].x)+abs(p[a].y-p[b].y);
	for(int i=1;i<=n;i++) val[i]=calc(p[i]);
	
	tp.push(a);tp.push(b);
	long long ans=0;
	clear(tp,q);
	while(!q.empty()){
		int u=q.front();q.pop();
		ans+=val[u];
		if((itr2=x3.find(p[u].x+p[u].y-d))!=x3.end()) expand(tp,(*itr2).second,p[u].y-d);
		clear(tp,q);
		if((itr2=x3.find(p[u].x+p[u].y+d))!=x3.end()) expand(tp,(*itr2).second,p[u].y);
		clear(tp,q);
		if((itr2=x4.find(p[u].x-p[u].y-d))!=x4.end()) expand(tp,(*itr2).second,p[u].y);
		clear(tp,q);
		if((itr2=x4.find(p[u].x-p[u].y+d))!=x4.end()) expand(tp,(*itr2).second,p[u].y-d);
		clear(tp,q);
	}
	
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 57344
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a = ni()
b = ni()
c = ni()
x = ni()
ans = 0

for i in range(a+1):
    for j in range(b+1):
        u = i*500+j*100
        if u <= x and (x-u)%50 == 0 and (x-u)//50 <= c:
            ans += 1

print(ans)

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

int convert( char c )
{
    switch ( c )
    {
    case 'I':   return 1;
    case 'V':   return 5;
    case 'X':   return 10;
    case 'L':   return 50;
    case 'C':   return 100;
    case 'D':   return 500;
    case 'M':   return 1000;
    }
}

int main( void )
{
    string input;
    int answer, prev;
    while ( cin >> input )
    {
        answer = 0;
        prev = 0;

        for ( string ::reverse_iterator it = input.rbegin(); it != input.rend(); it++ )
        {
            int next = convert( *it );
            if ( prev <= next )
            {
                answer += next;
            }
            else
            {
                answer -= next;
            }
            prev = next;
        }

        cout << answer << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

int N, D;

int main() {
    cin >> N >> D;
    cout << N/(2*D+1) + ((N%(2*D+1) == 0) ? 0 : 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n,a[100005];
int main(){
    n=rd();
    rep(i,1,n) a[i]=rd();
    drp(i,n-1,1) if(a[i]>a[i+1]) --a[i];
    rep(i,1,n-1) if(a[i]>a[i+1]) return puts("No"),0;
    puts("Yes");
    return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
    while(!isdigit(c=gc())&&c!='-');
    int f=c=='-'?c=gc(),1:0,x=c^48;
    while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
    return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll x;
	cin>>x;
	ll ans=x/500*1000;
	x%=500;
	cout<<ans+x/5*5<<endl;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    char ch;
    cin >> ch;

    ch += 1;
    cout << ch << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int a,b,tmp,bit,ans=0,num;
    
    cin>>a>>b;
    if(a>5)ans+=b/2;
    if(a>12)ans+=b/2;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    a := make([]Pair, n)
    for i:=0; i<n; i++{
        fmt.Scan(&a[i].first, &a[i].second)
        a[i].num=i+1
    }
    By(cmp).Sort(a)
    for i:=0; i<n; i++{
        fmt.Println(a[i].num)
    }
}





// Pairsort
type Pair struct {
    first string
    second int
    num int
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}

func cmp (p1, p2 *Pair) bool {
    if p1.first!=p2.first {
        return p1.first<p2.first
    } else {
        return p1.second>p2.second
    }
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

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

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

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


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

#define int long long

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

int X, Y;

signed main() {
    cin >> X >> Y;
    if (X > Y) {
        if (X % Y == 0) {
            cout << -1 << endl;
        } else {
            cout << X << endl;
        }
    } else if (X < Y)  {
        cout << X << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int H,N; vi A;
void input()
{
    cin>>H>>N;
    rep(i,N){
        int a; cin>>a; A.emplace_back(a);
    }
    return;
}

void solve()
{
    int sum=0;
    rep(i,N) sum+=A[i];
    if(H>sum) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
using namespace std;

LL powerLL(LL x, LL n) 
{ 
    LL result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % MOD; 
        n = n / 2; 
        x = x * x % MOD; 
    } 
    return result; 
} 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;

    cin>>s;

    for(int i=0;i<3;i++)
        cout<<s[i];

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector <int> A(n), B(n), C(n);
	for (int i = 0; i < n; i++) {
		cin >> C[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(all(A), greater<int>());
	sort(all(B), greater<int>());
	sort(all(C), greater<int>());
	int c = 0;
	vector <ll> tb(n);
	for (int i = 0; i < n; i++) {
		while(c < n && C[c] >= B[i]) {
			c++;
		}
		tb[i] += (n - c);
	}
	for (int i = n - 2; i >= 0; i--) {
		tb[i] += tb[i + 1];
	}
	int b = 0;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		while(b < n && B[b] >= A[i]) {
			b++;
		}
		if(b < n)
			ans += tb[b];
	}
	cout << ans;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    int N;
    cin >> N;
    vector<double> X(N);
    vector<double> Y(N);
    REP(i, N ){
        cin >> X[i] >> Y[i];
    }
    double ans = 1e9;
    REP(i, N-1){
        FOR(j, i+1, N) {
            double xc = (X[i] + X[j]) / 2;
            double yc = (Y[i] + Y[j]) / 2;
            double r = sqrt((X[i]-xc)*(X[i]-xc) + (Y[i]-yc)*(Y[i]-yc));
            bool flg = false;
            REP(k, N) {
                if(i == k || j == k) continue;
                if(sqrt((X[k]-xc)*(X[k]-xc) + (Y[k]-yc)*(Y[k]-yc)) > r + 0.00000001) {
                    flg = true;
                }
                double a1 = 2*X[i] - 2*X[j];
                double b1 = 2*Y[i] - 2*Y[j];
                double c1 = (X[i]*X[i] + Y[i]*Y[i]) - (X[j]*X[j] + Y[j]*Y[j]);
                double a2 = 2*X[i] - 2*X[k];
                double b2 = 2*Y[i] - 2*Y[k];
                double c2 = (X[i]*X[i] + Y[i]*Y[i]) - (X[k]*X[k] + Y[k]*Y[k]);
                if(b1*a2 - b2*a1 == 0) continue;
                double ycc = (c1*a2 - c2*a1) / (b1*a2 - b2*a1);
                double xcc = 0;
                if(a1 != 0) {
                    xcc = (c1 - ycc * b1) / a1;
                } else {
                    xcc = (c2 - ycc * b2) / a2;
                }
                double rcc = sqrt((X[i]-xcc)*(X[i]-xcc) + (Y[i]-ycc)*(Y[i]-ycc));

                if(rcc > ans) continue;

                bool flg2 = false;
                REP(l, N) {
                    if(i == l || j == l || k == l) continue;
                    if(sqrt((X[l]-xcc)*(X[l]-xcc) + (Y[l]-ycc)*(Y[l]-ycc)) > rcc + 0.00000001) {
                        flg2 = true;
                        break;
                    }
                }
                if(!flg2) ans = rcc;
            }
            if(!flg && r < ans) {
                ans = r;
            }
        }
    }
    cout << std::setprecision(10) <<  ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int f[1005];
int main(){
int n,m,sum=0;
cin>>n>>m;
for(int i=1;i<=m;i++){
int k;
cin>>k;
for(int j=1;j<=k;j++){
int t;
cin>>t;
f[t]++;
}
}
for(int i=1;i<=n;i++){
if(!f[i]) sum++;
}
cout<<sum;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main() {
   int a,b,C;
   double rad;
   double PI = acos(-1);
   cin >> a >> b >> C;
   
   rad = C * PI / 180;
   
   double S = (1/2.0)*a*b*sin(rad);
   double L = a+b+sqrt((a*a+b*b-2*a*b*cos(rad)));
   double h = b*sin(rad);
   
   printf("%lf\n%lf\n%lf\n", S, L, h);
  
    return 0;
}



Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;

int main(){
string s,ans;
cin >> s ;
if(s[0] != s[1] || s[1] != s[2] || s[0] != s[2]) ans = "Yes";
else ans = "No";
cout << ans << endl;
}  

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, n, x;
	
	scanf("%d", &n);
		
	for (i = 1; i <= n; i++) {
		x = i;
		if (i % 3 == 0) printf(" %d", i);
		else {
		      while (x > 0) {
		      if (x % 10 == 3) {
		      printf(" %d", i);
		      break;
		      }
		      x /= 10;
		      }
		}
	}
	printf("\n");
						
	return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] n = line.split(" ");
		Boolean x = true;
		int num5=0;
		int num7=0;
		for(int i=0; i < 3; i++) {
		    if(n[i].equals("5")){
		        num5++;
		    }
		    if(n[i].equals("7")){
		        num7++;
		    }
		}
		if(num5==2 && num7==1){
		    System.out.println("YES");
		} else {
		    System.out.println("NO");
		}
		
	}
}

Measured memory_bytes: 21332
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define INF LLONG_MAX
#define NINF LLONG_MIN
#define inf 1e18
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define rep1(i,a,n) for(ll i=a;i<=(long long)n;++i)
#define rep2(i,n,a) for(ll i=n;i>(long long)a;--i)
#define rep3(i,n,a) for(ll i=n;i>=(long long)a;--i)
#define repi(i,a,n) for(int i=a;i<=(int)n;++i)
#define repl(i,a,n) for(int i=a;i<(int)n;++i)
#define PI 3.141592653589793238510
#define en '\n'
#define MAX 100005
#define less_time ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug cout<<"HERE"<<en;
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vi vc<int>
#define mii unordered_map<int,int>
#define pql priority_queue<int>
#define pqs priority_queue<int,vi,greater<int>>
#define vll vector<long long>
#define pll pair<long long,long long>
#define pl pair<int,int>
#define eb emplace_back
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace std::chrono;
int main(){
    less_time;
    ll n,W,V=0;
    cin>>n>>W;
    ll wt[n+5]={0};
    ll val[n+5]={0};
    rep1(i,1,n)
    cin>>wt[i]>>val[i],V+=val[i];
    ll dp[n+5][V+5];
    rep1(i,0,n+1)
      rep1(j,0,V+1)
        dp[i][j]=1e18+5;
    //rep1(i,1,n)
    dp[1][0]=0;
    dp[1][val[1]]=wt[1];
    rep1(i,2,n)
    {
      rep1(v,0,V)
      {
        if(val[i]<=v)
         dp[i][v]=min(wt[i]+dp[i-1][v-val[i]],dp[i-1][v]);
        else
         dp[i][v]=dp[i-1][v];
      }
    }
    ll max_=-inf;
    rep1(i,1,V)
    {
      if(dp[n][i]<=W)
      max_=i;
    }
    cout<<max_;
return 0;
}

Measured memory_bytes: 81024
N,M=map(int, input().split())
S=input()
now=S[N-1]
dp=[float("INF")]*(N+1)
dp[N]=0
nowmin=0
right=N
for left in range(N-1,-1,-1):
    while right-left>M or S[right]=="1":
        right-=1
        nowmin=dp[right]
    if right<=left:
        print(-1)
        exit()
    if S[left]=="1":
        continue
    else:
        dp[left]=1+nowmin
#print(dp)
#print(dp[0])
now=dp[0]
nowi=0
"""
if now==float("INF"):
    print(-1)
    exit()
"""
for i in range(1,N+1):
    if now>dp[i]:
        print(i-nowi, end=" ")
        now=dp[i]
        nowi=i


Measured memory_bytes: 7920
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000010
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
int a[N],del[N]; ll b[N],s[1010][1010];
int main()
{	int n,t=0,k; ll ans=0; cin>>n>>k;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]);
	for(rint i=1;i<=n;i++)
	{	s[i][i]=a[i]; b[++t]=a[i];
		for(rint j=i+1;j<=n;j++) s[i][j]=s[i][j-1]+a[j],b[++t]=s[i][j];
	}
	for(rint i=60;i>=0;i--)
	{	int num=0;
		for(rint j=1;j<=t;j++)
		if(!del[j]&&(b[j]&(1LL<<i))) num++;
		if(num>=k)
		{	for(rint j=1;j<=t;j++)
			if(!(b[j]&(1LL<<i))) del[j]=1;
			ans|=(1LL<<i);
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 18688
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int k;
    cin >> k;
    if (k % 2 == 0) {
        cout << (k / 2) * (k / 2) << endl;
    } else {
        cout << (k / 2 + 1) * (k / 2) << endl;
    }
    return 0;
}



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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int mod=1000000007;
    long long sum=0;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        sum%=mod;
    }
    
    long ans=0;
    
    for(int i=0;i<n;i++){
        sum-=a[i];
        if(sum<0) sum+=mod;
        
        ans+=a[i]*sum;
        
        ans%=mod;
        
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3988
import math
import itertools
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  xy = [tuple(map(int, input().split())) for _ in range(N)]

  sum_ = 0
  for order in itertools.permutations(range(N)):
    for i in range(1, N):
      xi, yi = xy[order[i]][0], xy[order[i]][1]
      xj, yj = xy[order[i-1]][0], xy[order[i-1]][1]
      sum_ += math.sqrt((xi-xj)**2 + (yi-yj)**2)

  print(sum_ / math.factorial(N))


if(__name__ == '__main__'):
  main()


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


using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

const int p = 998244353;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

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

    int a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;

    vector<bool> water(f+1);
    water[0] = true;
    for (int i = 100; i<=f; i+=100)
    {
        if (i>=100*a && water[i-100*a]) water[i] = true;
        if (i>=100*b && water[i-100*b]) water[i] = true;
    }

    vector<bool> sugar(f+1);
    sugar[0] = true;
    for (int i = 1; i<=f; i++)
    {
        if (i>=c && sugar[i-c]) sugar[i] = true;
        if (i>=d && sugar[i-d]) sugar[i] = true;
    }

    int sug = 0; int wat = 100*a;

    for (int s = 0; s<=f; s++) if (sugar[s])
        for (int w = 0; w<=f; w++) if (water[w]) if (w+s<=f && w+s && s*100<=w*e)
        {
            if (s*wat>sug*w)
            {
                sug = s; wat = w;
            }
        }
    cout<<sug + wat<<' '<<sug;

}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;
    if (A==1 &&B==1)
        cout <<"Draw";
    else if  (A==1)
        cout<<"Alice";
    else if (B==1)
        cout <<"Bob";
    else if (A>B)
        cout<<"Alice";
    else if (B>A)
        cout<<"Bob";
    else if (A==B)
        cout<<"Draw";
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		int a, b,c;

		string[] s = Console.ReadLine().Split(' ');

		// int a = int.Parse(Console.ReadLine());

		a = int.Parse(s[0]);
		b = int.Parse(s[1]);
        c = int.Parse(s[2]);

		if (a <b&&b<c)
		{
			Console.WriteLine("Yes");
		}
        else
        {
            Console.WriteLine("No");
        }
		//Console.WriteLine("");


	}
}

Measured memory_bytes: 8932
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
  int A, B, C;
  std::cin >> A >> B >> C;
  int ans = A == B ? C : B == C ? A : B;
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0 for i in range(n)]
ans = 0
cnt = 0
for i in range(n):
  l[i] = p[i]*(p[i]+1)/(2*p[i])
if n == k:
  ans = sum(l)
else:
  ans = sum(l[:k])
  cnt = ans
  for i in range(n-k):
    cnt = cnt - l[i] + l[i+k]
    if cnt > ans:
      ans = cnt
print(ans)

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

int A, B, M;
int main() {
  cin >> A >> B >> M;
  int a[A], b[B];
  int minA = 1e9;
  int minB = 1e9;
  for (int i = 0; i < A; i++) {
    cin >> a[i];
    minA = min(minA, a[i]);
  }
  for (int i = 0; i < B; i++) {
    cin >> b[i];
    minB = min(minB, b[i]);
  }
  int ans = minA + minB;

  int x, y, c;
  for (int i = 0; i < M; i++) {
    cin >> x >> y >> c;
    x--;
    y--;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
def main():
    import numpy as np
    n=int(input())
    a=list(enumerate(map(int,input().split())))
    a.sort(key=lambda x: -x[1])
    dp=[np.zeros(i+1,dtype=np.int64) for i in range(n+1)]
    dp[0]=np.zeros(1,dtype=np.int64)
    r=np.arange(n+1,dtype=np.int64)
    for time,ix in enumerate(a):
        i,x=ix
        dp[time+1][1:]=dp[time][:time+1]+(i-r[:time+1])*x
        np.maximum(dp[time+1][:-1],dp[time]+((n-1-(time-r[:time+1]))-i)*x,out=dp[time+1][:-1])
    print(np.max(dp[n]))
main()

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    string n;
    cin >> n;
    REP(i, n.size()) {
        if (n[i] == '7') {
            cout << "Yes" << en;
            return;
        }
    }
    cout << "No" << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] c= {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
        for (;;) {
            String n = sc.next();
            if (n.equals("0")) {
                break;
            }
            int[] l=new int[6];
            for(int i=1;i<7;i++) {
                if(n.charAt(i)>='a'&&n.charAt(i)<='f') {
                    l[i-1]=n.charAt(i)-'a'+10 ; 
                }else {
                    l[i-1]=n.charAt(i)-'0'; 
                }
            }
            int r=l[0]*16+l[1]>127?4:0;
            int g=l[2]*16+l[3]>127?2:0;
            int b=l[4]*16+l[5]>127?1:0;
            System.out.println(c[r+g+b]);
        }
    }
}


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

int main() {
	int n;
	cin >> n;
	int v[20];
	int c[20];
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (v[i] > c[i])count += v[i] - c[i];
	}
	cout << count;
}

Measured memory_bytes: 256