akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 100
#define WHITE 0
#define BLACK 1
#define GRAY 2
#define INFNTY 1000000

int i, j, n, M[MAX][MAX];

void dijkstra()
{
    int u, v, mincost;
    int d[MAX], color[MAX];
    
    for (i = 0; i < n; i++) {
        d[i] = INFNTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    
    while (1) {
        mincost = INFNTY;
        u = -1;
        for (i = 0; i < n; i++) {
            if (color[i] != BLACK && d[i] < mincost) {
                mincost = d[i];
                u = i;
            }
        }
        if (u == -1) {
            break;
        }
        
        color[u] = BLACK;
        
        for(v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFNTY) {
                if (d[u] + M[u][v] < d[v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    
    for (i = 0; i < n; i++) {
        printf("%d ", i);
        if (d[i] == INFNTY) {
            d[i] = -1;
            printf("\n", d[i]);
        }
        else {
            printf("%d\n", d[i]);
        }
    }
}

int main()
{
    int u, k, v, c;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            M[i][j] = INFNTY;
        }
    }
    
    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; j++) {
            scanf("%d %d", &v, &c);
            M[u][v] = c;
        }
    }
    
    dijkstra();
    
    return 0;
}


Measured memory_bytes: 2104
n=int(input())

dic={}
for i in range(n):
    s=input()
    if s not in dic:
        dic[s]=1
    else:
        dic[s]+=1
dic2=sorted(dic.items(), key=lambda x:x[1],reverse=True)
ma=dic2[0][1]

keys=sorted([k for k,v in dic.items() if v==ma])
for i in keys:
    print(i)

Measured memory_bytes: 47320
package main

import "fmt"

var W, H, N int

func main() {
	var x, y, a, r int
	var arr [][]int
	fmt.Scan(&W, &H, &N)
	i := 0
	for i < H {
		w := make([]int, W)
		arr = append(arr, w)
		i++
	}
	for i := 0; i < N; i++ {
		fmt.Scan(&x, &y, &a)
		switch a {
		case 1:
			arr = func1(x, y, arr)
		case 2:
			arr = func2(x, y, arr)
		case 3:
			arr = func3(x, y, arr)
		case 4:
			arr = func4(x, y, arr)
		}
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if arr[i][j] == 0 {
				r++
			}
		}
	}
	fmt.Println(r)
}
func func1(x, y int, arr [][]int) [][]int {
	for i := 0; i < len(arr); i++ {
		for j := 0; j < x; j++ {
			arr[i][j] = 1
		}
	}
	return arr
}
func func2(x, y int, arr [][]int) [][]int {
	for i := 0; i < len(arr); i++ {
		for j := x; j < W; j++ {
			arr[i][j] = 1
		}
	}
	return arr
}
func func3(x, y int, arr [][]int) [][]int {
	for i := 0; i < y; i++ {
		for j := 0; j < W; j++ {
			arr[i][j] = 1
		}
	}
	return arr
}
func func4(x, y int, arr [][]int) [][]int {
	for i := y; i < H; i++ {
		for j := 0; j < W; j++ {
			arr[i][j] = 1
		}
	}
	return arr
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int k;
  string s;
  cin >> k >> s;

  // if (s.size() <= k) {
  //   cout << s << '\n';
  // } else {
  //   for (int i = 0; i < k; ++i) {
  //     cout << s[i];
  //   }
  //   cout << "..." << '\n';
  // }

  if (s.size() > k) {
    s = s.substr(0, k) + "...";
  }
  cout << s << '\n';

  return 0;
}


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

using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	a[0] = toupper(a[0]);
	b[0] = toupper(b[0]);
	c[0] = toupper(c[0]);
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e3 + 5;

char g[MAXN][MAXN];

char g1[2 * MAXN][2 * MAXN];

int dp1[2 * MAXN][2 * MAXN];

int dpl[2 * MAXN], dpr[2 * MAXN];

