akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N, vector<int>());
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int start = -1;
    int deg = INF;
    rep(i, N) {
        if(G[i].size() < deg) {
            start = i;
            deg = G[i].size();
        }
    }
    vector<int> path;
    vector<bool> used(N, false);
    path.pb(start);
    used[start] = true;
    int now = start;
    while(1) {
        int ok = 0;
        for(auto nv : G[now]) {
            if(!used[nv]) {
                used[nv] = true;
                now = nv;
                path.pb(now);
                ok = 1;
                break;
            }
        }
        if(!ok)
            break;
    }
    reverse(All(path));
    now = start;
    while(1) {
        int ok = 0;
        for(auto nv : G[now]) {
            if(!used[nv]) {
                used[nv] = true;
                now = nv;
                path.pb(now);
                ok = 1;
                break;
            }
        }
        if(!ok)
            break;
    }
    cout << path.size() << endl;
    rep(i, path.size()) cout << path[i] + 1 << (i == N - 1 ? "\n" : " ");

    return 0;
}

Measured memory_bytes: 9280
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
A,B = map(int,input().split())
S = input()

kazu = "[0-9]"
pattern = kazu*A + "-" + kazu*B
kekka = re.fullmatch(pattern,S)

ans = "Yes"
if kekka is None:
    ans = "No"

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();
        sc.close();

        int result = x;

        for (int i=1; i <= 10; i++){

            result = r * result - D;

            System.out.println(result);
        }
    }
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

