akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int h,m,h2,m2,k;
    cin >> h >> m >> h2 >> m2 >> k;
    int time = abs((60*h+m)-(60*h2+m2));
    int ans = time-k;
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 210000;

int n, col[N], ans[N];
vector<int> to[N], pos[2], rem[3];

inline void addEdg(int x, int y) {
	to[x].push_back(y), to[y].push_back(x);
	return;
}

void dfs(int now, int fa) {
	pos[col[now] = col[fa] ^ 1].push_back(now);
	for (auto &v : to[now]) {
		if (v == fa) continue;
		dfs(v, now);
	}
	return;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	int x, y;
	read(n);
	for (R int i = 1; i < n; ++i) read(x), read(y), addEdg(x, y);
	for (R int i = 1; i <= n; ++i)
		rem[i % 3].push_back(i);
	dfs(1, 0);
	if (pos[0].size() <= rem[0].size()) {
		while (pos[0].size()) {
			ans[pos[0].back()] = rem[0].back();
			pos[0].pop_back(), rem[0].pop_back();
		}
		for (R int i = 0; i <= 2; ++i) {
			while (rem[i].size()) {
				ans[pos[1].back()] = rem[i].back();
				pos[1].pop_back(), rem[i].pop_back();
			}
		}
	}
	else if (pos[1].size() <= rem[0].size()) {
		while (pos[1].size()) {
			ans[pos[1].back()] = rem[0].back();
			pos[1].pop_back(), rem[0].pop_back();
		}
		for (R int i = 0; i <= 2; ++i) {
			while (rem[i].size()) {
				ans[pos[0].back()] = rem[i].back();
				pos[0].pop_back(), rem[i].pop_back();
			}
		}
	}
	else {
		while (rem[1].size()) {
			ans[pos[1].back()] = rem[1].back();
			pos[1].pop_back(), rem[1].pop_back();
		}
		while (rem[2].size()) {
			ans[pos[0].back()] = rem[2].back();
			pos[0].pop_back(), rem[2].pop_back();
		}
		for (R int i = 0; i <= 1; ++i) {
			while (pos[i].size()) {
				ans[pos[i].back()] = rem[0].back();
				pos[i].pop_back(), rem[0].pop_back();
			}
		}
	}
	for (R int i = 1; i <= n; ++i) printf("%d ", ans[i]);
	return 0;
}

