akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (v[i] > c[i]) {
                ans += v[i] - c[i];
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vll = vector<LL>;
using LD = long double;

#define ALL(v) v.begin(), v.end()
#define endl '\n'
#define SYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);
#define REP(i , n) for(int i =0 ; i < n ;i++)
#define REPN(i , n) for(int i = 1; i <= n ; i++)
#define cot(x) cerr << #x << " " << x << " ";
#define cotd(x) cerr << #x << " " << x << endl;
#define her 	cerr << " here \n"; 
#define pp push_back
#define fi first 
#define se second
#define un(x) x.erase(unique(ALL(x)), x.end())

template<typename T > void check(T & a, const T & b) { if (a >= b) { a %= b; } }
template<typename T>T gcd(T u, T v) { if (u == v)return u; if (u == 0)return v; if (v == 0)return u; if (~u & 1) { if (v & 1) return gcd(u >> 1, v); else return gcd(u >> 1, v >> 1) << 1; }if (~v & 1)return gcd(u, v >> 1); if (u > v)return gcd((u - v) >> 1, v); return gcd((v - u) >> 1, u); }
LL mulmod(LL a, LL b, const LL & m) { LL q = (LL)(((LD)a*(LD)b) / (LD)m); LL r = a*b - q*m; if (r>m)r %= m; if (r<0)r += m; return r; }
template <typename T, typename S>T expo(T e, S n) { T x = 1, p = e; while (n) { if (n & 1)x = x*p; p = p*p; n >>= 1; }return x; }
template <typename T>T powerL(T e, T n, const T & m) { T x = 1, p = e; while (n) { if (n & 1)x = mulmod(x, p, m); p = mulmod(p, p, m); n >>= 1; }return x; }

int main(){
	SYNC; 
	LL n; 
	cin >> n;
	int x = 100;
	vector<int> v(100, 0); int l = 0, r = 99; 

	while(n){
		if(n & 1) v[r--] = x, n /= 2; 
		else v[l++] = x, n--; 
		x--; 
	}
	vi ans, _ans; 
	for(int & i : v) if(i) ans.pp(i), _ans.pp(i);
	sort(ALL(_ans));  
	//for(int & i : ans) i = lower_bound(ALL(_ans), i) - _ans.begin() + 1, _ans[i-1] = i; 
	cout << (int)ans.size() * 2 << endl; 
	for(int & i : ans) cout << i << " "; 
	for(int & i : _ans) cout << i << " ";  
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int n4=0;
  int n2=0;
  int n1;
  REP(i,N){
    int a;
    cin>>a;
    if(a%4==0)n4++;
    else if(a%2==0)n2++;
  }
  n1=N-n2-n4;
  if(n4>=n1 or n4>=N/2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn=2e5+10;
int n;
long long k,a[maxn],f[maxn];
bool check(long long x)
{
	long long sum=0LL;
	for(int i=0;i<n;i++)
	{
		sum+=max(0LL,a[i]-x/f[i]);
	}
	if(sum>k)
	{
		return false;
	}
	return true;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>f[i];
	}
	//С*�� 
	sort(a,a+n);
	sort(f,f+n);
	reverse(f,f+n);
	long long l=0LL,r=1e12;
	for(int i=0;i<64;i++)
	{
		long long mid=(l+r)/2LL;
//		cout<<mid<<" ##"<<endl;
		if(!check(mid))
		{
			l=mid+1LL;
		}
		else
		{
			r=mid;
		}
	}
	cout<<l<<endl;
	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=3000;
int n;
double p[N],cache[N][N];
bool vis[N][N];

double dp(int pos,int i)
{
     if(pos==n+1)
     {
          if(i>(n/2))
               return 1;
          return 0;
     }
     
     double &ans=cache[pos][i];
     if(vis[pos][i])
          return ans;
     vis[pos][i]=true;     
     return ans=((1-p[pos])*dp(pos+1,i))+(p[pos]*dp(pos+1,i+1));
}

int32_t main()
{
	IOS;
     
     cin>>n;
     
     for(int i=1;i<=n;i++)
          cin>>p[i];
          
     cout<<fixed<<setprecision(10)<<dp(1,0);
     
	return 0;
}

Measured memory_bytes: 79616
h,n = map(int, input().split())
ab = []
for i in range(n):
    a, b = map(int, input().split())
    ab.append([a,b])

dp = [0]*(h+1)

for i in range(1,h+1):
    mn = 10**9
    for j in ab:
        hp = j[0]
        mp = j[1]  
        if i-hp<0:
            mn = min(mp,mn)
        else:
            mn = min(dp[i-hp]+mp, mn)
        dp[i] = mn

print(dp[h])


Measured memory_bytes: 42092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
            var an = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).OrderByDescending(i => i).ToArray();
            var sum = an.Sum();
            Console.WriteLine((sum ) <= an[NM[1] - 1] * (4 * NM[1]) ? "Yes":"No");
        }
    }
}

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

