akhauriyash/Code-Regression huggingface dataset:
def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(2)]

    kari = 0
    dp = [0 for i in range(num)]
    for i in range(num):
        kari += data[0][i]
        if i == 0:
            dp[0] = kari + data[1][0]
        else:
            dp[i] = max(dp[i - 1], kari) + data[1][i]

    print(dp[num - 1])






if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var) \
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

constexpr auto no_value = numeric_limits<uint64_t>::max();

struct GraphParser {
  GraphParser(vector<vector<int>>& edges_)
      : edges(edges_), start(edges.size(), 0), end(edges.size(), 0) {
  }

  void run() {
    t = 0;
    for (size_t i = 0; i < edges.size(); ++i) {
      if (!start[i]) {
        recur(i);
      }
    }
  }

  void run_stack() {
    t = 0;
    for (size_t j = 0; j < edges.size(); ++j) {
      if (start[j]) continue;
      start[j] = ++t;
      st.push(make_pair(j, 0));
      while(!st.empty()) {
        auto& p = st.top();
        auto v = p.first;
        auto& i = p.second;
        if (i < edges[v].size()) {
          auto v2 = edges[v][i++];
          if (!start[v2]) {
            start[v2] = ++t;
            st.push(make_pair(v2, 0));
          }
        } else {
          end[v] = ++t;
          st.pop();
        }
      }
    }
  }

  vector<vector<int>>& edges;
  vector<int> start;
  vector<int> end;
  stack<pair<int, size_t>> st;
  int t;

 private:
  void recur(int cur) {
    if (start[cur]) {
      return;
    }
    start[cur] = ++t;
    for (auto&& e : edges[cur]) {
      recur(e);
    }
    end[cur] = ++t;
  }
};

int main() {
  int n;
  cin >> n;
  vector<vector<int>> edges(n, vector<int>());
  for (int i = 0; i < n; ++i) {
    int u;
    int k;
    cin >> u >> k;
    edges[u - 1].reserve(k);
    for (int j = 0; j < k; ++j) {
      int v;
      cin >> v;
      edges[u - 1].push_back(v - 1);
    }
  }

  GraphParser p(edges);
  p.run_stack();
  for (int i = 0; i < n; ++i) {
    cout << (i + 1) << " " << p.start[i] << " " << p.end[i] << endl;
  }
}

Measured memory_bytes: 3080
from string import ascii_lowercase, ascii_uppercase
l = ascii_lowercase
u = ascii_uppercase
def conv(c):
    if c in l:
        return u[l.index(c)]
    if c in u:
        return l[u.index(c)]
    return c
open(1, 'w').write("".join(map(conv, open(0).readline())))


Measured memory_bytes: 6684
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn readln<T>() -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().parse().unwrap()
}

fn main() {
    let n = readln();
    let xs: Vec<usize> = reads();

    let mut res = 0;
    for i in 0..n {
        let j = xs[i] - 1;
        if i == xs[j] - 1 {
            res += 1;
        }
    }

    res /= 2;
    println!("{}", res);
}


Measured memory_bytes: 6396
#include <iostream>
#include <set>
#include <list>
using namespace std;

int main(){
     int N;
     while(cin>>N,N){

	  bool isfree[N][31];
	  for(int i=0;i<N;i++){
	       for(int j=0;j<31;j++){
		    isfree[i][j]=false;
	       }
	  }
	  for(int i=0;i<N;i++){
	       int temp;
	       cin>>temp;
	       for(int j=0;j<temp;j++){
		    int n_day;
		    cin>>n_day;
		    isfree[i][n_day]=true;
	       }
	  }
	  list<int> freelist;
	  set<int> mapset[N];
	  set<int> nowmap;
	  bool end_f=false;
	  int ans=-1;
	  for(int i=0;i<N;i++){
	       mapset[i].insert(i);
	  }
	  for(int i=1;i<31;i++){
	       freelist.clear();
	       nowmap.clear();
	       for(int j=0;j<N;j++){
		    if(isfree[j][i]){
			 freelist.push_back(j);
			 nowmap.insert(mapset[j].begin(),mapset[j].end());
		    }
	       }
	       list<int>::iterator itr=freelist.begin();
	       while(itr!=freelist.end()){
		    mapset[*itr].insert(nowmap.begin(),nowmap.end());
		    if(mapset[*itr].size()==N){
			 end_f=true;
			 ans=i;
			 break;
		    }
		    itr++;
	       }
	       if(end_f)break;
	  }
	  cout<<ans<<endl;
     }
}

