akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

int n;
void dfs(int d, vector<int> x, int m) {
  if (d == n) {
    cout << x << endl;
    rep(i, sz(x)) cout << (char)('a' + x[i]); cout << endl;
    return;
  }
  rep(i, m + 1 + 1) {
    x.eb(i);
    dfs(d + 1, x, max(m, i));
    x.pop_back();
  }
}
void solve() {
  ll h, w;
  cin >> h >> w;
  if (h > w) swap(h, w);
  
  if (h % 2 == 0) {
    cout << h / 2 * w << endl;
  } else { 
    if (h == 1) { // 気づけなかった...
      cout << 1 << endl;
    } else {
      cout << (h - 1) * w / 2 + (w + 1) / 2 << endl;
    }
  }
}


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

namespace AOJ.Volume0
{
    class Program0009
    {
        static void Main(string[] args)
        {
            string input;
            Queue<int> results = new Queue<int>();

            while ((input = Console.ReadLine()) != null)
            {
                int n = int.Parse(input);

                results.Enqueue(GetPrimeNumbersNum(n));
            }

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }

        }

        static int GetPrimeNumbersNum(int n)
        {
            bool[] isPrime = new bool[n + 1];

            //初期化
            isPrime[0] = false;
            isPrime[1] = false;
            for (int i = 2; i <= n; i++)
                isPrime[i] = true;


            for (int i = 2; i <= n; i++)
            {
                if (isPrime[i])
                {
                    int current = i * 2;

                    while (current <= n)
                    {
                        isPrime[current] = false;
                        current += i;
                    }
                }
            }

            return isPrime.Count(b => b);
        }
    }
}

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

int main()
{
    char x;
    cin >> x;

    if (x == 'a')
        cout << 'b';
    if (x == 'b')
        cout << 'c';
    if (x == 'c')
        cout << 'd';
    if (x == 'd')
        cout << 'e';
    if (x == 'e')
        cout << 'f';
    if (x == 'f')
        cout << 'g';
    if (x == 'g')
        cout << 'h';
    if (x == 'h')
        cout << 'i';
    if (x == 'i')
        cout << 'j';
    if (x == 'j')
        cout << 'k';
    if (x == 'k')
        cout << 'l';
    if (x == 'l')
        cout << 'm';
    if (x == 'm')
        cout << 'n';
    if (x == 'n')
        cout << 'o';
    if (x == 'o')
        cout << 'p';
    if (x == 'p')
        cout << 'q';
    if (x == 'q')
        cout << 'r';
    if (x == 'r')
        cout << 's';
    if (x == 's')
        cout << 't';
    if (x == 't')
        cout << 'u';
    if (x == 'u')
        cout << 'v';
    if (x == 'v')
        cout << 'w';
    if (x == 'w')
        cout << 'x';
    if (x == 'x')
        cout << 'y';
    if (x == 'y')
        cout << 'z';
}


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

#define MAX 100000

void dequeue(char*, int*);
void inqueue(char*, int);

char name[MAX][10];
int  time[MAX];
int head=0, tail=1;

main(){
  int t=0;  //経過時間
  int i, n, q;
  char tmpName[10];
  int tmpTime;

  scanf("%d %d", &n, &q);
  for(i=0; i<n; i++)scanf("%s %d", name[i], &time[i]);
  tail = n;  //nコのデータを入力したため、更新

  while(head != tail){
    dequeue(tmpName, &tmpTime);
    if(tmpTime > q){
      t+=q;
      tmpTime -= q;
      inqueue(tmpName, tmpTime);
    }
    else {
      t+=tmpTime;
      printf("%s %d\n", tmpName, t);
    }
  }
  return 0;
}

void dequeue(char* tmpName, int* tmpTime){
  strcpy(tmpName, name[head]);
  *tmpTime = time[head];

  //printf("dequeue[%d] : %s %d\n", head, tmpName, *tmpTime);

  head = (head+1) % MAX;
}

void inqueue(char *tmpName, int tmpTime){
  strcpy(name[tail], tmpName);
  time[tail] = tmpTime;

  //printf("inqueue[%d] : %s %d\n", tail, tmpName, tmpTime);

  tail = (tail+1) % MAX;
}

Measured memory_bytes: 1976
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

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

  vector<int> b;
  int temp;
  for (int i=0; i<n-1; i++) {
    cin>>temp;
    b.push_back(temp);
  }

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

  cout<<ans<<endl;

  return 0;
}




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

