akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)


int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;

	cout << (N - 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
#define CHECK printf("check\n");
void countingSort(int*,int*,int,int);
int countMinimumCost(int*,int*,int);
void printArray(int*,int);
int main(void)
{
  int i;//counter
  int n;//length of array
  int wholeMax=0;//maximum value of array
  int *arr;//array sorted by minimum cost sort
  int *sortedArr;//array sorted by counting sort
  int cost;
  scanf("%d",&n);
  arr=(int*)malloc(sizeof(int)*n);
  sortedArr=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&arr[i]);
      if(wholeMax<arr[i]) wholeMax=arr[i];
    }
  countingSort(arr,sortedArr,n,wholeMax);
  cost=countMinimumCost(arr,sortedArr,n);
  printf("%d\n",cost);
  return 0;
}
void countingSort(int *arr,int *sortedArr,int n,int max)
{
  int i;//counter
  int *countArr=(int*)malloc(sizeof(int)*(max+1));
  for(i=0;i<max+1;i++) countArr[i]=0;
  for(i=0;i<n;i++) countArr[arr[i]]++;
  for(i=1;i<max+1;i++) countArr[i]+=countArr[i-1];
  for(i=n-1;i>=0;i--)
    {
      sortedArr[countArr[arr[i]]-1]=arr[i];
      countArr[arr[i]]--;
    }
}
int countMinimumCost(int *arr,int *sortedArr,int n)
{
  int i;//counter
  int *isSortedArr=(int*)malloc(sizeof(int)*n);
  int begin;//first index that is not sorted yet
  int index;//index pointing now
  int count;//length of loop
  int sum;//sum of loop
  int min;//minimum value among loop
  int wholeMin;//minimum value in the array
  int currentCost[2];//2 pattern of sorting cost in one loop
  int sumCost=0;//sum of whole cost;
  //init isSortedArr
  wholeMin=arr[0];
  begin=n;
  for(i=0;i<n;i++)
    {
      if(arr[i]==sortedArr[i]) isSortedArr[i]=1;
      else isSortedArr[i]=0;
      if(wholeMin>arr[i]) wholeMin=arr[i];
      if(isSortedArr[i]==0&&begin==n) begin=i;
    }
  
  for(;begin<n;begin++)
    {
      if(isSortedArr[begin]==0)
	{
	  index=begin;
	  sum=0;
	  min=arr[index];
	  for(count=1;;count++)
	    {
	      isSortedArr[index]=1;
	      sum+=arr[index];
	      if(min>arr[index]) min=arr[index];
	      for(i=begin+1;i<n;i++)
		{
		  if(arr[i]==sortedArr[index]&&isSortedArr[i]==0) break;
		}
	      if(i==n) break;
	      index=i;
	    }
	  currentCost[0]=sum-min+min*(count-1);
	  currentCost[1]=(wholeMin+min)*2+(sum-min+wholeMin*(count-1));
	  if(currentCost[0]<currentCost[1]) sumCost+=currentCost[0];
	  else sumCost+=currentCost[1];
	}
    }
  return sumCost;
}
void printArray(int *arr,int n)
{
  int i;//counter
  for(i=0;i<n;i++)
    {
      if(i>0) printf(" ");
      printf("%d",arr[i]);
    }
  printf("\n");
}



Measured memory_bytes: 2108
//#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>

#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e15;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

const int MAX_N=200005;
bool isPrime[MAX_N];
void eratos(){
  for(int i=0;i<MAX_N;i++)isPrime[i]=true;
  isPrime[0]=isPrime[1]=false;
  for(int i=0;i<MAX_N;i++){
    if(isPrime[i]){
      for(int j=i+i;j<MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
}

signed main(){
  eratos();
  int n,p;
  while(cin>>n>>p){
    if(n==-1&&p==-1)break;
    vector<int> ans;
    int tmpp=101;
    int s=n+1;
    while(tmpp){
      if(isPrime[s]){
        int tmpq=101;
        int t=s;
        while(tmpq){
          if(isPrime[t]){
            ans.push_back(s+t);
            tmpq--;
          }
          t++;
        }
        tmpp--;
      }
      s++;
    }
    sort(all(ans));

    cout<<ans[p-1]<<endl;
  }


 return 0;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
#include <atcoder/mincostflow>

using namespace std;
using namespace atcoder;

const int max_n = 55, inf = 1000111222;

int n, m;
string a[max_n];

int get_num(int x, int y) {
    return x * m + y;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    const int v = n * m;
    const int s = v;
    const int t = s + 1;
    mcf_graph<int, int> g(t + 1);
    int sum = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == 'o') {
                g.add_edge(s, get_num(i, j), 1, 0);
                sum += i + j;
                ++cnt;
            }
            if (a[i][j] != '#') {
                g.add_edge(get_num(i, j), t, 1, -i - j + n + m);
                for (int dx = 0; dx < 2; ++dx) {
                    const int dy = dx ^ 1;
                    int x = i + dx, y = j + dy;
                    if (x < n && y < m && a[x][y] != '#') {
                        g.add_edge(get_num(i, j), get_num(x, y), inf, 0);
                    }
                }
            }

        }
    }
    auto res = g.flow(s, t);
    int ans = (n + m) * cnt - res.second - sum;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

int main()
{
    int n, l;
    cin >> n >> l;
    int z = INF, x, ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (z > abs(l + i))
        {
            z = abs(l + i);
            x = l + i;
        }
        ans += l + i;
    }
    ans -= x;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b / a) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int N;
	long long An=0;
	int A[200000];
	long long B[200000]={0};
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
		A[i]-=1;
		B[A[i]]++;
	}
	for(int i=0;i<N;i++){
		An+=B[i]*(B[i]-1)/2;
	}
	long long Bn;
	for(int i=0;i<N;i++){
		Bn=An;
		Bn-=B[A[i]]*(B[A[i]]-1)/2;
		Bn+=(B[A[i]]-1)*(B[A[i]]-2)/2;
		printf("%lld\n",Bn);
	}
}

