akhauriyash/Code-Regression huggingface dataset:
class stack():
    def __init__(self):
        self.S = [0 for i in range(200)]
        self.top = 0
        self.MAX =200
    def isEmpty(self):
        return self.top == 0
    def isFull(self):
        return self.top >= self.MAX -1
    def push(self,x):
        if self.isFull():
            print('error')
        self.top += 1
        self.S[self.top] = x
    def pop(self):
        if self.isEmpty():
            print('error')
            
        self.top -= 1
        return self.S[self.top+1]
l = input().split()
s = stack()
for i in l:
    if i == '+':
        a = s.pop()
        b = s.pop()
        s.push(a+b)
    elif i == '-':
        a = s.pop()
        b = s.pop()
        s.push(b-a)
    elif i =='*':
        a = s.pop()
        b = s.pop()
        s.push(a*b)
    else:
        s.push(int(i))
print(s.S[1])


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long a, long long b){
	if (a<b) {
		rep(i,b) cout << a;
	} else {
		rep(i,a) cout << b;
	}
	cout << endl;
}

int main(){	
	long long a;
	long long b;
	scanf("%lld",&a);
	scanf("%lld",&b);
	solve(a, b);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 

 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	ll k;
	cin>>k;
	ll ans = -1;

	if(k%2!=0 or k%5!=0){
		ll num = 0;
		for(int i=1;i<=k;i++){
			num = (num*10 +7 )%k;
			if(num==0){
				ans = i;
				break;
			}
		}
	}   
	cout<<ans<<endl; 
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll x, n;
  cin >> x >> n;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  Sort(a);
  ll ans1;
  ll ans2;
  ll u = x;
  ll y = x;
  for (ll i = 0; i < 10000000; i++) {
    for (ll j = 0; j<n ; j++) {
      if (x == a[j]) {
        x++;
        break;
      }
      if (j == n-1) {
        ans1 = x;
        i = 10000000;
        break;
      }
    }
  }
  for (ll i = 0; i < 10000000; i++) {
    for (ll j = 0; j<n ; j++) {
      if (y == a[j]) {
        y--;
        break;
      }
      if (j == n-1) {
        ans2 = y;
        i = 10000000;
        break;
      }
    }
  }
  if (abs(u-x) >= abs(u-y)) {
    cout << y << '\n';
  }
  else {
    cout << x << '\n';
  }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char arr[27]={ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\0'};
    char n;
    cin>>n;
    char res;int i=1;
    for(char x : arr)
    {
        if(x==n)res = arr[i];
        ++i;
    }
    cout<<res;
    return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 100 * 1000 + 13;

int n;
int a[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%d", &a[i]);
	return true;
}

void solve(){
	multiset<int> vals(a, a + n);
	
	vector<pt> mvs;
	while (sz(vals) > 2 && *(++vals.begin()) < 0){
		int x = *vals.rbegin(), y = *(++vals.begin());
		mvs.pb(mp(x, y));
		vals.erase(--vals.end());
		vals.erase(++vals.begin());
		vals.insert(x - y);
	}
	
	while (sz(vals) > 2){
		int x = *vals.begin(), y = *(++vals.begin());
		mvs.pb(mp(x, y));
		vals.erase(vals.begin());
		vals.erase(vals.begin());
		vals.insert(x - y);
	}
	
	int x = *vals.rbegin(), y = *vals.begin();
	mvs.pb(mp(x, y));
	vals.erase(vals.begin());
	vals.erase(vals.begin());
	vals.insert(x - y);
	
	printf("%d\n", *vals.begin());
	for (auto it : mvs)
		printf("%d %d\n", it.x, it.y);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if (read()){
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 7796
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	ll n, m;
	cin >> n >> m;

	vector<pair<ll, ll>> a(n);
	rep(i, n)
	{
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());

	priority_queue<ll> pq;
	ll start = 0;
	ll ans = 0;
    ll id=0;
	for (ll i = 1; i <= m; i++)
	{
		while(id<n)
        {
            if(a[id].first<=i)
            {
                pq.push(a[id].second);
                id++;
            }
            else
            {
                break;
            }
        }
		if (!pq.empty())
		{
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2936
N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

for i in range(1, N + 1):
    A[i] += A[i - 1]
for i in range(1, M + 1):
    B[i] += B[i - 1]

# bisect
import bisect
ans = 0
for i in range(N+1):
    if A[i] <= K:
        rest = K - A[i]
        b_cnt = bisect.bisect_right(B,rest)-1
        ans = max(ans,i+b_cnt)
    else:
        break
print(ans)

Measured memory_bytes: 40100
#!/usr/bin/env python3

#from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, HS, VS):
    bit = [0] * (N + 1)  # 1-origin

    def bit_put(pos, val):
        assert pos > 0
        x = pos
        while x <= N:
            bit[x] = max(bit[x], val)
            x += x & -x  # (x & -x) = rightmost 1 = block width

    def bit_max(pos):
        assert pos > 0
        ret = 0
        x = pos
        while x > 0:
            ret = max(ret, bit[x])
            x -= x & -x
        return ret

    for i in range(N):
        h = HS[i]
        m = bit_max(h)
        bit_put(h, m + VS[i])

    return bit_max(N)


def main():
    # parse input
    N = int(input())
    HS = list(map(int, input().split()))
    VS = list(map(int, input().split()))
    print(solve(N, HS, VS))


# tests
T1 = """
4
3 1 4 2
10 20 30 40
"""


def test_T1():
    """
    >>> as_input(T1)
    >>> main()
    60
    """


T2 = """
1
1
10
"""


def test_T2():
    """
    >>> as_input(T2)
    >>> main()
    10
    """


T3 = """
5
1 2 3 4 5
1000000000 1000000000 1000000000 1000000000 1000000000
"""


def test_T3():
    """
    >>> as_input(T3)
    >>> main()
    5000000000
    """


T4 = """
9
4 2 5 8 3 6 1 7 9
6 8 8 4 6 3 5 7 5
"""


def test_T4():
    """
    >>> as_input(T4)
    >>> main()
    31
    """
# add tests above


def _test():
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())

    def input():
        return bytes(f.readline(), "ascii")

    def read():
        return bytes(f.read(), "ascii")


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        print("testing")
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 116544
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
//#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = int(2e5) + 3;
const int mod = int(1e9 + 7);

int lab[N], fac[N], n, c[N], w[N], x, y, lx, ly;
vector<int> ball[N];
unordered_map<int, int> node[N];

int mul(int x, int y) {return 1ll * x * y % mod;}
int Pow(int x, int y) {
    int res = 1;
    for(; y; y >>= 1) {
        if(y & 1) res = mul(res, x);
        x = mul(x, x);
    }
    return res;
}
int find(int x) {return lab[x] < 0? x: lab[x] = find(lab[x]);}
void uni(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(lab[x] > lab[y]) swap(x, y);
    lab[x] += lab[y], lab[y] = x;
    for(auto p: node[y]) node[x][p.fi] += p.se;
}
void upd(int id) {
    if(lx == -1) lx = id;
    else if(ly == -1) ly = id;
    else {
       if(w[ly] > w[id]) ly = id;
       if(w[lx] > w[ly]) swap(lx, ly);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> x >> y; fac[0] = 1;
    fill(lab, lab + n + 1, -1);
    for(int i = 1; i <= n; ++i) {
        cin >> c[i] >> w[i];
        ball[c[i]].pb(i);
        ++node[i][c[i]];
        fac[i] = mul(fac[i - 1], i);
    }
    if(sz(ball[c[1]]) == n) return cout << 1, 0;
    lx = -1, ly = -1;
    for(int i = 1; i <= n; ++i) {
        sort(ball[i].begin(), ball[i].end(), [&](const int& x, const int& y) {
                 return w[x] < w[y];
             });
        for(int j = 1; j < sz(ball[i]); ++j)
            if(w[ball[i][j]] + w[ball[i][0]] <= x) uni(ball[i][j], ball[i][0]);
        if(sz(ball[i])) upd(ball[i][0]);
    }
    for(int i = 1; i <= n; ++i) {
        if(c[i] != c[lx] && w[i] + w[lx] <= y) uni(i, lx);
        if(c[i] != c[ly] && w[i] + w[ly] <= y) uni(i, ly);
    }
    int ans = 1, rev = 1;
    for(int i = 1; i <= n; ++i) {
        if(lab[i] < 0) {
            ans = mul(ans, fac[-lab[i]]);
            for(auto p: node[i]) rev = mul(rev, fac[p.se]);
        }
    }
    cout << mul(ans, Pow(rev, mod - 2));
}


Measured memory_bytes: 40612
N = int(input())
A = list(map(int, input().split()))

C = {}

count = 0
H = 0
W = 0

res1=res2=res3=0

for i in A:
    C[i] = 0

for i in A:
    C[i] += 1

for i in A:
    if C[i] >= 2:
        res1 = max(res1, i)

for i in A:
    if C[i] >= 2 and i != res1:
        res2 = max(res2, i)

for i in A:
    if C[i] >= 4:
        res3 = max(res3, i)


print(max(res1 * res2, res3 * res3))

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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

int main()
{
    int n, mx1 = -1 , mx2 = -1;
    cin >> n;
    int a[n] , b[n];

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

    sort(a , a+n);
    mx1 = a[n-1];

    for(int i = n-1; i >= 0; --i){
        if(a[i] < mx1){
            mx2 = a[i];
            break;
        }
    }
    int x = 0;
    for(int i = 0; i < n; ++i)
        if(a[i] == mx1)
            x++;

    if(x > 1)
        mx2 = mx1;

    for(int i = 0; i < n; ++i){
        if(b[i] != mx1){
            cout << mx1 << "\n";
        }else{
            cout << mx2 << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int n, m;
	
	int a[100] = {};
	int b[100] = {};
	int c[100] = {};
	int d[100] = {};

	

	cin >> n >> m;

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

	for (int i = 0; i < m; i++)
	{
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < n; i++)
	{
		long long x = 0;
		long long min = 100000000000;
		int ans = 0;
		for (int j = 0; j < m; j++)
		{
			x = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (x < min) {
				min = x;
				ans = j + 1;
			}
		}

		cout << ans << endl;
	}


}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
aa = []
bb = []
common = []
for i in range(1, a+1):
    if a%i == 0:
        aa.append(i)
for i in range(1, b+1):
    if b%i == 0:
        bb.append(i)

for i in aa:
    if i in bb:
        common.append(i)
print(common[-k])

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    char b;
    scanf("%c",&b);
    if(b == 'A'){
        printf("T");
    }else if(b == 'T'){
        printf("A");
    }else if(b == 'C'){
        printf("G");
    }else if(b == 'G'){
        printf("C");

    }
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

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


    for(int x = n/4+1; x <= 3500;x++){
        for(int y = x;y <= 3500;y++){
            if(4*x*y - n*(x+y) > 0 && (n*x*y)%(4*x*y - n*(x+y)) == 0){
                int z = (n*x*y)/(4*x*y - n*(x+y));
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    
    

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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

int main()
{
    int N;
    cin >> N;
    
    bool flag = false;
    for (int a = 0; a <= N / 4; a++){
        for (int b = 0; b <= N / 7; b++){
            if (a * 4 + b * 7 == N) flag = true;
        }
    }
    
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<int> r(N + 1);
    for(int i=1; i<=N; ++i) {
        int p;
        cin >> p;
        r[p] = i;
    }

    for(int i=1; i<=N; ++i) cout << 30000 * i << (i != N ? ' ' : '\n');
    for(int i=1; i<=N; ++i) cout << 30000 * (N - i) + r[i] << (i != N ? ' ' : '\n');
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

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).bigin(), (c).end())

typedef long long ll;
typedef long double ld;

int main()
{
    ll n, m, d;
    cin >> n >> m >> d;

    ll hoge;
    if (d == 0)
        hoge = (n - d);
    else
        hoge = (2 * (n - d));

    ld ans = (ld)(m - 1) * (ld)hoge / (ld)n / (ld)n;
    cout << fixed;
    cout << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    vector<lint> cnt(N+1);
    FOR(i, 1, N+1) {
        for(int j=i; j<=N; j+=i) cnt[j]++;
    }
    lint ans = 0;
    FOR(i, 1, N+1) {
        ans += i * cnt[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 81340
N = int(input())
nums = list(map(int, input().split()))

div = 2
cnt = 0
FLAG = True

while (FLAG):
    
    for i in range(N):
        mod = nums[i] % div
        if (mod != 0):
            FLAG = False
            break
    
    if (FLAG):
        div *= 2
        cnt += 1

print(cnt)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

void Main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N){cin >> A.at(i);}
    ll tmp = A.at(0);
    rep(i, N-1){tmp = gcd(tmp, A.at(i+1));}
    cout << tmp << endl;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s; cin >> s;
    ll n = 0;
    rep(i, 0, 4){
        if(s[i] == '+'){
            n++;
        }else{
            n--;
        }
    }
    cout << n << endl;
    return 0;
}

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


int main(){

  bool isreversed = false;
  string tmp_s = "";
  list<string> s;
  int q_num, command_int;
  cin >> tmp_s >> q_num;
  s.emplace_back(tmp_s);
  rep(i,q_num){
    cin >> command_int;
    if(command_int == 1){
      if(isreversed) isreversed = false;
      else isreversed = true;
    }
    else if(command_int == 2){
      cin >> command_int >> tmp_s;
      if(isreversed){
        reverse(tmp_s.begin(), tmp_s.end());
        command_int = (command_int == 1)? 2:1;
      }
      if(command_int == 1){
        s.emplace_front(tmp_s);
      }
      else if(command_int == 2){
        s.emplace_back(tmp_s);
      }
    }
  }
  string ans;
  for(auto itr  = s.begin(); itr != s.end();itr++){
      ans += *itr;
  }
  if(isreversed) reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16736
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let k = read::<usize>();
    let s = read::<String>();
    if s.clone().len() <= k {
        println!("{}", s.clone());
    } else {
        let (s1, _s2) = s.split_at(k);
        let mut s1 = s1.to_string();
        s1.push_str("...");
        println!("{}", s1);
    }
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int a;
  cin >> n;
  deque<int> A;
  REP(i,n){
      cin >> a;
      if (i%2==0){
        A.push_back(a);
      }else{
        A.push_front(a);
      }
  }
  if (n%2==1){
      REV(A);
  }
  REP(i,n){
      cout << A[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3072
n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(n):
    if a[i]%2==0 and a[i]%3!=0 and a[i]%5!=0:
        s=s+1


if s==0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type BC struct {
	B int
	C int
}

type ByC []BC

func (a ByC) Len() int           { return len(a) }
func (a ByC) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByC) Less(i, j int) bool { return a[i].C > a[j].C }

var (
	sc = bufio.NewScanner(os.Stdin)
)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	M := nextInt()

	A := make([]BC, 0, N+M)

	for i := 1; i <= N; i++ {
		a := nextInt()
		A = append(A, BC{B:1,C:a})
	}

	for j := 1; j <= M; j++ {
		B := nextInt()
		C := nextInt()
		A = append(A, BC{B:B,C:C})
	}

	sort.Sort(ByC(A))

	ans := 0
	cnt := 0
	for _, bc := range A {
		b := bc.B
		if cnt + b > N {
			b = N - cnt
		}
		ans += bc.C * b
		cnt += b
		if cnt == N {
			break
		}
	}
	fmt.Println(ans)
}


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

#define M 1046527
#define NIL (-1)
#define L 14

using namespace std;

char H[M][L];

int getChar(char ch)
{
    if ( ch =='A' ) return 1;
    else if ( ch == 'C' ) return 2;
    else if ( ch == 'G' ) return 3;
    else if ( ch == 'T' ) return 4;
    else return 0;
}

long long getKey(char str[])
{
    long long sum = 0, p = 1;
    for (int i=0; i < strlen(str); ++i) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int Find(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for ( i=0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(H[h], str) == 0) return 1;
        else if ( strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int Insert(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for ( i=0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(H[h], str) == 0) return 1;
        else if ( strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for (i=0; i<M; ++i) H[i][0] = '\0';
    scanf("%d", &n);
    for (i=0; i<n; ++i) {
        scanf("%s %s", com, str);

        if (com[0] == 'i') Insert(str);
        else {
            if (Find(str)) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}



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

using namespace std;

#define intt long long 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 105;

int main() {

	FAST;

	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] = tolower(s[k - 1]);
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = min(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i

	for i,val in enumerate(S):
		tmp = max(val)
		for j,vol in enumerate(val):
			if tmp == vol:
				ans.append(random.randint(1, 26))
				break

	for i in range(D):
		print(ans[i])

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	ll a, b, c , x, y;	
	cin >> a>> b>> c >> x>> y;	
	ll ans = a * x + b * y;
	if ( x < y){
		swap(a,b);
		swap(x,y);
	}
	ll pre = 2 * y * c  + (x-y)*a ;
	chmin(pre,2*x*c);
	chmin(ans,pre);
	cout << ans << endl;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R), a(M), b(M), c(M);
    REP(i, R) cin >> r[i];
    REP(i, M) cin >> a[i] >> b[i] >> c[i];


    vector<vector<int>> graph(N, vector<int>(N, INF));
    REP(i, M){
        graph[a[i]-1][b[i]-1] = c[i];
        graph[b[i]-1][a[i]-1] = c[i];
    }
    
    REP(i, N) REP(j, N) if(i == j) graph[i][j] = 0;
    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }

    vector<int> nex(R);
    REP(i, R) nex[i] = i;
    
    int ans = INF;
    
    do{
        int cur = r[nex[0]]-1;
        int sum = 0;
        for(auto x : nex){
            sum += graph[cur][r[x]-1];
            cur = r[x]-1;
        }
        ans = min(sum, ans);

    }while(next_permutation(all(nex)));
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>


using namespace std;


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    
  int arr[10000];
  int n=0;
  
  while(n<=10000){
      cin>>arr[n];
     
            n++;
  }
  int i=0;
  while(arr[i]!=0){
      
        cout<<"Case "<<(i+1)<<": "<< arr[i]<<endl;
        i++;
  }
 return 0;
}



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

using namespace std;
typedef long long ll;

ll N,M;
ll a[100000];

ll count(ll n){
    bitset<64> bt(n);
    for(int i=0;i<N;i++){
        if(bt[i] == 1) return i;
    }
    return -1;
}

bool check(ll m){
    for(int i=1;i<N;i++){
        if(count(a[i]) != m) return true;
    }
    return false;
}

int main(){
    cin >> N >> M;
    ll l = 1;
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++){
        if(a[i] % 2 == 1){
            cout << 0 << endl;
            return 0;
        }
        a[i] /= 2;
    }
    ll b = count(a[0]);
    if(check(b)){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1;i<N;i++){
        ll g = __gcd(a[i],a[i-1]);
        a[i] /= g;
        a[i] *= a[i-1];
    }
    cout << ((M / a[N-1]) + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double d,t,s;
    cin>>d>>t>>s;
    double x=d/s;
    if(x<=t)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
   
}

Measured memory_bytes: 3720
import sys
s = input()
n = len(s)


flag = 1
for i in range(0,(n-1)//2):
    if(i <= (n-1)/2):
        if(s[i] != s[n-i-1] or s[i] != s[(n-1)//2-i-1]):
            print('No')
            sys.exit()

print('Yes')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ll,ll>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define nu 100001
#define M 1000000007
ll par[1000005];
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll parent(ll x)
{
    if(par[x]==x)
    {
        return x;
    }
    else
    {
        ll k = parent(par[x]);
        par[x]=k;
        return k;
    }
}
int main()
{
	ll n,m;
	cin>>n>>m;
	ll mini=min(n,m/2);
	n-=mini;
	m-=mini*2;
	mini+=m/4;
	cout<<mini;
}

Measured memory_bytes: 256
#include<stdio.h>

void sort(int *a, int n);

void sort(int *a, int n){
	int i, j, max, index;

	for(i=0; i<n-1; i++){
		max = a[i];	index = i;
		for(j=i+1; j<n; j++){
			if(max < a[j]){
				max = a[j];	index = j;
			}
		} 
		a[index] = a[i];	a[i] = max;
	}
}

int main(void){
	int n, l[10], i;

	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &l[i]);
	}
	sort(l, n);
	int x=0;
	for(i=1; i<n; i++){
		x += l[i];
	}

	if(l[0] >= x){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1664
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <vector <ll>> matrix;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

const int mod = 1e9 + 7;
template <typename T1, typename T2>
void modadd(T1 &a, const T2 &b) {
    a += b;
    
    if (a >= mod)
        a -= mod;
}

mt19937 rng(20010709);
const int INF = 1000000001;
const int N = 100005;

int n, m;
int down[N], up[N];
vector <int> e[N];

void dfsDown(int v);
void dfsUp(int v);

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

	cin >> n >> m;

	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}

    dfsDown(1);
    up[1] = 1;
    dfsUp(1);

    for (int i = 1; i <= n; i++)
        cout << down[i] * 1LL * up[i] % m << endl;

    cout << endl << endl;

    return 0;
}

void dfsDown(int v) {
    down[v] = 1;

	for (auto it : e[v]) {
        e[it].erase(find(e[it].begin(), e[it].end(), v));
		dfsDown(it);
        down[v] = down[v] * 1LL * (down[it] + 1) % m;
	}
}

void dfsUp(int v) {
    vector <int> pref(e[v].size() + 2), suff(e[v].size() + 1);
    pref[0] = up[v];
    suff[suff.size() - 1] = 1;

    for (int i = 0; i < e[v].size(); i++)
        pref[i + 1] = pref[i] * 1LL * (down[e[v][i]] + 1) % m;

    for (int i = e[v].size() - 1; i > -1; i--)
        suff[i] = suff[i + 1] * 1LL * (down[e[v][i]] + 1) % m;

    for (int i = 0; i < e[v].size(); i++) {
        up[e[v][i]] = (1 + pref[i] * 1LL * suff[i + 1]) % m;
        dfsUp(e[v][i]);
    }
}

Measured memory_bytes: 16512
N, M, P = map(int, input().split())
Edges = []
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    Edges.append([a, b, -(c - P)])


dist = [float('inf')] * N
dist[0] = 0

for i in range(2 * N):
    for fr, to, cost in Edges:
        if dist[to] > dist[fr] + cost:
            dist[to] = dist[fr] + cost
            if i >= N:
                dist[to] = -float('inf')


print(max(0, -dist[N - 1]) if -dist[N - 1] != float('inf') else -1)


Measured memory_bytes: 52312
import numpy as np
even = np.zeros(100001, dtype=np.int32)
odd = np.zeros(100001, dtype=np.int32)

n = int(input())
v = list(map(int, input().split()))

for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1
    else:
        odd[v[i]] += 1

e1 = even.argmax()
e1n = even.max()
o1 = odd.argmax()
o1n = odd.max()

# print(e1, e1n, o1, o1n)
if e1 == o1:
    e2n = np.sort(even)[-2]
    o2n = np.sort(odd)[-2]
    # print(e2n, o2n)
    print(min(n - e1n - o2n, n - e2n - o1n))
else:
    print(n - e1n - o1n)


Measured memory_bytes: 23484
#include <cstdio>
#include <iostream>
#include <string>
#include <string.h>
#include <cmath>
#include <deque>
#include <algorithm>
#include <time.h>
#include <math.h>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#define ms(a) memset(a,0,sizeof(a))
#define st(a,n) sort(a,a+n)
#define fr(i,k,n) for(int i=k;i<=n;++i)
#define FR(i,k,n) for(int i=n;i>=k;--i)
#define pb push_back
#define inf 0x3f3f3f
#define vc vector
#define exp 1e-6
#define ci cin
#define co cout
#define ed endl
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int mod =1e9+7;
const int maxn=1e5+10;
const double pi=acos(-1);
int main()
{
    int a,b,ans=0;
    ci>>a>>b;
    ans+=(a>=b)?a--:b--;
    ans+=(a>=b)?a--:b--;
    co<<ans<<ed;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector< vector <int> >vee;
typedef vector<pair<int,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const int N=1e5+5;
bool f;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    if(len(s)<=n)
        cout<<s;
    else
    {
       cout<<s.substr(0,n)<<"...";
    }
go;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  vector<int> A(N);
  
  int i;
  for (i=0; i<N; i++){    
    cin >> A.at(i);
  }
  //cout << A.size() << endl;
  int Alice = 0;
  int Bob = 0;
  
  std::vector<int>::iterator maxIt;
  size_t max_ind;
  
  for(i=0; i<A.size(); i++){
    Alice += *max_element(A.begin(), A.end());
    //cout << Alice << endl;
    //cout << 10 << endl;
    
    maxIt = max_element(A.begin(), A.end());
    max_ind = distance(A.begin(), maxIt);
    
    A.at(max_ind) = 0;
    
    Bob += *max_element(A.begin(), A.end());
    //cout << Bob << endl;
    
    maxIt = max_element(A.begin(), A.end());
    max_ind = distance(A.begin(), maxIt);
    
    A.at(max_ind) = 0;
    
  }
  
  cout << abs(Alice - Bob) << endl;
 
}

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

int k, n;
ll t[1 << 17], d[1 << 17];
vector<ll>v;

int main(){
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for(int i = 0;i < n ; i++){
        if(a[i] == b[i] && b[i] == c[i] && c[i] == a[i])continue;
        if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i])ans++;
        else ans+=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int best = INT_MAX;
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    for(int i = 0; i < n - k + 1; i++)
    {
        best = min(best, h[i + k - 1] - h[i]);
    }
    cout << best;

    return 0;
}


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

using namespace std;


const int MAX_N = 1e+9;


int n;

int solve()
{
    int n_500 = (n - n % 500) / 500;
    n -= 500 * n_500;
    int n_5 = (n - n % 5) / 5;

    return n_500 * 1000 + n_5 * 5;
    
}

int main()
{
    cin >> n;
    
    cout << solve() << endl;

    return EXIT_SUCCESS;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
#define tosmall(c) c-('A'-'a');

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 gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


int main(void){
  int n,k;
  string s;
  cin >> n >> k >> s;k--;
  s[k]=tosmall(s[k]);
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n, l[20];
	int max = 0, maxi, sum = 0;
	int i, j, k;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &l[i]);
		if (max < l[i]) {
			max = l[i];
			maxi = i;
		}
	}
	for (i = 0; i < n; i++) {
		if (maxi != i) {
			sum += l[i];
		}
		else {
			continue;
		}
	}
	if (max < sum) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
	

}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
typedef long long ll;
int MAXN = 3*1e6 + 5;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
struct node{
    int p1,p2 ;
    int index ;
} ;

int main (){
    int a,b ,c;
    cin >>a>>b>>c ;
    int k;
    cin >>k;
    int sum=a+b+c;
    cout<<(sum-max(a,max(b,c))) + pow(2,k)*max(a,max(b,c))<<endl;
    return 0;
}


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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int r,d,x;
	cin >> r >> d >> x;
	for(int i = 0; i < 10; i++){
		cout << (ll)(r * x - d) << endl;
		x = r * x - d;
	}

	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> r(A);
    vector<ll> g(B);
    vector<ll> m(C);
    for (ll i = 0;i<A;i++) {
        ll a; cin >> a;
        r.at(i) = a;
    }
    for (ll i = 0;i<B;i++) {
        ll a; cin >> a;
        g.at(i) = a;
    }
    for (ll i = 0;i<C;i++) {
        ll a; cin >> a;
        m.at(i) = a;
    }
    sort(r.begin(),r.end());
    sort(g.begin(),g.end());
    sort(m.begin(),m.end());
    reverse(r.begin(),r.end());
    reverse(g.begin(),g.end());
    reverse(m.begin(),m.end());


    ll rsum = 0;
    ll gsum = 0;
    for (ll i = 0;i<X;i++) {
        rsum += r.at(i);
    }
    for (ll i = 0;i<Y;i++) {
        gsum += g.at(i);
    }


    ll current_r = X - 1;
    ll current_g = Y - 1;
    for (ll i = 0;i<C;i++) {
        if ((current_r >= 0) && (current_g >= 0)) {
            ll dr,dg;
            dr = m.at(i) - r.at(current_r);
            dg = m.at(i) - g.at(current_g);
            if ((dr <= 0) && (dg <= 0)) break;
            else if (dr >= dg) {
                rsum += dr;
                current_r--;
            }
            else if (dr <= dg) {
                gsum += dg;
                current_g--;
            }
        }
        else if (current_r >= 0) {
            ll dr;
            dr = m.at(i) - r.at(current_r);
            if (dr <= 0) break;
            else {
                rsum += dr;
                current_r--;
            }
        }
        else if (current_g >= 0) {
            ll dg;
            dg = m.at(i) - g.at(current_g);
            if (dg <= 0) break;
            else {
                gsum += dg;
                current_g--;
            }
        }
    }
    cout << rsum + gsum << endl;
}


Measured memory_bytes: 2560
from collections import defaultdict
user_num, conn_num = (int(n) for n in input().split(" "))
conn = defaultdict(list)
for _ in range(conn_num):
    i, j = (int(n) for n in input().split(" "))
    conn[i].append(j)
    conn[j].append(i)
find = [-1 * n - 1 for n in range(user_num)]
query = int(input())
for q_num in range(query):
    one, theother = (int(n) for n in input().split(" "))
    if find[one] != find[theother] and find[one] < 0:
        queue = [one]
        find[one] = q_num
        while queue:
            new_queue = []
            for q in queue:
                for c in conn[q]:
                    if find[c] < 0:
                        new_queue.append(c)
                        find[c] = q_num
            queue = new_queue
    if find[one] == find[theother]:
        print("yes")
    else:
        print("no")

Measured memory_bytes: 37436
#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(){
  int a,b;
  cin>>a>>b;
  
  int d,r;
  double f;
  
  d=a/b;
  r=a%b;
  f=(double)a/b;
  
  cout<<fixed<<setprecision(8)<<d<<" "<<r<<" "<<f<<endl;
  
  return 0;
}


Measured memory_bytes: 3284
import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()

# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]

# a_list = get_string_list():
def get_string_list():
    return input().split()

# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())

# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    n = get_int()
    a_list = get_int_list()

    w_min = a_list[0]
    w_max = a_list[0]
    pre = a_list[0]
    kabu = 0
    kane = 1000

    for i in range(1, n):

        if pre < a_list[i] and kabu == 0:
            kabu = kane // w_min
            kane = kane - kabu * w_min
            w_max = a_list[i]

        elif pre > a_list[i] and kabu > 0:
            kane = kane + w_max * kabu
            kabu = 0
            w_min = a_list[i]

        elif pre < a_list[i] and kabu > 0:
            w_max = a_list[i]

        elif pre > a_list[i] and kabu == 0:
            w_min = a_list[i]



        pre = a_list[i]

    if kabu > 0:
        kane = kane + w_max * kabu

    print(kane)






if __name__ == '__main__':
    main()




Measured memory_bytes: 9288
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n = 0, b = 0, e;
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if ((s[i] - '0') == 0) {
			n++;
		}
		else {
			b++;
		}
	}
	cout << min(n, b) * 2 << endl;
	cin >> e;
}

Measured memory_bytes: 512