Measured memory_bytes: 20888
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Long[] a = new Long[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextLong();
			}
			
			long count = 0;
			for (long num : a) {
				while (num % 2 == 0) {
					num /= 2;
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 36068
from collections import Counter
inputs = ''
while True:
    try:
        inputs += input()
    except:
        break


ss = []
s = [x.strip('.') for x in inputs.split()]
for si in s:
    ss += list(si.lower())

cnt = Counter(ss)

for i in range(97, 123):
    print('{} : {}'.format(chr(i), cnt[chr(i)]))




Measured memory_bytes: 5968
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char a, b;
int main(void) {
    cin >> a >> b;
    if (a == '9' || b == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 H, W;
  cin >> H >> W;
  vvi A(H, vi(W));
  cin >> A;

  i64 ans_n = 0;
  vvi ans;

  rep(h,H){
    rep(w,W){
      i64 w_ = w;
      i64 hn, wn;
      if(h%2==1){
        w_ = W - 1 - w_;
        if(w_==0){
          wn = w_;
          hn = h+1;
        } else {
          wn = w_-1;
          hn = h;
        }
      } else {
        if(w_==W-1){
          wn = w_;
          hn = h+1;
        } else {
          wn = w_+1;
          hn = h;
        }
      }
      if(hn==H) break;
      if(A.at(h).at(w_)%2) {
        ans_n++;
        vi x;
        x.emplace_back(h+1);
        x.emplace_back(w_+1);
        x.emplace_back(hn+1);
        x.emplace_back(wn+1);
        ans.emplace_back(x);
        A[h][w_]--;
        A[hn][wn]++;
      }
    }
  }
  cout << ans_n << "\n";
  for(auto &p:ans){
    cout << p << "\n";
  }
}

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

Measured memory_bytes: 12976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
    
int main(){
  int n;
  string s;
  cin >> n;
  vector<ll> v(n); 
  rep(i,n) cin >> v[i];
  priority_queue<ll> pq;
  sort(v.begin(),v.end(),greater<ll>());
  int id = 2;
  ll ans = v[0];
  pq.push(v[1]);
  pq.push(v[1]);
  for (id = 2;id < n;id++){
    ll score = pq.top();pq.pop();
    ans += score;
    pq.push(v[id]);
    pq.push(v[id]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6928
n,m,l = list(map(int, input().split() ))
A = [ [0 for i in range(m)] for j in range(n) ]
B = [ [0 for i in range(l)] for j in range(m) ]
C = [ [0 for i in range(l)] for j in range(n) ]
for i in range(n):
 A[i] = list(map(int, input().split() ))
for i in range(m):
 B[i] = list(map(int, input().split() ))

for ni in range(n):
 for li in range(l):
  for mi in range(m):
   C[ni][li] = C[ni][li] + A[ni][mi] * B[mi][li]
 print(" ".join(map(str, C[ni])) )




Measured memory_bytes: 6912
def main():
    import sys
    from operator import itemgetter
    input = sys.stdin.readline

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

    mod = 998244353
    N = int(input())
    X_raw = [0] * N
    Y_raw = [0] * N
    for i in range(N):
        x, y = map(int, input().split())
        X_raw[i] = x
        Y_raw[i] = y

    val2idx_X = {}
    val2idx_Y = {}
    for i in range(N):
        val2idx_X[X_raw[i]] = i
        val2idx_Y[Y_raw[i]] = i
    X_raw.sort()
    Y_raw.sort()
    X = [0] * N
    Y = [0] * N
    for i in range(N):
        X[val2idx_X[X_raw[i]]] = i+1
        Y[val2idx_Y[Y_raw[i]]] = i+1

    XY = [(x, y) for x, y in zip(X, Y)]
    XY.sort(key=itemgetter(0))

    bit_ul = Bit(N + 2)
    bit_ur = Bit(N+2)
    ul = []
    ur = []
    for x, y in XY:
        ul.append(bit_ul.sum(y))
        ur.append(bit_ur.sum(N+1) - bit_ur.sum(y))
        bit_ul.add(y, 1)
        bit_ur.add(y, 1)

    bit_dl = Bit(N + 2)
    bit_dr = Bit(N + 2)
    dl = []
    dr = []
    for x, y in reversed(XY):
        dl.append(bit_dl.sum(y))
        dr.append(bit_dr.sum(N + 1) - bit_dr.sum(y))
        bit_dl.add(y, 1)
        bit_dr.add(y, 1)
    dl.reverse()
    dr.reverse()

    ans = 0
    two_N = pow(2, N, mod) - 1
    for i in range(N):
        half = ((pow(2, ul[i]+ur[i], mod) + pow(2, dl[i]+dr[i], mod))%mod
                + (pow(2, ul[i]+dl[i], mod) + pow(2, ur[i]+dr[i], mod))%mod)%mod
        qu = ((pow(2, ul[i], mod) + pow(2, ur[i], mod))%mod
              +(pow(2, dl[i], mod) + pow(2, dr[i], mod))%mod)%mod
        ans = ((ans + two_N)%mod + (-half + qu)%mod)%mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 122884
def main():
    n, m, v, p = list(map(int, input().split()))
    a = sorted(list(map(int, input().split())))
    # print(a)

    def value(i):
        if i+p >= n:
            return True
        if a[n-p] > a[i]+m:
            return False
        b = list(reversed([a[i]+m-j for j in a[:i] + a[i+1:n]]))[p-1:]
        #print(b)
        if b[0] < 0:
            return False
        rest = v-n+len(b)
        if rest <= 0:
            return True
        #print(rest)

        c = [min(m, i) for i in b]
        d = [i for i in c][:-rest]
        e = [m-i for i in c][-rest:]
        #print(d, e)
        if sum(d) < sum(e):
            return False
        else:
            return True

    def b_search(a, b, value):
        while a+1 < b:
            med = (a+b)//2
            if value(med):
                b = med
            else:
                a = med+1
        if a == b:
            return a
        else:
            if value(a):
                return a
            else:
                return b

    #print(value(1))

    print(n-b_search(0, n-1, value))


main()

Measured memory_bytes: 135088
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
ll n;
cin >> n;
ll ans = (n/11)*2;
n= n%11;

if(n==0){
    cout << ans << endl;
    return 0;
}
ll a=0;
while(n>=1){
    if(a%2==0){
        n-=6;
        ans++;
    }
    else{
        n-=5;
        ans++;
    }
}
cout << ans << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	if(n>=30)
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;
	
	
	


	
	return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000

void to_bin(char *s, int *res){

  for(int i=0;i<8;i++){
    int t;
    if('0' <= s[i] && s[i] <= '9' )
      t = s[i]-'0';
    else
      t = s[i]-'a' + 10;
    
    for(int j=3;j>=0;j--){
      res[i*4+j] = t%2;
      t/=2;
    }
  }

}

void calc(){
  char s[12];
  int bin[50];

  scanf("%s",s);

  to_bin(s,bin);

  if(bin[0]==1)
    printf("-");

  ll num = 0;

  for(int i=1;i<=24;i++){
    num = num*2 + bin[i];
  }

  printf("%lld",num);

  num = 0;

  for(int i=25;i<32;i++){
    num = num*2 + bin[i];
  }

  num *= 78125;

  printf(".");
  
  if(num > 0){
    
    char s2[50];
    sprintf(s2,"%07lld",num);

    int max_i = 0;

    for(int i=0;i<7;i++){
      if(s2[i]!='0') max_i = i;
    }
    s2[max_i+1] ='\0';

    printf("%s",s2);
  }else{
    printf("0");
  }
  
  printf("\n");
}

int main(){
  int q;

  scanf("%d",&q);
  
  while(q--){
    //scanf("%d",&n);
    //if(n==0) break;
    calc();
  }
  
  return 0;
}

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

int main()
{
	double a, b, c, d, e, f;

	while (cin >> a >> b >> c >> d >> e >> f){
		double x, y;
		x = (c * e - b * f) / (a * e - b * d);
		y = (c - (a * x)) / b;
		
		if (x == -0.000) x = 0.000;
		if (y == -0.000) y = 0.000;

		printf("%.3f %.3f\n", x, y);
	}

	return (0);
}

Measured memory_bytes: 3180
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <stack>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int mini,x,m,n;
vector<int> st;

void func(int id,vector<int>& c, vector<vector<int>>& a);
int judge(vector<vector<int>>& a);

int main(){
    mini=1e9;
    cin >>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));

    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }

    func(n,c,a);
    if(mini==1e9) cout << -1<<endl;
    else cout << mini << endl;

    return 0;
}

void func(int id,vector<int>& c, vector<vector<int>>& a){
    if(id==0){
        int sum=0;
        if(judge(a)==-1) return;
        rep(i,st.size()){
            sum+=c[st[i]];
        }
        chmin(mini,sum);
        return;
    }
    st.push_back(id-1);
    func(id-1,c,a);
    st.pop_back();
    func(id-1,c,a);
    return;
};

int judge(vector<vector<int>>& a){
    vector<int> sum(m);
    rep(i,st.size()){
        rep(j,m){
            sum[j]+=a[st[i]][j];
        }
    }
    rep(i,m){
        if(sum[i]<x){
            return -1;
        }
    }
    return 0;
};

Measured memory_bytes: 3624
# vim: fileencoding=utf-8


def main():
    s = input()
    p = 700
    if s[0] == "o":
        p += 100
    if s[1] == "o":
        p += 100
    if s[2] == "o":
        p += 100
    print(p)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61844
from sys import stdin
import itertools
import math

n = int(stdin.readline().rstrip())
l = [int(x) for x in range(n)]
p = itertools.permutations(l, n)

xy = []
for i in range(n):
    x, y = map(int, input().split())
    xy.append([x, y])

total = 0
for i in p:
    for j in range(n - 1):
        p1 = i[j] - 1
        p2 = i[j + 1] - 1
        dis = math.sqrt((xy[p2][0] - xy[p1][0])**2 +
                        (xy[p2][1] - xy[p1][1])**2)
        total += dis

print(total/math.factorial(n))

Measured memory_bytes: 3064
N, M =list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

memo={}
for a,b in AB:
  #print(a,b)
  memo.setdefault(a, set([])).add(b)
  memo.setdefault(b, set([])).add(a)

answer=0
from itertools import permutations
for p in permutations(list(range(2,N+1))):
  if p[0] not in memo[1]:
    continue
  for i in range(N-2):
    if p[i+1] in memo[p[i]]:
      pass
    else:
      break
  else:
    answer+=1
      
print(answer)                  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int x,d,n;
typedef pair<ll,ll> P;
inline ll sum(int a,int b){
    return 1ll*(a+a+b-1)*b/2;
}
int main(){
    scanf("%d%d%d",&n,&x,&d);
    if(d<0)d=-d,x=-x;
    if(d==0){
        if(x==0)printf("1\n");
        else printf("%d\n",n+1);
    }
    else{
        int g=__gcd(d,x);
        g=abs(g);
        d/=g,x/=g;
        set<P> s;
        ll ans=0;
        for(int i=0;i<d;i++){
            s.clear();
            for(int j=i;j<=n;j+=d){
                //s.insert({1ll*j/d*x+sum(0,j),1ll*j/d*x+sum(n-j,j)+1});
                s.emplace(1LL * j / d * x + sum(0, j), 1LL * j / d * x + sum(n - j, j) + 1);
            }
            ll r=-1e18;
            for(auto p:s){
                ans+=max(0ll,p.second-max(p.first,r));
                r=max(r,p.second);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    double R1, R2, R3;
    cin >> R1 >> R2;
    R3 = R1*R2/(R1+R2);
    cout << fixed << setprecision(10);
    cout << R3 << endl;
}


Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
/*long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[100001]; 

void solve2()
{
   lld p=1000000007;
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}

//vector< vector <lld > > v(100001);
/*
void bfs(lld x , vector<lld>& d)
{
    d[x]=0;
    q.pu(x);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            y=v[x][i];
            if(d[y]==INF) 
            {
                d[y] = d[x]+1;
                q.pu(y);
            }       
        }
    }

}
/*

lld DFS(lld a ,lld x)
{
    visited[a] =true;
    sub_size[a]=1;
 //   if(a==x) 
   //     cont[a] =true;
    lld l= v[a].size();
    for(lld i=0;i<l;i++)
    {
        if(visited[v[a][i]] == false)
        {
            sub_size[a]+= DFS(v[a][i],b);
//            if(cont[v[a][i]] ==true ) cont[a]=true;
        }
    }
    return sub_size[a];

}




*/lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;


void solve()
{
    cin>>x>>y>>z>>k;
    if(k<=x)
    {
        cout<<k;
        return;
    }
    lld ans=x;
    k-=x;
    if(k<=y)

    {
        cout<<ans;
        return;
    }
    k-=y;
    cout<<ans-k;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
       //cin>>t;
       //cout<<t;
 //   solve2();
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n, a, b;
const int N = 100000;
int h[N];

bool check(long long t) {
  long long times = 0LL;
  long long small = t * (long long)b;
  int delta = a - b;
  for (int i = 0; i < n; ++i) {
    if (h[i] <= small) continue;
    int tmp = h[i] - (int)small;
    int bigTime = tmp / delta;
    if (tmp % delta) bigTime++;
    times += bigTime;
    if (times > t) return false;
  }
  return true;
}

int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) cin >> h[i];
  int l = 1, r = 1e9, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (check(mid)) r = mid;
    else l = mid + 1;
  }
  cout << l << endl;
  return 0;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

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

const ll INF = 912345678;

int sn;
int n;

int main()
{
    cin >> n;
    int nn = n;
    while (nn)
    {
        sn += nn % 10;
        nn /= 10;
    }
    if (n % sn)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, total, ans;
    cin >> N;
    vector<int> data(N);
    vector<int> totals(N);

    total = 0;
    rep(i, N){
        int d;
        cin >> d;
        total += d;
        data[i] = d;
        totals[i] = total;
    }
    ans = 0;
    rep(i, N - 1){
        ans += data[i + 1] * totals[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
SP = [input().split() for _ in range(N)]
for k in range(N):
  City = "zzzzzzzzzzzzzz"
  Point = 0
  Num = 0
  for i in range(len(SP)):
    if SP[i][0] < City:
      City = SP[i][0]
  for j in range(len(SP)):
    if SP[j][0] == City and int(SP[j][1]) >= Point:
      Point = int(SP[j][1])
      Num = j
  print(Num+1)
  SP[Num][0] = "zzzzzzzzzzzzzzzzz"
  SP[Num][1] = 0

Measured memory_bytes: 40048
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
    long  K;
    long  N;
    long  A[1000000];
    long  d[1000000]; // d[i] = A[i+1] - A[i] (i != N-1)  // d[N-1] = A[1] + (K- A[N-1])   (i == N-1)
    long  max_d;
    long  ans;

    max_d = 0;

    cin >> K;
    cin >> N;
    cin >> A[0];
    

    for(int i=1; i < N-1; i++){
        cin >> A[i];
        d[i] =  A[i] - A[i-1];
        if(max_d < d[i]){
            max_d = d[i];
        }
    }
    cin >> A[N-1];
    d[N-1] =  A[N-1] - A[N-2];
     if(max_d < d[N-1]){
        max_d =  d[N-1];
    } 
  
    d[0] =  A[0] + (K- A[N-1]);
    if(max_d < d[0]){
        max_d =  d[0];
    }
    ans = K - max_d;

    cout << ans << endl;

    return 0;
}

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

using namespace std;

const long double INF = 1E15;
const int MAXN = 1000;
long double adjMat[MAXN + 3][MAXN + 3];
long double dist[MAXN + 3];
bool visited[MAXN + 3];
tuple<int, int, int> circles[MAXN + 3];

int main()
{
    int xs, ys, xt, yt, n;
    cin >> xs >> ys >> xt >> yt >> n;
    circles[n + 1] = make_tuple(xs, ys, 0);
    circles[n + 2] = make_tuple(xt, yt, 0);
    for (int i = 1; i <= n; i++)
    {
        int x, y, r;
        cin >> x >> y >> r;
        circles[i] = make_tuple(x, y, r);
    }
    for (int i = 1; i <= n + 2; i++)
    {
        for (int j = i + 1; j <= n + 2; j++)
        {
            int dx = abs(get<0>(circles[i]) - get<0>(circles[j]));
            int dy = abs(get<1>(circles[i]) - get<1>(circles[j]));
            long double d = sqrt((long long) dx * dx + (long long) dy * dy) - (get<2>(circles[i]) + get<2>(circles[j]));
            d = max(d, (long double) 0);
            adjMat[i][j] = adjMat[j][i] = d;
        }
    }
    fill(dist + 1, dist + n + 3, INF);
    dist[n + 1] = 0;
    for (int i = 0; i < n + 2; i++)
    {
        long double minDist = INF;
        int u = 1;
        for (int j = 1; j <= n + 2; j++)
        {
            if (!visited[j] && dist[j] < minDist)
            {
                minDist = dist[j];
                u = j;
            }
        }
        for (int j = 1; j <= n + 2; j++)
        {
            dist[j] = min(dist[j], dist[u] + adjMat[u][j]);
        }
        visited[u] = true;
    }
    cout << fixed << setprecision(10) << dist[n + 2] << endl;
    return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    long long count=0;
    if(K%2==1){
        count=pow(N/K,3);
    }
    else{
        int n=2*N/K;
        count+=pow(n/2+n%2,3)+pow(n/2,3);
    }
    cout<<count<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,b;
  cin>>n>>m;
  int a[n]={};
  for(int i=0;i<m;i++){
    cin>>b;
    a[b-1]++;
    cin>>b;
    a[b-1]++;
  }
  for(int i=0;i<n;i++){
    cout<<a[i]<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

vector<LL> parent(MAX);
vector<LL> length(MAX);

void init(LL n){
    for(LL i=0; i<n; i++){
        parent[i]=i;
        length[i]=1;
    }
}

int find(LL x){
    while(parent[x]!=x){
        x=parent[x];
    }
    return x;
}

bool same(LL x, LL y){
    return find(x)==find(y);
}

bool unite(LL x, LL y){
    x=find(x);
    y=find(y);
    if(x==y){
        return false;
    }
    if(length[x]<length[y]){
        swap(x,y);
    }
    parent[y]=x;
    length[x]+=length[y];
    return true;
}

int main(){
    LL n;
    LL m;
    cin >> n >> m;
    vector<LL> p(n);
    vector<vector<LL>> pg(n);
    LL x;
    LL y;
    for(LL i=0; i<n; i++){
        cin >> p[i];
        p[i]--;
    }
    init(n);
    for(LL i=0; i<m; i++){
        cin >> x >> y;
        x--;
        y--;
        unite(x,y);
    }

    for(LL i=0; i<n; i++){
        LL tmp=find(i);
        pg[tmp].push_back(i);
    }

    LL ans=0;
    for(LL i=0; i<n; i++){
        vector<LL> num;
        vector<LL> val; 
        if(pg[i].size()!=0){
            for(LL j=0; j<pg[i].size(); j++){
                num.push_back(pg[i][j]);
                val.push_back(p[pg[i][j]]);
            }
            sort(num.begin(), num.end());
            sort(val.begin(), val.end());
            LL idx_n=0;
            LL idx_v=0;
            while(idx_n<num.size() && idx_v<val.size()){
                if(num[idx_n]<val[idx_v]){
                    idx_n++;
                }else if(num[idx_n]>val[idx_v]){
                    idx_v++;
                }else{
                    ans++;
                    idx_n++;
                    idx_v++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11108
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
pii point[3010];
bool ex[5010][5010];
int main(){
	int n;
	while(cin>>n,n){
		if(n==0)break;
		memset(ex, false, sizeof(ex));
		memset(point, 0, sizeof(point));
		for(int i=0;i < n;i++){
			cin>>point[i].first>>point[i].second;
			ex[point[i].second][point[i].first]=true;
		}
		sort(point,point+n);
		/*rep(i,n){
			printf("(x,y) =(%d,%d)\n",point[i].first,point[i].second);
		}*/
			int ans =0;
			for(int i=0;i < n;i++){
				for(int j=i+1;j < n;j++){
					int dx =abs(point[j].first-point[i].first);
					int dy =abs(point[j].second-point[i].second);
					int tmp =dx*dx+dy*dy;
					if(tmp<=ans)continue;
				/*printf("(x1,y1) =(%d,%d)\n",point[i].first,point[i].second);
				printf("(x2,y2) =(%d,%d)\n",point[j].first,point[j].second);
				printf("(dx,dy) = (%d,%d)\n",dx,dy);*/
				int nx1 =point[j].first+dy;
				int ny1 =point[j].second+dx;

				int nx2 =point[i].first+dy;
				int ny2 =point[i].second+dx;
				//
				int mnx1 =(point[j].first-dy);
				int mny1 =(point[j].second-dx);

				int mnx2 =(point[i].first-dy);
				int mny2 =(point[i].second-dx);
				/*printf("(nx1,ny1) =(%d,%d)\n",nx1,ny1);
				printf("(nx2,ny2) =(%d,%d)\n",nx2,ny2);
				printf("(mnx1,mny2) =(%d,%d)\n",mnx1,mny1);
				printf("(mnx1,mny2) =(%d,%d)\n",mnx2,mny2);
				cout <<endl;*/
				if(nx1<=5000&&ny1<=5000&&nx2<=5000&&ny2<=5000&&
				   ex[ny1][nx1]&&ex[ny2][nx2]){
					ans=max(ans,tmp);
				//cout <<ans<<endl;
				continue;
			}
			if(mnx1>=0&&mny1>=0&&mnx2>=0&&mny2>=0&&
			   ex[mny1][mnx1]&&ex[mny2][mnx2]){
				ans=max(ans,tmp);
		}
	}
}
cout <<ans<<endl;
}
return 0;
}

Measured memory_bytes: 25708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    string s;

    cin >> n >> s;

    if (n == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    int sum[212345];

    sum[0] = 0;

    REP(i, n)
    sum[i + 1] = sum[i] + (s[i] == '.');

    int sum1[212345];
    sum1[n] = 0;

    for (int i = n - 1; i >= 0; i--)
    {
        sum1[i] = sum1[i + 1] + (s[i] == '.');
    }

    int res = INT_MAX;

    REP(i, n)
    {
        int tmp = 0;

        tmp += sum1[i + 1];
        tmp += (i + 1) - sum[i + 1];

        res = min(res, tmp);
    }

    res = min(res, sum[n]);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);
  Cins(ll, n, a);

  map<ll, int> mp;
  mp[0] = 1;

  ll s = 0;
  ll ans = 0;
  for (auto e : a) {
    s += e;
    ans += mp[s];
    mp[s]++;
  }

  cout << ans << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 14336
D = int(input())
cs = list(map(int, input().split()))
ss = [list(map(int, input().split())) for _ in range(D)]

width = 10

def calc(ts):
    last = [-1] * 26
    sat = 0
    for i, t in enumerate(ts):
        sat += ss[i][t-1]
        last[t-1] = i
        sat -= sum(c * (i - l) for c, l in zip(cs, last))       
    return sat

def search(ts):
    last = [-1] * 26
    sat = 0
    for i, t in enumerate(ts):
        sat += ss[i][t-1]
        last[t-1] = i
        sat -= sum(c * (i - l) for c, l in zip(cs, last))
    
    deltas = [-(10 ** 9)]
    i = len(ts)
    for t in range(1, 27):
        tmp = last[t-1]
        last[t-1] = i
        delta = ss[i][t-1] + sum(c * (i - l) for c, l in zip(cs, last))
        last[t-1] = tmp
        deltas.append(sat + delta)

    ls = sorted(enumerate(deltas), key = lambda t: t[1], reverse = True)
    return ls[:width]

#ビームサーチのつもり
best5ts = [[]]
for i in range(D):
    possible_best5ts = []
    possible_sats = []
    for ts in best5ts:
        best5t, sats = map(list, zip(*search(ts)))
        possible_best5ts += [ts + [t] for t in best5t]
        possible_sats += sats
    ls = sorted(enumerate(possible_sats), key = lambda t: t[1], reverse = True)
    best5ts = []
    for i, _ in ls[:width]:
        best5ts.append(possible_best5ts[i])

ts = best5ts[0]

print(*ts, sep = '\n')
#print(calc(ts))


Measured memory_bytes: 105052
import java.util.*;

public class Main {
    static int MOD = 1000000007;
	static int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        System.out.println(t+s);
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n,s=0;

	std::cin >> n;

	vector<bool> a(n + 1,false);
	repeq(i, 1, n) {
		a[i] = true;
		s += i;
		if (s > n) {
			a[s - n] = false;
			break;
		}
	}
	repeq(i, 1, n) {
		if (a[i]) {
			outn(i);
		}
	}

	return 0;
}


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

int main() {
  long s;
  cin >> s;
  long z = s;
  int n=0; //桁数
  while (z>0){
    z /= 10;
    n++;
  }
  vector<int> vec(n);
  for (int i=0; i<n; i++){
    vec.at(i) = s%10;
    s/=10;
  }
  reverse(vec.begin(), vec.end());
  int ans = abs(100*vec.at(0)+10*vec.at(1)+vec.at(2) - 753);
  for (int i=1; i<n-2; i++){
    if (abs(100*vec.at(i)+10*vec.at(i+1)+vec.at(i+2) - 753) < ans){
      ans = abs(100*vec.at(i)+10*vec.at(i+1)+vec.at(i+2) - 753);
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,a,b,c,d = map(int,input().split(" "))
s = input()
ans = ""
if c > b:
    if "##" in s[a-1:c] or "##" in s[b-1:d]:
        ans = "No"
    elif c > d and not("..." in s[b-2:d+1]):
        ans = "No"
    else:
        ans = "Yes"
else:
    if "##" in s[a-1:c] or "##" in s[b-1:d]:
        ans = "No"
    else:
        ans = "Yes"

print(ans)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 505

int V,E;
int root = 0;
int POW[20],pow_max = 0;
bool can_visit[20][SIZE][SIZE],check[2][SIZE];


bool isOK(int count){

	int CURRENT = 0,NEXT = 1;
	for(int i = 0; i < V; i++){
		check[CURRENT][i] = false;
		check[NEXT][i] = false;
	}

	bool FLG;

	check[CURRENT][root] = true;

	for(int i = pow_max; i >= 0; i--){
		if(POW[i] > count)continue;
		count -= POW[i];

		for(int k = 0; k < V; k++){
			if(!check[CURRENT][k])continue;


			for(int p = 0; p < V; p++){
				if(can_visit[i][k][p]){

					check[NEXT][p] = true;
				}
			}
		}

		FLG = true;
		for(int k = 0; k < V; k++){
			if(!check[NEXT][k]){
				FLG = false;
				break;
			}
		}

		if(FLG)return true;

		swap(CURRENT,NEXT);
		for(int k = 0; k < V; k++){

			check[NEXT][k] = false;
		}
	}

	return false;
}


int main(){

	scanf("%d %d",&V,&E);

	POW[0] = 1;
	for(int i = 1; i <= 19; i++){

		POW[i] = POW[i-1]*2;
	}

	for(int i = 0; i <= 19; i++){
		if(POW[i] > V*V+(V+5)){
			pow_max = i;
			break;
		}
	}

	for(int i = 0; i <= pow_max; i++){
		for(int from = 0; from < V; from++){
			for(int to = 0; to < V; to++){

				can_visit[i][from][to] = false;
			}
		}
	}

	int from,to;
	for(int loop = 0; loop < E; loop++){

		scanf("%d %d",&from,&to);
		from--;
		to--;
		can_visit[0][from][to] = true;
	}

	for(int i = 1; i <= pow_max; i++){
		for(int a = 0; a < V; a++){
			for(int b = 0; b < V; b++){
				if(!can_visit[i-1][a][b])continue;
				for(int c = 0; c < V; c++){
					if(!can_visit[i-1][b][c])continue;
					can_visit[i][a][c] = true;
				}
			}
		}
	}

	int left = 0,right = V*V+V+5,mid = (left+right)/2;
	int ans = BIG_NUM;

	while(left <= right){

		if(isOK(mid)){

			ans = mid;
			right = mid-1;
		}else{

			left = mid+1;
		}
		mid = (left+right)/2;
	}

	if(ans == BIG_NUM){

		printf("-1\n");
	}else{

		printf("%d\n",ans);
	}

	return 0;
}



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


#define ll long long


//gcdやり直す

void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}




/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}





/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);
  /*
  Yarudake Olympic in Japan 2020
  */

  int ans=0;
  for(int i=1;i<=n;i++){
    int a;
    scanf("%d",&a);
    if(i%2==1 && a%2==1){
      ans++;
    }
  }

  printf("%d\n",ans);
}

Measured memory_bytes: 1728
#include <cstdio>
#include <iostream>
#include <algorithm>
#define SENTINEL 2e9
using namespace std;
  
long long  cnt;
void Merge(int* A, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int *L,*R;
  L = new int[n1+1]; R=new int[n2+1];
  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] = SENTINEL;
  R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for(int k = left; k < right; k++){
    if(L[i] <= R[j]){
        A[k] = L[i];
        i = i + 1;
    } else {
        cnt += n1-i;
        A[k] = R[j];
        j = j + 1;
    }
  }
}
  
void Merge_Sort(int* A, int left, int right){
  if(left+1 < right){
    int mid = (left + right)/2;
    Merge_Sort(A, left, mid);
    Merge_Sort(A, mid, right);
    Merge(A, left, mid, right);
  }
}
           
int main(){
    int *a;
    int n;
    cnt = 0;
    scanf("%d",&n);
    a = new int[n];
    for(int i=0;i<n;i++){
        scanf(" %d",&a[i]);
    }
    Merge_Sort(a, 0, n);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 27432
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair<int, int> ii;
int main() {
	int r, c;
	scanf("%d %d", &r, &c);
	char grid[r][c];
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) scanf(" %c", &grid[i][j]);
	}
	int sp[r][c];
	sp[0][0] = (grid[0][0] == '#');
	for (int i = 1; i < c; ++i) {
		if (grid[0][i - 1] == '.' && grid[0][i] == '#') sp[0][i] = sp[0][i - 1] + 1;
		else sp[0][i] = sp[0][i - 1];
	}
	for (int i = 1; i < r; ++i) {
		if (grid[i - 1][0] == '.' && grid[i][0] == '#') sp[i][0] = sp[i - 1][0] + 1;
		else sp[i][0] = sp[i - 1][0];
	}
	for (int i = 1; i < r; ++i) {
		for (int j = 1; j < c; ++j) sp[i][j] = min(sp[i - 1][j] + (grid[i - 1][j] == '.' && grid[i][j] == '#'), sp[i][j - 1] + (grid[i][j - 1] == '.' && grid[i][j] == '#'));
	}
	printf("%d", sp[r - 1][c - 1]);
	return 0;
}

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

using lint = int64_t;
#define bit(n) ((lint)1 << n);
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
        cerr << fixed << setprecision(12);
    }
} iosetup;

int main() {
    int n;
    cin >> n;
    vector<lint> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    vector<lint> minus, plus;
    for (int i = 1; i < n - 1; i++) {
        if (a[i] < 0) {
            minus.push_back(a[i]);
        } else {
            plus.push_back(a[i]);
        }
    }

    lint ans = a[0];
    vector<pair<lint, lint>> anss;
    for (int i = 0; i < plus.size(); i++) {
        anss.push_back({ans, plus[i]});
        ans -= plus[i];
    }
    anss.push_back({a[n - 1], ans});
    ans = a[n - 1] - ans;
    for (int i = 0; i < minus.size(); i++) {
        anss.push_back({ans, minus[i]});
        ans = ans - minus[i];
    }

    cout << ans << endl;
    for (int i = 0; i < anss.size(); i++) {
        cout << anss[i].first << ' ' << anss[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5872
#include <stdio.h>

void show(long i)
{
	if (i / 26 != 0) {
		show((i / 26) - 1);
	}
	long amari = i % 26;
	printf("%c", (char) amari + 'a');
}

int main () {
	long N;
	scanf("%ld", &N);
	show(N - 1);
	printf("\n");
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{
    int i, j, n, m, tmp, p, a[100];

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

    // sort
    for (i=0; i<n-1; i++) {
        m=i;
        for (j=i+1; j<n; j++) {
            if (a[j]>a[m]) m=j;
        }
        tmp=a[i]; a[i]=a[m]; a[m]=tmp;
    }

    p=0;
    for (i=0; i<n; i++) {
        if (i%2==0) p += a[i];
        else        p -= a[i];
    }

    printf("%d\n", p);

    return 0;
}

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

int main(){
	int a, b, c, ans = 0;
	cin >> a >> b >> c;

	while(true){
		if(a % 2 || b % 2 || c % 2){
			cout << ans << endl;
			return 0;
		}

		if(a == b && b == c){
			cout << -1 << endl;
			return 0;
		}

		int A = a, B = b, C = c;
		a = B / 2 + C / 2;
		b = A / 2 + C / 2;
		c = A / 2 + B / 2;

		ans++;
	}

	return 0;
}


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


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  string s ;
  int k ;
  cin >> n >> s >> k ;
  char ch = s.at(k-1) ;
  REP(i,n){
    if(s.at(i)!=ch){
      s.at(i) = '*' ;
    }
  }
  cout << s <<endl ;


  return 0 ;
}




Measured memory_bytes: 256
require 'bigdecimal'
input = STDIN.read.split("\n")
input.shift.to_i.times.map do
  x1, y1, x2, y2, x3, y3, x4, y4 = input.shift.chomp.split.map { |e| BigDecimal.new(e) }
  if y1 == y2 && y3 == y4
    puts 'YES'
    next
  end
  ab = (y2 - y1) / (x2 - x1)
  cd = (y4 - y3) / (x4 - x3)
  puts(ab == cd ? 'YES' : 'NO')
end

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

int main(){
  string s,ans;
  cin >> s;
    for(int i=0;i<s.length();i++){
      char t=s[i];
      if(t=='B' && !ans.empty()){
        ans.pop_back();
      }
      else if(t!='B'){
        ans += t;
      }
    }
      cout << ans << endl;
}

Measured memory_bytes: 256