akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1e9+7;

int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int T=-1,S=0;
    for(int w=0;100*w<=f;w+=a)
    for(int x=0;100*(w+x)<=f;x+=b)
    for(int y=0;100*(w+x)+y<=f;y+=c)
    for(int z=0;100*(x+w)+y+z<=f;z+=d){
        int s=y+z;
        int t=100*(w+x)+s;
        if(s<=(w+x)*e && t>0 && (T<0||S*t<s*T))S=s,T=t;
    }
    cout<<T<<' '<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <limits.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void NO() { cout << "NO" << endl; }
inline void Yes() { cout << "Yes" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

void init();
void bfs(int org, vector<int>& d);

int n;
Vi opt, dp;

int main()
{
	init();

	bfs(0, dp);

	cout << dp[n] << endl;
}

void init()
{
	cin >> n;

	dp.resize(n + 1, -1);

	opt.PB(1);
	for (int x = 6; x <= n; x *= 6)
		opt.PB(x);
	for (int x = 9; x <= n; x *= 9)
		opt.PB(x);

	sort(ALL(opt), greater<>());
}


void bfs(int org, vector<int>& d)
{
	d[org] = 0;
	queue<int> que;
	que.push(org);

	while (!que.empty())
	{
		int v = que.front();
		que.pop();

		for (int x : opt)
			if (v + x <= n)
				if (dp[v + x] == -1)
				{
					dp[v + x] = dp[v] + 1;
					que.push(v + x);
				}
	}
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin>>n;int x=n%10;
	if(x==2||x==4||x==5||x==7||x==9)
	cout<<"hon";
	else if(x==0||x==1||x==6||x==8)
	cout<<"pon";
	else cout<<"bon";
}

Measured memory_bytes: 3596
using DataStructures

const MOD = 10^9+7
pow2(x) = big(2)^x%MOD

function solve()
    N = parse(Int,readline())
    cnt = counter(Rational{Int})
    zero = 0
    for i in 1:N
        a, b = parse.(Int,split(readline()))
        (a==0 && b==0) ? zero+=1 : 
        (b==0) ? inc!(cnt,abs(a)//b) : inc!(cnt,a//b)
    end

    ans = 1
    for (r,c) in cnt
        inv = r==0//1 ? 1//0 : -1/r
        ans = mod(ans*(pow2(c)+pow2(cnt[inv])-1), MOD)
        reset!(cnt, inv)
    end
    ans = mod(ans+(zero-1)+MOD, MOD)
    println(ans)
end
solve()

Measured memory_bytes: 362692
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  vector<int> b(2);
  int i=0;
  while(a){
    b[i]=a%10;
    a=a/10;
    i++;
  }
  if(b[0]==9||b[1]==9){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    ll a, b;
    cin >> a >> b;
    if (a == b) {
        cout << 1 << endl;
        return 0;
    }
    ll ans;
    ll mask = 1LL << 62;
    while (true) {
        while ((mask & b) == 0) mask >>= 1;
        if (a & mask) {
            a -= mask;
            b -= mask;
        }
        else {
            ans = mask - a;
            break;
        }
    }

    pll p1(a, mask), p2(0, b - mask + 1);

    ll can_max = b - mask;
    ll mask2 = 1LL << 62;
    while (mask2 > 0 and (mask2 & can_max) == 0) {
        mask2 >>= 1;
    }
    p2 = pll(0, mask2 << 1);

    if (p1.first <= p2.second) {
        ans += mask;
        cout << ans << endl;
        return 0;
    }

    ans += mask - a;
    if (mask2 == 0) ans++;
    else ans += (mask2 << 1);

    cout << ans << endl;
}

Measured memory_bytes: 3664
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;} 
	 }
	 return 1;
}
int main()
{
	unsigned long long n;
	cin>>n;
	unsigned long long i=0,g=100;
	while(g<n){
		g+=g/100;
		//cout<<g<<endl;
		i++;
	}
	cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<string> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        sort(v[i].begin(), v[i].end());
    }

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

    int ans = 0;
    int cnt = 0;
    for(int i = 1; i < n; i++) {
        if(v[i] == v[i - 1]) {
            cnt++;
            ans += cnt;
        } else {
            cnt = 0;
        }
    }


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


