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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e17;

LL dfs(const vector<vector<PLL>>& G, vector<bool>& used, int u, int p, int k){
  if(k == 1){
	LL res = 0;
	for(auto&& e: G[u]){
	  if(used[e.FF] && e.FF != p)
		res += e.SS;
	}
	return res;
  }

  LL res = -INF;
  used[u] = true;
  for(auto&& e: G[u]){
	if(e.FF == p) continue;
	res = max(res, dfs(G, used, e.FF, u, k-1) + e.SS);
  }
  used[u] = false;

  return res;
}

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

  LL N, K, S;
  while(cin>>N>>K>>S,N){
	vector<vector<PLL>> G(N);
	vector<VL> ps(N, vector<LL>(3));
	REP(i,N) REP(j,3) cin >> ps[i][j];
	REP(i,N) REP(j,i){
	  VL ls(3), rs(3);
	  REP(k,3)
		ls[k] = min(ps[i][k], ps[j][k]),
		rs[k] = max(ps[i][k], ps[j][k]);
	  bool inter = true;
	  REP(k,3) inter = inter && (rs[k] <= ls[k] + S);
	  if(!inter) continue;

	  LL surf = 0;
	  REP(k1,3) REP(k2,3)
		if(k1 != k2)
		  surf += (ls[k1] + S - rs[k1]) * (ls[k2] + S - rs[k2]);
	  G[i].EB(j, surf);
	  G[j].EB(i, surf);
	}

	LL ans = -INF;
	vector<bool> used(N);
	REP(i,N){
	  LL ret = dfs(G, used, i, -1, K);
	  maxi(ans, ret);
	}
	cout << (ans<0? -1: S*S*6*K - ans) << endl;
  }

  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
vector<ll> a;
vector<ll> f;
int main() {
    ll n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        ll a1;
        cin >> a1;
        a.push_back(a1);
    }
    for (int i = 0; i < n; i++) {
        ll a2;
        cin >> a2;
        f.push_back(a2);
    }
    sort(a.begin(), a.end(), greater<ll>());
    sort(f.begin(), f.end());
    ll m = -1;
    ll M = 1000000000001;
    while (M - m > 1) {
        ll med = (M + m) / 2;
        ll count = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > med / f[i]) {
                count += a[i] - med / f[i];
            }
        }
        if (k < count) {
            m = med;
        }
        else {
            M = med;
        }
    }
    cout << M << endl;
    return 0;
}

Measured memory_bytes: 7956
#include<iostream>
#include<climits>
using namespace std;
int main(){
	int n,sum,m,dp[30][30],a,b,c,d,now,tar,mon,pri;
	cin>>n;
	cin>>m;
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++){
		if(i!=j)
			dp[i][j]=INT_MAX/2;
		else
			dp[i][j]=0;
	}
	for(int i=0;i<m;i++){
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		dp[a-1][b-1]=c;
		dp[b-1][a-1]=d;
	}
	scanf("%d,%d,%d,%d",&now,&tar,&mon,&pri);
	for(int k=0;k<n;k++)
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
	sum=dp[now-1][tar-1]+dp[tar-1][now-1]+pri;
	cout<<mon-sum<<endl;
	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np
from operator import itemgetter

k =int(input())
nmax=0
s = []
for i in range(1,200):
    for j in range(14):
        p = i
        for ii in range(j):
            p=p*10+9
        q = i // 100 + (i // 10) % 10 + i % 10 + 9*j
        r = p / q

        s.append((p,q,r))

s= sorted( s, key=itemgetter(2) )
#print(s)
num=0
for a in s :
    if a[0] > nmax:
        nmax = a[0]
        print(nmax)
        num += 1
        if num >= k :
            break 
    


