akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> a(n);
    int cnt = 0;
    rep (i, n) {
        cin >> a[i];
        if (a[i] % 2 == 1) continue;
        while (a[i] % 2 != 1) {
            a[i] /= 2;
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

int main() {

  long long int n ,m, input1, input2;

  while( true ) {

    cin >> n >> m;

    if ( n == 0 ) break;

    vector< long long int > d, p, s;

    for ( long long int i = 0; i < n; i++ ) {

      cin >> input1 >> input2;

      d.push_back(input1);
      p.push_back(input2);
      s.push_back(input2);

    }

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

    for ( long long int i = s.size() - 1; i >= 0; i-- ) {

      long long int k = s[i];
      for ( long long int j = 0; j < n; j++ ) {

	if ( p[j] == k ) {
	  if ( d[j] > m ) {
	    d[j] -= m;
	    m = 0;
	  }else {
	    m -= d[j];
	    p[j] = 0;
	  }
	  break;
	}

      }
      if ( m == 0 ) break;

    }

    long long int ans = 0;

    for ( long long int i = 0; i < n; i++ ) {

      ans += d[i] * p[i];

    }

    cout << ans << endl;

  }

  return 0;

}

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

int main()
{
    int t, n;
    int s, f;
    int sum;

    while (cin >> t, t != 0) {
        sum = 0;
        
        cin >> n;

        for (int i = 0; i < n; i++) {
            cin >> s >> f;

            sum += (f - s);
        }

        if (sum >= t) {
            cout << "OK" << endl;
        }
        else {
            cout << t - sum << endl;
        }

    }

    return 0;
}



Measured memory_bytes: 3088
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll ans=0;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(!(i%3==0||i%5==0))
			ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{

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

    int n = Integer.parseInt(sc.next());
    int[] x = new int[n];

    for (int i=0; i<n; i++)
      x[i] = Integer.parseInt(sc.next());

    int total = 0;

    for(int i=1; i<=100; i++){
      int tmp=0;
      for (int j=0; j<n; j++){
        tmp += (x[j]-i)*(x[j]-i);
      }
      if (i==1)
        total = tmp;
      if(tmp<total)
        total = tmp;
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 21844
def main():
    LIMIT = 10 ** 18

    N = int(input())
    A = map(int, input().split())

    mul = 1
    for x in A:
        mul *= x
        if mul > LIMIT:
            if any(x == 0 for x in A):
                print(0)
            else:
                print(-1)
            return
    print(mul)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19316
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    int x;
    cin>>x;
    if(x==7 || x==5 || x==3){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}
    

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

int A, B, C, D;
int main() {
   cin >> A >> B >> C >> D;
   bool takahashiWin;
   while (true) {
       A = A - D;
       C = C - B;
       if (C <= 0) {
           cout << "Yes" << endl;
           break;
       }
       if (A <= 0) {
           cout << "No" << endl;
           break;
       }
   }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  vl abc(3);
  rep(i, 3) cin >> abc[i];

  stable_sort(abc.begin(), abc.end());

  cout << 10*abc[2] + abc[1] + abc[0] << "\n";
  
  return 0;
}


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

int n;
vi a;

int main()
{
    cin >> n;
    a.resize(n+1);
    rrep(i,n) cin >> a[i];
    int ans = 0;
    rrep(i,n){
        if(i == a[a[i]]) ans++;
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    int n,k;
    cin>>n>>k;
    vector<int64_t> h(n);
    rep(i,n){
        cin>>h[i];
    }
    vector<int64_t> dp(n);
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        int64_t mcos = 100000000000;
        for(int j=1;j<=k;j++){
            if(i-j<0){
                break;
            }
            mcos = min(mcos,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i]=mcos;
    }
    cout<<dp[n-1]<<endl;
}

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

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

long long comb(long long n, long long k)
{
    long mod = pow(10, 9) + 7;

    long long max_value = max(k, n - k);
    long long min_value = min(k, n - k);

    long long x = 1;
    long long y = 1;
    for (long long i = 1; i <= min_value; i++)
    {
        x *= i;
        x %= mod;
    }
    for (long long i = 0; i < n - max_value; i++)
    {
        y *= max_value + i + 1;
        y %= mod;
    }
    return y * modinv(x, mod) % mod;
}

int main()
{
    long X, Y;
    cin >> X >> Y;
    long mod = pow(10, 9) + 7;
    long long r = X - 2 * Y;
    long long l = -2 * X + Y;
    r *= -1;
    l *= -1;
    long long ans = 0;
    if (r % 3 != 0 || l % 3 != 0)
        ans = 0;
    else if (r < 0 || l < 0)
        ans = 0;
    else
    {
        r /= 3;
        l /= 3;
        ans = comb(r + l, r);
    }
    cout << ans % mod << endl;
    return 0;
}

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

#define endl '\n'
#define int long long

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

	int h, w; cin >> h >> w;
	vector<int> row(h, 0), col(w, 0);
	map<pair<int, int>, int> mapp;
	map<int, int> rows, cols;
	int m; cin >> m;
	for(int i = 0; i < m; i ++) {
		int r, c; cin >> r >> c;
		mapp[{r, c}] ++;
		row[r - 1] ++;
		col[c - 1] ++;
	}
	int rmax = -1, cmax = -1;
	for(int i = 0; i < h; i ++) {
		rmax = max(rmax, row[i]);
	}
	for(int i = 0; i < w; i ++) {
		cmax = max(cmax, col[i]);
	}
	for(int i = 0; i < h; i ++) {
		if(row[i] == rmax) rows[i + 1] ++;
	}
	for(int i = 0; i < w; i ++) {
		if(col[i] == cmax) cols[i + 1] ++;
	}
	for(auto i : rows) {
		for(auto j : cols) {
			if(mapp[{i.first, j.first}] == 0) {
				cout << cmax + rmax << endl;
				return 0;
			}
		}
	}
	cout << cmax + rmax - 1 << endl;

	return 0;
}

Measured memory_bytes: 64152
a,b,c = map(int, input().split())
def change(a, b):
    if a > b:
        tmp = a
        a = b
        b = tmp
        return a, b
    else:
        return a,b

a,b = change(a,b)
b,c = change(b,c)
a,b = change(a,b)

print(a, b, c)






Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x == 3 || x == 5 || x == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		sc.close();
	}
}

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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {                                                                                                     
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];

  ll sum = 0;
  for(ll i=1; i<N; ++i) {
    if(A[i] < A[i-1]) {
      sum += A[i-1] - A[i];
      A[i] = A[i-1];
    }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
#define M 1000000000
typedef long long int ll;

int main(){

	ll a, b, n, x;
	cin >> a >> b >> n;
	if(a == 1 || b == 1){
		cout << "0\n";
		return 0;
	}
	if(b > n)
		x = n;
	else
		x = b - 1;
	cout << floor(a*x/b) - a*floor(x/b) << endl;
	return 0;
}

Measured memory_bytes: 3788
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li rems[3] = {2, 3, 5};

void solve() {
    li n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    priority_queue<pair<li, li>> q;
    q.emplace(0, n);

    const li costs[3] = {a, b, c};

    __int128 nn = n, dd = d;
    __int128 mcost = nn * dd;

    map<li, li> memo;
    while (true) {
        auto t = q.top();
        q.pop();
        const li cost = -t.first;
        const li value = t.second;

        if (cost >= mcost) {
            cout << (li) mcost << '\n';
            return;
        }
        if (value == 0) {
            cout << cost << '\n';
            return;
        }
        if (value <= (li)(1e18) / d) {
            q.emplace(-(cost + d * value), 0);
        }
        for (int r = 0; r < 3; ++r) {
            const li rem = rems[r];
            const li rr = value % rem;
            {
                const li ncost = (cost + rr * d + costs[r]);
                const li nv = (value - rr) / rem;
                if (memo.find(nv) == memo.end() || memo[nv] > ncost) {
                    q.emplace(-ncost, nv);
                    memo[nv] = ncost;

                }
            }
            {
                const li ncost = (cost + d * (rem - rr) + costs[r]);
                const li nv = (value + rem - rr) / rem;
                if (memo.find(nv) == memo.end() || memo[nv] > ncost) {
                    q.emplace(-ncost, nv);
                    memo[nv] = ncost;

                }
            }
//            q.emplace(-(cost + (rem - rr) * d + costs[r]), (value + (rem - rr)) / rem);
        }
    }
}

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

    li t;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}

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

int main() {
	int a[4],b[4];
	int hit,blow;
	
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		hit = blow = 0;
		
		for(int i=0;i<4;++i)if(a[i]==b[i])++hit;
		for(int i=0;i<4;++i)for(int j=0;j<4;++j)if(i!=j)if(a[i]==b[j])++blow;
		
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    vector < long > inp(n);
    int i;
    for (i=0;i<n;i++)
        cin>>inp[i];
    sort(inp.begin(),inp.end());
    cout<<inp[n-1]-inp[0]<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c=0,i,j,n;
    for(i=0; i<s.length(); i++)
    {
        n=0;
        for(j=0; j<s.length(); j++)
        {
            if(s[i]==s[j])
                n++;
        }
        if(n%2==0)
            c++;
        else
            break;
    }
    if(c==s.length())
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}



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

int main(){
  int N;
  long long T;
  cin >> N >> T;
  
  long long ti[200000];
  for(int i=0;i<N;i++) cin >> ti[i];
  
  long long sum=0;
  for(int i=0;i<N-1;i++){
    if(ti[i+1]-ti[i]<T) sum+=ti[i+1]-ti[i];
    else sum+=T;
  }
  sum+=T;
  
  cout << sum << endl;
  return 0;
}
  

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int d;
	for (; cin >> d;)
	{
		int s = 0;
		int x = d;
		for (; x < 600; x += d)
		{
			s += x * x * d;
		}

		cout << s << endl;
	}
}


Measured memory_bytes: 3080
N, Q = list(map(int, input().split()))
S = input()
cnt = [0]

for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        cnt.append(cnt[i-1]+1)
    else:
        cnt.append(cnt[i-1])
for i in range(Q):
    l, r = list(map(int, input().split()))
    print(cnt[r-1]-cnt[l-1])

Measured memory_bytes: 6172
import java.util.Scanner

object Main {
  def calc(x: Int): Int = if (x == 1) (1) else (calc(x / 2) * 2)

  def solve(sc: => Scanner): Unit = {
    println(calc(sc.nextInt))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25552
/*@author hussein zayed ;
        ___  ___
       |\  \|\  \
       \ \  \_\  \
        \ \   ___ \USSEIN
         \ \  \\ \ \
          \ \__\\ \_\
           \|__| \|__|
    ****************************************
    */

    #include <bits/stdc++.h>
    using namespace std;
    #define fr for(int i=0;i<n;++i)
    #define fr1 for(int i=1;i<=n;++i)
    #define cinA for(int i=0;i<n;++i){cin>>arr[i];}
    #define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
    #define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
    #define ll long long
    #define lnarray sizeof(arr)/sizeof(*arr)
    #define vi vector<int>
    #define vs vector<string>
    void Fast()
    {
        ios_base :: sync_with_stdio( 0 ) ;
        cin.tie( 0 ) ;
        cout.tie( 0 ) ;
    }
    inline int RD()
    {
        int i ;
        cin>>i;
        return i;
    }

    inline float RF()
    {
        float i ;
        cin>>i;
        return i;
    }

    inline double RDO()
    {
        double i ;
        cin>>i;
        return i;
    }

    inline string RS()
    {
        string i ;
        cin>>i;
        return i;
    }

    inline ll RLL()
    {
        ll i ;
        cin>>i;
        return i;
    }



    ll sumSet(ll n)
    {
        return (1ll*n*(n+1))/2;
    }
    string s;


    bool isPrime(int n)
    {
        if(n==1)
            return false;
        for(int i=2; i*i<=n; ++i)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    int sumDigit(int n){
    int sum =0;
      while (n != 0)
        {
            sum+=  n % 10;
            n = n / 10;
        }
        return sum;
    }

    ll power2(int n){
      ll ans=(1<<n);
      return ans;
    }

    ll sumpow2(ll n){
     ll sum=(n*(n+1)*(2*n-1))/6;
     return sum;
    }
    vi vr;
  void printDivisors(int n)
{
vr.clear();
    for (int i=2;i<=n;i++)
        if (n%i==0)
           vr.push_back(i);
}
    int main(){
        Fast();
    //freopen("output.txt" , "w" , stdout);
    //freopen("wall.in" , "r" , stdin);
int n=RD(),k=RD();
int st=n-1;
for(int i=k-st;i<=k+st;++i)
cout<<i<<" ";

    }


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

const int MAX = 2e5;
struct edge{int to, cost;};
struct Diameter{int from, to, d;};

P farthest(int u, int p, vector<vector<edge>>& g) {
  P r(0,u);
  for(auto e : g[u]) {
    if(e.to == p) continue;
    P c = farthest(e.to,u,g);
    c.first += e.cost;
    r = max(r,c);
  }
  return r;
}

Diameter tree_diameter(vector<vector<edge>>& g) {
  P p = farthest(0,-1,g);
  P q = farthest(p.second,-1,g);
  return Diameter{p.second,q.second,q.first}; 
}

int main(){
  int n;
  cin >> n;
  vector<vector<edge>> g(n);
  rep(i,n-1) {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(edge{t,w});
    g[t].push_back(edge{s,w});
  }
  Diameter d = tree_diameter(g);
  cout << d.d << endl;
  return 0;
}


Measured memory_bytes: 17576
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a > b) cout << a-1 << endl;
  else cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
num = 0
ans = False
for i in range(N):
  D = list(map(int, input().split(' ')))
  if D[0] == D[1]:
    num += 1
    if num >= 3:
      ans = True
  else:
    num = 0

if ans:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9172
<?php

while (true) {
    fscanf(STDIN, '%d %s %d', $a, $op, $b);
    $result = culc($a, $op, $b);

    if (is_null($result)) { break; }
    $results[] = $result;
}

printf('%s%s', implode(PHP_EOL, $results), PHP_EOL);

function culc($a, $op, $b)
{
    switch ($op) {
        case '+':
            return $a + $b;
        case '-':
            return $a - $b;
        case '*':
            return $a * $b;
        case '/':
            return floor($a / $b);
    }

    return null;
}

Measured memory_bytes: 6612
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int n,a,m,M,i;
    long S;
    cin>>n>>a;
    m=M=a;
    S=a;
    for(i=1;i<n;i++) {
        cin>>a;
        if (a<m) m=a;
        if (M<a) M=a;
        S+=a;
    }
    printf("%d %d %ld\n", m, M, S);
    return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e15;

int main() {
    ll N,m=INF;
    cin >> N;
    
    for(ll i=1; i*i<=N; ++i)
        if(N%i == 0)
            m =min(m,i+N/i-2);

    cout << m << endl;
}

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

const int MOD = 998244353;
int upd(int x){return x + (x >> 31 & MOD);}
void inc(int &a , int b){a = upd(a + b - MOD);}
int N , M , vr[13] , vc[13]; char arr[13][13];

int f[1 << 10][1 << 10][3] , g[1 << 10][1 << 10][4][3][4];
bool vf[1 << 10][1 << 10][3] , vg[1 << 10][1 << 10][4][3][4];

int sf(int , int , int);
int sg(int , int , int , int , int);

bool check(int r , int c){
	bool flg = 1;
	for(int i = 0 ; i < N ; ++i) if(r >> i & 1) flg &= (vr[i] & c) != 0 && (vr[i] & c) != c;
	for(int j = 0 ; j < M ; ++j) if(c >> j & 1) flg &= (vc[j] & r) != 0 && (vc[j] & r) != r;
	return flg;
}

int sf(int a , int b , int c){
	if(!a && !b) return 1;
	if(!a || !b) return 0;
	if(vf[a][b][c]) return f[a][b][c];
	vf[a][b][c] = 1; return f[a][b][c] = sg(a , b , 0 , c , 0) + check(a , b);
}

int sg(int a , int b , int c , int d , int e){
	if(c == 4) return e ? sf(a , b , e - 1) : 0;
	if(vg[a][b][c][d][e]) return g[a][b][c][d][e];
	int &t = g[a][b][c][d][e]; vg[a][b][c][d][e] = 1;
	if(c <= 1)
		if(!d) t = sg(a , b , c + 1 , d , e);
		else for(int x = (!c ? a & 31 : a >> 5 << 5) , s = x ; ; s = (s - 1) & x){
				inc(t , sg(a ^ x ^ s , b , c + 1 , d , e | (s != x))); if(!s) break;
			}
	else
		if(d == 1) t = sg(a , b , c + 1 , d , e);
		else
			for(int x = (c == 2 ? b & 31 : b >> 5 << 5) , s = x ; ; s = (s - 1) & x){
				inc(t , sg(a , b ^ x ^ s , c + 1 , d , e | (s != x) << 1)); if(!s) break;
			}
	return t;
}

int main(){
	cin >> N >> M; for(int i = 0 ; i < N ; ++i) for(int j = 0 ; j < M ; ++j) cin >> arr[i][j];
	for(int i = 0 ; i < N ; ++i) for(int j = M - 1 ; ~j ; --j) vr[i] = vr[i] << 1 | (arr[i][j] == '#');
	for(int i = 0 ; i < M ; ++i) for(int j = N - 1 ; ~j ; --j) vc[i] = vc[i] << 1 | (arr[j][i] == '#');
	int sum = 0;
	for(int i = 0 ; i < 1 << N ; ++i) for(int j = 0 ; j < 1 << M ; ++j) inc(sum , sf(i , j , 2));
	cout << sum; return 0;
}


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

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

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

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using Graph = vector<VE>;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	double a, b, x; cin >> a >> b >> x;
	double v = a * a*b;
	double now = 0;
	if (2 * x < v) {
		now = a * b*b / (2 * x);
	}
	else {
		now = 2 * (v - x) / (a*a*a);
	}
	cout << fixed<<setprecision(15)<<atan(now)*180.0 / PI << endl;
	return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

s = inputIL()
print(len(set(s)))

Measured memory_bytes: 64076
/*package whatever //do not write package name here */

import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;


class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    }
    
	public static void main (String[] args) {
		FastReader ob = new FastReader();
	    Stack<String> st = new Stack<String>();
	    String s = ob.next();
	    int n = s.length();
	    for (int i=0;i<n ;i++ ) {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    }
	    String ans ="";
	    while(!st.empty()){
	        ans = st.pop()+ans;
	    }
	    System.out.print(ans);
	    
	}
}

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

vector<bool> prime(150000,true);

int main(){
    prime[0]=false;
    prime[1]=false;
    for(int i=2; i<150000; i++){
        if(prime[i]){
            for(int j=2; j*i<150000; j++){
                prime[j*i]=false;
            }
        }
    }

    while(1){
        int n,p;
        cin >> n >> p;
        if(n==-1) break;

        vector<int> prm(100);
        for(int i=n+1,cnt=0; cnt<p; i++){
            if(prime[i]){
                prm[cnt]=i;
                cnt++;
            }
        }

        vector<int> prmprd;
        for(int i=0; i<p; i++){
            for(int j=i; j<p; j++){
                prmprd.push_back(prm[i]+prm[j]);
            }
        }
        sort(prmprd.begin(),prmprd.end());
        cout << prmprd[p-1] << endl;



    }
    return 0;
}

Measured memory_bytes: 3168
#include<iostream>
using namespace std;
int main(){
        int N,a;
        int min, sum;
        min = -1;
        cin>>N;
        sum = 0;
        for(int i=0;i<N;i++){
                cin>>a;
                sum += a;
                if(a%10==0){
                        continue;
                }
                if(min>a||min==-1){
                        min = a;
                }
        }
        if(sum%10==0&&min!=-1){
                sum -= min;
        }
        if(sum%10==0){
                sum = 0;
        }
        //printf("%d\n",sum);
        cout<<sum<<endl;
}

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

int main() {
  int N;
  cin >> N;
  int answer;
  
  for(int i; i < N;i++){
  int l, r;
  cin >> l >> r;
  answer += r - l + 1;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

const lli N = 1e5+1;
lli n,a,b,c,d;
unordered_map<lli,lli> dp;

lli fun(lli e){
    if(e==0) return 0;
    else if(e==1) return d;
    if(dp[e]) return dp[e];
    lli res = 5e18;
    if(d < res/n) res = min(res, d*e);
    NA(i,0,3){
        lli m = vector<int>{2,3,5}[i];
        lli cost = vector<lli>{a,b,c}[i];
        if(e%m==0){
            res = min(res, cost + fun(e/m));
        } else {
            res = min(res, cost + (d*(e%m)) + fun(e/m));
            res = min(res, cost + (d*(m - (e%m))) + fun(e/m + 1));
        }
    }
    return dp[e] = res;
}

void solve(){
    dp.clear();
    cin>>n>>a>>b>>c>>d;
    cout<<fun(n)<<'\n';
    return;
}

int main(){
    fastIO; 
    lli t = 1; 
    cin>>t;
    NA(i,0,t) {
        // cout<<"Case #"<<i+1<<": "; 
        solve();
    }
    return 0;
}

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

int main(){
  int n, tmp, ans = 0;
  cin >> n;
  vector <int> l;
  for(int i = 0; i < n; ++i){
    cin >> tmp;
    l.push_back(tmp);
  }
  for(int i = 0; i < n - 1; ++i){
    for(int j = i+1; j < n; ++j){
      ans += l[i]*l[j];
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector <int> a(N);
  
  for (int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  int now, c;
  now=1, c=0;
  
  for (int i=0; i<N; i++){
    now = a.at(now-1);
    c++;
    
    if (now==2){
      cout << c << endl;
      break;
    }
  }
  if (now!=2){
    cout << -1 << endl;
  }
  



}


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

vector<int> v;
int n, l;

int main() {
#ifdef HOME
	freopen("agc2c.in", "r", stdin);	
	freopen("agc2c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> l;
	v.resize(n);	
	for (auto &i: v)
		cin >> i;

	for (int i = 1; i < n; ++i) if (v[i] + v[i - 1] >= l) {
		cout << "Possible\n";

		for (int j = n - 1; j > i; --j)
			cout << j << '\n';
		for (int j = 1; j < i; ++j)
			cout << j << '\n';
		cout << i << '\n';

		return 0; }
			

	cout << "Impossible\n";

	return 0; }


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int inf=0xffffffff;
ll x,sum[200009],n,ans;
ll minn=inf,cnt,pos;
ll abss(ll a)
{
    if(a>=0) return a;
    else return -a;
}
int main()
{
    scanf("%lld",&n);
    scanf("%lld",&x);
    sum[0]=x;
    for(ll i=1;i<n;i++)
    {
        scanf("%lld",&x);
        sum[i]=sum[i-1]+x;
    }
    ans=sum[n-1];
    cnt=sum[0]*2;

    minn=abss(ans-cnt);
    //pos=cnt-ans;
    //cout<<minn<<endl;
    for(ll i=1;i<n-1;i++)
    {
        cnt=sum[i]*2;
        minn=min(minn,abss(ans-cnt));
    }
    printf("%lld\n",minn);
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
 
int main()
{
    int i, m, h, len;
    char cards[201], temp[201];
     
    for(;;) {
        scanf("%s",cards);
        if(strcmp(cards,"-") == 0) break;
        len = strlen(cards);
        scanf("%d",&m);
        for (i=0; i<m; i++) {
            scanf("%d",&h);
            strcpy(temp,cards);
            strcpy(cards,&temp[h]);
            strncpy(&cards[len - h],temp,h);
            cards[len] = '\0';
        }
        printf("%s\n",cards);
    }
    return 0;
}

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

int n,m,k;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> k;
	if (!(k%n)||!(k%m)){
		cout << "Yes\n";
		return 0;
	}
	for (int i=1;i<=n/2;i++){
		if (i*m>k){
			break;
		}
		if (!(n-i-i)){
			continue;
		}
		if (!((k-i*m)%(n-i-i))&&
		(k-i*m)/(n-i-i)<=m){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
struct lazy_segtree{
private:
  int sz;
  vector<ll> node,lazy;
  ll seg_inf;
public:
  lazy_segtree(int n){
    sz=1;
    while(sz<n) sz*=2;
    node.resize(sz*2-1,0);
    lazy.resize(sz*2-1,0);
    seg_inf=0xffffffffffffff;
  }
  void eval(int k){
    node[k]+=lazy[k];
    if(k<sz-1){
      lazy[2*k+1]+=lazy[k];
      lazy[2*k+2]+=lazy[k];
    }
    lazy[k]=0;
  }
  void plus(int a,int b,ll x,int k,int l,int r){
    eval(k);
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      lazy[k]+=x;
      eval(k);
    }
    else{
      plus(a,b,x,2*k+1,l,(l+r)/2);
      plus(a,b,x,2*k+2,(l+r)/2,r);
      node[k]=min(node[2*k+1],node[2*k+2]);
    }
  }
  void add(int a,int b,ll x){
    plus(a,b,x,0,0,sz);
  }
  ll get_min(int a,int b,int k,int l,int r){
    eval(k);
    if(r<=a||b<=l) return seg_inf;
    if(a<=l&&r<=b) return node[k];
    else return min(get_min(a,b,2*k+1,l,(l+r)/2),get_min(a,b,2*k+2,(l+r)/2,r));
  }
  ll find(int s,int t){
    return get_min(s,t,0,0,sz);
  }
  void debug(int f){
    if(f==0){
      cout<<"node:";
      for(int i=0;i<node.size();i++) cout<<node[i]<<" ";
    }
    else{
      cout<<"lazy:";
      for(int i=0;i<lazy.size();i++) cout<<lazy[i]<<" ";
    }
    cout<<endl;
  }
};
int main(){
  int n,q;
  cin>>n>>q;
  lazy_segtree seg=lazy_segtree(n);
  for(int i=0;i<q;i++){
    int f;
    cin>>f;
    if(f==0){
      int s,t; ll x;
      cin>>s>>t>>x;
      //s++; t++;
      seg.add(s,t+1,x);
    }
    else{
      int s,t;
      cin>>s>>t;
      //s++; t++;
      cout<<seg.find(s,t+1)<<endl;
    }
    //seg.debug(0);
    //seg.debug(1);
  }
}



Measured memory_bytes: 7020
# coding: utf-8
N, K, Q = gets.split.map {|e| e.to_i}
A = []
Q.times do |_|
  A <<  gets.to_i
end
ans = 0

# 最初のポイント計算
init_p = K - Q
points = Array.new(N,init_p)

# 正解者のポイントを+1していく
A.each do |i|
  points[i-1] += 1
end

points.each do |e|
  if e > 0
    puts "Yes"
  else
    puts "No"
  end
end




Measured memory_bytes: 4148
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPoll solver = new CPoll();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPoll {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> count = new HashMap<>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                count.merge(s, 1, Integer::sum);
            }
            int max = 0;
            for (int c : count.values())
                max = Math.max(max, c);

            List<String> answer = new ArrayList<>();
            for (Map.Entry<String, Integer> e : count.entrySet()) {
                if (e.getValue() == max)
                    answer.add(e.getKey());
            }
            Collections.sort(answer);

            for (String s : answer) {
                out.println(s);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 67116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

int main(){
    ll i,j;
    ll a,b;
    cin>>a>>b;
    ll m=max(a-b,a+b);
    m=max(m,a*b);
    cout<<m<<endl;
    return 0;   
}

Measured memory_bytes: 256
class ModCalc:
    mod = 10**9 + 7

    def __init__(self, n):
        self.n = n
        self.inv = [1] * (self.n + 1)
        self.fac = [1] * (self.n + 1)
        self.finv = [1] * (self.n + 1)
        self.inv[0] = 0
        self.inv_table()

    def inv_table(self):
        for i in range(2, self.n+1):
            self.inv[i] = self.inv[self.mod % i] * (self.mod - self.mod // i) % self.mod
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0

        return self.fac[n] * self.finv[r] % self.mod * self.finv[n-r] % self.mod

    def perm(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0

        return self.fac[n] * self.finv[n-r] % self.mod

    def fact(self, n):
        return self.fac[n]


n, k = map(int, input().split())

mc = ModCalc(n)
mod = 10**9 + 7

for i in range(1, k+1):
    tmp = mc.comb(n-k+1, i)
    print(mc.comb(k-1, i-1) * tmp % mod)


Measured memory_bytes: 9328
n = int(input())
A = [*map(int, input().split())]
def solve():
    MAX_A = 10**6 + 1
    C = [0] * MAX_A
    for a in A: C[a] += 1
    pairwise = True
    for i in range(2, MAX_A):
        if sum(C[i::i]) > 1: pairwise = False
    if pairwise: return 'pairwise'
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    if g == 1: return 'setwise'
    return 'not'
print(solve(), 'coprime')


Measured memory_bytes: 204168
# 入力 : 数字2つ
A, B = map(int, input().split())

# 出力　A+Bの値を出力してください。
# ただし、A+Bが 10 以上の場合は、代わりに error と出力してください。

if A+B >= 10 :
    print("error")
else :
    print(A+B)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    cout << (n/(a+b)) * a + min(a,n%(a+b)) << endl;
}


Measured memory_bytes: 256
<?php
ini_set("date.timezone", "Asia/Tokyo");

function printDate($start, $date) {
	list($ys,,) = explode("-", $start);
	list($yd,$md,$dd) = explode("-", $date);

	$year = $yd - $ys + 1;

	return "$year $md $dd";
}
function main() {

	$MEIJI  = "1868-09-08";
	$TAISHO = "1912-07-30";
	$SHOWA  = "1926-12-25";
	$HEISEI = "1989-01-08";

	while ($line = trim(fgets(STDIN))) {
		list($y, $m, $d) = explode(' ', $line);
		$date = "$y-$m-$d";

		if (strtotime($date) < strtotime($MEIJI)) {
			echo "pre-meiji\n";
		} elseif (strtotime($date) < strtotime($TAISHO)) {
			echo "meiji " . printDate($MEIJI, $date) . "\n";
		} elseif (strtotime($date) < strtotime($SHOWA)) {
			echo "taisho " . printDate($TAISHO, $date) . "\n";
		} elseif (strtotime($date) < strtotime($HEISEI)) {
			echo "showa " . printDate($SHOWA, $date) . "\n";
		} else {
			echo "heisei " . printDate($HEISEI, $date) . "\n";
		}

	}
}

main();

Measured memory_bytes: 6852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[1000001];
    for(int i=2;i<1000001;i++)prime[i]=true;
    for(int i=2;i<=sqrt(1000000);i++){
        if(prime[i]==true){
            for(int j=i+i;j<1000001;j+=i)prime[j]=false;
        }
    }
    int n,cou=0;
    while(cin>>n&&n!=0){
        for(int i=2;i<=n/2;i++)if(prime[i]==true&&prime[n-i]==true)cou++;
        cout<<cou<<endl;
    cou=0;
    }
}

Measured memory_bytes: 2132
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    string ans = "";
    for(int i = s.size()-1; i >= t.size()-1;i--)
    {
        bool flag = true;
        for(int j = t.size()-1; j >= 0; j--)
        {
            if (s[i-(t.size()-1-j)]!='?' && s[i-(t.size()-1-j)]!=t[j]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            for(int k = 0; k < s.size(); k++)
            {
                if (k == i-t.size()+1) {
                    ans += t;
                    k += t.size() - 1;
                }
                else if (s[k] == '?') {
                    ans += "a";
                }
                else
                {
                    ans += s[k];
                }
            }
            break;
        }
    }
    if (ans == "") {
        cout << "UNRESTORABLE" << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int d;
    scanf("%d",&d);
    if(d == 25){
        printf("Christmas\n");
    }else if(d == 24){
        printf("Christmas Eve\n");
    }else if(d == 23){
        printf("Christmas Eve Eve\n");
    }else{
        printf("Christmas Eve Eve Eve\n");
    }
    return 0;
}

Measured memory_bytes: 128
N, X = map(int, input().split())


def saiki(n, x):
    #print(n, x)
    if n == 5:
        if x == 1:
            return 0
        elif x <= 4:
            return x-1
        else:
            return 3

    if x <= 1:
        return 0
    elif x <= 1 + (n-3)//2:
        return saiki((n-3)//2, x-1)
    elif x == 1 + (n-3)//2 + 1:
        return saiki(x - 2, x - 2) + 1
    elif x <= 1 + (n-3)//2 + 1 + (n-3)//2:
        return saiki((n - 3) // 2, (n - 3) // 2) + 1 + saiki((n - 3) // 2, x - ((n-3)//2+2))
    else:
        return 2 * saiki((n - 3) // 2, (n - 3) // 2) + 1


maisu = 1
for i in range(N):
    maisu = 2 * maisu + 3

ans = saiki(maisu, X)

print(ans)


Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    h_ls = tuple(map(int, input().split()))
    h_ = h_ls[-1]

    for h in h_ls[-2::-1]:
        if h > h_:
            if h - 1 == h_:
                continue
            print('No')
            quit()
        h_ = h
    print('Yes')


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
using namespace std;
//mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;
typedef pair<int,int> pii;

long long get(int x,int y) {return 1ll*x*1000000+y;}
unordered_map<ll,int> mp;
int sx[300005],sy[300005];
int main() {
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=k;++i) {
        int x,y;
        cin>>x>>y;
        sx[x]++,sy[y]++;
        mp[get(x,y)]++;
    }
    int mx=0;
    for(int i=1;i<=n;++i) mx=max(mx,sx[i]);
    vector<int> v;
    for(int i=1;i<=n;++i) if(mx==sx[i]) v.push_back(i);
    int my=0;
    for(int i=1;i<=m;++i) my=max(my,sy[i]);
    vector<int> v2;
    for(int i=1;i<=m;++i) if(my==sy[i]) v2.push_back(i);
    int ans=mx+my;
    if(1ll * v.size() * v2.size() > k) return cout<<ans<<endl,0;
    else {
        for(int i : v) {
            for(int j : v2) {
                if(!mp[get(i,j)]) return cout<<ans<<endl,0;
            }
        }
    }
    cout << ans-1 << endl;
}

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

#define ll long long
#define ar array

void solve() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
 
  int N;
  cin >> N;
  switch(N%10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << "\n";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << "\n";
      break;
    case 3:
      cout << "bon" << "\n";
      break;
    default:
      cout << "??" << "\n";
  }
}

Measured memory_bytes: 3660