akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(lint i = s; i < (lint)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main() {
  lint N,M,A,B,cnt = 0;
  cin >> N >> M;
  vector<lint> H(N),ans(N);
  rep(i,0,N){
    cin >> H[i];
    ans[i] = H[i];
  }
  
  rep(i,0,M){
    cin >> A >> B;
    if(H[A-1] == H[B-1]){ans[A-1] = 0; ans[B-1] = 0;}
    else if(H[A-1] > H[B-1]){ans[B-1] = 0;}
    else{ans[A-1] = 0;}
  }
  rep(i,0,ans.size()){
    if(ans[i] != 0){cnt++;}
  }
  co(cnt);
}

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

int main()
{
  int a,b,c,d;	cin >> a >> b >> c >>d;
  int l = a+b;
  int r = c+d;
  if (l>r)   cout << "Left" << endl ;
  else if (l<r)  cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define exact(x) { return (x); }

#define sum(v) accumulate(all(v), 0)
#define stlice(s, l) substr(s, (s) + (l) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1e9
#define MOD (1e9 + 7)

#define pb push_back
#define mt make_tuple
#define fi first
#define se second
#define str string
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<str>

using namespace std;

// clang-format on

main {
  int n, c, k;
  cin >> n >> c >> k;
  vi t(n);
  rep(i, n) cin >> t[i];
  sort(all(t));
  int wm = 0, b = 0, rm = 0;
  rep(i, n) {
    if (i == 0 || t[i] - wm > k || rm == 0) {
      wm = t[i];
      rm = c - 1;
      b++;
    } else {
      rm--;
    }
  }
  cout << b << endl;
  bye;
}


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

int main() {
    int X, N;
    cin >> X >> N;
    if (N == 0) {
        cout << X;
    }
    else {
        vector<int>p(N);
        for (int i = 0; i < N; i++) {
            cin >> p.at(i);
        }
        sort(p.begin(), p.end()); 
        bool check = false;
        int num = 0;
        for (int i = 0; i < N; i++) {
            if (p.at(i) == X) {
                check = true;
                num = i;
                break;
            }
        }
        if (!check) {
            cout << X;
        }
        else {
            if (num == 0) {
                cout << X - 1;
            }
            else if (num == N-1) {
                if (p.at(N-1) - p.at(N-2) > 1) {
                    cout << X - 1;
                }
                else {
                    cout << X + 1;
                }
            }
            else {
                int small = p.at(0) - 1, large = p.at(N-1) + 1;
                for (int i = num; i > 0; i--) {
                    if (p.at(i) - p.at(i-1) > 1) {
                        small = p.at(i) - 1;
                        break;
                    }
                }
                for (int i = num; i < N-1; i++) {
                    if (p.at(i+1) - p.at(i) > 1) {
                        large = p.at(i) + 1;
                        break;
                    }
                }
                if (large - X < X - small) {
                    cout << large;
                }
                else {
                    cout << small;
                }
            }
        }
    }
}

Measured memory_bytes: 3636
n,m = map(int,input().split())
A = [int(input()) for _ in range(n)]
V = [0 for _ in range(n)]
for i in range(m):
  b = int(input())
  for j in range(n):
    if A[j] <= b:
      V[j] += 1
      break

print(V.index(max(V)) + 1)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
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;
  }
}
// combination
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;
}
*******************************************************/
/********** UnionFind ***************
struct UnionFInd {
vector<ll> par;
UnionFInd(ll N) : par(N) {
for (ll i = 0; i < N; i++) {
par[i] = i;
}
}
ll root(ll x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
if (rx == ry) return;
par[rx] = par[ry];
}
bool same(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
return rx == ry;
}
};
*************************************/
/***********************************
ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }

  ll r = a % b;
  while (r > 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
***********************************/
const ll INF = 10000000000;
int main(int argc, char *argv[])
{
    // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    ll v, e, r;
    cin >> v >> e >> r;

    vector<vector<pair<ll, ll>>> graph(v, vector<pair<ll, ll>>());
    for (int i = 0; i < e; i++)
    {
      ll s, t, d;
      cin >> s >> t >> d;
      graph[s].push_back(make_pair(t, d));
      // graph[t].push_back(make_pair(s, d));
    }

    vector<ll> ans(v, INF);
    ans[r] = 0;
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> q;
    q.push(pair<ll,ll>(0, r));

    while(!q.empty()){
      auto p = q.top();
      q.pop();
      ll now = p.second;
      ll cost = p.first;

      if(ans[now] < cost)
        continue;

      for (int i = 0; i < graph[now].size(); i++){
        if(ans[graph[now][i].first] > graph[now][i].second + cost){
          ans[graph[now][i].first] = graph[now][i].second + cost;
          q.push(pair<ll,ll>(ans[graph[now][i].first], graph[now][i].first));
        }
      }
    }
    REP(i, v){
      if(ans[i] == INF){
        cout << "INF" << endl;
        continue;
      }
      cout << ans[i] << endl;
    }
}