###
# main
if(__name__ == '__main__'):
    # input
    k, n = map(int, input().split(" "))
    a = list(map(int, input().split(" ")))

    a.sort()

    d_max = 0
    for elem in range(0,len(a)):
        d = 0
        if elem == len(a) - 1:
            d = k - a[elem] + a[0]
        else:
            d = a[elem+1] - a[elem]

        if d > d_max:
            d_max = d

    ans = k - d_max
    
    print(ans)
# else:
    # do nothing


Measured memory_bytes: 25452
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((pow(2,n,p)-1-com[a]-com[b])%p)


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	vint A(N); cin >> A;
	vint cnt(N, 0);
	vint base;
	for (int i = 0; i < N; i++) cnt[--A[i]]++;
	sort(rbegin(cnt), rend(cnt));
	
	vint rsum(N);

	for (int i = N-1; i >= 0; i--) {
		rsum[i] = cnt[i];
		if (i < N-1) rsum[i] += rsum[i+1];
	}

	int t = N;
	int k = 0;
	for (int K = 1; K <= N; K++) {
		while (t > 0) {
			while (cnt[k] > t) k++;
			int sum = k * t + rsum[k];
			if (sum >= K * t) {
				cout << t << el;
				break;
			}
			t--;
		}
		if (t == 0) cout << 0 << el;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])

        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<iostream>
using namespace std;

int bubble(int A[], int n) {
    int flag = 1;
    int count = 0;
    while(flag) {
        flag = 0;
        for (int i = n - 1; i > 0; i--) {
            if (A[i] < A[i-1]) {
                swap(A[i], A[i-1]);
                count++;
                flag = 1;
            }
        }
    }
    return count;
}