Measured memory_bytes: 4864
z=input().split()
a=int(z[0])
b=int(z[1])
c=int(z[2])
goukei=a+b+c
count = 0
if a == b and b == c:
    print(0)
    exit()
while 1:
  count += 1
  
  goukei = goukei + 2
#   print(str(count)+':'+str(goukei))
  if goukei>=max([a,b,c])*3 and goukei%3 == 0:
    print(count)
    break

Measured memory_bytes: 9112
A,B=map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)
        
    if arr==[]:
        if n!=1:
            arr.append(n)

    return arr

print(len(set(factorization(A)) & set(factorization(B)))+1)

Measured memory_bytes: 38512
#include <iostream>

using namespace std;

int N,M;

int a[2005], b[2005];
long long int c[2005];

long long int dis[1005];

int main(void) {

	cin >> N>>M;

	int tmp1; long long int tmp2;

	for (int i = 1; i <= M; i++) {
		cin >> tmp1; a[i] = tmp1;
		cin >> tmp1; b[i] = tmp1;
		cin >> tmp2; c[i] = tmp2;
	}

	for (int i = 1; i <= N; i++) {
		dis[i] = -10000000000002;
	}

	dis[1] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (dis[b[j]] < dis[a[j]] + c[j]) { dis[b[j]] = dis[a[j]] + c[j]; }
		}
	}


	long long int save = dis[N];

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (dis[b[j]] < dis[a[j]] + c[j]) { dis[b[j]] = dis[a[j]] + c[j]; }
		}
	}

	if (save!=dis[N]) { cout << "inf" << endl; }
	else { cout << dis[N] << endl; }

	//system("pause");
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;

