akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)
            r=(r*a)%m;
        b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int main(){
    ll n,k,q; cin>>n>>k>>q;
    vpi arr(n+1);
    rep(i,1,n+1)
    {
        arr[i].first = i;
        arr[i].second = 0;
    }
    rep(i,0,q)
    {
        ll x; cin>>x;
        arr[x].second++;
    }
    ll flag = 1;
    rep(i,1,n+1)
    {
        if(k+arr[i].second<=q)cout<<"No\n";
        else cout<<"Yes\n";
    }
    
    return 0;
    
}

Measured memory_bytes: 2176
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int a[] = new int[4];
			int b[] = new int[4];
			for(int i=0;i<4;i++) a[i] = sc.nextInt();
			for(int i=0;i<4;i++) b[i] = sc.nextInt();
			int hit = 0;
			int br = 0;
			
			for( int i=0;i<4;i++ ) for (int j=0;j<4;j++){
				if(a[i] == b[j] ) {
					if(i == j)hit++;
					else br++;
				}
			}
			System.out.println(hit + " " + br);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
def main():
    a = list(map(int, input().split()))
    a.sort()
    C,B,A = a
    AB = A-B
    AC = A-C
    if AB%2==0 and AC%2==0:
        return AB//2 + AC//2
    elif AB%2==1 and AC%2==1:
        return AB//2 + AC//2 + 1
    else:
        return AB//2 + AC//2 + 2


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }

int n, m, A, B;

char s[1010][1010];

void alg1(){
	int a=A, b=B;
	for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) s[i][j]='.';
	
	if(n%2==1 && m%2==1 && a>=2 && b>=2){
		a-=2; b-=2;
		s[n-2][m-2]='<'; s[n-2][m-1]='>'; s[n-2][m-0]='^';
		s[n-1][m-2]='^'; s[n-1][m-1]='.'; s[n-1][m-0]='v';
		s[n-0][m-2]='v'; s[n-0][m-1]='<'; s[n-0][m-0]='>';
	}
	
	if(m%2 == 1){
		for(int i=1; i+1<=n; i+=2){
			if(!b) continue;
			if(s[i][m]!='.' || s[i+1][m]!='.') continue;
			--b;
			s[i][m]='^';
			s[i+1][m]='v';
		}
	}
	if(n%2 == 1){
		for(int j=1; j+1<=m; j+=2){
			if(!a) break;
			if(s[n][j]!='.' || s[n][j+1]!='.') continue;
			--a;
			s[n][j]='<';
			s[n][j+1]='>';
		}
	}
	for(int i=2; i<=n; i+=2){
		for(int j=2; j<=m; j+=2){
			if(s[i-1][j-1] != '.') continue;
			if(a){
				s[i-1][j-1]='<';
				s[i-1][j]='>';
				--a;
				if(a){
					s[i][j-1]='<'; s[i][j]='>';
					--a;
				}
			} else if(b){
				s[i-1][j-1]='^';
				s[i][j-1]='v';
				--b;
				if(b){
					s[i-1][j]='^'; s[i][j]='v';
					--b;
				}
			}
		}
	}
	if(a==0 && b==0){
		puts("YES");
		for(int i=1; i<=n; ++i) puts(s[i]+1);
		exit(0);
	}
}

void alg2(){
	int a=A, b=B;
	for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) s[i][j]='.';
	
	if(m%2 == 1){
		for(int i=1; i+1<=n; i+=2){
			if(!b) break;
			--b;
			s[i][m]='^';
			s[i+1][m]='v';
		}
	}
	if(n%2 == 1){
		for(int j=1; j+1<=m; j+=2){
			if(!a) break;
			if(s[n][j+1]!='.') break;
			--a;
			s[n][j]='<';
			s[n][j+1]='>';
		}
	}
	for(int i=2; i<=n; i+=2){
		for(int j=2; j<=m; j+=2){
			if(a){
				s[i-1][j-1]='<';
				s[i-1][j]='>';
				--a;
				if(a){
					s[i][j-1]='<'; s[i][j]='>';
					--a;
				}
			} else if(b){
				s[i-1][j-1]='^';
				s[i][j-1]='v';
				--b;
				if(b){
					s[i-1][j]='^'; s[i][j]='v';
					--b;
				}
			}
		}
	}
	if(a || b) return;
	puts("YES");
	for(int i=1; i<=n; ++i) puts(s[i]+1);
	exit(0);
}