Measured memory_bytes: 19388
#include <stdio.h>
#include <math.h>

int primecheck(int n){
    int i;
    
    if(n==0||n==1)return 0;
    //if(n==2||n==3)return 1;
    
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0)return 0;
    }
    return 1;
}
//1???????´???°???0??????????´???°???

int main(void){
    int i,n,cnt,sum;
    
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        
        for(i=sum=cnt=0;cnt<n;i++){
            if(primecheck(i)==1){
                cnt++;
                sum+=i;
            }
        }
        printf("%d\n",sum);
    }
    
    return 0;
}

Measured memory_bytes: 596
def main():
    n = int(input())
    s, t = map(list, input().split())

    ans = []
    for i in range(n):
        ans.append(s[i])
        ans.append(t[i])

    ans_s = ''.join(ans)
    print(ans_s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
 
int main(){
 
int a,b;
 
cin >> a>>b;
 
if(a>b) cout<<"a > b"<<endl;
else if(a<b) cout<<"a < b"<<endl;
else cout<<"a == b"<<endl;
 
 
return 0;
 
}


Measured memory_bytes: 3104
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans;
  int m = -1;
  rep(i, n){
    int j = i+1;
    int tmp = 0;
    while(j%2 == 0){
      tmp++;
      j/=2;
    }
    if(tmp >= m){
      ans = i+1;
      m = tmp;
    }
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[111],sum,c[111];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	int mn=1e9;
	for(int i=0;i<n;i++)
	{
		int x=a[i]*n;
		c[i]=abs(sum-x);
		mn=min(mn,c[i]);
	}
	for(int i=0;i<n;i++)
	{
		if(c[i]==mn)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
(defun main (a b)
  (let ((rst "")
        (astri (make-string b :initial-element (aref (write-to-string a) 0)))
        (bstri (make-string a :initial-element (aref (write-to-string b) 0))))
    (if (<= a b)
        (setf rst astri)
      (setf rst bstri))
    rst))

(format t "~A~%" (main (read) (read)))


Measured memory_bytes: 17376
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	const long long int kuni = 10000000000;
	long long int w,h,n,a[500000],x[500000],y[500000],left=0,right,up,down=0;
	cin >> w>>h>>n;
	right = w;
	up = h;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> a[i];
		if (a[i] == 1&&x[i]>left) { left = x[i]; }

		if (a[i] == 2&&x[i]<right) { right = x[i]; }
		if (a[i] == 3&&y[i]>down) { down = y[i]; }
		if (a[i] == 4&&y[i]<up) { up = y[i]; }
	}
	if ((right - left)<0||(up - down) < 0) { cout << 0; return 0; }
	cout << (right - left)*(up - down);
}


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

int main() {
  int n, cnt;
  vector<int> nums;
  auto insertionSort = [&nums, &n, &cnt](int d) {
    for(int i = d; i < n; ++i) {
      int top = nums[i];
      int j;
      for(j = i - d; j >= 0 && nums[j] > top; j -= d) {
        nums[j + d] = nums[j];
        ++cnt;
      }
      nums[j + d] = top;
    }
  };
  auto shellSort = [&nums, &n, insertionSort]() {
    int maxid = log(2 * n + 1) / log(3) - 1;
    cout << maxid + 1 << endl;
    for(int id = maxid; id >= 0; --id) {
      unsigned int d = (pow(3, id + 1) - 1) / 2;
      cout << d << (id == 0 ? "\n" : " ");
      insertionSort(d);
    }
  };
  cin >> n;
  nums = vector<int>(n);
  for(int& c: nums) cin >> c;
  cnt = 0;
  shellSort();
  cout << cnt << endl;
  for(auto&& c: nums) cout << c << endl;
  return 0;
}

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

int main() {

	int a,b,c,d;
	int left,right;

	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;

	left	= a + b;
	right	= c + d;

	if(left > right){
		cout << "Left" << endl;
	}else if (left < right)
	{
		cout << "Right" << endl;
	}else{
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
#define ll long long
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s[1] == 'B') {
        cout << "ARC";
    } else {
        cout << "ABC";
        
    }
}

Measured memory_bytes: 3568
#include <iostream>

/*某国に住んでいる友達がお金に困って、あるヤミ金融業者から
10 万円の借金をしたまま、全く返済していないといいます。
この業者は、一週間ごとに 5% の利子を借金に加え、
さらに借金の 1,000 円未満を切り上げます。*/

/*整数 n を入力し、n 週間後の借金の残高を出力するプログラムを作成して下さい。*/

int addInteresOfTheDebt(int);

int main(){
	int n;  //入力される整数
	int money = 100000;  //元金
	std::cin >> n;

	for (int i = 0; i < n; i++)
	{
		money = addInteresOfTheDebt(money);
	}

	std::cout << money  << std::endl;
}

//借金に利子を加算する関数
//加算後、借金の1000未満を切り上げる
//入力：現在の借金
//出力：利子加算後の借金
int addInteresOfTheDebt(int money){
	money = money * 1.05;
	if (money % 1000 != 0){
		money =  money - (money % 1000) + 1000;
	}
	return money;
}


Measured memory_bytes: 3048
length = int(input())
raw_list = input().split()
for i in range(length):
	raw_list[i] = int(raw_list[i])
for i in range(length):
	key = raw_list[i]
	j = i - 1
	while j >= 0 and raw_list[j] > key:
		raw_list[j+1] = raw_list[j]
		j -= 1
	raw_list[j+1] = key
	for k in range(length):
		if k-length+1:
			print(raw_list[k], end=' ')
		else:
			print(raw_list[k])


Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
const int  maxi=1e5;
 bool vis[maxi];
  vector<int>adj[maxi],ans;
void dfs(int u)
{
  vis[u]=1;
  for(int v:adj[u])
  {
    if(!vis[v])
      dfs(v);
  }
}

int main()
{
  ll n,m;
  cin>>n>>m;
 
  for(int i=0,a,b;i<m;++i)
  {
    cin>>a>>b,--a,--b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  for(int i=0;i<n;++i)
  {
    if(!vis[i])
    {
      ans.push_back(i);
      dfs(i);
    }
  }
  cout<<ans.size()-1<<endl;
  return 0;
}

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

int main(){
	/*input*/
	int d, n;	cin >> d >> n;
	/*calculation*/
	int ans = 0;
	if(n < 100){
		ans += n*pow(100, d);
	}else{
		ans += 101*pow(100, d);
	}
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var abc=arr.shift();
   if(abc=="0 0 0 0 0")break;
   var ary=(abc+" "+arr.shift()).split(" ").map(Number);
   (function(a,b,c,d,e,na,nb,nc){
      var A,B;
      var amari=nc%d;
      A=na*a+nb*b+Math.floor(nc/d)*d*e+amari*c;
      if(nc>=d)B=na*a+nb*b+nc*e;
      if(nc<d){
         var husoku=d-amari;
         while(husoku--){
            if(nb>0)nb--;
            else if(na>0)na--;
         }
         B=na*a+nb*b+d*e;
      }
      console.log(Math.min(A,B));
   }).apply(null,ary);
}

Measured memory_bytes: 17220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
  int A,B;
  cin >> A >> B;
  bool flag = true;
  int i = 1;
  while(flag){
    int a = i*0.08;
    int b = i*0.1;
    if(a == A && b == B){
      cout << i << endl;
      break;
    }
    else if(a > A && b > B){
      cout << -1 << endl;
      break;
    }
    i++;
  }
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 200005;

int val[N],ans[N];
vector<int> a[N];
multiset<int> lis;

void dfs(int c,int p)
{
    lis.insert(val[c]);
    auto it = lis.lower_bound(val[c]);it++;
    int del = -1;
    if(it!=lis.end())
    {
        del = *it;
        lis.erase(it);
    }
    ans[c] = lis.size();
    for(auto ne:a[c])
    {
        if(ne!=p)dfs(ne,c);
    }
    lis.erase(val[c]);
    if(del != -1)lis.insert(del);
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;

    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)cin>>val[i];
        for(int i=1;i<n;i++)
        {
            int x,y;
            cin>>x>>y;
            a[x].pb(y);
            a[y].pb(x);
        }
        dfs(1,0);
        for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 29660
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define lint long long
#define trace(x) cout << #x << " = " << x << '\n'
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, M, K, Q, x, y, z;
lint mod(lint n) { return (n%MOD + MOD)%MOD; }
lint kali(lint a, lint b, lint c = 1, lint d = 1) { return mod(mod(a*b)*mod(c*d)); }

lint N, ans;

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%lld", &N);
	lint sbls = N/11;
	lint sisa = N-11*sbls;
	if (sisa) ans = (sisa <= 6? 1: 2)+2*sbls;
	else ans = 2*sbls;
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;
const int NMAX = 10000;

void PrintArray(int* A, int N)
{
   cout << A[0]; 
   for (int k = 1; k < N;k++) {
     cout << " " << A[k] ; 
   }
   cout << endl;
}
void Swap(int& a, int &b) {
  int tmpA, tmpB;
  tmpA = a;
  tmpB = b;
  a = tmpB;
  b = tmpA;
}

int selectionSort(int* A, int N){
  int count = 0;
  for (int i = 0; i < N - 1; i++){
    int minj = i;
    for (int j = i+1; j < N; j++) {
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    Swap(A[i], A[minj]);
    if (i != minj) { 
      count += 1;
    }
  }
  return count;
} 


int main()
{
  int A[10];
  for (int i = 0; i< 10; i++) {
    int x; 
    cin >> x; 
    A[i] = x;
  } 
  selectionSort(A,10);
  for (int i = 0; i< 3; i++) {
    cout << A[9 -i] << endl; 
  } 
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void swap2(double* a, double* b)
{
	double tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}


int main()
{
	int A, B,C, N, M;

	scanf("%d%d%d", &A,&B,&C);

	if (A == B && A != C)
		printf("Yes");
	else if (B == C && B != A)
		printf("Yes");
	else if (A == C && A != B)
		printf("Yes");
	else 
		printf("No");
}

Measured memory_bytes: 760
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll K = 0;
	ll Y = 0;
	ll X = 0;
	ll m[100000] = {};
	ll p[100] = {};
	ll x[100] = {};
	//ll *x, *c, *d;
	string S;
	ll count = 0;
	ll sum = 0;
	ll min = 1;
	ll i = 0;
	//char p;
	cin >> N;
	
	rep(i, 0, N+0) {
		cin >> m[i];
		count += m[i];
	}
	
	if (N % 2 == 0) {
		
		for (int i = N - 1; i > 0; i = i - 2) {
			sum += i * 2;
		}

	}
	else {
		for (int i = N - 1; i > 0; i = i - 2) {
			sum += i * 2;
		}
	}
	
	if (sum == count) {

		//min = pow(2, (N / 2));

	for (int i = 0; i < N / 2; i++) {
		min *= 2;
		min %= huge;
	}


		cout <<  min%huge  << endl;
	}
	else {
		cout << 0 << endl;
	}

	
	return 0;

}



Measured memory_bytes: 1024
#include <stdio.h>

int try(long n, long div){
	return (n % div) ? (n % div == 1) : try(n/div, div);
}

int main(void){
	long n;
	int count = 0;

	scanf("%ld", &n);

	if(n > 1e5) {
		for(long i=1; i*i <= n; i++) {
			if((n-1) % i == 0) {
				count++;
				if(i != (n-1) / i)
					count++;
			}
			if(n % i == 0) {
				if(i != 1 && try(n, i))
					count++;
				if(i != n / i && try(n, n/i))
					count++;
			}
		}
		count--;
	}else{
		for(int i=2; i <= n; i++) {
			if(try(n, i))
				count++;
		}
	}
	printf("%d", count);

	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n;
    cin >> n;

    cout << n/3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
long long f[200001];
long long fac[200001];
long long r[200001];
typedef struct point
{
	int x,y;
	bool operator < (const struct point & t)const
	{
		return x==t.x?y<t.y:x<t.x;
	}
}POINT,*PPOINT;
POINT p[200002];
void init(int h,int w)
{
	fac[0]=fac[1]=r[1]=r[0]=1;
	//printf("1");
	int i;
	for(i=2;i<=h+w-2;i++)
	{
		fac[i]=fac[i-1]*i%MOD;
		r[i]=(long long)(MOD-MOD/i)*r[MOD%i]%MOD;
		//printf("  %d %d %d\n",i,fac[i],r[i]);
	}	
	for(i=2;i<=h+w-2;i++)
		r[i]=r[i-1]*r[i]%MOD;
}
long long mycomb(int n,int m)
{
	return fac[n]*r[n-m]%MOD*r[m]%MOD;
}
int main()
{
	int i,j,n,w,h;
	scanf("%d %d %d",&h,&w,&n);
	for(i=0;i<n;i++)
		scanf("%d %d",&p[i].x,&p[i].y);
	p[n].x=h;
	p[n].y=w;
	sort(p,p+n+1);
	init(h,w);
	for(i=0;i<=n;i++)
	{
		f[i]=mycomb(p[i].x+p[i].y-2,p[i].x-1);
		for(j=0;j<i;j++)
		{
			f[i]=f[i]-f[j]*mycomb(p[i].x-p[j].x-p[j].y+p[i].y,p[i].x-p[j].x)%MOD;
	//((long long)f[i]+MOD-(long long)f[j]*fac[p[i].x-p[j].x-p[j].y+p[i].y]%MOD*r[p[i].x-p[j].x]*r[p[i].y-p[j].y]%MOD)%MOD;
		}
		f[i]=(f[i]+MOD)%MOD;
	}
	printf("%lld\n",(f[n]+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 4864
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc113_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int[] height = ReadLine().Split().Select(int.Parse).ToArray();

            int cnt = 0;
            double min = int.MaxValue;
            for (int i = 0; i < height.Length; i++)
            {
                var tmp = Abs(input[0]-0.006*height[i]-input[1]);
                if(tmp<min){
                    min = tmp;
                    cnt = i;
                }
            }

            WriteLine(cnt+1);
            //WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);
            //WriteLine($"答えは{input[0]+input[1]}");
        }
    }
}

Measured memory_bytes: 13340
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jul  5 21:21:15 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::map<std::string, Int> mp;
    REP(i, n) {
        std::string s;
        std::cin >> s;
        mp[s]++;
    }
    for (std::string s : {"AC", "WA", "TLE", "RE"}) {
        std::cout << s << " x " << mp[s] << "\n";
    }
}


Measured memory_bytes: 3664
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	hasTreat := make(map[int]struct{})
	var d int
	var a int
	for i := 0; i < k; i++ {
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			fmt.Scan(&a)
			hasTreat[a] = struct{}{}
		}
	}
	fmt.Println(n - len(hasTreat))
}


Measured memory_bytes: 2356
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

int n;
ar<int,2> adj[N];

int main(){
    AC
    cin>>n;
    for(int i=0; i<n-1; i++){
        int a,b;
        cin>>a>>b;
        adj[i][0]=a;
        adj[i][1]=b;
    }

    ll ans = 0;
    for(int i=1; i<=n; i++){
        ans+=(ll)i*(n-i+1);
    }

    for(int i=0; i<n-1; i++){
        if(adj[i][0]>adj[i][1])
            swap(adj[i][0],adj[i][1]);
        ans-=(ll)adj[i][0]*(n-adj[i][1]+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5180
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll x, y;cin >> x >> y;
	REP(i, 101){
		REP(j, 101){
			if(i + j != x)continue;
			if(2 * i + 4 * j != y)continue;
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-9)
#define INF (1e9 + 1)
#define PI (acos(-1))

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	ll c = (b / gcd(a, b));
	return c * a;
}

int N;
string S[100010];
int flg[100];
int SGS[1000010];

int bekijo(int a, int b) {
	int tmp = 1;
	REP(i, a) tmp *= b;
	return tmp;
}

int main() {
	int C[3] = { 3, 5, 7 };
	cin >> N;
	int l = 0;
	for (int k = 3; k <= 9; k++) {
		for (int i = 0; i < bekijo(k, 3); i++) {
			int tmp = i;
			int sum = 0;
			REP(j, k) {
				flg[j] = tmp % 3;
				tmp /= 3;
				sum += C[flg[j]] * bekijo(j, 10);
			}
			SGS[l++] = sum;
		}
	}

//	REP(i, bekijo(9, 3)) cout << SGS[i] << endl;

	int i = 0, ans = 0;
	bool check[3] = {};
	while (SGS[i] <= N && i != l) {
		string T = to_string(SGS[i]);
		REP(j, 3) check[j] = false;
		REP(j, (int)T.length()) {
			check[(T[j] - '0') / 2 - 1] = true;
		}
		if (check[0] && check[1] && check[2]) {
//			cout << SGS[i] << endl;
			ans++;
		}
		i++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
const int mod = 1e9 + 7;


signed main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n) cin >> a[i];
    for(int i = 0; i < n; i++){
        int now = n - 1 - i;
        int tmp = i / 2;
        if(i % 2){
            b[n - 1 - tmp] = a[now];
        }else{
            b[tmp] = a[now];
        }
    }
    rep(i, 0, n){
        cout << b[i];
        if(i != n - 1) cout << " ";
    }
    cout << endl;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << end
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll prime_count(ll n){
    map<ll,ll> mp;
    ll res = 1;
    ll x = n;
    for(ll i=2;i*i<=n;i++){
        while(n%i == 0){
            n/=i;
            mp[i]++;
        }
    }
    if(n != 1)mp[n]++;
    for(auto a:mp) res*=a.second+1;
    return res-1;//約数の個数から1を引く
}
ll factor_count(ll n){
    vector<ll> a;
    ll res = 0;
    for(ll i=2;i*i<=n;i++){
        if (n % i == 0) {
            a.push_back(i);
            ll j = n / i;
            if (j != i) a.push_back(j);
        }
    }
    //debug(a);
    for(auto b:a){
        ll N = n;
        while(N % b == 0) N/=b;
        if(N%b==1)res++;
    }
    return res;
}
signed main()
{   
    gearup;
    ll n; cin >> n;
    //まずk=n-1の素因数を求める
    //素数なら一個
    ll res = prime_count(n-1);
    res += factor_count(n);
    cout << res+1 << endl;
}


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

int main() {

	int labor_task[3];
	int cost_task[2];
	int answer = 0;

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

	sort(labor_task, labor_task + 3);

	for (int i = 0; i < 2; i++) {
		cost_task[i] = abs(labor_task[i + 1] - labor_task[i]);
		answer += cost_task[i];
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<tuple<string,int,int>>a;
  for(int i=1;i<=n;++i){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout<<get<2>(a[i])<<endl;
  }

  
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,a;
    cin>>n>>a;
    if(n<500)
    {
        if(a>=n)
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
            
        }
    }
    else
    {
        n=n%500;
        if(n<=a)
        cout<<"Yes\n";
        else
        cout<<"No\n";
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0 ; i<s.size()/2; i++){
        if(s[i]!=s[s.size()-i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  const int MOD = 998244353;
  int n; cin >> n;
  map<int,int> mp;
  vi d(n);
  int mx = 0;
  rep(i,n){
    cin >> d[i];
    mp[d[i]]++;
    chmax(mx,d[i]);
  }
  if(mp[0]!=1 || d[0]!=0){
    cout << 0;
    return 0;
  }
  ll ans = 1;
  for(int i = 1; i <= mx; i++){
    // ll res = (ll)pow(mp[i-1],mp[i]);
    ll res = 1;
    rep(j,mp[i]){
      res *= mp[i-1];
      res %= MOD;
    }
    ans *= res;
    ans %= MOD;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 8216
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n;
vector<vector<ll>> dp(100005,vector<ll>(3,0));
//long long dp[100010][3];
int main(){
    cin>>n;
    vector<vector<ll>> a(n,vector<ll>(3));
    rep(i,n) rep(j,3) cin>>a[i][j];
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(j==k) continue;
                chmax(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }
    ll res=0;
    rep(i,3) chmax(res,dp[n][i]);
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 14356
#include <iostream>
#include <cstdlib>

using namespace std;

// change minimumのこと
// a>bならばaにbを代入し、trueを返す
// 他の場合はfalseを返す
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;
}

const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  int h[n];
  long long dp[n];
  for(int i = 0; i < n; i++) {
    cin >> h[i];
    dp[i] = INF; 
  }
  dp[0] = 0;
  for(int i = 1; i < n; i++) {
    chmin(dp[i],dp[i-1] + abs(h[i]-h[i-1]));
    if(i > 1) {
      chmin(dp[i],dp[i-2] + abs(h[i]-h[i-2]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define DEBUG if(1)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxK = 5000; int k, q;
lli d[maxK], n, x, m;
lli acc[maxK + 1];

int main()
{
  while (scanf("%d %d", &k, &q) != EOF)
  {
    for (int i = 0; i < k; i ++)
      scanf("%lld", &d[i]);

    while (q --)
    {
      scanf("%lld %lld %lld", &n, &x, &m);

      for (int i = 0; i < k; i++)
        acc[i + 1] = acc[i] + (d[i] % m == 0 ? m : d[i] % m);
      lli s = (x % m) + acc[k]*((n - 1) / k) + acc[(n - 1) % k];
      lli ans = n - 1 - s / m;
      printf("%lld\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  int H, W, N;
  cin >> H >> W >> N;
  int sr, sc;
  cin >> sr >> sc;
  --sr; --sc;
  string S, T;
  cin >> S;
  cin >> T;

  // At first, check left-right.
  int left = 0, right = W-1;  // If piece is in [left, right] before the step, it is ok.
  if (S[N-1] == 'L') { ++left; }  // shrink
  if (S[N-1] == 'R') { --right; } // shrink
  // W >= 2, so it is ok here.
  for (int i = N - 2; i >= 0; --i) {
    if (T[i] == 'L') { right = min(right + 1, W-1); } // expand
    if (T[i] == 'R') { left = max(left - 1, 0); }   // expand
    if (S[i] == 'L') { ++left; }                    // shrink
    if (S[i] == 'R') { --right; }                   // shrink
    if (left > right) { // Bad
      cout << "NO" << endl;
      return 0;
    }
  }
  if (sc < left || right < sc) { // Bad
    cout << "NO" << endl;
    return 0;
  }

  // Next, check up-down.
  int up = 0, down = H-1;  // If piece is in [up, down] before the step, it is ok.
  if (S[N-1] == 'U') { ++up; }   // shrink
  if (S[N-1] == 'D') { --down; } // shrink
  // W >= 2, so it is ok here.
  for (int i = N - 2; i >= 0; --i) {
    if (T[i] == 'U') { down = min(down + 1, H-1); } // expand
    if (T[i] == 'D') { up = max(up - 1, 0); }     // expand
    if (S[i] == 'U') { ++up; }                    // shrink
    if (S[i] == 'D') { --down; }                  // shrink
    if (up > down) { // Bad
      cout << "NO" << endl;
      return 0;
    }
  }
  if (sr < up || down < sr) { // Bad
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,a[maxn],cnt1[maxn],cnt2[maxn];

int main()
{
    fastio();
    cin>>n;
    rep(i,1,n) cin>>a[i];
    int ans = 0;
    int mx=0,mx2=0,x;
    for(int i=1;i<=n;i+=2){
        cnt1[a[i]]++;
        if(cnt1[a[i]]>mx) mx=cnt1[a[i]],x=a[i];
    }
    for(int i=1;i<=n;i+=2){
        if(a[i]!=x && cnt1[a[i]]>mx2) mx2=cnt1[a[i]];
    }
    int Mx=0,Mx2=0,X;
    for(int i=2;i<=n;i+=2){
        cnt2[a[i]]++;
        if(cnt2[a[i]]>Mx) Mx=cnt2[a[i]],X=a[i];
    }
    for(int i=2;i<=n;i+=2){
        if(a[i]!=X && cnt2[a[i]]>Mx2) Mx2=cnt2[a[i]];
    }
    if(x!=X) ans = n-mx-Mx;
    else{
        ans = min(n-mx-Mx2,n-mx2-Mx);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
const int N = 2e5 + 10;

ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a % b);
}
int n, c0 = 0, c1 = 0, c2 = 0;
ll a[N], b[N], g, x, y, ta, tb;



void add_self(ll &a, ll b){
    a += b;
    if(a >= mod)a -= mod;
}



int main(){
   IOS

   cin>>n;


   map<pair<ll, ll>, int> mp;


   for(int i = 1; i <= n; i++){
       cin>>a[i]>>b[i];
       if(a[i] == 0 and b[i] == 0)c0++;
       else if(a[i] == 0)c1++;
       else if(b[i] == 0)c2++;
       else{
           if(b[i] < 0)a[i] = -a[i], b[i] = -b[i];
           g = gcd(abs(a[i]), abs(b[i]));           
           mp[{a[i]/g, b[i]/g}]++;
       }
   }

   ll ans = 0;
   ans += c0;

   vector<pii> comp;

   for(auto it : mp){
       if(it.first.first == 0 or it.first.second == 0){
           continue;
       }else{
            x = it.first.first, y = it.first.second;
            if(x < 0){
                comp.pb({it.second, mp[{y, -x}]});
                mp.erase(mp.find({y, -x}));
            }else{
                comp.pb({it.second, mp[{-y, x}]});
                mp.erase(mp.find({-y, x}));
            }
       }
   } 

 
    ta = 1ll, tb = 0ll;

   for(auto it : comp){
        tb = pwr(2, it.first) % mod;
        add_self(tb, pwr(2, it.second) % mod);
        tb = (tb -1LL + mod)%mod;
        ta = (ta % mod * tb %mod) % mod;
   }

   tb = pwr(2, c1)%mod;
   add_self(tb, pwr(2, c2)%mod);
   tb = (tb -1LL + mod)%mod;

   ta = (ta % mod * tb % mod)%mod;

   ans = (ans + ta -1LL + mod)%mod;

   cout<<ans<<"\n";
}



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

    return res;
}



Measured memory_bytes: 20756
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B=MI()
    print(A*B//gcd(A,B))
if __name__ == '__main__':
    main()

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    if (A >= B && B >= C) {
        cout << A - C << endl;
        return 0;
    }
    if (A >= C && C >= B) {
        cout << A - B << endl;
        return 0;
    }
    if (B >= A && A >= C) {
        cout << B - C << endl;
        return 0;
    }
    if (B >= C && C >= A) {
        cout << B - A << endl;
        return 0;
    }
    if (C >= A && A >= B) {
        cout << C - B << endl;
        return 0;
    }
    if (C >= B && B >= A) {
        cout << C - A << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans;
    if(n >= 2 && m >= 2) {
        ans = (n - 2) * (m - 2);
    } else if(n == 1 && m > 1) {
        ans = m - 2;
    } else if(m == 1 && n > 1) {
        ans = n - 2;
    } else {
        ans = 1;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        for(int i = A;i <= B*A;i += A){
            if(i % B == C){
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 21844
n, m = map(int, input().split())
l = list(map(int, input().split()))

if n >= m:
  print(0)
  exit()

l.sort()
d = [0]*(m-1)
for i in range(m-1):
  d[i] = l[i+1] - l[i]

d.sort()

print(sum(d[0:(m-n)]))




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

using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
const int N = 500001;
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

struct edge {
	int x, y, next;
} e[2 * N]; int len, last[N];
struct tnode {
	int cnt, lc[N << 1], rc[N << 1], c[N << 1];
	
	void bt(int l, int r) {
		int now = ++cnt;
		lc[now] = rc[now] = -1;
		c[now] = 999999999;
		if(l < r) {
			int mid = (l + r) / 2;
			lc[now] = cnt + 1; bt(l, mid);
			rc[now] = cnt + 1; bt(mid + 1, r);
		}
	}
	
	void change(int now, int l, int r, int p, int C) {
		if(l == r) {c[now] = C; return ;}
		int mid = (l + r) / 2;
		if(p <= mid) change(lc[now], l, mid, p, C);
		else change(rc[now], mid + 1, r, p, C);
		c[now] = _min(c[lc[now]], c[rc[now]]);
	}
	
	int getmn(int now, int l, int r, int ll, int rr) {
		if(ll > rr) return 999999999;
		if(l == ll && r == rr) return c[now];
		int mid = (l + r) / 2;
		if(rr <= mid) return getmn(lc[now], l, mid, ll, rr);
		else if(ll > mid) return getmn(rc[now], mid + 1, r, ll, rr);
		else return _min(getmn(lc[now], l, mid, ll, mid), getmn(rc[now], mid + 1, r, mid + 1, rr));
	}
} t;
int n, K, du[N], a[N], ans[N];
priority_queue<int, vector<int>, greater<int> > q;

void ins(int x, int y) {
	e[++len].x = x, e[len].y = y;
	e[len].next = last[x], last[x] = len;
}

void topsort() {
	int cnt = 0;
	for(int i = 1; i <= n; i++) if(!du[i]) q.push(i);
	while(!q.empty()) {
		int x = q.top(); ans[x] = ++cnt; q.pop();
		for(int k = last[x]; k; k = e[k].next) {
			int y = e[k].y;
			if(!(--du[y])) q.push(y);
		}
	}
}

int main() {
	n = read(), K = read();
	for(int i = 1; i <= n; i++) a[read()] = i;
	t.bt(1, n);
	for(int i = n; i; i--) {
		int x;
		x = t.getmn(1, 1, n, a[i] + 1, _min(a[i] + K - 1, n));
		if(x != 999999999) ins(a[i], a[x]), du[a[x]]++;
		x = t.getmn(1, 1, n, _max(a[i] - K + 1, 1), a[i] - 1);
		if(x != 999999999) ins(a[i], a[x]), du[a[x]]++;
		t.change(1, 1, n, a[i], i);
	} topsort();
	for(int i = 1; i <= n; i++) put(ans[i]), puts("");
	return 0;
}


Measured memory_bytes: 34816
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, A, B;
lint ans[300000];
int main() {
	cin >> N >> A >> B;
	if (N > A * B || N + 1 < A + B) {
		cout << -1 << endl;
	}
	else {
		REP(i, N) {
			ans[i] = i + 1;
		}
		lint curr = 0;
		A--;
		while (curr + B < N - A) {
			reverse(ans + curr, ans + curr + B);
			curr += B;
			A--;
		}
		reverse(ans + curr, ans + N - A);
		REP(i, N) {
			cout << ans[i] << " ";
		}
	}
}

Measured memory_bytes: 5876
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
map < char , bool > mp;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	string s;
	string t = "abcdefghijklmnopqrstuvwxyz";
	cin >> s;
	int maxi = 0, cnt = 0, ans = INT_MAX;
	for(auto x : t){
		cnt = 0;
		for(auto c : s){
			if(x == c){
				maxi = max(maxi , cnt);
				cnt = 0;
			}
			else
				cnt++;
		}
		if(maxi){
			ans = min(ans , max(maxi , cnt));
			maxi = 0;
		}
	}
	cout << (ans > 100 ? 0 : ans) << endl;
	return 0;
}


Measured memory_bytes: 256