Measured memory_bytes: 976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt()
				,b = scanner.nextInt()
				,c = scanner.nextInt();
		
		int ans = 0;
		for (int i = 0; i <= a; i++) {
			int total =0;
			char[] nums = String.valueOf(i).toCharArray();
			for (int j = 0; j < nums.length; j++) {
				String s = String.valueOf(nums[j]);
				total += Integer.parseInt(s);
			}
			if (total>=b && total<= c) {
				ans += i;
			}
		}
		
		
		System.out.println(ans);
		
		scanner.close();
	}
}


Measured memory_bytes: 24276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;cin>>n;
  vector<P> v[n];
  int a,b;
  rep(i,n-1){
    cin>>a>>b;
    a--;
    b--;
    v[a].push_back(P(b,i));
    v[b].push_back(P(a,i));
  }
  ll at[n];
  ll ans[n-1];
  rep(i,n-1) ans[i]=0;
  rep(i,n) at[i]=INF;
  int an=0;
  queue<int> q;
  rep(i,n){
    int cnt=1;
    if(at[i]!=INF) continue;
    q.push(i);
    int now;
    while(!(q.empty())){
      now=q.front();q.pop();
      if(at[now]==1){
        continue;
      }
      at[now]=1;
      cnt=1;
      int u=0;
      for(P j:v[now]){
        if(ans[j.se]>0) u=ans[j.se];
        //cout<<u<<endl;
      }
      for(P j:v[now]){
        if(u==cnt) cnt++;
        if(ans[j.se]>0) continue;
        ans[j.se]=cnt;
        an=max(an,cnt);
        q.push(j.fi);
        cnt++;
        //cout<<j.fi<<endl;
      }
    }
  }
  
  cout<<an<<endl;
  rep(i,n-1) cout<<ans[i]<<endl;
}

Measured memory_bytes: 8192
#include <iostream>
using namespace::std;
int main(int argc, const char * argv[]) {
    int H, W;
    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i<H; i++) {
            for (int j = 0; j<W; j++) {
                if (i>=1 && i<H-1 && j>=1 && j<W-1) {
                    cout << ".";
                }
                else{
                cout <<"#";
                }
            }
            cout << endl;
        }
        cout << endl;

    }
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], m = tmp[1];
        int[] results = new int[n];
        for (int i = 0; i < m; i++)
        {
            tmp = ReadIntArray();
            results[tmp[0]-1]++;
            results[tmp[1]-1]++;
        }
        for (int i = 0; i < n; i++)
            WriteLine(results[i]);
    }
}

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