int main()
{
	read(n, m, A, B);
	alg1(); alg2();
	puts("NO");
	return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
		//Scanner cin = new Scanner();
		string line;
		while (!string.IsNullOrEmpty(line = System.Console.ReadLine())) {
			string[] l = line.Split(' ');
			TimeSpan s = new TimeSpan(int.Parse(l[0]), int.Parse(l[1]), int.Parse(l[2]));
			TimeSpan e = new TimeSpan(int.Parse(l[3]), int.Parse(l[4]), int.Parse(l[5]));
			e -= s;
			Console.WriteLine("{0} {1} {2}", e.Hours, e.Minutes, e.Seconds);
		}
		return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

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

#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
const ll N=1e5+5,inf=1e18;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll a,b,n;
	cin >> a>> b >> n;
	ll x=n;
	ll d=(n/b)*b;
	x=d-1;
	ll ans=0;
	ans=max((a*x)/b-a*(x/b),ans);
	x=n;
	ans=max((a*x)/b-a*(x/b),ans);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;
int main() {
    int R[MAX], n;
    
    cin >> n;
    for (int i = 0;i < n;i++)cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for (int i = 1;i < n;i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
        return 0;
}

Measured memory_bytes: 3872
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a, b, c;
	double d;
	double S, L, h;
	double sinc, cosc;
	
	scanf("%d%d%d", &a, &b, &c);
	
	sinc=sin(c/180.0*3.14159265);
	cosc=cos(c/180.0*3.14159265);
	d=sqrt(a*a+b*b-2*a*b*cosc);
	
	S=a*b*sinc/2.0;
	L=a+b+d;
	h=b*sinc;
	
	printf("%f\n%f\n%f\n", S, L, h);
	
	return 0;
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;
 
int main()
{
    int N,M,X;
    cin >> N >>M >>X;
    vector <int> C(N);
    int  A[N][M];
    
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++){
             cin >> A[i][j];
             
        }
    }
    ll ans = INF;
    
    int n=N;
    int co=1;
    
    rep(div,1<<(N)) {
        int g = 0;
        vector<int> id(M);
        bool flag = true;
        ll cos=0; 
        //cout << "sss"<<div << endl;
        rep(i,N) {
        // cout << div;
        int d = div;
            if (d>>i&1){
                for(int j=0;j<M;j++){
                    //cout << "j " << j  << endl;
                    //cout << "a "<<A[i][j] << endl;
                    id[j] += A[i][j];
                    //cout << "id "<<id[j] << endl;
                    
                    
                    
                }
                cos += C[i];
        
                
            }
        }
        for(int j=0;j<M;j++){
            //cout << id[j] << " ";  
            if(id[j] < X){
                flag=false;
            }
        }
        //cout << endl;
        if(flag){
            ans = min(ans, cos);
        }
    }   
    if(ans == INF){
        ans =-1;
    }
    cout << ans;
 
 
 
    return 0;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n,m;
  cin >> n >> m;
  
  int p[n]={};
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  
  vector< vector<int> > op(n);
  
  int x,y;
  for(int i=0;i<m;i++){
    cin >> x >> y;
    x--;y--;
    op[x].push_back(y);
    op[y].push_back(x);
  }

  int flag[n] = {};
  int groupCount = 1;
  int totalCount = 0;
  for(int i=0;i<n;i++){
    if(flag[i]!=0) continue;

    list<int> currentGrp;
    map<int, int> currentGrpPMap;

    queue<int> q; q.push(i);
    flag[i] = groupCount;

    while(!q.empty()){
      int node = q.front(); q.pop();
      currentGrp.push_back(node);
      currentGrpPMap[p[node]]++;
      for(auto nd:op[node]){
        if(flag[nd]==0) q.push(nd);
        flag[nd] = groupCount;
      }
    }
    for(auto nd:currentGrp){
      if(currentGrpPMap[nd]>0){
        totalCount++;
      }
    }
    groupCount++;  
  }
  cout << totalCount << endl;
  return 0;
}



Measured memory_bytes: 17008
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

#define N (1 << 15) 

int main(){
    bool prime[N] = {1,1,0};
    vector<int> v;
    rep(i,N){
        if(!prime[i]){
            v.pb(i);
            for(int j = i + i; j < N; j+=i){
                prime[j] = 1;
            }
        }
    }
    map<int, int> cnt;
    rep(i,v.size()){
        range(j,i,v.size()){
            cnt[v[i] + v[j]]++;
        }
    }
    int n;
    while(cin >> n,n){
        cout << cnt[n] << endl;
    }
}

Measured memory_bytes: 2964
<>=~$";@a=glob`dd`;$a[$_-1]%2&&($%=$_%$'?$_:$_<$`*$'&&$_-1+$')&&++$a[$%]+push@_,"@{[map{$_/$'+1|0,$_%$'+1}$_-1,$%]}
"for 1..$`*$';print@_.$/,@_

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

