akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<int> a(n+1);
    FOR(i, n+1) cin >> a[i];
    if (a[0] > 1) {
        cout << - 1 << endl;
        return 0;
    }
    if (a[0] == 1){
        if (n > 0)
            cout << - 1 << endl;
        else
            cout << 1 << endl;
        return 0;
    }
    if (n==0 && a[0] != 1){
        cout << - 1 << endl;
        return 0;
    }

    vector<ll> b(n+1);
    b[n] = a[n];
    FORI(i, n) b[i] = b[i+1] + a[i]; b[0] = 1;//max no nodes at each depth
    ll x = 1;
    ll sol = 1;
    FOR1(i, n) {
        x = min(2*x, b[i]) - a[i]; //non-leaf nodes
        b[i] = x + a[i];
        if (x < 0) {
            sol = -1;
            break;
        }
        else
            sol += b[i];
    }
    if (x != 0) sol = -1;
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 4468
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

int main(){

    int n; cin >> n;

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

    int cnt = 1;

    int hmax = h[0];

    for(int i=1; i<n; i++){
        if(hmax <= h[i]){
            cnt++;
            hmax = h[i];
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

int main() {
    vector<int> nums(3);
    for (int i = 0; i < 3; ++i) cin >> nums[i];
    sort(nums.begin(), nums.end());
    cout << nums[2]*10 + nums[1] + nums[0] << endl;
    return 0;
}


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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    double ans = (arr[0]+arr[1])/2;
    for(int i=2;i<n;i++)
    {
        ans = (ans+arr[i])/2;
    }
    cout<<fixed<<ans<<"\n";

}

Measured memory_bytes: 3788
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define REP(i,b,n) for(int (i)=b; (i)<(int)(n); ++(i))
#define rep(i,n) REP(i,0,n)
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(a) (a).begin(),(a).end()
#define print(var) cout<<#var":"<<(var)<<endl;
#define printkv(key,var) cout<<#key":"<<(var)<<endl;
#define updatemax(dst,src) dst=max(dst,src);
#define updatemin(dst,src) dst=min(dst,src);

typedef long long ll;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
  if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

int main() {
  string o, e;
  while (cin>>o>>e) {
    int n = o.size();
    int m = e.size();
    rep(i,n) {
      cout<<o[i];
      if (i <= (m - 1)) {
        cout<<e[i];
      }
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n=gets.to_i

a=1
b=n-1
ans=1000000

(n-1).times{
    
    aa=a.to_s.split("")
    bb=b.to_s.split("")
    
    aa=aa.map(&:to_i)
    bb=bb.map(&:to_i)
    
    
    
    sum=aa.inject(:+)+bb.inject(:+)
   
   ans=[ans,sum].min
   
   a+=1
   b-=1
}


puts ans


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, K;
	cin >> N >> K;
	vector<ll> vec(N);
	rep(i,0,N){
		cin >> vec[i];
	}
	sort_desc(vec);
	if (K >= N){
		cout << 0 << endl;
	}
	else{
		ll sum = 0;
		rep(i,K, N){
			sum+=vec[i];
		}
		cout << sum << endl;
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string S;

int main()
{
	int ans = 0;

	cin >> S;

	int odd = 0;
	int even = 0;
	for (int i = 0;i<S.size(); i++) {
		if (i % 2 == 0 && S.at(i) == '0'
			|| i % 2 == 1 && S.at(i) == '1') {
			odd++;
		}
		else {
			even++;
		}
	}

	ans = min(odd,even);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf = 10e17;
const ll mod = inf;//1000000007;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);


ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans = mulmod(ans, n - i);

	 return mulmod(ans, inv[r]);
	// return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

bool binary_check(ll mid, ll key)
{
	return mid >= key;
}

ll binary_search()
{
//	ll ng = 0;
//	ll ok = x;
//
//	while (abs(ok - ng) > 1)
//	{
	//	ll mid = (ok+ng) / 2;
	//	if (binary_check(mid, k)) ok = mid;
	//	else ng = mid;
	//}

	return 0;
	//return ok;
}

ll solve(void)
{
	ll n, k;
	cin >> n >> k;

	map<ll, bool> m;
	for (ll i = 0; i < k; i++)
	{
		ll d;
		cin >> d;
		for (ll j = 0; j < d; j++)
		{
			ll a;
			cin >> a;
			m[a] = true;
		}
	}

	cout << n - m.size() << endl;

	return 0;
}

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int a,b,t;
		cin>>a>>b>>t;
		int p=t/a;
		int s=p*b;
		cout<<s;
		return 0;
	}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
S=input()

if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
    print("Yes")
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:
    print("Yes")
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    if n == 1 {
        println!("0");
    } else {
        println!("{}", (n * (n - 1)) / 2);
    }
}


Measured memory_bytes: 2160
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    res = 0
    for i in range(k, n + 2):
        mi = (i - 1) * i // 2
        ma = (n + (n - i + 1)) * i // 2
        res += ma - mi + 1
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define in(j,n) for(j=0;j<n;j++)
#define inp(j,n) for(j=1;j<=n;j++)
#define lo(i,st,n) for(i=st;i<n;i++)
#define pb push_back
#define csbits(n) __builtin_popcount(n)
int main()
{
  ll a,b;
  cin>>a>>b;
  if(a>9||b>9)
    cout<<"-1"<<endl;
  else
    cout<<a*b<<endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from math import floor
N = int(input())
res = N
for i in range(N+1):
    cc = 0
    t = i
    while t > 0:
        cc += t % 6
        t = t // 6
    t = N - i
    while t > 0:
        cc += t % 9
        t = t // 9
    if res > cc:
        res = cc
print(floor(res))

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    int N;cin>>N;
    string S;
    map<string,int> mp;
    for(int i=0;i<N;i++){
        cin>>S;
        mp[S]++;
    }
    int m=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        m=max(m,itr->second);
    }
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        if(itr->second==m){
            cout<<itr->first<<endl;
        }
    }    
    return 0;
}

Measured memory_bytes: 27136
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int n,x; cin >> n >> x;
  vector<int> l(n+1);
  
  for (int i=1; i<=n; i++)
    cin >> l[i];
  
  vector<int> d(n+1); d[1]=0;
  
  for (int i=2; i<=n+1; i++)
    d[i]=d[i-1]+l[i-1];
  
  int count = 0;
  
  for (int i=1; i<=n+1; i++){
    if (d[i]<=x)
      count++;
  }
  
  cout << count << endl;
    
  
  return 0;
}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int m;
    cin >> m;
    cout << 48 - m << "\n";
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M, ans = 1;
  cin >> N >> M;
  for(int i = 1; i * i < M; i += 1)
    if(M % i == 0){
      if(M / i >= N) ans = max(ans, i);
      if(i >= N) ans = max(ans, M / i);
    }
  cout << ans;
}

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

int main() {
  int N,K;
  int x;
  int i;
  int sum = 0;
  
  cin >> N >> K;
  
  for (i = 0; i < N; i++) {
  	cin >> x;
    if ( (K-x) > x ) {
      sum += 2 * x;
    } else {
      sum += 2 * (K-x);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int a, b, k;
    cin >> a >> b >> k;

    map<int, int> m;
    repd(i, a, b + 1) {
        if (i < a + k | b - k < i) {
            if (m[i] == 0) {
                cout << i << endl;
                m[i]++;
            }
        }
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

int main (){
    int S,h,m,s;
    cin>>S;
    h = S/3600;
    m = S%3600/60;
    s = S%3600%60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll k;
    cin >> k;
    ll n = 50;
    vector<ll> a(n, 1);
    rep(i, min(n, k)) {
        a[i] = n - i + ((k - (i + 1)) / n);
    }
    printf("%lld\n", n);
    rep(i, n) printf("%lld%s", a[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


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

int main(void){
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> b(n);
    rep(i,n) {
        if(i!=n-1){
            b[i] = abs(a[i] - a[i+1]);
        }
        else {
            b[i] = k - a[i] + a[0];
        }
        //cout << b[i] << endl;
    }
    int max = 0;
    int index = 0;
    rep(i,n) {
        if(max < b[i]){
            max = b[i]; index = i;
        }
    }
    ll ans = 0;
    rep(i,n) {
        if(i!=index) ans += b[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
   int a,b;
   scanf("%d %d",&a,&b);
  // int ans = (a+b)-1;
   //int ar = a*b;
   //int an = ar-ans;
   printf("%d\n",(a*b)-(a+b)+1);
   return 0;
   }

Measured memory_bytes: 128
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  cout.precision(15); cout << fixed;
  double a, b, h, m; cin >> a >> b >> h >> m;
  double alpha = ((60 * h + m)/720) * 2 * M_PI;
  double beta = (m / 60) * 2 * M_PI;
  double theta = alpha - beta;
  cout << sqrt(a*a + b*b - 2*a*b*cos(theta)) << endl;
  return 0;
}


Measured memory_bytes: 4120
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;


int main() {
	int n;
	cin>>n;
	ll t=1,a=1;
	for(int i=0;i<n;++i){
		ll a1,t1;
		cin>>t1>>a1;
		ll m1=1,m2=1;
		if(a1<a)m1=a/a1+(a%a1>0);
		if(t1<t)m2=t/t1+(t%t1>0);

		a1*=max(m1,m2);
		t1*=max(m1,m2);
		a=a1;
		t=t1;

	}
	cout<<a+t<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
int deg[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int x, y;
		cin >> x >> y;
		deg[x]++;
		deg[y]++;
	}
	for (int i = 1; i <= n; i++) cout << deg[i] << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "Good";
    if(s.charAt(0) == s.charAt(1)
        | s.charAt(1) == s.charAt(2)
        | s.charAt(2) == s.charAt(3)) {
      ans = "Bad";
    }
      System.out.println(ans);
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a, b;
  cin>>a>>b;
  if(a>b){
    swap(a, b);
  }
  REP(i, b){
    cout<<a;
  }
  cout<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


string s;
int red,blue;

int main(){
  cin >> s;
  int size = s.size();
  rep(i,size){
    if(s[i] == '0') red++;
    else blue++;
  }
  cout << size - abs(red-blue) << endl;
  
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, A;
    cin >> N >> A;

    vi X(N);
    REP(i, N) cin >> X[i];

    ll dp[N + 1][2501];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    FOR(k, 1, N + 1) {
        REP(i, k) {
            REP(j, 2501) {
                if (j - X[k-1] > -1) dp[k - i][j] += dp[k - i - 1][j - X[k-1]];
            }
        }
    }

    ll ans = 0;
    FOR(i, 1, N+1) {
        ans += dp[i][A * i];
    }

    print(ans);
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
int N,M;
bool fld[90][90];
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int rec(int x,int y){
      int res=0;
      REP(i,4){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx<0||nx>=M||ny<0||ny>=N||!fld[nx][ny])continue;
//            cout<<nx<<" "<<ny<<endl;
            fld[nx][ny]=false;
            res=max(res,rec(nx,ny));
            fld[nx][ny]=true;
      }
      return res+1;
}
int main(){
      while(cin>>M>>N&&M&&N){
            REP(i,N)REP(j,M)cin>>fld[j][i];
            int ans=0;
            REP(i,N)REP(j,M){
                  if(fld[j][i]){
//                        cout<<j<<" "<<i<<endl;
                        ans=max(ans,rec(j,i)-1);
                  }
            }
            cout<<ans<<endl;
      }
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (auto &i : a) {
    cin >> i;
  }
  cout << *max_element(a, a + n) - *min_element(a, a + n) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdio.h>

int main()
{
	int a, b;
	char op;

	scanf("%d %c %d", &a, &op, &b);

	while(op != '?'){

	 if(op == '+')
		printf("%d\n", a + b);
	else if(op == '-')
		printf("%d\n", a - b);
	else if(op == '*')
		printf("%d\n", a * b);
	else if(op == '/')
		printf("%d\n", a / b);

	scanf("%d %c %d", &a, &op, &b);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(){
  char line[128];
  int k;
  int min,max;
  fgets(line,sizeof(line),stdin);
  sscanf(line,"%d",&k);
  fgets(line,sizeof(line),stdin);
  sscanf(line,"%d%d",&min,&max);

  int i;
  for(i=min;i<=max;i++){
    if(i % k == 0){
      printf("OK");
      return 0;
    }
  }
  printf("NG");
  return 0;
}


Measured memory_bytes: 1748
(defn input []
  (->> (repeatedly 2 read-line)
    (into []
      (comp (mapcat #(clojure.string/split % #"\s"))
        (map #(Integer/parseInt %))))))

(defn CandyDistributionAgain [[N x & As]]
  (let [[C S](->> (sort As)
               (reductions +)
               (take-while (partial >= x))
               ((juxt count last)))]
    (cond
      (= x S) C
      (= C 0) 0
      (< C N)  C
      (= C N) (dec C))))

(->> (input)
  CandyDistributionAgain
  println)

Measured memory_bytes: 66760
n, m, x, y = map(int,input().split())
lsx = input().split()
lsy = input().split()
lsx = list(map(int, lsx))
lsy = list(map(int, lsy))
z = False

lsxmax = max(lsx)
lsymin = min(lsy)
for i in range(x + 1, y + 1):
	if ((i > lsxmax) and (i <= lsymin)):
		z = True
if(z):
	print("No War")
else:
	print("War")

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int x,y,smo,big,arr=1,arr2,ans;
  scanf("%d%d",&x,&y);
  if(x>=y){
    smo=y;
    big=x;
  }
    else{
      smo=x;
      big=y;
    }

    while(1){
      arr=(big%smo);
      if(arr==0){
	ans=smo;
	break;
      }
      arr2=smo;
      smo=arr;
      big=arr2;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>

int assort(const void *a,const void *b){return *(int*)a>*(int*)b?1:0;}

int main(void){
    int n;
    long long ans=0;
    scanf("%d",&n);
    int a[n],b[n],A[n],B[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for (int i=0; i<n; i++){
        scanf("%d",&b[i]);
    }
    for (int i=0; i<29; i++){
        long long t=1<<i,count=0;
        for (int j=0; j<n; j++){
            A[j]=a[j]%(2*t);
            B[j]=b[j]%(2*t);
        }
        qsort (B,n,sizeof(int),assort);
        for (int j=0; j<n; j++){
            int imin,imax,key,imid,tmp[4]={};
            for (int k=0; k<4; k++){
                imin=0,imax=n-1,key=(k+1)*t-A[j];
                if (B[n-1]<key){
                    imax=n;
                    imin=n;
                }
                while(imax-imin>1){
                    imid=imin+(imax-imin)/2;
                        if (B[imid]<key){
                        imin=imid;
                    } else {
                        imax=imid;
                    }   
                }
                if (B[imin]<key){
                    tmp[k]=imax;
                } else {
                    tmp[k]=imin;
                }
            }
            count+=tmp[1]-tmp[0]+tmp[3]-tmp[2];
        }
        if (count%2==1){
            ans+=t;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
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;
}
using namespace std;

void solve(){
 int a,b;
 cin>>a>>b;
 int ans=a-2*b;
 if(ans<0)cout<<0<<endl;
 else cout<<ans<<endl;
 return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n;
pair<string, ll> playlist[55];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >>  n;
	for (ll i= 0; i< n; i++){
		string a;
		ll b;
		cin >> a >> b;
		playlist[i] = mp(a, b);
		//~ cin >> playlist[i].F >> playlist[i].S;
	}
	string sleep;
	cin >> sleep;
	ll ans = 0;
	bool check = 0;
	for (ll i = 0; i< n; i++){
		if (check)ans += playlist[i].S;
		if (playlist[i].F == sleep){
			check=1;
		}
	}
	cout  << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pl pair<ll,ll>
#define plp pair<ll,pl>
#define ppl pair<pl,ll>
#define pb push_back
#define pi acos(-1.0)
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define vl vector<ll>
#define mp make_pair
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define vll vector<vector<ll>>
#define all(a) a.begin(),a.end()
#define INF 1e9+5
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
 
 //ll n,m;
ll MOD1=1000000007;
ll MOD2=998244353;
 
 
void yes() {cout<<"YES"<<endl;}
void no() {cout<<"NO"<<endl; }
/*
ll gcd(ll a,ll b);
ll lcm(ll a, ll b);
ll mod_exp(ll x,ll power,ll m);
ll ext_gcd(ll a,ll b,ll& x,ll& y);
void swap(ll& a,ll& b);
ll root(vector<ll>& arr,ll a);
void Union(vector<ll>& arr,ll a,ll b);
const ll N=32001;
vl fenwick(N,0);
void update(ll index,ll add);
ll sum(ll index);
ll find_kth_smalest(ll k);
ll find(ll k);
ll ETF(ll n);
*/
 
 


ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    return gcd(b%a, a);
}
 
ll lcm(ll a, ll b)
{
    return ( a*b/(gcd(a,b)));
}
 
//void sieve();
//vector<ll> factorise(1000+2,-1);
//vector<ll> prime(20005,1);
//vl fug;
//void p();
//void fact();
 
 
/*
void sieve()
{
    prime[0]=prime[1]=0;
    for(ll i=2;i<=sqrt(2005);i++)
    {
        if(prime[i]==1)
        {
            for(ll j=i*i;j<2005;j+=i)
                prime[j]=0;
        }
    }
}
*/





void solve()
{
    ll n; cin>>n;
    
    vll dp(n+1,vl(3,0));
    
    for(ll i=1;i<=n;i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);
    }
   
    cout<<max3(dp[n][0],dp[n][1],dp[n][2])<<endl;
    
    
    
    
    
    
    
    
    
    
    
}
 
int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll tests=1;
   // cin>>tests;
    while (tests--) {
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 8716
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>

using namespace std;
const int maxn = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;

ll x;
int main(){
	cin >> x;
	ll a = 0;
	a += x / 500 * 1000;
	x %= 500;
	a += x / 5 * 5;
	cout << a << endl;
}


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

int main() {
	int q, query, x;
	cin >> q;
	multimap<string, int> M;
	for (int i = 0; i < q; ++i) {
		cin >> query;
		if (0 == query) {
			string key;
			cin >> key >> x;
			M.emplace(key, x);
		}
		else if (1 == query) {
			string key;
			cin >> key;
			for (decltype(M)::iterator i = M.equal_range(key).first; i != M.equal_range(key).second; ++i) cout << i->second << endl;
		}
		else if (2 == query) {
			string key;
			cin >> key;
			M.erase(key);
		}
		else {
			string L, R;
			cin >> L >> R;
			for (multimap<string, int>::iterator i = M.lower_bound(L); i != M.upper_bound(R); ++i) cout << i->first << ' ' << i->second << endl;
		}
	}
}


Measured memory_bytes: 24748
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

typedef long long ll;

ll dp[2000][2000];
int cake[2000];
int n;

int main() {
	cin >> n;
	REP(i, n) scanf("%d", &cake[i]);
	
	REP(i, n) {
		REP(j, n) {
			int a = j, b = (j + i) % n;
			
			if ((n - i - 1) % 2 == 0) {
				dp[a][b] = max(dp[(a + 1) % n][b] + cake[a], dp[a][(b - 1 + n) % n] + cake[b]);
			}
			else {
				if (cake[a] > cake[b])
					dp[a][b] = dp[(a + 1) % n][b];
				else
					dp[a][b] = dp[a][(b - 1 + n) % n];
			}
		}
	}
	
	ll ans = 0;
	REP(i, n) ans = max(ans, dp[i][(i + n - 1) % n]);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34484
from collections import deque

K = int(input())

visited = [False] * K
Q = deque([(1, 1)])

while True:
    s, v = Q.popleft()
    if v == 0:
        print(s)
        quit()

    if visited[v]:
        continue
    visited[v] = True

    Q.appendleft((s, (10 * v) % K))
    Q.append((s + 1, (v + 1) % K))

Measured memory_bytes: 14444
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int X, A, B;
  cin >> X >> A >> B;
  if (A >= B) {
    cout << "delicious" << endl;
  } else if (A+X >= B) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int ans=-1;
  string s;
  while(getline(cin,s)){
    while(1){
      ans = s.find("the");
      if(ans!=-1)break;
      ans = s.find("this");
      if(ans!=-1)break;
      ans = s.find("that");
      if(ans!=-1)break;
      for(int i=0;i<s.size();i++){
	if(s[i]=='z') s[i]='a';
	else if(s[i]>='a' && s[i]<'z') s[i]++;
      }
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1176
x, y = input().split()
X = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6}

if X[x] > X[y]:
    print('>')
elif X[x] < X[y]:
    print('<')
else:
    print('=')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int h,w;cin >> h >> w;
	vector<string> S(h);
	rep(i,h)
	{
		cin>>S[i];
	}


	rep(i,h)
		rep(j,w)
		if(S[i][j]=='.')S[i][j]='0';

	rep(i,h)
		rep(j,w)
		if(S[i][j]=='#')
		{
			if(i-1>=0&&j-1>=0&&S[i-1][j-1]!='#')S[i-1][j-1]++;
			if(i>=0  &&j-1>=0&&S[i][j-1]!='#')S[i][j-1]++;
			if(i-1>=0&&j>=0  &&S[i-1][j]!='#')S[i-1][j]++;
			if(i+1<h &&j>=0  &&S[i+1][j]!='#')S[i+1][j]++;
			if(i>=0  &&j+1<w &&S[i][j+1]!='#')S[i][j+1]++;
			if(i+1<h &&j+1<w &&S[i+1][j+1]!='#')S[i+1][j+1]++;
			if(i+1<h &&j-1>=0&&S[i+1][j-1]!='#')S[i+1][j-1]++;
			if(i-1>=0&&j+1<w &&S[i-1][j+1]!='#')S[i-1][j+1]++;
			
		}


	rep(i,h)
	{
		cout<<S[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int _,__,___,____,_____,______,_______,________,_________,__________,___________;string s,t;int main(){	scanf("%d%d%d%d%d",&_,&__,&___,&____,&_____);
	cin>>s>>t;	________=0;__________=0;_________=__+1;___________=_+1;	for (int ______=___-1;______>=0;______--){		if (t[______]=='L'){
			_________=min(__+1,_________+1);		}		if (t[______]=='R'){			________=max(0,________-1);
		}		if (t[______]=='U'){			___________=min(_+1,___________+1);		}		if (t[______]=='D'){
			__________=max(0,__________-1);		}		if (s[______]=='R'){			_________--;		}		if (s[______]=='L'){			________++;	}		if (s[______]=='U'){			__________++;		}		if (s[______]=='D'){			___________--;		}		if (__________+1>___________-1){			puts("NO");
			return 0; 		}		if (________+1>_________-1){			puts("NO");
			return 0;		}	}	if (__________<____&&____<___________&&________<_____&&_____<_________) puts("YES"); else puts("NO");}


Measured memory_bytes: 776
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.StringTokenizer;
import java.util.TreeMap;
 
public class Main {
	
	public static boolean[][] mul(final int n, final boolean[][] mat1, final boolean[][] mat2){
		boolean[][] ret = new boolean[n][n];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				for(int k = 0; k < n; k++){
					ret[i][j] |= mat1[i][k] && mat2[k][j];
				}
			}
		}
		
		return ret;
	}
	
	public static boolean[][] pow(final int n, final boolean[][] adj, final int a){
		if(a == 1){
			boolean[][] ret = new boolean[n][n];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					ret[i][j] = adj[i][j];
				}
			}
			return ret;
		}else if(a % 2 == 0){
			boolean[][] ret = pow(n, adj, a / 2);
			return mul(n, ret, ret);
		}else{
			return mul(n, adj, pow(n, adj, a - 1));
		}
	}
	
	public static int[][] warshallFroyd(final int n, int[][] adj){
		int[][] ret = new int[n][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				ret[i][j] = adj[i][j];
			}
		}
		
		for(int k = 0; k < n; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					ret[i][j] = Math.min(ret[i][j], Math.min(ret[i][k] + ret[k][j], INF));
				}
			}
		}
		
		return ret;
	}
	
	public static final int INF = Integer.MAX_VALUE / 2 - 1;
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		final int m = sc.nextInt();
		
		int[] hops = new int[3];
		for(int i = 0; i < 3; i++){
			hops[i] = sc.nextInt();
		}
		
		boolean[][] adj = new boolean[n][n];
		for(int i = 0; i < m; i++){
			final int u = sc.nextInt() - 1;
			final int v = sc.nextInt() - 1;
			
			adj[u][v] = true;
		}
		
		boolean[][][] hop_adjs = new boolean[3][n][n];
		for(int index = 0; index < 3; index++){
			hop_adjs[index] = pow(n, adj, hops[index]);
			//System.out.println(Arrays.deepToString(hop_adjs[index]));
		}
		
		int[] costs = new int[n];
		Arrays.fill(costs, INF);
		costs[n - 1] = 0;
		
		while(true){
			boolean updated = false;
			
			LOOP:
			for(int from = 0; from < n; from++){
				int max_cost = 0;
				
				for(int type = 0; type < 3; type++){
					boolean found = false;
					int min_cost = INF;
					
					for(int next = 0; next < n; next++){
						if(!hop_adjs[type][from][next]){ continue; }
						if(costs[next] >= INF){ continue; }
						
						min_cost = Math.min(min_cost, costs[next] + 1);
						found = true;
					}
					
					if(!found){ continue LOOP; }
					max_cost = Math.max(max_cost, min_cost);
				}
				
				//System.out.println(max_cost + " " + from);
				if(costs[from] > max_cost){
					costs[from] = max_cost;
					updated = true;
				}
			}
			
			//System.out.println(Arrays.toString(costs));
			if(!updated){
				break;
			}
		}
		
		System.out.println(costs[0] >= INF ? "IMPOSSIBLE" : costs[0]);
	}
}

Measured memory_bytes: 36132
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

constexpr long long MOD = 1000000007;

int dfs(const std::array<int, 5>& a, std::array<bool, 5> state, int i, int t)
{
  if (i == 4)
  {
    auto it = std::find(begin(state), end(state), false);
    return t + a[it - begin(state)];
  }
  int ans = std::numeric_limits<int>::max();
  for (int j = 0; j < 5; ++j)
  {
    if (!state[j])
    {
      auto next = state;
      next[j] = true;
      ans = std::min(ans, dfs(a, next, i + 1, t + ((a[j] + 9)/ 10) * 10));
    }
  }
  return ans;
}

int main()
{
  std::array<int, 5> a;
  for (auto& val: a)
    std::cin >> val;
  std::array<bool, 5> s{false, false, false, false, false};
  std::cout << dfs(a, s, 0, 0) << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	long long a,b;
	long long u,ans=0;
	scanf("%d%lld%lld%lld",&n,&a,&b,&u);
	for(int i=2;i<=n;i++)
	{
		long long m;
		scanf("%lld",&m);
		if((m-u)*a<=b)
			ans+=(m-u)*a;
		else
			ans+=b;
		u=m;
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        int M, G, D;
        cin >> M >> G >> D;
        vector<string> lots(D);
        for(int i = 0; i < D; ++i) {
            cin >> lots[i];
            lots[i] = '0' + lots[i] + '0';
        }
        vector<vector<int> > history(D+1, vector<int>(N+2));
        for(int i = 0; i <= N+1; ++i) history[0][i] = i;

        //Simulation
        for(int turn = 1; turn < D+1; ++turn) {
            history[turn] = history[turn-1];
            for(int i = 1; i < N; ++i)
                if(lots[turn-1][i] == '1') swap(history[turn][i], history[turn][i+1]);
        }
        int target = history[D][G];
        if(target == M) cout << 0 << endl;
        else {
            for(int turn = 0; turn < D; ++turn) {
                for(int i = 1; i <= N; ++i) {
                    if(history[turn][i] == M) {
                        if(history[turn][i-1] == target && lots[turn].substr(i-2,3) == "000") {
                            cout << turn+1 << ' ' << i-1 << endl;
                            goto next;
                        }
                        else if(history[turn][i+1] == target && lots[turn].substr(i-1,3) == "000") {
                            cout << turn+1 << ' ' << i << endl;
                            goto next;
                        }
                    }
                }
            }
            cout << 1 << endl;
        }
next:
        ;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
 
typedef long long int ll;
const int MOD = 1e9 + 7;
const ll INF = __LONG_LONG_MAX__;
 
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  auto x = vector<ll>(N);
  auto y = vector<ll>(N);
  REP(i, N) cin >> x[i] >> y[i];
 
  ll ans = INF;
  REP(i1, N) REP(i2, N) REP(j1, N) REP(j2, N) {
    if(x[i1] == x[i2] || y[j1] == y[j2]) continue;
    ll xmin = min(x[i1], x[i2]);
    ll xmax = max(x[i1], x[i2]);
    ll ymin = min(y[j1], y[j2]);
    ll ymax = max(y[j1], y[j2]);
    int cnt = 0;
    REP(i, N) {
      if(xmin <= x[i] && x[i] <= xmax && ymin <= y[i] && y[i] <= ymax) {
        cnt++;
      }
    }
    if(K <= cnt) {
      ll s = (xmax - xmin) * (ymax - ymin);
      ans = min(ans, s);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr2[101];


int main()
{
    int a,b,c,d,e,f,g,h,i;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
    int n;
    cin>>n;
    bool is[101];
    memset(is,false, sizeof(is));
    int z;

    for(int i=0;i<n;i++){
        cin>>z;
        is[z]=true;
    }
if(is[a] && is[b] && is[c]) {
    cout<<"Yes"<<endl;
    return 0;
}
if(is[d] && is[e] && is[f]) {
    cout<<"Yes"<<endl;
    return 0;
}
if(is[g] && is[h] && is[i]) {
    cout<<"Yes"<<endl;
    return 0;
}
    if(is[a] && is[d] && is[g]) {
    cout<<"Yes"<<endl;
    return 0;
}
if(is[e] && is[b] && is[h]) {
    cout<<"Yes"<<endl;
    return 0;
}
if(is[f] && is[i] && is[c]) {
    cout<<"Yes"<<endl;
    return 0;
}
if(is[a] && is[e] && is[i]) {
    cout<<"Yes"<<endl;
    return 0;
}
if(is[g] && is[e] && is[c]) {
    cout<<"Yes"<<endl;
    return 0;
}



        cout<<"No"<<endl;
    }


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n,l;cin>>n>>l;
    int a[114514];
    rep(i,0,n)cin>>a[i];
    int last=-1;
    rep(i,0,n-1){
        if(a[i]+a[i+1]>=l)last=i;
    }
    if(last==-1){
        cout<<"Impossible"<<endl;return 0;
    }
    else cout<<"Possible"<<endl;
    rep(i,0,last)cout<<i+1<<endl;
    for(int i=n-1;i>=last+2;i--)cout<<i<<endl;cout<<last+1<<endl;
    return 0;;
}


Measured memory_bytes: 1664
from itertools import permutations
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
i=0
for j in permutations(range(1,n+1)):
  i+=1
  if list(j)==p:
      p=i
  if list(j)==q:
      q=i
print(abs(p-q))

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

int main(){
	int n, x, min, max;
	cin >> n;
	cin >> x;
	min = x;
	max = x;
	for(int i=1; i<n; ++i){
		cin >> x;
		if(x>max){max=x;}
		if(x<min){min=x;}
	}

	cout << (max-min)/2 + (max-min)%2 << endl;

	return 0;
}



Measured memory_bytes: 3088
#include <iostream>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)

using namespace std;

struct Node {
    long key = 0;
};

int main() {
    int n;
    cin >> n; 
    Node N[500] = {};
    rep(i,n) {
        long tmp;
        cin >> tmp;
        N[i+1].key = tmp;
    }
    rep(i,n) {
        cout << "node " << i+1 << ": key = " << N[i+1].key << ", ";
        if(N[(i+1)/2].key != 0) {
            cout << "parent key = " << N[(i+1)/2].key << ", ";
        }
        if(N[2*(i+1)].key != 0) {
            cout << "left key = " << N[2*(i+1)].key << ", ";
        }
        if(N[2*(i+1)+1].key != 0) {
            cout << "right key = " << N[2*(i+1)+1].key << ", ";
        }
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 3084
def solve():
    max_fare = 99000001
    def dijkstra(start, goal):
        unvisited = [i for i in range(n)]
        fare = [max_fare] * n
        fare[start] = 0
        
        while True:
            min_fare = max_fare
            for i in unvisited:
                f = fare[i]
                if f < min_fare:
                    min_fare = f
                    u = i
                    
            if u == goal:
                return min_fare
            elif min_fare == max_fare:
                return -1
            
            unvisited.remove(u)
            
            for v, f in adj[u]:
                if v in unvisited:
                    fare[v] = min(min_fare + f, fare[v])
        
    import sys
    file_input = sys.stdin
    
    while True:
        n, k = map(int, file_input.readline().split())
        if n == 0 and k == 0:
            break
        
        adj = [[] for i in range(n)]
        
        for i in range(k):
            line = file_input.readline()
            if line[0] == '0':
                a, b = map(int, line[2:].split())
                print(dijkstra(a - 1, b - 1))
            else:
                c, d, e = map(int, line[2:].split())
                adj[c - 1].append((d - 1, e))
                adj[d - 1].append((c - 1, e))

solve()


Measured memory_bytes: 6204