int main(){
	int a,b;
	while(1){
		cin>>a>>b;
		if(a==0&&b==0)break;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				
				if(i%2==0){
					if(j%2==0)cout<<"#";
					else cout<<".";
				}
				
				else {
					if(j%2==0)cout<<".";
					else cout<<"#";
				}
				
				
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
N=int(input())
MOD=10**9+7
#AAA AAC AAG AAT ACA ACC ACG! ACT AGA AGC! AGG AGT ATA ATC ATG ATT
#0   1   2   3   4   5   6    7   8   9    10  11  12  13  14  15

#CAA CAC CAG CAT CCA CCC CCG CCT CGA CGC CGG CGT CTA CTC CTG CTT
#16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31

#GAA GAC! GAG GAT GCA GCC GCG GCT GGA GGC GGG GGT GTA GTC GTG GTT
#32  33   34  35  36  37  38  39  40  41  42  43  44  45  46  47

#TAA TAC TAG TAT TCA TCC TCG TCT TGA TGC TGG TGT TTA TTC TTG TTT
#48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63
ans=[1]*64
ans[6]=0
ans[9]=0
ans[33]=0
for i in range(N-3):
  val=[0]*64
  for j in range(16):
    for k in range(4):
      val[4*j+k]=(ans[j]+ans[j+16]+ans[j+32]+ans[j+48])%MOD
  val[6]=0
  val[9]=0
  val[33]=0
  val[41]=(val[41]-ans[10])%MOD
  val[45]=(val[45]-ans[11])%MOD
  val[57]=(val[57]-ans[14])%MOD
  ans=val
print(sum(ans)%MOD)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vi a(3*n);
	trav(x, a) cin >> x;
	sort(all(a));
	ll ans = 0;
	rep(i,0,3*n)
		if((i+n)%2 == 0 && i >= n) ans += a[i];
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	long long n,m;
	long long ans=1;
	cin>>n>>m;
	cout<<n+1-m;
    return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector< pair<int,int> > p(m);
    for(int i=0;i<n;i++)
        cin >> a[i];
    int ina,inb;
    for(int i=0;i<m;i++){
        cin >> ina >> inb;
        p[i]=make_pair(inb,ina);
    }
    sort(a.begin(),a.end());
    sort(p.begin(),p.end());
    int i=0,flag=0;
    for(int j=m-1;j>=0;j--){
        for(int k=0;k<p[j].second;k++){
            if(a[i]<p[j].first) a[i]=p[j].first;
            else{
                flag=1;
                break;
            }
            i++;
            if(i>=n){
                flag=1;
                break;
            }
        }
        if(flag==1)
            break;
    }
    long long r=0;
    for(int j=0;j<n;j++){
        r+=a[j];
    }
    cout << r << endl;
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll K,X;
    cin >> K >> X;
    for (int i = X-K+1; i <= X+K-1; i++) {
        cout << i;
        if(i == K+X-1){
            cout << endl;
        } else {
            cout << " ";
        }
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
  vll a(n);
  rep(i,0,n) cin >> a[i];
  
  ll now=2;
  ll ans=a[0]-1;
  rep(i,1,n){
   ans+=(a[i]-1)/now;
   if(a[i]==now) now++;  
  }
  cout << ans << endl;
  
}  
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3988
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 12;

int n;
int arr[N];
int ans;
vector <int> vec[N];

void go(int x, long long p) {
  if (x == n) {
    ans += (p % 2 == 0);
    return;
  }
  go(x + 1, p * vec[x][0]);
  go(x + 1, p * vec[x][1]);
  go(x + 1, p * vec[x][2]);
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    vec[i].push_back(arr[i] - 1);
    vec[i].push_back(arr[i]);
    vec[i].push_back(arr[i] + 1);
  }
  go(0, 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    cout << min(N * A, B) << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum = 0; 
    ll ans = 0;
    int r = 0;
    for(int l = 0; l < n; ++l) {
        while(r < n && (sum + a[r]) == (sum ^ a[r])){
            sum+=a[r];
            r++;
        }
        ans += r-l;
        sum ^= a[l];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4032
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    N=int(readline())

    #dfs
    count=0
    stack=deque(["0"])
    while len(stack)>=1:
        t=stack.pop()
        for s in "357":
            now=t+s
            if int(now)>N:
                break
            if ("7" in now) and ("5" in now) and ("3" in now):
                count+=1
            stack.append(now)
    
    print(count)

if __name__=="__main__":
    main()

Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

// ??????g????????????????????\?????????
void insertionSort(int A[], int n, int g) {
  for ( int i = g; i < n; i++ ) {
    int v = A[i];
    int j = i - g;

    while ( j >= 0 && A[j] > v ) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  for ( int h = 1; ;) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i-- ) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;

  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  for ( int i = G.size() - 1; i >= 0; i-- ) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

ll dp[305][305][305];
int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n+1);
    REP(i, n) cin >> a[i+1];

    REP(i, 305) REP(j, 305) REP(k, 305) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    FOR(i, 1, n+1) REP(j, m+1) REP(k, i) {
        ll pre = a[k];
        // 操作しない dp[i+1][j][i] <- dp[i][j][k]
        ll add = 0;
        if(pre > a[i]) add += pre - a[i];
        // dump(i,j,i,"aa",i-1,j,k);
        chmin(dp[i][j][i], dp[i-1][j][k] + add);
        // 操作する dp[i+1][j+1][k] <- dp[i][j][k]
        chmin(dp[i][j+1][k], dp[i-1][j][k]);
    }

    // REP(i, n+1) REP(j, m+1) REP(k, i+1) {
    //     dump(i, j, k, dp[i][j][k]);
    // }

    ll ret = INF;
    REP(i, m+1) REP(j, n+1) chmin(ret, dp[n][i][j]+a[j]);
    cout << ret << endl;

    return 0;
}

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

namespace AtCoder
{
	public class ProblemA
	{
		public static void Main(string[] args)
		{
			string[] line = Console.ReadLine().Split(' ');
			int n = int.Parse(line[0]);
			int m = int.Parse(line[1]);

			int[] dp = new int[n + 1];
			HashSet<int> broken = new HashSet<int>();

			for (int i = 0; i < m; i++)
			{
				int a = int.Parse(Console.ReadLine());
				broken.Add(a);
			}

			dp[0] = 1;
			if (!broken.Contains(1))
			{
				dp[1] = 1;
			}

			for (int i = 2; i <= n; i++)
			{
				if (broken.Contains(i))
					continue;

				dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;	
			}

			Console.WriteLine(dp.Last());
		}
	}
}


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


#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


using namespace std;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;


    int a;
    cin >> a;

    ll ans = 0;

    ans = a + a * a + a * a * a;

    cout << ans << endl;


}


Measured memory_bytes: 3584
#include<iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	while(1){
	int r;
	cin>>r;
	if(r==0)break;
	int n=1000-r;
	int c=0;
	while(1){
		if(n>=500){c++;
		n-=500;}else
	    if(n>=100){c++;
		n-=100;}else
		if(n>=50){c++;
		n-=50;}else
	    if(n>=10){c++;
		n-=10;}else
		if(n>=5){c++;
		n-=5;}else
	    if(n>=1){c++;
		n--;}else{break;}}
	cout<<c<<endl;}
	return 0;}


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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(s,element) (s.find(element)!=s.end())
#define cpresent(c,element) (find(c,element)!=c.end())
#define fi(i,n) for(int i=0;i<int(n);i++)
#define tr(i,a) for(auto i:a)
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
const double PI=acos(-1);
const ll mod=1e9+7;