int main(){
	int N;
  	double x;
 	string y;
  	double gifts=0;
  	cin>>N;
  	for(int i=0;i<N;i++){
      cin>>x>>y;
      if(y=="JPY") gifts+=x;
      else if(y=="BTC")gifts+=x*380000;
    }
  
  cout<<gifts<<endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i32,
        m: usize,
        a: [i32; m],
    }

    let sum = a.iter().fold(0, |acc, x| acc + x);
    if sum <= n {
        println!("{}", n - sum);
    } else {
        println!("-1");
    }
}


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

bool solve(const long long n, long long k, const std::vector<long long> a, const std::vector<long long> f, long long cost)
{
    for (int i = 0; i < n; i++) {
        if ((long long) a[i] * f[i] <= cost) {continue;}

        long long training = a[i] - cost / f[i];
        k -= training;
        if (k < 0) {return false;}
    }

    return true;
}

long long binary_search(long long n, long long k, std::vector<long long> a, std::vector<long long> f)
{
    long long cost_max = 0;

    for (int i = 0; i < n; i++) {
        cost_max = std::max(cost_max, (long long) a[i] * f[i]);
    }

#ifdef _DEBUG
    std::cout << "cost max: " << cost_max << std::endl;
#endif

    long long lower_bound = 0;
    long long upper_bound = cost_max;

    while(true) {
        long long median = (upper_bound + lower_bound) / 2;
#ifdef _DEBUG
        std::cout << lower_bound << ", " << median << ", " << upper_bound << std::endl;
#endif
        if (solve(n, k, a, f, median)) {
            if (lower_bound == median) {return lower_bound;}
            upper_bound = median;
        } else {
            if (lower_bound == median) {return upper_bound;}
            lower_bound = median;
        }
    }

    return -1;
}