Measured memory_bytes: 21656
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main()
{
    int64_t n;
    cin >> n;
    vector<int64_t> v(5);
    rep(i, 5) cin >> v.at(i);

    sort(v.begin(), v.end());

    int64_t mn = v.at(0);
    int64_t ans = 4 + (n + mn -1)/mn;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

struct UF{
	vector<int>par,sz;
	void init(int n){
		par.resize(n);
		sz.resize(n);
		for(int i=0;i<n;i++){
			par[i]=i;
			sz[i]=1;
		}
	}
	int find(int x){
		return x==par[x]?x:par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		sz[x]+=sz[y];
		par[y]=x;
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

signed main(){
	int N,M;
	cin >> N >> M;
	vector<int> a(N); for(auto& e:a)cin >> e;
	UF uf;
	uf.init(N);
	priority_queue<int,vector<int>,greater<int>>que;
	int ans = 0;
	vector<int>group(N,INF);
	REP(i,M){
		int a,b;
		cin>>a>>b;
		uf.unite(a,b);
	}
	REP(i,N){
		CHMIN(group[uf.find(i)],a[i]);
	}
	int mori = 0;
	REP(i,N){
		if(a[i] == group[uf.find(i)]){
			ans += a[i];
			group[uf.find(i)] = INF;
			mori++;
		}else{
			que.push(a[i]);
		}
	}
	//cout << mori << endl;
	int add = 0;
	REP(i,mori-2){
		if(que.empty()){
			cout<<"Impossible"<<endl;
			return 0;
		}
		add += que.top();
		que.pop();
	}
	if(mori == 1){
		cout << 0 << endl;
		return 0;
	}
	//cout << ans << " " << add << endl;
	cout << ans + add << endl;
}


Measured memory_bytes: 4472
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll x=1,y=0,z=0,k,n,m,h,ans = 0,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9 + 1;
  string s, t, u;
  bool ok=true;
  cin >> n >> m;
  if(n > m){
    rep(i,n){
      char c = m+'0';
      s += c;
    }
  }
  else{
    rep(i,m){
      char c = n+'0';
      s += c;
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<ll,ll>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  ll h,w,n;
  int dir[3] = {-1,0,1};
  cin >> h >> w >> n;
  vector <P> d;
  if(n > 0){
    REP(i,n){
      int a,b;
      cin >> b >> a;
      REP(j,3){
	REP(k,3){
	  if((a+dir[j] >= 2) && (a+dir[j] <= w-1) && (b+dir[k] <= h-1) && (b+dir[k] >= 2)){
	    d.pb(mk(a+dir[j],b+dir[k]));
	    //cout << a+dir[j] << "             " << b+dir[k] << endl;
	  }
	}
      }
  }
    //cout << 1 << endl;
    if(d.size() > 0)
      sort(d.begin(),d.end());
    ll res[10] = {0};
    
    P before = d[0];
    ll num = 1;
    /*REP(i,d.size()){
      cout << d[i].first << "   " << d[i].second << endl;
      }
    */
    //cout << 1 << endl;
    for(int i = 1;i < d.size();i++){
      if(before == d[i]){
	num++;
      }
      else{
	before = d[i];
	res[num]++;
	num = 1;
	
      }
    }
    //cout << 1 << endl;
    res[num]++;
    ll sum = 0;
    for(int i = 1;i < 10;i++)
      sum += res[i];
    res[0] = (h-2)*(w-2) - sum;
    REP(i,10){
      cout << res[i] << endl;
    }
  }
  else{
    cout << (h-2)*(w-2) << endl;
    REP(i,9){
      cout << 0 << endl;
    }
  }
  return 0;
}


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

int main()
{
    char a[5];
    cin>>a;
    if(a[0]=='7' || a[1]=='7' || a[2]=='7')
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3620
s = input()

def is_yymm(s):
    y, m = int(s[:2]), int(s[2:])
    return True if m > 0 and m < 13 else False

def is_mmyy(s):
    m, y = int(s[:2]), int(s[2:])
    return True if m > 0 and m < 13 else False

if is_yymm(s) and is_mmyy(s):
    print('AMBIGUOUS')
elif is_yymm(s) and not is_mmyy(s):
    print('YYMM')
elif not is_yymm(s) and is_mmyy(s):
    print('MMYY')
else:
    print('NA')


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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
const int answer[9] = {1, 2, 3, 4, 5, 6, 7, 8, 0};
const bool dir[9][4] = {{false, false, true, true},
                        {true, false, true, true},
                        {true, false, true, false},
                        {false, true, true, true},
                        {true, true, true, true},
                        {true, true, true, false},
                        {false, true, false, true},
                        {true, true, false, true},
                        {true, true, false, false}}; /* left, up, down, right */
vector<int> original(9, 0);

class board;

priority_queue<board> pq;
vector<int> searched[9][9];

class board{
public:
    int moves;
    int wrongs;
    int zero_place;
    int cost;
    vector<int> tiles;

    explicit board(vector<int> num, int move){
        wrongs = 0;
        tiles = num;
        REP(i, 9){
            if(num[i] == 0)
                zero_place = i;
            if(num[i] != answer[i])
                wrongs++;
        }
        moves = move;
        cost = wrongs + moves;
    }

    void board_to_int(){
        int k = 0;
        REP(i, 7)
            k += (tiles[i+2] * pow(10, i));
        for(int i = searched[tiles[0]][tiles[1]].size(); i > 0 ; i--)
            if(k == searched[tiles[0]][tiles[1]][i-1])
                return;
        pq.push(board(tiles, moves+1));
        searched[tiles[0]][tiles[1]].push_back(k);
        return;
    }

    void move() {
        if(dir[zero_place][0]){
            swap(tiles[zero_place], tiles[zero_place-1]);
            board_to_int();
            swap(tiles[zero_place], tiles[zero_place-1]);
        }
        if(dir[zero_place][1]){
            swap(tiles[zero_place], tiles[zero_place-3]);
            board_to_int();
            swap(tiles[zero_place], tiles[zero_place-3]);
        }
        if(dir[zero_place][2]){
            swap(tiles[zero_place], tiles[zero_place+3]);
            board_to_int();
            swap(tiles[zero_place], tiles[zero_place+3]);
        }
        if(dir[zero_place][3]){
            swap(tiles[zero_place], tiles[zero_place+1]);
            board_to_int();
            swap(tiles[zero_place], tiles[zero_place+1]);
        }
    }
};

bool operator< (board b1, board b2){
    return ((b1.cost > b2.cost) ? true : false);
}

int solve(){
    pq.push(board(original, 0));
    while(1){
        auto target = pq.top();
        if(target.wrongs == 0)
            return target.cost;
        pq.pop();
        target.move();
    }
}

int main() {
    REP(i, 9) cin >> original[i];
    int move = solve();
    cout << move << endl;
    return 0;
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N,K; cin>>N>>K;

  ll ans=0;

  reps(b,K+1,N+1){
    ans+=(N/b)*(b-K);
    ans+=max(0, (N%b)-K+1);
    if(K==0) --ans;
  }

  cout<< ans<<"\n";
}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Map<String,Integer> frequencies = new HashMap<>();

        String[] verdicts = {"WA","AC","TLE","RE"};
        for(String verdict:verdicts)frequencies.put(verdict,0);
        int n = Integer.parseInt(br.readLine());
        for(int i=0;i<n;i++){
            String verdict  = br.readLine();
            frequencies.put(verdict,frequencies.getOrDefault(verdict,0)+1);
        }
        System.out.println("AC" + " x " +frequencies.get("AC"));
        System.out.println("WA" + " x " +frequencies.get("WA"));
        System.out.println("TLE" + " x " +frequencies.get("TLE"));
        System.out.println("RE" + " x " +frequencies.get("RE"));
    }
}


Measured memory_bytes: 44300
import numpy as np
n = int(input())
a = []
b = []
c = []
for i in range(n):
  a_i, b_i = map(int,input().split())
  a.append(a_i)
  b.append(b_i)
  c.append(a_i+b_i)
c.sort(reverse=True)
k = int((n+1)/2)
print(np.sum(c[::2])-np.sum(b))

Measured memory_bytes: 25648
num = [int(x) for x in input().split()]
array = []
for i in range(num[0]):
    array.append(list(input()))


for j in range(num[0]):
    for k in range(num[1]):
        cnt = 0
        if array[j][k] != "#":
            try:
                if array[j-1][k] == "#" and j-1 != -1:
                    cnt += 1
            except IndexError:
                pass
            try:
                if array[j-1][k-1] == "#" and j-1 != -1 and k-1 != -1:
                    cnt += 1
            except IndexError:
                pass
            try:
                if array[j-1][k+1] == "#" and j-1 != -1:
                    cnt += 1
            except IndexError:
                pass
            try:
                if array[j][k-1] == "#" and k-1 != -1:
                    cnt += 1
            except IndexError:
                pass
            try:
                if array[j][k+1] == "#":
                    cnt += 1
            except IndexError:
                pass
            try:
                if array[j+1][k] == "#":
                    cnt += 1
            except IndexError:
                pass
            try:
                if array[j+1][k-1] == "#" and k-1 != -1:
                    cnt += 1
            except IndexError:
                pass
            try:
                if array[j+1][k+1] == "#":
                    cnt += 1
            except IndexError:
                pass
            array[j][k] = str(cnt)

for i in array:
    print("".join(i))


Measured memory_bytes: 3188
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

template<class T>
class binary_heap{
	const static int N_MAX=3000;
	int n;
	T a[N_MAX+1];
public:
	binary_heap():n(0){}
	const T &find_min()const{ return a[1]; }
	void insert(const T &x){
		int u=++n;
		a[u]=x;
		while(u!=1 && a[u/2]>a[u]) swap(a[u/2],a[u]), u/=2;
	}
	void delete_min(){
		a[1]=a[n--];
		for(int u=1;;){
			int v=u;
			if(2*u+0<=n && a[v]>a[2*u+0]) v=2*u+0;
			if(2*u+1<=n && a[v]>a[2*u+1]) v=2*u+1;
			if(v==u) break;
			swap(a[v],a[u]);
			u=v;
		}
	}
	bool empty()const{ return n==0; }
	int size()const{ return n; }
};

struct edge{ int v,cost1,cost2; };

int main(){
	for(int m,n;scanf("%d%d",&m,&n),n;){
		vector<edge> G[100];
		rep(i,m){
			int u,v,cost1,cost2; scanf("%d%d%d%d",&u,&v,&cost1,&cost2); u--; v--;
			G[u].push_back((edge){v,cost1,cost2});
			G[v].push_back((edge){u,cost1,cost2});
		}

		int q; scanf("%d",&q);
		while(q--){
			int s,t,type; scanf("%d%d%d",&s,&t,&type); s--; t--;

			int d[100];
			rep(u,n) d[u]=(u==s?0:INF);
			static binary_heap< pair<int,int> > H; H.insert(make_pair(0,s));
			while(!H.empty()){
				int d_now=H.find_min().first,u=H.find_min().second;
				H.delete_min();

				if(d[u]<d_now) continue;

				rep(i,G[u].size()){
					const edge &e=G[u][i];
					int d2=d_now+(type==0?e.cost1:e.cost2);
					if(d[e.v]>d2){
						d[e.v]=d2;
						H.insert(make_pair(d2,e.v));
					}
				}
			}

			printf("%d\n",d[t]);
		}
	}

	return 0;
}

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


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int S; cin >> S;
  int a=S/100;
  int b=S%100;
  int A, B;
  if(a>12 || a==0){ A=0;}
  else A=1;
  if(b>12 || b==0){ B=0;}
  else B=1;
  if(A==0 && B==0){ cout << "NA" << endl;}
  if(A==0 && B==1){ cout << "YYMM" << endl;}
  if(A==1 && B==0){ cout << "MMYY" << endl;}
  if(A==1 && B==1){ cout << "AMBIGUOUS" << endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int A,B;
	cin >> A >> B;
	if(A<=5){
		cout << 0 << endl;
	}else if(A<=12){
		cout << B/2 << endl;
	}else{
		cout << B << endl;
	}
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

int main() {
	int N, x = 0, ans = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		ans = max(ans, x += (S[i] == 'I' ? 1 : -1));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
A = gets.to_i

isBreak = false
1000.times do |i|
    2000.times do |j|
        if A == i ** 5 - (j - 1000) ** 5 then
            isBreak = true
            puts "#{i} #{j - 1000}"
            break
        end
        break if isBreak
    end
end


Measured memory_bytes: 14296
from heapq import heappop,heappush
inf = float("inf")

n,m,s = map(int,input().split())

G = [[] for _ in range(n)]
for _ in range(m):
    u,v,cost,time = map(int,input().split())
    u -= 1
    v -= 1
    G[u].append((v,cost,time))
    G[v].append((u,cost,time))

for i in range(n):
    cost,time = map(int,input().split())
    G[i].append((i,-cost,time))

# mint[i][j]
# 銀貨j枚を持って都市iに付くことができる最小時間
mint = [[inf]*2451 for _ in range(n)]

# color[i][j]
# 銀貨j枚を持って都市iに付くことができる最小時間が確定したか
white = 0
black = 1
color = [[white]*2451 for _ in range(n)]

def dijkstra(u,s):
    # 銀貨50枚で49回移動が最大コスト、いらない分は捨てる
    s = min(s,2450)
    mint[u][s] = 0
    color[u][s] = black

    PQ = []
    heappush(PQ,(0,u,s))
    while PQ:
        # minv:PQ内の最小値
        # now:今いる都市
        # nowcoins:今持っている銀貨
        minv,now,nowcoins = heappop(PQ)
        color[now][nowcoins] = black
        # 最小時間じゃないなら無視
        if mint[now][nowcoins] < minv: continue
        
        # nxt: 次に行く都市
        # cost: 次の都市に行くのに使う銀貨
        # time: 次の都市に行くのにかかる時間
        # nxtcoins: 次の都市に行った段階で持っている銀貨
        for nxt,cost,time in G[now]:
            nxtcoins = min(nowcoins - cost,2450)
            if nxtcoins < 0: continue
            if color[nxt][nxtcoins]: continue
            if mint[nxt][nxtcoins] > minv + time:
                mint[nxt][nxtcoins] = minv + time
                heappush(PQ,(mint[nxt][nxtcoins],nxt,nxtcoins))

dijkstra(0,s)

# for i in range(n): print(mint[i])
# for i in range(n): print(color[i])
for i in range(1,n): print(min(mint[i]))

Measured memory_bytes: 24788
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int A, B, ans=-1;
  cin >> A >> B;
  for (int i=0; i<1001; i++) {
    if ((2*i)/25==A && i/10==B) {
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		//int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] NMK = Console.ReadLine().Split(' ');
		long N = long.Parse(NMK[0]);
		long K = long.Parse(NMK[1]);

		// N > K の時、N%KとKにする
		if(N > K)
		{
			N = N%K;
		}

		// N <= K の時、最小値 = MIN(N, K-N)
		long A = Math.Min(N, K-N);
		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
		//Console.WriteLine((a+b+c) + " " + s);
		Console.WriteLine(A);
	}
}


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


int main(){
  ll N,sum=0, i;
  cin>>N;
  for(i=1;i<=N;i++){
    sum+=i;
    if(sum>=N)break;
  }
  
  while(N>0){
    if( N>=i){
      cout<<i<<endl;
      N-=i;
    }
    i--;
  }
  
  return 0;
}


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

using namespace std;

#define pb push_back
#define fio ios::sync_with_stdio(false);

typedef long long ll;
typedef pair <ll, ll> pi;

const ll maxn =  55556;
const ll N = 277775;
const ll mod = 1e9 + 7;

ll n, m, sm;
bool isp[maxn];
vector <ll> pr, res;

int main() {
    fio;
    cin >> n;
    for (int i = 2; i < maxn; i++)
        isp[i] = true;
    for (int i = 2; i * i < maxn; i++) {
        if (!isp[i])
            continue;
        for (int j = 2; i * j < maxn; j++)
            isp[i * j] = 0;
    }
    for (int i = 0; i < maxn; i++)
        if (isp[i])
            pr.pb(i);
    ll it = 0;
    while (n) {
        if (pr[it] % 5 == 1) {
            n--;
            res.pb(pr[it]);
            it++;
        } else
            it++;
    }
    for (int i = 0; i < res.size(); i++)
        cout << res[i] << " ";
}

Measured memory_bytes: 384
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    llint n;
    cin >> n;
    string ans;
    while(n){
        n--;
        ans+=('a'+n%26);
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

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




Measured memory_bytes: 3620
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        if(k % 2 == 0) System.out.println(a - b);
        else System.out.println(b - a);
        sc.close();
    }

}


Measured memory_bytes: 22740
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    dp=[10**10]*(1<<n)
    dp[0]=0
    for i in range(m):
        a,b=map(int,input().split())
        C=list(map(int,input().split()))
        d=0
        for c in C:
            d|=1<<(c-1)
        for j in range(1<<n):
            dp[j|d]=min(dp[j|d],dp[j]+a)
    if dp[-1]==10**10:
        print(-1)
    else:
        print(dp[-1])
        
if __name__=='__main__':
    main()

Measured memory_bytes: 3188
function inI()
    a = Ref{Int64}(0)
    ccall(:scanf, Int32, (Ptr{UInt8}, Ref{Int64},), "%lld", a)
    Int(a[])
end

function outI(x::Int64)
    ccall(:printf, Void, (Ptr{UInt8}, Int64), "%lld\n", x)
end

let
    n = inI()
    x = Int[inI() for _ in 1:n]
    l = inI()
    q = inI()
    const lg = 20
    F = Array(Int, lg, n)
    B = Array(Int, lg, n)
    for i = 1:n
        F[1,i] = searchsortedlast(x, x[i]+l)
        B[1,i] = searchsortedfirst(x, x[i]-l)
    end

    for fe = 2:lg
        for i = 1:n
            F[fe,i] = F[fe-1,F[fe-1,i]]
            B[fe,i] = B[fe-1,B[fe-1,i]]
        end
    end

    for i = 1:q
        a = inI()
        b = inI()

        ans = 1
        if a < b
            for fe = lg:-1:1
                if F[fe,a] < b
                    a = F[fe,a]
                    ans += 2^(fe-1)
                end
            end
        else
            for fe = lg:-1:1
                if B[fe,a] > b
                    a = B[fe,a]
                    ans += 2^(fe-1)
                end
            end
        end
        outI(ans)
        #println(ans)
    end
end


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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  bool isAwin = true;

  if((b-a) % 2 == 0){
    isAwin = true;
  }else{
    isAwin = false;
  }
  
  if(isAwin){
    cout << "Alice" << endl;
  }else{
    cout << "Borys" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c, k;
  cin>>a>>b>>c>>k;
  int f = 0;
  int mx = max(a, max(b, c));
  int mn = min(a, min(b, c));
  if (mx == c && mn == a && a != b && b != c && c != a) f = 1;
  while (k-- && f != 1)
  {
    if (mx != c || (mx == c && (mx == a || mx == b))) c *= 2;
    else if (mx == c && b <= a) b *= 2;
    else;
    mx = max(a, max(b, c));
    mn = min(a, min(b, c));
    if (mx == c && mn == a && a != b && b != c && c != a) f = 1;
    //cout<<a<<" "<<b<<" "<<c<<endl;
  }
  if (f == 1) cout<<"Yes";
  else cout<<"No";
}

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

int main(){ 
  ll N,K,Ans;
  cin >> N >> K;
  Ans = 0;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec[i];
  }
  std::sort(vec.begin(),vec.end());
  for(int i = 0; i < K; i++){
    Ans += vec[i];
  }
  cout << Ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}
 
void solve() {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    vector<int> dp(n, 0);
    REP1(i, n - 1) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i != 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << EOL;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b;

int main()
{
    cin >> a >> b;
    int ans = a + b;
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int W, H, x, y, r;
    string c = "No";
    cin >> W >> H >> x >> y >> r;
    if (((r <= x) && (x <= W-r)) && ((r <= y) && (y <= H-r)))
        c = "Yes";
    cout <<  c  <<endl;
}

Measured memory_bytes: 3220
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    var min = Int.MAX_VALUE
    var ans = 0
    for (i in 0 until N) {
        if (min > A[i]) min = A[i]
        if (A[i] == min) ans += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 83092
from collections import Counter

n = int(input())
v_list = [int(i) for i in input().split()]
odd_v = v_list[::2]
even_v = v_list[1::2]

cnt_odd = Counter(odd_v).most_common()+[(0, 0)]
cnt_even = Counter(even_v).most_common()+[(0, 0)]

if cnt_odd[0][0] == cnt_even[0][0]:
    print(min(n-cnt_odd[0][1]-cnt_even[1][1], \
              n-cnt_odd[1][1]-cnt_even[0][1]))
else:
    print(n-cnt_odd[0][1]-cnt_even[0][1])

Measured memory_bytes: 21212
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>

typedef struct{
	int to, cost;
} Edge;

typedef std::pair<int, int> P;	//<cost, pos>

const int kMaxSize	= 32;
const int kMaxField = kMaxSize*kMaxSize;
const int kCostFriendlyInk = 1;
const int kCostShot = 2;
const int kCostBlank = 2;
const int kShotRange = 3;

const char kWall = '#';
const char kFriend = 'o';
const char kEnemy = 'x';
const char kStart = 'S';
const char kGoal = 'G';
const char kBlank = '.';

char field[kMaxField];
int way[4] = { -1, 1, -kMaxSize, kMaxSize };

const int kInf = 1 << 16;
int d[kMaxField];
std::vector<Edge> cost[kMaxField];
int R, C;

inline int xy2pos(const int x, const int y){
	return x + y*kMaxSize;
}

void initCost(){
	for (int y = 1; y <= R; y++){
		for (int x = 1; x <= C; x++){
			int pos = xy2pos(x, y);
			if (field[pos] == kWall) continue;
			for (int i = 0; i < 4; i++){
				for (int j = 1; j <= kShotRange; j++){
					int newpos = pos + j*way[i];
					if (field[newpos] == kWall) break; //?£?????????????????????????
					if (j == 1){
						if (field[newpos] == kFriend) cost[pos].push_back({ newpos, kCostFriendlyInk });
						else if (field[newpos] == kEnemy) cost[pos].push_back({ newpos, kCostShot + kCostFriendlyInk });
						else cost[pos].push_back({ newpos, kCostBlank });
					}else{
						int newcost;
						if (field[newpos] == kFriend)
							newcost = std::min(kCostShot + kCostFriendlyInk * j, cost[pos].back().cost + kCostFriendlyInk);
						else if (field[newpos] == kEnemy)
							newcost = kCostShot + kCostFriendlyInk * j;
						else
							newcost = std::min(kCostShot + kCostFriendlyInk * j, cost[pos].back().cost + kCostBlank);
						cost[pos].push_back({ newpos, newcost });
					}
				}
			}
		}
	}
}

void dijkstra(int spos){
	std::priority_queue<P, std::vector<P>, std::greater<P>> q;
	std::fill(d, d + kMaxField, kInf);
	d[spos] = 0;
	q.push(P( 0, spos ));

	while (!q.empty()){
		P p = q.top(); q.pop();
		if (d[p.second] < p.first) continue;
		for (unsigned int i = 0; i < cost[p.second].size(); i++){
			Edge e = cost[p.second][i];
			if (d[e.to] > d[p.second] + e.cost){
				d[e.to] = d[p.second] + e.cost;
				q.push(P( d[e.to], e.to ));
			}
		}
	}
}

int main(){
	int start, goal;

	std::fill(field, field + kMaxField, '#');

	std::scanf("%d %d", &R, &C);
	for (int y = 1; y <= R; y++)
		for (int x = 1; x <= C; x++){
			int pos = xy2pos(x, y);
			std::scanf(" %c", &field[pos]);
			if (field[pos] == kStart) start = pos;
			else if (field[pos] == kGoal) goal = pos;
		}
	initCost();
	dijkstra(start);
	printf("%d\n", d[goal]);
	return 0;
}

Measured memory_bytes: 2852
n = int(input())
line1 = list(map(int, input().split()))
line2 = list(map(int, input().split()))
answer = 0
for i in range(n):
    line1_sum = sum(line1[:i+1])
    line2_sum = sum(line2[i:])
    total = line1_sum + line2_sum
    answer = max(answer, total)
print(answer)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> w = vector<int>(n);
  vector<int> v = vector<int>(n);
  rep(i, n) {
    cin >> w[i] >> v[i];
  }

  vector<vector<ll>> dp = vector<vector<ll>>(n + 1, vector<ll>(W + 10, -1));
  dp[0][0] = 0;
  rep(i, n) {
    rep(j, W) {
      if(dp[i][j] == -1) continue;
      chmax(dp[i + 1][j], dp[i][j]);
      if(j + w[i] > W) continue;
      chmax(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
    }
  }

  ll ans = 0;
  rep(i, W + 1) {
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 80256
''' DFS(TLE)
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    def rep(r,c,nest):
        global cnt
        f=s[r][c]
        if f=='.':return
        s[r][c]='.'
        if r>0:
            if s[r-1][c]==f:rep(r-1,c,False)
        if r<a[0]-1:
            if s[r+1][c]==f:rep(r+1,c,False)
        if c>0:
            if s[r][c-1]==f:rep(r,c-1,False)
        if c<a[1]-1:
            if s[r][c+1]==f:rep(r,c+1,False)
        if nest==True:
            cnt+=1 
    for i in range(a[0]):
        s.append(list(input()))
    for i in range(a[0]):
        for j in range(a[1]):
            rep(i,j,True)
    print(cnt)
'''
#
''' BFS(List)
import queue
dr=[0,0,1,-1]
dc=[1,-1,0,0]
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    for i in range(a[0]):
        s.append(list(input()))
    q=queue.Queue()
    for i in range(a[0]):
        for j in range(a[1]):
            if s[i][j]=='.':continue
            f=s[i][j]
            l=[[i,j]]
            while len(l)!=0:
                next_depth=[]
                for cor in l:
                    for k in range(4):
                        r=cor[0]+dr[k]
                        c=cor[1]+dc[k]
                        if 0<=r<a[0] and 0<=c<a[1] and s[r][c]==f:
                            s[r][c]='.'
                            next_depth.append([r,c])
                l=next_depth
            cnt+=1
    print(cnt)
'''
#
''' BFS(Queue) '''
import queue
dr=[0,0,1,-1]
dc=[1,-1,0,0]
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    for i in range(a[0]):
        s.append(list(input()))
    q=queue.Queue()
    for i in range(a[0]):
        for j in range(a[1]):
            if s[i][j]=='.':continue
            f=s[i][j]
            q.put([i,j])
            while not q.empty():
                cor=q.get()
                for k in range(4):
                    r=cor[0]+dr[k]
                    c=cor[1]+dc[k]
                    if 0<=r<a[0] and 0<=c<a[1] and s[r][c]==f:
                        s[r][c]='.'
                        q.put([r,c])
            cnt+=1
    print(cnt)

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

bool primeNumber(int n){
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
int main()
{
    long long x;
    cin >> x;

    while (!(primeNumber(x)))
    {
        x++;
    }
    
    cout << x << endl;
}

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

const ll Mod = 1e9+7;

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
  return modpow(a, mod-2, mod);
}

ll cal_comb(ll a, ll b, ll mod) {
  if (b > a-b) return cal_comb(a, a-b, mod);
  ll bunsi = 1;
  ll bunbo = 1;
  for (int i = 0; i < b; ++i) {
    bunsi *= (a - i);
    bunsi %= mod;
    bunbo *= (i + 1);
    bunbo %= mod;
  }
  return bunsi * modinv(bunbo, mod) % mod;
}

int main() {
  ll X, Y;
  cin >> X >> Y;
  ll s = 2*X-Y, t = 2*Y-X;
  if (!(s%3) && !(t%3) && s/3 >= 0 && t/3 >= 0) {
    ll a = s / 3, b = t / 3;
  	cout << cal_comb(a+b, a, Mod) << endl;
  }
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <vector>


using namespace std;


int main(void) {

	vector<int> v = { 0 };

	int N;
	char data;
	int i = 0;
	int cnt = 0;

	cin >> N;

	v.resize(4);
	
	while (N > 0) {
		cin >> data;
		N--;
		switch (data) {
			case 'P':
				v[0]=1;
				break;
			case 'W':
				v[1]=1;
				break;
			case 'G':
				v[2]=1;
				break;
			case 'Y':
				v[3]=1;
				break;
		}
	}

	for (int j = 0; j < 4; j++) {
		if (v[j] == 1)
			cnt++;
	}

	if (cnt == 4)
		cout << "Four" << endl;
	else if (cnt == 3)
		cout << "Three" << endl;
	else if (cnt == 2)
		cout << "Two" << endl;
	else
		cout << "One" << endl;

	return 0;

}

Measured memory_bytes: 256
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

def solve():
    n, k = NextInts()
    da = NextIntList()
    ans = 1
    MOD = 10**9+7
    
    if n == k:
        for i in range(n):
            ans = ans*da[i]%MOD
        return ans
    
    neg = []
    pos = []
    for i in range(n):
        if da[i] < 0:
            neg.append(da[i])
        else:
            pos.append(da[i])
    neg.sort()
    pos.sort()

    if len(pos) == 0 and k%2 == 1:
        neg.reverse()
        for i in range(k):
            ans = ans * neg[i] % MOD
        return ans
    
    pos.reverse()
    li = []
    po, ne = 0, 0
    if k%2 == 1:
        po = 1
        ans = pos[0]
    while po+1 < len(pos):
        li.append(pos[po]*pos[po+1])
        po += 2
    while ne+1 < len(neg):
        li.append(neg[ne]*neg[ne+1])
        ne += 2
    li.sort()
    li.reverse()
    for i in range(k//2):
        ans = li[i] * ans % MOD
    return ans

if __name__ == "__main__":
    print(solve())

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(s == u) {
        a--;
    }
    else if(t == u)
        b--;
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}
int main()
{
    Imposter
    
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll l;
        cin>>l;
        long double side=(double)l/3;
        long double vol=side*side*side;
        cout<<fixed<<setprecision(6)<<vol<<endl;
        
    }
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll x = (a1 - b1) * t1;
    ll y = (a2 - b2) * t2;
    if(x > 0){
        x *= -1;
        y *= -1;
    }
    if(x+y == 0){
        cout << "infinity" << endl;
        return 0;
    }
    if(x+y < 0){
        cout << 0 << endl;
        return 0;
    }
    ll z = (-x) / (x+y);
    if((-x)%(x+y)) cout << (z*2 + 1LL) << endl;
    else cout << z*2 << endl;
    return 0;
}


Measured memory_bytes: 3624
/****************************************

	LostMartian

****************************************/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define LOCAL #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
	clock_t z = clock();
	FAST
	//LOCAL
	ll n;
	cin>>n;
	cout<<n+(n*n)+(n*n*n)<<"\n";
	

	debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 3776
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

A, B, C, K = MAP()

if K%2:
	print(B-A)
else:
	print(A-B)

Measured memory_bytes: 5200
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(System.in);){
			long N = Long.parseLong(scan.next());
			List<Long> list = new ArrayList<Long>();
			for(int i=0;i<5;i++) {
				list.add(Long.parseLong(scan.next()));
			}
			Collections.sort(list);
          	long minDist = list.get(0);
			long min = (N + minDist - 1) / minDist;
			long ans = min + 4;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#define ll long long
using namespace std;
int num[10005];
int main()
{
   int a,m;
   scanf("%d",&a);
    int sum=0;
    if(a==0)
        printf("0\n");
    else
    {
        while(a)
        {
            if(a%2!=0)
            {
                num[++sum]=1;
                a=(a-1)/(-2);
            }
            else
            {
                num[++sum]=0;
                a=a/(-2);
            }
        }
        for(int i=sum;i>=1;i--)
            printf("%d",num[i]);
    }
    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 N = sc.nextInt();
		char[] alp = new char[]{'M','A','R','C','H'};
		long[] count = new long[5];
		for( int i=1; i<=N; i++ ){
			String ss = sc.next();
			char cc = ss.charAt(0);
			for( int j=0; j<=4; j++ ){
				if( cc==alp[j] ){
					count[j]++;
					break;
				}
			}
		}
		long ans = 0;
		for( int i=0; i<=2; i++ ){
			for( int j=i+1; j<=3; j++ ){
				for( int k=j+1; k<=4; k++ ){
					ans += count[i]*count[j]*count[k];
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 47196