stack<int> stk;

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, 0, n){
		scanf("%s", &g[i][0]);
	}
	REP(i, 0, n - 1){
		REP(j, 0, m - 1){
			int cnt = 0;
			REP(i0, 0, 2){
				REP(j0, 0, 2){
					if (g[i + i0][j + j0] == '.'){
						cnt ^= 1;
					}
				}
			}
			g1[2 * i + 1][2 * j + 1] = cnt;
		}
	}
	/*for(int j = 1; j < 2 * m; j += 2){
		dp1[1][j] = -1;
		if (g1[1][j]){
			dp1[1][j] = 1;
		}
	}
	for(int i = 3; i < 2 * n; i += 2){
		for(int j = 1; j < 2 * m; j += 2){
			dp1[i][j] = dp1[i - 2][j];
			if (g1[i][j]){
				dp1[i][j] = i;
			}
		}
	}*/
	for(int j = 0; j < 2 * m; j++){
		dp1[0][j] = -1;
	}
	for(int i = 1; i < 2 * n; i++){
		for(int j = 0; j < 2 * m; j++){
			dp1[i][j] = dp1[i - 1][j];
			if (g1[i][j]){
				dp1[i][j] = i;
			}
		}
	}
	int ans = max(n, m);
	for(int i = 0; i < 2 * n; i += 2){
		// dpl
		while(!stk.empty()){
			stk.pop();
		}
		for(int j = 1; j < 2 * m - 2; j += 2){
			while(!stk.empty() && dp1[i][stk.top()] <= dp1[i][j]){
				stk.pop();
			}
			if (stk.empty()){
				dpl[j] = -1;
			} else {
				dpl[j] = stk.top();
			}
			stk.push(j);
		}
		// dpr
		while(!stk.empty()){
			stk.pop();
		}
		for(int j = 2 * m - 3; j > 0; j -= 2){
			while(!stk.empty() && dp1[i][stk.top()] <= dp1[i][j]){
				stk.pop();
			}
			if (stk.empty()){
				dpr[j] = 2 * m - 1;
			} else {
				dpr[j] = stk.top();
			}
			stk.push(j);
		}
		// dp
		for(int j = 1; j < 2 * m - 2; j += 2){
			int cur = ((dpr[j] - dpl[j]) / 2) * ((i - dp1[i][j]) / 2 + 1);
			ans = max(ans, cur);
		}
		
		/*printf("%d\n", i);
		for(int j = 1; j < 2 * m - 2; j += 2){
			printf("%d %d %d\n", j, dpl[j], dpr[j]);
		}*/
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 82688
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mx=500009;
in n,l;
vector<double> v(2*mx),h(2*mx);
in ofsv=0;
in ofsh=0;
in b=mx;
in e=mx;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n>>l;
  v[e]=h[e]=0;
  ++e;
  cout<<setprecision(15);
  in adh,adv;
  cin>>adh>>adv;
  adh*=adv;
  h[e]=adh;
  v[e]=adv;
  ++e;
  forn(zz,n-1){
    /*for(in i=b;i<e;++i){
      cout<<(v[i]+ofsv)<<" "<<(h[i]+ofsh)<<" "<<(h[i]+ofsh)/(v[i]+ofsv)<<endl;
    }*/
    cout<<(h[e-1]+ofsh)/(v[e-1]+ofsv)<<"\n";
    cin>>adh>>adv;
    adh*=adv;
    while(e-b>=2 && v[e-2]+ofsv+adv>=l){
      --e;
    }
    v[--b]=-ofsv-adv;
    h[b]=-ofsh-adh;
    if(v[e-1]+ofsv+adv>=l){
      h[e-1]=h[e-2]+(h[e-1]-h[e-2])/(v[e-1]-v[e-2])*(l-(v[e-2]+ofsv+adv));
      v[e-1]=l-ofsv-adv;
    }
    ++b;
    while(b+1<e && (h[b+1]+ofsh+adh)/(v[b+1]+ofsv+adv)>(h[b]+ofsh+adh)/(v[b]+ofsv+adv)){
      ++b;
    }
    --b;
    v[b]=-ofsv-adv;
    h[b]=-ofsh-adh;
    ofsh+=adh;
    ofsv+=adv;
  }
  cout<<(h[e-1]+ofsh)/(v[e-1]+ofsv)<<"\n";
  return 0;
}


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

int main() {
 int n,ans;
  cin >> n;
  ans=n;
  r(i,n+1){
    int t=i,count=0;
    while(t){
      count+=t%6;
      t/=6;
    }
    t=n-i;
    while(t){
      count+=t%9;
      t/=9;
    }
    ans=min(ans,count);
  }
  cout<< ans<<endl;
}

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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll l, r, d;
    cin >> l >> r >> d;
    ll ans = r/d - (l-1)/d;
    cout << ans << endl;
    return 0;
}

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

double dist(double x1, double y1, double x2, double y2)
{
    return(sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
}

int main(void){
    // Your code here!
    double x1,x2,y1,y2;
    
    scanf("%lf %lf %lf %lf", &x1,&y1,&x2,&y2);
    
    printf("%f\n", dist(x1,y1,x2,y2));
    
}



Measured memory_bytes: 1848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		if(n>=10) System.out.println(r);
		else System.out.println(r+100*(10-n));
		sc.close();
	}
}