int main() {
    int n, count;
    int A[100];
    cin >> n;
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    count = bubble(A, n);
    for (int i = 0; i < n; i++) {
        if(i) printf(" ");
        printf("%d", A[i]);
    }
    cout << endl;
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 3284
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node* NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key) {
      cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (NodePointer)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = (NodePointer)malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	deleteKey(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 33820
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
struct edge{
	int to,next,len;
}e[N*4]; 
int tot,m,n,first[N],dep[N],fa[N],num;
void add(int u,int v){
	e[++tot].next=first[u],first[u]=tot;
	e[tot].to=v;
}
void bfs(){
	queue<int>q;
	q.push(1);
	while(!q.empty()){
		int now=q.front();q.pop();num++;
		for(int i=first[now];i;i=e[i].next){
			int u=e[i].to;
			if(dep[u]!=-1)continue;
			dep[u]=dep[now]+1;fa[u]=now;
			q.push(u);
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	memset(dep,-1,sizeof(dep));
	dep[1]=0;
	bfs();
	if(num!=n)return puts("No"),0;
	puts("Yes");
	for(int i=2;i<=n;i++)printf("%d\n",fa[i]);
}

Measured memory_bytes: 10132
#include<stdio.h>
int main(void){
    char s[5]={0};
    int i;
    int flag=1;
    scanf("%s",s);
    for(i=0;i<3;i++){
        if(s[i]==s[i+1]){
            flag=0;
        }
    }
    if(flag==0){
        printf("Bad");
    }else{
    printf("Good");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
           int g[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
           int k;
           cin>>k;
           cout<<g[--k]<<endl;
}

Measured memory_bytes: 3644
class Node:
    def __init__(self, key, parent=None, left=None, right=None):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right
         
 
def get_minimum(node):
    x = node
    while x.left is not None:
        x = x.left
    return x
 
class Tree:
    def __init__(self):
        self.root_node = None
         
    def insert(self, z):
        y = None # y stands for the parent of x
        x = self.root_node # root node
        # First, we ascend the tree until the point where we insert the new node
        while x is not None:
            y = x # set parent
            if z.key < x.key:
                x = x.left # move to the left child
            else:
                x = x.right # move to the right child
        # insert z under y
        z.parent = y
         
        if y is None:
            # when the tree is empty
            self.root_node = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
     
    def find(self, k):
        x = self.root_node
        while (x is not None) and (x.key != k):
            x = x.left if (k < x.key) else x.right            
        return x
 
    def delete_node(self, z):
        # determine y, the node to be deleted
        y = z if ((z.left is None) or (z.right is None)) else get_minimum(z.right)
        # determine x, the child of y (note that y has at most one child)
        x = y.left if (y.left is not None) else y.right
        # set the parent of x (if x is not None)
        if x is not None:
            x.parent = y.parent
         
        if y.parent is None:
            self.root_node = x
        elif y is y.parent.left:
            y.parent.left = x
        else:
            y.parent.right = x
         
        if y is not z:
            z.key = y.key
    
 
    def print_preorder(self, node):
        print(f" {node.key}", end="")
        if node.left is not None:
            self.print_preorder(node.left)
        if node.right is not None:
            self.print_preorder(node.right)
 
    def print_inorder(self, node):
        if node.left is not None:
            self.print_inorder(node.left)
        print(f" {node.key}", end="")
        if node.right is not None:
            self.print_inorder(node.right)
 
    def print_nodes(self):
        if self.root_node is None:
            pass
        else:
            self.print_inorder(self.root_node)
            print("")
            self.print_preorder(self.root_node)
            print("")
         

tree = Tree()

m = int(input())
for _ in range(m):
    command = input().split()
    if command[0] == 'print':
        tree.print_nodes()
    elif command[0] == 'find':
        node = tree.find(int(command[1]))
        print("no") if (node is None) else print("yes")
    elif command[0] == 'delete':
        x = tree.find(int(command[1]))
        tree.delete_node(x)
    else:
        key = int(command[1])
        new_node = Node(key)
        tree.insert(new_node)




Measured memory_bytes: 85296
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back

#define int int64_t
struct node {
    node() {
        go[0] = go[1] = nullptr;
    }
    node* go[2];
};

int hc[3] = {1, 2, 1};
int f(int lvl) {
    if (lvl % 4 != 3)
        return hc[lvl % 4];
    else
        return 4 * f(lvl / 4);
}

int dfs(node* v, int lvl) {
    if (v == nullptr)
        return f(lvl);

    return dfs(v->go[0], lvl - 1) xor dfs(v->go[1], lvl - 1);
}

int32_t main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();
    int L = input<int>();

    node* root = new node();
    for (int i = 0; i != n; ++i) {
        node* cur = root;
        for (char ch: input<string>()) {
            if (cur->go[ch - '0'] == nullptr)
                cur->go[ch - '0'] = new node();
            cur = cur->go[ch - '0'];
        }
    }

    cout << (dfs(root, L) == 0 ? "Bob\n" : "Alice\n");
    
    
    return 0;
}


Measured memory_bytes: 6508
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int x, y;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int ans = INF;
    cin >> x >> y;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            int X = x * (!i ? 1 : -1);
            int Y = y * (!j ? 1 : -1);
            if (Y >= X)
                chmin(ans, Y - X + i + j);
        }
    }

    cout << ans << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

int main(){
int a,t=0,h=0,lt,lh,tt,hh,l;
cin >> a;
string taro,hana;
for(int i=0; i<a; ++i){
cin >> taro >> hana;
lt= taro.length();
lh= hana.length();
if(lt>lh){
l=lt;
}
else{
l=lh;
}
tt=0;
hh=0;

if(taro>hana){
t=t+3;
}
else if(hana>taro){
h=h+3;
}
else if(hana==taro){
h=h+1;
t=t+1;
}
}
cout<<t<<" "<<h<<endl;

    return 0;
}

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

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n != 0){
			int [] sum = new int[301];
			Arrays.fill(sum, 1);
			for(int i = 2; i * i <= 289 ; i++){
				
				for(int j=0; j <= 300;j++){
					if(j - i*i >= 0){
						sum[j] += sum[j - i*i];
					}
				}
			}
			
			System.out.println(sum[n]);
			n = sc.nextInt();
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<string> arr(n);
	for(string& s : arr) {
		cin >> s;
		sort(s.begin(), s.end());
	}
	
	sort(arr.begin(), arr.end());
	ll ans = 0;
	
	for(int i = 0, j = 0; i < n; i = j) {
		for(; j < n && arr[i] == arr[j]; j++);
		ans += 1LL * (j - i) * (j - i - 1) / 2;
	}
	
	cout << ans << endl;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  //ll n; cin>>n;
  ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  ll buf2 = 0;
  ll buf3 = 0;
  bool judge = true;
  //cout<<<<endl;
  for(i=0,buf=a;buf<=b;i++) buf*=2;
  cout<<i<<endl;

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){

  }
  */

  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n);
    for(auto&& i : a){
        cin >> i;
    }
    a.push_back(t + m);
    int now = 0, ans = 0;
    for(int i = 0; i < a.size(); i++){
        ans += max(0, a[i] - now - m);
        now = a[i] + m;
    }
    cout << ans << "\n";
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

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

const int INF = 100000002;
const int mod = 1000000007;
//const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}




mint modPow(mint a, int n){
	//cout << a << endl;
	if(n == 1) return a;
	if(n % 2) return a * modPow(a, n-1);
	else return modPow(a*a, n/2);
}


int main(){
	int n, k; cin >> n >> k;
	mint ans = 0;
	vector<mint> d(k+1);
	for(int i=k; i>0; i--){
		ll cnt = k/i;
		d[i] = modPow(cnt, n);
		int mult = 2;
		while(k>=mult*i){
			d[i] -= d[i*mult];
			
			mult++;
		}
		ans += d[i]*i;		
	}

	cout << ans << endl;
}

Measured memory_bytes: 4052
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

#[allow(unused_macros)]
macro_rules! dbg { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; }

#[fastout]
fn main() {
    input! {
        mut n: usize,
        x: usize,
        m: usize,
    }
    let mut memo = vec![vec![(0, 0); m]; 35];
    memo[0] = (0..m).map(|i| (i, (i * i) % m)).collect();
    for d in 1..35 {
        for i in 0..m {
            let (c1, p) = memo[d - 1][i];
            let (c2, p) = memo[d - 1][p];
            memo[d][i] = (c1 + c2, p);
        }
    }
    let mut ans = 0;
    let mut x = x;
    for d in (0..35).rev() {
        if (n >> d) & 1 == 1 {
            ans += memo[d][x].0;
            x = memo[d][x].1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 58208
S = input()
n = len(S)
total = 0
for i in range(2**(n-1)) :
  fo = ''
  fo = S[0]
  for j in range(n-1) :
    if ((i >> j) & 1) :
      fo += '+' 
    fo += S[j+1]
  total += sum(map(int,fo.split('+')))
print(total)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=100005;
int main()
{
  long long int t,w,n,a,r,ans,x=0;
  char s[5];
  scanf("%lld",&n);
  a=w=r=t=0;
  for(int i=0;i<n;i++){
    scanf("%s",s);
    if(s[0]=='A') a++;
    if(s[0]=='W') w++;
    if(s[0]=='T') t++;
    if(s[0]=='R') r++;
  }
  printf("AC x %lld\n",a);
   printf("WA x %lld\n",w);
    printf("TLE x %lld\n",t);
     printf("RE x %lld\n",r);
 /* int neg,pos,zer;
  while(t--){
    neg=pos=zer=0;
    scanf("%d",&n);
    a=(n-1)/2;
    
    for(int i=0;i<n;i++) scanf("%d",&ar[i]);
    for(int i=1;i<n-1;i++){
      if(ar[i]>ar[i-1]){
        if(ar[i]<ar[i+1]) ar[i+1]*=-1;
      }
      if(ar[i]<ar[i-1]){
        if(ar[i]>ar[i+1]) ar[i+1]*=-1;
      }
    }
      
    
    
    printf("%lld\n",ans);
     
  }*/
  
    
    return 0;
}

Measured memory_bytes: 3808
#include<cstdio>
#include<bitset>
using namespace std;
bitset<4000020>s;
int n,a,i,sum;
int main(){
	s[0]=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a);
		sum+=a;
		s|=s<<a;
	}
	for(i=sum+1>>1;i<=sum;i++)
	if(s[i]){
		printf("%d",i);
		return 0;
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, s, n) for (int i = s; i < (int)(n); i++)
#define inpv(i, n, v) rep(i,n) do {int tmp; cin>>tmp; v.push_back(tmp);} while(0)
#define outv(i,n,v) rep(i,n) cout << v[i] << endl

void Main() {
    int n;
    cin >> n;
    cout << n/2+n%2;
}


int main() {
    Main();
    return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#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 a, b;
    cin >> a >> b;

    if(a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if(0 < a && 0 < b) cout << "Positive" << endl;
    else if( (-a+b+1)%2 == 0 ) cout << "Positive" << endl;
    else cout << "Negative" << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(a: int, b: int):
    if a > 0:
        print('Positive')
    elif a <= 0 <= b:
        print('Zero')
    else:
        if (b-a) % 2 == 0:
            print('Negative')
        else:
            print('Positive')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

v1 = v[0::2]
v2 = v[1::2]

c1 = Counter(v1)
c2 = Counter(v2)

c1 = c1.most_common()
c2 = c2.most_common()

if c1[0][0] != c2[0][0]:
    ans = n - c1[0][1] - c2[0][1]
else:
    if len(c2) > 1:
        choice_1 = c1[0][1] + c2[1][1]
    else:
        choice_1 = c1[0][1]
    if len(c1) > 1:
        choice_2 = c2[0][1] + c1[1][1]
    else:
        choice_2 = c2[0][1]
    ans = n - (max(choice_1, choice_2))

print(ans)

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

using namespace std;

const long long MOD=1000000007;

long long add_mod(long long x,long long y){
	return (x+y)%MOD;
}

long long sub_mod(long long x,long long y){
	return (x-y+MOD)%MOD;
}

long long mul_mod(long long x,long long y){
	return x*y%MOD;
}

long long inv_mod(long long x){
	if(x == 1) return 1;
	long long d = MOD/x+1;
	return d*inv_mod(x-(MOD%x))%MOD;
}

long long div_mod(long long x, long long y){
	return x*inv_mod(y)%MOD;
}

int b,w;
long long dp[100001];

void solve(){
    long long i,j;
    string str;
    cin >> b >> w;
    dp[b] = 1;
    long long x = 1;
    vector<long long> ans(b+w);
    long long ob=0,bw=1,ow=0;
    long long d2,pd2;
    pd2 = d2 = inv_mod(2);
    long long cb = 1,cw = 1;
    for(i = 0;i < b+w;i++){
        ans[i] = mul_mod(add_mod(ob*2,bw),pd2);
        pd2 = mul_mod(pd2,d2);
        ob = mul_mod(ob,2);
        bw = mul_mod(bw,2);
        if(i >= w-1){
            if(i >= w) cw = mul_mod(cw,i);
            if(i >= w+1) cw = div_mod(cw,i-w+1);
            ob = add_mod(ob,cw);
            bw = sub_mod(bw,cw);
        }
        if(i >= b-1){
            if(i >= b) cb = mul_mod(cb,i);
            if(i >= b+1) cb = div_mod(cb,i-b+1);
            bw = sub_mod(bw,cb);
        }
    }
    for(i = 0;i < ans.size();i++) cout << ans[i] << endl;
}

int main(){
    solve();
}


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


int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << ' ' << X <<  ' ' << Y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <map>
#include <math.h>
using namespace std;

#define Int long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl

int main(){
    string a,b;
    cin >> a >> b;
    string c=a+b;
    double num=0;
    REP(i,c.size()){
        num*=10;
        num+=c[i]-'0';
    }
    double d=sqrt(num);
    int in=d;
    if(d-in>0)NO;
    else YES;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

#define P pair<ll,ll>
#define fs first
#define sc second

signed main(){
    ll h,w;
    cin >> h >> w;
    ll ans = min(h,w);
    if(h % 3 == 0 || w & 3 == 0){
        cout << 0 << endl;
        return 0;
    }

    rep(i,1,h){
        ll temp = max(abs((h-i)*w - i*(w/2)),abs((h-i)*w - i*(w - w/2)));
        ans = min(ans,temp);
    }

    swap(h,w);

    rep(i,1,h){
        ll temp = max(abs((h-i)*w - i*(w/2)),abs((h-i)*w - i*(w - w/2)));
        ans = min(ans,temp);
    }

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

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var A = int.Parse(ss[0]);
            var B = int.Parse(ss[1]);

            if (A >= 13)
            {
                Console.WriteLine(B);
            }
            else if (A <= 5)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(B / 2);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

bool can[100005];
int r, s, p;

int pu(char t) {
    if (t == 'r') return p;
    if (t == 's') return r;
    if (t == 'p') return s;
    return 0;
}

int main() {

    int n, k;
    cin >> n >> k;
    cin >> r >> s >> p;
    
    string t;
    cin >> t;

    int ans = 0;
    for(int i = 0; i < n; i++) {
        if (i-k >= 0) {
            if (t[i] == t[i-k]) {
                if (can[i-k]) can[i] = false;
                else {
                    can[i] = true;
                    ans += pu(t[i]);
                }
            } else {
                can[i] = true;
                ans += pu(t[i]);
            }
        } else {
            can[i] = true;
            ans += pu(t[i]);
        }
        // cout << ans << endl;
        
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

Node * find(Node *x, int k) {
	while ( x != NIL && k != x->key) {
		if ( k < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	return x;
}

void insert (int k ) {
	Node *y = NIL; // yは親、xは現在地のノードを表す
	Node *x = root; // rootから探索する
	Node *z; // zは挿入したいノード

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

	while ( x != NIL) { //xがNILのときは、一番下の葉まで行った時
		y = x; //下に動く前に現在地をとして記憶
		if ( z->key < x->key ) {
			x = x->left;
		} else {
			x = x->right;
		}
	}

	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;
	inorder(u->left);
	printf(" %d" , u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if ( u == NIL ) return;
	printf(" %d" , u->key);
	preorder(u->left);
	preorder(u->right);
}

int main () {
	int n, i, x;
	string com;

	scanf("%d", &n);

	for ( i = 0; i < n; i++ ) {
		cin >> com;
		if ( com == "insert" ) {
			scanf("%d", &x); 
			insert(x);
		} else if ( com == "find" ) {
			scanf("%d", &x);
			Node *t = find(root, x);
			if ( t != NIL ) printf("yes\n");
			else printf("no\n");
		} else if ( com == "print" ) {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 21892
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int main(){
  int n,c;cin>>n>>c;
  int d[c+1][c+1];
  int s[n][n];
  for(int i=1;i<=c;i++)for(int j=1;j<=c;j++)cin>>d[i][j];
  int v[3][c+1];
  for(int i=0;i<c+1;i++){
    v[0][i]=0;v[1][i]=0;v[2][i]=0;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>s[i][j];
      int q=(i+j)%3;
      v[q][s[i][j]]++;
     
    }
  }
  vector<pii>p0,p1,p2;
  for(int i=0;i<3;i++){
    for(int j=1;j<=c;j++){
      int sum=0;
      for(int k=1;k<=c;k++){
        sum+=v[i][k]*d[k][j];
      }
      if(i==0){
        pii p=make_pair(sum,j);
        p0.push_back(p);
      }
      if(i==1){
        pii p=make_pair(sum,j);
        p1.push_back(p);
      }
      if(i==2){
        pii p=make_pair(sum,j);
        p2.push_back(p);
      }
    }
  }
  sort(p0.begin(),p0.end());
  sort(p1.begin(),p1.end());
  sort(p2.begin(),p2.end());
  bool bo[c+1];
  for(int i=0;i<c+1;i++)bo[i]=false;
  int ma=1<<30;
  for(int i=0;i<3;i++){
    int x=p0[i].first;
    bo[p0[i].second]=true;
    for(int j=0;j<3;j++){
      if(bo[p1[j].second])continue;
      int y=p1[j].first;
      bo[p1[j].second]=true;
      for(int k=0;k<3;k++){
        if(bo[p2[k].second])continue;
        int z=p2[k].first;
        ma=min(x+y+z,ma);
      }
      bo[p1[j].second]=false;
    }
    bo[p0[i].second]=false;
  }
  cout<<ma<<endl;
}
  
  
  


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

ll tw[300000];

int main(){
	int N; cin >> N;
	ll A[N], B[N], s = 0;
	tw[0] = 1;
	for(int i=1; i<300000; i++) tw[i] = (tw[i-1]*2)%mod;
	vector<PP> arr;
	rep(i, N){
		int ff;
		cin >> A[i] >> B[i];
		if(A[i] == 0 && B[i] == 0){
			s++;
			continue;
		}
		if(A[i] == 0){
			if(B[i] < 0) ff = 2;
			else ff = 0;
			arr.pb({{0, 1}, ff});
			continue;
		}
		if(B[i] == 0){
			if(A[i] < 0) ff = 1;
			else ff = 3;
			arr.pb({{0, 1}, ff});
			continue;
		}
		if(A[i] < 0){
			if(B[i] < 0) ff = 2;
			else{ ff = 1; swap(A[i], B[i]); }
		}else{
			if(B[i] < 0){ ff = 3; swap(A[i], B[i]); }
			else ff = 0;
		}
		if(A[i] < 0) A[i] = -A[i];
		if(B[i] < 0) B[i] = -B[i];
		ll g = gcd(A[i], B[i]);
		A[i] /= g;
		B[i] /= g;
		arr.pb({{A[i], B[i]}, ff});
	}
	sort(all(arr));
/*	rep(i, arr.size()){
		cout << arr[i].first.first << " " << arr[i].first.second << " " << arr[i].second << endl;
	}
*/	ll ans = 1;
	P now;
	vector<ll> c(4, 0);
	rep(i, arr.size()+1){
		if(i==arr.size()){
			ll cnt = 1;
			rep(x, 4) cnt = (cnt + tw[c[x]]+mod-1)%mod;
			rep(x, 2) cnt = (cnt + (tw[c[x]]+mod-1)*(tw[c[x+2]]-1)%mod)%mod;
			ans = (ans*cnt)%mod;
			break;
		}
		int ff = arr[i].second;
		if(i==0){
			now = arr[i].first;
			c[ff]++;
		}else{
			if(now != arr[i].first){
				ll cnt = 1;
				rep(x, 4) cnt = (cnt + tw[c[x]]+mod-1)%mod;
				rep(x, 2) cnt = (cnt + (tw[c[x]]+mod-1)*(tw[c[x+2]]+mod-1)%mod)%mod;
				ans = (ans*cnt)%mod;
				now = arr[i].first;
				rep(y, 4) c[y] = 0;
				c[ff]++;
			}else{
				c[ff]++;
			}
		}
	}
	cout << (ans+s+mod-1)%mod << endl;
	return 0;
}


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

using namespace std;

int main(){
	double ans = 0;
	int n; cin >> n;
	for(int i = 0; i < n; ++i){
		double x; cin >> x;
		ans += 1/x;
	}
	ans = 1 / ans;
	printf("%.9f", ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,r,b;
    r=0;
    b=0;
    string s;
    cin>>n>>s;
    for (int i=0;i<n;i++){
        if(s[i]=='R') r++;
        else b++;
    }
    if(r>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

/*
#include <thread>
#include <exception>
*/

using namespace std;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;



/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/



int main() {
	double r; cin >> r;

	cout << r * r * 3 << endl;

	return 0;
}

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

int main()
{
    int N;
    string S;

    cin >> N;

    bool is_four = false;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        if (S == "Y")
        {
            is_four = true;
            break;
        }
    }
    if (is_four)
        cout << "Four\n";
    else
        cout << "Three\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 25
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[N];
int D[N],H[N];

void print(int);
void setDepth(int, int);
int setHeight(int);
int getSibling(int);

int main(){
  int n,i,id,l,r,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    T[id].l=l;
    T[id].r=r;
    if(l!=NIL) T[l].p=id;
    if(r!=NIL) T[r].p=id;
  }

  for(i=0;i<n;i++){
    if(T[i].p==NIL) root=i;
  }

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++) print(i);

  return 0;
}


void print(int u){
  printf("node %d: parent = %d, sibling = %d, ",u,T[u].p,getSibling(u));
  int deg=0;
  if(T[u].l != NIL) deg++;
  if(T[u].r != NIL) deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);

  if(T[u].p==NIL) printf("root\n");
  else if(T[u].l==NIL && T[u].r==NIL) printf("leaf\n");
  else printf("internal node\n");
}

void setDepth(int u, int d){
  if(u==NIL) return;
  D[u]=d;
  if(T[u].r!=NIL) setDepth(T[u].r, d+1);
  if(T[u].l!=NIL) setDepth(T[u].l, d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].l != NIL) h1=(setHeight(T[u].l)+1);
  if(T[u].r != NIL) h2=(setHeight(T[u].r)+1);
  H[u] = (h1>h2 ? h1:h2);
  return H[u];
}

int getSibling(int u){
  if(T[u].p==NIL) return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;
  return NIL;
}


Measured memory_bytes: 2076
loop {
  n = gets.to_i
  break if n.zero?

  a = n.times.map { gets.to_i }

  ans = -Float::INFINITY
  cur = 0

  a.each do |v|
    if cur < 0
      cur = v
    else
      cur += v
    end

    ans = cur if ans < cur
  end

  puts ans
}



Measured memory_bytes: 6904
a,b,c,x,y=map(int,input().split())

ans=2000000000
for i in range(max(x,y)+1):
    total=i*2*c
    if i < x:
        total += (x-i)*a
        
    if i < y:
        total += (y-i)*b
    ans=min(ans,total)
print(ans)  

Measured memory_bytes: 3060