Measured memory_bytes: 7296
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val a = readLine()!!.toCharArray()
    val changePoints = mutableListOf(0)
    (1 until n).forEach { if (a[it - 1] != a[it]) changePoints.add(it) }
    changePoints.add(n)
    var max = 0
    var lp = 0
    while (true) {
        val rp = lp + 2 * k - if (a[changePoints[lp]] == '0') 1 else 0
        if (rp >= changePoints.size - 1) {
            max = Math.max(changePoints.last() - changePoints[lp], max)
            break
        }
        max = Math.max(changePoints[rp + 1] - changePoints[lp], max)
        lp++
    }
    println(max)
}


Measured memory_bytes: 39700
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N;cin>>N;
  int ans=LINF;
  int j;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    for(j=0;a%2==0;j++)a/=2;
    ans=min(ans,j);
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  S.erase(std::unique(all(S)), S.end());
  cout << S.size() << endl;
}


Measured memory_bytes: 512
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
N, D = [int(x) for x in input().split()]
X = []
for _i in range(N):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(N):
    for j in range(i+1,N):
        dist2 = 0
        for x1, x2 in zip(X[i], X[j]):
            dist2 += (x1 - x2)**2
        if math.sqrt(dist2) == int(math.sqrt(dist2)):
            ans += 1
print(ans)



Measured memory_bytes: 3440
#include "bits/stdc++.h"
using namespace std;
#define dup(x,y) (((x)+(y)-1)/(y))//result of div + 1
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int N;
	double ans = 0;
	//int val = 0;
	cin >> N;
	vector<double> A(N);


	rep(i,N){
		cin >> A[i];}
	rep(i,N){
	    ans+=1/A[i];}

	ans=(1/ans);



	cout << ans <<setprecision(10)<< endl;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int k, w, h;
// string s;
Vs v;

void fall() {
    REP2(i, 1, h) REP(j, w) {
        if (v[i][j] == 'x') {
            RREP(x, i, 0) {
                if (x != 0) v[x][j] = v[x-1][j];
                else v[x][j] = 'x';
            }
        }
    }
}

void print() {
    REP(i, h) {
        REP(j, w) std::cout << v[i][j]<< ' ';
        std::cout << '\n';
    }
    std::cout << "/* message */" << '\n';
}

int calc() {
    int score = 0, times = 0;
    while (true) {
        fall();
        bool f = true;
        REP(i, h) {
            char x = v[i][0];
            int cnt = 1;
            REP2(j, 1, w) {
                if (x == v[i][j]) cnt++;
                else {
                    if (x != 'x' && cnt >= k) {
                        REP(t, cnt) v[i][j-t-1] = 'x';
                        score += cnt * (x - '0') * pow(2, times);
                        f = false;
                    }
                    x = v[i][j];
                    cnt = 1;
                }
            }
            if (x != 'x' && cnt >= k) {
                REP(t, cnt) v[i][w-t-1] = 'x';
                score += cnt * (x - '0') * pow(2, times);
                f = false;
            }
        }
        times++;
        if (f) break;
    }
    return score;
}

int run(int y, int x) {
    v[y][x] = 'x';
    int score = calc();
    return score;
}

int main() {
    cin >> h >> w >> k;
    v = Vs(h);
    REP(i, h) cin >> v[i];

    Vs v2(v);
    int maxi = 0;
    REP(i, h) REP(j, w) {
        maxi = max(maxi, run(i, j));
        v = v2;
    }
    std::cout << maxi << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}
