akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
 
using namespace std;
 
int main(){
  	int A,B,K,mid,dif;
  	cin >> A >> B;
  	dif = A - B;
	if(dif > 0){
    	mid = (A-B)/2;
	}else{
    	mid = (B-A)/2;
    }
  
  	if(dif%2 == 0){
   		if(A > B){
        	K = A - mid;
        }else{
        	K = B - mid;
        }
      	cout << K << endl;
    }else{
    	cout << "IMPOSSIBLE" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    cout << A[0] + A[1] << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


int N_all;


int main(int argc, char* argv[]){
    int i,j;
    int xx,yy,count;
    count=0;
    scanf("%d",&N_all);
    for(i=1;i<=N_all;i++){
        scanf("%d %d",&xx,&yy);
        if( xx == yy ){
            count++;
        }else{
            count = 0;
        }
        if(count >=3){
            printf("Yes");
            break;
        }
    }
    if(count<=2){
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1728
#include<cstdio>
#include<iostream>
using namespace std;
int a[10][10];
int main()
{
	cin>>a[1][1]>>a[1][2]>>a[2][2];
	a[3][1]=a[1][1]+a[1][2]-a[2][2];
	a[3][2]=a[2][2]-a[3][1]+a[1][1];
	int tmp=a[1][2]+a[2][2]+a[3][2];
	a[2][1]=tmp-a[1][1]-a[3][1];
	a[1][3]=tmp-a[1][1]-a[1][2];
	a[2][3]=tmp-a[2][1]-a[2][2];
	a[3][3]=tmp-a[3][1]-a[3][2];
	for(register int i=1;i<=3;i++)
	{
		for(register int j=1;j<=3;j++)
		{
			cout<<a[i][j]<<' ';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
_n = gets
cards = readlines.each_with_object({'S' => [], 'H' => [], 'C' => [], 'D' => []}) do |line, hash|
  suit, rank = line.split
  hash[suit] << rank.to_i
end
rank_array = (1..13).to_a
cards.each do |suit, ranks|
  (rank_array - ranks).each do |rank|
    puts "#{suit} #{rank}"
  end
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7;

int a[N];

struct BIT {
	int bit[N];
	void add(int pos, int val) {
		pos++;
		for(; pos < N; pos += pos & -pos)
			bit[pos] += val;
	}
	int qry(int pos) {
		pos++;
		int ret = 0;
		for(;pos;pos -= pos & -pos)
			ret += bit[pos];
		return ret;
	}
} x, y;

signed main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> a[i], a[i]--;	
	int ans = 0, mx = 0;
	for(int i = 0; i < n - 1; i++) {
		ans += (a[i + 1] - a[i] + m) % m;
		if(a[i + 1] == a[i] + 1) continue;
		if(a[i + 1] > a[i]) {
			x.add(a[i] + 1, 1), x.add(a[i + 1] + 1, -1);
			y.add(a[i] + 1, -a[i]), y.add(a[i + 1] + 1, +a[i]);
		}
		else {
			x.add(a[i] + 1, 1), x.add((m - 1) + 1, -1);
			y.add(a[i] + 1, -a[i]), y.add((m - 1) + 1, +a[i]);

			x.add(0, 1), x.add(a[i + 1] + 1, -1);
			y.add(0, m-a[i]), y.add(a[i + 1] + 1, -m+a[i]);	
		}
	}
	for(int i = 0; i < m; i++) {
		mx = max(mx, x.qry(i) * i - x.qry(i) + y.qry(i));
	}

	cout << ans - mx << endl;

}





Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
#define PI acos(-1)
using namespace std;
#define toLower(str)transform(str.begin(),str.end(),str.begin(),::tolower)

int main(){
    int i, j;
    char s[205], p[105], s1[105];
    cin >> s >> p;
    strcpy(s1, s);
    strcat(s, s1);
    if(strstr(s, p) == NULL) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3128
import math

def main():
    n, k = [int(c) for c in input().split()]
    ret = 0
    for i in range(1, n+1):
        tmp = 1 / n
        now = i
        while now < k:
            now *= 2
            tmp /= 2
        ret += tmp
    print(ret)

main()

Measured memory_bytes: 3060
s=input()
s1,s2=s[:2],s[2:]

if 1 <= int(s1) <= 12 and 1 <= int(s2) <= 12:
  print("AMBIGUOUS")
elif 1 <= int(s1) <= 12 and 0 <= int(s2) <= 99:
  print("MMYY")
elif 1 <= int(s2) <= 12 and 0 <= int(s1) <= 99:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  double ans=N*2.0*M_PI;
  printf("%.10lf\n",ans);
  }


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

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;
}

Measured memory_bytes: 256
'use strict'

function cake_score(array){
  return Math.abs(array[0]) + Math.abs(array[1]) + Math.abs(array[2])
}

function main(input){
  const lines = input.split('\n');
  const NM = lines.shift().split(' ').map(x => parseInt(x));
  const N = NM[0];
  const M = NM[1];

  const cakes = [];
  for(var i=0;i<N;i++){
    cakes.push( lines.shift().split(' ').map(x => parseInt(x)) )
  }

  let patterns = [
    [1,1,1],
    [1,-1,1],
    [1,1,-1],
    [1,-1,-1],
    [-1,1,1],
    [-1,-1,1],
    [-1,1,-1],
    [-1,-1,-1]
  ];

  let cake_patterns = [];
  for(let p of patterns){
    let current_scores = cakes.map(cake => 
      cake[0]*p[0] + cake[1]*p[1] + cake[2]*p[2]
    ).sort(function(a,b){return b-a;})

    cake_patterns.push(current_scores);
  }

//  console.log(cake_patterns);

  let m_cakes_score_pattern = cake_patterns.map( scores => scores.slice(0,M).reduce((a,b) => a + b, 0) )

//  console.log(m_cakes_score_pattern);

  let result = Math.max(...m_cakes_score_pattern);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

ll POW(ll n,ll m){
  ll pow = 1;
  while (m>0) {
    if ((m&1) == 1) pow = (pow*n)%MOD;
    m >>= 1;
    n = (n*n)%MOD;
  }
    return pow;
}

int main(){
    ll N; cin >> N;
    ll a = POW(10,N),b = POW(9,N),c=POW(8,N);
    AA((a-(b*2%MOD)+c+MOD)%MOD);
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
l = [0] * n
#for i in range(n):
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x*x+y*y+z*z+x*y+y*z+z*x
            if a <= n:
                l[a-1] += 1
for i in range(n):
    print(l[i])


Measured memory_bytes: 69072
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()


typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

#ifdef TESTING
#define DEBUG fprintf(stderr,"====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG 
#define VALUE(x)
#define debug(...)
#endif
/*
inline string IntToString(ll a) {
	char x[100];
	sprintf_s(x, "%lld", a); string s = x;
	return s;
}

inline ll StringToInt(string a) {
	char x[100]; ll res;
	strcpy_s(x, a.c_str()); sscanf_s(x, "%lld", &res);
	return res;
}
*/

inline string uppercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
	return s;
}

inline string lowercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
	return s;
}


int main()
{
	int n;
	cin >> n;
	int count[100002] = {};
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x == 0) {
			count[0]++;
			count[1]++;
		}
		else
		{
			count[x - 1]++;
			count[x]++;
			count[x + 1]++;
		}
	}
	int Max = 0;
	for (int i = 0; i < 100002; i++) {
		MAX(Max, count[i]);
	}
	cout << Max << endl;
}


Measured memory_bytes: 640
# https://atcoder.jp/contests/abc131/tasks/abc131_c



A, B, C, D = gets.split.map(&:to_i)

def multiple_count(x)
  B / x - (A - 1) / x
end

puts B - A + 1 - multiple_count(C) - multiple_count(D) + multiple_count(C.lcm(D))


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = CRLF;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  --N;
  vector<int> C(N), S(N), F(N);
  for (int i = 0; i < N; ++i) {
    cin >> C[i] >> S[i] >> F[i];
  }

  vector<int> result;
  for (int i = 0; i < N; ++i) {
    int t = S[i];
    t += C[i];
    for (int j = i+1; j < N; ++j) {
      int shupppatu;
      if (t < S[j]) {
        shupppatu = S[j];
      } else if (t % F[j] != 0) {
        shupppatu = t + (F[j] - (t % F[j]));
      } else {
        shupppatu = t;
      }
      t = shupppatu;
      t += C[j];
    }
    result.push_back(t);
  }
  result.push_back(0);
  
  cout << result << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define inf 100000000000
#define mod 1000000007


int main()
{
  int n;
  cin >> n;
    string a,b;
    cin >> a >> b;
    for(int i=0;i<a.size();i++)
    {
        cout << a[i] << b[i];
    }
    return 0;
}

Measured memory_bytes: 384
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter
def rl(s): return xrange(len(s))

INF = 2147483647


import sys
stdin = sys.stdin

S =        ( stdin.readline().strip() )

N = len(S)
ok_ends = [False] * (N+1)
ok_ends[0] = True
for i in range(1, N+1):
    for word in ['dream', 'dreamer', 'erase', 'eraser']:
        if S[max(0, i-len(word)): i] == word:
            if ok_ends[max(0, i-len(word))]:
                ok_ends[i] = True

if ok_ends[-1]:
    print "YES"
else:
    print "NO"


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

// main.cpp

std::int_fast64_t f(const std::int_fast64_t x) {
  const std::string s = std::to_string(x);
  return std::accumulate(s.begin(), s.end(), static_cast<std::int_fast64_t>(0), [](const std::int_fast64_t sum, const char c) {
    return sum + (c - '0');
  });
}

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::cout << (n % f(n) == 0 ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
K = int(input())

ans = []

for i in s:
    if i == "a":
        ans.append("a")
        continue
    
    if ord(i) + K >= ord("z") + 1:
        ans.append("a")
        K -= ord("z") + 1 - ord(i)
    
    else:
        ans.append(i)
        


last = (K + ord(ans[-1]) - ord('a')) % 26
ans[-1] = chr(ord("a") + last)
print(''.join(ans))

Measured memory_bytes: 46576
def seiseki(m,f,r):
    if m == -1 or f == -1:
        return 'F'
    if m + f >= 80:
        return 'A'
    if m + f >= 65 and m + f < 80:
        return 'B'
    if m + f >= 50 and m + f < 65:
        return 'C'
    if m + f >= 30 and m + f < 50 and r >= 50:
        return 'C'
    if m + f >= 30 and m + f < 50:
        return 'D'
    if m + f < 30:
        return 'F'

import sys

for l in sys.stdin:
    m, f, r = map(int,l.split())
    if f == -1 and m == -1 and r == -1:
        break
    print (seiseki(m,f,r))

Measured memory_bytes: 6444
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        BigDecimal A = new BigDecimal(scanner.next());
        BigDecimal B = new BigDecimal(scanner.next());
        BigDecimal C = A.multiply(B).setScale(0, RoundingMode.DOWN);
        System.out.println(C);
    }
}


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

int main() {
  vector<string> S(3);
  for (int i = 0; i < 3; i++) cin >> S.at(i);
  vector<int> N(3);
  for (int i = 0; i < 3; i++) N.at(i) = S.at(i).size();
  vector<int> K(3, 0);
  int X = 0;
  while (true) {
    K.at(X)++;
    if (K.at(X) == N.at(X) + 1) {
      if (X == 0) cout << "A" << endl;
      else if (X == 1) cout << "B" << endl;
      else if (X == 2) cout << "C" << endl;
      break;
    }
    if (S.at(X).at(K.at(X) - 1) == 'a') X = 0;
    else if (S.at(X).at(K.at(X) - 1) == 'b') X = 1;
    else if (S.at(X).at(K.at(X) - 1) == 'c') X = 2;
  }
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

use_clipboard=True
bbn=1000000007
	
#+++++

		
def main():
	n = int(input())
	al = list(map(int, input().split()))
	
	cc=defaultdict(lambda : 0)
	for v in al:
		cc[v] += 1
		
	ccl=[]
	for key in cc:
		ccl.append((key,cc[key]))
	ccl.sort(reverse=True)
	
	ma,mb=0,0
	for v,n in ccl:
		if ma == 0 and n >= 4:
			return v*v
		elif ma == 0 and n >= 2:
			ma = v
		elif n >= 2:
			return ma*v
	return 0
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 21412
n, m = map(int, input().split())
L, R = 0, n
for i in range(m):
    l, r = map(int, input().split())
    if l > L:
        L = l
    if r < R:
        R = r
if R-L+1 > 0:
    print(R-L+1)
else:
    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	int ans = A + B;
	ans = max(ans, A - B);
	ans = max(ans, A * B);
	cout << ans << endl;
}

Measured memory_bytes: 384
def main():
  n, m = map(int, input().split())

  p = 2 ** n
  inf = 10 ** 9
  dp = [inf] * p
  dp[0] = 0
  for i in range(m):
    a, b = map(int, input().split())
    c = sum([2 ** (int(j) - 1) for j in list(input().split())])
    for k in range(p):
      if dp[k|c] > dp[k] + a:
        dp[k|c] = dp[k] + a
  if dp[-1] == inf:
    print(-1)
  else:
    print(dp[-1])

  
if __name__ == "__main__":
    main()

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

using namespace std;
int main()
{
    string s; cin >> s;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == s[i+1]){
            cout << i + 1 << " " << i+1 + 1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < s.size() - 2; i++){
        if(s[i] == s[i+2]){
            cout << i + 1 << " " << i+2 + 1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;

}


Measured memory_bytes: 3736
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

typedef long long ll;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int prices[4] = {0}, N;
	double liter[4] = { 0.25, 0.5, 1, 2 };
	REP(i, 4) cin >> prices[i];
	cin >> N;

	ll one[3], two[4];
	REP(i, 3) one[i] = prices[i] * (1 / liter[i]);
	REP(i, 4) two[i] = prices[i] * (2 / liter[i]);

	int min_two = 0, min_one = 0;
	FOR(i, 1, 3)
	{
		if (one[min_one] > one[i]) min_one = i;
	}
	FOR(i, 1, 4)
	{
		if (two[min_two] > two[i]) min_two = i;
	}
	
	if (N == 1) {
		cout << prices[min_one] * (1 / liter[min_one]) << "\n";
	}
	else if (N % 2 == 0) {
		ll t = prices[min_two] * (2 / liter[min_two]);
		cout << t * (N / 2) << "\n";
	}
	else {
		ll t = prices[min_two] * (2 / liter[min_two]);
		ll o = prices[min_one] * (1 / liter[min_one]);
		cout << t * (N / 2) + o << "\n";
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


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

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;

    make_fact(N);
    make_invfact(N);

    ll res = 1;

    ll lef = 0, rig = 0;
    for(int i = 0; i < 2*N; i++){
        if(s[i] == 'B'){
            if((lef - rig) % 2 == 0){
                lef++;
            }
            else{
                res = mul(res, lef-rig);
                rig++;
                if(lef < rig){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        else{
            if((lef - rig) % 2 == 0){
                res = mul(res, lef-rig);
                rig++;
                if(lef < rig){
                    cout << 0 << endl;
                    return 0;
                }
            }
            else{
                lef++;
            }
        }
    }

    if(lef != rig){
        cout << 0 << endl;
        return 0;
    }

    cout << mul(res, fact[N]) << endl;


    return 0;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  int A = S.size();
  int M = 0;
  for(int i = 0; i < A; i++){
    if(S.at(i) == T.at(i)){
      M = M + 1;
    }
  }
  cout << A - M << endl;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int tot,n,m,fa[N],head[N],nex[N<<1],to[N<<1];
bool vis[N],vv[N<<1];
void add(int u,int v)
{
    to[tot]=v;nex[tot]=head[u];head[u]=tot++;
    to[tot]=u;nex[tot]=head[v];head[v]=tot++;
}
stack<int>s;
void dfs(int u)
{
    vis[u]=true;
    s.push(u);
    for(int i=head[u];~i;i=nex[i])
        if(!vis[to[i]])
            fa[to[i]]=i,dfs(to[i]);
}
int main()
{
    memset(head,-1,sizeof(head));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
    }
    if(m&1) {printf("-1\n");return 0;}
    dfs(1);
    while(!s.empty())
    {
        int u=s.top(),tot=0;s.pop();
        for(int i=head[u];~i;i=nex[i])
            if(!vv[i]&&i!=fa[u]&&i!=(fa[u]^1)) tot++;
        //cout<<u<<' '<<tot<<endl;
        if(tot&1)
        {
            for(int i=head[u];~i;i=nex[i])
                if(!vv[i])
                {
                    vv[i]=vv[i^1]=true;
                    printf("%d %d\n",u,to[i]);
                }
        }
        else
        {
            for(int i=head[u];~i;i=nex[i])
                if(!vv[i]&&i!=fa[u]&&i!=(fa[u]^1))
                {
                    vv[i]=vv[i^1]=true;
                    printf("%d %d\n",u,to[i]);
                }
        }
    }
}
/*
4 6
1 2
1 3
1 4
2 3
2 4
3 4
*/


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  char c;
  cin >> c;

  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    printf("vowel\n");
  }
  else printf("consonant\n");
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	int N;
	cin >> N;
	vector<ll> x(N), y(N), h(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}
	if (N == 1) {
		cout << x[0] << " " << y[0] << " " << h[0] << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (h[i] > 0) {
			swap(h[i], h[0]); swap(x[i], x[0]); swap(y[i], y[0]);
			break;
		}
	}
	for (int i = 0; i <= 100; i++)for (int j = 0; j <= 100; j++) { //中心 i,j
		ll H = abs(x[0] - i) + abs(y[0] - j) + h[0];
		if (H <= 0)continue;
		for (int k = 1; k < N; k++) {
			if (h[k] != max(H - abs(x[k] - i) - abs(y[k] - j),0LL))break;
			if (k == N - 1) {
				cout << i << " " << j << " " << H << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author HP
 */
public class Main {
   public static void main(String[] args) {
       Scanner s= new Scanner(System.in);
       int a = s.nextInt();
       long res = a;
       res += a*a +a*a*a;
       System.out.println(res);
   }
}

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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

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

ll sum(ll x) { // sum of subsequent numbers from 0 to x
	return x*(x + 1)/2;
}

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

	vector<string> ordered(n);
	queue<string> que;
	rep(i,n) {
		string s;
		cin >> ordered.at(i);
	}
	sort(ordered.begin(), ordered.end());
	//rep(i,n) cout << ordered.at(i) << endl;
	rep(i,n) que.push(ordered.at(i));

	int kind = 0;
	while (!que.empty()) {
		string ref;
		ref = que.front(); que.pop();
		kind++;
		int current_size = que.size();
		rep(i,current_size) {
			string current = que.front();
			if (ref == current) que.pop();
			else break;
		}
	}
	cout << kind << endl;
}


Measured memory_bytes: 16116
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        long D = in.i() * 2;
        int A = in.i();

        Monster[] monsters = new Monster[N + 1];
        for (int i = 0; i < N; i++) {
            int x = in.i();
            int h = in.i();
            monsters[i] = new Monster(x, h);
        }
        monsters[N] = new Monster(1 << 30, 0);
        Arrays.sort(monsters, (m1, m2) -> m1.x - m2.x);

        long[] q = new long[N];
        int pop = 0;
        int push = 0;

        long ans = 0;
        long extra = 0;

        for (int i = 0; i < N; i++) {
            int x = monsters[i].x;
            int h = monsters[i].h;

            while (pop < push) {
                long p = q[pop];
                int x2 = (int)(p >> 31);
                if (x <= x2) break;
                int h2 = (int)(p & (1L << 31) - 1);
                extra -= h2;
                pop++;
            }
            h -= extra;

            if (h > 0) {
                long num = (h + A - 1) / A;
                ans += num;
                long attack = A * num;
                extra += attack;
                q[push++] = ((x + D) << 31) + attack;
            }
        }
        System.out.println(ans);
    }
}

class Monster {
    int x;
    int h;
    Monster (int x, int h) {
        this.x = x;
        this.h = h;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 46068
/* https://atcoder.jp/contests/abc107/tasks/arc101_a */

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main(int argc, char *argv[])
{
  int N, K;

  std::cin >> N >> K;

  std::vector<int> x(N);

  for (int i = 0; i < N; ++i)
  {
    std::cin >> x.at(i);
  }

  int min_total_times = -1;

  for (int i = 0; i+K-1 < N; i++)
  {
    int point_l = x.at(i);
    int point_r = x.at(i+K-1);

    int dist_from_l = std::abs(point_l) + std::abs(point_r - point_l);
    int dist_from_r = std::abs(point_r) + std::abs(point_l - point_r);

    int total_times = dist_from_l > dist_from_r ? dist_from_r : dist_from_l;
    if (min_total_times < 0)
      min_total_times = total_times;
    else
      min_total_times = min_total_times > total_times ? total_times : min_total_times;
  }

  std::cout << min_total_times << std::endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  vector<int> v;
  int N = 0, tmp = 0;
  int t=10000000;
  cin >> N;
  for(int i=0;i<N;i++){
      cin >> tmp;
      v.push_back(tmp);
  }
  for(int i=2;i<N;i++){
      t = min(t, abs(accumulate(v.cbegin() + i, v.cend(), 0) - accumulate(v.cbegin(), v.cbegin() + i, 0)));
  }
  std::cout << t;
}

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

int main() {
  cin.tie()->sync_with_stdio(0);
  
  int n, k;
  cin >> n >> k;
  
  int ans = 0;
  while(n > 0) {
    n /= k;
    ans++;
  }
  
  cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>

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

    scanf("%d %d", &a, &b);
    d = a/b;
    r = a%b;
    f = (double)a / (double)b;
    printf("%d %d %lf\n", d, r, f);
}


Measured memory_bytes: 2756
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<Pi,int> Pii;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

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

	cin>>n>>m;

	rep(i,m){
		cin>>a[i]>>b[i];
		if(a[i]==1){
			c[b[i]-1]++;
		}
		if(b[i]==n){
			c[a[i]-1]++;
		}
	}

	rep(i,n){
		if(c[i]==2){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;

	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  bool flag=0;
  if(a[0]>0)
  {
    a[0]--;
  }
  for(int i=1;i<n;i++)
  {
    if(a[i]>a[i-1])
    {
      a[i]--;
    }
    if(a[i]<a[i-1])
    {
      cout<<"No";
      flag=1;
      break;
    }
  }
  if(flag==0)
  {
    cout<<"Yes";
  }
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        System.out.println(Math.min(A, B) + Math.min(C, D));

    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define EPS (1e-7)
#define INF (1e9)
#define PI acos(-1.0)

int main(void)
{
  ld a,b;
  ll x;
  cin >> a >> b >> x;

  ld alpha,theta;
  if( b < 2*x/(a*a))
  {
    alpha = atan((2*b-2*x/(a*a))/a );
//    cout << "alpha=" << setprecision(10) <<alpha << endl;
    cout << setprecision(12) << alpha*180/PI;
  }
  else
  {
    theta = atan(2*x/(a*pow(b,2)) );
    cout << setprecision(12) << 90 - theta*180/PI;
  }
  
  
  return 0;
}

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

int main(void){
    long long w,h,x,y;
    cin >> w >> h >> x >> y;
    printf("%.1f %d\n", w*h/2.0, ((w == x*2 && h == y*2) ? 1 : 0));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;


int main(void) {
	char s;
	int n,ans=0,cnt=0; cin >> n;
	rep(i, n) {
		cin >> s;
		if (s == 'A') {
			cnt=1;
		}else
		if (s == 'B'&&cnt==1) {
			cnt++;
		}else
		if (s == 'C'&&cnt==2) {
			ans++;
			cnt = 0;
		}
		else {
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;

}

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

#define rep(i, N) for (int i = 0; i < N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

void solve()
{
    int N;
    cin >> N;
    vector<int> S(1 << N);
    rep(i, 1 << N) cin >> S[i];

    multiset<int, greater<int>> ms_prenatal;
    rep(i, 1 << N) ms_prenatal.insert(S[i]);
    multiset<int> ms_alive;

    auto it_max = ms_prenatal.begin();
    ms_alive.insert(*it_max);
    ms_prenatal.erase(it_max);

    rep(n, N)
    {
        multiset<int> ms_alive_next = ms_alive;
        for (int s : ms_alive)
        {
            auto it = ms_prenatal.upper_bound(s);

            if (it == ms_prenatal.end())
            {
                cout << "No" << endl;
                return;
            }
            ms_alive_next.insert(*it);
            ms_prenatal.erase(it);
        }
        ms_alive = ms_alive_next;
    }

    cout << "Yes" << endl;
}

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

Measured memory_bytes: 25856
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
s=input()
ss=s.replace("x","")
if ss!=ss[::-1]:
 print(-1)
else:
 e=[]
 for i in range(len(ss)):
  e.append(ss[i])
 j=0
 k=0
 d1=[]
 jj=0
 kk=0
 d2=[]
 sr=s[::-1]
 for i in range(len(s)):
  if k<len(e) and s[i]==e[k] :
    d1.append(s[j:i])
    j=i+1
    k+=1
  if kk<len(e) and sr[i]==e[kk] :
    d2.append(sr[jj:i])
    jj=i+1
    kk+=1
 d1.append(s[j:])
 d2.append(sr[jj:]) 
 dd=0  
 for i in range(len(d1)//2):
   dd+=abs(len(d1[i])-len(d2[i]))
 print(dd)


Measured memory_bytes: 58036
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
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 r;  cin >> r;
  cout << (int)pow(r,2);
}


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

typedef long long ll;
const int maxn=3e3+10;
ll n,mod,c[maxn][maxn],s[maxn][maxn],ans;

inline ll fpow(ll a,ll n,ll mod){
	ll res=1;
	for(;n;n>>=1,a=a*a%mod)
		if(n&1ll)
			res=res*a%mod;
	return res;
}

int main(){
	cin>>n>>mod;
	for(int i=0;i<maxn;++i){
		c[i][0]=1;
		for(int j=1;j<=i;++j)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	for(int i=0;i<maxn;++i){
		s[i][0]=1;
		for(int j=1;j<=i;++j)
			s[i][j]=(s[i-1][j-1]+s[i-1][j]*(j+1))%mod;
	}
	for(int i=0;i<=n;++i){
		ll k=c[n][i];
		if((n-i)&1)k=(mod-k)%mod;
		ll cnt=0;
		for(ll j=0,y=1,kind=fpow(2,i,mod);j<=n-i;++j,y=y*kind%mod)
			(cnt+=s[n-i][j]*y)%=mod;
		(ans+=k*cnt%mod*fpow(2,fpow(2,i,mod-1),mod))%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 140160
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
if ord('A') <= ord(s) <= ord('Z'):
    print('A')
else:
    print('a')

Measured memory_bytes: 10436
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 19:10:47 2020

@author: Kanaru Sato
"""
import bisect

n = int(input())
_1 = list(map(int,input().split()))
_2 = list(map(int,input().split()))
_3 = list(map(int,input().split()))

a = sorted(_1)
b = sorted(_2)
c = sorted(_3)

count = 0
for i in range(n):
    smallernums = bisect.bisect_left(a,b[i])
    biggernums = len(c)-bisect.bisect_right(c,b[i])
    count += smallernums*biggernums

print(count)

Measured memory_bytes: 23328
<?php
    $K = intval(trim(fgets(STDIN)));
    
    fscanf(STDIN,"%d%d",$A,$B);

    for($i=$A;$i<=$B;$i++){
        if($i%$K == 0){
            echo "OK\n";
            exit;
        }
    }
    echo "NG\n";
?>

Measured memory_bytes: 16280
def __main__():
    P = []
    for i in range(5):
        P.append(int(input()))
    k = int(input())
    
    for i in range(4):
        for j in range(i+1,5):
            if abs(P[i] - P[j]) > k:
                print(":(")
                return
    print("Yay!")
    return

if __name__ == "__main__":
    __main__()


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

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

	int j = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == j + 1) {
			j++;
		}
	}
	cout << (j == 0 ? -1 : n - j) << endl;
	return 0;
}

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

int main(){
  int ans=0;
  string s, t;
  cin >> s >> t;
  rep(i, 3){
    if(s[i]==t[i]){
      ans++;
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

vector<vector<ll>> bunkai(ll a){
  if(a<=0) return {};
  if(a==1) return {{1,1}};
  vector<ll> f;
  ll b=a;
  for(ll i=2;i*i<=a;i++){
    if(b%i==0){
      f.push_back(i);
      b=b/i;
      i--;
    }
  if(b==1)break;
  }
  if(b!=1)f.push_back(b);

  vector<vector<ll>> u;
  ll p=f[0];
  ll c=1;
  for(ll i=1;i<f.size();i++){
    if(f[i]==p)c++;
    else{
      u.push_back({p,c});
      p=f[i];
      c=1;
    }
  }
  u.push_back({p,c});

  return u;
}

vector<ll> yakusu(ll a){
  if(a<=0)a=-a;
  if(a==1) return {1};
  vector<ll> f={1,a};
  for(ll i=2;i*i<=a;i++){
    if(a%i==0 && i*i!=a){
      f.push_back(i);
      f.push_back(a/i);
    }
    if(i*i==a)f.push_back(i);
  }
  sort(f.begin(),f.end());

  return f;
}

int main(){

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

  if(x==0)cout << 0 << endl;
  else if(x==1)cout << n << endl;
  else{
    mat u=bunkai(x),v=bunkai(m);
    vec h,w;
    for(ll i=0;i<u.size();i++)h.push_back(u[i][0]);
    for(ll i=0;i<v.size();i++)w.push_back(v[i][0]);
    bool ok=1;
    for(ll i=0;i<w.size();i++){
      ll e=w[i];
      if(lower_bound(h.begin(),h.end(),e)==upper_bound(h.begin(),h.end(),e))ok=0;
    }
    if(ok){
      ll ans=0;
      ans+=x;
      while(x!=0){
        x=x*x%m;
        ans+=x;
      }
      cout << ans << endl;
    }
    else{
      ll y=x;
      ll ans=0;
      ll p=x;//1周の和
      ll c=1;//1周の長さ
      vec s(m+1);
      s[x]=1;
      ll ok=false;
      while(!ok){
        x=x*x%m;
        if(s[x]==0){
          s[x]=1;
          p+=x;
          c++;
        }
        else{
          ok=true;
        }
      }
      if(y==x){
        ans+=p*(n/c);
        ll q=n%c;
        x=y;
        if(q>0)ans+=x;
        for(ll i=0;i<q-1;i++){
          x=x*x%m;
          ans+=x;
        }
        cout << ans << endl;
        return 0;
      }
      ok=false;
      ans+=y;
      ll d=1;
      while(y!=x){
        y=y*y%m;
        if(y!=x){
          ans+=y;
          d++;
        }
      }
      n-=d;
      p=y;
      c=1;
      while(!ok){
        x=x*x%m;
        if(x!=y){
          p+=x;
          c++;
        }
        else ok=1;
      }
      ans+=p*(n/c);
      ll q=n%c;
      x=y;
      if(q>0)ans+=x;
      for(ll i=0;i<q-1;i++){
        x=x*x%m;
        ans+=x;
      }
      cout << ans << endl;

      //cout << c  <<" " << q << " " << n/c << " " << p << " " << x << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4040
n, m = map(int, input().split())

nb = [[0 for x in range(n)] for y in range(n)]
inp = [list(map(int, input().split())) for x in range(m)]
for start, end in inp:
    nb[start - 1][end - 1] = 1
    nb[end - 1][start - 1] = 1


# start, end = 1, 2
# nb[start - 1][end - 1] = 0
# nb[end - 1][start - 1] = 0
#
# for i in nb: print(*i)

def can(f):
    end = [0 for x in range(n)]
    que = [(0, f[0])]

    while que:
        index, targets = que.pop()
        for ti, target in enumerate(targets):
            if target and not end[ti]:
                que.append((ti, f[ti]))
        end[index] = 1
    return end.count(1) == n
#
# can(nb)

count = 0
for start, end in inp:
    nb[start - 1][end - 1] = 0
    nb[end - 1][start - 1] = 0

    if not can(nb):
        # print(start, end)
        count += 1

    nb[start - 1][end - 1] = 1
    nb[end - 1][start - 1] = 1
print(count)

# count = 0
# for index, i in enumerate(nb):
#     if i.count(1) == 1:
#         count += 1
#         nb[index] = [0 for x in range(n)]
#         for row in nb:
#             row[index] = 0
#
# print()
# for i in nb: print(*i)
#
# print(count)


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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

signed main()
{
  int x; cin >> x;
  int t = x;
  int ans = 0;
  int a = 0;
  
  for(int i = 0; i < 8; ++i){
   a = x % 10; //if x = 128,a is 8
   x /= 10; //128 becomes to 12 
   ans += a;
  }
  
  if(t % ans == 0)
    cout << "Yes";
  else
    cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;

bool chek(ll key) {
	if (key) return true;
	else return false;
}

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}

	map<string, int> m;

	int g = 0, bl = 0, w = 0, b = 0, y = 0, o = 0, r=0;
	int target = 0;
	int color[9];

	rep(i, 9) {
		color[i] = 0;
	}
	rep(i, n) {
		if (a[i] >= 1 && a[i] < 400) color[0]++;
		else if (a[i] >= 400 && a[i] < 800) color[1]++;
		else if (a[i] >= 800 && a[i] < 1200) color[2]++;
		else if (a[i] >= 1200 && a[i] < 1600) color[3]++;
		else if (a[i] >= 1600 && a[i] < 2000) color[4]++;
		else if (a[i] >= 2000 && a[i] < 2400) color[5]++;
		else if (a[i] >= 2400 && a[i] < 2800) color[6]++;
		else if(a[i] >= 2800 && a[i] <3200)color[7]++;
		else color[8]++;
	}
	int ans=0;
	rep(i, 8) {
		if (color[i] > 0) ++ans;
	}

	if(ans > 0) cout << ans;
	else {
		cout << 1;
	}
	
	cout << " " << ans + color[8] << endl;;
	return 0;
}


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

// dp[items][weight]
long long dp[100001];

int main() {
	int n, w;
	cin >> n >> w;
	vector<int> wt(n, 0), val(n, 0);

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

	//Base Case
	for (int i = 0; i <= n; i++) {
		for (int j = w; j >= 0; j--) {
			if (i == 0 || j == 0) {
				dp[j] = 0;
			} else if (wt[i - 1] <= j) {
				dp[j] = max(val[i - 1] + dp[j - wt[i - 1]], dp[j]);
			} else {
				dp[j] = dp[j];
			}
		}
	}

	cout << dp[w] << endl;
	return 0;
}

Measured memory_bytes: 4412
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    // Your code here!
    int N = 0;
    cin>>N;
    int p[N];
    
    for(int i = 0;i < N;i++){
        cin>>p[i];
    }
    
    sort(p,p+N,greater<int>());
    
    int res = 0;
    res += p[0]/2;
    for(int i = 1;i < N;i++){
        res +=p[i];
    }
    
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 256
#calc practice.py

i = 1
while True:
    x,y = (int(x) for x in input().split())
    if (x == 0 and y == 0):
        exit()

    else :
            list = [0, 0]
            list[0] = x
            list[1] = y
            list.sort()
            print (list[0],list[1])
            i += 1



Measured memory_bytes: 5624