akhauriyash/Code-Regression huggingface dataset:
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e9
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a>=1&&a<=9&&b>=1&&b<=9)
        cout<<a*b<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int ans=0;
    rep(i,n){
        cin>>a[i];
        if(i%2==0&&a[i]%2==1)
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include<iostream>

using namespace std;
#define MAX 1000000
#define INF 1000000000

int dp1[MAX+1],dp2[MAX+2];

int main() {
    for(int i = 1;i <= MAX;i++) {
        dp1[i] = INF;
        dp2[i] = INF;
    }

    for(int n = 1;n * (n + 1) * (n + 2) / 6 <= MAX;n++) {
        int a = n * (n + 1) * (n + 2) / 6;
        for(int i = a;i <= MAX;i++) {
            dp1[i] = min(dp1[i],dp1[i - a] + 1);
        }
        if(a % 2 == 0)continue;
        for(int i = a;i <= MAX;i++) {
            dp2[i] = min(dp2[i],dp2[i - a] + 1);
        }
    }

    while(true) {
        int n;
        cin >> n;
        if(n == 0)break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 10792
#B - Small and Large Integers
A,B,K = map(int,input().split())

ans = []
for j in range(K):
    a = A+j
    b = B-j
    if a > B or b < A:
        break
    ans.append(a)
    ans.append(b)

ans = list(sorted(set(ans), reverse = False))

for i in ans:
    print(i)

Measured memory_bytes: 9084
# リスト p を返す.
# p[n][k] (0 <= n <= N, 0 <= k <= n)
# は n の k 以下の正整数による分割のリスト.
def partitions(N):
    p = [[None for k in range(n + 1)] for n in range(N + 1)]
    p[0][0] = [[]]
    for n in range(1, N + 1):
        p[n][0] = []
        for k in range(1, n + 1):
            p[n][k] = p[n][k - 1] + list(map(lambda l: l + [k], p[n - k][min(n - k, k)]))
    return p

while True:
    n = int(input())
    if n == 0:
        break
    l = partitions(n)[n][n]
    for i in range(len(l) - 1, -1, -1):
        print(" ".join((map(str, reversed(l[i])))))


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

int main(){
  int n, x;
  cin >> n >> x;
  int m[n];
  for(int i = 0; i < n; i++) cin >> m[i];
  int min = m[0];
  for(int i = 1; i < n; i++) if(min > m[i]) min = m[i];
  int num = 0;
  for(int i = 0; i < n; i++){
    x -= m[i];
    num++;
  }
  while(x >= min){
    x -= min;
    num++;
  }
  cout << num << endl;
  return 0;
}


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

#define ll long long int
#define All(a) (a).begin(),(a).end()

  queue<pair<int,int>> q,v;
// Remember v.shrink_to_fit() when erasing
void solve(){
  ll h,w,ch,cw,dh,dw,x,y;
  int X[4]={-1,0,0,1};
  int Y[4]={0,1,-1,0};
  cin>> h>>w>>ch>>cw>>dh>>dw;
  ch--;
  cw--;
  dh--;
  dw--;
  ll M[h][w];
	string s[h];
	for(ll i = 0; i < h; i++) {
    cin >> s[i];
    for (int j = 0; j < w; j++)
    {
      if(s[i][j]=='#')M[i][j]=-1;
      else M[i][j]=10000000000;
    }
  }
    

  ll cnt=0;
  M[ch][cw]=0;
  q.push(make_pair(ch,cw));
  while(!q.empty() || !v.empty()){
    while(!q.empty()){
      auto tmp=q.front();
      v.push(tmp);
      q.pop();
      if(tmp.first==dh && tmp.second==dw){
        printf("%lld\n",M[dh][dw]);
        return;
      }
      for (int i = 0; i < 4; i++){
        x=tmp.first+X[i];
        y=tmp.second+Y[i];
        if(x>=0 && x<h && y>=0 && y<w && M[x][y]>M[tmp.first][tmp.second]){
          M[x][y]=cnt;
          q.push(make_pair(x,y));
        }
      }
    }
    while(!v.empty()){
      auto tmp=v.front();
      v.pop();
      for (int i = -2; i <= 2; i++)
      {
        for (int j = -2; j <= 2; j++)
        {
          x=tmp.first+i;
          y=tmp.second+j;
          if(x>=0 && x<h && y>=0 && y<w && M[x][y]>cnt+1){
            M[x][y]=cnt+1;
            q.push(make_pair(x,y));
          }
        }        
      }
      
    }
    cnt++;
  }
  printf("-1\n");
  return;
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 13444
while True:
    try:
        a = list(map(int,input().split()))
        b = list (map(int,input().split()))
    except:
        break
    hit = blow = 0
    for i in range(4):
        if a[i] == b[i]:
            hit += 1
        for j in range(4):
            if i != j and a[i] == b[j]:
                blow +=1
    print(hit,blow)


Measured memory_bytes: 5596
#include <stdio.h>
#include <cmath>
#include <stdlib.h>
#include <algorithm>

int main()
{
    int n,m;
    int fav[30];
    
    scanf("%d", &n);
    scanf("%d", &m);
    
    for(int i = 0;i < 30;i++)
       fav[i] = 0;
    
    for(int i = 0;i < n;i++)
    {
        int k;
        scanf("%d", &k);
        for(int j = 0;j < k;j++)
        {
            int a;
            scanf("%d", &a);
            fav[a-1]++;
        }
    }

    int count = 0;
    for(int i = 0;i < m;i++)
    {
        if(fav[i] == n)
        {
            count++;
        }
    }
    printf("%d",count);
    
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ll n, m, answer = 0, h[100005] = {}, a, b;
	ll AroundHighestTowerTall[100005] = {};
	bool IsAroundThereSameTallTower[100005] = {};
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
		AroundHighestTowerTall[i] = h[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		if (h[a] > h[b])
		{
			AroundHighestTowerTall[b] = h[a];
		}
		else if (h[a] < h[b])
		{
			AroundHighestTowerTall[a] = h[b];
		}
		else
		{
			IsAroundThereSameTallTower[a] = true;
			IsAroundThereSameTallTower[b] = true;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (h[i] == AroundHighestTowerTall[i] && !IsAroundThereSameTallTower[i])
		{
			answer++;
		}
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 5296
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string S;
    int flag=0;
    cin>>S;
    // if(S.find("hi")!=std::string::rnpos)
    //     cout<<"Yes";
    //     else{
    //         cout<<"No";
    //     }
    for(int i=0;;i++){
        if(S[i*2]!='h'){cout<<"No";flag=1;break;}
        else if(S[i*2+1]!='i'){cout<<"No";flag=1;break;}
        else if(S[i*2+2]=='\0')break;
    }
    if(flag==0)cout<<"Yes";
}


Measured memory_bytes: 256
a_point, b_point, c_point, possible_of_distance = map(int, input().split())

# a地点とb地点の距離
if a_point > b_point:
    a_b_distance = a_point - b_point
elif b_point > a_point:
    a_b_distance = b_point - a_point
elif a_point == b_point:
    a_b_distance = 0

# b地点とc地点の距離
if c_point > b_point:
    b_c_distance = c_point - b_point
elif b_point > c_point:
    b_c_distance = b_point - c_point
elif c_point == b_point:
    b_c_distance = 0

# a地点とc地点の距離
if a_point > c_point:
    a_c_distance = a_point - c_point
elif c_point > a_point:
    a_c_distance = c_point - a_point
elif a_point == c_point:
    a_c_distance = 0


# コンタクト可能かの処理。
if a_c_distance <= possible_of_distance:
    print('Yes')
elif a_c_distance > possible_of_distance:
    if a_b_distance <= possible_of_distance and b_c_distance <= possible_of_distance:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8964
while True:
    n = int(input())
    if n==0: break

    for i in range(n):
        m,e,j = map(int,input().split())
        if (m==100 or e==100 or j ==100) or ((m+e)/2 >= 90) or ((m+e+j)/3 >=80):
            print("A")
        elif((m+e+j)/3 >=70) or (((m+e+j)/3>=50) and (m>=80 or e>=80)):
            print("B")
        else:
            print("C")


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

void test_case(){

}

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

	vector<int> v(n);
	unordered_set<int> s;
	
	for(int i=0;i<n;i++){
		cin >> v[i];
		s.insert(v[i]);
	}

	if(n==0){
		cout << X << endl;
		return 0;
	}

	int mini = *min_element(v.begin(), v.end());
	int maxi = *max_element(v.begin(), v.end());

	int mindif = 99999999;
	int num;

	if(X < mini || X > maxi){
		cout << X << endl;
		return 0;
	}
 
	for(int i = maxi+1 ; i>=mini-1 ; i--){
		if(s.count(i)>0) continue;
		
		if(abs(i-X) <= mindif){
			mindif = abs(i-X);
			num = i;
		}
	}
	
	cout << num << endl;

	return 0;
}

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

ll n, a, b, ans[300005];

int main() {
    scanf("%lld%lld%lld", &n, &a, &b);
    if (a == 1) {
        if (b != n) {
            printf("-1\n");
            return 0;
        }
        for (int i = n; i >= 1; i--) printf("%d ", i);
        return 0;
    }
    int x = (n - b) / (a - 1), y = (n - b) % (a - 1);
    if (a > n || b > n || n - b < a - 1 || x + (y > 0) > b) {
        printf("-1\n");
        return 0;
    }
    int cnt = 0, now = b;
    for (int i = b; i >= 1; i--) ans[++cnt] = i;
    for (int i = 1; i <= y; i++) {
        for (int j = now + x + 1; j > now; j--) ans[++cnt] = j;
        now += x + 1;
    }
    for (int i = 1; i <= a - 1 - y; i++) {
        for (int j = now + x; j > now; j--) ans[++cnt] = j;
        now += x;
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 4480
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main() {
    int N, H;
    cin >> N >> H;

    vector<int> a(N), b(N);

    REP(i, N)
    cin >> a[i] >> b[i];

    sort(ALL(a), greater<>());
    sort(ALL(b), greater<>());

    //    cout << a[0] << b[0] << endl;

    // 投げる
    int sum = 0, sum_step = 0;
    bool ok = false;

    for (int i = 0; i < N; i++) {
        if (sum < H && b[i] > a[0]) {
            sum_step++;
            sum += b[i];
            //            cout << "throw:" << b[i] << endl;
        }
    }

    if (sum < H) {
        int remain = H - sum;
        int attacks = remain / a[0];
        if (remain % a[0] != 0) attacks++;
        sum_step += attacks;
    }

    cout << sum_step << endl;
    /*
        while (!ok) {
            if (sum < H) {
                sum += a[0];
                sum_step++;
                cout << "xxx:" << a[0] << endl;
            } else
                ok = true;
        }
        */

    return 0;
}


Measured memory_bytes: 1024
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

//int dp[32][


int
main(void){  
  ios_base::sync_with_stdio(false);

  ll x, y;
  cin >> x >> y;

  ll ans = 0LL;
  while(x <= y){
    x *= 2;
    ans++;
  }

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


Measured memory_bytes: 256
def main():
    S = input()
    N = len(S)
    A = 0
    ans = 0
    i = 0
    while i < N:
        if S[i] == "A":
            A += 1
            i += 1
        elif i+1 < N and S[i] == "B" and S[i+1] == "C":
            ans += A
            i += 2
        else:
            A = 0
            i += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40672
// 1:10 -> 1:17
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
vector<int>v[100005];
int main (){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m; 
	int x,y;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		v[x].pb(y);
	}
	priority_queue<int> pq;
	ll ans = 0;
	for(int i=m-1;i>=0;i--){
		for(auto x:v[m-i])pq.push(x);
		if(!pq.empty()){
			ans+=pq.top();
			pq.pop();
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5632
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

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

    auto calc = [&](int mask) {
        int t = __builtin_popcount(mask);

        vector<int> b(h);
        int bi = 0;
        rep(i, h) {
            b[i] = bi;
            if (i < h - 1 && mask >> i & 1) ++bi;
        }
        const int B = bi + 1;

        vector<int> ct(B);
        rep(i, w) {
            vector<int> add(B);
            rep(j, h) add[b[j]] += s[j][i] - '0';

            bool ok = true;
            rep(j, B) if (ct[j] + add[j] > k) ok = false;
            if (ok) {
                rep(j, B) ct[j] += add[j];
            } else {
                ++t;
                ct = add;
            }

            rep(j, B) if (ct[j] > k) return INT_MAX;
        }

        return t;
    };

    int ans = h + w - 2;
    rep(mask, 1 << (h - 1)) ans = min(ans, calc(mask));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
program panasonic2020_d
    use,intrinsic :: iso_fortran_env
    implicit none

    character(10):: c='a'
    integer(int32):: n

    read*, n
    call make_standard(n,c)
contains
recursive subroutine make_standard(n,c)
    integer(int32):: n,i
    character(*):: c
    character(1):: cmax

    if (n==1) then
        print'(a)', c
        return
    end if

    cmax = 'a'

    do i=1,len_trim(c)
        cmax = max(cmax, c(i:i))
    end do

    do i=ichar('a'), ichar(cmax)+1
        call make_standard(n-1, trim(c)//char(i))
    end do

    
end subroutine
end program panasonic2020_d

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
// #define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

ll n,a,b;

int main(){
	FAST;
	cin >> n >> a >> b;
	if (a>b) cout << 0 << LF;
	else if (n==1&&a!=b) cout << 0 << LF;
	else if (n==1&&a==b) cout << 1 << LF;
	else {
		cout << (n-2)*(b-a)+1 << LF;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long f(long long n){
    long long ans=0;
    int rest=n%4;
    if(rest==3){
        ans=0;
    }
    else if(rest==1){
        ans=1;
    }
    else if(rest==0){
        ans=n;
    }
    else if(rest==2){
        ans=n^1;
    }
    return ans;
}
int main(){
    long long a,b;cin>>a>>b;
    long long ans=f(a-1)^f(b);
    cout<<ans<<endl;
    return 0;
}

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

#define task "E"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 3002;
int n, m, k, v[N][N];
ll dp[N][N][4];
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n >> m >> k;
    rep(i, 1, k)
    {
        int x, y, w;
        cin >> x >> y >> w;
        v[x][y] = w;
    }
    dp[1][1][1] = v[1][1];
    rep(i, 1, n) rep(j, 1, m)
    {
        if (i == 1 && j == 1) continue;

            ll mx = 0;
            rep(t, 0, 3) mx = max(mx, dp[i - 1][j][t]);
            dp[i][j][0] = mx;
            dp[i][j][1] = mx + v[i][j];

        rep(t, 0, 3)
            {
                dp[i][j][t] = max(dp[i][j][t], dp[i][j - 1][t]);
                if (t > 0) dp[i][j][t] = max(dp[i][j][t], dp[i][j - 1][t - 1] + v[i][j]);
            }
        //rep(t, 0, 3) if (dp[i][j][t]) DB3(dp, i, j, t);
    }
    ll mx = 0;
    rep(t, 0, 3) mx = max(mx, dp[n][m][t]);
    cout << mx;
    return 0;
}


Measured memory_bytes: 320088
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:# b:#));
    let mut a = a.split(".");
    let ax = a.next().unwrap().parse::<i64>().unwrap();
    let ay = a.next().map(|x| x.parse::<i64>().unwrap()).unwrap_or(0);

    let mut b = b.split(".");
    let bx = b.next().unwrap().parse::<i64>().unwrap();
    let by = b.next().map(|x| x.parse::<i64>().unwrap()).unwrap_or(0);

    (ax * bx + (ax * by) / 100 + (ay * bx) / 100 + (ay * by) / 10000).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "198 1.10\n" => "217\n",
    test2: "1 0.01\n" => "0\n",
    test3: "1000000000000000 9.99\n" => "9990000000000000\n",
}


Measured memory_bytes: 2140
# fork from: https://atcoder.jp/contests/practice2/submissions/16655600
# frozen_string_literal: true

def bsf(x)
  (x & -x).bit_length - 1
end

cnt2 = bsf(998244353 - 1)
e = 3.pow((998244353-1) >> cnt2, 998244353)
ie = e.pow(998244353 - 2, 998244353)

es = [0]*(cnt2-1)
ies = [0]*(cnt2-1)
cnt2.downto(2){ |i|
  es[i-2] = e
  ies[i-2] = ie
  e = e*e % 998244353
  ie = ie*ie % 998244353
}
now = inow = 1

@sum_e = [0]*(cnt2-2)
@sum_ie = [0]*(cnt2-2)
(cnt2-2).times{ |i|
  @sum_e[i] = es[i]*now % 998244353
  now = now*ies[i] % 998244353
  @sum_ie[i] = ies[i]*inow % 998244353
  inow = inow*es[i] % 998244353
}

def convolution(a, b)
  n = a.size
  m = b.size
  return [] if n==0 || m==0

  h = (n+m-2).bit_length
  z = 1 << h

  a = a+[0]*(z-n)
  b = b+[0]*(z-m)

  batterfly(a, h)
  batterfly(b, h)

  c = (0 ... z).map{ |i| a[i]*b[i] % 998244353 }

  batterfly_inv(c, h)

  iz = z.pow(998244353-2, 998244353)
  return c[0,n+m-1].map{ |c| c*iz % 998244353 }
end

def batterfly(a, h)
  sum_e = @sum_e
  1.upto(h){ |ph|
    w = 1 << (ph-1)
    p = 1 << (h-ph)
    now = 1
    w.times{ |s|
      offset = s << (h-ph+1)
      offset.upto(offset+p-1){ |i|
        l = a[i]
        r = a[i+p]*now % 998244353
        a[i] = l+r
        a[i+p] = l-r
      }
      now = now*sum_e[bsf(~s)] % 998244353
    }
  }
end

def batterfly_inv(a, h)
  sum_ie = @sum_ie
  h.downto(1){ |ph|
    w = 1 << (ph-1)
    p = 1 << (h-ph)
    inow = 1
    w.times{ |s|
      offset = s << (h-ph+1)
      offset.upto(offset+p-1){ |i|
        l = a[i]
        r = a[i+p]
        a[i] = l+r
        a[i+p] = (l-r)*inow % 998244353
      }
      inow = inow*sum_ie[bsf(~s)] % 998244353
    }
  }
end

_, a, b = $<.map{ |e| e.split.map &:to_i }

puts convolution(a, b).join(?\s)


Measured memory_bytes: 134696
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (int)(n); i++)

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

}



Measured memory_bytes: 256
object Main extends App {

  def combinationExists(xs: Seq[Int], p: (Seq[Int]) => Boolean) = {

    def rec(xs: Seq[Int], acc: List[Int]): Boolean = {
      if (xs.isEmpty)
        p(acc)
      else
        rec(xs.tail, xs.head::acc) || rec(xs.tail, acc)
    }

    rec(xs, List())
  }

  val sc = new java.util.Scanner(Console.in)

  def nextInt() = sc.next().toInt

  val A  = Seq.fill(nextInt())(nextInt())
  val ms = Seq.fill(nextInt())(nextInt())
  for (m <- ms)
    println(if (combinationExists(A, _.sum == m)) "yes" else "no")
}



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

#define NIL NULL/*??????????????§???????????§NULL????????¨?????¨??????*/
struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
};

typedef struct node * Node;/*?§???????node?????????????????¨????????£?¨?*/


void insert(Node,int);
Node Find(Node,int);
void PrintInorder(Node );
void PrintPreorder(Node );
Node root,newnode;
main()
{
  int number,k,i;
  char str[20];
  
  scanf("%d",&number);
  root = malloc(sizeof(struct node));
  for(i=0;i<number;i++)
    {
      scanf("%s",str);
      if(str[0]=='i')
	{
	  scanf("%d",&k);
	  if(i !=0) {
	    
	    insert(root,k);}/*??????Tree????????£????????????????????¢??°????????????*/	
	  else root->key = k;
	 
	  
	}
      else if(str[0] == 'p'){
      PrintInorder(root);
      printf("\n");
      PrintPreorder(root);
      printf("\n"); 
    }	
      else{
	scanf("%d",&k);
	if(Find(root,k)==NIL)printf("no\n");
	else printf("yes\n"); 
      }
    }
return 0;
}

void insert(Node t,int k)
{
  Node y,x,z;
  /*??????????????§????????????????????§malloc?????????????????£??\??§?????????*/
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = z->right = NIL;
 
  

  y = NIL;/*????????§????????????????????? y???x??????????????????*/
  x = t;/*T=root*/ 
  
  while(1)
    {
      y = x;/*??????????????????*/
      
      if(z->key < x->key) x = x->left;
      else x = x->right;
      
      if(x == NIL)break;
    }

   z->parent = y;
   if(y == NIL)t = z;/*??????????¨???????????????¨??§??????root?????£??\??§?????????*/

   else if(z->key < y->key) y->left = z;
   else y->right = z;


}

void PrintInorder(Node T)
{
  if(T != NIL){
     PrintInorder(T->left);
  
  
  printf(" %d",T->key);
 
 
   PrintInorder(T->right);
  }
  else return;
  
}

void PrintPreorder(Node T)
{
  if(T != NIL){
    printf(" %d",T->key);

    PrintPreorder(T->left);
    PrintPreorder(T->right);

  }
  else return ;
 
}


Node Find(Node T,int k)
{
  if(T == NIL || k == T->key)return T;
  if(k < T->key)return Find(T->left,k);
  else return Find(T->right,k);

}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( a == b ){
        cout << a + b << endl;
    } else {
        cout << max(a, b) * 2 - 1 << endl;
    }
    //*/
    
    //cout << ( a - c )  * ( b - d ) << endl;

    return 0; 
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int H,W,sh,sw;
    cin >> H >> W >> sh >> sw;
    cout << H*W+sh*sw-sh*W-sw*H << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a;
    string s;
    int n;
    cin>>n;
    double sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a>>s;
        if(s=="JPY")
        {
            sum+=a;
        }
        else
        {
            sum+=a*380000.0;
        }
    }
    cout<<fixed<<setprecision(20)<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int mo = 998244353;

ll ksm(ll x, ll y) {
	ll s = 1;
	for(; y; y /= 2, x = x * x % mo)
		if(y & 1) s = s * x % mo;
	return s;
}

const int N = 405;

int n, a[N], b[N];
ll fac[N], nf[N];
ll f[N][N], sa, sb, g[N][N], ss, ni;

void build(int n) {
	fac[0] = 1; fo(i, 1, n) fac[i] = fac[i - 1] * i % mo;
	nf[n] = ksm(fac[n], mo - 2); fd(i, n, 1) nf[i - 1] = nf[i] * i % mo;
}
int main() {
	build(400);
	scanf("%d", &n);
	fo(i, 1, n) scanf("%d %d", &a[i], &b[i]), ss += a[i];
	ni = ksm(ss, mo - 2);
	f[0][0] = 1;
	fo(i, 1, n) {
		fo(j, 0, sa) fo(k, 0, sb) g[j][k] = f[j][k], f[j][k] = 0;
		fo(j, 0, sa) fo(k, 0, sb) if(g[j][k]) {
			f[j + a[i]][k] = (f[j + a[i]][k] + g[j][k]) % mo;
			ll ma = 1, ca = a[i] * ni % mo;
			fo(u, 0, b[i] - 1) {
				f[j][k + u] = (f[j][k + u] - g[j][k] * ma % mo * nf[u]) % mo;
				ma = ma * ca % mo;
			}
		}
		sa += a[i], sb += b[i] - 1;
	}
	fo(j, 0, sa) fo(k, 0, sb) f[j][k] = (-f[j][k] + mo) % mo;
	f[sa][0] ++;
	ll nisa = ksm(sa, mo - 2);
	ll ans = 0;
	fo(j, 0, sa) fo(k, 0, sb) {
		ll t = j * nisa % mo;
		ans = (ans + fac[k] * ksm(ksm(1 - t + mo, mo - 2), k + 1) % mo * f[j][k]) % mo;
	}
	pp("%lld\n", ans);
}


Measured memory_bytes: 2816
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

v = [a,b,c,d,e]

import math

times = [ math.ceil(a/10)*10,
          math.ceil(b/10)*10,
          math.ceil(c/10)*10,
          math.ceil(d/10)*10,
          math.ceil(e/10)*10 ]

digit1 = [a - a//10*10,
          b - b//10*10,
          c - c//10*10,
          d - d//10*10,
          e - e//10*10]

m = digit1[0]
tt = 0
idx = 0

for i in range(5):
    tt += times[i]
    if 0 < digit1[i] and digit1[i] < m:
        m = digit1[i]
        idx = i

print('{}'.format(tt - times[idx] + v[idx]))


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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define mod1 998244353
#define mod2 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define FILL(name,val) memset(name , val , sizeof(name))
#define repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
const ll sz = 2e5+5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const ll inf = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;

void solve(){
    //
    int n;
    cin >> n;
    int dp[n+10][4] , mat[n+1][4];
    memset(dp , 0 , sizeof(dp));
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 1 ; j <= 3 ; ++j){
            cin >> mat[i][j];
        }
    }
    //dp[i][j] is max cost of happiness at day i when he chose jth activity at (i-1)th day
    dp[1][1] = max(mat[1][2] , mat[1][3]);
    dp[1][2] = max(mat[1][1] , mat[1][3]);
    dp[1][3] = max(mat[1][2] , mat[1][1]);
    for(int i = 2 ; i <= n ; ++i){
        for(int j = 1 ; j <= 3 ; ++j){
            for(int k = 1 ; k <= 3 ; ++k)
                if(k!=j)dp[i][j] = max(dp[i][j] , mat[i][j] + dp[i-1][k]);
        }
    }
    cout << max(dp[n][1] , max(dp[n][2] , dp[n][3])) << endl;
    //
    return;
}



int main(){
    FIO;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define len(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
#define Sort(arr) sort(arr,arr+len(arr))
#define For(i,s,n) for(int i=s;i<n;i++)	
#define Rep(i,n) for(int i=0;i<n;i++)
#define Per(i,n) for(int i=n;i>=0;i--)
#define All(x) (x).begin(),(x).end()
#define in(arr,n) Rep(i,n) cin >> arr[i];
#define in2(arr1,arr2,n) Rep(i,n) cin >> arr1[i] >> arr2[i];
#define in3(arr1,arr2,arr3,n) Rep(i,n) cin >> arr1[i] >> arr2[i] >> arr3[i];
#define LL_MAX 9223372036854775807
#define LL_MIN -9223372036854775808
#define MOD 1000000007
#define MOD9 1000000009

//{ ライブラリ

// 標準出力の高速化
#define endl "\n"

// 出力
template<typename Type>
void print(Type a[],int n){
	Rep(i,n) cout << a[i] << endl;
}
template<typename Type1,typename Type2>
void print(Type1 a[],Type2 b[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << endl;
}
template<typename Type1,typename Type2,typename Type3>
void print(Type1 a[],Type2 b[],Type3 c[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << " " << c[i] << endl;
}

// 配列の最大値
template<typename Type>
Type max(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=max(ret,a[i]);
	return ret;
}

// 配列の最小値
template<typename Type>
Type min(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=min(ret,a[i]);
	return ret;
}

// 最大公約数
template<typename Type>
Type gcd(Type a,Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type gcd(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=gcd(ret,a[i]);
	return ret;
}

// 最小公倍数
template<typename Type>
Type lcm(Type a,Type b){return (a/gcd(a,b))*b;}
template<typename Type>
Type lcm(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=lcm(ret,a[i]);
	return ret;
}

// aを元にしてペアでソート
template<typename Type1,typename Type2>
void PairSort(Type1 a[],Type2 b[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,left,i-1);
	if(j+1<right) PairSort(a,b,j+1,right);
}
template<typename Type1,typename Type2,typename Type3>
void PairSort(Type1 a[],Type2 b[],Type3 c[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		swap(c[i],c[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,c,left,i-1);
	if(j+1<right) PairSort(a,b,c,j+1,right);
}

// 配列を逆順にする
template<typename Type>
void Reverse(Type a[],int n){Rep(i,n/2) swap(a[i],a[n-i-1]);}

// 文字列を逆順にする
// reverse(All(str));

//}

int main(){
	int N;
	cin >> N;
	int d[N];
	in(d,N);
	
	Sort(d);
	cout << d[N/2]-d[N/2-1];
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int val(int a, int b)
{
    if (a > b)
        swap(a, b);
    return a * 1001 + b + 1;
}
int N;
vint A(1100);
vvint graph(1100000);
vint indeg(1100000, -1);
vint dist(1100000);
vint seen(1100000); //1 : 行きがけ 2 : 見た後
int dfs(int p)
{
    if (seen[p] == 2)
        return dist[p];

    seen[p]=1;
    for (auto &&i : graph[p])
    {
        if (seen[i] == 1)
        {
            cout << -1 << endl;
            exit(0);
        }
        
        chmax(dist[p], dfs(i) + 1);
    }
    seen[p]=2;
    return dist[p];
};
int main()
{
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N - 1; j++)
        {
            cin >> A[j];
            A[j]--;
        }
        graph[0].push_back(val(i,A[0]));
        for (int j = 0; j < N - 2; j++)
        {
            indeg[val(i, A[j])] = 0;
            graph[val(i, A[j])].push_back(val(i, A[j + 1]));
            if (indeg[val(i, A[j + 1])] == -1)
                indeg[val(i, A[j + 1])] = 0;
            indeg[val(i, A[j + 1])]++;
        }
    }
    cout << dfs(0);
    return 0;
}

Measured memory_bytes: 54656
/***from dust i have come, dust i will be***/

#include<bits/stdc++.h>

typedef long long int ll;
typedef unsigned long long int ull;

#define dbg printf("in\n")
#define nl printf("\n");
#define N 101010
#define inf 1e9

#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%I64d", &n)
#define sffl(n,m) scanf("%I64d%I64d",&n,&m)

#define pf(n) printf("%d",n)
#define pff(n,m) printf("%d %d",n,m)
#define pffl(n,m) printf("%I64d %I64d",n,m)
#define pfl(n) printf("%I64d",n)
#define pfs(s) printf("%s",s)

#define pb push_back
#define pp pair<int, int>

using namespace std;

bool status[N];
vector<int> primes;

void sieve_of_eratosthenes()
{
	int sq = sqrtl(N * 1.0);

	memset(status, 0, sizeof(status));

	status[0] = status[1] = 1;

	//all the evens except 2 is composite
	for (int i = 4; i < N; i += 2)
		status[i] = 1;

	for (int i = 3; i <= sq; i+=2)
	{
		if (!status[i])
		{
			//i is prime so its multipliers are not
			for (int j = i * i; j < N; j += i + i)
				status[j] = 1;
		}
	}

	for (int i = 0; i < N; i++)
	{
		if (!status[i])
			primes.push_back(i);
	}
}

int main()
{
    //freopen("in.txt", "r", stdin);

    int i, j, k;
    int n, m;

    sf(n);
    sieve_of_eratosthenes();

    k = lower_bound(primes.begin(), primes.end(), n) - primes.begin();
    pf(primes[k]);


    return 0;
}



Measured memory_bytes: 512
import copy

H,W = map(int, input().split())
S = [list(map(str,input())) for _ in range(H)]

def BFS(q):
	flg = copy.deepcopy(S)
	while q != []:
		cx,cy,cd = q.pop(0)
		if flg[cx][cy] == "#":
			continue
		else:
			flg[cx][cy] = "#"
		nps = [[cx+1,cy],[cx-1,cy],[cx,cy+1],[cx,cy-1]]
		for nx,ny in nps:
			if 0 <= nx < H and 0 <= ny < W:
				if flg[nx][ny] != "#":
					q.append([nx,ny,cd+1])

	return cd

ans = 0

for sx in range(H):
	for sy in range(W):
		if S[sx][sy] == "#":
			continue
		else:
			ans = max(ans,BFS([[sx,sy,0]]))

print(ans)

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

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

int main() {
  int N;
  cin >> N;
  vector<long long> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  long long INF = 1LL << 60;
  vector<long long> dp(N, INF);
  dp.at(0) = 0;
  for (int i = 1; i < N; i++) {
    chmin(dp.at(i), dp.at(i-1) + abs(h.at(i) - h.at(i-1)));
    if (i > 1) chmin(dp.at(i), dp.at(i-2) + abs(h.at(i) - h.at(i-2)));
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  cout << min(A,B) << " " << max(A + B - N,0) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
import heapq

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = LIST()
F = LIST()

A.sort(reverse=True)
F.sort()

time = [A[i]*F[i] for i in range(N)]
# print(F)
# print(time)

def is_ok(x):  # 時間をx以下にできるか？
	tmp = 0
	for i in range(N):
		if time[i] <= x:
			pass
		else:
			tmp += ceil((time[i]-x)/F[i])
	if tmp > K:
		return False
	else:
		return True

min_ = -1
max_ = 10**18
while min_ + 1 != max_:
	search = (min_+max_)//2
	# print(min_, max_, search)
	if is_ok(search):
		max_ = search
	else:
		min_ = search

print(max_)


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

int main() {
  int n, min;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    int a, cnt;
    cin >> a;
    
    cnt = 0;
    while (a % 2 == 0) {
      a /= 2;
      cnt++;
    }
    
    if (i == 0) {
      min = cnt;
    }
    else if (min > cnt) {
      min = cnt;
    }
  }
  
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int D; cin >> D;
  vector<int> C(26);
  for(int i = 0; i < 26; i++){
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> S[i][j];
    }
  }

  random_device seed_gen;
  mt19937_64 rnd(seed_gen());
  uniform_int_distribution<int> dist_T(1, 26);
  clock_t start = clock();

  int score = -INF;
  vector<int> ans(D);
  while(true){
    int res = 0;
    vector<int> L(26, -1);
    vector<int> dp(D);
    for(int i = 0; i < D; i++){
      int T = dist_T(rnd);
      res += S[i][T-1];
      for(int j = 0; j < 26; j++){
        if(L[j] == -1) continue;
        res -= i - L[j];
      }
      dp[i] = T;
    }
    if(score < res){
      score = res;
      ans = dp;
    }

    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
    if(time >= 1.9) break;
  }

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}

Measured memory_bytes: 3764
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t.sort(reverse=True)
    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    # for j in range(d):  #必殺技の回数
    #     c = sum(t)
    #     if c != 0:
    #         g = max(t)
    #         for i in range(b):
    #             if g == t[i]:
    #                 t[i] = 0
    #                 break
    #         t[f] = 0
    #         f = 0
    #     else:
    #         break
    c = sum(t)
    for i in range(d):
        if c != 0:
            c -= t[i]
            t[i] = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Measured memory_bytes: 26016
from collections import deque
N, K = map(int, input().split())
ab = [list(map(int,input().split())) for _ in range(N-1)]
mod = 1000000007

routes = [[] for _ in range(N)]
for i in range(N-1):
    routes[ab[i][0]-1].append(ab[i][1]-1)
    routes[ab[i][1]-1].append(ab[i][0]-1)

options = [0 for i in range(N)]
seen = [False for _ in range(N)]
options[0] = K
seen[0] = True
todo = deque([0])
color = 0
while len(todo):
    checking = todo.pop()
    if checking == 0:
        rest = K
    else:
        rest = K-1
    for route in routes[checking]:
        if seen[route] == False: 
            todo.append(route)
            rest = rest - 1
            options[route] = rest
            seen[route] = True

answer = 1
for i in range(N):
    answer = (answer * options[i])%mod
print(answer)

Measured memory_bytes: 122504