Measured memory_bytes: 23636
#include<iostream>
#define min(a,b) a<b?a:b
using namespace std;
long long int dp[20005];
int size[20005];
const long long int MAX=100000000000007;
int main(){
	long long int n,m,x;
	int i,j,k;
	long long int ma,mb;
	for(i=1;i<20005;i++){dp[i]=MAX;}
	cin>>n>>m>>x;
	for(i=0;i<n;i++){
		cin>>size[i];
	}
	for(i=1;i<=n;i++){
		ma=MAX,mb=0;
		for(j=1;j<=m;j++){
			if(i-j<0)break;
			if(size[i-j]<ma)ma=size[i-j];
			if(mb<size[i-j])mb=size[i-j];
			dp[i]=min(dp[i],dp[i-j]+x+(mb-ma)*j);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    char b;
    cin >> b;

    if(b=='A')
    {
        cout << "T" << endl;
    }

    if(b=='C')
    {
        cout << "G" << endl;
    }

    if(b=='T')
    {
        cout << "A" << endl;
    }

    if(b=='G')
    {
        cout << "C" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    int ar[27],br[27],i,j,k,l,x,y;
    cin>>s>>t;
    for(i=0;i<27;i++)
    {
        ar[i]=0;
        br[i]=0;
    }
    for(i=0;i<s.size();i++)
    {
        l=s[i]-'a';
        ar[l]++;
    }
    for(i=0;i<t.size();i++)
    {
        l=t[i]-'a';
        br[l]++;
    }
    sort(ar,ar+27);
    sort(br,br+27);
    for(i=0;i<27;i++)
    {
        if(ar[i]!=br[i])
        {
            cout<<"No"<<endl;
            x=0;
            break;
        }
        else
        {
           x=1;
        }
    }
    if(x==1)
        cout<<"Yes"<<endl;

}


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

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

    set<int> value;
    for (int i=0; i<n; i++) value.insert(d[i]);

    cout << value.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

int n,m;

int main(){
    cin >> n >> m;
    vector<int> a(m);
    REP(i,m){
        cin >> a[i];
        a[i]--;
    }
    vector<int> b={2,5,5,4,5,6,3,7,6};
    map<int,int> mp;
    REP(i,m){
        auto itr = mp.find(b[a[i]]);
        if(itr!=mp.end()){
            if(mp[b[a[i]]]<a[i]){
                mp[b[a[i]]]=a[i];
            }
        }else{
            mp[b[a[i]]]=a[i];
        }
    }
    vector<vector<int>> dp(n+1);
    for(auto itr:mp){
        if(itr.first<=n){
            dp[itr.first].push_back(itr.second);
        }
    }
    REP(i,n+1){
        if(!dp[i].empty()){
            for(auto itr:mp){
                if(i+itr.first<=n){
                    if(dp[i].size()+1>dp[i+itr.first].size()){
                        vector<int> temp=dp[i];
                        temp.push_back(itr.second);
                        dp[i+itr.first]=temp;
                    }else if(itr.second>dp[i+itr.first].back()){
                        vector<int> temp=dp[i];
                        temp.push_back(itr.second);
                        dp[i+itr.first]=temp;
                    }
                }
            }
        }
    }
    string res = "";
    ll l=dp[n].size();
    REP(i,l){
        res.push_back((char)(dp[n][l-1-i]+1+'0'));
    }
    put(res);
    return 0;
}



Measured memory_bytes: 127232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			StringBuilder sb = new StringBuilder(scanner.next());
			StringBuilder prefix = new StringBuilder();
			int q = scanner.nextInt();
			boolean reverse = false;
			for (int i = 0; i < q; i++) {
				switch (scanner.nextInt()) {
				case 1:
					reverse = !reverse;
					break;
				case 2:
					int f = scanner.nextInt();
					String c = scanner.next();
					if (1 == f) {
						if (reverse) {
							sb.append(c);
						} else {
							prefix.append(c);
						}
					} else {
						if (reverse) {
							prefix.append(c);
						} else {
							sb.append(c);
						}
					}
				}
			}
			System.out.println((reverse ? sb.reverse().append(prefix) : prefix.reverse().append(sb)).toString());
		}
	}
}


Measured memory_bytes: 155616
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

ll dfs(int time, vector<int> cnt, vector<vector<ll>> &f, vector<vector<ll>> &p, int n) {
    if (time == 10) {
        if (all_of(cnt.begin(), cnt.end(), [](int i){return i==0;})) {
            return -1e16;
        }
        ll ret = 0;
        for (int i=0; i<n; i++) {
            ret += p.at(i).at(cnt.at(i));
        }
        return ret;
    }
    ll one = dfs(time+1, cnt, f, p, n);
    for (int i=0; i<n; i++) {
        cnt.at(i) += f.at(i).at(time);
    }
    ll two = dfs(time+1, cnt, f, p, n);
    return max(one, two);
}

int main() {
    int n = 0;
    cin >> n;
    vector<vector<ll>> f(n, vector<ll>(10));
    for (int i=0; i<n; i++) {
        for (int j=0; j<10; j++) {
            cin >> f.at(i).at(j);
        }
    }
    vector<vector<ll>> p(n, vector<ll>(11));
    for (int i=0; i<n; i++) {
        for (int j=0; j<11; j++) {
            cin >> p.at(i).at(j);
        }
    }
    vector<int> cnt(n);
    cout << dfs(0, cnt, f, p, n) << endl;
    return 0;
}


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