struct Node
{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL)
    {
        y = x; // Keep the node of a candidate for the parent of the Node z;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }

    // Construct a double link between the Node z and its parent;
    z->parent = y;
    if (y == NIL)
    {
        root = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if (u == NIL)
    {
        return;
    }
    else
    {
        inorder(u->left);
        cout << " " << u->key;
        inorder(u->right);
    }
}

void preorder(Node *u)
{
    if (u == NIL)
    {
        return;
    }
    else
    {
        cout << " " << u->key;
        preorder(u->left);
        preorder(u->right);
    }
}

int main(int argc, char const *argv[])
{
    string com = "";
    int k = 0;

    int n = 0;
    cin >> n;

    // vector<int> a(n, 0);
    for (size_t i = 0; i < n; ++i)
    {

        cin >> com;
        if (com == "insert")
        {
            cin >> k;
            insert(k);
        }
        else
        {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 26452
#include<bits/stdc++.h>
using namespace std;
#include <vector>
#include <iterator>
#include <math.h>



int main()
{
    vector<int> data;
	int n,q;
	cin>>n;
	int i = 0;
	for(i=0;i<n;i++)
	{
		cin>>q;
		data.push_back(q);
	}	
    std::sort(data.begin(),data.end(),greater<int>());
    
	cout<<data[n/2-1]-data[n/2];
    return 0;
} 	

Measured memory_bytes: 892
// HEADERS //
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <bits/stdc++.h>
 
// MISCELLANEOUS //
#define fast_IO() ios_base::sync_with_stdio(false),cin.tie(NULL)
#define gcd __gcd
#define cnt_1s __buitlin_popcount
#define ll long long
#define endl "\n"
#define test(t) cin>>t; while(t--)
#define mem(v,x) memset(v,x,sizeof(v))

// LOOPS //
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define irep(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define srep(i,v) for(decltype(v.begin())i=v.begin();i!=v.end();i++)
 
// CONTAINERS //
// #define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define all(v) (v).begin(),(v).end()
#define present(v,x) (v).find(x)!=(v).end()
 
// DEBUGGING //
#define dbg() printf("\n**DEBUG**\n") 
#define chk(a) cerr<<endl<<#a<<":"<<a<<endl
#define chk2(a,b) cerr<<endl<<#a<<":"<<a<<"\t"<<#b<<":"<<b<<endl
 
// CONSTANTS //
#define M 1000000007
 
// MAIN //
// using namespace __gnu_pbds; 
using namespace std;
int main()
{
  fast_IO();
  int h, w; 
  cin >> h >> w;
  int dp[h][w]; mem(dp, 0); dp[0][0] = 1;
  vector<string> v(h);
  rep(i, 0, h) cin >> v[i];
  rep(i, 0, h) rep(j, 0, w)
  {
      if(v[i][j] == '.' && j >= 1) dp[i][j] += dp[i][j-1] % M;
      if(v[i][j] == '.' && i >= 1) dp[i][j] += dp[i-1][j] % M;
  }
  cout << dp[h-1][w-1] % M;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll N,W;
    cin>>N>>W;
    ll a[N+1][W+1];
    for(ll i=0;i<=N;i++)
    {
        for(ll j=0;j<=W;j++)
        {
            a[i][j]=0;
        }
    }
    ll ans=0;
    for(ll i=1;i<=N;i++)
    {
        ll w,v;
        cin>>w>>v;
        if(w<=W)
        a[i][w]=max(a[i-1][w],v);
        if(a[i][w]>ans)
            ans=a[i][w];
        for(ll j=1;j<=W;j++)
        {
            
            if(a[i-1][j]>0)
            {
                a[i][j]=max(a[i][j],a[i-1][j]);
                if(j+w<=W)
                {
                    a[i][j+w]=max(a[i-1][j+w],a[i-1][j]+v);
                }
                
                    
            }
            if(a[i][j]>ans)
                {
                    ans=a[i][j];
                }
        }
        
    }
    // for(ll j=0;j<=W;j++)
    // {
    //     for(ll i=0;i<=N;i++)
    //     {
    //         cout<<a[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
     cout<<ans;
    return 0;
}

Measured memory_bytes: 79104
s,t=open(0)
m=len(t:=t[:-1])
for i in range(len(s)):
 if all(c in'?'+d for c,d in zip(s[-i-m:],t)):s=s.replace(*'?a');exit(print(s[:-i-m]+t+s[-i:]))
print('UNRESTORABLE')

Measured memory_bytes: 9076
using System;

class MainClass
{
    const long MOD = 1000000007;

    public static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var d = new long[s.Length];
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '?')
            {
                d[i] = -1;
            }
            else
            {
                d[i] = s[i] - '0';
            }
        }

        var n = d.Length;
        var m = 13;

        var dp = new long[n + 1, m];
        dp[0, 0] = 1;

        for (int i = 0; i < n; i++)
        {
            if (0 <= d[i])
            {
                for (int k = 0; k < m; k++)
                {
                    dp[i + 1, (k * 10 + d[i]) % m] += dp[i, k];
                    dp[i + 1, (k * 10 + d[i]) % m] %= MOD;
                }
            }
            else
            {
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < m; k++)
                    {
                        dp[i + 1, (k * 10 + j) % m] += dp[i, k];
                        dp[i + 1, (k * 10 + j) % m] %= MOD;
                    }
                }
            }
        }

        Console.WriteLine(dp[n, 5]);
    }
}

