akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  scanf("%d\n", &n);
  double p[n] = {};
  rep(i, n) {
    scanf("%lf", &p[i]);
  }

  double dp[n+1][n+1] = {1};

  rep(i, n) {
    rep(j, i+1) {
      dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
      dp[i+1][j+1] += dp[i][j] * p[i];
    }
  }

  double ans = 0;
  rep(i, n+1) {
    if (i > n-i) {
      ans += dp[n][i];
    }
  }

  printf("%.10lf\n", ans);
}


Measured memory_bytes: 70528
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <cmath>
#include <string>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 2000006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        int a[120];
        cin>>n;
        rep(i, n)
            cin>>a[i];
        sort(a, a+n);
        int ans=1;

        for(i=n-2;i>=0;i--)
            if(a[i]<a[i+1])
                ans++;
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	while (cin >> n, n) {
		string s;
		cin >> s;
		string ans = "SAFE";
		vector<set<int>> vsi(10);
		int memo = 0;
		REP(i, s.length()) {
			if (s[i] == 'u') {
				memo = 0;
			}
			else {
				if (((memo >> (s[i] - '0')) & 1)) {
					ans = "UNSAFE";
					break;
				}
				vsi[s[i] - '0'].insert(memo);
				memo |= 1 << (s[i] - '0');
			}
		}
		REP(k, 8)
			REP(i, 9)
			FOR(j, i + 1, 10)
			for (auto x1 : vsi[i])
				for (auto x2 : vsi[j]) {
					if (!(x1&x2)) {
						if (((x1 >> j) & 1)) {
							vsi[i].insert(x1 | x2);
							if(((x1 | x2)>>i)&1) {
								ans = "UNSAFE";
								goto finish;
							}

						}
						if ((x2 >> i) & 1) {
							vsi[j].insert(x1 | x2);
							if (((x1 | x2) >> j) & 1) {
								ans = "UNSAFE";
								goto finish;
							}
						}
					}
				}
		REP(i, 9)
		FOR(j, i + 1, 10)
			for (auto x1 : vsi[i])
				for (auto x2 : vsi[j]) {
					if (((x1 >> j) & 1)&& ((x2 >> i) & 1)&&!(x1&x2)) {
						ans = "UNSAFE";
						break;
					}
				}
		finish:
		cout << ans << endl;
	}
	return 0;
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;

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

ll H, W; 
ll sh, sw; 
ll gh, gw;

char field[1010][1010];
ll cnt[1010][1010];
struct grid{ll to; ll cost;};

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> H >> W >> sh >> sw >> gh >> gw;
	--sh, --sw, --gh, --gw;
	REP(h, H) REP(w, W) cin >> field[h][w];
	REP(h, H) REP(w, W) cnt[h][w] = INF;

	cnt[sh][sw] = 0;
	priority_queue<pair<ll, P>,
				   vector<pair<ll, P>>,
				   greater<pair<ll, P>>> que;
	que.push(pair<ll, P>{0, P{sh, sw}});

	while (que.size())
	{
		DEBUG(que.size());
		auto now = que.top();
		que.pop();
		ll cn = now.first;
		ll h = now.second.first;
		ll w = now.second.second;

		if (cnt[h][w] < cn) continue;

		REP(i, 4)
		{
			ll hh = h + dy[i];
			ll ww = w + dx[i];
			if (hh < 0 || hh >= H || ww < 0 || ww >= W) continue;
			if (field[hh][ww] == '#') continue;

			if (cnt[hh][ww] > cn)
			{
				cnt[hh][ww] = cn;
				que.push(pair<ll ,P>{cn, P{hh, ww}});
			}
		}

		for (ll dy = -2; dy <= 2; ++dy)
		{
			for (ll dx = -2; dx <= 2; ++dx)
			{
				ll hh = h + dy;
				ll ww = w + dx;

				if (hh < 0 || hh >= H || ww < 0 || ww >= W) continue;
				if (field[hh][ww] == '#') continue;

				if (cnt[hh][ww] > cn+1)
				{
					cnt[hh][ww] = cn + 1;
					que.push(pair<ll, P>{cn+1, P{hh, ww}});
				}
			}
		}
	}

	if (cnt[gh][gw] == INF)
		std::cout << -1 << std::endl;
	else
		std::cout << cnt[gh][gw] << std::endl;
	
	return 0;
}









Measured memory_bytes: 12632
#include<bits/stdc++.h>
using namespace std;
long long calc(long long n, long long x) {
	long long delta((n - x) / x);
	if(n - x - delta * x == 0) {
		return delta * 2 * x;
	}else {
		return delta * 2 * x + x + n - x - delta * x + calc(x, n - x - delta * x);
	}
}
int main() {
	long long n, x;
	cin >> n >> x;
	if(x * 2 < n) {
		cout << calc(n - x, x) + n + x << endl;
	}else {
		cout << calc(n, n - x) + x << endl;
	}
}


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

