akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

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

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int> A(N);
	int two = 0;
	int yon = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] % 4 == 0) {
			yon++;
		}
		if (A[i] % 2 == 0) {
			two++;
		}
	}
	two -= yon;

	int ans = 2*yon + 1 + max(0,two-1);
	if (ans >= N) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x,y;
  cin>>x>>y;
  REP(i,x+1) {
    int j=x-i;
    if (2*i + 4*j == y) {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    vector<ll> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    ll ans = 0;
    rep2(i, 1, 3) ans += abs(A[i] - A[i - 1]);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector <int> vec(n, 0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    vec.at(a-1)++;
  }
  int d = 0;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) > 0) {
      d++;
    }
  }
  sort(vec.begin(), vec.end());
  int ans = n;
  if (d <= k) {
    ans = 0;
  } else {
    for (int i = 0; i < k; i++) {
      ans -= vec.at(n-1-i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
int n,m,k;
LL ans,INV1,INV2,INV3;
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}

int main(){
	cin>>n>>m>>k;
	ans=0;
	INV1=pw(n+m,MO-2);
	INV2=pw(n+m-1,MO-2);
	INV3=INV1*INV2%MO;
	FOR(i,2,k) (ans+=1ll*i*(i-1))%=MO;
	ans=ans*INV3%MO;
	ans=ans*n%MO*m%MO;
	(ans+=k)%=MO;
	(ans+=1ll*k*(k+1)/2%MO*INV1%MO*(n+m))%=MO;
	FORD(i,n+m,n+m-k+1) ans=ans*i%MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long[] A = new long[(int)N];
        for (int i = 0; i < N; i++) {
            long num = sc.nextLong();
            A[i] = num;
        }
        int MK = 62;
        int[] dp = new int[MK];
        for (int k = 0; k < MK; k++) {
            long mask = 1l << k;
            for (int i = 0; i < N; i++) {
                if ((A[i] & mask) == 0l) {
                    dp[k]++;
                }
            }
        }
        long ans = 0;
        for (int k = 0; k < MK; k++) {
            long tmp = 1l << k;
            tmp %= MOD;
            tmp *= (dp[k] * (N - dp[k])) % MOD;
            tmp %= MOD;
            ans += tmp;
            ans %= MOD;
        }
        System.out.println(ans % MOD);
    }
}

Measured memory_bytes: 98480
#include <string>
#include <iostream>

using namespace std;

int main() {
    string S;
    bool isEasyToStep = true;
    cin >> S;
    for(int i = 0; i < S.size(); i++) {
        bool isEven = (i + 1) % 2 == 0;
        char text = S[i];
        if(isEven) {
            if (!(text == 'L' || text == 'U' || text == 'D')) {
                isEasyToStep = false;
            }
        } else {
            if (!(text == 'R' || text == 'U' || text == 'D')) {
                isEasyToStep = false;
            }
        }
    }
    cout << (isEasyToStep ? "Yes" : "No") << endl;
}

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

using namespace std;

long long prime = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    for (int c = 0; c < 2000; ++c) {
        if (c * 8 / 100 == a && c * 10 / 100 == b) {
            cout << c << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    c = 0
    for i in range(n):
        if c < min(a[i], abs(a[-1] - a[i])):
            c = a[i]
    print(a[-1], c)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 62832
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 8e2+9;
const ll mod = 1e9+7;

queue <pii> q;
string s[maxn];
int dis[maxn][maxn];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	for (int i = 0; i < h; i++)
		cin >> s[i];
		int xs, ys;
	for (int i = 0; i < h; i++)
		for (int t = 0; t < w; t++)
			if (s[i][t] == 'S') {
				xs = i;
				ys = t;
			}
	memset(dis, -1, sizeof dis);
	dis[xs][ys] = 0;
	q.push(MP(xs, ys));
	while (q.size()) {
		int x = q.front().F, y = q.front().S; q.pop();
		int d = dis[x][y];
		if (d == k) break;
		if (x - 1 >= 0 && dis[x - 1][y] == -1 && s[x - 1][y] == '.') {
			dis[x - 1][y] = d + 1;
			q.push(MP(x - 1, y));
		}
		if (y - 1 >= 0 && dis[x][y - 1] == -1 && s[x][y - 1] == '.') {
			dis[x][y - 1] = d + 1;
			q.push(MP(x, y - 1));
		}
		if (x + 1 < h && dis[x + 1][y] == -1 && s[x + 1][y] == '.') {
			dis[x + 1][y] = d + 1;
			q.push(MP(x + 1, y));
		}
		if (y + 1 < w && dis[x][y + 1] == -1 && s[x][y + 1] == '.') {
			dis[x][y + 1] = d + 1;
			q.push(MP(x, y + 1));
		}
	}
	for (int i = 0; i < w; i++)
		if (dis[0][i] + 1 || dis[h - 1][i] + 1)
			return cout << 1 << "\n", 0;
	for (int i = 0; i < h; i++)
		if (dis[i][0] + 1 || dis[w - 1][i] + 1)
			return cout << 1 << "\n", 0;
	int ans = 1e9;
	for (int i = 0; i < h; i++)
		for (int t = 0; t < w; t++)
			if (dis[i][t] + 1) {
				int f = min(min(i, h - i - 1), min(t, w - t - 1));
				ans = min(ans, 1 + f / k + ((f % k) ? 1 : 0));
			}
	cout << ans << "\n";
}



Measured memory_bytes: 3456
import sys
n = int(input())
pts = [None] * n
for i, line in enumerate(sys.stdin.readlines()):
    x, y = map(int, line.split())
    pts[i] = (x, y)
pts.sort(key=lambda x: (x[0], x[1]))
print('\n'.join(map(lambda x: f'{x[0]} {x[1]}', pts)))


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

int A, B;

int main () {
    cin >> A >> B;
    if (A == 1) {
        A = 14;
    }
    if (B == 1) {
        B = 14;
    }
    if (A == B) {
        cout << "Draw" << endl;
    } else if (A > B) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
main = do
    n <- getLine
    printTestCases 1 n

printTestCases :: Int -> String -> IO ()
printTestCases index "0" = putStr ""
printTestCases index number = do
    putStrLn $ "Case " ++ show(index) ++ ": " ++ number
    next <- getLine
    printTestCases (index + 1) next

Measured memory_bytes: 4004
#include <stdio.h>

int main () {
    int N;
    scanf("%d", &N);
    char S[N];
    scanf("%s", &S);
    
    if (N % 2 != 0) {
        printf("No");
        return 0;
    }
    
    for (int i = 0; i < N / 2;i++) {
        if (S[i] != S[N / 2 + i]) {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1700
ranknum,goal = map(int,input().split())
probnum = [0]*ranknum
bonus = [0]*ranknum
compscore = [0]*ranknum

for i in range(ranknum):
    probnum[i],bonus[i] = map(int,input().split())
    compscore[i] = probnum[i]*100*(i+1)+bonus[i]

from itertools import product
from math import ceil

minprob = 1001

for c in product(range(2),repeat=ranknum):
    score = 0
    solvedprob = 0
    notcompedindex = -1

    for i in range(ranknum):    
        if c[i] == 1:
            score += compscore[i]
            solvedprob += probnum[i]
        else:
            notcompedindex = i
        
    if score < goal and score+100*(notcompedindex+1)*(probnum[notcompedindex]-1) >= goal:
        solvedprob += ceil((goal-score)/(100*(notcompedindex+1)))
        score += ceil((goal-score)/(100*(notcompedindex+1))) * (100*(notcompedindex+1))
    
    if score >= goal:
        minprob = min(minprob,solvedprob)

print(minprob)


Measured memory_bytes: 3444
cnt = 0
n = int(input())
l = list(map(int, input().split()))
if len(l) >= 3:
  for i in range(len(l)):
    for j in range(i, len(l)):
      for k in range(j, len(l)):
        if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
          continue
        elif l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[j] + l[k] > l[i]:
          cnt += 1
        else:
          continue
print(cnt) 

Measured memory_bytes: 73820
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t r;
    cin >> r;
    cout << 3 * r * r << endl;
}


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

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  V d;
  for(ll i=0; i<3; i++) {
    ll t;
    cin >> t;
    d.push_back(t);
  }

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

  cout << d[0]+d[1] << endl;

  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
P=list(map(int,input().split()))
for i in range(n):
    P[i]=0.5*(P[i]+1)
x=sum(P[:k])
s=[x]

for i in range(1,n-k+1):
    x=x-P[i-1]+P[i+k-1]
    s.append(x)

print(max(s))

Measured memory_bytes: 25604
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999
#define eps 1e-9

int n;

string cat(string a,string t){
    for(int i=max(0,((int)a.size()-(int)t.size()));i<=a.size();i++){
        bool f=true;
        rep(j,a.size()-i){
            if(a[i+j]!=t[j])f=false;
        }
        if(f){
            string ret=a.substr(0,i)+t;
            return ret;
        }
    }
    return "error";
}

int toBin(vector<int> a){
    int ret=0;
    rep(i,a.size()){
        ret*=2;
        ret+=a[i];
    }
    return ret;
}

void del(string s[11]){
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            bool rev=false;
            string a,b;
            b=s[i],a=s[j];
            if(a.size()<b.size()){
                rev=true;
                swap(a,b);
            }
            rep(k,a.size()-b.size()+1){
                bool f=true;
                rep(l,b.size()){
                    if(a[k+l]!=b[l])f=false;
                }
                if(f){
                    if(rev)s[j]="";
                    else s[i]="";
                    break;
                }
            }
        }
    }
}

int main(){
    string s[11];
    while(cin>>n&&n){
        rep(i,n) cin>>s[i];
        
        del(s);
        
        string dp[1<<10][11];
        rep(i,1<<10)rep(j,11)dp[i][j]=string(200,'-');
        rep(i,10)dp[0][i]="";
        
        rep(i,n+1){
            vector<int> a;
            rep(j,i)a.pb(1);
            rep(j,n-i)a.pb(0);
            sort(all(a));
            
            do{
                int bin=toBin(a);
                rep(j,n){
                    if( ((1<<j)&bin)!=0 )continue;
                    rep(k,n){
                        string res=cat(dp[bin][k],s[j]);
                        if( dp[( bin^(1<<j) )][j].size()>res.size() ||  (dp[( bin^(1<<j) )][j].size()==res.size() && dp[( bin^(1<<j) )][j]>res)  ){
                            dp[( bin^(1<<j) )][j]=res;
                        }
                    }
                }
            }while(next_permutation(all(a)));
        }
        
        string ans=string(200,'-');
        rep(i,n){
            if(dp[(1<<n)-1][i].size()<ans.size() || (dp[(1<<n)-1][i].size()==ans.size()&&dp[(1<<n)-1][i]<ans))
                ans=dp[(1<<n)-1][i];
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4116
s = gets.chomp
t = gets.chomp
ans = "false"
s.length.times{
  if s == t
    puts :Yes
    ans = "true"
    break
  end
  s.insert(0,s[s.length-1])
  s.slice!(s.length-1)
}
if ans == "false"
  puts :No
end

Measured memory_bytes: 1788
#include <iostream>
#define rng(z) (1050 <= z && z <= 1170)
using namespace std;
int a, b, t1, t2, p, q;
int x[7][7] = {
	{0, 300, 500, 600, 700, 1350, 1650},
	{6, 0, 350, 450, 600, 1150, 1500},
	{13, 7, 0, 250, 400, 1000, 1350},
	{18, 12, 5, 0, 250, 850, 1300},
	{23, 17, 10, 5, 0, 600, 1150},
	{43, 37, 30, 25, 20, 0, 500},
	{58, 52, 45, 40, 35, 15, 0}
};
int main() {
	while (cin >> a, a) {
		cin >> p >> q; t1 = p * 60 + q; a--;
		cin >> b >> p >> q; t2 = p * 60 + q; b--;
		if (a > b) swap(a, b);
		int cost = x[a][b], dist = x[b][a];
		if (dist <= 40 && (rng(t1) || rng(t2))) cost /= 2;
		cost = (cost + 49) / 50 * 50;
		cout << cost << endl;
	}
}

Measured memory_bytes: 3028
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    deque<int> dq;
    FOR(i, 0, N) {
        int a;
        cin >> a;
        if (i % 2 == 0)
            dq.push_back(a);
        else
            dq.push_front(a);
    }

    FOR(i, 0, N) {
        int a = 0;
        if (N % 2 == 0) {
        a = dq.front();
        dq.pop_front();
        } else {
        a = dq.back();
        dq.pop_back();
        }
        cout << a << " ";
    }
    cout << endl;
};


int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 3072
#include <stdio.h>

int kuadrat(int a, int b)
{
    int total = 1;
    while(b > 0){
        total *= a;
        b--;
    }
    return total;
}
int main()
{
    int cases;
    scanf("%d", &cases);
    long long int arr[cases], total = 1;

    int i = 0;
    char temp;
    do
    {
        scanf("%lld%c", &arr[i], &temp);
        if(arr[i] == 0){
            printf("0");
            return 0;
        }
        i++;
    } while (temp != '\n');
    
    for(int j = 0; j < cases; j++){
        if (total > 1000000000000000000 / arr[j])
        {
            printf("-1");
            return 0;
        }
        else
        {
            total *= arr[j];
        }
    }
    printf("%lld", total);

    return 0;
}

Measured memory_bytes: 2448
N = int(input())
A, B, C =list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))
D = set(A[1:] + B[1:] + C[1:])
ans = 0
for e in D:
    if(e not in A[1:] and e in C[1:]) or (e in B[1:] and e in C[1:]):
        ans += 1
print(ans)





Measured memory_bytes: 5604
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x;
    cin >> x;
    int u = x/100;
    int d = x%100;
    if((0 < u && u <= 12 ) && (0 < d && d <= 12 ) ) {
        cout << "AMBIGUOUS" << endl;
    }else if(!(0 < u && u <= 12 ) && !(0 < d && d <= 12 )){
        cout << "NA" << endl;
    }else if((0 < u && u <= 12 )){
        cout << "MMYY" << endl;
    }else if((0 < d && d <= 12 )){
        cout << "YYMM" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int A,B,X;
    cin >> A >> B >> X;
    string ans;
    if(X < A)
        ans = "NO";
    else if(X > A+B)
        ans = "NO";
    else
        ans = "YES";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<string.h>
using namespace std;
int main(){
int n,f1,f2;
cin>>n;
f1=floor(n/500);
f2=(n-(f1*500))/5;
cout<<f1*1000+f2*5;

  return 0;}




  


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b_li = list(map(int,input().split()))
ans = 0
for i in range(n):
  a_li = list(map(int,input().split()))
  check = 0
  for k in range(m):
    check += a_li[k]*b_li[k]
  if check+c>0:
    ans += 1
print(ans)

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

using namespace std;

long max_size = 0;

void dump(const char *label, const vector<long>& v)
{
    cout << label << ": ";
    for (auto i = v.begin(); i != v.end(); ++i) cout << (*i) << " ";
    cout << endl;
}

void trace(vector<long>& A, vector<long>& order)
{
    long max = *max_element(A.begin(), A.end());
    bool stop = true;
    for (long p = 1; p < max; ++p) {
        for (int i = 0; i < A.size(); ++i) {
            if (A[i] == p) break;
            if (A[i] > p) {
                stop = false;
                A[i] -= p;
                order.push_back(p);
                trace(A, order);
                order.pop_back();
                A[i] += p;
                break;
            }
        }
    }
    if (stop) {
        if (order.size() > max_size) {
            max_size = order.size();
            dump("save - A", A);
            dump("save - order", order);
        }
    }
}

long d(const vector<long>& A)
{
    long num = 0;
    long min = 1;
    for (size_t i = 0; i < A.size(); ++i) {
        if (A[i] == min) {
            ++min;
        } else if (A[i] > min) {
            auto n = (A[i]-1) / min; 
            // for (int i = 0; i < n; ++i) cout << min << " ";
            if (min == 1) ++min;
            num += n;
        }
    }
    // cout << endl;
    return num;
}

int main()
{
    int N;
    cin >> N;
    vector<long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    cout << d(A) << endl;
    /*
    vector<long> order;
    trace(A, order);
    cout << max_size << endl;
    */
    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        var n = sc.Int;

        var minv = int.MaxValue;
        var sum = 0;

        for (var i = 0; i < n; i++)
        {
            var t = sc.Int;
            sum += t;
            if (t < minv && t % 10 != 0)
                minv = t;
        }

        if (minv == int.MaxValue)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(sum % 10 == 0 ? sum - minv : sum);
        }
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Line { get { return Console.ReadLine(); } }

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Line.Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public string[] StrArr { get { return Line.Split(' '); } }
    public int Int { get { return int.Parse(Str); } }
    public int[] IntArr { get { return Line.Split(' ').Select(int.Parse).ToArray(); } }
    public long Long { get { return long.Parse(Str); } }
    public long[] LongArr { get { return Line.Split(' ').Select(long.Parse).ToArray(); } }
    public double Double { get { return double.Parse(Str); } }
    public double[] DoubleArr { get { return Line.Split(' ').Select(double.Parse).ToArray(); } }
}

Measured memory_bytes: 11092
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v<10050:
                ans[v]+=1
for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9320
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N == 3:
    print('2 5 63')
    exit()
l = np.array([3, 9, 2, 10, 4, 8, 6, 12]).astype('int32')
l2 = np.array([6, 3, 9, 2, 10, 4, 8, 12]).astype('int32')
time = N // 8
answer = np.array([])
for i in range(time):
    answer = np.append(answer, l + 12 * i)
remain = N % 8
if remain%2 == 0:
    answer = np.append(answer, l[:remain] + 12 * time)
else:
    answer = np.append(answer, l2[:remain] + 12 * time)

answer = [int(x) for x in answer]
print(*answer)
# 48


Measured memory_bytes: 13736
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;
#define FOR(i, m, n) for (int i = int(m); i < int(n); i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
#define INF 1e9 + 7
using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;
typedef long long ll;

int GetDigit(int x) {
    int digit = 0;
    while (x) {
        x /= 10;
        digit++;
    }
    return digit;
}

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

    if (n < 10) {
        cout << n << endl;
    } else if (n < 100) {
        cout << 9 << endl;
    } else if (n < 1000) {
        cout << n - 90 << endl;
    } else if (n < 10000) {
        cout << 909 << endl;
    } else if (n < 100000) {
        cout << n - 9090 << endl;
    } else {
        cout << 90909;
    }
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, Q; cin >> N >> Q;
	string S; cin >> S;
	S.insert(S.begin(), '?');
	vector<int>sum(N + 1);
	rep(i, 1, N + 1) {
		sum[i] = sum[i - 1];
		if (S[i - 1] == 'A' and S[i] == 'C') {
			chmax(sum[i], sum[i - 2] + 1);
		}
	}
	dump(S);
	dump(sum);
	loop(Q) {
		int l, r; cin >> l >> r;

		int ans = sum[r] - sum[l - 1];
		if (S[l - 1] == 'A' and S[l]=='C')ans--;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 1872
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        int n = s.length();
        StringBuffer sb = new StringBuffer(s);

        boolean judge = false;
        if (s.equals(sb.reverse().toString())) {
            String head = s.substring(0, n / 2);
            sb = new StringBuffer(head);

            if (head.equals(sb.reverse().toString())) {
                String foot = s.substring((n + 3) / 2 - 1, n);
                sb = new StringBuffer(foot);

                judge = foot.equals(sb.reverse().toString());

            }

        }
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7  
nums = 10**5 # 制約に合わせよう
g1, g2, inverse = [1, 1] , [1, 1], [0, 1]
 
for num in range(2, nums + 1):
    g1.append((g1[-1] * num) % mod)
    inverse.append((-inverse[mod % num] * (mod//num)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

ans = 0
for i in range(n):
    res = cmb(n-i-1, k-1, mod)
    ans += res*a[n-i-1] - res*a[i]
    ans %= mod
print(ans)

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

int main(){
	int i, j, tmp, a[3]={1, 0, 0};
	char s1, s2, kanma;
	
	
	while(1){
		cin>>s1>>kanma>>s2;
		if(cin.eof())break;

		if(s1=='A'||s2=='A'){
			i=0;
			if(s1=='B'||s2=='B')
				j=1;
			else 
				j=2;
		}
		else if(s1=='B'||s2=='B'){
			i=1;
			if(s1=='C'||s2=='C')
				j=2;
			else
				j=0;
		}
		else if(s1=='C'||s2=='C'){
			i=2;
			if(s1=='A'||s2=='A')
				j=0;
			else
				j=1;
		}

		tmp=a[i];
		a[i]=a[j];
		a[j]=tmp;
	}

	if(a[0]==1)
		cout<<"A\n";
	else if(a[1]==1)
		cout<<"B\n";
	else if(a[2]==1)
		cout<<"C\n";

	return 0;
}

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

int main() {
	long N;
	cin >> N;
	long usagi[N];
	
	for(long i=0; i<N; i++){
		cin >> usagi[i];
	}
	
	long count=0;
	for(long i=0; i<N; i++){
		long love1 = usagi[i];
		long love2 = usagi[love1-1];
		if(i+1==love2)count++;
	}
		
	cout << count/2<<endl;
		
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int dx[] {0, 0, -1, 1}, dy[] {-1, 1, 0, 0};
bool isPrime(int x) {
    for (int i = 2; i * i <= x; ++i)
        if (x % i == 0)
            return false;
    return true;
}
LL lcm(LL x, LL y) {return x / __gcd(x, y) * y;}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> primes;
    int now = 2;
    while (primes.size() < 2 * n) {
        if (isPrime(now))
            primes.push_back(now);
        ++now;
    }
    vector<vector<LL>> a(n);
    for (int i = 0; i < n; ++i)
        a[i].resize(n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            if ((i + j) % 2 == 0)
                a[i][j] = primes[(i + j) / 2] * primes[(i - j + n - 1) / 2 + n];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if ((i + j) % 2 == 1) {
                a[i][j] = 1;
                for (int k = 0; k < 4; ++k) {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if (x >= 0 && x < n && y >= 0 && y < n)
                        a[i][j] = lcm(a[i][j], a[x][y]);
                }
                ++a[i][j];
            }
        }
    }
    if (n == 2)
        a[1][0] = 2 * a[1][0] - 1;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cout << a[i][j] << " \n"[j == n - 1];
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<char>> a(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a.at(i).at(j);
        }
    }
    vector<bool> row(H, false);
	vector<bool> col(W, false);

    for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
    for (int i = 0; i < H; i++) {
		if (row[i]) {
			for (int j = 0; j < W; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

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

int main() {
  int n,m;
  cin >> n >> m;
  int total = (n + m) * (n + m - 1) / 2;
  cout << total - n*m << endl;
  
}

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

int compare_int(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);

    int *A = (int*)malloc(N * sizeof(int));
    int i;
    for(i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }
    qsort(A, N, sizeof(int), compare_int);
    unsigned long sum = 0;
    for(i=K; i<N; i++) {
        sum += (unsigned long)A[i];
    }
    printf("%lu\n", sum);
    return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int n,m,sum1=0,sum2=0,ans1,ans2,d,max=100000,count=0;
    int s[110],t[110];
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    for(int i=0; i<n; i++){
       cin >> s[i];
       sum1 += s[i];
     }
    for(int i=0; i<m; i++){
      cin >> t[i];
      sum2 += t[i];
    }
    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
        if(sum1+t[j]-s[i]==sum2+s[i]-t[j]){
          if(max>s[i]+t[j]){
            max=s[i]+t[j];
            ans1=s[i];
            ans2=t[j];
            count++;
          }
        }
      }
    }
    if(count != 0) cout << ans1 << " " << ans2 << endl;
    else cout << -1 << endl;
  }
  return 0;
}




Measured memory_bytes: 3088
#include<stdio.h>

void insertionsort(int A[], int n)
{
	int v, j;
	for(int i = 0; i < n; i++)
	{
		if(i < n-1)
		printf("%d ", A[i]);	
		else
		printf("%d", A[i]);
	}
	putchar('\n');
	for(int i = 1; i < n; i++)
	{
		v = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > v)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
	for(int i = 0; i < n; i++)
	{
		if(i < n-1)
		printf("%d ", A[i]);	
		else
		printf("%d", A[i]);
	}	
	putchar('\n');
	}
}
int main()
{
	int A[100];
	int n,x;
	scanf("%d", &x);	
	for(int i = 0; i < x; i++)
		scanf("%d", &A[i]);
	insertionsort(A, x);	
	return 0;
}


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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(a > k){
      a = a - k;
      cout << a << " " << b << endl;
  }else if((a + b) >k){
      k = k - a;
      b = b - k;
      cout << "0" << " " << b << endl;
  }else{
      cout << "0" << " " << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  map<string,int> mp;
  int N; cin>>N;
  for (int i = 0; i < N; i++)
  {
    string str;
    cin>>str;
    auto itr = mp.find(str);
    // DEBUG(i);
    if(itr == mp.end())
    {
      mp[str] = 1;
    }
    else
    {
      mp[str]++;
    }
  }

    int M;
    cin>>M;
    for (int i = 0; i < M; i++)
    {
    string str;
    cin>>str;
    auto itr = mp.find(str);
    if(itr == mp.end())
    {
      //NOP
    }
    else
    {
      mp[str] = itr->second -1;
    }
    }

    int ANS = 0;
    for (int i = 0; i < mp.size(); i++)
    {
      static auto itr = mp.begin();
      chmax(ANS,itr->second);
      itr++;
    }
    cout<<ANS<<endl;

    
    
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

int main(){
  ll A,B ;
  cin >> A >> B ;
  ll ans=0;
  int res =(B-A-1)/2%2 ;
  if(A %2 == 0){
    if(B %2 ==1){
      ans = (B-A+1)/2 % 2 ;
    }
    else{
      ans = (B-A)/2 % 2;
      ans += B;
    }
  }
  else{
    if(B % 2 == 1){
      ans=A-((B-A)/2 % 2) ;
    }
    else{
      int i=0;
      while(A>0 || B>0){
        if(A%2 != B%2){
          ans += pow(2,i) ;
        }
        i++;
        A /= 2;
        B /=2 ;
      }
      if(ans %2 ==0){
      ans += res;
      }
      else{
      ans -= res;
      }
    }
  }
  cout << ans << endl;
}
        

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   long A = sc.nextLong();
   long B = sc.nextLong();
   long sum = A;
   long ans1 = 0;
   long ans2 = 0;

   boolean flag = true;
   if(A % B == 0) {
	   flag = false;
   }else {
	 sum = A % B;
   }

   if(flag == true) {
   ans1 = sum;
   ans2 = B - sum;
   }

   if(ans1 < ans2) {
   System.out.print(ans1);
   }else {
   System.out.print(ans2);
   }
   }
}




Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
	int A , B;

	cin >> A >> B;;

	if(A > 9 || B > 9){
		cout << "-1" << endl;
	}else{
		cout << A * B << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import Control.Monad (replicateM)
import Data.List

primes = takeWhile (<10000) $ primes' [2..]
  where
    primes' (p:l) = (p:primes' (filter ((/=0) . flip mod p) l))

isPrime x = elem x primes || all ((/=0) . mod x) primes

main =
  readLn >>=
    flip replicateM readLn >>=
      print . length . filter isPrime



Measured memory_bytes: 7916
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import Data.Char

main = do
    [a,b,c,d] <- map digitToInt <$> getLine :: IO[Int]
    let (Just (_,i,j,k)) = find (\(v,_,_,_) -> v == 7) [(a + b*i + c*j + d*k,i,j,k) |i<-[1,-1], j<-[1,-1], k<-[1,-1]]
    
    putStrLn $ show a ++ tos i ++ show b ++ tos j ++ show c ++ tos k ++ show d ++ "=7"
    where tos f
            | f == 1 = "+"
            | True = "-"

Measured memory_bytes: 380
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut seq = vec![0 as i64; 3];
    for i in 0..3 {
        seq[i] = read();
    }
    let k: usize = read();
    seq.sort();
    let mut ans = seq[2];
    for _ in 0..k {
        ans *= 2;
    }
    ans += seq[0] + seq[1];
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  for(ll i = 0; i < n; i++) cin >> a[i] >> b[i];
  
  ll ans = 0;
  ll p = 0;
  for(ll i = n-1; i >= 0; i--){
    a[i] += p;
    ll d = b[i] - a[i] % b[i];
    if(d != b[i]){
      ans += d;
      p += d;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    int N; cin>>N;
    ll a[N]; 
    map<ll,int> mp;
    map<ll,int> ok;
    REP(i,N){
        cin >> a[i];
        ++mp[a[i]];
        ok[a[i]]=1;
    }
    if(mp[1]>=1){
        if(mp[1]==1){ cout << 1 << "\n"; }
        else{ cout << 0 << "\n";}
        return 0;
    }
    
    sort(a,a+N);
    
    REP(i,N){
        if(ok[ a[i] ]==0){ continue; }
        if(mp[ a[i] ]>=2){ ok[ a[i] ] = 0;}
        int temp = a[i]*2;
        while(temp<=a[N-1]){
            ok[temp] = 0;
            temp += a[i];
        }
    }
    int ans = 0;
    REP(i,N){ ans += ok[ a[i] ]; }
    cout << ans << "\n";
}

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

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    vector<int> num(5,0);
    for (auto i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        S[i] = s;
    }

    for (auto i = 0; i < n; i++)
    {
        if(S[i][0] == 'M'){
            num[0] += 1;
        }else if(S[i][0] == 'A'){
            num[1] += 1;
        }else if(S[i][0] == 'R'){
            num[2] += 1;
        }else if(S[i][0] == 'C'){
            num[3] += 1;
        }else if(S[i][0] == 'H'){
            num[4] += 1;
        }
    }

    vector<int> flag = {0, 0, 1, 1, 1};
    long long ans = 0;
    do{
        long long tmp = 1;
        for (auto i = 0; i < 5; i++)
        {
            if(flag[i] == 1){
                tmp *= num[i];
            }
        }

        ans += tmp;

    } while (next_permutation(flag.begin(), flag.end()));
    cout << ans << endl;
}

Measured memory_bytes: 6144
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      int m = sc.nextInt();
      int idata[] = new int[m];
      String sdata[] = new String[m];
      boolean ac[] = new boolean[10000000];
      int a = 0;
      int w = 0;
      int wdata[] = new int[10000000];

      for (int i = 0;i<m ;i++ ) {
        idata[i] = sc.nextInt();
        sdata[i] = sc.next();
      }

      for (int i = 0;i<m ;i++ ) {
        if (ac[idata[i]]==false) {
          if (sdata[i].equals("WA")) {
            wdata[idata[i]]++;
            w++;
          }else{
            a++;
            ac[idata[i]]=true;
          }
        }
      }
      for (int i = 0;i<m ;i++ ) {
        if (ac[idata[i]]==false) {
          w = w-1;
        }
      }

      System.out.println(a+" "+w);

  }
}


Measured memory_bytes: 127912
import collections


# 素因数分解（試し割り法）
def prime_factorize(n: int) -> list:
    """
    整数 n を素因数分解する
    :param n: 整数
    :return a:リスト
    """
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f <= n ** 0.5:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())
c = collections.Counter(prime_factorize(n))
count = 0
for i in c.values():
    if i == 1:
        count += 1
    else:
        s = 1
        while i > 0:
            i = i - s
            s += 1
            if i < 0:
                break
            count += 1

print(count)







Measured memory_bytes: 9648