Measured memory_bytes: 22240
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

ll n;
ll a[3] = {3,5,7};

ll dfs(ll s){
    if(s>n){
        return 0;
    }
    ll t=s;
    ll rtn=0;
    bool e3=false,e5=false,e7=false,ee = true;
    while(t>0){
        if(t%10==3){
            e3 = true;
        }else if(t%10==5){
            e5=true;
        }
        else if(t%10==7){
            e7=true;
        }
        else{
            ee = false;
        }
        t/=10;
    }
    if(e3&&e5&&e7){//七五三数
        rtn += 1;
    }
    if(ee){//準七五三数ならば、末尾に3,5,7をつけてdfs呼び出し
        REP(i,3){
            rtn += dfs(s*10+a[i]);
        }
    }
    return rtn;
}

int main() {
    cin >> n;
    put(dfs(0));
    return 0;
}


Measured memory_bytes: 256
public class Main {
  public static void main(String [] args) {
    for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        System.out.print(i);
        System.out.print("x");
        System.out.print(j);
        System.out.print("=");
        System.out.print(i * j);
        System.out.println("");
      }
    }
  }
}  

Measured memory_bytes: 23920
import java.util.*;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Long r = sc.nextLong();
    Long D = sc.nextLong();
    Long x = sc.nextLong();
    for (int i = 0; i < 10; i++) {
      Long ans = r * x - D;
      System.out.println(ans);
      x = ans;
    }
  }
}


Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,a[1000],var;
    ll maxcost=1000;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[j]>a[i])
            {
                var=maxcost/a[i];
                maxcost=maxcost-(var*a[i])+(var*a[j]);
                i=j;
                i--;
                break;
            }
            else if(a[j]<a[i])
            {
                i=j;
                i--;
                break;
            }
        }
    }
    cout<<maxcost<<'\n';
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
vector <ll> parent (1e6,0),size1(1e6,0);
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