int main() {
    int64_t N;
    cin >> N;
    
    vector<int64_t> a(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> a[i];
    }
    
    int64_t all = 0;
    int64_t b = 0;
    for ( int64_t i = 0; i < N; ++i){
        b = a[i];
        all = all^b;
    }
    
    for ( int64_t i = 0; i < N; ++i){
        b = a[i];
        int64_t a = all^b;
        cout << a << " ";
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 4684
F=->{gets.split.map &:to_i};n,*d=F[];g=(0..n).map{[]};n.times{A,B,c=F[];c&&g[A]<<[B,c]&&g[B]<<[A,c]};d[B]=0;s=[B];g[n].map{|u,c|d[u]||(d[u]=c+d[n];s<<u)}while n=s.pop;A.times{a,b=F[];p d[a]+d[b]}

Measured memory_bytes: 38524
#include<stdio.h>
int main(){
  int x,y,i,a = 0,b,c,d,e,f;
  while(1){
    a = 0;
    scanf("%d",&x);
    if(x == 0)break;
  y = 1000 - x;
  if(y >= 500){a = y/500;}
  b = y%500;
 if(b >= 100){a += b/100;}
  c = b%100;
 if(c >= 50){a += c/50;}
  d = c%50;
 if(d >= 10){a += d/10;}
  e = d%10;
 if(e >= 5){a += e/5;}
  f = e%5;
 if(f >= 1){a += f/1;}
 printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    ll n, k, q; cin >> n >> k >> q;
    vector<ll> a(q);
    rep(i, q){
        cin >> a[i];
        a[i]--;
    }
    vector<ll> point(n, 0);
    rep(i, q) point[a[i]]++;
    rep(i, n){
        if(q - k < point[i])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 2176
a = list(input())
b = list(input())
c = list(input())
cur = "a"
while(True):
  if cur == "a":
    if not a:
      print("A")
      break
    cur = a.pop(0)
  if cur == "b":
    if not b:
      print("B")
      break
    cur = b.pop(0)
  if cur == "c":
    if not c:
      print("C")
      break
    cur = c.pop(0)

Measured memory_bytes: 8992
a = Array.new(3).map{Array.new(3)}
b = []

3.times do |i|
  a[i] = gets.chomp.split.map(&:to_i)
end

n = gets.to_i

n.times do
  b << gets.chomp.to_i
end

3.times do |i|
  3.times do |j|
  a[i][j] = 0 if b.include?(a[i][j])
  end
end

ans = "No"

3.times do |i|
    ans = "Yes" if a[0][i].zero? && a[1][i].zero? && a[2][i].zero?
    ans = "Yes" if a[i][0].zero? && a[i][1].zero? && a[i][2].zero?
end

ans = "Yes" if a[0][0].zero? && a[1][1].zero? && a[2][2].zero?
ans = "Yes" if a[0][2].zero? && a[1][1].zero? && a[2][0].zero?

puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string str;
int l;
int main()
{
    cin>>str;
    l=str.size();
    for(unsigned int i=0;i<l;i++)
    {
        if(str[i]=='C')
        {
            for(unsigned int j=i+1;j<l;j++)
            {
                if(str[j]=='F')
                {
                    cout<<"Yes\n";
                    return 0;
                }
            }
        }
    }
    cout<<"No\n";
    return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> vec(H+2,vector<char>(W+2,'#'));
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      cin >> vec.at(i).at(j);
    }
  }
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout << vec.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
from collections import deque

n = int(input())

graph = [[] for _ in range(n)]

inputs = []
for i in range(n - 1):
    f, t = map(int, input().split())
    f -= 1
    t -= 1
    graph[f].append(t)
    graph[t].append(f)
    inputs.append((f, t))

que = deque([(0, None)])
visited = [False] * n
visited[0] = True
# edge = [None] * n
edge = [{} for _ in range(n)]

color_n = -1
while que:
    now, skip = que.popleft()
    i = 0
    for t in graph[now]:
        if not visited[t]:
            if i == skip:
                i += 1
            que.append((t, i))
            visited[t] = True
            # edge[t] = i + 1
            edge[now][t] = i + 1
            color_n = max(color_n, i + 1)
            i += 1

print(color_n)
for f, t in inputs:
    print(edge[f].get(t) or edge[t].get(f))


Measured memory_bytes: 97184
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int K = sc.nextInt();
        int X = sc.nextInt();
        String ans = (500 * K >= X) ? "Yes" : "No";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld double
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
ll mod=1e9+7;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }

ll n;
ve<ll>ar(401,0);
ll dp[401][401];

void fun(ll i,ll j){
	if(dp[i][j]!=-1) return;
	if(i==j){
		dp[i][j]=0;
		return;
	}
	for(ll k=i;k<j;k++){
		fun(i,k); fun(k+1, j);
		if(dp[i][j]==-1)
			dp[i][j]=dp[i][k]+dp[k+1][j]+ar[j]-ar[i-1];
		else dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+ar[j]-ar[i-1]);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	lr(n){
		ll x;
		cin>>x;
		ar[i+1]=ar[i]+x;
	}		
	for(ll i=0;i<=n;i++) for(ll j=0;j<=n;j++) dp[i][j]=-1;
	fun(1,n);
	cout << dp[1][n] << "\n";
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
void sort(int *a, int *b){
	int tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(){
	int x,y,z;
    scanf("%d %d %d", &x, &y, &z);

    if (x > z)
        sort(&x, &z);
    if (x > y)
        sort(&x, &y);
    if (y > z)
        sort(&y, &z);

    printf("%d %d %d\n",x,y,z);

    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> x(N),y(N),h(N);
    for(int i=0;i<N;i++) cin>>x[i]>>y[i]>>h[i];
    
    int MAX = 100;
    for(int cy=0;cy<=MAX;cy++){
        for(int cx=0;cx<=MAX;cx++){
            int H=-1;
            for(int i=0;i<N;i++){
                if(h[i]>0){
                    int tmp=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
                    if(H==-1){
                        H=tmp;
                    }
                    else{
                        if(H!=tmp){
                            H=-2;
                            break;
                        }
                    }
                }
            }
            if(H==-2) continue;
            
            for(int i=0;i<N;i++){
                if(h[i]==0){
                    int tmp2=abs(x[i]-cx)+abs(y[i]-cy);
                    if(H>tmp2){
                        H=-2;
                        break;
                    }
                }
            }
            if(H==-2) continue;
            
            cout<<cx<<" "<<cy<<" "<<H<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
def resolve():
    import math
    n = int(input())
    distance = [list(map(int, input().split())) for i in range(n)]
    c =[[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            dix = (distance[i][0] - distance[j][0]) **2
            diy = (distance[i][1] - distance[j][1]) **2
            c[i][j] = (dix+diy)**0.5
    sumc = 0
    for i in range(n):
        sumc += sum(c[i])
    print(sumc/n)
resolve()

Measured memory_bytes: 38256
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner sc=new Scanner(System.in);
    int L = sc.nextInt();
    int R = sc.nextInt();
    int d = sc.nextInt();
    
    int counter=0;
    for(int i=L;i<=R;i++){
      if(i%d==0) counter++;
    }
    System.out.print(counter);
  }
}

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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end();

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

int sum(int n){
   int s = 0;
   while(n > 0){
      s+=n%10;
      n/=10;
   }
   return s;
}
using namespace std;


int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   
   int n,a,b; cin >> n >> a >> b;

   int ans = 0;
   for(int i = 1; i <= n; i++){
      int d = sum(i);
      if(d >= a && d <= b){
         ans += i;
      }
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1e9+7 ;
//long double pie = acos(-1) ;
//ll INF = 1e15 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s ; cin >> s ;
	ll n = s.size() ;
	vll l,r ;
	for(int i=0;i<n;i++){
		if(s.at(i)=='L') l.push_back(i) ;
		else r.push_back(i) ;
	}
	vll ans(n,0) ;
	for(int i=0;i<n;i++){
		if(s.at(i)=='L'){
			auto itr = lower_bound(all(r),i) ;
			itr-- ;
			if((i-*itr)&1) ans.at(*itr+1)++ ;
			else ans.at(*itr)++ ;
		}else{
			auto itr = lower_bound(all(l),i) ;
			if((*itr-i)&1) ans.at(*itr-1)++ ;
			else ans.at(*itr)++ ;
		}
	}
	for(int i=0;i<n;i++) cout << ans.at(i) << (i==n-1?"\n":" ") ;
}


Measured memory_bytes: 5112
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

  int D;
  cin>>D;
  
  int C[27];
  int S[366][27];
  int last[366][27];

  for(int d=1;d<=26;d++) cin>>C[d];
  for(int d=1;d<=D;d++){
    for(int i=1;i<=26;i++) cin>>S[d][i];
  }

  for(int d=1;d<=D;d++){
    int maxi,max=-1e9;
    for(int i=1;i<=26;i++){
      int tmp=S[d][i];
      for(int j=1;j<=26;j++){
        if(j!=i) tmp-=C[j]*(d-last[d][j]);
      }
      if(max<tmp){
        max=tmp;
        maxi=i;
      }
    }
    for(int i=1;i<=26;i++) last[d][i]=last[d-1][i];
    last[d][maxi]=d;
    cout<<maxi<<endl;
  }

  return 0;
}

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

int main() {
   int N,T,A;
   cin >> N >> T >> A;
  
   
   double x;
   double d;
   double e=1000;
   int r;
  for(int i=0;i<N;i++){
    cin >> x;
    d=abs((T-0.006*x)-A);
    if(d<e){
      e=d;
      r=i;
    }  
    
  } 
   cout << r+1 << endl;
   
   
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000

typedef struct{
    char name[10];
    int num;
} Card;

int partition(Card A[], int p, int r){
    int i;
    Card x = A[r];
    i = p-1;
    for(int j=p;j<r;j++){
        if(A[j].num<=x.num){
            i = i+1;
            Card tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    Card tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;
    return i+1;

}

void quickSort(Card A[], int p, int r){
    if (p < r){
        int q = partition(A,p,r);
        quickSort(A,p,q-1);
        quickSort(A,q+1,r);
    }
}

Card L[MAX/2+2], R[MAX/2+2];

void merge(Card A[], int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; ++i) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; ++i) {
        R[i] = A[mid + i];
    }
    L[n1].num = R[n2].num = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; ++k) {
        if(L[i].num <= R[j].num){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(Card A[], int n, int left, int right){
    if(left+1 < right){
        int mid = (left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int main(){

    Card A[MAX];
    Card B[MAX];
    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> A[i].name >> A[i].num;
        strcpy(B[i].name, A[i].name);
        B[i].num = A[i].num;
    }

    mergeSort(A,n,0, n);
    quickSort(B,0,n-1);

    int fl = 0;


    for(int i= 0;i < n; i++){
        if(strcmp(A[i].name, B[i].name)!=0)
        {
            fl = 1;
            break;
        }
    }

    if(fl==1) cout << "Not stable" << endl;
    else cout << "Stable" << endl;


    for (int i = 0; i < n; ++i) {
        cout << B[i].name << " " << B[i].num << endl;
    }


    return 0;
}


Measured memory_bytes: 7792
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	
	ll n,a,b;
	cin >> n >> a >> b;
	ll ans;
	ans=(n/(a+b))*a;
	ll x=(n%(a+b));
	if(x>=a){
		ans+=a;
	}
	else{
		ans+=x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    static void Main()
    {
        int n;
        int m;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            m = int.Parse(words[1]);
        }

        int[] cards = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                cards[i] = int.Parse(words[i]);
            }
        }
        Array.Sort(cards);

        Tuple<int, int>[] changes = new Tuple<int, int>[m];
        {
            for (int i = 0; i < m; i++)
            {
                var line = Console.ReadLine();
                var words = line.Split(' ');
                changes[i] = Tuple.Create(int.Parse(words[0]), int.Parse(words[1]));
            }
        }
        changes = changes.OrderByDescending(c => c.Item2).ToArray();

        int index = 0;
        for (int i = 0; i < m; i++)
        {
            var change = changes[i];
            int num = change.Item2;
            int count = change.Item1;
            for (int j = 0; j < count; j++)
            {
                if (cards[index] < num)
                {
                    cards[index] = num;
                    index++;
                }
                if (index == n)
                {
                    break;
                }
            }
            if (index == n || cards[index] >= num)
            {
                break;
            }
        }

        long answer = 0;
        for (int i = 0; i < n; i++)
        {
            answer += cards[i];
        }
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 32832
n,m = map(int,input().split())
h = list(map(int,input().split()))
c = [0]*(n)
for i in range(m):
  a,b = map(int,input().split())
  if h[a-1] > h[b-1]:
    c[b-1] += 1
  elif h[a-1] < h[b-1]:
    c[a-1] += 1
  else:
    c[a-1] += 1
    c[b-1] += 1
print(c.count(0))

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

int main(){
    string S;
    cin >> S;
    string x = "";
    rep(i,S.size()){
        x += 'x';
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n, k;
  cin >> n >> k;
  vector<ll> d(k);
  vector<vector<ll>> a(k, vector<ll>(200, -1));
  vector<ll> s(n);
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }

  for (int i = 0; i < k; i++) {
    for (int j = 0; j < 200; j++) {
      if (a[i][j] < 0) continue;

      s[a[i][j]]++;
    }
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 0) {
      ans++;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    double n; cin >> n;
    int ans = n/1.08;

    if ((int)(ans*1.08) == n) cout << ans << endl;
    else if ((int)((ans+1)*1.08) == n) cout << ans+1 << endl;
    else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  for(int i=0; i<n; i++){
    cin >> s[i];
  }
  int q;
  cin >> q;
  vector<int> t(q);
  for(int i=0; i<q; i++){
    cin >> t[i];
  }
  int ans=0;
  for(int i=0; i<q; i++){
    int left=0;
    int right=n;
    while(right > left+1){
        int mid = (left+right)/2;
        if(t[i] >= s[mid]){
          left = mid;
        }else if(t[i] < s[mid]){
          right = mid;
        }
    }
    if(s[left] != t[i]) continue;
    ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <cmath>

using namespace std;

int escolhas(int dia, int k);

int n_dias;

int atividades[100001][3];

int pontos[100001][3];

int main(){
    cin >> n_dias;

    for(int i = 1; i <= n_dias; i++){
        cin >> atividades[i][1];
        cin >> atividades[i][2];
        cin >> atividades[i][3];
    }

    for(int i = 1; i <= n_dias; i++){
        for(int j = 1; j <= 3; j++){
            pontos[i][j] = -1;
        }
    }

    int felicidade = escolhas(1, -1);

    cout << felicidade << endl;

    return 0;
}

int escolhas(int dia, int k){
    if(dia == n_dias + 1){
        return 0;
    }

    for(int i = 1; i <= 3; i++){
        if(i != k){
            if(pontos[dia][i] == -1){
                pontos[dia][i] = atividades[dia][i] + escolhas(dia + 1, i);
            }
        }
    }

    int maximo = 0;

    for(int i = 1; i <= 3; i++){
        if(i != k){
            if(pontos[dia][i] > maximo){
                maximo = pontos[dia][i];
            }
        }
    }

    return maximo;
}

Measured memory_bytes: 8832
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
//#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {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;}

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

const int N = 2e5 + 1;
int n , m, k , q;
string s;
bool check(int m){
	map < string , int > vc;
	for(int i = 0 ; i + m <= sz(s) ; i++){
		string tmp = s.substr(i,m);
		if(vc.count(tmp)){
			if(vc[tmp] < i)
				return true;
		}else vc[tmp] = i + m - 1;
			
	}
	return false;	
}
main(){
	cin >> n;
	cin >> s;
	int l = 1 , r = sz(s) , res = 0;
	while(l <= r){
		int m = (l + r) >> 1;
		if(check(m))
			res = m , l = m + 1;
		else r = m - 1;
	}
	cout << res ;
}

Measured memory_bytes: 6672
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

const int LIM = 2e5 + 5;

int n, dsu[LIM], a[LIM], b[LIM];
long long ans;
std::map<int, int> map;
std::queue<int> q;

int root(int x)
{
	if (dsu[x] <= 0) return x;
	else return dsu[x] = root(dsu[x]);
}

void merge(int x, int y)
{
	x = root(x); y = root(y);
	if (x != y)
	{
		if (dsu[x] < dsu[y])
			std::swap(x, y);
		dsu[y] += dsu[x];
		dsu[x] = y;	
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	
	std::sort(b + 1, b + n + 1);
	for (int i = 1; i <= n; ++i)
		map[b[i]] = i;
	for (int i = 1; i <= n; ++i)
		a[i] = map[a[i]];
	a[n + 1] = n + 1;
	
	memset(dsu, 0xff, sizeof(dsu));
	for (int i = 1; i <= n; ++i)
		q.push(a[i]);
		
	for (int i = 1; i <= n; ++i)
	{
		int s = root(q.front()); q.pop();
		while (root(i) != root(s))
		{
			merge(s, q.front());
			q.pop();
		}
		ans -= ++dsu[root(s)];
//		printf("%d -> %d\n", i, -dsu[root(s)]);
		q.push(root(s));
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 15160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 200090
#define INF 0x3f3f3f3f
#define ls (now << 1)
#define rs (now << 1 | 1)
#define mid (l + r >> 1)

int n , x[MAX] , att[MAX];
struct N{
	int sml[2];
	PII val[2];
} st[MAX * 4];
N pull(N l , N r){
	N ans;
	ans.sml[0] = min(l.sml[0] , r.sml[0]);
	ans.sml[1] = min(l.sml[1] , r.sml[1]);

	ans.val[0] = min(l.val[0] , r.val[0]);
	ans.val[0] = min(ans.val[0] , mp(l.sml[0] , r.sml[1]));

	ans.val[1] = min(l.val[1] , r.val[1]);
	ans.val[1] = min(ans.val[1] , mp(l.sml[1] , r.sml[0]));
	return ans;
}
void build(int now , int l , int r){
	if(l == r){
		st[now].val[0] = st[now].val[1] = mp(INF , INF);
		if(l % 2 == 0) st[now].sml[0] = x[l] , st[now].sml[1] = INF;
		if(l % 2 == 1) st[now].sml[0] = INF , st[now].sml[1] = x[l];
	}
	else {
		build(ls , l , mid + 0);
		build(rs , mid + 1 , r);
		st[now] = pull(st[ls] , st[rs]);
	}
}
N query(int now , int l , int r , int ql , int qr){
	if(ql <= l && r <= qr) return st[now];
	else if(qr <= mid + 0) return query(ls , l , mid + 0 , ql , qr);
	else if(mid + 1 <= ql) return query(rs , mid + 1 , r , ql , qr);
	return pull(query(ls , l , mid + 0 , ql , qr) , query(rs , mid + 1 , r , ql , qr));
}
priority_queue<PII , vector<PII> , greater<PII>> pq;
vector<int> ans;
set<int> use;

PII query(int l , int r){
	assert(l <= r);
	if(l % 2 == 0) return query(1 , 1 , n , l , r).val[0];
	if(l % 2 == 1) return query(1 , 1 , n , l , r).val[1];
}
void add(int l , int r){
	// DB4("add = " , l , r , "");
	if(l <= r) pq.emplace(query(l , r));
}
int32_t main(){
	IOS;
	cin >> n;
	REP(i , 1 , n + 1) cin >> x[i] , att[x[i]] = i;
	build(1 , 1 , n);

	// DBGG(st[1].val[0].A , st[1].val[0].B);
	// DBGG(st[1].val[1].A , st[1].val[1].B);
	add(1 , n);
	use.insert(0);
	use.insert(n + 1);

	REP(i , 1 , n / 2 + 1){
		assert(pq.size() != 0);
		PII now = pq.top(); pq.pop();
		ans.pb(now.A) , ans.pb(now.B);
		int v1 = att[now.A] , v2 = att[now.B];
		use.insert(v1) , use.insert(v2);
		add(v1 + 1 , v2 - 1);
		add((*prev(use.find(v1))) + 1 , v1 - 1);
		add(v2 + 1 , (*next(use.find(v2))) - 1);
	}
	for(auto to : ans) cout << to << " " ; cout << endl;
    return 0;
}


Measured memory_bytes: 32364
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;

ll N, ookisa[2000];
ll dp[2000][2000];

int conv(int a) {
	if (a < 0)return a + N;
	if (a >= N)return a - N;
	return a;
}

ll solve(int l, int r) {

	if (dp[l][r] != 0)return dp[l][r];

	if (r - l == 0 || (r == 0 && l == N - 1))return dp[l][r] = ookisa[l];
	if (r - l == 1 || (r == 0 && l == N - 2) || (r == 1 && l == N - 1))return dp[l][r] = max(ookisa[l], ookisa[l + 1]);

	ll res = 0;
	ll hidari = 0, migi = 0;
	//use left peace
	if (ookisa[conv(l + 1)] > ookisa[r])hidari = solve(conv(l + 2), r) + ookisa[l];
	else hidari = solve(conv(l + 1), conv(r - 1)) + ookisa[l];

	//use right peace
	if (ookisa[conv(r - 1)] > ookisa[l])migi = solve(l, conv(r - 2)) + ookisa[r];
	else migi = solve(conv(l + 1), conv(r - 1)) + ookisa[r];

	return dp[l][r] = max(hidari, migi);
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> ookisa[i];

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, solve(i, conv(i - 1)));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 34412
A,B=gets.split.map &:to_i
K=35
M=K.times.map{'#'*(2*K)}+K.times.map{'.'*(2*K)}
(A-1).times{|i|M[i/K*2][i%K*2]='.'}
(B-1).times{|i|M[2*K-1-i/K*2][i%K*2]='#'}
puts [2*K,2*K]*' '
puts M

Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>

using namespace std;

char s[1005];

int main()
{
    int n = 0;
    scanf("%s", s);
    for(int i = 0; i <= 3; i ++)
    {
        if(s[i] == '+')
            n++;
        else
            n--;
    }
    printf("%d", n);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;



int main(){
    int n;
    cin>>n;
    int x[n],y[n];
    pan(i,n) {
        cin>>x[i]>>y[i];
    }
    double ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            // cout<<sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]))<<endl;
            ans+=sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
        }
    }
    // cout<<ans<<endl;
    double f=(double)2/n;
    // cout<<f<<endl;
    ans=ans*f;
    cout<<fixed<<setprecision(10)<<ans;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
total = sum(a)
div = 4 * m
limit = total / div
a.sort()
a.reverse()
ans = True
for i in range(m):
    if a[i] < limit:
        ans = False
        break

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
ll n,m,i,j,k,l,t,arr[sz];
int main()
{
    char c[123];
    scanf("%s",&c);
    n=strlen(c);
    for(i=0;i<n;i++)
    {
        if(c[i]!=c[n-1-i])
            k++;
    }
    if(k)
    {
        printf("No\n");
        return 0;
    }
    k=(n-1)/2;
    for(i=0;i<k;i++)
    {
        if(c[i]!=c[k-1-i])
            l++;
    }
    if(l)
    {
        printf("No\n");
        return 0;
    }
    l=((n+3)/2)-1;
    for(i=l;i<n;i++)
    {
        if(c[i]!=c[n-1-i+l])
            m++;
    }
    if(m)
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
grid = 3.times.map { gets.split.map(&:to_i) }

0.upto(grid[0][0]) do |b1|
  a1 = grid[0][0] - b1

  0.upto(grid[1][1]) do |b2|
    a2 = grid[1][1] - b2

    next if a1 + b2 != grid[0][1]
    next if a2 + b1 != grid[1][0]

    0.upto(grid[2][2]) do |b3|
      a3 = grid[2][2] - b3

      next if a1 + b3 != grid[0][2]
      next if a2 + b3 != grid[1][2]
      next if a3 + b1 != grid[2][0]
      next if a3 + b2 != grid[2][1]

      puts 'Yes'
      exit
    end
  end
end

puts 'No'


Measured memory_bytes: 1788
n = int(input())
a = list(map(int, input().split()))

a_even = [elm_a for i, elm_a in enumerate(a) if i % 2 == 0]
a_odd = [elm_a for i, elm_a in enumerate(a) if i % 2 == 1]

ans = a_even[::-1] + a_odd
if n % 2 == 0:
  ans = ans[::-1]

print(' '.join(map(str, ans)))

Measured memory_bytes: 31172
#include<stdio.h>
int main(){
  int n,i,j,k,b;
  char s[1010][1110]={};
  while(scanf("%d",&n),n){
    char s[1010][1110]={};
    for(i=0;i<n;i++)scanf("%s",s[i]);
    for(i=0;i<n;i++){
      for(j=0;s[i][j]=='.';j++)s[i][j]=' ';
      if(j)s[i][j-1]='+';
    }
    for(j=0;j<n;j++){
      b=-1;
      for(i=0;i<n;i++){
	if(s[i][j]-'+'&&s[i][j]-' ')b=-1;
	if(s[i][j]-'+')continue;
	if(b>-1){
	  for(k=b+1;k<i;k++)s[k][j]='|';
	}
	b=i;
      }
    }
    for(i=0;i<n;i++)printf("%s\n",s[i]);
  }
  return 0;
}

Measured memory_bytes: 1688
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
int A[301][301];
int S[301];
bool check[301];
int main(){
    cin>>N>>M;
    REP(i,N){
        REP(j,M){
            cin>>A[i][j];
            A[i][j]--;
        }
    }
    REP(i,M){
        S[i]=0;
        check[i]=false;
    }
    int ans=10000000;
    while(1){
      bool c=true;
      REP(i,M){
          if(check[i]==false)c=false;
          S[i]=0;
      }
      if(c)break;
      REP(i,N){
          REP(j,M){
              if(check[A[i][j]]==false){
                 S[A[i][j]]++;
                 break;
              }
          }
      }
      int a=0;
      int now=-1;
      REP(i,M){
          if(a<S[i]){
             a=S[i];
             now=i;
          }
      }
      check[now]=true;
      ans=min(ans,a);
    }
    cout<<ans<<endl;
    return(0);
}

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

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


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

const az = "ABCDEFGHIJKLMNOPQRSTUVWXYZA"

func main() {
	var S string
	var N int
    var ind int

	fmt.Scan(&N)
	fmt.Scan(&S)

    SS := strings.Split(S, "")

	for i, c := range S {
        ind = (strings.Index(az, string(c)) + N )%26
        SS[i] = string([]rune(az[ind:ind+1])[0])
	}
    fmt.Println(strings.Join(SS, ""))
}



Measured memory_bytes: 1024
from collections import defaultdict 
import sys
import heapq
sys.setrecursionlimit(10**8)

def Find(x):	#xの根を返す
	global table

	if table[x] == x:
		return x
	else:
		table[x] = Find(table[x])	#親の更新(根を直接親にして参照距離を短く)
		return table[x]

def Union(x,y):	#xとyを繋げる
	x = Find(x)	
	y = Find(y)
	
	if x == y:
		return
	
	if rank[x] > rank[y]:
		table[y] = x
	else:
		table[x] = y
		if rank[x] == rank[y]:
			rank[y] += 1

def Check(x,y):
	if Find(x) == Find(y):
		return True
	else:
		return False


		
#N:頂点数 E:辺数 
N = int(input())

#Union-Find
table = [i for i in range(N)]	#木の親 table[x] == x なら根	
rank  = [1 for i in range(N)]	#木の長さ

# 優先度付きキューの作成
q = []
heapq.heapify(q)


rout = []

for i in range(N):
	x,y = list(map(int,input().split()))
	rout.append([i,x,y])
	
# y順ソートルート
rout.sort(key=lambda x:x[2])
for i in range(N-1):	
	n1,x1,y1 = rout[i]
	n2,x2,y2 = rout[i+1]
	w = y2 - y1
	heapq.heappush(q,[w,n1,n2])


# x順ソートルート
rout.sort(key=lambda x:x[1])
for i in range(N-1):	
	n1,x1,y1 = rout[i]
	n2,x2,y2 = rout[i+1]
	w = x2 - x1
	heapq.heappush(q,[w,n1,n2])

	

#総コスト	
weight = 0


while q:
	w,a,b = heapq.heappop(q)
	
	if not Check(a,b):
		weight += w
		Union(a,b)
		
print(weight)

Measured memory_bytes: 55096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  string B = "B";
  for (int i=0; i<2; i++){
    cin >> s;
    B += s.at(0);
  }
  cout << "A" << B.at(2) << "C" << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> power(31);

bool sameline(ll a, ll b, int k){
    ll line1=(a-1)/power[k-1];
    ll line2=(b-1)/power[k-1];
    if(line1==line2&&line1%3==1)return true;
    return false;
}

bool otherside(ll a, ll b, int k){
    ll line1=(a-1)/power[k-1];
    ll line2=(b-1)/power[k-1];
    if(line2-line1>1)return true;
    return false;
}

ll min_path(ll a,ll b, ll c,ll d){
    ll x1,x2,y1,y2;
    if(abs(a-c)<abs(b-d)){
        x1=min(a,c);
        x2=max(a,c);
        y1=min(b,d);
        y2=max(b,d);
    }else{
        x1=min(b,d);
        x2=max(b,d);
        y1=min(a,c);
        y2=max(a,c);
    }
    for (int k = 30; k > 0 ; k--){
        if(sameline(x1,x2,k)){
            if(otherside(y1,y2,k)){
                ll upl=(x1-1)%power[k-1]+1;
                ll upr=(x2-1)%power[k-1]+1;
                ll downl=power[k-1]-upl+1;
                ll downr=power[k-1]-upr+1;
                return min(upl+upr,downl+downr)+y2-y1;
            }
        }
    }
    return x2-x1+y2-y1;
}
int main() {
    power[0]=1;
    for (int i = 1; i <= 30; i++){
        power[i]=3*power[i-1];
    }
    int Q;
    cin>>Q;
    for (int i = 0; i < Q; i++){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<min_path(a,b,c,d)<<endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main()
{
	char a[100], b[100], c[100];
	scanf("%s %s %s", a, b, c);
	if (a[strlen(a) - 1] == b[0] && b[strlen(b) - 1] == c[0])
		puts("YES");
	else puts("NO");
	return 0;
}


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

void fnInput(vector<int>& rvnBall, int& rnVarie)
{
  int nBallSiz;
  cin >> nBallSiz >> rnVarie;

  rvnBall.resize(nBallSiz);
  for (int& rnBall : rvnBall)
    cin >> rnBall;
}

int fnRewCount(const vector<int>& cnrvnBall, int nVarie)
{
  map<int, int> mpBall;

  for (int nBall : cnrvnBall)
    mpBall[nBall]++;

  vector<int> vnNum;
  for (pair<const int, int> PBall : mpBall)
    vnNum.push_back(PBall.second);

  int nRewCnt = 0;
  sort(begin(vnNum), end(vnNum), greater<int>());
  if (vnNum.size() <= nVarie)
    nRewCnt = 0;
  else
    for (int i = nVarie; i < vnNum.size(); i++)
      nRewCnt += vnNum[i];

  return nRewCnt;
}

int main()
{
  vector<int> vnBall;
  int nVarie;
  fnInput(vnBall, nVarie);
  cout << fnRewCount(vnBall, nVarie) << endl;

  return 0;
}


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

int sum(int n){
  int sum = 0;
  
  while(n > 0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  
  if (sum(n) == 1){
    cout << 10 << endl;
  }
  else {
    cout << sum(n) << endl;
  }
}


Measured memory_bytes: 256
#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
#define endl "\n"

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 T> ostream& operator<<(ostream& s,const multiset<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 EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll sum=0;
	rep(i,n){
		cin>>a[i];
		if(i%2==0) sum+=a[i];
		else sum-=a[i];
	}
	sum/=2;
	rep(i,n){
		cout<<2*sum<<endl;
		sum=a[i]-sum;
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int N, M, Q;
vector<int> a(55), b(55), c(55), d(55);

void func(deque<int>& A, int& ans) {
	if (A.size() >= N) {
		int tmp = 0;
		for (int i = 0; i < Q; ++i) {
			if (A[b[i]] - A[a[i]] == c[i]) { tmp += d[i]; }
		}
		ans = max(ans, tmp);
		return;
	}
	
	int a = (A.empty() ? 1 : A.back());
	for (int i = a; i <= M; ++i) {
		A.emplace_back(i);
		func(A, ans);
		A.pop_back();
	}
}

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

	int ans = 0;
	deque<int> A;
	func(A, ans);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;

int main(){
    int n;
    double r, sum=0;
    string s;
    cin>>n;
    
    for(int i=0; i<n; i++){
        cin>>r>>s;
        if(s=="BTC")r*=380000;
        sum+=r;
    }
    cout<<fixed<<setprecision(5)<<sum<<endl;
}


Measured memory_bytes: 256
import math
N,D=map(int,input().split())

xlist=[]
for i in range(N):
  x=list(map(int,input().split()))
  xlist.append(x)
  
#print(xlist)
answer=0
for i in range(0,N-1):
  x1=xlist[i]
  for j in range(i+1,N):
    x2=xlist[j]
    
    dist2=0
    for d in range(D):
      dist2+=(x2[d]-x1[d])**2
      
    dist=math.sqrt(dist2)
    if int(dist) == dist:
      answer += 1
      
print(answer)


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

using namespace std;

int main()
{
    unsigned long long n,m,mi,ma;
    scanf("%lld %lld",&n,&m);
    mi=min(n,m);
    ma=max(n,m);
    if(mi==1)
    {
        if(ma>=2)printf("%lld\n",ma-2);
        else printf("1\n");
    }
    else if(mi==2) printf("%d\n",0);
    else printf("%lld\n",(n-2)*(m-2));
    return 0;
}


Measured memory_bytes: 256