void add(ll &a, ll b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
void sub(ll &a, ll b)
{
	a-=b;
	if(a<0)a+=mod;
}
ll mul(ll a, ll b)
{
	return ((a*b)%mod);
}

ll p2[200005];

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

int test=1;
//cin>>test;
while(test--)
{
	int n,zer=0,cnta=0,cntb=0; cin>>n;
	map<pll,int> mp1, mp2;
	for(int i=0;i<n;i++)
	{
		ll a,b; cin>>a>>b;
		if(a==0&&b==0)zer++;
		else if(a==0)
		{
			cnta++;
		}
		else if(b==0)
		{
			cntb++;
		}
		else
		{
			ll d=__gcd(a,b);
			a/=d;b/=d;
			if(b<0){a=-a;b=-b;}
			if(a>0)mp1[{a,b}]++;
			else mp2[{a,b}]++;
		}
	}
	p2[0]=1;
	for(int i=1;i<=n;i++)
	{
		p2[i]=mul(p2[i-1],2);
		//cout<<p2[i]<<" ";
	}

	ll ans=p2[cnta];
	add(ans,p2[cntb]);
	sub(ans,1);
	for(auto p:mp1)
	{
		ll a=p.first.first, b=p.first.second;//cout<<a<<" "<<b<<endl;
		ll temp=p2[p.second];//cout<<temp<<endl;
		add(temp,p2[mp2[{-b,a}]]);
		sub(temp,1);
		ans=mul(ans,temp);
		mp2.erase({-b,a});
		//cout<<ans<<endl;
	}
	for(auto p:mp2)
	{
		ans=mul(ans,p2[p.second]);
	}
	add(ans,zer);
	sub(ans,1);
	cout<<ans<<endl;

}
return 0;
}










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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n; cin >> n;

    if (n == 2) {
        cout << 2 << endl;
        return;
    }
    
    while (1) {
        bool m = true;
        for (int i = 2; i * i <= n; ++i) {
            if (n % i == 0) {
                m = false;
                break;
            }
        }
        if (m) {
            cout << n << endl;
            return;
        }
        ++n;
    }
}   

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	if (A+B>C+D){
		cout<<"Left"<<endl;
	}else if (A+B==C+D){
		cout<<"Balanced"<<endl;
	}else{
		cout<<"Right"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll a[100005];
int n, ans;
int main()
{
	cin >> n;
	for(int i = 0; i < n; i ++) 
		cin>>a[i];
	sort(a, a + n);
	for(int i = 0; i < n; i ++) 
	{
		a[i] += a[i - 1];
		ans ++;
		if(a[i] + a[i] < a[i+1]) 
			ans=0;
	}
	printf("%d\n",ans);
	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    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 {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long 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 {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int N;
    string S;
    cin >> N >> S;

    map<char, int> mp({});
    for (int i = 0; i < N; i++) {
        mp[S[i]]++;
    }

    mint ans = 1;
    for (auto p : mp) {
        ans *= mint(p.second + 1);
    }

    ans -= 1;

    cout << ans.x << endl;

    return 0;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)
int n1000,n100,n10,n1,n10000;
long sum=0;

int main(void){
  int n,a,b;
  cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
      n10000=i/10000;
      n1000=(i%10000)/1000;
      n100=(i%1000)/100;
      n10=(i%100)/10;
      n1=(i%10);
      if(a<=n1000+n100+n10+n1+n10000&&b>=n1000+n100+n10+n1+n10000){
        sum+=i;
      }
    }

    cout<<sum<<endl;

return 0;}


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

int main() {
    double r;
    const double PI=3.141592653589;
    cin >> r;
    cout << r*2*PI << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(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 = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> 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; }}

int n;
vector<int> node;

void init(int n_){
	n = 1;
	while(n < n_) n *= 2;
	node.resize(2*n-1, INT_MIN);
}

void update(int x, int val) {
    x += (n - 1);
    node[x] = val;
    while(x > 0) {
        x = (x - 1) / 2;
        node[x] = max(node[2*x+1], node[2*x+2]);
    }
}

int getmax(int a, int b, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    if(r <= a || b <= l) return INT_MIN;
    if(a <= l && r <= b) return node[k];
    int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
    int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
}

int main(){
	int N; cin >> N;
	init(N);
	vector<P> r(N);
	vector<int> p(N);
	rep(i, N){
		cin >> r[i].first >> r[i].second;
		p[i] = r[i].first;
	}
	sort(ALL(r));
	sort(ALL(p));
	ll dp[N+1];
	int right[N];
	rrep(i, N){
		int li = lower_bound(ALL(p), p[i]+r[i].second) - p.begin();
		update(i, i);
		update(i, getmax(i, li));
		right[i] = getmax(i, i+1);
	}
	dp[N] = 1;
	rrep(i, N){
		dp[i] = (dp[i+1] + dp[right[i]+1]) % mod;
	}
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 8576
#include<iostream>
using namespace std;
const int N=100005;
long long  hp[N];
long long  k[N];
long long n,a,b;
bool check(long long  t){
	 for(long long  i=1;i<=n;i++)
	 {
	 	k[i]=hp[i];
	 }
     for(long long  i=1;i<=n;i++)
	 {
         k[i]=k[i]-b*t;
     }
     long long ab=a-b;
     long long cnt=0;
     for(long long  i=1;i<=n;i++){
         if(k[i]>0) 
         {
         	if(k[i]%ab==0)
         	{
         		cnt+=k[i]/ab;
			 }
			 else
			 {
			 	cnt+=k[i]/ab+1;
			 }
		 }
     }
     return cnt<=t;
 }

int  main()
{
	
	cin>>n>>a>>b;
	for(long long  i=1;i<=n;i++)
	{
		cin>>hp[i];
		
	}
	long long  ans=0;
	long long  left=1;
	long long  right=1e9;
	long long  mid;
	while(left<=right)
	{
		mid=(left+right)/2;
		if(check(mid))
		{
			ans=mid;
			right=mid-1;
		}
		else
		{
			left=mid+1;
		}
	}
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}
int main(){
  ll n;cin>>n;
  vl a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(n%2==1){
    cout<<b[n/2]-a[n/2]+1<<endl;
  }
  else{
    ll aa=a[n/2-1]+a[n/2];
    ll bb=b[n/2-1]+b[n/2];
    cout<<bb-aa+1<<endl;
  }
}

Measured memory_bytes: 6364
import java.util.*;

class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int m = sc.nextInt();
    
    int mina = 1000000;
    int minb = 1000000;
    
    int[] ai = new int[a];
    int[] bi = new int[b];
    
    for(int i=0;i<a;i++){
      ai[i] = sc.nextInt();
      if(ai[i]<mina)
        mina = ai[i];
    }
    for(int i=0;i<b;i++){
      bi[i] = sc.nextInt();
      if(bi[i] < minb)
        minb = bi[i];
    }
    
    int[] c  = new int[m];
    int[] x  = new int[m];
    int[] y  = new int[m];
    
    for(int i=0;i<m;i++){
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }
    
    int ans = mina + minb;
    int tmp;
    
    for(int k=0;k<m;k++){
      tmp = ai[x[k]-1] + bi[y[k]-1] -c[k];
      if(tmp<ans)
        ans = tmp;
    }
    
    
    System.out.print(ans);
  }
}

Measured memory_bytes: 132396
n,m,x=map(int,input().split())
l=[]
c=[]
l4=[]
for _ in range(n):
    k=list(map(int,input().split()))
    c.append(k[0])
    l.append(k[1:])

for i in range(2**n):
    l2=[]
    for j in range(n):
        if (i>>j)&1==1:
            l2.append(j)
    l3=[0]*m
    for jj in l2:
        for kk in range(m):
            l3[kk]+=l[jj][kk]
    if min(l3)>=x:
        count=0
        for kkk in l2:
            count+=c[kkk]
        l4.append(count)
if l4==[]:
    print(-1)
else:
    print(min(l4))
    

Measured memory_bytes: 68752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,tot,L[N][2],R[N][2],a[N],rt[N];
struct node
{
    int l,r,sum;
    node(){l=r=sum=0;}
}t[N*40];
int newnode()
{
    tot++;t[tot]=node();return tot;
}
void build(int l,int r,int &now)
{
    if(!now) now=newnode();
    if(l==r) return;
    int m=l+r>>1;
    build(l,m,t[now].l);build(m+1,r,t[now].r);
}
void update(int l,int r,int x,int &now,int pre)
{
    if(!now) now=newnode(),t[now].sum=t[pre].sum;
    t[now].sum++;
    if(l==r) return;
    int m=l+r>>1;
    if(x<=m) update(l,m,x,t[now].l,t[pre].l),t[now].r=t[pre].r;
    else update(m+1,r,x,t[now].r,t[pre].r),t[now].l=t[pre].l;
}
int query(int l,int r,int x,int now,int pre)
{
    if(l>x) return t[now].sum-t[pre].sum;
    if(r<=x) return 0;
    int m=l+r>>1;
    return query(l,m,x,t[now].l,t[pre].l)+query(m+1,r,x,t[now].r,t[pre].r);
}
int query(int l,int r,int x)
{
    return query(1,n,x,rt[r],rt[l-1]);
}
void solve1(int x)
{
    int l=1,r=x,ans;
    while(l<=r)
    {
        int m=l+r>>1;
        if(query(m,x,a[x])==0) ans=m,r=m-1;
        else l=m+1;
    }
    L[x][0]=x-ans+1;
}
void solve2(int x)
{
    int l=x,r=n,ans;
    while(l<=r)
    {
        int m=l+r>>1;
        if(query(x,m,a[x])==0) ans=m,l=m+1;
        else r=m-1;
    }
    R[x][0]=ans-x+1;
}
void solve3(int x)
{
    int l=1,r=x-L[x][0],ans=r;
    if(r<l) return;
    while(l<=r)
    {
        int m=l+r>>1;
        if(query(m,x,a[x])==1) ans=m,r=m-1;
        else l=m+1;
    }
    L[x][1]=x-L[x][0]-ans+1;
}
void solve4(int x)
{
    int l=x+R[x][0],r=n,ans=l;
    if(r<l) return;
    while(l<=r)
    {
        int m=l+r>>1;
        if(query(x,m,a[x])==1) ans=m,l=m+1;
        else r=m-1;
    }
    R[x][1]=ans-x-R[x][0]+1;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    build(1,n,rt[0]);
    for(int i=1;i<=n;i++)
        update(1,n,a[i],rt[i],rt[i-1]);
    for(int i=1;i<=n;i++)
    {
        solve1(i);
        solve2(i);
        solve3(i);
        solve4(i);
    }
    long long ans=0;
    for(int i=1;i<=n;i++)
        ans+=(ll)L[i][0]*R[i][1]*a[i]+(ll)R[i][0]*L[i][1]*a[i];
    printf("%lld\n",ans);
}


Measured memory_bytes: 49408
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a <= 1){ return 1; } else{ return a * fact(a - 1); } }
template<class T> inline ll comb(T a, T b){ return a == 0 ? 0 : fact(a) / fact(b) / fact(a - b); }