//Union by size
void make_set(int v) {
    parent[v] = v;
    size1[v] = 1;
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (size1[a] < size1[b])
            swap(a, b);
        parent[b] = a;
        size1[a] += size1[b];
    }
}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,m;
    cin>>n>>m;
    rep (i,1,n+1)
    {
        make_set(i);
    }
    rep (i,0,m)
    {
        ll x,y;
        cin>>x>>y;
        union_sets(x,y);
    }
    ll ans=0;
    rep (i,1,n+1)
    {
        ans=max(ans,size1[i]);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 18652
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int a,b,c,sum=5+7+5;
int main(){
    scanf("%d %d %d",&a,&b,&c);
    int tmp=a+b+c;
    (tmp<=sum)?printf("YES\n"):printf("NO\n");
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h>
using namespace std;
int main(void){
    // Your code here!
    int K,S;
    cin >> K >> S;
    int count = 0;
    for(int i = 0;i <= K;i++){
        for(int j = 0;j <= K; j++){
            if(S-i-j >=0 && S-i-j <= K){
                count++;
            }
        }
    }
    cout << count << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mx 1000000007
#define ll long long int

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,w;
	cin>> n >> w;
	ll wv[n+1][2];
	for(ll i=1;i<=n;++i)
        cin>> wv[i][0] >> wv[i][1] ;
	ll dp[n+1][n*1000+1];
	memset(dp,0,sizeof(dp));
	for(ll i=1;i<=(1000*n) ; ++i){
        dp[0][i]=100000000000;
	}
	for(ll i=1;i<=n;++i){
        for(ll j=1;j<=1000*n;++j){
            if(wv[i][1]>j)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=min(wv[i][0]+dp[i-1][j-wv[i][1]],dp[i-1][j]);
        }
	}
	ll ans=0;
	for(ll i=0;i<=1000*n;++i){
        if(dp[n][i]<= w)
            ans=i;
	}
	cout<< ans ;
	return 0;
}

Measured memory_bytes: 82536
#include <stdio.h>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)

int main(){
    int A[10000], B[10000], count = 0;
    while(1){
        int H, W;
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        A[count] = H;
        B[count] = W;
        count++;
    }

    rep(i, 0, count){
        rep(y, 0, A[i]){
            rep(x, 0, B[i]) printf("#");
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    int n,i;
    cin>>n>>i;
    if(n+i==15)
    cout<<"+"<<endl;
    if(n*i==15)
    cout<<"*"<<endl;
    if(n+i!=15&&n*i!=15)
    cout<<"x"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
  
#define tate 3
#define yoko 3
#define SUM (tate*yoko)
#define Cnt 45
extern inline void up(void);     
extern inline void down(void);     
extern inline void right(void);   
extern inline void left(void);    
extern int  serch(int a, int b, int cnt,int p);
 
int n = 0,A[SUM]; 

int main()
{
  int i = 0,a,b= 0;
     
    
    for(i=0; i<SUM; i++)
    {
        scanf("%d",&A[i]);
         
        if(A[i] == 0)n = i;
    } 
    a = tate - (n/yoko) -1;
    b = yoko - (n%yoko) -1;
    for(i=0; i<Cnt; i++){
        if( serch(a,b,i,4) == 1 ){
            printf("%d\n",i);
            break;
        }
    }          
    return 0;
}
 
int serch(int a, int b, int cnt, int p)
{
  int res, i=0;
     
  if(Cnt < (a + b) )return 0;  
    if(cnt==0){
        for(i=0; i<SUM-1; i++){
            if(A[i] != (i+1))return 0;
        }   
        return 1;
    }
        
    for(i=0; i<4; i++){
        res= 0;        
        switch(i){
            case 0:
                if( (a> 0) && (p != 3) ){
                    down();      
                    res = serch(a-1, b, cnt-1, 0);
                    up();
                }
                break;
                 
            case 1:
	      if( (b> 0) && (p != 2)){
                    right();
                    res = serch(a, b-1, cnt-1, 1);
                    left();
                }
                break;
                 
            case 2:
                if( (b < yoko -1 ) && (p != 1) ){
                    left();
                    res = serch(a, b+1, cnt-1, 2);
                    right();
                }
                break;
                 
            case 3:
                if( (a < tate -1 ) && (p != 0) ){
                    up();
                    res = serch(a+1, b, cnt-1, 3);
                    down();
                }
                break;
                 
            default:
                break;
        }
        if(res)return 1;
    }     
    return 0;
}
 
inline void up()
{
    A[n] = A[n - yoko];
    n = n - yoko;
}
 
inline void down()
{
    A[n] = A[n + yoko];
    n = n + yoko;
}
  
inline void right()
{
    A[n] = A[n +1];
    n = n + 1;
}
  
inline void left()
{
    A[n] = A[n -1];
    n = n - 1;
}



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

int main() {
int A, B;
cin >> A >> B;

int a, b, c, d, e;
int count = 0;
for (int i = A; i <= B; i++) {
    a = i % 10;
    b = i / 10 % 10;
    c = i / 100 % 10;
    d = i / 1000 % 10;
    e = i / 10000;
    if (a == e && b == d) {
        count++;
    }
}
cout << count << endl;
}

Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

const int N=101;
const int MAXN=100001;
int n, W;


int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cin>>n>>W;
    vector<int> wt(n), val(n);

    fori(n)
        cin>>wt[i]>>val[i];

    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));

    for(int i=0; i<=n; i++) {
        for(int j=0; j<=W; j++) {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(wt[i-1]<=j)
                dp[i][j]=max(val[i-1] + dp[i-1][j-wt[i-1]], dp[i-1][j]);
            else    
                dp[i][j]=dp[i-1][j];
        }
    }

    ll ans=dp[n][W];
    cout<<ans<<endl;
}



Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr int inf = (1 << 30) - 1;

int main() {
  int N, M, X;
  std::cin >> N >> M >> X;
  std::vector<int> cost(N);
  std::vector<std::vector<int>> get(N, std::vector<int>(M));
  for (int i: range(0, N)) {
    std::cin >> cost[i];
    for (auto &x: get[i]) {
      std::cin >> x;
    }
  }
  int ans = inf;
  for (int S: range(0, 1 << N)) {
    std::vector<int> cur(M);
    int need = 0;
    for (int i: range(0, N)) {
      if (S >> i & 1) {
        need += cost[i];
        for (int j: range(0, M)) {
          cur[j] += get[i][j];
        }
      }
    }
    if ([&] {
      for (int j: range(0, M)) {
        if (cur[j] < X) {
          return false;
        }
      }
      return true;
    }()) {
      chmin(ans, need);
    }
  }
  std::cout << (ans == inf ? -1 : ans) << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  ll a,b = 0;
  cin >> a >> b;
  ll sum = 0;
  if (a > b) {
    sum += a;
    a--;
  }
  else {
    sum += b;
    b--;
  }
  
  if (a > b) {
    sum += a;
    a--;
  }
  else {
    sum += b;
    b--;
  
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
   vector<ll> l(100);
   l.at(0)=2;
   l.at(1)=1;
   for(int i=2;i<=99;i++){
     l.at(i)=l.at(i-1)+l.at(i-2);
   }
   int n;
   cin >> n;
   cout << l.at(n) << endl;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")



signed main() {

	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
		cout << "Bad" << endl;
	else
		cout << "Good" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
   public static void main(String[] args){
          Scanner in=new Scanner(System.in);
          int n=in.nextInt();
          int day=in.nextInt();
          int x=in.nextInt();
          int ans=x+n;
          int[] a=new int[n];
          for(int i=0;i<n;i++){
          a[i]=in.nextInt();
          ans+=(day-1)/a[i];
          }
  System.out.println(ans);
}
}

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

int main()
{
    int n;
    std::cin >> n;
    std::priority_queue< int, std::vector<int>, std::greater<int>> q;

    int ans = 0;
    q.push(INT_MAX);
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        int m = q.top();
        if (m >= tmp)
            ans++;
        q.push(tmp);
    }
    std::cout << ans << std::endl;
    return 0;
}


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

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		
		for(int i=0;i<n;i++) {
			System.out.println(LCS(in.next().toCharArray(),in.next().toCharArray()));
		}
	}
	
	static int LCS(char[] A,char[] B) {
		int DP[][]=new int[B.length][A.length];
		
		for(int i=0;i<A.length;i++) {
			if(A[i]==B[0])DP[0][i]=1;
			else if(i>0)DP[0][i]=DP[0][i-1];
		}
		
		for(int i=1;i<B.length;i++) {
			for(int j=0;j<A.length;j++) {
				if(j==0) {
					if(B[i]==A[j])DP[i][j]=1;
					else DP[i][j]=DP[i-1][j];
				}
				else {
					if(B[i]==A[j])DP[i][j]=DP[i-1][j-1]+1;
					else DP[i][j]=Math.max(DP[i-1][j], DP[i][j-1]);
				}
			}
		}
		//print(DP);
		
		int res=0;
		for(int i=0;i<B.length;i++) {
			res=Math.max(res,DP[i][A.length-1]);
		}
		
		return res;
	}
	
	static void print(int[][] A) {
		for(int i=0;i<A.length;i++) {
			for(int j=0;j<A[i].length;j++)System.out.print(A[i][j]+" ");
			System.out.println();
		}
	}

}



Measured memory_bytes: 66036
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    cin >> N;
    cout << (N-1)/2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
def main():
    a, b = map(int, raw_input().split())
    s = raw_input()

    if len(s) == a+b+1 and  s[:a].isdigit() and s[a] == "-" and s[a+1:].isdigit():
        print "Yes"
    else:
        print "No"
    

if __name__=="__main__":
    main()


Measured memory_bytes: 2568
n = int(input())
T = list(map(int,input().split()))
V = list(map(int,input().split()))
s = [0]*n
for i in range(n-1):
    s[i+1] = s[i] + T[i]
l = (s[-1]+T[n-1])*2+1
ans = [1e100]*l

for i in range(l):
    ans[i] = min(ans[i],i/2)
    ans[l-i-1] = min(ans[i],i/2)

for j in range(n):
    for i in range(l):
        if i <= s[j]*2:
            ans[i] = min(ans[i], V[j]+(s[j]*2-i)/2)
        elif s[j]*2 <= i <= s[j]*2+T[j]*2:
            ans[i] = min(ans[i],V[j])
        else:
            ans[i] = min(ans[i],V[j]+(i-s[j]*2-T[j]*2)/2)
anser = 0
for i in range(l-1):
    anser += (ans[i]+ans[i+1])/4
print(anser)


Measured memory_bytes: 52060
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
using namespace std;

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


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

	if (2 * a <= b && 4 * a >= b && b % 2 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


}







Measured memory_bytes: 3096
import sys

H = int(sys.stdin.readline())
A = list(map(int,sys.stdin.readline().split()))

def maxHeapify(A, i):
    l = (i+1)*2-1  
    r = (i+1)*2    
    
    if l < H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r < H and A[r] > A[largest]:
        largest = r

    if largest != i: 
        A[i], A[largest] = A[largest], A[i]
        maxHeapify(A, largest) 

def buildMaxHeap(A):
    for i in range(H//2-1, -1, -1):
        maxHeapify(A, i)

buildMaxHeap(A)
print('',' '.join(map(str,A)))


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

using namespace std;

int main ()
{
	int N;
	cin >> N;
	vector<int>data ( 100005 );
	data[0]++;
	data[N + 4]--;
	for( size_t i = 0; i < N; i++ )
	{
		int a , b;
		cin >> a >> b;
		data[a]++;
		data[b + 1]--;
	}
	for( size_t i = 1; i < 100005; i++ )
	{
		data[i] += data[i - 1];
		//cout << data[i] << endl;
	}
	for( int i = N+1; i >= 0; i-- )
	{
		if( data[i] >= i )
		{
			cout << i -1<< endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int n;cin>>n;
	map<string,int> mp;
	ll ans = 0;
	rep(i,n){
		string s;cin>>s;
		sort(all(s));
		mp[s]++;
		ans += mp[s] - 1;
}
	cout << ans << endl;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll A,B,N;
    string S;
    cin >> A >> B >> N;
    /*ll L = -1;
    ll R = N;
    while(L + 1 < R){
    ll X = (L+R)/2;*/
    ll X = min(B-1,N);
    ll ans = ll(A*X/B) - A*ll(X/B);
    //}
    cout << ans <<endl;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    
    for (int i = A; i <= B; i++)
    {
        int c = i % 10, d = i / 10000 % 10;
        int e = i / 10 % 10, f = i / 1000 % 10;
        if (c == d && e == f)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <iomanip>
using namespace std;


typedef pair<int,int> P;


int main(int argc, char const *argv[]) {
  int a,b;
  char op;
  cin>>a>>op>>b;
  if(op=='+')cout<<a+b<<endl;
  else cout<<a-b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1e6 + 5 ;
char s[105] ;
int main()
{
	scanf("%s" , s) ;
	int len = strlen(s) ;
	for(int i = 0 ; i < len ; i ++)  printf("x") ;
	printf("\n") ;
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int NIL = -1;
const int MAX = 30;

struct Node {
    int parent, left, right;
};

Node tree[MAX];

void print_preorder(int root_id) {
    if (root_id == NIL) {
        return;
    }
    cout << " " << root_id;
    print_preorder(tree[root_id].left);
    print_preorder(tree[root_id].right);
}

void print_inorder(int root_id) {
    if (root_id == NIL) {
        return;
    }
    print_inorder(tree[root_id].left);
    cout << " " << root_id;
    print_inorder(tree[root_id].right);
}

int get_root(int node_temp) {
    if (tree[node_temp].parent == NIL) {
        return node_temp;
    } else {
        return get_root(tree[node_temp].parent);
    }
}

void print_postorder(int root_id) {
    if (root_id == NIL) {
        return;
    }
    print_postorder(tree[root_id].left);
    print_postorder(tree[root_id].right);
    cout << " " << root_id;
}

int main() {
    int number_of_nodes, node_id, left_node, right_node;
    cin >> number_of_nodes;

    for (int n=0; n < number_of_nodes; n++) tree[n].parent = tree[n].left = tree[n].parent = NIL;

    for (int n=0; n < number_of_nodes; n++) {
        cin >> node_id;
        cin >> left_node;
        cin >> right_node;

        tree[node_id].left = left_node;
        tree[node_id].right = right_node;
        if (left_node != NIL) tree[left_node].parent = node_id;
        if (right_node != NIL) tree[right_node].parent = node_id;
    }
    int root = get_root(0);

    cout << "Preorder" << endl;
    print_preorder(root);
    cout << endl;

    cout << "Inorder" << endl;
    print_inorder(root);
    cout << endl;

    cout << "Postorder" << endl;
    print_postorder(root);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const int MaxH = 103;
int h,w,n,c[MaxH][MaxH];

int main() {
    scanf("%d%d%d",&h,&w,&n);
    int x=1,y=0;
    for (int i=1;i<=n;++i) {
        int a;
        scanf("%d",&a);
        for (int j=1;j<=a;++j) {
            if (x&1) {
                y++;
                if (y>w) x++,y=w;
            } else {
                y--;
                if (y<=0) x++,y=1;
            }
            c[x][y]=i;
        }
    }
    for (int i=1;i<=h;++i) {
        for (int j=1;j<=w;++j)
            printf("%d ",c[i][j]);
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    string s;
    cin >> s;
    vector<int> a(3);

    for(char c: s){
        switch(c){
            case 'a': a[0]++;
                      break;
            case 'b': a[1]++;
                      break;
            case 'c': a[2]++;
                      break;
            default: break;
        }
    }
    sort(a.begin(), a.end());
    if(a[2] - a[0] <= 1){
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	if(a+b+c >= 22) printf("bust\n");
	else printf("win\n");
}


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

int main(){
  int N, M;
  cin >> N >> M;
  int A[M];
  rep(i, M)
    cin >> A[i];

  int sum = 0;
  rep(i, M)
    sum += A[i];

  if(sum > N)
    cout << -1 << endl;
  else
    cout << N-sum << endl;

  return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main(){
  int N, L;
  std::cin >> N >> L;
  std::vector<std::string> rstr(N);
  for (int i=0; i < N; i++)
  {
    std::cin >> rstr[i];
  }
  std::sort(rstr.begin(), rstr.end());
  for (int i=0; i<N; i++)
  {
    std::cout << rstr[i];
  }
  std::cout << std::endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back

using namespace std;

const int N = 310;
const int Mod = 1e9 + 7;

struct Constraint{
	int l, x;
};

vector<Constraint> C[N];

inline void add(int &x, int y){
	x += y;
	if(x >= Mod) x -= Mod;
}

int n, m;
int dp[N][N][N];

int main(){
	scanf("%d%d", &n, &m);
	For(i, 1, m){
		int l, r, x;
		scanf("%d%d%d", &l, &r, &x);
		C[r].pb((Constraint){l, x});
	}
	dp[0][0][0] = 1;
	For(i, 0, n - 1){
		For(a, 0, i) For(b, 0, i){
			int v = dp[i][a][b];
			if(!v) continue;
			add(dp[i + 1][a][b], v);
			add(dp[i + 1][a][i], v);
			add(dp[i + 1][b][i], v);
		}

		For(a, 0, i + 1) For(b, 0, i + 1){
			bool valid = true;
			for(auto v : C[i + 1])
				if((a >= v.l) + (b >= v.l) != v.x - 1){
					valid = false;
					break;
				}
			if(!valid) dp[i + 1][a][b] = 0;
		}
	}
	
	int ans = 0;
	For(i, 0, n) For(j, 0, n) add(ans, dp[n][i][j]);
	printf("%d\n", ans);

	return 0;
}

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

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: 3552
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;
const long long MOD = 1000000007;
long long A[200000];
long long B[200000];
pair <long long, long long> frac_AB[200000];
long long two_power[200001];
long long gcd(long long m, long long n){
  if(n > m){
    return gcd(n, m);
  } else if(n == 0){
    return m;
  }
  return gcd(n, m % n);
}

pair <long long, long long> get_inv_neg(pair<long long, long long> a){
  if(a.first < 0){
    return make_pair(a.second, - a.first);
  }
  return make_pair(- a.second, a.first);
}
int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }

  two_power[0] = 1;
  for(int i = 1; i <= N; i++){
    two_power[i] = (two_power[i - 1] * (long long) 2) % MOD;
  }

  long long A_zero_count = 0;
  long long B_zero_count = 0;
  long long both_zero_count = 0;
  for(int i = 0; i < N; i++){
    if(A[i] != 0 && B[i] != 0){
      long long tmp = gcd(abs(A[i]), abs(B[i]));
      if((A[i] > 0 && B[i] > 0) || (A[i] < 0 && B[i] < 0)){
        frac_AB[i] = make_pair(abs(A[i]) / tmp, abs(B[i]) / tmp);
      } else {
        frac_AB[i] = make_pair(- abs(A[i]) / tmp, abs(B[i] / tmp));
      }
    } else if(A[i] == 0 && B[i] != 0){
      A_zero_count ++;
      frac_AB[i] = make_pair(0, B[i]);
    } else if(A[i] != 0 && B[i] == 0){
      B_zero_count ++;
      frac_AB[i] = make_pair(A[i], 0);
    } else {
      both_zero_count ++;
      frac_AB[i] = make_pair(0, 0);
    }
  }

  map <pair<long long, long long>, int> frac_counts;
  long long ans = 1;
  for(int i = 0; i < N; i++){
    if(frac_counts.find(frac_AB[i]) == frac_counts.end()){
      frac_counts[frac_AB[i]] = 1;
    } else {
      frac_counts[frac_AB[i]] ++;
    }
  }

  set <pair <long long, long long> > done;
  for(auto it = frac_counts.begin(); it != frac_counts.end(); it++){
    //cout << it->first.first << " " << it->first.second << endl;
    //cout << ans << endl;
    if(it->first.first == 0 || it->first.second == 0 || done.find(it->first) != done.end()){
      continue;
    }
    long long cur = (two_power[it->second] - 1 + MOD) % MOD;
    done.insert(it->first);
    pair <long long, long long> inv_neg  = get_inv_neg(it->first);
    if(frac_counts.find(inv_neg) != frac_counts.end()){
      cur = (cur + (two_power[frac_counts[inv_neg]] - 1 + MOD) % MOD) % MOD;
      done.insert(inv_neg);
    }
    ans = (ans * (cur + 1)) % MOD;
  }

  if(A_zero_count != 0 || B_zero_count != 0){
    long long A_tmp = (two_power[A_zero_count] - 1 + MOD) % MOD;
    long long B_tmp = (two_power[B_zero_count] - 1 + MOD) % MOD;
    ans = (ans * ((A_tmp + B_tmp) % MOD + 1)) % MOD;
  }
  ans = (ans - 1 + MOD) % MOD;
  ans = (ans + both_zero_count) % MOD;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 36412
/* package whatever; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
import java.util.ArrayList;
import java.util.List;
 
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        //文字列読込み
        Scanner sc = new Scanner(System.in);
 
        //結果格納
        int scInt;
        scInt = sc.nextInt();
	
        double price = 100000;

        for (int i = 0; i < scInt; i++){
	price = price * 1.05;
	price = (Math.ceil(price / 1000))*1000;
        }

        System.out.println(Math.round(price));         

    }
}


Measured memory_bytes: 25988
H, W = map(int, input().split())
if H%3 == 0 or W%3 == 0:
  print(0)
  exit()
r = min(H, W)
def calc(a, b, c):
  a, b, c = sorted([a, b, c])
  return c-a
h = H//3
w = W//2
r = min(r, calc(h*W, (H-h)*w, (H-h)*(W-w)))
h = H//3+1
w = W//2
r = min(r, calc(h*W, (H-h)*w, (H-h)*(W-w)))
w = W//3
h = H//2
r = min(r, calc(H*w, h*(W-w), (H-h)*(W-w)))
w = W//3+1
h = H//2
r = min(r, calc(H*w, h*(W-w), (H-h)*(W-w)))
print(r)


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

typedef long long ll;

string str;

int main() {
    cin >> str;
    int n = str.length();

    ll res = 0;
    int cu = 0;
    for(int i = 0; i < n; ) {
        if(i < n - 1 && str[i] == 'B' && str[i + 1] == 'C') {
            res += cu;
            i += 2;
        }
        else if(str[i] == 'A') {
            cu++;
            i++;
        }
        else {
            cu = 0;
            i++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 764
n, m = map(int, input().split())
jobs = [[] for _ in range(m+1)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m: continue
    jobs[m-a].append(-b)
import heapq
q = []
heapq.heapify(q)
ans = 0
for i in reversed(range(m)):
    [heapq.heappush(q, job) for job in jobs[i]]
    if q: ans -= heapq.heappop(q)
print(ans)

Measured memory_bytes: 17712
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100001],ans=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		 ans+=a[i];
	}
	if(ans%2==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;

int calc(int n){
  vector<int> p(1000008,1);
  //cout<<"OK"<<endl;
  int buf=n;
  for(int i=2;i<=1000007;i++){
    while(buf%i==0){
      p[i]++;
      buf/=i;
      //printf("i=%lld\n",i);
    }
    if(buf==1)break;
  }
  //cout<<"OK"<<endl;
  int hoge=1;
  rep1(i,1000007){
    hoge*=p[i];
  }
  //cout<<buf<<"\n";
  if(buf!=1){
    hoge*=2;
  }
  //printf("ans=%lld\n",21*buf);
  return hoge-1;
}
signed main(){
  int n;cin>>n;
  int res=1;
  if(n<=1000007){
    for(int i=2;i<n;i++){
      int buf=n;
      if(buf%i!=0){
        buf%=i;
        if(buf==1)res++;
      }
      else{
        while(buf%i==0){
          buf/=i;
        }
        buf%=i;
        if(buf==1)res++;
      }
    }
  }
  else{
    res=1;
    for(int i=2;i<=1000007;i++){
      int buf=n;
      if(buf%i!=0){
        buf%=i;
        //if(buf==1)res++;
      }
      else{
        while(buf%i==0){
          buf/=i;
        }
        buf%=i;
        if(buf==1){
          res++;
          //cout<<i<<endl;
        }
      }
      //cout<<i<<"\n";
    }
    //cout<<res<<"\n";
    res+=calc(n-1);
    //cout<<calc(n-1)<<"\n";
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	
	string s;
	int cnt = 0;
	cin >> s;
	sort(s.begin(), s.end());
	for (int i = 0; i < s.length()-1; i++)
		if (s[i] == s[i + 1])
			cnt++;
	if (cnt == 2)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3084