int main(){
    int N, K; cin >> N >> K;
    vector<ll> a(N);
    for(auto &x : a) cin >> x;
    ll l=0, r=1e9+5;
    while(r-l > 1){
        ll mid=l+(r-l)/2;
        ll cnt=0;
        bool ok=true;
        for(int i=0; i<N; i++){
            cnt+=(a[i]+mid-1)/mid-1;
            if(cnt > K) ok=false;
        }
        if(ok) r=mid;
        else l=mid;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;

struct edge {
    int to;
    ll cost;
};

struct status {
    ll cost;
    int v;

    bool operator<(const status &another) const { return cost < another.cost; };

    bool operator>(const status &another) const { return cost > another.cost; };
};


int n;
vector<vector<edge>> graph;
vector<ll> dis;

const ll INF = 1145141919810364364;

void dijkstra(int s) {
    priority_queue<status, vector<status>, greater<>> que;
    dis = vector<ll>(n, INF);
    dis[s] = 0;
    que.push({0, s});

    while (!que.empty()) {
        status now = que.top();
        que.pop();

        if (dis[now.v] < now.cost)continue;

        for (auto &next:graph[now.v]) {
            if (dis[next.to] > dis[now.v] + next.cost) {
                dis[next.to] = dis[now.v] + next.cost;
                que.push({dis[next.to], next.to});
            }
        }
    }
}

int main() {
    int m, start;
    cin >> n >> m >> start;
    graph = vector<vector<edge>>(n);
    for (int i = 0; i < m; i++) {
        int from, to, cost;
        cin >> from >> to >> cost;
        graph[from].push_back({to, cost});
    }

    dijkstra(start);

    for (int i = 0; i < n; i++)cout << (dis[i] == INF ? "INF" : to_string(dis[i])) << endl;
    return 0;
}


Measured memory_bytes: 19400
#include <iostream>

using namespace std;

int main(){
  int a[7] = {1, 3, 5, 7, 8, 10, 12};
  int b[5] = {4, 6, 9, 11};
  int x, y;
  bool flag = false;
  cin >> x >> y;
  for(int i = 0; i < 7; i++){
    if(x == a[i]){
      for(int j = i; j < 7; j++){
        if(y == a[j]){
          flag = true;
        }
      }
    }
  }
  for(int i = 0; i < 5; i++){
    if(x == b[i]){
      for(int j = i; j < 5; j++){
        if(y == b[j]){
          flag = true;
        }
      }
    }
  }
  
  if(flag)  cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import math
a=input().split()
A=int(a[0])
B=int(a[1])
H=int(a[2])
M=int(a[3])
M_deg=M*6
H_deg=H*30+M*0.5

HM_deg=abs(H_deg-M_deg)

Y=math.cos(math.radians(HM_deg))
x=math.sqrt(A*A+B*B-2*A*B*Y)
print(x)


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

namespace ABC146_D___Coloring_Edges_on_Tree
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var connections = new List<int>[N + 1];
            var edges = new List<int>[N + 1];
            var edgeColor = new int[N - 1];
            for (int i = 0; i < N + 1; i++)
            {
                connections[i] = new List<int>();
                edges[i] = new List<int>();
            }
            for (int i = 0; i < N - 1; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var a = ab[0]; var b = ab[1];
                connections[a].Add(b);
                connections[b].Add(a);
                edges[a].Add(i);
                edges[b].Add(i);
            }
            Console.WriteLine(edges.Select(n => n.Count).Max());

            var queue = new Queue<int>();
            queue.Enqueue(1);
            var parentColor = new int[N + 1];
            while (queue.Count > 0)
            {
                var currentNode = queue.Dequeue();
                var color = 1;
                for (int i = 0; i < connections[currentNode].Count; i++)
                {
                    var currentEdge = edges[currentNode][i];
                    if (edgeColor[currentEdge] != 0) continue;
                    if (color == parentColor[currentNode]) color++;
                    edgeColor[currentEdge] = color;
                    parentColor[connections[currentNode][i]] = color;
                    color++;
                    queue.Enqueue(connections[currentNode][i]);
                }
            }
            foreach (int i in edgeColor) Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 38284
#include"bits/stdc++.h"
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	long long sum=b,temp;
	vector<long long> x;
	for(int i=0;i!=a;++i){
		cin>>temp;
		x.push_back(temp);
	}
	for(int i=1;i!=a;++i)
		sum+=min(b,x[i]-x[i-1]);
	cout<<sum;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 998244353;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 3*(int)1e3 + 10;

int n, s;

int32_t main(){_
   
   cin>>n>>s;

   vector<int> polynomial(s+1);
   
   polynomial[0] = 2;
   int x;
   cin >> x;
   if (x <= s){
      polynomial[x] = 1;
   }

   for (int i = 1; i < n; ++i)
   {
      cin >> x;
      vector<int> t(s+1, 0);
      for (int j = 0; j <= s; ++j)
      {
         if (j + x <= s){
            t[j + x] = polynomial[j];
         }
      }
      for(auto &it: polynomial){
         it *= 2;
         it %= mod;
      }
      for (int j = 0; j <= s; ++j)
      {
         polynomial[j] += t[j];
         polynomial[j] %= mod;
      }
   }

   cout<<polynomial[s];

   return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 2e5+10;

int N;
ll cnt[10][10];

int main() {
    cin >> N;
    ll ans = 0;

    FOR (i, 1, N+1) {
        int a = i; while (a >= 10) a /= 10;
        int b = i % 10;
        cnt[a][b]++;
    }

    REP (a, 10) REP (b, 10) {
        ans += cnt[a][b] * cnt[b][a];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func parseToArray2d(lines []string) [][]int64 {
	var result [][]int64
	for _, line := range lines {
		var parsedLine []int64
		for _, element := range strings.Split(line, " ") {
			n, err := strconv.ParseInt(element, 10, 64)
			if err != nil {
				fmt.Printf("Error: element = %v\n", element)
			}
			parsedLine = append(parsedLine, n)
		}
		result = append(result, parsedLine)
	}
	return result
}

func pop(stack []int64) ([]int64, int64) {
	lenStack := len(stack)
	return stack[0:(lenStack - 1)], stack[lenStack-1]
}

func contains(s []int64, e int64) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	content := []string{}
	for scanner.Scan() {
		line := scanner.Text()
		content = append(content, line)
	}
	arr := parseToArray2d(content)
	input := arr[1]

	stack := []int64{}
	result := -1

	for i, x := range input {
		if x > 0 {
			if contains(stack, x) {
				result = i + 1
				break
			} else {
				stack = append(stack, x)
			}
		} else {
			var top int64
			if len(stack) == 0 {
				result = i + 1
				break
			}
			stack, top = pop(stack)
			if top != -x {
				result = i + 1
			}
		}
	}

	if result < 0 {
		fmt.Println("OK")
	} else {
		fmt.Println(result)
	}
}



Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	string ans = "OK";
	if ((a - 1) / k == b / k) ans = "NG";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToArray();
            long ans = 0;
            for (int i = 1; i < N; i++)
            {
                if (A[i - 1] > A[i])
                {
                    long tmp = A[i - 1] - A[i];
                    A[i] += tmp;
                    ans += tmp;
                }
            }
            Console.WriteLine(ans);
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 47940
#include<stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(n==i*j){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main(){
	fast_io;
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5])cout<<"Yes";
	else cout<<"No";

	
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve()
{
	string s;cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	cout<<"Yes";
	else
	cout<<"No";
}
int main()
{
//	int t;cin>>t;
//	while(t--)
	solve();
}


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

int main(){
    int N;
    cin >> N;
    string S[N];
    rep(i,N) cin >> S[i];

    map<string, int> mp;
    rep(i,N) mp[S[i]]++;

    cout << mp.size() << endl;

    return 0;
}

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

int main() {
  int r_0, w_0, c, r;
  while(cin >> r_0 >> w_0 >> c >> r, r_0) {

    for (int x=0; x<1001001001; x++) {
      if (c <= (double)(r_0+x*r)/w_0){
        cout << x << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3088
import std.stdio;
import std.algorithm;
import core.stdc.stdio;

int[] ds;
int[] as;

int[][] dim2arr(int w,int h){
	int[] buf = new int[w*h];
	int[][] ret = new int[][h];
	for(int i=0;i<h;i++){
		ret[i] = buf[i*w..(i+1)*w];
	}
	return ret;
}

int factorial(int a){
	if(a <= 1)
		return 1;
	else
		return a * (a-1).factorial;
}

int unUsed(bool[] used,int idx){
	foreach(int i,ref b;used){
		if(!b){
			if(idx-- == 0){
				b = true;
				return i;
			}
		}
	}
	assert(false);
}

int dMax=0;

bool[] used;
void sequence(int[] dest,int t){
	used[] = false;
	for(int i=0;i<dMax;i++){
		dest[i] = used.unUsed(t % (dMax-i));
		t /= (dMax-i);
	}
}

int[] seqTmp;
int seqIdx(int[] seq){
	used[] = false;
	for(int i=0;i<dMax;i++){
		int c=0;
		for(int j=0;j<dMax;j++){
			if(!used[j]){
				if(j == seq[i]){
					seqTmp[i] = c;
					used[j] = true;
					break;
				}
				c++;
			}
		}
	}
	int res = 0;
	for(int i=dMax-1;i>=0;i--){
		res *= (dMax-i);
		res += seqTmp[i];
	}
	return res;
}

void step_insert(int[] seq,int t,int idx){
	int c=0;
	for(int i=0;i<dMax;i++){
		if(seq[i] == 0){
			if(i < idx){
				idx--;
			}
			continue;
		}
		seq[c++] = seq[i]-1; 
	}
	for(int i=idx;i<dMax;i++){
		swap(seq[i],t);
	}
}

int[][] dp;

void main(){
	int n;
	scanf("%d",&n);
	ds = new int[n];
	as = new int[n];
	
	for(int i=0;i<n;i++){
		scanf("%d",&ds[i]);
		dMax = max(dMax,ds[i]);
	}
	used = new bool[dMax];
	seqTmp = new int[dMax];
	
	for(int i=0;i<n;i++){
		scanf("%d",&as[i]);
	}
	
	int dFact = dMax.factorial;
	
	dp = dim2arr(dFact,n);
	
	
	int[] seq = new int[dMax];
	bool[] ate = new bool[dMax];
	
	for(int k=0;k<dFact;k++){
		
		sequence(seq,k);
		ate[] = false;
		int sum=0;
		foreach(i;seq){
			ate[i] = true;
			for(int j=max(0,i-ds[i]);j<min(dMax,i+ds[i]+1);j++){
				if(!ate[j])
					sum += as[i];
			}
		}
		dp[0][k] = sum;
	}
	
	for(int i;i<n-dMax;i++){
		for(int j=0;j<dFact;j++){
			for(int k=0;k<dMax+1;k++){
				int s = dp[i][j];
				sequence(seq,j);
				int c=0;
				foreach(l;seq[0..k]){
					if(dMax-l <= ds[i+l]){
						s += as[i+l];
					}
				}
				foreach(l;seq[k..dMax]){
					if(dMax-l <= ds[i+dMax]){
						s += as[i+dMax];
					}
				}
				seq.step_insert(dMax-1,k);
				int si = seq.seqIdx;
				dp[i+1][si] = max(dp[i+1][si],s);
			}
		}
	}
	
	int ri = max(0,n-dMax);
	int ans = 0;
	for(int i=0;i<dFact;i++){
		ans = max(dp[ri][i],ans);
	}
	
	printf("%d\n",ans);
}

Measured memory_bytes: 4136
#include <stdio.h>

int main() {
	int a, b;
	int answer;
	scanf("%d %d",&a,&b);
	for (int i = 0; i < 2; i++) {
		if (a >= b) {
			answer += a;
			a--;
		}
		else {
			answer += b;
			b--;
		}
	}
	printf("%d", answer);
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;
import java.util.Map;
import java.util.HashMap;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if((Math.abs(b-a) <= d && Math.abs(c-b) <= d) || Math.abs(c-a) <= d){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}	
}


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

typedef long long ll;
const int N = 20, N2 = 65554, mod = 1000000007;

int n, K, ALL;
int k[N], f[N][N2];
int fact[N2], finv[N2];

inline void add(int &x, const int y) {x += y - mod, x += x >> 31 & mod;}
inline void fma(int &x, const int y, const int z) {x = (x + (ll)y * z) % mod;}
ll PowerMod(ll a, int n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

void init(int n) {
	int i;
	for (*fact = i = 1; i <= n; ++i) fact[i] = (ll)fact[i - 1] * i % mod;
	finv[n] = PowerMod(fact[n], mod - 2);
	for (i = n; i; --i) finv[i - 1] = (ll)finv[i] * i % mod;
}

inline ll A(int n, int r) {return n < r ? 0 : (ll)fact[n] * finv[n - r] % mod;}

int main() {
	int i, j, c, r, ans = 0;
	scanf("%d%d", &n, &K), ALL = ~(-1 << n), init(ALL + 1);
	for (i = 0; i < K; ++i) scanf("%d", k + i), --k[i];
	std::reverse(k, k + K), **f = 1;
	for (i = 0; i < K; ++i)
		for (j = 0; j <= ALL; ++j) if (r = f[i][j]) {
			add(f[i + 1][j], r);
			for (c = 0; c < n; ++c) if (!(j >> c & 1))
				fma(f[i + 1][j | 1 << c], r, (A(ALL - j - k[i], ~(-1 << c)) << c) % mod);
		}
	for (i = 0; i <= ALL; ++i)
		ans = (ans + ll(parity(i) ? -f[K][i] : f[K][i]) * fact[ALL & ~i]) % mod;
	ans = ((ll)ans << n) % mod;
	printf("%d\n", ans + (ans >> 31 & mod));
	return 0;
}


Measured memory_bytes: 7768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x, n; scanf("%d%d",&N,&x);
  vector<int> stk; n = N;
  while(N--) {
    int foo; scanf("%d",&foo);
    stk.push_back(foo);
  }
  sort(stk.begin(), stk.end());
  int ans = 0;
  for(auto& it: stk) {
  	if(x - it >= 0) ++ans, x -= it;
  }
  printf("%d", ans - (ans == n && x != 0 ? 1 : 0));
  return 0;
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (U == S) {
        A --;
    } else {
        B --;
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
t,*b='.'*102
q=range(101)
for s in[*open(i:=0)][1:]:
 a=[i];i+=1
 for x,y,z,c in zip(b,t+s,s,q):a+=min(c+(t>z<x),a[-1]+(t>z<y)),
 b,q=s,a[1:]
print(a[-2])

Measured memory_bytes: 9044
/* Coached by Dukkha */
#include <stdio.h>
#include <stdlib.h>

#define N 100

int aa[N], bb[N], cc[N], dd[N];

int compare_i(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return aa[j] - aa[i];
}

int compare_j(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return dd[i] - dd[j];
}

int main() {
	static char used[N];
	static int ii[N], jj[N];
	int n, i, j, cnt;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &aa[i], &bb[i]);
		ii[i] = i;
	}
	for (j = 0; j < n; j++) {
		scanf("%d%d", &cc[j], &dd[j]);
		jj[j] = j;
	}
	qsort(ii, n, sizeof *ii, compare_i);
	qsort(jj, n, sizeof *jj, compare_j);
	cnt = 0;
	for (j = 0; j < n; j++) {
		int j_ = jj[j], c = cc[j_], d = dd[j_];

		for (i = 0; i < n; i++) {
			int i_ = ii[i], a = aa[i_], b = bb[i_];

			if (!used[i_] && a < c && b < d) {
				used[i_] = 1;
				cnt++;
				break;
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

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

using namespace std;

int main(void){
  int a[3][3],work[3][3];
  rep(i,3){
    rep(j,3){
      cin >> a[i][j];
      work[i][j] = 0;
    }
  }
  int n;
  cin >> n;
 
  rep(i,n){
    int b;
    cin >> b;
    rep(j,3){
      rep(k,3){
	if(a[j][k] == b){
	  work[j][k] = 1;
	}
      }
    }
  }

  bool flag = false;
  if(work[0][0]*work[1][1]*work[2][2] == 1 || work[0][2]*work[1][1]*work[2][0] == 1)
    flag = true;
  rep(i,3){
    if(work[i][0]*work[i][1]*work[i][2] == 1)
      flag = true;
    if(work[0][i]*work[1][i]*work[2][i] == 1)
      flag = true;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import copy
import bisect







def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input())
m=nCast(input().split())



def func():
    s=set(m)
    while len(s)>1:
        l=list()
        for n in s:
            l.append(n)
        l.sort()
        s=set()
        s.add(l[0])
        for n in l:

            k=n%l[0]
     
            if k==1:
                return k
            if k!=0:
                s.add(n%l[0])
    for i in s:
        return i
    

print(func()) 



Measured memory_bytes: 17552
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int h,w;cin>>h>>w;string tmp;
	for(int i=1;i<=w+2;i++) cout<<"#";
	cout<<"\n";
	for(int i=1;i<=h;i++){
		cout<<"#";cin>>tmp;cout<<tmp;cout<<"#\n";
	}
	for(int i=1;i<=w+2;i++) cout<<"#";
	cout<<"\n";
}


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

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


	if(n==1){
		cout<<"Hello World"<<endl;
		return 0;
	}else{
		cin>>a>>b;
		cout<<a+b<<endl;
		return 0;
	}

}

Measured memory_bytes: 256
// Last Change: 06/25/2019 18:55:38.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

ll N, A, B, C, X;

ll NextVal(ll x) {
  return (A * x + B) % C;
}

ll Solve() {
  ll ans = 0;
  vector<ll> Y(N);
  for (auto &&e : Y) {
    cin >> e;
  }

  for (ll i = 0; i < N; ++i) {
    while (X != Y[i]) {
      ++ans;
      X = NextVal(X);
      if (ans > 10000) {
        return -1;
      }
    }
    ++ans;
    X = NextVal(X);
  }
  return ans - 1;
}

int main() {
  while (cin >> N >> A >> B >> C >> X and N > 0) {
    cout << Solve() << endl;
  }
}



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

   int sumdigit(int p)
   {

        int rem,sumdgt=0,i;
        for(i=1;i<=5;i++)
        {
            rem=p%10;
            p=p/10;
            sumdgt=sumdgt+rem;

        }

        return sumdgt;
   }
 int main()
 {
   int n,a,b,j,sum=0,sumt;

   scanf("%d%d%d",&n,&a,&b);

   for(j=1;j<=n;j++)
   {
        sumt=sumdigit(j);
        if(sumt>=a && sumt<=b)
          sum=sum+j;

   }

     printf("%d",sum);




 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,K;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> K;
}

int solve(){
    ll ans=min(N%K,abs(N%K-K));
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		long a,b,z,A,B;
		while(scan.hasNext()){
			a = scan.nextInt();
			b = scan.nextInt();
			z = 1;
			A = a;
			B = b;
			while(z != 0){
				z = a % b;
				a = b;
				b = z;
			}
			for(int i = 1 ; i > 0 ; i++){
				if(A*B == a*i){
					System.out.println(a + " " + i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 19428
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e6;

int main()
{
    double ans=0;
    int n;
    double rate=380000;
    cin>>n;
    rep(i,n)
    {
        double x;
        string s;
        cin>>x>>s;
        if(s=="BTC")x*=rate;
        ans+=x;
    }
    cout<<ans;
    
}

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

int main()
{
	int N;
	int A[3][110]={};
	
	cin >> N;
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=N;j++)
		{
			cin >> A[i][j];
			A[i][j]+=max(A[i-1][j],A[i][j-1]);
		}
	}
	
	cout << A[2][N] << endl;
	return 0;
}

Measured memory_bytes: 256
suits = ['S','H','C','D']

table = [[False]*14 for i in range(4)]

N = int(input())

for loop in range(N):

    mark,num = input().split()
    num = int(num)

    if mark == 'S':
        table[0][num] = True
    elif mark == 'H':
        table[1][num] = True
    elif mark == 'C':
        table[2][num] = True
    else:
        table[3][num] = True

for i in range(4):
    for k in range(1,14):
        if table[i][k] == False:
            print("%s %d"%(suits[i],k))



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

int* lower_bound(int *l,int *r,int val){
    int n=r-l;
    int lb=-1,ub=n;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(*(l+mid)>=val)ub=mid;
        else lb=mid;
    }
    return l+ub;
}

void fill_n(int *l,int n,int val){
    for(int i=0;i<n;i++)*(l+i)=val;
}
const int INF=1001001001;
int N;
int dp[100010];

int main(){
    cin>>N;
    fill_n(dp,N+2,INF);
    dp[0]=-1;

    for(int i=0;i<N;i++){
        int A;cin>>A;
        *lower_bound(dp,dp+N+3,A)=A;
    }

    cout<<lower_bound(dp,dp+N+3,INF)-dp-1<<endl;
}

Measured memory_bytes: 1548
#include <string>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<pair<int, int>> q(Q);
    for (int i = 0; i < Q; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        q[i] = pair<int, int>(a, b);
    }
    vector<int> imos(S.size() + 1, 0);
    for (int i = 1; i <= S.size(); i++)
    {
        if (S[i - 1] == 'A' && S[i] == 'C')
        {
            imos[i + 1] = imos[i] + 1;
        }
        else
        {
            imos[i + 1] = imos[i];
        }
    }

    for (int i = 0; i < Q; i++)
    {
        cout << imos[q[i].second + 1] - imos[q[i].first + 1] << endl;
    }
}

Measured memory_bytes: 2176
fn main() {
  
  let xy = read::<u64>();
  let (mut x, y) = (xy[0], xy[1]);
  let mut cnt = 1;
  loop {
    x *= 2;
    if x <= y {
      cnt += 1;
    } else {
      break;
    }
  }
  println!("{}", cnt);
}

fn read<T: std::str::FromStr>() -> Vec<T> {
  gets().split_whitespace().filter_map(|s|s.parse().ok()).collect()
}

fn gets() -> String {
  let mut line = String::new();
  std::io::stdin().read_line(&mut line).ok();
  line.trim().to_string()
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;

int main(){
    ll N,Q; cin>>N>>Q;
    ll value[N+1]; FILL(value,N+1,0LL);
    queue<ll> edge[N+1];
    bool use[N+1]; FILL(use,N+1,false);
    REP(count,N-1){
        ll a,b; cin>>a>>b;
        edge[a].push(b);
        edge[b].push(a);
    }
    REP(count,Q){
        ll p,x; cin>>p>>x;
        value[p] += x;
    }
    queue<ll> que;
    que.push(1);
    use[1] = true;
    while(!que.empty()){
        ll cur = que.front();
        que.pop();
        while( !edge[cur].empty() ){
            ll next = edge[cur].front();
            edge[cur].pop();
            if(use[next]==false){
              value[next] += value[cur];
              use[next] = true;
              que.push(next);
            }
        } 
    }
    for(int i=1;i<=N;++i){
        if(i<N){ printf("%Ld ",value[i]);}
        else{ printf("%Ld\n",value[i]); }
    }
}


Measured memory_bytes: 140032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

struct ModInt {
    using M = ModInt;

    static vector<M> fact, finv;
    static long long MOD;
    long long v;

    // normalize: [-MOD, MOD**2] -> [0, MOD)
    ModInt(const long long _v = 0) : v((_v < 0) ? _v % MOD + MOD : _v % MOD) {}

    M operator+(const M& x) const { return M(v + x.v); }
    M operator-(const M& x) const { return M(v - x.v); }
    M operator*(const M& x) const { return M(v * x.v); }
    M operator/(const M& x) const { return M(v * x.inv().v); }
    M& operator+=(const M& x) { return *this = *this + x; }
    M& operator-=(const M& x) { return *this = *this - x; }
    M& operator*=(const M& x) { return *this = *this * x; }
    M& operator/=(const M& x) { return *this = *this / x; }
    bool operator==(const M& x) const { return v == x.v; }
    bool operator!=(const M& x) const { return v != x.v; }
    friend istream& operator>>(istream& input, M& x) {
        return input >> x.v, x = M(x), input;
    }
    friend ostream& operator<<(ostream& output, const M& x) {
        return output << x.v;
    }
    inline M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    inline M inv() const { return this->pow(MOD - 2); }
    static void build(int n) {
        fact.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
        finv.assign(n + 1, fact[n].inv());
        for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
    }
    static M comb(int n, int k) {
        if (n < k || k < 0) return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int& x, int& y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    map<P, int> mp;
    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        if (a | b) {
            ll g = abs(__gcd(a, b));
            a /= g;
            b /= g;
        }
        mp[P(a, b)]++;
    }
    map<P, int> c = mp;
    int z = c[P(0, 0)];
    c[P(0, 0)] = 0;
    ModInt ans = 1;
    for (auto&& p : mp) {
        ll a, b;
        tie(a, b) = p.first;
        int x = c[P(a, b)] + c[P(-a, -b)];
        int y = c[P(-b, a)] + c[P(b, -a)];
        c[P(a, b)] = c[P(-a, -b)] = c[P(-b, a)] = c[P(b, -a)] = 0;
        ans *= ModInt(2).pow(x) + ModInt(2).pow(y) - 1;
    }
    cout << ans + z - 1 << endl;
}

Measured memory_bytes: 65984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	char C;
	while (!isdigit(C = getchar_unlocked()));
	N = C - '0';
	while (isdigit(C = getchar_unlocked())) N = N * 10 + C - '0';

	int A[300010];
	A[0] = 0;
	rep(i, N) {
		A[i + 1] = A[i];
		if (getchar_unlocked() == 'W') A[i + 1]++;
	}

	int kotae = 1e9;
	rep(i, N) {
		kotae = min(kotae, A[i] + N - i - 1 - A[N] + A[i + 1]);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
#define ll long long
int a[100005];
int main(int argc, char const *argv[])
{
    int n;
    int sum = 0;
    cin >> n;
    memset(a, 0, sizeof a);
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i <= n; i++) sum += abs(a[i]-a[i+1]);
    for (int i = 1; i <= n; i++)
        printf("%d\n", sum+abs(a[i-1]-a[i+1])-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1])));
    return 0;
}

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

typedef long long ll;

bool exist[110];

int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	memset(exist, 0, sizeof(exist));
		
	ll n, ans = 0;
	cin>>n;

	while(n--) {
		ll a;
		cin>>a;
		if(exist[a] == 0) ans++;
		exist[a] = 1;
	}

	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if (N <= K) {
    cout << X * N << endl;
  } else {
    cout << K * X + (N - K) * Y << endl;
  }
  return 0;
}

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

namespace AthleteProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = getint();
            string[] input = getsplit();
            string[] a = new string[n];
            string[] b = new string[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = input[i];
                b[i] = input[i];

            }
            for (int i = 0; i < n; i++)
            {
                for (int j = n - 1; j > i; j--)
                {
                    if (a[j][1] < a[j - 1][1])
                    {
                        string k = a[j];
                        a[j] = a[j - 1];
                        a[j - 1] = k;
                    }
                }
            }
            for (int i = 0; i < n - 1; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.WriteLine(a[n - 1]);
            Console.WriteLine("Stable");
            for (int i = 0; i < n; i++)
            {
                int minj = i;
                for (int j = i; j < n; j++)
                {
                    if (b[j][1] < b[minj][1])
                    {
                        minj = j;
                    }
                }
                if (i != minj)
                {
                    string k = b[i];
                    b[i] = b[minj];
                    b[minj] = k;
                }
            }
            for (int i = 0; i < n - 1; i++)
            {
                Console.Write(b[i] + " ");
            }
            Console.WriteLine(b[n - 1]);
            bool s = true;
            for (int i = 0; i < n; i++)
            {
                if (a[i] != b[i])
                {
                    s = false;
                    break;
                }
            }



            if (s)
            {
                Console.WriteLine("Stable");
            }
            else
            {
                Console.WriteLine("Not stable");
            }
        }
        static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
    }
}

Measured memory_bytes: 9020
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
	int a,b;
	int sum;
	scanf("%d %d",&a,&b);
	sum = a*b;
	if(sum%2 == 0)
		printf("Even\n");
	else
		printf("Odd\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;
  
public class Main {
      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
          
        while(sc.hasNextLine()){
            Stack<Double> stack = new Stack<Double>();
 
            for(String s : sc.nextLine().split(" ")){
                if(s.equals("+")){
                    double d2 = stack.pop();
                    double d1 = stack.pop();
                    stack.push(d1 + d2);
                }else if(s.equals("-")){
                    double d2 = stack.pop();
                    double d1 = stack.pop();
                    stack.push(d1 - d2);
                }else if(s.equals("*")){
                    double d2 = stack.pop();
                    double d1 = stack.pop();
                    stack.push(d1 * d2);
                }else if(s.equals("/")){
                    double d2 = stack.pop();
                    double d1 = stack.pop();
                    stack.push(d1 / d2);
                }else{
                    stack.push(Double.parseDouble(s));
                }
            }
              
            System.out.println(stack.pop());
        }
          
    }
      
}

Measured memory_bytes: 17200
#include <bits/stdc++.h>
#define int long long
#define watch cerr << 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

int32_t main(){

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int h , w ; 
	cin >> h >> w ; 
	cout << ( h==1 or w == 1 ? 1 : (h*w+1)/2 ) << endl ;

	return 0;
}


Measured memory_bytes: 256