int main(){
    ll H, N;
    vector<ll> A;
    cin >> H >> N;
    rep(i, 0, N){
        ll temp;
        cin >> temp;
        A.push_back(temp);
    }
    ll ans = (ll)accumulate(begin(A), end(A), 0ll);
    cout << (ans >= H ?  "Yes" : "No") << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
  string s, ss;
  cin >> s >> ss;
  string ans="YES";
  for(int i=0;i<3;i++){
    if(s[i] != ss[2-i]){
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;
}

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

int main()
{
	int N;
	scanf("%d", &N);
	std::map<std::string, int64_t> count;
	for (int i{}; i < N; i++)
	{
		std::string tmp;
		std::cin >> tmp;
		std::sort(tmp.begin(), tmp.end());
		count[tmp]++;
	}
	int64_t ans{};
	for (auto& e: count)
		ans += e.second * (e.second - 1) / 2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 11136
import sys
input = sys.stdin.readline

n,m,s,t = map(int,input().split())


links_e = [[] for _ in range(n+1)]
links_s = [[] for _ in range(n+1)]
for _ in range(m):
    u,v,a,b = map(int, input().split())
    links_e[u].append((a,v))
    links_e[v].append((a,u))
    links_s[u].append((b,v))
    links_s[v].append((b,u))

# dijkstra
import heapq
def dijkstra(links, start, n):
    inf = 10**10
    d = [inf] * (n+1)
    d[start] = 0
    hq = []
    used = set()
    used.add(start)
    for i in links[start]:
        heapq.heappush(hq, i)
    while(hq):
        cost,i = heapq.heappop(hq)
        if( i in used):
            continue
        d[i] = cost
        used.add(i)
        for tmp in links[i]:
            cost_next, j = tmp
            if(not j in used):
                heapq.heappush(hq, (cost+cost_next, j))
    return d

d_e = dijkstra(links_e, s, n)
d_s = dijkstra(links_s, t, n)

ans = [0] * (n+1)
min_cost = 10**15
for i in range(n,0,-1):
    min_cost = min(min_cost, d_e[i]+d_s[i])
    ans[i] = min_cost

for i in range(1,n+1):
    print(10**15 - ans[i])

Measured memory_bytes: 126004
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

Measured memory_bytes: 504
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
s = []
for i in range(h):
    s.append(ins())
mn = 20000
for t in range(2**(h-1)):
    lbl = [0]*h
    top = 0
    for i in range(1,h):
        if (t>>(i-1))%2==1:
            top += 1
        lbl[i] = top
    #ddprint(f"t {t} mn {mn}")
    #ddprint(lbl)
    sm = [0]*(top+1)
    ans = top
    pos = True
    for j in range(w):
        ok = True
        tmp = [x for x in sm]
        for i in range(h):
            if s[i][j]=='1':
                tmp[lbl[i]] += 1
        if max(tmp)>k:
            ans += 1
            sm = [0]*(top+1)
        for i in range(h):
            if s[i][j]=='1':
                sm[lbl[i]] += 1
        if max(sm)>k:
            pos = False
            break
    if pos and ans<mn:
        mn = ans
print(mn)


Measured memory_bytes: 46300
#include <cstdio>
int N, K, l, r, x, c, a[1000009], v[1000009], p[1000009]; char ch, s[19];
int main() {
	scanf("%d %d\n", &N, &K);
	for (int i = 0; i < N; i++) {
		ch = getchar_unlocked();
		while (48 <= ch && ch <= 57) a[i] = a[i] * 10 + ch - 48, ch = getchar_unlocked();
	}
	for (int i = 0; i < K; i++) {
		while (l != r && v[r - 1] >= a[i]) r--;
		v[r] = a[i], p[r++] = i;
	}
	for (int i = K; i <= N; i++) {
		x = v[l]; c = 0;
		while (x > 0) s[c] = x % 10 + 48, x /= 10, ++c;
		while (--c >= 0) putchar_unlocked(s[c]);
		putchar_unlocked(i == N ? '\n' : ' ');
		if (p[l] == i - K) l++;
		while (l != r && v[r - 1] >= a[i]) r--;
		v[r] = a[i], p[r++] = i;
	}
	return 0;
}


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



int main(){

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

    int A, B ;
    cin >> A >> B ;

    if (A >= 13){

        cout << B ;
        return 0 ;

    }
    if( A >= 6){

        cout << B/2 ;
        return 0 ;

    }
    cout << 0 ;
    return 0 ;

}


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

class B {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        long N, A, B;
        Input(out N, out A, out B);
        if(A == 0) {
            Print(0);
        } else {
            long C = N / (A + B);
            long R = N % (A + B);
            if(R > A) {
                Print(C * A + A);
            } else {
                Print(C * A + R);
            }
        }
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 11220
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

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

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if (T[u].p == NIL) {
    cout << "root, ";
  } else if (T[u].l == NIL) {
    cout << "leaf, "; 
  } else {
    cout << "internal node, ";
  }

  cout << "[";

  for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
    if (i) {
      cout << ", ";
    }
    cout << c;
  }
  cout << "]" << endl;
}

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

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for (i = 0; i < n; i++) {
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for (i = 0; i < n; i++) {
    cin >> v >>d;
    for (j = 0; j < d; j++) {
      cin >> c;
      if (j == 0) {
        T[v].l = c;
      } else {
        T[l].r = c;
      }
      l = c;
      T[c].p = v;
    }
  }

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

  rec(r, 0);

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

  return 0;
}



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

int main() {
	int n; cin >> n;
	vector<int>d(n); for (auto&& x : d)cin >> x;
	sort(d.begin(), d.end());
	int mid = (n - 1) / 2;
	cout << d[mid+1]-d[mid] << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i<n; i++){
    cin >> x[i];
  }
  int d = 1001001001;
  

  for (int i = 0; i <= 100; i++){
    int tmp = 0;
    for (int j = 0; j < n; j++){
      tmp += (x[j] - i) * (x[j] - i);
    }
    if(tmp < d){
      d = tmp;
    }
  }
  cout << d << "\n";
  return 0;
}

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

n = int(input())
blues = []
for i in range(n):
    blues.append(input())

m = int(input())
reds = []
for i in range(m):
    reds.append(input())

variation = list(set(blues + reds))

patterns = [0]

for v in variation:
    patterns.append(blues.count(v) - reds.count(v))

print(max(patterns))

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


int main()
{
	int n;
	cin >> n;
	Vl A(n);
	rep(i, n)  cin >> A[i];
	A.push_back(0);

	ll ans = 1000;
	ll cur = 0;
	ll kb = 0;
	bool f = false;
	for (int i = 0; i < n; i++) {
		if (f) {
			f = false;
			ans = cur + kb * A[i];
			//cout << cur <<" "<<kb << endl;
		}
		if (A[i] < A[i + 1]) {
			kb = ans / A[i];
			cur = ans % A[i];
			//cout << kb <<" "<<cur<< endl;
			f = true;
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 3628