int main() {
    int n, x;
    cin >> n >> x;
    ll iMoto;
    ll ans = n;
    ll minMoto = INT_MAX;
    for (int i = 0; i < n; ++i) {
        cin >> iMoto;
        minMoto = min(iMoto, minMoto);
        x -= iMoto;
    }
    ans += x / minMoto;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbig=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n,a[111];
bool f[10011];
int main()
{
	geti(n);
	f[0]=1;
	for(int i=1;i<=n;i++)
	{
		int x;
		geti(x);
		for(int j=10000-x;j>=0;j--)
		{
			f[j+x]|=f[j];
		}
	}
	for(int i=10000;i>=0;i--)
	{
		if(i%10!=0&&f[i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) 
{
    ll n;
    cin >> n;
    vll a(n);
    
    ll r = 0;
    ll next = 0;
    
    rep(i, n) {
        cin >> a[i];
    }
    
    rep(i, n+1) {
        r++;
        if (a[next] == 2) {
            mes(r);
            re0;
        }
        next = a[next]-1;
    }
    
    mes(-1);
    
    
   
    
}


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

int main() {
  int N;
  scanf("%d", &N);
  
  vector<int> nums(N);
  
  unordered_map<int, int> count;
  for (int i = 0; i < N; ++i) {
  	scanf("%d", &nums[i]);
  	++count[nums[i]];
  }
  
  long long total = 0;
  for (auto& p : count) {
  	long long n = p.second;
  	total += n * (n - 1) / 2;
  }
  
  for (int i = 0; i < N; ++i) {
  	printf("%lld\n", total - count[nums[i]] + 1);
  }
  
  return 0;
}

Measured memory_bytes: 8392
l, r = map(int, input().split())
if (r // 2019) > (l // 2019):
    l = l % 2019
    r = 2019 + (r % 2019)
else:
    l = l % 2019
    r = r % 2019
ans = 10 ** 9
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min((i*j) % 2019, ans)
print(ans)

Measured memory_bytes: 3060
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long a, b, n;
	cin >> a >> b >> n;
	
	auto calc = [&](long long x) {
		return (a*(x%b)-((a%b)*x)%b)/b;
	};

	
	cout << max(calc(min(n,b-1)), calc(min(n,a%b?b/(a%b):1)));


	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
typedef long long ll;
using namespace std;

int main(void) {
	//数学複素数平面
	/*
	int x[2],y[2];
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	cout << x[1]+y[0]-y[1] << " " << -x[0] + x[1] + y[1] << " " << x[0] + y[0] - y[1] << " " << -x[0] + x[1] + y[0] << endl;
	return 0;*/
	//数学的に考える
	ll n, k, res = 0;
	cin >> n >> k;
	res = (n / k)*(n / k)*(n / k);
	if (k % 2 == 1) {
		cout << res << endl;
	}
	else {
		ll x = k / 2;
		ll num = 0;
		if (x > n) {
			cout << res << endl;
			return 0;
		}
		else {
			num = 1;
			for (ll i = 0;i < n;i++) {
				if (x + k <= n) {
					x += k;
					num++;
				}
				else break;
			}
			res += num*num*num;
			cout << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define INF 100000000
int main(void)
{
	int high=0;
	double minsp,sp;
	while(scanf("%lf",&minsp) != EOF)
	{
		high = 0;
		sp = 0; 
		while(sp<minsp)
		{
			high++;
			sp = (sqrt((high*5-5)/4.9))*9.8;
		}
		printf("%d\n",high);
	}
	return 0;
}

Measured memory_bytes: 628
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    using namespace std;
    #define INF 10000000;
     
    int main() {
        int n;
        bool check = false;
        cin >> n;

        for(int i=0;i*4<=n;i++){
            for(int j=0;j*7<=n-i*4;j++){
                if(n == i*4 + j*7){
                    check = true;
                    break;
                
            }
        }if(check)break;
    }
    if(check)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    }

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
		string[] nums = Console.ReadLine().Split(' ');
		int a = int.Parse(nums[0]);
		int b = int.Parse(nums[1]);
		int c = int.Parse(nums[2]);

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

	

Measured memory_bytes: 8924
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846

using namespace std;

class comb
{
	ll inf;
	vector <ll> fact, inv;

public:
	comb(ll n, ll infi)
	{
		fact.resize(n + 1);
		inv.resize(n + 1);
		inf = infi;
		fact[0] = 1;
		for(ll i = 1; i <= n; i++)
			fact[i] = (fact[i - 1]  * i) % inf;
		for(ll i = 0; i <= n; i++)
			inv[i] = exp(fact[i], inf - 2);
	}

	ll ncr(ll n, ll r)
	{
		ll ans = fact[n];
		ans = (ans * inv[r]) % inf;
		ans = (ans * inv[n - r]) % inf;
		return ans;
	}
	
	ll f(ll n)
	{
		return fact[n];
	}
	
	ll iv(ll n)
	{
		return inv[n];
	}
	
	ll exp(ll a, ll b)
	{
		ll res = 1;
		while(b > 0)
		{
			if(b & 1)
				res = (res * a) % inf;
			a = (a * a) % inf;
			b >>= 1;
		}
		return res;
	}
};

void solve()
{
	ll k;
	cin >> k;
	string s;
	cin >> s;
	ll m = s.size(), inf = 1e9 + 7, ans = 0;
	comb c(m + k, inf);
	for(ll i = 0; i <= k; i++)
	{
		ll tans = c.exp(26, i);
		tans = (tans * c.exp(25, k - i)) % inf;
		tans = (tans * c.ncr(m + k - i - 1, m - 1)) % inf;
		ans = (ans + tans) % inf;
	}
	cout << ans << endl;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 35556
s=input()
if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
else:
    print(1)
 


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;

int main(){
    ll n,t,s[200001],sum=0;
    cin>>n>>t;
    rep(i,n){
        cin>>s[i];
        if(i>0){
            if(s[i]-s[i-1]>=t){
                sum+=t;
            }else{
                sum+=s[i]-s[i-1];
            }
        }
    }
        cout<<sum+t;
    
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<string, int>> r(n);
    for (int i = 0; i < n; i++)
    {
        cin >> r.at(i).first >> r.at(i).second;
    }
    vector<pair<string, int>> r2 = r;
    
    sort(r.begin(), r.end());

    int index = 0;
    string s = r.at(0).first;
    vector<pair<string, int>> rx;
    for (int i = 0; i < n; i++)
    {
        s = r.at(i).first;
        if (r.at(i).first == s) {
            vector<int> v;
            s = r.at(i).first;
            while (i < n && r.at(i).first == s) {
                v.push_back(r.at(i).second);
                i++;
            }
            i--;
            sort(v.begin(), v.end());
            reverse(v.begin(), v.end());
            for (int j = 0; j < (int)v.size(); j++)
            {
                rx.push_back(pair<string, int>(s, v.at(j)));
            }
        }
        else {
            rx.push_back(r.at(i));
        }
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (rx.at(i).first == r2.at(j).first && rx.at(i).second == r2.at(j).second) {
                cout << j + 1 << endl;
                break;
            }
        }
        
    }
    
}


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

int main(void){
    int K,A,B;
    cin >> K >> A >> B;
    
    for(int i = A; i <= B; i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100
#define MAX_W 100'000
i64 N, W;
i64 w[MAX_N + 1];
i64 v[MAX_N + 1];
i64 dp[MAX_N + 1][MAX_W + 1];

void solve() {
    REP(i, N) REP(j, W + 1) dp[i][j] = 0;
    dp[0][w[0]] = v[0];

    REP(i, N) {
        REP(j, W + 1) {
            dp[i + 1][j] = dp[i][j];
            if (j - w[i + 1] >= 0) {
                chmax(dp[i + 1][j], dp[i][j - w[i + 1]] + v[i + 1]);
            }
        }
    }

    i64 res = 0;
    REP(j, W + 1) {
        chmax(res, dp[N - 1][j]);
    }
    cout << res << endl;
}

int main() {
    cin >> N >> W;
    REP(i, N) cin >> w[i] >> v[i];

    solve();

    return 0;
}

Measured memory_bytes: 79232
for _ in [0]*int(input()):
    s=input()
    cur=0
    for _ in [0]*int(input()):
        c=input()
        if c=='forward word':
            while cur<len(s) and s[cur]==' ':cur+=1
            while cur<len(s) and s[cur]!=' ':cur+=1
        elif c=='delete char':s=s[:cur]+s[cur+1:]
        elif c=='backward word':
            while cur>0 and s[cur-1]==' ':cur-=1
            while cur>0 and s[cur-1]!=' ':cur-=1
        elif c=='forward char':cur=min(len(s),cur+1)
        elif c=='delete word':
            if s[cur:].count(' ') == len(s[cur:]): continue
            while cur<len(s) and s[cur]==' ':s=s[:cur]+s[cur+1:]
            while cur<len(s) and s[cur]!=' ':s=s[:cur]+s[cur+1:]
        elif c[0]=='i':
            c=c.split('"')[1]
            s=s[:cur]+c+s[cur:]
            cur+=len(c)
        elif 'backward char':cur=max(0,cur-1)
    print(s[:cur]+'^'+s[cur:])

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

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

	int64 N;
	bool flag = 0;
	while (cin >> N && N) {
		int64 c[4] = {};
		int64 pr[4] = {10, 50, 100, 500};
		int64 use[4] = {};
		int64 res[4] = {};
		int64 cnt = INF;
		REP(i, 4) cin >> c[i];

		if (flag) cout << endl;
		flag=1;

		auto oturi = [&](int64 x) {
			vector<int> ret(4, 0);
			int64 cnt = 0;
			for (int i = 3; i >= 0; i--) {
				while (pr[i] <= x) {
					x -= pr[i];
					ret[i]++;
				}
			}
			return ret;
		};
		

		for (use[0] = 0; use[0] < c[0]+1; use[0]++) {
			for (use[1] = 0;use[1] < c[1]+1; use[1]++) {
				for (use[2] = 0; use[2] < c[2]+1; use[2]++) {
					for (use[3] = 0; use[3] < c[3] + 1; use[3]++) {
						int64 sum = 0;
						REP(i, 4) {
							sum += use[i] * pr[i];
						}
						if (sum < N) continue;
						bool flag = 0;
						auto luz = oturi(sum-N);
						int64 oturi_cnt = 0;
						REP(i, 4) {
							oturi_cnt += luz[i];
							if (luz[i] * use[i] != 0) {
								flag=1;
							}
						}
						if (flag) break;
						int64 ret = c[0]+c[1]+c[2]+c[3] - use[0]-use[1]-use[2]-use[3];
						ret += oturi_cnt;
						if (ret < cnt) {
							REP(i, 4) {
								res[i] = use[i];
							}
						}
					}
				}
			}
		}

		REP(i, 4) {
			if (res[i]) {
				cout << pr[i] << " " << res[i] << endl;
			}
		}
	}
}



Measured memory_bytes: 3148
#include <stdio.h>

void putcross(int a){
    int i;
    for(i=0;i<a;i++){
        if(i%2==0)
            printf("#");
        else
            printf(".");
    }
        printf("\n");

}

    
    
    void putpoint(int a){
    int i;
    for(i=0;i<a;i++){
        if(i%2==0)
            printf(".");
        else
            printf("#");
        }
        printf("\n");
        }



void putframe(int a,int b){
    int i;
    for(i=0;i<a;i++)
    {
        if(i%2==0)
            putcross(b);
        else
            putpoint(b);
    }



}

int main() {
    int a,b;
    while(1){
    scanf("%d%d",&a,&b);
        if(a==0&&b==0)
            break;
    putframe(a,b);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2064
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

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

    ll N, A, B;
    cin >> N >> A >> B;
    if (N == 1) {
        cout << (A != B ? 0 : 1) << endl;
    } else if(A>B){
        cout << 0 << endl;
    } else {
        cout << (N - 2)*(B - A) + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll INF=1<<30;

int gcd(int a,int b){
    if(a<b) swap(a,b);
    while(a%b!=0){
        a = a%b;
        swap(a,b);
    }
    return b;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    int ans=a[0];
    for(int i=1;i<n;i++){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;

int main()
{
    int a, b;
    cin >> a >> b;
    string aa, bb;
    if (a < b)
    {
        for (int i = 0; i < b; i++)
        {
            cout << a;
        }
        cout << endl;
    }
    else
    {
        for (int i = 0; i < a; i++)
        {
            cout << b;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll;
#pragma GCC optimize("O3")
#define pb push_back
ll dp[101][(int)2e5];
int32_t main()  {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n , W;
    cin >> n >> W;
    for ( int  i = 0 ; i<=n ; i++) {
        for( int j = 0 ; j<=W ; j++) {
            dp[i][j]=0;
        }
    }
    ll w[n+1];
    ll v[n+1];
    for ( int i = 1 ; i <= n; i++) {
        cin >> w[i];
        cin >> v[i];
    }
    for ( int i = 1 ; i<=n ; i++) {
      for ( int j = 1 ; j <=W ; j++)
      {
          if(j-w[i] >= 0)
            dp[i][j]=max( dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
          else
            dp[i][j]= dp[i-1][j];
      }  
  }
  ll ans=1;
  for ( int i   = 0 ; i<=W ; i++) {
      ans=max(ans, dp[n][i]);
  }
  cout<<ans<<endl;
}
        


Measured memory_bytes: 157184
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ').map { it.toInt() }
 
    val x = (a * 100 + 7) / 8
    if (x / 10 == b) {
        println(x)
        return
    }
 
    val y = b * 10
    if (y * 8 / 100 == a) {
        println(y)
        return
    }
 
    println(-1)
}


Measured memory_bytes: 38240
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


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

Measured memory_bytes: 256
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(abs(a-c)+abs(b-c)==abs(a-b)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
X.sort()
Y.sort()
Z=[i for i in range(x+1,y+1)]
if X[-1]<Y[0]:
  z=[i for i in range(X[-1]+1,Y[0]+1)]
  if len(set(z)&set(Z))>0:
    print("No War")
  else:
    print("War")
else:
  print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}

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

int main(void) {
    long int n;
    cin>>n;
    long int d[n+5],cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>d[i];
        if(d[i]%2==0)
        {
            while(d[i]%2==0)

            {
                d[i]/=2;
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;




    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n, x;
int ans[262144], flg[262144];

int main(){
  cin >> n >> x;
  if (x==1 || x==2*n-1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    if (x < n){
      ans[n-1] = x+1; ans[n] = x; ans[n+1] = x-1;
      flg[x+1]++; flg[x]++; flg[x-1]++; 
      if (n>2) {ans[n+2] = x+2; flg[x+2]++;} 
    }else{
      ans[n-1] = x-1; ans[n] = x; ans[n+1] = x+1;
      flg[x+1]++; flg[x]++; flg[x-1]++; 
      if (n>2) {ans[n+2] = x-2; flg[x-2]++;} 
    }
    int offs = 1;
    for(int i=1;i<=2*n-1;i++){
       if (ans[i]==0){
         for(;offs<=2*n-1;offs++){
           if (flg[offs]==0){
             ans[i] = offs; break;
           }
         }offs++;
       }
      cout << ans[i] << endl;
    }    
  }
    
  return 0;
}

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

int main() {
  string a;
  cin >> a;
  
  if (a.at(0) == 'a'){
    cout << "vowel" ;
  }
  else if(a.at(0) == 'i'){
    cout << "vowel" ;
  }
  else if(a.at(0) == 'u'){
    cout << "vowel" ;
  }
  else if(a.at(0) == 'e'){
    cout << "vowel" ;
  }
  else if(a.at(0) == 'o'){
    cout << "vowel" ;
  }
  else{
    cout << "consonant";
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Random r = new Random();
        int n = 10000000;
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = r.nextInt();
        }
        Arrays.parallelSort(a);
        solve();
    }

    public static void solve() {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        System.out.println(r * r);
        sc.close();
    }
}


Measured memory_bytes: 68764
x = int(input())
if 400 <= x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)
elif 1000 <= x < 1200:
    print(5)
elif 1200 <= x < 1400:
    print(4)
elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
elif 1800 <= x < 2000:
    print(1)

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

using namespace std;

const int md = 1e9 + 7;

int add(int x, int y) {
  x += y;
  if (x >= md) {
    x -= md;
  }
  return x;
}

int sub(int x, int y) {
  x -= y;
  if (x < 0) {
    x += md;
  }
  return x;
}

int mul(int x, int y) {
  return (long long)x * y % md;
}

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }
  vector<int> ways(n + 1);
  ways[0] = 1;
  for (int i = 1; i <= n; ++i) {
    ways[i] = mul(ways[i - 1], (i << 1) - 1);
  }
  vector<vector<int>> f(n << 1, vector<int> (n << 1));
  vector<vector<int>> g(n << 1, vector<int> (n << 1));
  int answer = 0;
  for (int l = (n << 1) - 1; ~l; --l) {
    for (int r = l + 1; r < n << 1; r += 2) {
      bool flag = true;
      int inside = 0;
      for (int i = 0; i < m; ++i) {
        int type = (a[i] >= l && a[i] <= r) + (b[i] >= l && b[i] <= r);
        if (type == 1) {
          flag = false;
          break;
        }
        if (type) {
          ++inside;
        }
      }
      if (flag) {
        inside = (r - l + 1 >> 1) - inside;
        int outside = n - m - inside;
        f[l][r] = g[l][r] = ways[inside];
        for (int i = l + 1; i < r - 1; i += 2) {
          f[l][r] = sub(f[l][r], mul(f[l][i], g[i + 1][r]));
        }
        answer = add(answer, mul(f[l][r], ways[outside]));
      }
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
ll LCM(ll x, ll y) { 
  return x / GCD(x, y) * y;
}

int main(){
  int n, k; cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    int h; cin >> h;
    if(h >= k) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> cards(4, vector<int>(13, 0));
  int n; cin >> n;
  for (int i = 0; i < n; i++){
    string t; int z; cin >> t >> z;
    if (t == "S") cards[0][z - 1] = 1;
    if (t == "H") cards[1][z - 1] = 1;
    if (t == "C") cards[2][z - 1] = 1;
    if (t == "D") cards[3][z - 1] = 1;
  }
  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 13; j++){
      if (!cards[i][j]){
        if (i == 0) cout << "S ";
        if (i == 1) cout << "H ";
        if (i == 2) cout << "C ";
        if (i == 3) cout << "D ";
        cout << j + 1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> ans(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll temp=1;
  for(ll i=0;i<n;i++) {
    ans[0]+=a[i]*temp;
    temp*=-1;
  }
  for(ll i=0;i<n-1;i++) {
    ans[i+1]=2*a[i]-ans[i];
  }
  for(ll i=0;i<n;i++) {
    if(i!=0) {
      cout << " ";
    }
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 2944
#include <stdio.h>
#define N 251

int parent(int );
int left(int );
int right(int );

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

    scanf("%d",&n);

    for(i=1;i<=n;i++) scanf("%d",&A[i]);

    for(i=1;i<=n;i++){
        printf("node %d: key = %d, ",i,A[i]);
        if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
        if(left(i)<=n) printf("left key = %d, ",A[left(i)]);
        if(right(i)<=n) printf("right key = %d, ",A[right(i)]);
        printf("\n");
    }
    return 0;
}

int parent(int i){
    return i/2;
}

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}

Measured memory_bytes: 600
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    N = c+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(g,h):
        return (fac[g+h]*pow(fac[g],MOD-2,MOD)*pow(fac[h],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 82200
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    ll Y;
    cin >> N >> Y;
    rep(i, N+1){
        int j = 0;
        do{
            int k = N - (i + j);
            ll x, y, z;
            x = i * 10000;
            y = j * 5000;
            z = k * 1000;
            ll sum = x + y + z;
            if(sum == Y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
            if(sum > Y) break;
            j++;
        }while(j < (N + 1) - i);
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

int main() {
	int N, M;
	cin >> N >> M;

	cout << (N * 3+M) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

const long INF = 10000000000000;
 
int main(){
    int A, B, Q;
    cin >> A >> B >> Q;
 
    vector<long> s, t;
    s.push_back(-1*INF);
    t.push_back(-1*INF);
    for(int i=0; i<A; i++){
        long a;
        cin >> a;
        s.push_back(a);
    }
    for(int i=0; i<B; i++){
        long b;
        cin >> b;
        t.push_back(b);
    }
    s.push_back(INF);
    t.push_back(INF);
 
    long x[Q];
    for(int i=0; i<Q; i++){
        cin >> x[i];
    }
 
    long ans[Q];
    for(int i=0; i<Q; i++){
        ans[i] = 100000000000000;
 
        auto sind = lower_bound(s.begin(), s.end(), x[i]);
        auto tind = sind;
        vector<long> sl;
        sl.push_back(*sind);
        sl.push_back(*(--sind));
        for(auto se : sl){
            tind = lower_bound(t.begin(), t.end(), se);
            ans[i] = min(ans[i], abs(x[i]-se)+abs(se-(*tind)));
            tind--;
            ans[i] = min(ans[i], abs(x[i]-se)+abs(se-(*tind)));
        }
 
        tind = lower_bound(t.begin(), t.end(), x[i]);
        vector<long> tl;
        tl.push_back(*tind);
        tl.push_back(*(--tind));
        for(auto te : tl){
            sind = lower_bound(s.begin(), s.end(), te);
            ans[i] = min(ans[i], abs(x[i]-te)+abs(te-(*sind)));
            sind--;
            ans[i] = min(ans[i], abs(x[i]-te)+abs(te-(*sind)));
        }
    }
 
    for(int i=0; i<Q; i++){
        cout << ans[i] << endl;
    }
 
    return 0;
}


Measured memory_bytes: 4596
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
long long k,s,x,y,z,he;
int main()
{
	cin>>k>>s;
	for(int i=0;i<=k;i++)
	{
		x=i;
		for(int j=0;j<=k;j++)
		{
			y=j;
			if(s-(x+y)>=0&&s-(x+y)<=k)
			{
				he++;
			}
		}
	}
	cout<<he;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int takahashi_hp = sc.nextInt();
        int takahashi_att = sc.nextInt();
        int aoki_hp = sc.nextInt();
        int aoki_att = sc.nextInt();
        while (true) {
            aoki_hp -= takahashi_att;
            if (aoki_hp <= 0) {
                System.out.println("Yes");
                break;
            }
            takahashi_hp -= aoki_att;
            if (takahashi_hp <= 0) {
                System.out.println("No");
                break;
            }
        }
    }
}


Measured memory_bytes: 35732
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int n, m, k;

int main() {
    scanf("%d %d %d", &n, &m, &k);
    vector<int> a(n + 1, 0), b(m + 1, 0);
    vector<long long> sumA(n + 1, 0), sumB(m + 1, 0);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        sumA[i] = sumA[i - 1] + a[i];
    }
    for (int i = 1; i <= m; ++i) {
        scanf("%d", &b[i]);
        sumB[i] = sumB[i - 1] + b[i];
    }

    int max_ans = 0;
    int j = m;
    for (int i = 0; i <= n; ++i) {
        if (sumA[i] > k) {
            break;
        }
        while (sumB[j] > k - sumA[i]) {
            j--;
        }
        max_ans = max(max_ans, i + j);
    }

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


Measured memory_bytes: 7928
import string
n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
sl = [list(input()) for i in range(n)]

alpha = list(string.ascii_lowercase)

dic = {si: sl[0].count(si) for si in alpha}

for s in sl:
    for ch in alpha:
        dic[ch] = min(dic[ch], s.count(ch))
ans = ''
for ch in alpha:
    for i in range(dic[ch]):
        ans += ch
print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  int maxcount = 0;
  
  for (int j = 0; j < N; j++) {
    int count = 0;
    for (int j1 = 0; j1 < j + 1; j1++) {
      count += A.at(0).at(j1);
    }
    for (int j2 = j; j2 < N; j2++) {
      count += A.at(1).at(j2);
    }
    if (count > maxcount) {
    maxcount = count;
    }
  }
  cout << maxcount << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ara[104][104];
int r,c;
int C[10004];
int fx[]={0,1,0,-1,0,1,0,-1};
int fy[]={1,0,-1,0,1,0,-1,0};
bool vis[105][105];
void dfs(int x,int y,int i)
{
//    cout<<x<<" "<<y<<" "<<i<<" "<<C[i]<<endl;
    ara[x][y]=i;
    vis[x][y]=1;
    for(int k=0;k<8;k++)
    {
        int xx=x+fx[k];
        int yy=y+fy[k];
        if(xx>=0&&yy>=0&&xx<r&&yy<c)
        {
            if(vis[xx][yy]==0)
            {
                if(C[i]==0)i++;
                C[i]--;
                dfs(xx,yy,i);
            }
        }
    }
    return;
}

int main()
{
        memset(ara,0,sizeof ara);
        memset(C,0,sizeof C);
        cin>>r>>c;
        int n;cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>C[i];
        }
        C[1]--;
        dfs(0,0,1);
        for(int i=0;i<r;i++)
        {
            for(int j=0;j<c;j++)
            {
                cout<<ara[i][j];
                if(j<c-1)cout<<" ";
            }
            cout<<endl;
        }

}
/*
6 6
6
1 4 2 8 15 6

5 5
6
1 4 2 3 12 3

5 5
5
5 5 5 5 5
*/


Measured memory_bytes: 896
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))

	if 0 in  A:
		print(0)
		return

	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return

	print(prod)

main ()

Measured memory_bytes: 21560
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
const int N = 1e6+5;
int n,ans,val[N];
char s[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%s",s+1),n=strlen(s+1);
	for(ri i=1;i<=n;++i) val[i]=s[i]-'0';
	reverse(val+1,val+1+n);
	for(ri i=1;i<=n;++i){
		if(val[i]<5) ans+=val[i];
		else if(val[i]>5) ans+=10-val[i],++val[i+1];
		else{
			if(val[i+1]>=5) ++val[i+1];
			ans+=5;
		}
		if(val[i+1]>=10) val[i+1]-=10,++val[i+2];
	}
	print(ans+val[n+1]);
	return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
using namespace std;
int main(){
  string w;
  string t;
  cin >> w;
  int i;
  for(i=0;i<w.size();i++) {
    if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
  }
  int o=0;
  cin >> t;
  while(t!="END_OF_TEXT"){
  
    for(i=0;i<t.size();i++) {
      if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
    }
    if(w==t) o++;
    cin >> t;
  }
  cout << o << endl;
}



Measured memory_bytes: 3220
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    x, a, b = read_int_list()
    if abs(a - x) < abs(b - x):
        print('A')
    else:
        print('B')


main()


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<queue>
#include<functional>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<ll,int> P;
int N,M;ll C;
vector<P>G[100000];
ll S[100000];
vector<P>NUM;
bool F[100000];
ll SUM=0;
int main()
{
	scanf("%d%d%lld",&N,&M,&C);
	for(int i=0;i<N;i++)S[i]=100000000000000;
	for(int i=0;i<M;i++){
		int A,B;ll D;
		scanf("%d%d%lld",&A,&B,&D);A--;B--;
		SUM+=D;
		G[A].push_back(P(D,B));
		G[B].push_back(P(D,A));
	}
	priority_queue<P,vector<P>,greater<P> >que;
	que.push(P(0,0));
	while(!que.empty()){
		P p=que.top();que.pop();
		ll pf=p.first;int ps=p.second;
		if(S[ps]<=pf)continue;
		S[ps]=pf;
		for(int i=0;i<G[ps].size();i++){
			if(pf+G[ps][i].first<S[G[ps][i].second]){
				que.push(P(pf+G[ps][i].first,G[ps][i].second));
			}
		}
	}
	for(int i=0;i<N;i++){
		NUM.push_back(P(S[i],i));
	}
	sort(NUM.begin(),NUM.end());
	ll ans=SUM;
	for(int i=0;i<N;i++)F[i]=true;
	F[0]=false;
	for(int i=1;i<N;i++){
		F[NUM[i].second]=false;
		for(int j=0;j<G[NUM[i].second].size();j++){
			if(F[G[NUM[i].second][j].second])continue;
			SUM-=G[NUM[i].second][j].first;
		}
		//printf("%d:%lld\n",i,SUM);
		ans=min(ans,C*NUM[i].first+SUM);
		//printf("%d:%lld\n",i,C*NUM[i].first+SUM);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18724
# -*- coding: utf-8 -*-


def main():
    s = input()
    # 判定をシンプルにするため，'BC'を'D'と置き換える
    # ループを扱いやすくするため，リストを反転させる
    mod_s = list(s.replace('BC', 'D'))[::-1]
    d_count = 0
    ans = 0

    # 文字列にBCが存在する必要がある
    # 操作をよく見ると，BCの左側にあるAを右側に移動させていることと同じ
    # BCが出現してから，
    #   1. Aが現れたときはBCを飛び越えた回数を答えに加算
    #   2. BCが現れたら，BCを管理する変数のカウントを1増やす
    #   3. BかCが単独で現れたら，BCを管理する変数のカウントをリセット
    for si in mod_s:
        if si == 'D':
            d_count += 1
        elif si == 'A':
            ans += d_count
        else:
            d_count = 0

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6376
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]
# print(xyc)
cost = []
cost.append(min(a) + min(b))
for x, y, c in xyc:
    tmp = a[x - 1] + b[y - 1] - c
    cost.append(tmp)
print(min(cost))


Measured memory_bytes: 42556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fcout cout << fixed << setprecision(18)

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

  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> P(N); for (ll i = 0; i < N; i++) cin >> P[i];
  vector<ll> S(N + 1, 0);
  for (ll i = 1; i <= N; i++) {
    S[i] = S[i - 1] + P[i - 1];
  }

  double ans = 0;
  for (ll i = 0; i < N; i++) {
    if (i + K > N) break;
    double temp = S[i + K] - S[i];
    ans = max(ans, (temp + K) / 2.0);
  }

  fcout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include <numeric>
#include <queue>

using namespace std;
#define rep(i, s, n) for(int i = s;i<n;i++)

int main(void) {
    int n, m;
    vector<int> x;
    priority_queue<int> diff;

    cin >> n >> m;
    n--;
    rep(i, 0, m) {
        int temp;
        cin >> temp;
        x.push_back(temp);
    }

    if ((n >= m) || (m == 1)) {
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());

    rep(i, 0, m - 1) {
        diff.push(x[i + 1] - x[i]);
    }

    rep(i, 0, n) {
        diff.pop();
    }

    long long int sum = 0;
    while (!diff.empty()) {
        sum += diff.top();
        diff.pop();
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <ctype.h>
using namespace std;

int main(){
	char s;
  	cin>>s;
  	char t1=tolower(s);
  	char t2=toupper(s);
  	
  	if(t1==s){
    	cout<<"a"<<endl;
    }else if(t2==s){
    	cout<<"A"<<endl;
    }
  	//cout<<t1<<" "<<t2<<endl;
 
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  if(a * b >= c * d) cout << a * b << endl;
  else cout << c * d << endl;
  return;
}

int main(){
  solve();
  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++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


VI g[100005];
VI ans(100005, -1);

int main() {
	int n, m;
	cin >> n >> m;
	
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	queue<int> q;

	for (int i : g[0]) {
		ans[i] = 0;
		q.push(i);
	}

	while (!q.empty()) {
		int i = q.front();
		q.pop();

		for (int j : g[i]) {
			if (ans[j] == -1) {
				ans[j] = i;
				q.push(j);
			}
		}
	}

	FOR(i, 1, n) {
		if (ans[i] == -1) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	FOR(i, 1, n) {
		cout << ans[i] + 1 << endl;
	}





}


Measured memory_bytes: 10232
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using Graph = vector<vector<pair<int, int>>>;
vector<int> color;

void dfs(const Graph& G, pair<int, int> v, int col) {
  color[v.first] = 1 + ((v.second % 2) + (col - 1)) % 2;
  for (auto& next_v : G[v.first]) {
    if (color[next_v.first]) continue;
    dfs(G, next_v, color[v.first]);
  }
}

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

  Graph G(n);
  rep(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    G[u - 1].push_back(make_pair(v - 1, w));
    G[v - 1].push_back(make_pair(u - 1, w));
  }

  color.assign(n, 0);
  dfs(G, make_pair(0, 0), 1);
  rep(i, n) { cout << color[i] - 1 << endl; }
  return 0;
}


Measured memory_bytes: 8192
#include<stdio.h>
int n,s=1,k,i;
int min(int x,int y)
{
    if(x>y)
    return y;
    else
    return x;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)
    {s+=min(s,k);}
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(c - (a - b), 0) << endl;
  return 0;
}

Measured memory_bytes: 256