int main(){
	int a, b;
  	cin >> a >> b;
  	int ans = 6-a-b;
  
  	cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define erep(i, n) for(int i = 0; i <= (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1E-11;

using namespace std;

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

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
	int n; cin >> n;
	vector<int>v(n);
	rep(i, n)cin >> v[i];

	vector<pair<int, int>>odd(100100);
	vector<pair<int, int>>even(100100);

	//一種類の数字しか出てこない場合
	int cnt = 0;
	rep(i, n - 1) {
		if (v[i] == v[i + 1])cnt++;
		else cnt = 0;
	}

	if (cnt == n - 1) {
		cout << n / 2 << endl;
		return 0;
	}
	////////////////////////////////
	/*
	for (int i = 0; i < 100100; i++) {
		odd[i].second = i;
		even[i].second = i;
	}
	*/

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			odd[v[i]].first++;
			odd[v[i]].second = v[i];
		}
		else {
			even[v[i]].first++;
			even[v[i]].second = v[i];
		}
	}

		sort(all(odd));
		reverse(all(odd));

		sort(all(even));
		reverse(all(even));

		if (odd[0].second != even[0].second) {
			cout << (n / 2) - odd[0].first + (n / 2) - even[0].first << endl;
			return 0;
		}

		int sum1 = (n / 2) - odd[0].first + (n / 2) - even[1].first;
		int sum2 = (n / 2) - odd[1].first + (n / 2) - even[0].first;

	cout << min(sum1, sum2) << endl;
	

	//cout << odd[0].first << endl;
}

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

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> mat(n,vector<ll>(n,0));
    for(ll i=0;i<n;i++) {
        ll u,k;
        cin>>u>>k;
        for(ll j=0;j<k;j++) {
            ll tmp;
            cin>>tmp;
            mat[u-1][tmp-1] = 1;
        }
    }
    for(ll i=0;i<n;i++) {
        for(ll j=0;j<n;j++) {
            if(j<n-1) {
                cout << mat[i][j] << " ";
            }else {
                cout << mat[i][j];
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int sum = 0;
	if (a > b)
		sum += a--;
	else
		sum += b--;
	if (a > b)
		sum += a--;
	else
		sum += b--;
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	long long a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF)
	{
		if(a*2>b)
		printf("%lld\n",b/2);
		else if(a*2==b)
		printf("%lld\n",a);
		else
		printf("%lld\n",a+(b-2*a)/4);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll n,m;
vector<pair <ll,ll> > a,b;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  a.resize(n);
  b.resize(m);
  REP(i,n){
    cin >> a[i].first >>a[i].second;
  }
  REP(i,m){
    cin >> b[i].first >>b[i].second;
  }
  REP(i,n){
    ll index=0;
    ll min=INF;
    REP(j,m){
      if( abs(b[j].first-a[i].first)+abs(b[j].second-a[i].second) < min ){
        index=j;
        min=abs(b[j].first-a[i].first)+abs(b[j].second-a[i].second);
      }
    }
    cout <<index+1 <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		int K = sc.nextInt();
        int X = sc.nextInt();
        
        int sum = 500*K;
        
        if(X <= sum){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 21716
#include <stdio.h>
#define M 100

int selectionSort(int A[], int N){
  int i, j, k, sw = 0, a;
  for(i = 0; i < N - 1; i++){
    a = i;
    for(j = i; j < N; j++){
      if(A[j] < A[a]) a = j;}
    k = A[i];
    A[i] = A[a];
    A[a] = k;
    if(i != a)sw += 1;}
  return sw;
}
    

int main(){
  int A[M], i, N, sw;

  scanf("%d", &N);
  for(i = 0; i < N; i++)scanf("%d", &A[i]);
  sw = selectionSort(A, N);

  for(i = 0; i < N; i++){
     if(i == 0)printf("%d", A[i]);
    else if(i > 0){printf(" ");
      printf("%d", A[i]);}
    else break;}

  printf("\n");
  printf("%d\n", sw);
  return 0;
}



Measured memory_bytes: 2100
/**
 * @author: Jun
 * @date  : 03-18-2019
 **/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int g[27];
string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(g, 0, sizeof g);
    cin >> s;
    int n=s.length();
    for(int i=0;i<n;i++){
        g[(int) s[i]-'a'+1]++; 
    }
    bool can=true;
    for(int i=1;i<=26;i++){
        if(g[i]%2==1){
            can=false;
            break;
        }
    }
    string res = (can) ? "Yes" : "No";
    cout << res << el;
    return 0;
}

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

#define INF 1000000000
int V, E;
int d[15][15]; //g[i][j] : i??????j??????????????¢?????????????????????-1
int dp[15][1<<15]; //dp[i][j] : i??????????????????0?????????????°??????¢(j?????¢????????£???????????±)

int tsp(int v, int b){
  //  cout<<v<<endl;
  if(dp[v][b]>0)return dp[v][b]; //?????¢????????¨????????????
  if(b==(1<<V)-1 && v==0)return dp[v][b]=0; //??¨?????????????????£?????????0????????£?????????
  int ret=INF;
  for(int i=0; i<V; i++){
    if((b>>i)&1)continue; //??¢????????£???
    if(d[v][i]==-1)continue; //????????????
    ret = min(ret, tsp(i, b|(1<<i))+d[v][i]);
  }
  return dp[v][b]=ret;
}

int main(){
  memset(d, -1, sizeof(d));
  memset(dp, -1, sizeof(dp));
  cin>>V>>E;
  for(int i=0; i<E; i++){
    int s, t, p;
    cin>>s>>t>>p;
    d[s][t]=p;
  }
  int min_d = tsp(0, 0);
  if(min_d==INF)cout<<-1<<endl;
  else cout<<min_d<<endl;
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long
#define foi(a,n) for(int i = a; i < (int)n; i++)
#define foj(a,n) for(int j = a; j < (int)n; j++)
#define pb(a) push_back(a)
#define ln '\n'
#define fastio 	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define cases int tests; cin >> tests; while(tests--)
using namespace std;
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void aq(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
// Driver Code 
int main() 
{ 
  
    int n, q;
    cin >> n >> q;
    int a[n];
    foi(0, n) cin >> a[i];
  
    Query queries[q];
    int l, r;
    foi(0,q){
		cin >> queries[i].l >> queries[i].r;
		queries[i].l--;
		queries[i].r--;
		queries[i].idx = i;
	  
    }
    sort(queries, queries+q, cmp);
    aq(a, n, queries, q);
} 


Measured memory_bytes: 19372
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  map<int, int> m1, m2;
  for(int i = 0; i < n; ++i){
    if(i%2) m1[v[i]]++;
    else m2[v[i]]++;
  }

  int e1=0 , e2=0, o1=0 , o2=0;
  int even1, even2, odd1, odd2;
  for(auto itr = m1.begin(); itr != m1.end(); ++itr){
    if(itr->second > e1){
      e1 = itr->second;
      even1 = itr->first;
    }
  }
  for(auto itr = m1.begin(); itr != m1.end(); ++itr){
    if(itr->second > e2 && itr->first != even1){
      e2 = itr->second;
      even2 = itr->first;
    }
  }
  for(auto itr = m2.begin(); itr != m2.end(); ++itr){
    if(itr->second > o1){
      o1 = itr->second;
      odd1 = itr->first;
    }
  }
  for(auto itr = m2.begin(); itr != m2.end(); ++itr){
    if(itr->second > o2 && itr->first != odd1){
      o2 = itr->second;
      odd2 = itr->first;
    }
  }

  if(even1 != odd1){
    cout << n - e1 - o1 << endl;
  }else{
    int ans = max(e1+o2, e2+o1);
    cout << n - ans << endl;
  }

}


Measured memory_bytes: 5376
n, k=map(int, input().split())
import math

#まず、nがk以上だった場合、勝ちになるので、① n-k+1/n
#k-1 => 得点 >1の場合、コインを投げ、表を出し続け、k以上に出す確率
#k-1=> k/2（切り上げ）に関しては、１回表を出すから 1/2 (1乗）
#k/2(切り捨て）からk/4（切り上げ）に関しては、1/2の二乗
#print(int(math.log2(n))+1)
if n>=k:
  ans=n-k+1
  for i in range(1, k):
    ans+=(1/2)**(math.ceil(math.log2(k/i)))
else:
  ans=0
  for i in range(1, n+1):
    ans+=(1/2)**(math.ceil(math.log2(k/i)))
print(ans/n)

Measured memory_bytes: 9400
// AOJ 1009
#include <iostream>
#include <cstdio>

using namespace std;

int GCD(int a, int b)
{
	while (1){
		a %= b;
		if (a == 0) return b;
		b %= a;
		if (b == 0) return a;
	}
}

int main(void)
{
	int a, b;
	while (scanf("%d %d", &a, &b) != EOF){
		cout << GCD(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	string s;
	cin >> s;
	int cnt(0);
	rep(i, 4)rep(j, 4) {
		if (i == j)continue;
		if (s[i] == s[j]) {
			cnt++;
		}
	}
	cnt /= 2;
	if (cnt == 2) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int N;
int A,B,C;
int l[8] = {0};
int ans;
int cal(int *vec){
  int len[3] = {0};
  int MP = 0;
  for(int i=0; i<N; i++){
    if(len[vec[i]] > 0 && vec[i] < 3) MP += 10;
    len[vec[i]] += l[i];
  }
  for(int i=0; i<3; i++){
    if(len[i] == 0) return 1000000000;
  }
  return abs(A - len[0]) + abs(B - len[1]) + abs(C - len[2]) + MP;
}

void dfs(int depth, int *vec){
  if(depth == N) ans = min(ans, cal(vec));
  else
    for(int i=0; i<4; i++){
      vec[depth] = i;
      dfs(depth + 1, vec);
    }
}

int main(){
  
  cin >> N;
  cin >> A >> B >> C;
  
  int i;
  for(i=0; i<N; i++) cin >> l[i];
 
  ans = 1000000000;
  int vec[N] = {0};
  dfs(0, vec);
  
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
struct edge { int to, cap, rev, cost; };
vector<edge> G[1000];
void add_edge(int from, int to, int cap, int cost = 0){
	G[from].push_back(edge{ to, cap, (int)G[to].size(),cost });
	G[to].push_back(edge{ from,0,(int)G[from].size() - 1,-cost });
}

int main() {
	  int N,G,E;
    std::cin >> N;
		if(N==1){
			std::cout << "Hello World" << '\n';
		}
		else{
			std::cin >> G>>E;
			std::cout << G+E << '\n';
		}
    }

Measured memory_bytes: 256
M=1000005
s=int(input())

def f(n,i):
    if i==1:
        return s

    if n%2==0:
        return n//2
    else:
        return 3*n+1

A={}
n=0
for i in range(1,M):
    n=f(n,i)
    A.setdefault(i,n)
    for j in range(1,i):
        if A[j]==A[i]:
            print(i)
            exit()

Measured memory_bytes: 38704
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll a[100009];
vector<ll> v[100009];
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    x = 0;
    for(i=1;i<=n;i++)
    {
        bool f = 0;
        for(j=0;j<v[i].size();j++)
        {
            if(a[i]<=a[v[i][j]])
            {
                f = 1;
                break;
            }
        }
        if(f==0)
            x++;
    }
    cout<<x<<endl;
    return 0;
}



Measured memory_bytes: 10264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	double mx = -1;
	pair<int, int> p;
	for (int i = 0; i <= f; i+=a) {
		for (int j = 0; j <= f; j+=b) {
			if (!i && !j) continue;
			for (int k = 0; k <= f; k+=c) {
				for (int l = 0; l <= f; l+=d) {
					int wa = i + j;
					int su = k + l;
					if (wa + su > f) continue;
					if ( 100.0 * su / (wa + su) > e * 100.0 / (e + 100)) continue;
					if (100.0 * su / (wa + su) > mx) {
						mx = 100.0 * su / (wa + su);
						p.first = wa + su;
						p.second = su;
					}
				}
			}
		}
	}
	cout << p.first << " " << p.second << endl;
}

Measured memory_bytes: 3612
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
int main(){
	char s[9];
	int c=0,i=0;
	scanf("%s",s);
	for(;i<3;i++)c+=s[i]=='1';
	printf("%d\n",c);
	return 0;
}


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

using namespace std;

namespace SetOperation
{
  template<typename T>
  std::set<T> unite(const std::set<T> &s1, const std::set<T> &s2)
  {
    std::set<T> t;
    std::set_union(s1.begin(), s1.end(), s2.begin(), s2.end(), std::inserter(t, t.end()));
    return t;
  }
};

int main()
{
  uint64_t N, M;
  cin >> N >> M;
  
  vector<uint64_t> a(M), b(M);
  vector<set<uint64_t>> c(M);
  
  for (uint64_t m = 0; m < M; ++m) {
    cin >> a[m] >> b[m];
    
    for (uint64_t i = 0; i < b[m]; ++i) {
      uint64_t c_mi;
      cin >> c_mi;
      
      c[m].insert(c_mi - 1);
    }
  }
  
  set<uint64_t> all_union_set;
  for (uint64_t m = 0; m < M; ++m) {
    all_union_set = SetOperation::unite(all_union_set, c[m]);
  }
  
  if (all_union_set.size() < N) {
    cout << -1 << endl;
    return 0;
  }
  
  uint64_t K = 1 << N;
  vector<vector<uint64_t>> dp(M + 1, vector<uint64_t>(K, 1e+15));
  dp[0][0] = 0;
  
  for (uint64_t m = 0; m < M; ++m) {
    uint64_t mask = 0;
    for (uint64_t i : c[m]) { mask |= 1 << i; }
    
    for (uint64_t k = 0; k < K; ++k) {
      dp[m + 1][k] = min(dp[m + 1][k], dp[m][k]);
      
      dp[m + 1][k | mask] = min(dp[m + 1][k | mask], dp[m][k] + a[m]);
    }
  }
  
  cout << dp[M][K - 1] << endl;
  
  return 0;
}

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


int main(void){
    // Your code here!
    
    int n, k;
    cin >> n >> k;
    
    double p = 0.0;
    
    for(int i = 1; i <= n; i ++){
        int score = i;
        double p2 = 1.0;
        while(score < k){
            score *= 2;
            p2 *= 0.5;
        }
        p += p2;
    }
    p /= n;
    cout << fixed;
    cout << setprecision(10) << p;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    char S[4]; 

    scanf("%s", S);
    if((S[0] != S[1]) && (S[1] != S[2]) && (S[2] != S[0]))
      printf("Yes\n");
    else
      printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
	new Main().doIt();
    }
    void doIt() { D(); } 
    void D() {
	long ans = 0;
	int N = sc.nextInt(), M = sc.nextInt();
	HashMap<Integer, ArrayList<Integer> > hash =  new HashMap<Integer, ArrayList<Integer> > ();
	for(int i = 0; i < N; i++) {
	    int A = sc.nextInt(), B = sc.nextInt();
	    if(! hash.containsKey(A)) {
		hash.put(A, new ArrayList<Integer>());
	    }
	    hash.get(A).add(B);
	}
	PriorityQueue<Integer> q = new PriorityQueue<Integer>(new Comparator<Integer>() {
		public int compare(Integer i0, Integer i1) {
		    return i1 - i0;
		}
	    } );
	for(int d = 1; d <= M; d++) {
	    if(hash.containsKey(d)) {
		for(Integer data : hash.get(d)) q.add(data);
	    }
	    //	    System.out.println(d + " " + q.size() + " " + hash.get(d) + ans );
	    if(! q.isEmpty()) {
		long tmp = q.poll();
		ans += tmp;
		//		System.out.println("Answer=" + ans + " " + tmp + " " + q.size());
	    }
	}
	System.out.println(ans);
    }
    void C() {
	long ans = 0;
	ArrayList<String> s = new ArrayList<String>();
	int N = sc.nextInt();
	for(int i = 0; i < N; i++) {
	    char [] work = sc.next().toCharArray();
	    Arrays.sort(work);
	    s.add(new String(work));
	}
	Collections.sort(s);
	//	for(String ss: s) System.out.println(ss);
	int cnt = 0;
	for(int i = 1; i < N; i++) {

	    if(s.get(i-1).equals(s.get(i))) {
		cnt++;
		ans += cnt;
	    } else cnt = 0;
	}
	System.out.println(ans);


    }
    void B() {
	int K = sc.nextInt(), X = sc.nextInt();
	ArrayList<Integer> ans = new ArrayList<Integer>();
	for(int i = X-(K-1); i <= X+(K-1); i++) ans.add(i);
	//	System.out.println(ans);
	for(Integer i: ans) System.out.print(" " + i);
	System.out.println();
    }
    void A() {
	int A = sc.nextInt(), B = sc.nextInt();
	int ans = A+B;
	ans = Math.max(ans, Math.max(A-B, A*B));
	System.out.println(ans);
    }
}




Measured memory_bytes: 104360
S = input()
ans = 0
plus_words = []
for i in range(2**(len(S)-1)):
  for j in range(len(S)-1):
    plus_words.append(S[j])
    if ((i>>j)&1):
      ans += int("".join(plus_words))
      plus_words.clear()
  plus_words.append(S[-1])
  ans += int("".join(plus_words))
  plus_words.clear()
  
print(ans)

Measured memory_bytes: 3060
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    a = tuple(map(int, input().split()))

    ave = sum(a)/N
    ls = [abs(ave - i) for i in a]
    print(ls.index(min(ls)))

if __name__ == '__main__':
    main()


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


int main() {
   int A, B, C, X, k;
   cin >> A;
   cin >> B;
   cin >> C;
   cin >> X;
   k = 0;
    for (int i = 0; i <=A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int l = 0; l <= C; ++l) {
                int total = 500*i + 100*j + 50*l;
                if(total == X)
                    ++k;
            }
        }
    }
    cout << k << endl;
    return 0;
}

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

int main() {
	// your code goes here
	long long n;
	cin>>n;
	long long sum=0;
	for(int i=1; i<=n; i++)
	{
		if(i%3!=0 && i%5!=0)
		{
			sum+=i;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		UL K; cin >> K;
		UL N; cin >> N;
		vector<UL> A(N); rep(i, N) cin >> A[i];
		UL ans = A[N - 1] - A[0];
		rep(i, N - 1) {
			ans = min(ans, K - A[i + 1] + A[i]);
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 1024
def gcd(a, b):
    if b == 0: return a
    else: return gcd(b, a % b)

def lcm(a, m):
    return a * b / gcd(a, b);

while True:
    try:
        a, b = map(int, raw_input().split())
        print gcd(a, b), lcm(a, b)
    except (EOFError):
        break

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 998244353;

int main(void){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  ll res = 0;
  for(int i = 0;i <= n;i += r){
    int rest = n - i;
    for(int j = 0;j <= rest;j += g){
      if((rest - j) % b == 0)
        ++res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut songs = vec![];
    for i in 0..n {
        let v = read_vec::<String>();
        songs.push((v[0].clone(), i64::from_str_radix(&v[1], 10).unwrap()));
    }
    let x = read::<String>();
    let sum = songs.iter().map(|ref xx| xx.1).sum::<i64>();
    let mut count = 0;
    for i in 0..n {
        count += songs[i].1;
        if songs[i].0 == x {
            break;
        }
    }
    println!("{}", sum - count);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N, K;
    cin >> N >> K;

    if (K > (N - 1) * (N - 2) / 2) {
        cout << "-1" << endl;
        return 0;
    }

    int count = (N - 1) * (N - 2) / 2 - K;
    cout << ((N - 1) + count) << endl;
    for (int i = 2; i <= N; i++) printf("1 %d\n", i);
    if (count <= 0) return 0;
    for (int i = 2; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            printf("%d %d\n", i, j);
            count--;
            if (count <= 0) return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< vector<ll> > vvl;
ll mod = 1e9+7, n;

void multiply(vvl& a, vvl& b){
    vvl c(n, vector<ll>(n, 0));
    
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            for(int k = 0; k < n; k++)
                c[i][j] = (c[i][j] + ( a[i][k]*b[k][j] ))%mod;
    
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            a[i][j] = c[i][j];
}

vvl solve(vvl& a, ll k, vvl& base){
    if(k == 1) return base;
    vvl aux = solve(a, k/2, base);
    multiply(aux, aux);
    if(k%2 == 1)
        multiply(aux, base);
    return aux;
}

int main(){
    ll k; cin >> n >> k;
    vvl mat(n, vector<ll>(n, 0));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> mat[i][j];
    vvl base(mat);
    vvl res = solve(mat, k, base);
    ll sum = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            sum = (sum+res[i][j])%mod;
    cout << sum << endl;
    
	return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >>k;
    vector<int> h(n);
    rep(i,0,n) cin >> h[i];
    sort(all(h),greater<int>());
    ll ans=0;
    rep(i,0,n){
        if(i<=k-1) continue;
        ans+= h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/**
     **author : _KMS_
     **created : 12-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+100,MOD=2e9;
typedef long long ll;
string s;
int x=-1,y=10000000;
int main() 
{ 
      
 ios::sync_with_stdio(false);
 cin.tie(0);
 int n,m;
 cin>>n>>m;
 for(int i=0;i<m;i++)
 {
       int a,b;
       cin>>a>>b;
       x=max(x,a);
       y=min(y,b);
 }
(x>y)?cout<<"0\n":cout<<y-x+1<<"\n";
 
 
	return 0; 
} 

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

int n, die[101000], pl, pr, now;
struct L{
	int l, r, id;
}a[101000], sl[101000], sr[101000];

bool cmpl(L a,L b){
	return a.l>b.l;
}
bool cmpr(L a,L b){
	return a.r<b.r;
}

int gao(L *s,int &pos){
	for (;die[s[pos].id];) ++pos;
	return s[pos].id;
}

ll cal(){
	ll res=0, p=0;
	memset(die,0,sizeof die); pl=pr=1;
	for (int i=1;i<=n;++i){
		int id;
		id= now? gao(sl,pl): gao(sr,pr);
		if (p>a[id].r){
			res+=p-a[id].r; p=a[id].r;
		}
		if (p<a[id].l){
			res+=a[id].l-p; p=a[id].l;
		}
		die[id]=1; now^=1;
	}
	return res+abs(p);
}

int main(){
	cin>>n;
	for (int i=1;i<=n;++i){
		scanf("%d%d",&a[i].l,&a[i].r);
		a[i].id=i;
		sl[i]=sr[i]=a[i];
	}
	sort(sl+1,sl+n+1,cmpl);
	sort(sr+1,sr+n+1,cmpr);

	ll ans=0;
	for (int org=0;org<=1;++org){
		now=org;
		ans=max(ans,cal());
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;

int main() {
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++) {
			if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
				cout << i << " " << j << " " << N - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;

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

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

  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += a[i] - 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ARC059D();

int main()
{
	ARC059D();
	fflush(stdout);
	return 0;
}

static void ARC059D()
{
	std::string orgs;
	std::cin >> orgs;

	int start = -1, end = -1;
	int sLen = orgs.length();
	char bfr1 = 0, bfr2 = 0;
	for (int i = 0; i < sLen; i++) {
		if (orgs[i] == bfr1) {
			start = i;
			end = i + 1;
			break;
		}
		if (orgs[i] == bfr2) {
			start = i - 1;
			end = i + 1;
			break;
		}
		bfr2 = bfr1;
		bfr1 = orgs[i];
	}

	printf("%d %d\n", start, end);
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;


int main(void) {
	int k, n; cin >> k >> n;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int x = a[0] + k - a[n - 1];
	rep(i, n - 1) {
		x = max(x, a[i + 1] - a[i]);
	}
	cout << k - x << endl;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = [int(input()) for _ in range(N)]
    a.sort()
    
    if N%2 == 0:
        print(2*sum(a[(N//2):])-a[N//2]-2*sum(a[:(N//2)])+a[N//2-1])
    else:
        x = 2*sum(a[(N//2):])-a[N//2]-a[(N//2)+1]-2*sum(a[:(N//2)])
        y = 2*sum(a[(N//2+1):])-2*sum(a[:(N//2+1)])+a[N//2]+a[N//2-1]
        print(max(x,y))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 7508