akhauriyash/Code-Regression huggingface dataset:
H,W=map(int,input().split())
if H%3==0 or W%3==0:
    print(0)
    exit()
def Tcheck(X,Y):
    res=X*Y
    for i in range(Y+1):
        #X*i X*(Y-i)
        Z=[X*i,(Y-i)*(X//2),(Y-i)*(X-(X//2))]
        res=min(res,max(Z)-min(Z))
    return res
print(min(H,W,Tcheck(H,W),Tcheck(W,H)))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
int s_abc[26], t_abc[26];

int main(int argc, char **argv) {
    bool res = true;
    
	string S, T;
	cin >> S >> T;

	for(int i = 0; i < S.size(); ++i)
        s_abc[S[i] - 'a']++;
	for(int i = 0; i < T.size(); ++i)
        t_abc[T[i] - 'a']++;
    sort(s_abc, s_abc + 26);
    sort(t_abc, t_abc + 26);

    vector<int> diff;
    set_difference(s_abc, s_abc + 26, t_abc, t_abc + 26, inserter(diff, diff.end()));

    res &= diff.size() == 0;

    cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 776
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

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

    int p = 1;
    ll ans = 0LL;
    rep(n){
        if(a[i] > p){
            int diff = (a[i] - 1) /  p;
            ans += diff;
            if(p > 1 && a[i] % p == 0) a[i]--;
            a[i] -= p*diff;
        }
        if(a[i] == p) p++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int max(int a, int b){
  if(a>=b){
    return a;
  }
  else{
    return b;
  }
}

int main(){
  char buf[1024];
  int A,B;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &A, &B);

  int ans=0;

  if(A==B){
    ans=A+B;
  }
  else{
    ans=max(A,B)*2-1;
  }

  printf("%d\n", ans);

  return 0;


}


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

int main() {
    int a, b;
    cin >> a >> b;
    string ans = "Impossible";
    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) ans = "Possible";
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np

N, W = [int(item) for item in input().split()]
item = np.array([[int(item) for item in input().split()] for _ in range(N)])


dp = np.full((N+1, 10**5 + 1), 10**12+1)
dp[0][0] = 0

for i in range(N):
    dp[i+1] = dp[i]
    w, v = item[i]
    np.minimum(dp[i][v:], dp[i][:-v] + w, out=dp[i+1][v:])

print(np.where(dp[N] <= W)[0][-1])

Measured memory_bytes: 92132
def d_candy_distribution(N, M, A):
    import itertools
    import collections
    # Aの累積和のうち、Mで割った余りが等しい要素の個数
    remainders = collections.defaultdict(int)
    for t in [0] + list(itertools.accumulate(A)):
        remainders[t % M] += 1
    # 余りが等しい要素が2個以上あるなら、それから2つ選んで要望を満たせる
    return sum([v * (v - 1) // 2 for v in remainders.values() if v >= 2])

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_candy_distribution(N, M, A))

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

typedef long long ll;

template<typename T>
T GCD(T a, T b) {
  if(a > b) std::swap(a, b);
  if(a == 0) return b;
  else return GCD(b % a, a);
}

template<typename T>
T LCM(T a, T b) {
  if(a > b) std::swap(a, b);
  if(a == 0) return 0;
  else return a / GCD(a, b) * b;
}

int main() {
  ll A, B, C, D;
  std::cin >> A >> B >> C >> D;

  ll lcm = LCM(C, D);
  ll ans = B - A + 1;
  ans -= (B / C) - ((A - 1) / C) + (B / D) - ((A - 1) / D) - (B / lcm) + ((A - 1) / lcm);
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
prime = []
for i in range(0, 1000000):
	prime.append(True)

for i in range(0, 1000):
	if i < 2:
		prime[i] = False
	else:
		looking = i * 2
		while looking < 1000000:
			prime[looking] = False
			looking += i

sum = []
cnt = 0
for i in range(0, 1000000):
	if prime[i]:
		cnt += 1
	sum.append(cnt)

while True:
	try:
		n = int(raw_input())
		print sum[n]
	except:
		break

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

using namespace std;

typedef long long int ll;

const int mod = 1e9 + 7;

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

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

  int n;
  cin >> n;
  vector < int > c (n + 1);
  for (int i = 1; i <= n; i++) cin >> c[i];
  sort (c.begin() + 1, c.end(), greater < int > ());

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (ll)c[i] * (i + 1);
    ans %= mod;
  }
  ans = (ans * pwr (4, n - 1)) % mod;

  cout << ans << '\n';
}


Measured memory_bytes: 3972
import java.io.*;
import java.util.*;
import static java.lang.System.out;

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

    public static void main(String[] args){
        int N, K; {int[] a = in.ii(); N = a[0]; K = a[1];}
        // K^(d-1) <= N < K^d
        int d = 0;
        for(int i = 1; i <= N; i *= K){
            d++;
        }
        out.println(d);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 23124
x, y = list(map(int, input().split()))
arr = list(map(int, input().split()))


def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
    if(1 <= x, y <= 1000 and 1 <= max(arr) <= 1000 and 1 <= min(arr) <= 1000):
        ref = arr[0]
        ref_count = 0

        for ele in arr:
            if ele < ref:
                left.append(ele)
            elif ele > ref:
                right.append(ele)
            else:
                ref_count += 1
        left = quick_sort(left)
        right = quick_sort(right)
        return left + [ref] * ref_count + right


sorted_list = quick_sort(arr)

result = 0

for i in range(0, y):
    result += sorted_list[i]


print(result)

Measured memory_bytes: 9228
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1):
  sets = [p[_] for _ in range(i - 1, i + 2)]
  if max(sets) != sets[1] and min(sets) != sets[1]:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int main(){
  int n, x;
  cin >> n >> x;
  int a;
  cin >> a;
  int ans = abs(x - a);
  FOR(i, 1, n){
    cin >> a;
    ans = gcd(ans, abs(x - a));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define mod 10000009
using namespace std;
int main()
{
ll d,t,s;
cin>>d>>t>>s;
if(t*s>=d)
    cout<<"Yes";
else
    cout<<"No";
cout<<"\n";
return 0;
}


Measured memory_bytes: 3584
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadInt;
            var B = cin.ReadInt;

            var cnt = 0;

            for (int i = 1; i <= N; i++)
            {
                var sum = 0;
                foreach (var c in i.ToString())
                {
                    sum += (int)(c - '0');
                }
                if (A <= sum && sum <= B)
                {
                    cnt += i;
                }
            }
            
            WriteLine(cnt);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

using namespace std;

#define ll long long


int main(){
	ll a,b,c,d;
    cin >> a >> b >> c >> d;
  	vector<ll> vc;
  	vc.push_back(a*c);
  	vc.push_back(a*d);
  	vc.push_back(b*c);
  	vc.push_back(b*d);
  
  	cout << *max_element(vc.begin(),vc.end());
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int s = scanner.nextInt();
			long[] result = new long[Math.max(3, s + 1)], sum = new long[Math.max(3, s + 1)];
			result[0] = result[1] = result[2] = 0L;
			sum[0] = sum[1] = sum[2] = 0L;
			IntStream.rangeClosed(3, s).forEach(i -> {
				result[i] = (sum[i - 3] + 1) % MOD;
				sum[i] = (sum[i - 1] + result[i]) % MOD;
			});
			System.out.println(result[s]);
		}
	}
}


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

int main() {
	
	int a,b,c;
	cin >> a >> b >> c;
	int count = 0;
	while(b >= a)
	{
	    b = b - a;
	    count++;
	    if(count == c)
	    break;
	    if(b < a)
	    break;
	}
	cout << count;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <memory.h>
#include <iostream>
#include <vector>
#include <string>
#include <ctime>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <cassert>
typedef unsigned long long ull;
typedef unsigned long ul;
#define rep(i,n) for(unsigned long long i = 0;i<n;i++)
#define clear(c) memset(c,0,sizeof(c))
#define clearm(c) memset(c,-1,sizeof(c))
using namespace std;

int main(){
	int n;

	cin >> n;
	ull dp[100+1][100+1];
	clearm(dp);
	ull r[n],c[n];
	rep(i,n){
		int rr,cc;
		cin >> rr >> cc;
		r[i] = rr;
		c[i] = cc;
	}
	rep(i,n-1){
		dp[i][i+1] = r[i] * c[i+1] * r[i+1];
	}
	rep(i,n){
		dp[i][i] = 0;
	}
	for(int dif = 2;dif<n;dif++){
		for(int i = 0;i + dif<n;i++){
			for(int j = i + 1;j <= i +dif - 1;j++){
				dp[i][i+dif] = min(dp[i][i+dif],dp[i][j] + dp[j+1][i+dif] + r[i] * c[j] * c[i+dif]);
			}
		}
	}
	cout << dp[0][n-1] << endl;
	return 0;
}

Measured memory_bytes: 1244
#include<iostream>
using namespace std;
int main(){
int a,b;
  string s;
  cin >> a >> b >> s;
  if(s.at(b-1)=='A'){
  s.at(b-1)='a';
  }else if(s.at(b-1)=='B'){
  s.at(b-1)='b';
  }else{
  s.at(b-1)='c';
  }
  cout << s << endl;
}

Measured memory_bytes: 3612
#from Collections import Counter

N = int(input())
count = 0
word = {}
def str_sort(str):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(str)
for _ in range(N):
    sorted_str = str_sort(input())
    if sorted_str not in word:
        word[sorted_str] = [0]
        word[sorted_str].append(1)
    else:
        if word[sorted_str] == 0:
            word[sorted_str][0] = 1
        else:
            word[sorted_str][0] += word[sorted_str][1]
            word[sorted_str][1] += 1
            #word[sorted_str] = word[sorted_str][0] + word[sorted_str][1]
total = sum(
    v[0] for v in word.values()
)
#print(word)
print(total)


Measured memory_bytes: 27428
#include<iostream>
#define N 32768
long a[N],b[N],n,k,i=N;int main(){for(std::cin>>n>>k;--i;b[i]=i<n?i:n)a[i]=n/i;while(--k){for(std::swap(a,b);++i<N;)b[i]+=b[i-1];for(*b=b[n/--i];*a=--i;)*b=a[i]=(*b+a[i]*(n/i-n/(i+1)))%0x3B9ACA07;}std::cout<<*b;}

Measured memory_bytes: 768
#include<stdio.h>
#include<math.h>
main(){
	int i,n;
	double points[1000];
	double sum,norm,nijouwa,deviation;

	while(1){
		sum = 0;
		nijouwa = 0;
		scanf("%d",&n);
		if(n == 0) break;

		for(i=0;i<n;i++){
			scanf("%lf",&points[i]);
			sum = sum + points[i];
		}
		norm = sum / (double)n;

		for(i=0;i<n;i++){
			nijouwa = nijouwa + (points[i] - norm) * (points[i] - norm);
		}
		deviation = sqrt(nijouwa / (double)n);
		printf("%f\n",deviation);
	}
	return 0;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
int n,m;
long long k;
long long ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        long long pom=n/i;
        ans+=pom*(pom+1)/2*i;
    }
    cout<<ans;
}
		

Measured memory_bytes: 3608
X,Y,A,B,C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
P = P[:X]
Q = Q[:Y]
All = P + Q + R
All.sort(reverse = True)
print(sum(All[:X+Y]))

Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a,b;
    cin>>n>>a>>b;
    if(a==0)
    {
        cout<<0<<endl;
        return 0;
    }
    long long int ans=(n/(a+b));
    long long int rem=n%(a+b);
    if(rem<=a)
     ans=ans*a+rem;
    else
     ans=ans*a+a;
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(){
  long long a ,b,c,k;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
  if(k<=a){
    printf("%lld",k);
  }
  else if(k<=a+b){
    printf("%lld",a);
  }
  else{
    printf("%lld",a+(a+b-k));
  }
}

Measured memory_bytes: 1736
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] towns = new int[4];
        String result = "YES";
        for (int i = 0; i < 6; i++) {
            int road = sc.nextInt();
            towns[road - 1]++;
            if (towns[road - 1] > 2) {
                result = "NO";
            } 
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;

int main() {
    char a, b;
    cin >> a >> b;
    string s, t;
    for (int i=0;i<b-'0';i++){
        s.push_back(a);
    }
    for (int i=0;i<a-'0';i++){
        t.push_back(b);
    }
    if (s < t) cout << s << endl;
    else cout << t << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli x, y,n;
    cin>>n>>x>>y;
    cout<<min(x, y)<<sp<<max((lli)0, x+y-n);
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

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

    ll res = 0;
    int pre = A[0];

    for(int i=1;i<n;i++){
        if(pre<=A[i]){
            pre = A[i];
        }
        else {
            res += (ll)(pre-A[i]);
        }
    }

    cout<<res<<"\n";


    return 0;
}


Measured memory_bytes: 4432
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

ll fact(ll n){
    ll ret = 1;
    for(int i = 1; i <= n; i++){
        ret = (i * ret) % 1000000007;
    }
    return ret;
}

int main(){
    ll n, m;
    cin >> n >> m;
    if(abs(n - m) >= 2){
        cout << 0 << endl;
        return 0;
    }
    cout << ((((fact(n) * fact(m)) % 1000000007) * (n == m ? 2 : 1)) % 1000000007) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int i;
    double s[1000]={},sum=0,a=0;
    for(i=0;i<n;i++){
      cin >> s[i];
      sum+=s[i];
    }
    for(i=0;i<n;i++){
      a+=((sum/n)-s[i])*((sum/n)-s[i])/n;
    }
    printf("%.5f\n",sqrt(a));
    cin >> n;
  }
  
  return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1);
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int a, b;
    cin >> a >> b;
    string s, t;
    rep(i, a){
        s = s + to_string(b);
    }
    rep(i, b){
        t = t + to_string(a);
    }
    vector<string> asdf;
    asdf.push_back(s);
    asdf.push_back(t);
    sort(ALL(asdf));

    cout << asdf[0] << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

lli n, k, sum, ar[N], d[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> ar[i];
		sum += ar[i];
	}

	for(int i = 1; i <= n; i++)
		d[i] = ar[i + 1 > n ? 1 : i + 1] - ar[i];
	if(sum % (n * (n + 1) / 2) != 0) {
		cout << "NO";
		return 0;
	}
	k = sum / (n * (n + 1) / 2);
	for(int i = 1; i <= n; i++) {
		if(k < d[i]|| (k - d[i]) % n != 0) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
    int a, b;

    if(scanf("%d %d", &a, &b) == 1);

    printf("%d", (a * b) - a - b + 1);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

struct Node{
	int XL;
	int XR;
	double XG;
	vector<Node*> next;
};

int w, h;
char p[100][100];
int pieceNum;


void getPiece(int w0, int h0, int num, vector<int>* pieceX, vector<int>* pieceY)
{
	if(w0 < 0 || w0 >= w || h0 < 0 || h0 >= h) return;
	if(p[w0][h0] != num) return;
	
	pieceX->push_back(w0);
	pieceY->push_back(h0);
	p[w0][h0] += 'A' - '0';
	
	getPiece(w0+1, h0, num, pieceX, pieceY);
	getPiece(w0-1, h0, num, pieceX, pieceY);
	getPiece(w0, h0+1, num, pieceX, pieceY);
	getPiece(w0, h0-1, num, pieceX, pieceY);
}

void makeTree(int w0, int h0, char num, Node* root)
{
	vector<int> pieceX, pieceY;
	getPiece(w0, h0, num, &pieceX, &pieceY);
	
	Node* node = new Node();
	
	int minX = 100, maxX = -100; double sum = 0;
	for(int i = 0; i < 4; i++){
		if(pieceY[i] == 0 || (p[pieceX[i]][pieceY[i]-1] != '.' && p[pieceX[i]][pieceY[i]-1] - 'A' + '0' != num) ){
			if( minX > pieceX[i] ) minX = pieceX[i];
			if( maxX < pieceX[i] ) maxX = pieceX[i];
		}
		sum += pieceX[i] + 0.5;
	}
	
	node->XL = minX;
	node->XR = maxX+1;
	node->XG = sum / 4.0;
	root->next.push_back(node);
	
	
	for(int i = 0; i < 4; i++){
		if(pieceY[i] >= h-1) continue;
		
		char pp = p[pieceX[i]][pieceY[i]+1];
		if(pp != num && pp >= '0' && pp <= '9'){
			makeTree( pieceX[i], pieceY[i]+1, pp, node);
		}
	}
}

int checkStable(Node* tree, double* xg, int* weight)
{
	int w = 0; double g = 0;
	for(int i = 0; i < (int)tree->next.size(); i++){
		double _xg; int _weight;
		if(checkStable(tree->next[i], &_xg, &_weight) == 0) return 0;
		g += _weight * _xg;
		w += _weight;
	}
	g += tree->XG;
	g /= w + 1;
	
	*xg = g;
	*weight = w + 1;
	
	if(g > tree->XL && g < tree->XR) return 1;
	else return 0;
}

void deleteTree(Node* tree)
{
	for(int i = 0; i < (int)tree->next.size(); i++) deleteTree( tree->next[i] );
	delete tree;
}

int main(void)
{
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		
		for(int i = h-1; i >= 0; i--){
			for(int j = 0; j < w; j++){
				cin >> p[j][i];
			}
		}
		
		Node tree;
		for(int i = 0; i < w; i++){
			if( p[i][0] != '.'){
				makeTree(i, 0, p[i][0], &tree);
				break;
			}
		}
		
		double dummy1; int dummy2;
		int ans = checkStable(tree.next[0], &dummy1, &dummy2);
		if(ans) cout << "STABLE" << endl;
		else cout << "UNSTABLE" << endl;
		
		deleteTree(tree.next[0]);
	}
	
	return 0;
}
		

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

char s[60][60];

bool is_isolated(int y,int x){
	int dx[4]={0,1,0,-1};
	int dy[4]={1,0,-1,0};
	for(int i=0;i<4;i++){
		if(s[y+dy[i]][x+dx[i]]=='#'){
			return false;
		}
	}
	return true;
}

int main(){
	int H,W; cin>>H>>W;
	for(int y=0;y<60;y++){
		for(int x=0;x<60;x++){
			s[y][x]='.';
		}
	}
	for(int y=1;y<=H;y++){
		for(int x=1;x<=W;x++){
			cin>>s[y][x];
		}
	}
	for(int y=1;y<=H;y++){
		for(int x=1;x<=W;x++){
			if(s[y][x]=='#'){
				if(is_isolated(y,x)){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<cstring>
#define maxn 100007
#define ll long long 
#define SDOI2020 RP++ 
using namespace std;
ll n,k,s;
inline ll read()
{
	ll x=0;
	ll flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}


int main()
{
	n = read();
	k = read();
	s = read();
	/*ll t1,t2;
	if(s & 1)
	{
	t1 = s / 2;
	t2 = t1 + 1;
	}
	else
	{
		t1 = t2 = s / 2;
	}
	for(register ll i = 1;i <= n;i++)
	{
	    if(i - 1 > k) 
		{
			printf("%d ",s + 1);
			continue;
		}
		if(i & 1)
		printf("%d ",t1);
		else printf("%d ",t2);
	}
	*/
	for(register ll i = 1;i <= k;i++)
	{
		printf("%lld ",s);
	}
	for(register ll i = k + 1;i <= n;i++)
	{
		printf("%lld ",s == 1e9 ? 1 : s + 1);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  ll cost;
  scanf("%d %lld", &n, &cost);
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  vector<ll> sum(n + 1);
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = sum[i] + x[i];
  }
  ll answer = 1ll << 60;
  for (int i = 1; i <= n; ++i) {
    ll result = i * cost;
    for (int j = n, temp = 1; j && result < answer; ++temp) {
      int k = max(j - i + 1, 1);
      result += (sum[j] - sum[k - 1]) * (temp == 1 ? 5 : temp << 1 | 1);
      j = k - 1;
    }
    answer = min(answer, result);
  }
  printf("%lld\n", answer + (ll)n * cost);
  return 0;
}


Measured memory_bytes: 2560
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;

int GCD(int a,int b){
  int r=a%b;
  while(r>0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}

int main(){
  int n,x; cin>>n>>x;
  int gcd;
 

  REP(i,n){
    int b; cin>>b;
    int diff=abs(b-x);
    if(i==0)gcd=diff;
    else gcd=GCD(diff,gcd);
  }
  cout<<gcd<<endl;
}

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

using namespace std;
#define ld long double


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

    ld dp[n+1][n+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1.0;
    
    for(int i = 1; i <= n; i++){
    for(int j = 0; j <= i; j++){
    if(j == 0)
        dp[i][j] = dp[i-1][j] * (1.0 - a[i-1]);
    else{
    dp[i][j] = dp[i-1][j-1] * a[i-1] + dp[i-1][j] * (1.0 - a[i-1]);
}
}
}

ld p = 0.0;
for(int j = 0; j <= n; j++){
    if(j > n/2) p += dp[n][j];
}
cout << setprecision(10) << p;
}




Measured memory_bytes: 144384
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  bool T =true;
  reverse(S.begin(),S.end());
  while(S.size()>0){
   if(S.at(0)=='r'&&S.at(1)=='e'&&S.at(2)=='m'&&S.at(3)=='a'&&S.at(4)=='e'&&S.at(5)=='r'&&S.at(6)=='d'){
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
       S.erase(S.begin());
     continue;
  }
    if(S.at(0)=='m'&&S.at(1)=='a'&&S.at(2)=='e'&&S.at(3)=='r'&&S.at(4)=='d'){
      S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     continue;
 }
    if(S.at(0)=='r'&&S.at(1)=='e'&&S.at(2)=='s'&&S.at(3)=='a'&&S.at(4)=='r'&&S.at(5)=='e'){
            S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     continue;
    }
    if(S.at(0)=='e'&&S.at(1)=='s'&&S.at(2)=='a'&&S.at(3)=='r'&&S.at(4)=='e'){
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     S.erase(S.begin());
     continue;
    }
    else{
      T=false;
      break;
    }
}
  if(T){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}
  


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  std::cout << std::fixed << std::setprecision(10);

  int a, b;
  scanf("%d %d", &a, &b);

  ll ans = -1;
  for (ll i = 0; i < 100000; i++) {
    ll p1 = (i * 8 / 100);
    ll p2 = (i * 10 / 100);

    if (p1 == a && p2 == b) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


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

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

    bool c = true;

    for(int i = 1; i < n; i++){
        if(w[i-1][w[i-1].size()-1] != w[i][0]) c = false;
    }

    if(c){
        for(int i = 0; i < n - 1; i++){
            for(int j = i + 1; j < n; j++){
                if(w[i] == w[j]){
                    c = false;
                    break;
                }
            }
            if(!c) break;
        }
    }

    if(c) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


bool graph[10][10];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m; cin >> n >> m;
	VE a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}
	VE tmp(n - 1);
	rep(i, n - 1)tmp[i] = i + 1;
	int ans = 0;
	do {
		bool ok = true;
		if (!graph[0][tmp[0]])ok = false;
		rep(i, n - 2) {
			if (!graph[tmp[i]][tmp[i + 1]])ok = false;
		}
		if (ok)ans++;

	} while (next_permutation(ALL(tmp)));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define yorn(f) cout << ((f) ? "Yes" : "No") << endl
#define YORN(f) cout << ((f) ? "YES" : "NO") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int K, X;
    cin >> K >> X;
    yorn(K * 500 >= X);
    return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  if(a.at(0) == b.at(2) &&a.at(1) == b.at(1)&&a.at(2) == b.at(0)){
    cout << "YES" << endl;
  }
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T>
T get(){ T s; cin >> s; return(s);}
#define geti get<int>()
#define gets get<string>()
template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define getvi(n) getv<int>(n)
#define getvs(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"Yes":"N1010o"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, string before = "", int nest = 0) { cout << string("          ", nest) << before <<  ": "; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//variables
int n;
string s;
vec<int> nums;

void Main() {
    //code here
    s = gets;
    auto i = count(s.begin(), s.end(),'1');
    print(i);
}

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

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    s=[int(readline()) for _ in range(n)]

    max_score=sum(s)
    if max_score%10!=0:
        print(max_score)
    else:
        s.sort()
        flag=False
        for i in range(n):
            if s[i]%10!=0:
                max_score-=s[i]
                flag=True
                break
        print(max_score if flag else 0)
        
if __name__=="__main__":
    main()

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

int main(){
    int N;
    cin >> N;
    
    int x[N];
    for(int i = 0; i < N; ++i){
        cin >>x[i];
    }
    
    int count = 0;
    int flag = 0;
    
    while(flag == 0){
        for(int i = 0; i < N; ++i){
            if(x[i] % 2 == 1){
                flag = 1;
                break;
            }
            x[i] = x[i] /2;
        }
        ++count;
    }
    cout << count-1 << endl;
    return 0;
}

Measured memory_bytes: 256
y, m, d = map(int, input().split('/'))

if y > 2019:
    print('TBD')
elif y == 2019:
    if m > 4:
        print('TBD')
    elif m == 4:
        if d > 30:
            print('TBD')
        else:
            print('Heisei')
    else:
        print('Heisei')
else:
    print('Heisei')

Measured memory_bytes: 3060
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int s = 0;
	for (int i=0; i<N.size(); i++) {
		s += (int)(N[i] - '0');
	}

	string ans;
	if (s % 9 == 0) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
using namespace std;
typedef long long int mint_type;
const mint_type MOD = 1000000007;
const mint_type MAX = 500000;
class mint{
    public:
        static mint_type fac[MAX];
        static mint_type finv[MAX];
        static mint_type mpow(mint_type a, mint_type n, mint_type mod = MOD);
        static mint_type extGCD(mint_type a, mint_type b, mint_type& x, mint_type& y);
        static mint_type minv(mint_type a, mint_type mod = MOD);
        static void mcinit(mint_type max = MAX, mint_type mod = MOD);
        static mint_type mchoose(mint_type n, mint_type r, mint_type mod = MOD);
};
mint_type mint::fac[MAX];
mint_type mint::finv[MAX];

mint_type mint::mpow(mint_type a, mint_type n, mint_type mod){
    mint_type result = 1;
    while(n > 0){
        if(n & 1){
            result = result * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    
    return result;
}

mint_type mint::extGCD(mint_type a, mint_type b, mint_type& x, mint_type& y){
    if(a % b == 0){
        x = 0;
        y = 1;
        return b;
    }
    
    mint_type d = extGCD(b, a % b, x, y);
    mint_type tmp = -y * (a / b) + x;//
    x = y;
    y = tmp;
    return d;
}

mint_type mint::minv(mint_type a, mint_type mod){
    mint_type x, y;
    mint::extGCD(a, mod, x, y);
    while(x < 0) x += mod;
    return x;
}

void mint::mcinit(mint_type max, mint_type mod){
    mint::fac[0] = 1;
    for(mint_type i = 1; i < max; i++){
        mint::fac[i] = mint::fac[i-1] * i % mod;
    }
    
    /*
    mint::finv[max-1] = mint::minv(fac[max-1]);
    cout << finv[max-1] << endl;
    for(mint_type i = max-1; i > 0; i--){
        mint::fac[i-1] = mint::fac[i] * i % mod;
    }
    */
}

mint_type mint::mchoose(mint_type n, mint_type r, mint_type mod){
    //cout << mint::fac[n] << " " << mint::finv[r] << " " <<  mint::finv[n-r] << endl;
    return mint::fac[n] * (mint::minv(fac[r]) * mint::minv(fac[n-r])) % mod;
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    
    mint::mcinit();
    
    long long int res = mint::mpow(2, n) - 1;
    long long int cur = 1;
    for(int i = 1; i <= max(a, b); i++){
        cur = ((cur * (n-i+1) % MOD) * mint::minv(i) ) % MOD;
        if(i == a || i == b) res -= cur;
        while(res < 0) res += MOD;
        res %= MOD;
    }
    
    cout << res << endl;
    
    return 0;
}

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

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

void dfs(int y, int x, vector<vector<int>>& v) {
    int c = v[y][x];
    v[y][x] = -1;
    for(int i=0; i<4; ++i) {
        int ny = y + dy[i], nx = x + dx[i];
        if(ny < 0 || v.size() <= ny || nx < 0 || v[0].size() <= nx || v[ny][nx] != c) {
            continue;
        }
        dfs(ny, nx, v);
    }
}

int main() {
    int w, h;
    while(cin >> w >> h, w) {
        int xs, ys, xg, yg;
        cin >> xs >> ys >> xg >> yg;
        xs--; ys--; xg--; yg--;

        vector<vector<int>> v(h, vector<int>(w));
        int n;
        cin >> n;
        for(int i=0; i<n; ++i) {
            int c, d, x, y;
            cin >> c >> d >> x >> y;
            x--; y--;
            int size[2] = {2, 4};
            for(int j=y; j<y+size[d]; ++j) {
                for(int k=x; k<x+size[(d+1)%2]; ++k) {
                    v[j][k] = c;
                }
            }
        }
        dfs(ys, xs, v);
        if(v[yg][xg] == -1) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int po = 0, yo = 0;
	for(int i = 0; i < n; i++) (i & 1 ? yo : po) += a[i];
	cout << po - yo << endl;
	return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<n); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  int n, m;
  cin >> n >> m;
  bool light[m][n];
  rep(i,m){
    rep(j,n){
      light[i][j]=false;
    }
  }
  rep(i,m){
    int num;
    cin >> num;
    rep(j,num){
      int tmp;
      cin >> tmp;
      tmp--;
      light[i][tmp]=true;
    }
  }
  arr(p,m);

  int ans=0;
  bitrep(i,n){
    int lightnum=0;
    rep(j,m){
      int on=0;
      rep(k,n){
        if(bis(i,k)){
           if(light[j][k]) {on++;}
        }
      }
      if(on%2==p[j]){lightnum++;}
    }
    if(lightnum==m){ans++;}
  }

  prt(ans);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    
    cin >> s;
    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    int index_c = -1;
    for(int i = 2; i < s.size()-1; i++)
        if(s[i] == 'C'){
            index_c = i;
            break;
        }
    if(index_c == -1){
        cout << "WA" << endl;
        return 0;
    }
    
    for(int i = 1; i < s.size(); i++)
        if(!islower(s[i]) && index_c != i){
            cout << "WA" << endl;
            return 0;
        }
    
    cout << "AC" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		final int N = scan.nextInt();
		final int A = scan.nextInt();
		final int B = scan.nextInt();
		scan.close();
		
		if (N * A >= B) {
			System.out.println(B);
		} else {
			System.out.println(N * A);
		}

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <string>
#include <numeric>

typedef long long ll;
using namespace std;

int main(){
	int n,ans=0;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		while(a[i]%2==0){
			ans++;
			a[i]/=2;
		}
	}
	cout << ans<<endl;
  return 0; 
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {

		Scanner sc = new Scanner(System.in);

		char c = sc.next().charAt(0);
		char h = sc.next().charAt(0);
		
		System.out.println((c < h) ? "<" : (c > h) ? ">" : "=");
		
	}

}


Measured memory_bytes: 24016