int main(int argc, char *argv[])
{
    long long n, k;
    std::vector<long long> a; // 消化コスト
    std::vector<long long> f; // 食べにくさ
    long long ans;

    std::cin >> n >> k;

    a.resize(n);
    f.resize(n);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> f[i];
    }

    std::sort(a.begin(), a.end(), std::greater<long long>());
    std::sort(f.begin(), f.end(), std::less<long long>());

    ans = binary_search(n, k, a, f);

    std::cout << ans << std::endl;

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  char c = s[0];
  for (int i = 1; i < s.size(); i++) {
    if (s[i] != c) {
      c = s[i];
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
    int n, c;
    cin >> n >> c;
    int S[1000000];
    fill(S, S + 1000000, 0);
    //チャンネル別で考える
    int Sc[30][100100];
    rep(i, 30) fill(Sc[i], Sc[i] + 100100, 0);
    rep(i, n){
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        Sc[c][s]++;
        Sc[c][t]--;
    }

    rep(i, 100100){
        rep(j, 30){
            if(Sc[j][i] == 1){
                S[2*i - 1]++;
            }else if(Sc[j][i] == -1){
                S[2*i]--;
            }
        }
    }
    int ans = 0;
    for(int i = 1; i < 1000000; i++){
        S[i] += S[i-1];
        ans = max(S[i], ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 19244
from fractions import gcd

def fe(n):
    cnt = 0
    while n % 2 == 0:
        n /= 2
        cnt += 1
    return cnt

N, M = map(int, input().split())
a = list(map(int, input().split()))
for i in range(N):
    a[i] = a[i] // 2
t = fe(a[i])
for i in range(N):
    tmp = fe(a[i])
    if tmp != t:
        print(0)
        exit()
    a[i] >>= t
M >>= t

l = 1
for i in range(N):
    l = l * a[i] // gcd(l, a[i])
    if l > M:
        print(0)
        exit()
M //= l
ans = (M + 1) // 2
print(ans)



Measured memory_bytes: 16320
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

vector<vector<pair<Int, Int>>> Graph;
vector<Int> dis;//最短距離

void dfs(Int v) {//v: 考えている頂点 
	Int d = dis[v];//その頂点までの最短距離
	for (auto nv : Graph[v]) {
		if (dis[nv.first] != INF)continue;
		else {
			dis[nv.first] = d + nv.second;
			dfs(nv.first);
		}
	}
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	Graph.resize(N);
	dis.resize(N, INF);

	Int a, b, c;
	for (Int i = 0; i < N-1; i++) {
		cin >> a >> b >> c;
		Graph[a - 1].push_back(make_pair(b - 1, c));
		Graph[b - 1].push_back(make_pair(a - 1, c));
	}

	Int Q, K;
	cin >> Q >> K;

	dis[K - 1] = 0;//スタート地点

	dfs(K - 1);

	Int x, y, ans;
	for (Int i = 0; i < Q; i++) {
		cin >> x >> y;
		x--;
		y--;

		ans = dis[x] + dis[y];
		cout << ans << "\n";
	}

}


Measured memory_bytes: 12800
package main

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

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	k, n := nextInt(), nextInt()
	a := nextInts(n)
	sort.Sort(sort.IntSlice(a))

	ans := k + 1
	for i := 0; i < n; i++ {
		d := min(k-(a[i]-a[(i-1+n)%n]+k)%k, k-(a[(i+1)%n]-a[i]))
		// puts(a[(i-1+n)%n], a[i], a[(i+1)%n], k-(a[i]-a[(i-1+n)%n]+k)%k, k-(a[(i+1)%n]-a[i]), d)
		ans = min(ans, d)
	}

	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

struct Range{
	mutable int b,e;
	mutable ll eat;
	bool operator<(const Range& rhs)const{
		return b<rhs.b;
	}
};

int main(){
	int n=read(),q=read();
	set<Range> s;
	s.insert(Range{0,n,0});
	REP(_,q){
		int a=read();
		ll b=readLL();
		auto itr=s.lower_bound(Range{a});
		--itr;
		if(a<itr->e){
			Range tmp=*itr;
			tmp.b=a;
			itr=s.insert(tmp).first;
			itr--;
			itr->e=a;
		}
		while(itr!=s.begin()){
			auto p=itr;p--;
			ll dif=p->eat-itr->eat;
			if(dif*(itr->e-itr->b)<=b){
				b-=dif*(itr->e-itr->b);
				itr=s.erase(itr);
				itr--;
				itr->e=a;
			}else
				break;
		}
		itr->eat+=b/(itr->e-itr->b);
		Range x=*itr;
		x.e=x.b+b%(itr->e-itr->b);
		if(x.b<x.e){
			itr->b=x.e;
			x.eat++;
			s.insert(x);
		}
	}
	for(auto g:s)
		FOR(i,g.b,g.e)
			printf("%lld\n",g.eat);
}


Measured memory_bytes: 7680
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
int main(){
	int a,b;
	in2(a,b);
	if((a*b)%2) printf("Yes");
	else if((a*b*2)%2) printf("Yes");
		else if((a*b*3)%2) printf("Yes");
			else printf("No");
	return 0;
}

Measured memory_bytes: 128
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int n ;
string s ; 

string make ( int x ) {
	string ans = "" ;
	while ( x ) {
		ans += ( char ) ( x % 10 + '0' ) ;
		x /= 10 ; 
	}
	reverse ( all ( ans ) );
	return ans ; 
}

int solve ( int pos , int eq ) {
	if ( pos == ( int ) s . size ( ) ) return 0 ; 
	if ( eq == 0 ) {
		int rem = ( int ) s . size ( ) - pos ;
		return rem * 9 ; 
	}
	int ret = 0 ; 
	for ( int i = 0 ; i < ( int ) ( s [ pos ] - '0' ) ; ++ i ) {
		smax ( ret , solve ( pos + 1 , 0 ) + i ) ; 
	}
	return max ( solve ( pos + 1 , 1 ) + ( s [ pos ] - '0' ) , ret) ; 
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	s = make ( n ) ;
	cout << solve ( 0 , -1 ) ; 
}


Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);

int mod9(int A) {
    int tmp = 0;
    while (A > 0) {
        tmp += A % 10;
        A /= 10;
    }
    return tmp;
}

//番号ズレ注意！！
int main() {
    int N;
    cin>>N;
    ll a[3*N];
    REP(i, N * 3) {
        cin >> a[i];
    }
    sort(a, a + 3 * N, greater<int>());
    ll ans = 0;
    for (int i = 1; i <= N * 2 - 1; i += 2) {
        ans += a[i];
    }
    print(ans);

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int n;
    cin >> n;
    map<string, int> s;
    rep(i, n) {
        string enter;
        cin >> enter;
        s[enter]++;
    }
    int m;
    cin >> m;
    rep(i, m) {
        string enter;
        cin >> enter;
        s[enter]--;
    }
    int ans = 0;
    arep(i, s) {
        if(i.second > ans) ans = i.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long N, K;
cin >> N >> K;
long long J = N / K;
long long ans;
long long ichi, ni;
ichi = N - K*J;
ni = K*(J+1) - N;
ans = min(ichi, ni);
cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=3e5+5;
const ll inf=1e9+9;

vector<int> vv[ms];


map<int,int> ma;
map<int,int> mb;


void add(int v)
{
    int f=ma[v];
    if(mb[f]==1)mb.erase(f);
    else mb[f]-=1;
    mb[f+1]+=1;
    ma[v]+=1;
}

void del(int v)
{
    int f=ma[v];
    if(mb[f]==1)mb.erase(f);
    else mb[f]-=1;
    mb[f-1]+=1;
    ma[v]-=1;
}

int main()
{
    idfc;

    int n,m;
    int t;
    cin>>n>>m>>t;
    int x,y;
    while(t--)
    {
        cin>>x>>y;
        x--;
        y--;
        vv[y].pb(x);
        add(x);
    }


   // buildtree(0,n-1,1);
    int i,j;
    int ans=0;
    int c;
    int p;
   // for(auto it:mb)cout<<it.first<<" "<<it.second<<"\n";
    for(i=0;i<m;i++)
    {
        c=vv[i].size();
      //  for(auto it:mb)cout<<it.first<<" "<<it.second<<"\n";
        for(int ii:vv[i])del(ii);
     //   for(auto it:mb)cout<<it.first<<" "<<it.second<<"\n";
        if(mb.empty())p=0;
        else
        p=(*mb.rbegin()).first;
        ans=max(ans,c+p);
        for(int ii:vv[i])add(ii);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 34064
'''SDESTINY　　問題(特に定義)の細部に拘らないと解けない
良い展望台の定義は展望台 i から一本の道を使って辿り着ける
どの展望台よりも展望台 i の方が標高が高いことであって、
同じ高さの展望台に繋がっている展望台は、良い展望台にならない。
良い展望台は単独１位が必要で、同点１位の高さは良い展望台にならない。
入力例２を見ること。
N個の展望台の一つ一つずつと繋がっている展望台の番号(0-index)を
setに格納する配列を作る。
全体でN個、その中に繋がっている展望台の数だけ、要素がある。
要素はsetで持っていうる。
そのsetの中から要素を一つ一つ取り出す（（C)の部分）。
取り出した高さH[x]と、いま見ている展望台の高さH[i]を比べて、
H[i]<=H[x]なら、条件に合わない（等号がないと単独で１位を選べない。）
N 箇所の展望台があり展望台 i の標高が Hi、また展望台を結ぶ道が M 本あり、
道 j は展望台 Aj と Bj を結んでいる。展望台から伸びている道
を1つだけ通って行ける展望台のうち最も高い展望台を良い展望台と呼び、
それがいくつあるか求める。
（A)N 箇所の展望台 i に対応するように配列を作り、
各展望台から道が繋がっている展望台をsetで持つ。0-index
配列を順番に見ていき、見ている展望台とsetが持っている
展望台の高さを比較し、最も高ければ答えを1増やす。
'''
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [set() for i in range(N)]#（A)
for i in range(M):
    A,B = map(int,input().split())
    AB[A-1].add(B-1)#0-indexへ
    AB[B-1].add(A-1)
#print(AB)
ans = 0
for i in range(N):#iは見ている展望台をチェック
    res = True
    for x in AB[i]:#（C)二重ループ
    #setのi番目にある複数の要素をxとして一つずつ取り出す
#配列を順番に見ていき、見ている展望台iとsetが持っている
#展望台xの高さを比較し、低ければ条件に合わない
        if H[i]<=H[x]:#これが（B)のif、等号なしだと同点１位も残る
            #print(H[i],H[x])
            res = False
            break
    if res:#（B)のifでbreakしなければ、最も高いので答を１増やす
        ans += 1
print(ans)

Measured memory_bytes: 45192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());

        System.out.println((t / a) * b);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;

class Node {
public:
    int val;
    Node* left;
    Node* right;

    Node(int _x, Node* _left = NULL, Node* _right = NULL) :
        val(_x), left(_left), right(_right){}

    string to_str() {
        string ret = "["+to_string(this->val)+"]";

        if (this->left != NULL)
            ret = "(" + this->left->to_str() + ")" + ret;
        else
            ret = "()" + ret;
        if (this->right != NULL)
            ret += "(" + this->right->to_str() + ")";
        else
            ret += "()";

        return ret;
    }
};

Node* parse_tree(string s) {
    if (s == "") return NULL;

    int kakko = 1;
    int left_idx = 1; // left: [0, left_idx]
    while (kakko) {
        if (s[left_idx] == '(') kakko++;
        if (s[left_idx] == ')') kakko--;
        left_idx++;
    }
    string left_s = s.substr(1, left_idx - 2);

    int num_idx = left_idx + 2; // number: [left_idx + 1, num_idx];
    while (s[num_idx] != ']') num_idx++;
    int number = atoi(s.substr(left_idx + 1, num_idx - left_idx - 1).c_str());
    string right_s = s.substr(num_idx + 2, s.size() - num_idx - 3);

    auto left = parse_tree(left_s);
    auto right = parse_tree(right_s);

    Node* node = new Node(number, left, right);
    return node;
}

Node* add_tree(Node* a, Node* b) {
    Node* left = NULL;
    Node* right = NULL;

    if (a->left != NULL && b->left != NULL) {
        left = add_tree(a->left, b->left);
    }

    int ans = b->val + a->val;

    if (a->right != NULL && b->right != NULL) {
        right = add_tree(a->right, b->right);
    }

    Node* node = new Node(ans, left, right);
    return node;
}

int main() {
    string a, b;
    cin >> a >> b;
    auto first = parse_tree(a);
    auto second = parse_tree(b);

    cout << add_tree(first, second)->to_str() << endl;
}



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

int main(){
	long long a, b, c, d, i, j;
	cin >> a >> b >> c >> d;
	long long max, max1, max2, max3, max4;
	max1 = a * c;
	max2 = a * d;
	max3 = b * c;
	max4 = b * d;
	max = max1;
	if (max < max2) max = max2;
	if (max < max3) max = max3;
	if (max < max4) max = max4;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3600
# B - Power Socket
def main():
    a, b = map(int, input().split())
    cnt = 1
    ans = 0
    for i in range(20):
        if cnt >= b:
            print(ans)
            exit()
        else:
            cnt = a + (a-1) * i
            ans += 1

if __name__ ==  "__main__":
    main()

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

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

struct UnionFind {
    Vec<i32> p;
    i32 num;

    UnionFind(i32 N): num(N) {
        p = Vec<i32>(N, -1);
    }

    i32 root(i32 x) {
        if (p[x] < 0) return x;
        return p[x] = root(p[x]);
    }

    bool unite(i32 x, i32 y) { // xとyの木を併合
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (p[x] > p[y]) swap(x, y);
        p[x] += p[y];
        p[y] = x;
        num--;
        return true;
    }

    bool same(i32 x, i32 y) { // xとyが同じ木に属するか？
        x = root(x);
        y = root(y);
        return x == y;
    }

    i32 size(i32 x) { // xと同じ木に属するものの数
        return -p[root(x)];
    }

    i32 setSize() { // 木の数(何個のグループがあるか)
        return num;
    }
};

void Main() {
    i32 N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for (i32 i = 0; i < M; i++) {
        i32 A, B;
        cin >> A >> B;
        A--; B--;
        uf.unite(A, B);
    }
    cout << uf.setSize() - 1 << endl;
}


Measured memory_bytes: 3740
import java.util.Scanner;
class Main {
  public static void main(String[] args){
  Scanner scanner = new Scanner(System.in);
  int a = scanner.nextInt();
  int b = scanner.nextInt();
  int area = a * b;
  int length = 2 * a + 2 * b;
  System.out.println(area + " " + length);
  }
}

Measured memory_bytes: 26180
#input
H, W = map(int, input().split())
import numpy as np
S = [input() for _ in range(H)]

#output
import numpy as np

INF = -1
dx = [1, 0, -1, 0]
dy = [0, 1, 0 ,-1]

answer = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != "#":
            dp = np.full((H, W), INF)
            q = []
            q.insert(0, (i, j))
            dp[i, j] = 0
            while len(q):
                x, y = q.pop()

                for t in range(4):
                    nx, ny = x + dx[t], y + dy[t]

                    if (0 <= nx < H) and (0 <= ny < W) and (S[nx][ny] != "#") and (dp[nx, ny] == INF):
                        q.insert(0, (nx, ny))
                        dp[nx, ny] = dp[x, y] + 1
            for row in dp:
                answer = max(answer, max(row))
print(int(answer))


Measured memory_bytes: 12516
#include <iostream>
#include <string>

int main(){
    int n = 0;
    std::string s = "";

    std::cin >> n >> s;

    int count = 0;

    for(int i = 0; i < n - 2; i++){
        if(s.at(i) == 'A'){
            if(s.at(i+1) == 'B'){
                if(s.at(i+2) == 'C'){
                    count++;
                }
            }
        }
    }
    printf("%d", count);

}

Measured memory_bytes: 256
using System;

namespace ABC071B
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            bool[] chk = new bool[26];

            for (int i = 0; i < str.Length; i++)
            {
                chk[str[i] - 'a'] = true;
            }

            for (int i = 0; i < 26; i++)
            {
                if (!chk[i])
                {
                    Console.WriteLine((char)('a' + i));
                    return;
                }
            }

            Console.WriteLine("None");
        }
    }
}


Measured memory_bytes: 13212
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
	
	return 0;
}

Measured memory_bytes: 3576
/*  ex3_2
    Rikuta  */

#include <stdio.h>

int main(void){

    int number,ones_place;
    //numberを入力
    scanf("%d",&number);
    //ones_placeはnumberを10で割った余り．
    ones_place = number%10;
    //ones_placeの値によって分岐してそれぞれで読み方を出力
    switch (ones_place)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        printf("hon\n");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon\n");
        break;
    case 3:
        printf("bon\n");
        break;
    //デフォルトの指示としてswitch文からの脱出
    default:
        break;
    }

    return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <bitset>

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

using namespace std;

int main() {
	int N, A = 0;
	scanf("%d", &N);
	vector<int> a(N);
	rep(i, N) {
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end(), greater<int>());

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) A += a[i];
		else A -= a[i];
	}

	printf("%d", A);
}




Measured memory_bytes: 3776
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

int main(){
	vector<ll> A(3,0);
	ll sum=0;
	rep(i,3){
		cin >> A[i];
		sum += A[i];
	}

	if(sum >= 22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
#define int long long

const int N = (int)(1e6) + 322;
const int inf = (int)(2e9);
const int mod = (int)(1e9) + 7; // check modulo

int pw[N], X[N], Y[N];

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

inline bool sign(int x) {
    return (x < 0);
}

int dot(int i, int j) {
    return X[i] * X[j] + Y[i] * Y[j];
}

void solve() {
    map <pair <int, int>, int> cnt[2];
    map <pair <int, int>, bool> ban;
    int n; cin >> n;
    pw[0] = 1;
    int both = 0;
    for(int i = 1; i <= n; ++i) {
        pw[i] = (pw[i - 1] * 2) % mod;
        int x, y; cin >> x >> y;
        if (!x && !y) {
            both++;
            continue;
        }
        bool s = (sign(x) ^ sign(y));
        x = abs(x);
        y = abs(y);
        int g = gcd(x, y);
        x /= g;
        y /= g;
        if (!x) s = false;
        if (!y) s = true;
        cnt[s][{x, y}]++;
    }
    int res = 1;
    for(auto it : cnt[0]) {
        int x = it.first.first, y = it.first.second, sz = it.second;
        int curmult = pw[sz];
        if (cnt[1].count({y, x})) {
            curmult += pw[cnt[1][{y, x}]] - 1;
        }
//        cout << curmult << ' '  << sz << ' ' << x << ' ' << y << endl;
        ban[{y, x}] = true;
        res = (res * curmult) % mod;
    }
    for(auto it : cnt[1]) {
        int x = it.first.first, y = it.first.second, sz = it.second;
        if (ban.count({x, y})) continue;
        res = (res * pw[sz]) % mod;
    }

    cout << (res + both - 1 + mod) % mod;
}

signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("elevator.in", "r", stdin);
//    freopen("elevator.out", "w", stdout);
//    int test; cin >> test;
//    for(int t = 1; t <= test; ++t) {
        solve();
//    }
    return 0;
}


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

int main() {
  int N;
  int n;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> n;
    if (n % 2 == 0 && n % 3 != 0 && n % 5 != 0) {
      cout << "DENIED" << endl;
      break;
    }
    if (i == N-1) {
      cout << "APPROVED" << endl;
    }
  }
}

Measured memory_bytes: 256
// 2020-06-28 21:34:59
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const ll C = 26, INF = 1e18;
ll D;
vector<ll> cs(C);
void answer() {
  cin >> D;
  rep(i, C) cin >> cs[i];
  vector<vector<ll> > ss(D, vector<ll>(C, 0));
  rep(i, D) rep(j, C) cin >> ss[i][j];
  vector<ll> last(C, 0);
  ll score = 0;
  REPC(d_, 1, D) {
    ll d = d_, now = -INF, nowc = 0;
    rep(j, C) {
      ll cur = score + ss[d-1][j];
      rep(k, C) if(j != k) cur -= cs[k] * (d - last[k]);
      if(chmax(now, cur)) nowc = j;
    }
    last[nowc] = d;
    score = now;
    cout << nowc+1 << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3736
a,b,k=map(int,input().split())
l=[i for i in range(a,min(a+k,b+1))]
s=[i for i in range(max(a,b-k+1),b+1)]
l=l+s
l=list(set(l))
l.sort()
for i in l:
    print(i)

Measured memory_bytes: 3064
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
key = k
for i in range(n):
    for j in range(n):
        if a[i] > a[j] and i != j:
            if i < j:
                ans += (1 + key) * key // 2 % (10 ** 9 + 7)
            else:
                ans += (1 + key - 1) * (key - 1) // 2 % (10 ** 9 + 7)
        # print(ans, i, j)
ans %= ( 10 ** 9 + 7)
print(ans)

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

int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	//for ( e = 0; e < d; e++)
	//{
	//	f = a + b;
	//	g = b + c;
	//	h = c + a;
	//	a = g;
	//	b = h;
	//	c = f;

	//	if (g>h)
	//	{
	//		i = g;
	//		g = h;
	//		h = i;
	//	}
	//	if (g>f)
	//	{
	//		i = g;
	//		g = f;
	//		f = i;
	//	}
	//	if (h>f)
	//	{
	//		i = h;
	//		h = f;
	//		f = i;
	//	}
	//	a -= g;
	//	b -= g;
	//	c -= g;
	//	if (h - g > 1000000000000000000 && f - h > 1000000000000000000 )
	//	{
	//		cout << "Unfair" << endl;
	//		return 0;
	//	}
	//	/*if (a>1000000000000000000|| b>1000000000000000000|| c>1000000000000000000)
	//	{
	//		cout << "Unfair" << endl;
	//		return 0;
	//	}*/
	//}
	//if (a - b > 1000000000000000000 || b - a > 1000000000000000000 || a - b < -1000000000000000000 || b - a < -1000000000000000000)
	//{
	//	cout << "Unfair" << endl;
	//}

	if (d % 2 == 1)
	{
		if (a - b > 1000000000000000000 || b - a > 1000000000000000000 || a - b < -1000000000000000000 || b - a < -1000000000000000000)
		{
			cout << "Unfair" << endl;
			return 0;

		}
		cout << b - a << endl;
	}
	if (d % 2 == 0)
	{
		if (a - b > 1000000000000000000 || b - a > 1000000000000000000 || a - b < -1000000000000000000 || b - a < -1000000000000000000)
		{
			cout << "Unfair" << endl;
			return 0;

		}
		cout << a - b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>

int main(void) {
  int i, j, k, l, m, n;
  long long ans = 0;
  std::vector<int> vx, vy, vd;
  scanf("%d%d", &n, &k);
  int x1[n], y1[n], d1[n], x2[n], y2[n], d2[n];
  for(i = 0; i < n; ++i) {
    scanf("%d%d%d%d%d%d", &x1[i], &y1[i], &d1[i], &x2[i], &y2[i], &d2[i]);
    vx.push_back(x1[i]);
    vx.push_back(x2[i]);
    vy.push_back(y1[i]);
    vy.push_back(y2[i]);
    vd.push_back(d1[i]);
    vd.push_back(d2[i]);
  }
  std::sort(vx.begin(), vx.end());
  std::sort(vy.begin(), vy.end());
  std::sort(vd.begin(), vd.end());
  vx.erase(std::unique(vx.begin(), vx.end()), vx.end());
  vy.erase(std::unique(vy.begin(), vy.end()), vy.end());
  vd.erase(std::unique(vd.begin(), vd.end()), vd.end());
  for(i = 1; i < vx.size(); ++i) {
    for(j = 1; j < vy.size(); ++j) {
      for(l = 1; l < vd.size(); ++l) {
        int t = 0;
        for(m = 0; m < n; ++m) {
          if(x1[m] <= vx[i - 1] && vx[i] <= x2[m] && y1[m] <= vy[j - 1] && vy[j] <= y2[m] && d1[m] <= vd[l - 1] && vd[l] <= d2[m]) ++t;
        }
        if(t >= k) ans += (long long)(vx[i] - vx[i - 1]) * (long long)(vy[j] - vy[j - 1]) * (long long)(vd[l] - vd[l - 1]);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 2664
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int a[N],c[N];
int n,m,v[20];
int f[N],ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		a[x]^=z; a[y]^=z;
	}
	for (int i=0;i<n;i++)
		c[a[i]]++;
	for (int i=1;i<16;i++)
	{
		ans+=c[i]/2;
		if (c[i]&1) v[m++]=i;
	}
	f[0]=0;
	for (int i=1;i<1<<m;i++)
	{
		int k=0,x=0;
		for (int j=0;j<m;j++)
			if ((i>>j)&1)
			{
				x^=v[j];
				k++;
			}
		f[i]=(x?100:k-1);
		for (int p=i-(i&(-i)),j=p;;j=(j-1)&p)
		{
			f[i]=min(f[i],f[j]+f[i^j]);
			if (!j) break; 
		}
	}
	printf("%d",ans+f[(1<<m)-1]);
}

Measured memory_bytes: 768
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        long x = sc.nextLong();
        //String s = sc.next();

        // 処理
        long out = 0;
        long work = 100;
        while(true){
            work = (long)(work * 1.01);
            out += 1;
            if(work >= x) break;
        }

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 35768
/**
*	created: 19.09.2020 21:03:55
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
// #define endl '\n'
#define int long long
#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 rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
using ll = long long;
using P = pair<int,int>;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
inline void print(P a) {cout << a.first << " " << a.second << endl;}
template<typename T> T pow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;



signed main() {
    int n; cin >> n;
    bool ok1 = false;
    bool ok2 = false;
    rep(i,n) {
        int a, b; cin >> a >> b;
        if (a != b) {
            ok1 = false;
            ok2 = false;
        }
        else {
            if (ok1 && ok2) {
                cout << "Yes" << endl;
                return 0;
            } 
            else if (ok1) {
                ok2 = true;
            }
            else ok1 = true;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3640