akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]
        self.rank = [0]*(n+1)
        self.weight = [0]*(n+1)

    def find(self,x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def is_same(self,x,y):
        return self.find(x)==self.find(y)

    def union(self,x,y,w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
    def diff(self,x,y):
        return self.weight[x] - self.weight[y]


N,M = list(map(int,input().split()))
un = UnionFind(N)

for i in range(M):
    l,r,w = list(map(int,input().split()))
    if un.is_same(l,r):
        diff = un.diff(l,r)
        if diff != w:
            print('No')
            exit()
    else:
        un.union(l,r,w)

print('Yes')

Measured memory_bytes: 11408
fun main(args: Array<String>) {
    val (r, c) = readLine()!!.split(" ").map(String::toInt)
    val l = mutableListOf<MutableList<Int>>()
    repeat((0 until r).count()) {
        val row = readLine()!!.split(" ").map(String::toInt).toMutableList()
        row.add(row.sum())
        l.add(row)
    }

    l.add((0..c).map { 0 }.toMutableList())
    (0 until r).forEach { i ->
        (0..c).forEach { j ->
            l[r][j] += l[i][j]
        }
    }

    l.map { it.joinToString(" ") }.forEach(::println)
}


Measured memory_bytes: 35144
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int H,W;
vector<vector<int>> b;
int calc(int y) {
    int ret=0;
    stack<pair<int,int>> st;
    REP(j,W) {
        if(st.empty() || st.top().first<b[y][j]) {
            st.push({b[y][j],j});
        } else if(st.top().first>b[y][j]) {
            int idx=0;
            while(!st.empty() && st.top().first>b[y][j]) {
                auto tp=st.top();
                idx=tp.second;
                st.pop();
                chmax(ret,(j-tp.second+1)*tp.first);
            }
            st.push({b[y][j],idx});
        }
    }
    return ret;
}
signed main() {
    cin>>H>>W;
    vector<string> S(H);
    cin>>S;
    b=vector<vector<int>>(H,vector<int>(W,0));
    REP(j,W-1) {
        b[0][j]=1;
        REPF(i,1,H) {
            if((S[i][j]==S[i][j+1])==(S[i-1][j]==S[i-1][j+1])) {
                b[i][j]=b[i-1][j]+1;
            } else {
                b[i][j]=1;
            }
        }
    }
    int ans=max(H,W);
    REP(i,H) {
        chmax(ans,calc(i));
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 35968
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int one = 0;

	unsigned int A;
	unsigned int K, N;
	cin >> N >> K;
	//for (int i = 0; i < N; i++) {
	//	cin >> A;
	//	if (A == 1) one = i;
	//}
	if ((N - 1) % (K - 1) != 0) cout << (N - 1) / (K - 1) + 1	<< endl;
	else						cout << (N - 1) / (K - 1)		<< endl;
	
	return 0;
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(26,vector<int>(N,0));

    rep(i,N) {
        string S;
        cin >> S;
        rep(j,S.size()) {
            int idx = S[j] - 'a';
            A[idx][i]++;
        }
    }
    
    vector<int> B(26,0);
    string ans = "";
    rep(i,26) {
        int n = INF;
        rep(j,N) {
            n = min(n,A[i][j]);
        }
        rep(j,n) {
            char tmp = 'a' + i;
            ans += tmp;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3568
#include<stdio.h>
int main()
{
	int a,i,n,m=101,r;
	r=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		r+=a;
		if(a%2==1&&m>a){
			m=a;
		}
	}
	if(r%2==1)r-=m;
	printf("%d\n",r/2);
	return 0;
}



Measured memory_bytes: 2760
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

P nyaxt[4] = {{1,-1},{1,1},{-1,1},{-1,-1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int x,y;
int op(int nw){
	return nw%3+1;
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int a,b;cin>>a>>b;
	int fib[2] = {0,1};
	P z = {0,0};
	int nw = 0;
	while(true){
		P y;
		y.first = z.first+fib[1]*nyaxt[nw%4].first;
		y.second = z.second+fib[1]*nyaxt[nw%4].second;
		if(nw%4==0){
			if(z.first <= a && a < y.first && y.second < b && b <= z.second){
				cout << op(nw) << endl;
				return 0;
			}
		}else if(nw%4==1){
			if(z.first <= a && a < y.first && z.second < b && b <= y.second){
				cout << op(nw) << endl;
				return 0;
			}
		}else if(nw%4==2){
			if(y.first <= a && a < z.first && z.second < b && b <= y.second){
				cout << op(nw) << endl;
				return 0;
			}
		}else{
			if(y.first <= a && a < z.first && y.second < b && b <= z.second){
				cout << op(nw) << endl;
				return 0;
			}
		}
		z = y;
		fib[0] += fib[1];
		swap(fib[0],fib[1]);
		nw++;
	}

}



Measured memory_bytes: 3168
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <ratio>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;

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

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

const ull C = 1000000007;
int main(){
    auto N = read<ll>();
    auto A = read<ull>(N);
    v<ull> a0(63, 0), a1(63, 0);
    
    ull ans = 0;
    REP(i, 63){
        REP(j, N){
            if(A[j] & (1ULL << i)) a1[i]++;
            else a0[i]++;
        }
        ans += (a1[i] % C) * (a0[i] % C) % C * ((1ULL << i) % C) % C ;
        ans %= C;
    }
    write(ans);
    
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int M;
    ll K;
    cin>>M>>K;
    ll MAX=1;
    rep(i,M) MAX=MAX*2;
    MAX--;
    if(M==1){
        if(K==0) cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    if(K>MAX) cout<<-1<<endl;
    else{
        cout<<K<<" ";
        rep(i,MAX+1){
            if(i==K) continue;
            cout<<i<<" ";
        }
        cout<<K<<" ";
        rep(i,MAX+1){
            if((MAX-i)==K) continue;
            cout<<MAX-i<<" "; 
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
	string s,t;
	cin >> s >> t;
	int cnt,ans=0x3f3f3f3f,ls=s.length(),lt=t.length();
	for (int i=0;i<=ls-lt;i++)
	{
		cnt=0;
		for (int j=0;j<lt;j++)
		{
			if (s[j+i]!=t[j])   cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}

signed main() {
	int a;
	cin >> a;
	cout << 48 - a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){
	
	int n;
	cin>>n;
	vector<vector<int> > comp(n,vector<int>(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>comp[i][j];
		}
	}
	vector<long long> dp(1<<n);
	dp[0]=1;
	

		for(int i=0;i<(1<<(n));i++){
			int m = __builtin_popcount(i);
			for(int w=0;w<n;w++){
				if((i&(1<<w))==0 && comp[m][w]==1){
					int j= (i|(1<<w));
					dp[j]+=dp[i];
					dp[j]%=1000000007;
				}
				
			}
		}
//	}
	
	cout<<dp[(1<<n)-1]%1000000007;
	
}

Measured memory_bytes: 19628
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

const long long INF = 1LL << 60;

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1

int N;
int a[100100];
vector<int> G;
queue<int> q;

void arrayPrint(int array[], int N) {
    rep(i, N) {
        if(i)
            printf(" ");
        printf("%d", array[i]);
    }
    printf("\n");
}

int insertSort(int array[], int N) {
    int cnt = 0;
    int v;
    int j;
    repp(i, 1, N) {
        v = array[i];
        j = i - 1;
        while(j >= 0 && array[j] > v) {
            array[j + 1] = array[j];
            j--;
            cnt++;
        }
        array[j + 1] = v;
        arrayPrint(array, N);
    }
    return cnt;
}

int bubbleSort(int array[], int N) {
    int cnt = 0;
    bool flag = true;
    for(int i = 0; flag; i++) {
        flag = false;
        for(int j = N - 1; j > i; j--) {
            if(array[j] < array[j - 1]) {
                flag = true;
                cnt++;
                swap(array[j], array[j - 1]);
            }
        }
        arrayPrint(array, N);
    }
    return cnt;
}

int selectSort(int array[], int N) {
    int cnt = 0;
    int mini;
    for(int i = 0; i < N - 1; i++) {
        mini = i;
        for(int j = i; j < N; j++) {
            if(array[mini] > array[j]) {
                mini = j;
            }
        }
        if(i != mini) {
            swap(array[i], array[mini]);
            cnt++;
        }
        arrayPrint(array, N);
    }
    return cnt;
}

int insertionSort(int array[], int N, int g) {
    int cnt = 0;
    int v;
    int j;
    repp(i, g, N) {
        v = array[i];
        j = i - g;
        while(j >= 0 && array[j] > v) {
            array[j + g] = array[j];
            j = j - g;
            cnt++;
        }
        array[j + g] = v;
        arrayPrint(array, N);
    }
    return cnt;
}

int shellSort(int array[], int N) {
    int cnt = 0;
    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--) {
        cnt += insertionSort(array, N, G[i]);
        // arrayPrint(array, N);
    }
    return cnt;
}

int main() {
    long long N;
    long long minv = INF;
    cin >> N;
    for(ll i = 1; i * i <= N; i++) {
        if(i * (N / i) == N) {
            minv = min(minv, i + (N / i) - 2);
        }
    }

    cout << minv << endl;
}


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

const int N_MAX = 1e5;
bool is_prime[N_MAX+1];
int like_num[N_MAX+1];

void prime(int n){
  for(int i = 0; i <= n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i <= n; i++){
    if(is_prime[i]){
      for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
  }
}

int main(){
  int Q;
  cin >> Q;
  prime(N_MAX);
  for(int i = 1; i <= N_MAX; i++){
    if(i % 2 && is_prime[i] && is_prime[(i+1)/2]) like_num[i] = like_num[i-1] + 1;
    else like_num[i] = like_num[i-1];
  }
  int ans[Q];
  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    ans[i] = like_num[r] - like_num[l-1];
  }
  for(int i = 0; i < Q; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 1536
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
from fractions import Fraction
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

N = _I()

"""
並び替えた後あまりを計算する
まずは貪欲的に考える
大きい方からあまりが最大になるものをマッチングする
しかしこれだと10**9なので絶対間に合わない
gcdとかいきてきそう
そもそもあまりが
1,2,...Nを割っていく
Nを割ってN余ることはない。
8 % 9は8になる。
ひとつずつずらしていくか
そうすると、1/2n n+1がなりたつ
"""

ans = Fraction(1/2) * Fraction(N) * Fraction(N-1)
print(int(ans))


Measured memory_bytes: 7608
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }
    var max = 0
    var ans = 0
    repeat(n) {
        if (max <= t[it]) {
            ans++
        }
        max = Math.max(max, t[it])
    }
    println(ans)
}

Measured memory_bytes: 31268
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 105, K = 1e5 + 5, MOD = 1e9 + 7;
int n, p, dp[N][K], prefix[N][K], a[N];
 
inline int add(int a, int b){
	a += b;
	if(a >= MOD)a -= MOD;
	return a;
}
 
inline int sub(int a, int b){
	a -= b;
	if(a < 0)a += MOD;
	return a;
}
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
 
	cin>>n>>p;
	for(int i=1;i<=n;++i)cin>>a[i];
 
	for(int i=0;i<=n;++i)dp[i][0] = prefix[i][0] = 1;
	for(int j=0;j<=p;++j)prefix[0][j] = 1;
 
	for(int i=1;i<=n;++i)
		for(int j=1;j<=p;++j){
			// coefficient of x^j is prefix[i - 1][j - a[i] : j];
 
			int first = (j - a[i] - 1 >= 0)? prefix[i - 1][j - a[i] - 1] : 0;
			int last = prefix[i - 1][j];
			dp[i][j] = add(dp[i][j], sub(last, first));
			prefix[i][j] = add(prefix[i][j - 1], dp[i][j]);
		}
 
	cout<<dp[n][p]<<"\n";
	return 0;
}

Measured memory_bytes: 82176
N = int(input())
H = input().split()
H = [int(x) for x in H]

c = 0
for i in range(N):
  h = H[i]
  T = "Y"
  for j in range(i):
    if h < H[j]:
      T = "N"
  if T == "Y":
    c +=1
print(c)

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL p(n);
	cin >> p;
	LL ans = 0;
	map<LL,LL> mp;
	for (int i = 0; i < n; i++) {
		mp[p[i]] = i; // インデックスの保持
	}
	multiset<int> st = {-1,-1, n,n};
	for (int i = n; i >= 1; i--) {
		auto itr = st.lower_bound(mp[i]);
		int r = *itr;
		++itr;
		int rr = *itr;
		--itr;
		--itr;
		int l = *itr;
		--itr;
		int ll = *itr;
		ans += (rr - r) * (mp[i] - l) * i;
		ans += (l - ll) * (r - mp[i]) * i;
		st.insert(mp[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12032
#include<stdio.h>
int main(void)
{
double r;
double M_PI=3.14159265359,menseki=0,enshu=0;
scanf("%lf",&r);
menseki=r*r*M_PI;
enshu=2*r*M_PI;
printf("%.6lf  %.6lf\n",menseki,enshu);
return 0;
}

Measured memory_bytes: 652
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] b = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			b[i] = sc.nextInt();
		}
		int[] a = new int[n];
		a[0] = b[0];
		a[n - 1] = b[n - 2];
		int sum = a[0] + a[n - 1];
		for (int i = 1; i < n - 1; i++) {
			a[i] = Math.min(b[i - 1], b[i]);
			sum += a[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23764
N = int(input())

dp = [[0] * 10 for _ in range(10)]
for n in range(1, N + 1):
    # last
    i = n % 10

    # first
    while n >= 10:
        n //= 10
    j = n % 10

    dp[i][j] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += dp[i][j] * dp[j][i]

print(ans)


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


inline ll pow5(const int &a) {
        return (ll) a * a * a * a * a;
}


void _main() {
        int x; cin >> x;
        for (int a = -200; a < 200; a++) {
                for (int b = -200; b < 200; b++) {
                        if (pow5(a) - pow5(b) == x) {
                                cout << a << ' ' << b;
                                return;
                        }
                }
        }

}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

from collections import Counter

def main(N,A):
    a = b = 0
    count = Counter(A)
    length = sorted(set(A), reverse=True)
    for i in length:
        if(count[i]>=4 and a==b==0):
            a = b = i
            break
        elif(count[i]>=2 and a==0):
            a = i
        elif(count[i]>=2 and b==0):
            b = i
            break
    print(a*b)

if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    main(N,A)

Measured memory_bytes: 20644
#要素の根を探す関数
def find_root(n,parts):
    root=[]
    n=n-1
    #根をnとして返す
    while(parts[n][0]!=n):
        root.append(n)
        n=parts[n][0]
    #途中で見つけた要素は全てnに繋ぐことで経路圧縮
    for i in root:
        parts[i][0]=n
    #partsをタプルで返す
    return tuple(parts[n])

#入力を受け取る
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]

#partsの1つ目は根の番号、2つ目は深さ、3つ目は接続されている要素数
parts=[[i,1,1] for i in range(N)]
ans=[N*(N-1)//2]

#橋の数-1だけ処理を行う（橋が全部かかっているときは不便度0なので）
for i in range(M-1):
    #一番最後に壊れた橋を探す
    ab=AB.pop()
    #それぞれの要素の根を探す
    a=find_root(ab[0],parts)
    b=find_root(ab[1],parts)
    #木構造が深い方をaとする
    if a[1]>=b[1]:
        a,b=a,b
    else:
        b,a=a,b
    #根が同一ならば処理不要
    if a[0]==b[0]:
        ans.append(ans[-1])
    #根が違うのであれば、以後木をくっつける処理を行う
    else:
    #要素x個の木と要素y個の木が繋がれば不便度はxyだけ減る
        ans.append(ans[-1]-a[2]*b[2])
    #bの根にaを接続する
        parts[b[0]][0]=parts[a[0]][0]
    #接続後のaの深さは(aの深さ)と(bの深さ+1)の大きい方
        parts[a[0]][1]=max(parts[a[0]][1],parts[b[0]][1]+1)
    #aの要素数+bの要素数が接続後のaの要素数
        parts[a[0]][2]+=parts[b[0]][2]
#答えを出力
for i in reversed(ans):
    print(i)

Measured memory_bytes: 38216
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
	int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

const int N = 2010;
int n, k;
int sum[2][N][N];

int b;
inline int Calc(int xl, int yl, int Col) {
	if (xl > k || yl > k) return 0;
	int xr = min(k, xl + b - 1), yr = min(k, yl + b - 1);
	chkmax(xl, 1); chkmax(yl, 1);
	return sum[Col][xr][yr] - sum[Col][xl - 1][yr] - sum[Col][xr][yl - 1] + sum[Col][xl - 1][yl - 1];
}

int main () {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
	n = read();
	k = read() * 2;
	For (i, 1, n) {
		int x = read() % k + 1, y = read() % k + 1;
		char str[5]; scanf ("%s", str + 1);
		if (str[1] == 'W') ++sum[0][x][y];
		else ++ sum[1][x][y];
	}
	For (i, 1, k)
		For (j, 1, k) {
			sum[0][i][j] += sum[0][i - 1][j] + sum[0][i][j - 1] - sum[0][i - 1][j - 1];
			sum[1][i][j] += sum[1][i - 1][j] + sum[1][i][j - 1] - sum[1][i - 1][j - 1];
		}

	int ans = 0;
	b = k / 2;
	For (i, -b + 1, b)
		For (j, -b + 1, b) {
			int res1 = 0, res2 = 0;
			For (qx, 0, 2)
				For (qy, 0, 2) {
					int x = i + qx * b, y = j + qy * b;
					res1 += Calc(x, y, (qx + qy) & 1);
					res2 += Calc(x, y, !((qx + qy) & 1));
				}
			chkmax(ans, max(res1, res2) );
		}
	cout << ans << endl;
    return 0;
}


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

int main()
{
  long long n, k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  int i, ans;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i) >> b.at(i);
  }
  vector<long long> count(100001);
  for(i = 0; i < n; i++)
  {
    count.at(a.at(i)) += b.at(i);
  }
  for(i = 1; i <= 100000; i++)
  {
    k -= count.at(i);
    if(k <= 0)
    {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
string S;
#define MAXN 5020
ll dp[MAXN+1][MAXN+1];
int main(){
    int N;cin >> N;
    rep(i,N+1)rep(j,N+1)dp[i][j] = 0;
    cin >> S;
    
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            if(S[i]==S[j]){
                dp[i+1][j+1] = dp[i][j]+1;
            }else{
                dp[i+1][j+1] = 0;
            }
        }
    }
    ll ma = 0;
    rep(i,N){
        for(int j=i+1;j<N+1;j++){
            if(dp[i][j]+i<=j)ma = max(ma,dp[i][j]);
        }
    }

    cout << ma << endl;
    return 0;

}

Measured memory_bytes: 196864
n =int(input())
yes = True
primesand10=[10,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
if n <= 10:
  yes = True
elif n <= 81:
  for prime in primesand10:
    if n%prime == 0:
      yes = False
      break
else:
  yes = False

if yes:print("Yes")
else: print("No")

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int a[n+1]; rep(i, n) cin >> a[i];
  a[n] = 0;
  
  int ans = 0;
  rep(all, 100) {
    rep(i, n) {
      rep(j, n) {
	if(a[j] != 0 && a[j+1] == 0) ++ans;
      }
      rep(k, n) {
	a[k] -= (a[k]!=0);
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
//abc129_b.cpp
//Sat Aug 10 20:22:44 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	int ans = INTINF;

	for (int i=0;i<n;i++){
		int first = 0;
		int second = 0;
		for (int j=0;j<n;j++){
			if (j<=i){
				first += w[j];
			}else {
				second += w[j];
			}
		}
		if (ans > abs(first-second)){
			ans = abs(first-second);
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
long long a[9];
struct P { string p; };
bool operator<(P a, P b) {
	if (a.p.length() > b.p.length()) return false;
	else if (a.p.length() < b.p.length()) return true;
	else return a.p < b.p;
}
int main() {
	int n;
	while (cin >> n) {
		P b[10000];
		for (int i = 0; i < n; i++) cin >> b[i].p;
		sort(b, b + n);
		int f = 0,e=min(4,n);
		for (int i = 0; i < e; i++) {
			for (int j = 0; j < e; j++) {
				if (i != j) {
					a[f] = stoll(b[i].p + b[j].p);
					f++;
				}
			}
		}
		sort(a, a + f);
		cout << a[2] << endl;
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int INF = 10000;
int d[20][20];
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
char maze[20][20];
int h, w, hw;
int l = 0;
bool flg = true;
int bfs(int sx, int sy) {
  int hwc = 0;
  queue<P> que;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      d[i][j] = INF;
  que.push(P(sx, sy));
  d[sx][sy] = 0;
  while (hw > hwc && que.size()>0) {
    P p = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (0 <= nx && nx < h && 0 <= ny && ny < w && maze[nx][ny] != '#'
          && d[nx][ny] == INF) {
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
        if (l < d[nx][ny]) {
          l = d[nx][ny];
        }
      }
    }
    hwc++;
  }
  return l;
}
int main() {
  string s;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> s;
    for (int j = 0; j < w; j++) {
      maze[i][j] = s[j];
    }
  }
  hw = h * w;
  int ans = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (maze[i][j] == '.')
        ans = max(ans, bfs(i, j));
  cout << ans;
  return 0;
}


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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split(' ');
            long N = long.Parse(S[0]);
            long A = long.Parse(S[1]);
            long B = long.Parse(S[2]);
            long total = A + B;
            long ans;
     
            ans = (N / total) * A;
            ans += Math.Min(A,(N % total));

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 13140
# -*- Coding: utf-8 -*-
def trace(A, N):
    for i in range(int(N)-1):
        print(A[i], end=' ')
    print(A[int(N)-1])

def insertionSort(A, N):
    for i in range(1, int(N)):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1]  = v
        trace(A, N)

if __name__ == '__main__':
    N = input()
    A = list(map(int, input().split()))
    
    trace(A, N)
    insertionSort(A, N)



Measured memory_bytes: 5980
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    A,B,C,D = inputMap()
    tmp = A*B
    tmp2 = C*D
    print(max(tmp,tmp2))
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 40688
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
	string str1,str2;
	cin>>str1>>str2;

	int cnt=0;
	for(int i=0;i<str1.size();i++)
	{
		if(str1[i]!=str2[i])
			cnt++;
	}
	cout<<cnt;
  return 0;
}


Measured memory_bytes: 3792
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

fn main() {
    input!{
        h: usize,
        w: usize,
        s_v: [chars; h],
    }

    // 塗らなければならないマスのうち、上下左右に隣接するマスすべてが塗ってはならないマスであった場合 'No'
    for (i, row) in s_v.iter().enumerate() {
        for (j, s) in row.iter().enumerate() {
            if *s == '.' { continue; }

            if j > 0 {
                // 左
                if s_v[i][j-1] == '#' {
                    continue;
                }
            }

            if j < w-1 {
                // 右
                if s_v[i][j+1] == '#' {
                    continue;
                }
            }

            if i > 0 {
                // 上
                if s_v[i-1][j] == '#' {
                    continue;
                }
            }

            if i < h-1 {
                // 下
                if s_v[i+1][j] == '#' {
                    continue;
                }
            }

            println!("No");
            return;
        }
    }

    println!("Yes");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

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

signed main(){
    int N,M; cin>>N>>M;
  	int ans = N+M;
    if(ans<10) Out(ans);
  	else Out("error");
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int v1,v2,l[10];
    int lSum;
    int d;
    
    int i;
    
    while(1){
        if(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9])!=10)return 0;
        lSum=0;
        for(i=0;i<10;i++)lSum+=l[i];
        scanf("%d,%d",&v1,&v2);
        for(i=0,d=0;i<10&&d<((double)v1*((double)lSum/((double)v1+(double)v2)));d+=l[i++]){}
        printf("%d\n",i);
    }
    
    return 0;
}



Measured memory_bytes: 2028
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, _ := sc.NextInt()
	a, b := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = sc.NextInt()
		b[i], _ = sc.NextInt()
	}
	ans := solve(n, a, b)
	fmt.Println(ans)
}

const mod = 1000000007

type pair struct {
	x, y int
}

func solve(n int, a, b []int) (ans uint) {
	zero := uint(0)
	count := map[pair]*pair{}
	for i := 0; i < n; i++ {
		x, y := a[i], b[i]
		if x == 0 && y == 0 {
			zero++
			continue
		}
		if y < 0 || y == 0 && x < 0 {
			x, y = rotate180(x, y)
		}
		rot90 := x <= 0
		if rot90 {
			x, y = rotate90(x, y)
		}
		g := gcd(x, y)
		x, y = x/g, y/g
		key := pair{x, y}
		if count[key] == nil {
			count[key] = &pair{}
		}
		if rot90 {
			count[key].y++
		} else {
			count[key].x++
		}
	}

	ans = 1
	for _, v := range count {
		c1, c2 := v.x, v.y
		now := uint(1)
		now = (now + ModPow(2, uint(c1), mod) - 1) % mod
		now = (now + ModPow(2, uint(c2), mod) - 1) % mod
		ans = ModMul(ans, now, mod)
	}
	ans = (ans + zero - 1 + mod) % mod
	return ans
}

func rotate180(x1, y1 int) (x2, y2 int) {
	return -x1, -y1
}

func rotate90(x1, y1 int) (x2, y2 int) {
	return y1, -x1
}

func gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}

// ModMul returns a*b with mod
func ModMul(a, b, mod uint) uint {
	if b == 0 {
		return 0
	}
	if a*b/b == a {
		return a * b % mod
	}
	panic("overflow")
}

// ModPow returns base^n with mod
func ModPow(base, n, mod uint) uint {
	ans := uint(1)
	for ; n > 0; n >>= 1 {
		if n&1 == 1 {
			ans = ModMul(ans, base, mod)
		}
		base = ModMul(base, base, mod)
	}
	return ans
}


Measured memory_bytes: 22808
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
//
#define MAX_TIME 100000
#define MAX_NAME 100
#define MAX_PROCESS 100000
#define SMAX 1000000
//
int number;
int quantum;
int time[MAX_TIME];
char name[MAX_PROCESS][MAX_NAME];
int tail;
int head;
int sumtime=0;
//
void initialize(void);//キューを初期化する
int isEmpty(void);//キューが空なら１を返す
int isFull(void);//キューが満杯なら１を返す
void enqueue_name(char n,int i);//nameに値を追加する
void enqueue_time(int t);//timeに値を追加する
int dequeue_time(void);//timeから値を取りだす
void input(void);//enqueueの呼び出しを管理する
void queue_in(void);//キューへの標準データ入力を管理する
void cal(void);//計算と処理を行う
//
int main(void)
{
    initialize();
    queue_in();
    while(isEmpty()==0)
    {cal();}
    return 0;
}
//
void initialize(void)
{tail=0;head=0;}
int isEmpty(void)
{
    if(head==tail){return 1;}
    else{return 0;}
}
int isFull(void)
{
    if(head==(tail+1)%(number)){return 1;}
    else{return 0;}
}
void enqueue_name(char n,int i)
{
  if(isFull()){printf("over-flow\n");}
    else
    {
        name[tail][i]=n;
    }
}
void enqueue_time(int t)
{
    if(isFull()){printf("over-flow\n");}
    else
    {
        time[tail]=t;
        if(tail+1==number){tail=0;}
        else{tail++;}
    }
}
int dequeue_time(void)
{
    if(isEmpty()){printf("under-flow\n");}
    else
    {   int x=time[head];
        if((head+1)==number){head=0;}
        else{head++;}
        return x;
    }
}
void input(void)
{
    char str[SMAX];
    int x;
    fgets(str,SMAX,stdin);
    int i=0;
    int linenum=0;
    while(str[i]>=' ')
    {
        while(isspace(str[i])){i++;}
        if(isdigit(str[i]))
        {
            x=0;
            while(isdigit(str[i]))
            {
                x=10*x+(str[i]-'0');
                i++;
            }
            enqueue_time(x);
        }
        else
        {
            while(isspace(str[i])==0)
            {
            enqueue_name(str[i],linenum);
            linenum++;
            i++;
            }
        }
    }
} 
void queue_in(void)
{
    char str[SMAX];
    fgets(str,SMAX,stdin);
    int i=0;
    int j=0;
    while(str[i]>=' ')
    {
        while(isspace(str[i])){i++;}
        if(isdigit(str[i]))
        {
            if(j==0)
            {
                number=0;
                while(isdigit(str[i]))
                {
                    number=10*number+(str[i]-'0');
                    i++;
                }
                number++;
                j++;
            }
            else if(j==1)
            {
               quantum=0;
            while(isdigit(str[i]))
            {
                quantum=10*quantum+(str[i]-'0');
                i++;
            }  
            }
        }
        
    }
    for(int k=0;k<number-1;k++)
    {
        input();
    }
}
void cal(void)
{
    char x[MAX_NAME];
    char z[MAX_NAME];
    sprintf(x,name[head]);
    int y=dequeue_time();
    y-=quantum;
    if(y>0)
    {
        strcpy(name[tail],x);
        enqueue_time(y);
        sumtime+=quantum;
    }
    else
    {
        sumtime+=(y+quantum);
        printf("%s %d\n",x,sumtime);
    }
}


Measured memory_bytes: 6856
# 入力
N=int(input())
S=input()

mx=0
for i in range(1,N):
  l1=list(set(S[:i]))
  l2=list(set(S[i:]))
  
  c=0
  for x in l1:
    if l2.count(x)>0:
      c+=1

  # 最大値更新
  mx=max(mx,c)

# 出力
print(mx)

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

int main() {
  int n, a = 0;
  cin >> n;

  for (int i = 1; i < n + 1; i++) {
    a = i;
    if (a % 3 == 0) {
      cout << " " << i;
    } else {
      do {
        if (a % 10 == 3) {
          cout << " " << i;
          break;
        }
      } while (a /= 10);
    }
  }
  cout << endl;
  return 0;
}


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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using llint = long long;

llint x, y;

void run() {
  scanf("%lld%lld", &x, &y);
  llint nw = x;
  int c = 0;
  for (; nw <= y; nw *= 2) {
    ++c;
  }
  printf("%d\n", c);
}

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


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

#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)

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

    int ans=0;
    if(a >=13){
        ans=b;
    }else if(a >=6){
        ans=b/2;
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String[] temp = in.nextLine().trim().split("\\s");
        int n = Integer.parseInt(temp[0]);
        int w = Integer.parseInt(temp[1]);
        int[] warr = new int[n];
        int[] varr = new int[n];
        for(int i = 0; i < n; i++){
            temp = in.nextLine().trim().split("\\s");
            warr[i] = Integer.parseInt(temp[0]);
            varr[i] = Integer.parseInt(temp[1]);
        } 
        long[][] dp = new long[n+1][w+1];
        for(int i = 1; i <= n; i++){
            for(int j = 0; j <= w; j++){
                dp[i][j] = dp[i-1][j];
                if(j >= warr[i-1]){
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][j-warr[i-1]] + varr[i-1]);
                }
            }
        }
        
        System.out.println(dp[n][w]);
    }
}

Measured memory_bytes: 123860