int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  vector<int> l(n + 1, 0), r(n + 2, 0);
  for(int i = 1; i < n + 1; ++i)l[i] = gcd(v[i - 1], l[i - 1]); 
  for(int i = n; i > 0; --i) r[i]  = gcd(v[i - 1], r[i + 1]);
  int ans = 0;
  for(int i = 1; i < n + 1; ++i){
    ans = max(ans, gcd(l[i -1], r[i + 1]));
  }
  cout << ans << endl;
}

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

int n;
string s;
bool f = 1;

int main()
{	

	cin >> n >> s;

	if (n % 2 == 0) {
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[i + n / 2]) {
				f = 0;
				break;
			}
		}
	}
	else
		f = 0;

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

	return 0;
}

Measured memory_bytes: 764
import java.util.*;
public class Main {

	public void doIt(){
		final int MOD = 100000;
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		while(!(x == 0 && y == 0)){
			int [][][] list= new int[y+1][x+1][4];
			//初期値設定
			list[1][1][0] = 1;
			list[1][1][1] = 0;  //実質いらない
			list[1][1][2] = 1;
			list[1][1][3] = 0;  //実質いらない

			//表を埋める
			for(int i=1; i <= y; i++){
				for(int j=1; j <= x; j++){
					if(i == 1 && j == 1)
						continue;
					list[i][j][0] += list[i-1][j][3];
					list[i][j][1] += (list[i-1][j][0] + list[i-1][j][1]) % MOD;
					list[i][j][2] += list[i][j-1][1];
					list[i][j][3] += (list[i][j-1][2] + list[i][j-1][3]) % MOD;
				}
			}
			//合計を計算
			int sum = 0;
			for(int i=0; i < 4; i++){
				sum += list[y][x][i];
			}
			System.out.println(sum % MOD);

			x = sc.nextInt();
			y = sc.nextInt();
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

using namespace std;

int main() {
  uint64_t A, B, C;
  cin >> A >> B >> C;
  if (C <= A + B) {
    cout << "No" << endl;
    return 0;
  }

  int64_t left = 4LL * A * B;
  int64_t right = (C - A - B) * (C - A - B);

  if (left < right) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i = 0; i < strlen(str); i++) {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1 + (key%(M-1));}

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for(i = 0;;i++) {
    h = (h1(key) + i*h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for(i = 0;; i++) {
    h = (h1(key) + i*h2(key))%M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for(i = 0; i < M; i++) H[i][0] = '\0';
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s %s", com, str);

    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



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

int H, W;
char s[50][50];

int check(int x, int y){
  bool k=false;
  if(x>0 && s[x-1][y]==1){
    k=true;
    s[x-1][y]=0;
    check(x-1, y);
  }
  if(y<W && s[x][y+1]==1){
    k=true;
    s[x][y+1]=0;
    check(x, y+1);
  }
  if(x<H && s[x+1][y]==1){
    k=true;
    s[x+1][y]=0;
    check(x+1, y);
  }
  if(y>0 && s[x][y-1]==1){
    k=true;
    s[x][y-1]=0;
    check(x, y-1);
  }
  s[x][y]=-1;
  return k;
}

int main() {
  cin >> H >> W;
  
  for(int i=0 ; i<H ; i++){
    string str;
    cin >> str;
    for(int j=0 ; j<W ; j++){
      if(str[j]=='.')
        s[i][j]=-1;
      else
        s[i][j]=1;
    }
  }
  
  for(int i=0 ; i<H ;i++)
    for(int j=0 ; j<W ; j++)  
      if(s[i][j]==1)
        if(!check(i, j)){
          cout << "No" << endl;
          return 0;
        }
  cout << "Yes" << endl;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  
  ll ans = 0;
  for (ll b = k + 1; b <= n; b++) {
    ans += (n / b) * (b - k);
    if (k == 0) ans += n % b;
    else if (n % b >= k) ans += (n % b) - (k - 1);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
#define MOD 1000000007
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
using namespace std;
typedef long long LL;
using  P = pair<LL, LL>;

LL pw(LL x,LL y) {
	LL tmp = x;
	LL res = 1;
	while (y) {
		if (y%2) res = res*tmp%MOD;
		y >>= 1;
		tmp = tmp*tmp%MOD;
	}
	return res;
}

LL ans;
int n;
map<P,bool> vis;
map<P,int> mp;

int main()
{
	while (~scanf("%d", &n)) {
		mp.clear();
		vis.clear();

		REP(i,1,n) {
			LL a,b,g;
			scanf("%lld %lld", &a,&b);
			g = __gcd(abs(a), abs(b));
			if (g) {
				a /= g;
				b /= g;
			}

			if (a < 0) {
				a *= -1;
				b *= -1;
			}
			if (a==0 && b<0) {
				a *= -1;
				b *= -1;
			}
			mp[make_pair(a,b)]++;

			vis[make_pair(a,b)] = true;
			if (b <= 0) {
				vis[make_pair(-b,a)] = true;
			} else {
				vis[make_pair(b, -a)] = true;
			}
		}

		ans = 1;
		for (auto i: vis) if (i.first.first > 0 && i.first.second >= 0) {
			P tmp;
			tmp.first = i.first.second;
			tmp.second = i.first.first * -1;

			LL aa, bb;
			aa = mp[i.first];
			bb = mp[tmp];
			if (i.first.second == 0) {
				tmp.second *= -1;
				bb = mp[tmp];
			}
			ans *= (pw(2, aa) + pw(2, bb) - 1) % MOD;
			ans %= MOD;
		}

		ans = ans - 1 + mp[make_pair(0LL, 0LL)];
		ans = (ans%MOD+MOD) % MOD;
		printf("%lld\n", ans);
		
	}
  return 0;
}


Measured memory_bytes: 53572
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class BPowerSocket {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int a,b,c=1,d=0;
        in>>a>>b;
        while(c<b) c+=a-1,++d;
        out<<d<<endl;
    }
};

int main() {
    BPowerSocket solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())

if a>0:
    if a<=b:
        ans = b-a
    elif b>0:
        ans = 2 + a-b
    elif abs(b)<=a:
        ans = 1 + b + a
    else:
        ans = 1 - b - a
elif a<0:
    if b<a:
        ans = 2 + a-b
    elif b<=0:
        ans = b - a
    elif b < abs(a):
        ans = 1 - a - b
    else:
        ans = 1 + b + a
else:
    if b>0:
        ans = b
    elif b<0:
        ans = 1 - b
    else:
        ans = 0
        
print(ans)

Measured memory_bytes: 3064
import sys

a = input()
l = True

for i in range(len(a)):
    if i % 2 == 1:
        if a[i] == 'R':
            l = False

    if i % 2 == 0:
        if a[i] == 'L':
            l = False

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


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int X = 111111;
bool isp[X];
int x;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    fill(isp + 2, isp + X, true);
    rep(i, 2, X - 1) {
        if(isp[i]) {
            for(int j = 2 * i; j < X; j += i) {
                isp[j] = false;
            }
        }
    }
    cin >> x;
    while(!isp[x]) {
        x++;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in);) {
			int labels[] = new int[6];
			
			for(int i = 0; i < 6; i++) {
				labels[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			
			Dice dice = new Dice(labels);
			StringBuilder sb = new StringBuilder();
			
			int top;
			int sideS;
			for(int i = 0; i < q; i++) {
				top = sc.nextInt();
				sideS = sc.nextInt();
				
				int count = 0;
				while(dice.getSideS() != sideS) {
					if(count++ == 4) {
						dice.move("E");
					}
					dice.move("S");
				}
				while(dice.getTop() != top) {
					dice.move("E");
				}
				
				sb.append(dice.getSideE());
				sb.append("\n");
			}
			
			System.out.print(sb.toString());
		}
	}
}

class Dice {
	
	private int position[];
	
	Dice(int labels[]){
		this.position = labels;
	}
	
	void move(String order) {
		if(order.equals("N")) {
			position = new int[]{position[1], position[5], position[2], position[3], position[0], position[4]};
			return;
		}
		if(order.equals("E")) {
			position = new int[]{position[3], position[1], position[0], position[5], position[4], position[2]};
			return;
		}
		if(order.equals("S")) {
			position = new int[]{position[4], position[0], position[2], position[3], position[5], position[1]};
			return;
		}
		if(order.equals("W")) {
			position = new int[]{position[2], position[1], position[5], position[0], position[4], position[3]};
			return;
		}
	}
	
	int getTop() {
		return position[0];
	}
	
	int getSideS() {
		return position[1];
	}
	
	int getSideE() {
		return position[2];
	}
}


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> a) {
  bool o = false;
  rep(i, N) {
    if (a.at(i) % 2 != 0) {
      o = true;
      break;
    }
  }

  if (o)
    cout << "first" << endl;
  else
    cout << "second" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 4060
# C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report

# 比がa:bとなる合計最小の票分布はa,b
# 次にc:dになったとき、a<=cかつb<=dとなるようにc,dに同じ数をかける

import math

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a, b = TA[0]
c, d = a, b

for idx in range(1,N):
    c, d = TA[idx]
    multi = max((a+c-1)//c, (b+d-1)//d)
    c *= multi
    d *= multi
    a,b = c,d
    
print(c+d)

Measured memory_bytes: 3188
def pattern_100():
    pass


def pattern_200_110():
    pass


n, a, b, c = map(int, input().split())
abc = [a, b, c]
total = sum(abc)
operate_pattern = [[0, 1], [1, 2], [2, 0]]
s = []
for i in range(n):
    tmp = input()
    if tmp == 'AB':
        s.append(0)
    elif tmp == 'AC':
        s.append(2)
    else:
        s.append(1)
answer = []
flag = True
for i in range(n):
    op = operate_pattern[s[i]]
    if abc[op[0]] ==1 and abc[op[1]] ==1:
        if i==n-1:
            answer.append(op[0])
        else:
            if (s[i]+1)%3 ==s[i+1]:
                answer.append(op[1])
                abc[op[1]] +=1
                abc[op[0]] -=1
            else:
                answer.append(op[0])
                abc[op[0]] += 1
                abc[op[1]] -= 1
    elif abc[op[0]] == 0:
        if abc[op[1]] == 0:
            flag =False
            break
        else:
            answer.append(op[0])
            abc[op[0]] +=1
            abc[op[1]] -=1
    elif abc[op[1]] == 0:
        if abc[op[0]] == 0:
            flag =False
            break
        else:
            answer.append(op[1])
            abc[op[1]] +=1
            abc[op[0]] -=1
    else:
        if abc[op[0]] > abc[op[1]]:
            answer.append(op[1])
            abc[op[1]] +=1
            abc[op[0]] -=1
        else:
            answer.append(op[0])
            abc[op[0]] +=1
            abc[op[1]] -=1

if flag:
    print('Yes')
    for i in answer:
        if i == 0:
            print('A')
        elif i == 1:
            print('B')
        else:
            print('C')
else:
    print('No')

Measured memory_bytes: 82608
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def print_array(a):
    print(" ".join(map(str, a)))


def bubblesort(a, n):
    swap = 0
    flag = True
    while flag:
        flag = False
        for j in range(n - 1, 0, -1):
            if a[j] < a[j - 1]:
                (a[j], a[j - 1]) = (a[j - 1], a[j])
                swap += 1
                flag = True
    return (a, swap)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    (b, swap) = bubblesort(a, n)
    print_array(b)
    print(swap)

if __name__ == "__main__":
    main()

Measured memory_bytes: 7748
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if(a + b + c >= 22)
    	cout << "bust" << endl;
    else
    	cout << "win" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1; 

void Evolve(LL& l, LL& r, LL A) {
    l = ((l+(A-1)) / A) * A;
    r = (r/A)*A + (A-1);
    if (r < l) {
        cout << "-1" << "\n";
        exit(0);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int K;
    cin >> K;
    vector<LL> A(K);
    for (int i = 0; i < K; i++) cin >> A[i];
    LL l = 2;
    LL r = 2;
    for (int i = K-1; i >= 0; i--) Evolve(l, r, A[i]);
    cout << l << " " << r << "\n";
}



Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Main main = new Main();
		Restanrant[] re = new Restanrant[N];
		for (int i=0;i<N;i++) {
			Restanrant r = main.new Restanrant();
			r.S = sc.next();
			r.P = sc.nextInt();
			r.num = i+1;
			re[i] =r;
		}
		Arrays.sort(re);
		for(int i=0;i<N;i++) {
			System.out.println(re[i].num);
		}
	}

	public class Restanrant  implements Comparable<Restanrant> {
		String S ;
		int P;
		int num;
		@Override
		public int compareTo(Restanrant o) {
			if (this.S.equals(o.S)==false) {
				return this.S.compareTo(o.S);
			}
			if (this.P<o.P) {
				return 1;
			}
			if (this.P>o.P) {
				return -1;
			}
			return 0;
		}

	}
}

Measured memory_bytes: 20820
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>

using namespace std;

int main()
{
    int h=1,w=1;
    while(1){
        cin >> h >> w;
        if(h==0&&w==0){
            return 0;
        };
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if((i+j)%2==0){
                    cout << '#';

                }else{
                    cout << '.';

                }
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3036
int main(void) {
	int x, y, rest = 0, ans = 0 ,change;
	scanf("%d %d",&x,&y);
	if (x < y){
		change = x;
		x = y;
		y = change;
	
	}

	rest = x%y;
	
	while (1) {
		if (x == y) { ans = x; break; }
		ans = rest;
		rest = y%rest;
		
		if (rest == 0)break;
		y = ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1844
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (_a, x, _c) = get!(String, String, String);

    println!("A{}C", x.chars().next().unwrap());
}


Measured memory_bytes: 4352
limit = 1E18
n = int(input())
total = 1
# A string
line = str(input())

if line.startswith("0 ") or " 0" in line:
    print(0)
    exit()

for i in line.split():
    x = int(i)
    total *= x
    if total > limit:
        print(-1)
        exit()

print(-1 if total > limit else total)


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  bool ok = true;
  rep(i,n) {
    if (a[i]%2 == 1) continue;
    if (a[i]%3 != 0 && a[i]%5 != 0) ok = false;
  }
  if (ok) cout << "APPROVED";
  else cout << "DENIED";
  return 0;
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

void solve(){
  int n;
  cin >> n;
  ll ans = 0LL, x;
  ll prev = 0;
  for (int i = 0; i < n; i++){
    cin >> x;
    if (x == 0LL){
      prev = 0LL;
      continue;
    }
    //cerr << "PREV: " << prev << '\n';
    if (prev) {
      x--;
      ans++;
    }
    ans += x / 2LL;
    prev = x % 2LL;
    //cerr << "ANS: " << ans << '\n';
  }
  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 3616
def examB():
    N = I()
    bit = 0; yen = 0
    for _ in range(N):
        x, u = LSI()
        if u=="JPY":
            yen +=float(x)
        else:
            bit +=float(x)
    ans = bit*380000 + yen
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 3668
#include<iostream>

using namespace std;

int main()
{
  int L,A,B,C,D;
  cin>>L;
  cin>>A;
  cin>>B;
  cin>>C;
  cin>>D;

  int Japanese,Math;
  Japanese = A / C;
  if(A % C != 0){
    ++Japanese;
  }
  Math = B / D;
  if(B % D != 0){
    ++Math;
  }

  int ans;
  if(Japanese >= Math){
    ans = L - Japanese;
  }
  else{
    ans = L - Math;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3092
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	int n;
	int[] top;
	int[] bottom;
	int[][] dp;
	
	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			top = new int[n];
			bottom = new int[n];
			for (int i = 0; i < n; i++) {
				top[i] = sc.nextInt();
				bottom[i] = sc.nextInt();
			}
			dp = new int[n+1][n+1];
			int res = dp(0, n);
			System.out.println(res);
		}
	}

	// min cost of [a, b)
	int dp(int a, int b) {
		if (b - a <= 1) return 0;
		if (dp[a][b] != 0) return dp[a][b];
		int res = Integer.MAX_VALUE;
		for (int i = a+1; i < b; i++) {
			int here = dp(a, i) + dp(i, b);
			here += top[a] * bottom[i-1] * top[i] * bottom[b-1];
			res = Math.min(res, here);
		}
		return dp[a][b] = res;
	}
}

Measured memory_bytes: 21872
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, k, i, res, tab[100005], r;

int main() {
scanf("%d %d", &n, &k);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
res = INF;
for (i=0;i+k-1 < n;i++) {
	if (tab[i] >= 0) r = tab[i+k-1]; 
	else if (tab[i+k-1]<=0) r = -tab[i];
	else if (tab[i+k-1] <= -tab[i]) r = tab[i+k-1]*2-tab[i];
	else r = -tab[i] * 2 + tab[i+k-1];
	res = min(res, r);
}
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	int n, a[1010];
	cin >> n;
	for(int i=0; i<n; i++){
		a[i]=i+1;
	}
	ll ans=1;
	for(int i=2; i<=n; i++){
		int cnt=0;
		for(int j=0; j<n; j++){
			while(a[j]%i==0){
				a[j]/=i;
				cnt++;
			}
		}
		ans=(ans*(cnt+1))%MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>

using namespace std;
typedef long long ll;



int main(void) {
	int h, n; cin >> h >> n;
	int a = 0;
	rep(i, n) {
		int x; cin >> x;
		a += x;
	}
	if (a < h) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

a,b,c,k = mp()
if k >= a:
    ans = k - (k-a)
    k -= a
    if k >= b:
        k -= b
        ans -= k
    print(ans)
else:
    print(k)

    

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

int main(int, char**) {
  string s;
  cin >> s;

  for (char c : s) {
    if (!isalpha(c)) {
      cout << "WA" << endl;
      return 0;
    }
  }

  if (s.size() == 4) {
    if (s[0] != 'A' || isupper(s[3])) {
      cout << "WA" << endl;
      return 0;
    } else if ((s[1] != 'C' && s[2] != 'C') || (s[1] == 'C' && s[2] == 'C')) {
      cout << "WA" << endl;
      return 0;
    }
    cout << "AC" << endl;
    return 0;
  }

  if (s[0] != 'A' || isupper(s[1])) {
    cout << "WA" << endl;
    return 0;
  }

  int c_count = 0;
  for (int i = 2; i < s.size() - 1; ++i) {
    if (s[i] == 'C') {
      c_count++;
      if (c_count > 1) {
        cout << "WA" << endl;
        return 0;
      }
      continue;
    }

    if (isupper(s[i])) {
      cout << "WA" << endl;
      return 0;
    }
  }

  if (c_count == 0) {
    cout << "WA" << endl;
    return 0;
  }

  for (int i = s.size() - 1; i < s.size(); i++) {
    if (isupper(s[i])) {
      cout << "WA" << endl;
      return 0;
    }
  }

  cout << "AC" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

static const ll max_n = 1000010;

vector<ll> primes(max_n);
vector<bool> is_prime(max_n, true);

ll sieve(ll N){
    // fill(is_prime.begin(), is_prime.end(), true);
    is_prime[0] = false;
    is_prime[1] = false;
    ll num_p=0;
    for(ll i=2;i<N;i++){
        if(is_prime[i]){
            primes[num_p++] = i;
            for(ll j=2*i;j<N;j+=i){
                is_prime[j] = false;
            }
        }
    }
    return num_p;
}

void Main(){
    ll N, a;
    sll(N);
    vector<ll> as(N,0);
    map<ll, ll> counter;
    bool has_one = false;
    rep(i, N){
        sll(a);
        as[i] = a;
        has_one = has_one || (a == 1);
        ++counter[a];
    }

    sort(as.begin(), as.end());
    // sieve;
    ll one_num = counter[1];
    if(one_num==1){
        cout << "1" <<endl;
        return;
    }else if(one_num>1){
        cout << "0" <<endl;
        return;
    }
    ll num_p = 0;
    for(ll i=one_num;i<N;i++){
        // printf("i=%lld a=%lld\n", i, as[i]);
        a = as[i];
        if(is_prime[a]){
            primes[num_p++] = a;
            for(ll j=a;j<=max_n;j+=a){
                is_prime[j] = false;
            }
        }
    }

    // cout << counter <<endl;
    // cout << primes[0] << " " <<primes[1] << " "<<primes[2] <<endl;

    ll dup = 0;
    rep(i, num_p){
        // printf("primes %lld=%lld\n", i, primes[i]);
        if(counter[primes[i]]>1){
            ++ dup;
        }
    }

    // cout << "num p = " << num_p << " dup:" <<dup <<endl;
    cout << num_p - dup <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 24668
#include<iostream>
#include<cstring>
#define maxn 10000
using namespace std;

int bcj[maxn + 100], n, m;

int Find(int x){
	if(bcj[x] < 0)
		return x;
	return bcj[x] = Find(bcj[x]);
}

void Union(int x, int y){
	x = Find(x);
	y = Find(y);
	if(x == y)
		return;
	bcj[x] += bcj[y];
	bcj[y] = x;
}

int main(){
	cin >> n >> m;
	int choice, x, y;
	memset(bcj, -1, sizeof(bcj));
	for(int i = 0; i < m; i++){
		cin >> choice >> x >> y;
		if(choice == 0){
			Union(x, y);
		}
		else{	
			cout << (Find(x) == Find(y)) << endl;
		}
	}
	return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int sx=Integer.parseInt(str[0]);
        int sy=Integer.parseInt(str[1]);
        
        int tx=Integer.parseInt(str[2]);
        int ty=Integer.parseInt(str[3]);
        
        StringBuilder sb=new StringBuilder();
        
        if(sx>0){
            tx-=sx;
        }else if(sx<0){
            tx+=Math.abs(sx);
        }
        sx=0;
        
        if(sy>0){
            ty-=sy;
        }else if(sy<0){
            ty+=Math.abs(sy);
        }
        sy=0;
        
        for(int i=0;i<ty;i++){
            sb.append("U");
        }
        
        for(int i=0;i<tx;i++){
            sb.append("R");
        }
        
         for(int i=0;i<ty;i++){
            sb.append("D");
        }
        
        for(int i=0;i<tx;i++){
            sb.append("L");
        }
        
        sb.append("L");
        
        for(int i=0;i<=ty;i++){
            sb.append("U");
        }
        
          for(int i=0;i<=tx;i++){
            sb.append("R");
        }
        
        sb.append("DR");
        
          for(int i=0;i<=ty;i++){
            sb.append("D");
        }
        
          for(int i=0;i<=tx;i++){
            sb.append("L");
        }
        sb.append("U\n");
        
        System.out.println(sb);
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N,K; cin>>N>>K;
  vi A(N);
  rep(i,0,N){
    cin>>A[i];
    }
  sort(ALL(A));
  int ans=-1;
  int sum=0;
  rep(i,0,N){
    sum+=A[i];
    if(sum>K){
      ans=i;
      break;
      }
    }
  if(ans==-1)
    ans=N-1;
  if(sum==K)
    ans++;
  cout<<ans<<endl;
  }


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

int main(){
    int n,m; cin>>n>>m;
    priority_queue<int> q;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        q.push(a);
    }
    long long ans=0;
    while(!q.empty()){
        int t=q.top();
        q.pop();
        if(m>0){
            m--;
            q.push(t/2);
        }else{
            ans+=t;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892