akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

MOD = (10 ** 9) + 7
assert MOD == 1000000007

def gcd(a, b):
    if a % b == 0:
        return b
    return gcd(b, a % b)

n = int(raw_input())

ns = []
d = defaultdict(int)
zero = 0

for i in xrange(n):
    a, b = map(int, raw_input().split())
    ns.append((a, b))
    if a and b:
        s = 1 if a * b >= 0 else -1
        g = gcd(abs(a), abs(b))
        m1 = (s * abs(a) / g, abs(b) / g)
        m2 = (-s * abs(b) / g, abs(a) / g)
    elif a == 0 and b == 0:
        zero += 1
        continue
    elif a == 0:
        m1 = (1, 0)
        m2 = (0, 1)
    elif b == 0:
        m1 = (0, 1)
        m2 = (1, 0)

    d[m1] += 1
    d[m2] += 0

'''
res = 0
for i in xrange(1 << n):
    fs = []
    flag = True
    for j in xrange(n):
        if i & (1 << j):
            fs.append(ns[j])
    for i, f1 in enumerate(fs):
        for f2 in fs[i + 1:]:
            (a1, b1) = f1
            (a2, b2) = f2
            if a1 * a2 + b1 * b2 == 0:
                flag = False
                break
        if not flag:
            break
    if flag:
        res += 1
print res - 1
'''

pre = 1
for k in d.keys():
    if k[0] <= 0:
        assert (k[1], -k[0]) in d
        continue
    else:
        k1 = k
        k2 = (-k[1], k[0])

        tot = pow(2, d[k1], MOD) + pow(2, d[k2], MOD) - 1
        pre = pre * tot % MOD
print (pre - 1 + zero + MOD) % MOD


Measured memory_bytes: 179212
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int H, W;
    for (;;) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        rep(h, H) {
            rep(w, W) {
                if (h == 0 || w == 0 || h == H - 1 || w == W - 1) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << "\n";
        }
        cout << "\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3128
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=300300,INF=1000010000;
int n,m,L,t,ans,sum,mi,y,z,cnt;
int a[N],b[N],su[N],lx[N],rx[N],rm[N],vi[N];
int main(){
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	scanf("%d%d",&n,&L);
	FOR(i,1,n) scanf("%d",&a[i]);
	FOR(i,1,n){
		scanf("%d",&t);
		ans+=2*(t/2/L);t%=2*L;
		if(!t) {vi[i]=1;continue;}
		int b1=t<=2*a[i],b2=t<=2*(L-a[i]);
		if(!b1&&!b2) {ans+=2;vi[i]=1;continue;}
		if(b1&&b2) b[i]=0,ans++;
		else b[i]=b1?1:-1,ans++;
	}
	//cout<<ans<<'\n';
	//FOR(i,1,n) cout<<b[i]<<'-'<<vi[i]<<'\n';cout<<'\n';
	rm[n+1]=INF;
	ROF(i,n,1){
		su[i]=su[i+1]+(vi[i]?0:(b[i]>0?-1:+1));
		rx[i]=min(rx[i+1],su[i]);
		rm[i]=min(rm[i+1],su[i]);
	}
	sum=0;mi=INF;
	FOR(i,0,n){
		t=sum-su[i+1];y=min(lx[i],rx[i+1]+t);
		z=min(lx[i],rm[i+1]+t);//cout<<z<<'\n';
		mi=min(mi,max(0,-y)+max(0,t-y)+2*(z<=t));
		//cout<<sum<<' '<<t<<' '<<y<<' '<<mi<<'\n';
		sum+=(vi[i+1]?0:b[i+1]<0?-1:+1);
		lx[i+1]=min(lx[i],sum);
	}
	cout<<1ll*L*(ans+mi);
}


Measured memory_bytes: 8448
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
typedef pair<int,int> P;
typedef pair<int,P> PP;		//p,(d,t)
vector<PP> warp;
int dp[1001];	//dp[0]
int main(){
	int l,n;
	cin >> l >> n;
	rep(i,n){
		int p,d,t;
		cin >> p >> d >> t;
		warp.push_back(PP(p,P(d,t)));
	}
	warp.push_back(PP(l,P(0,0)));
	sort(ALL(warp));
	rep(i,n+1){
		dp[i]=warp[i].first;
		rep(j,n){
			if(warp[j].first+warp[j].second.first>warp[i].first) continue;
			dp[i]=min(dp[i],dp[j]+warp[j].second.second+warp[i].first-(warp[j].first+warp[j].second.first));
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 1232
import java.util.Scanner;

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

            while(true){

              int c =0;

               String str = scan.next();

               if(str.equals("0")){
                  break;
               }

                  for(int i =0;i<str.length();i++){
 
                  c+=Integer.parseInt(str.substring(i,i+1));

                  }
                System.out.println(c);
            }
      }
   }


Measured memory_bytes: 26680
#include<bits/stdc++.h>
#define pb push_back
#define vl vector
#define ll long long
#define fast std::ios::sync_with_stdio(false)
using namespace std;

int main()
{
    fast;
    ll n,k;
    cin>>n>>k;
    set<ll> se;
    for(ll i=0;i<k;i++)
    {
        ll a;
        cin>>a;
        for(ll j=0;j<a;j++)
        {
            ll b;
            cin>>b;
            se.insert(b);
        }
    }
    cout<<n-se.size();
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//ori
#define MOD 1000000007
 
int main() {
  int N;
  cin >> N;
  VI A(N),B(N);
  REP(i,N) {
    cin >> A.at(i);
    B.at(i) = A.at(i);
  }
  SORT(A);
  REP(i,N) {
    if(A.at(N-1) != B.at(i)) cout << A.at(N-1) << endl;
    else cout << A.at(N-2) << endl;
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
const int X = 23;
char str[N];
int len, ans = 0;

int main()
{
   cin>>str;
   len = strlen(str);
   int l = 0, r = len - 1, ll = -1, lr = len;
   while(l < r) {
        while(str[l] == 'x')l ++;
        while(str[r] == 'x')r --;
        if(l > r)break;
        if(str[l] != str[r]) {
            puts("-1");
            return 0;
        }
        int u = l - ll - 1;
        int v = lr - r - 1;
        ans += (max(u,v) - min(u,v));

        //cout<<l<<" "<<r<<" "<<ans<<endl;
        ll = l, lr = r;
        l ++, r --;
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] dic = new String[9];
		dic[0] = ".,!? ";
		dic[1] = "abc";
		dic[2] = "def";
		dic[3] = "ghi";
		dic[4] = "jkl";
		dic[5] = "mno";
		dic[6] = "pqrs";
		dic[7] = "tuv";
		dic[8] = "wxyz";
		while(scan.hasNext()){
			int n = scan.nextInt();
			String str = "";
			int count;
			boolean fl;
			int t;
			int tt;
			int j;
			for(int i = 0;i < n;i++){
				str = scan.next();
				count = 0;
				fl = false;
				t = 0;
				tt = 0;
				j = 0;
				while(j < str.length()){
					t = Integer.parseInt(str.charAt(j)+"");
					j++;
					if(t == 0){
						if(fl){
							System.out.print(dic[tt].charAt(count%(dic[tt].length())));
							fl = false;
							count = 0;
						}
					}else if(!fl){
						tt = t-1;
						fl = true;
					}else{
						count++;
					}
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 30932
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin >> a.at(i) >> b.at(i);
    }
    ll chka=0;
    ll ans;
    rep(i,n){
        if(chka<a.at(i)){
            chka=a.at(i);
            ans=a.at(i)+b.at(i);
        }
    }
    cout << ans << endl;
} 
    

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

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

    ll a[n];
    ll b[n];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        sum -= b[i];
    }

    if(sum >= 0){
        ll c[n];
        for(int i = 0; i < n; i++){
            c[i] = a[i] - b[i];
        }

        sort(c, c + n);

        sum = c[n - 1];
        int poj = 0;
        int poj_2 = n - 2;
        ll k = c[poj];
        int ans = 1;
        while(1){
            if(c[poj] >= 0){
                if(poj == 0){
                    ans--;
                }
                break;
            }

            if(c[poj] < 0){
                sum += c[poj];
                ans++;
                while(1){
                    if(sum >= 0){
                        break;
                    }else{
                        sum += c[poj_2];
                        poj_2--;
                        ans++;
                    }
                } 
            }
            poj++;
        }

        cout << ans << endl;

    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：
int fct(int m, int k) {
	int ft = 1;
	rep(i, k) ft *= m;
	return(ft);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;
	double ans;
	if(N%2 == 0) ans = 0.5;
	else ans = 0.5+0.5/N;

	cout << ans << endl;
	return 0;
}
// std::string str;
// str = std::to_string(int i);
// bitset<3> s(N);


Measured memory_bytes: 256
n = int(input())
data = list(map(int, input().split()))   # 1行にある複数の値を整数にして、リストにしまう
#
vmin = min(data)  # 最小値
vmax = max(data)  # 最大値
vsum = sum(data)  # 合計
#
print(vmin, vmax, vsum)


Measured memory_bytes: 6580
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    a, b, c = list(map(int,ipti().split()))
    ans = max(0, c - (a - b))
    print(ans)

if __name__ == '__main__':
    main()

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

int main() {
  int N,K,dis;
  cin>>N>>K;
  dis=0;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    int da,db;
    da=x*2;
    db=(K-x)*2;
    if (da<db){dis+=da;}
    else{dis+=db;}
  }
  cout<<dis<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define MAXN 100005
#define MP make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define SQ(a) (a)*(a)
#define nl "\n"
#define INF std::numeric_limits<int>::max()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
ll mod=1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll a[n] = {0};
	ll cmn_cnt[63] = {0};
	for(ll i = 0 ; i < n ; i++) {
		cin>>a[i];
	}
	ll ans = 0;
	for(ll i = 0; i <= 60;i++){
		ll cnt=0;
		for(int j = 0; j < n; j++){
				cnt+=(a[j]>>i)&1;
		}
		ans=(ans+(((((1LL<<i)%mod)*cnt)%mod)*(n-cnt))%mod)%mod;
	}
	cout<<ans%mod<<nl;
	return 0;
}






Measured memory_bytes: 2560
#include<iostream>
#include<cstring>
#include<bitset>
using namespace std;

const int MAX = 8000;
const char FORWARD = 'F';
const char TURN = 'T';

int main() {
	string s;
	int x, y;
	cin >> s >> x >> y;
	
	int read = 0;
	for (;s[read] == FORWARD;++ read) -- x; // 最初の文字数だけxを減らす
	x = x < 0 ? -x : x;
	y = y < 0 ? -y : y;
	
	bitset<MAX> dpX(1), dpY(1); // 部分和問題はdpで解けるよ
	int xSum = 0, ySum = 0;
	
	for (++ read;s[read] != '\0';++ read) {
		int xGo = 0, yGo = 0; // 連続した移動の長さ
		for (;s[read] == FORWARD;++ read) ++ yGo; // y軸方向
		dpY |= dpY << yGo;
		ySum += yGo;
		
		if (s[read] == '\0') break;
		for (++ read;s[read] == FORWARD;++ read) ++ xGo; // x軸方向
		dpX |= dpX << xGo;
		xSum += xGo;
	}
	
	if (xSum >= x && (xSum - x & 1) == 0 && dpX[xSum - x >> 1] && ySum >= y && (ySum - y & 1) == 0 && dpY[ySum - y >> 1]) cout << "Yes"; // 例えば左右に合計100マス動けるとして、目的地が20なら丁度60動けるような部分和があれば移動可能、と考えるよ
	else cout << "No";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、x方向とy方向はそれぞれ独立に求めることができる
最初に、Tが出てくるまで自分を動かしてしまう
そうすると、残りはどちらの方向にも動けるので、左右か上下ということさえ分かっていれば左と右および上と下の区別をつける必要はない
この時、部分和問題を解けば答えが分かる
*/

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;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 elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
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 kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	int n;
	string s, t;
	cin >> n;
	cin >> s >> t;
	rep(i, n) {
		cout << s[i] << t[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
N = int(input())
count = 0
for i in range(1, 6):
    if N-(10**i) < 0:
        break;
    else:
        count += 1
if count == 0:
    p = N
elif count == 1: 
    p = 9
elif count == 2:
    p = 9 + N - 100 + 1
elif count == 3:
    p = 909
elif count == 4:
    p = 909 + N - 10000 + 1
else:
    p = 90909
print(p)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();

	    double menseki=r*r*3.141592653589;
	    double gaisyuu=r*2*3.141592653589;

	    System.out.println(String.format("%.6f", menseki) + " " + String.format("%.6f", gaisyuu));

	}

}

Measured memory_bytes: 28140
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


signed main()
{
    int N, M, ans = 1;
    COMinit();
    map<int, int> mp;
    cin >> N >> M;
    for(int i = 2; i * i <= M; i++){
        int cnt = 0;
        while(M % i == 0){
            M /= i;
            cnt++;
        }
        ans = (ans * COM(N + cnt - 1, N - 1)) % mod;
    }
    if(M > 1){
        ans = (ans * COM(N + 1 - 1, N - 1)) % mod;
    }
    cout << ans << endl;


    return 0;
}
/*


*/


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

int main() {
  ll n;
  ll i = 0;
  ll ans = 0;
  cin >> n;
  
  while (n>0) {
    ans += pow(2,i);
    n /= 2;
    i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <climits>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <atcoder/all>
#include <random>
using namespace atcoder;
using namespace std;

using Pair = pair<int, int>;
using lint = long long;

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

// const int mod = 1e9 + 7;
// const int mod = 998244353;

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<int> solver1(int n,vector<pair<Pair,int>> xy){
  sort(xy.begin(), xy.end());
  stack<Pair> s;
  dsu d(n);
  rep(i, n) {
    if (!s.empty()) {
      Pair mn = s.top();
      if (mn.first < xy[i].first.second) {
        s.pop();
        d.merge(i, mn.second);
        while (!s.empty() && s.top().first < xy[i].first.second) {
          d.merge(i, s.top().second);
          s.pop();
        }
        s.push(mn);
      } else {
        s.push(Pair(xy[i].first.second, i));
      }
    }else s.push(Pair(xy[i].first.second, i));
  }
  vector<int> ret(n);
  rep(i, n) ret[xy[i].second] = d.size(i);
  return ret;
}
void input(int &n,vector<pair<Pair,int>> &xy){
  cin >> n;
  xy.resize(n);
  rep(i, n) {
    cin >> xy[i].first.first >> xy[i].first.second;
    xy[i].second = i;
  }
}
vector<int> solver2(int n,vector<pair<Pair,int>> xy){
  sort(xy.begin(), xy.end());
  dsu d(n);
  rep(i, n) {
    rep(j,i){
      if (xy[i].first.first > xy[j].first.first &&
          xy[i].first.second > xy[j].first.second){
        d.merge(i, j);
      }
    }
  }
  vector<int> ret(n);
  rep(i, n) ret[xy[i].second] = d.size(i);
  return ret;
}
void random(int &n,vector<pair<Pair,int>> &xy){
  n = 4;
  xy.resize(n);
  std::random_device seed_gen;
  std::mt19937 engine(seed_gen());
  vector<int> a(n), b(n);
  rep(i, n){
    a[i] = i + 1;
    b[i] = i + 1;
  }
  shuffle(a.begin(), a.end(), engine);
  shuffle(b.begin(), b.end(), engine);
  rep(i,n){
    xy[i].first.first=a[i];
    xy[i].first.second = b[i];
    xy[i].second = i;
  }
}
void test(int n,vector<pair<Pair,int>> xy){
  int cnt = 0;
  while (1) {
    random(n, xy);
    vector<int> ret1 = solver1(n, xy), ret2 = solver2(n, xy);
    if (ret1 != ret2) {
      cout << n << endl;
      rep(i, n) {
        cout << xy[i].first.first << " " << xy[i].first.second << endl;
      }
      rep(i, n) cout << ret1[i] << " ";
      cout << endl;
      rep(i, n) cout << ret2[i] << " ";
      cout << endl;
      break;
    }
    cout << cnt << endl;
    cnt++;
  }
}
int main(){
  int n;
  vector<pair<Pair,int>> xy(n);
  input(n,xy);
  vector<int> ret(n);
  ret = solver1(n, xy);
  rep(i, n) cout << ret[i] << endl;
  //test(n, xy);
}


Measured memory_bytes: 10264
import itertools
b=[]
for a in itertools.product((0, 1), repeat=3):
    b.append(a)

A=input()
c=int(A[0])
for i in range(len(b)):
    c=int(A[0])
    for j in range(3):
        if b[i][j]==0:
                c=c+int(A[j+1])
        else:
                c=c-int(A[j+1])
    if c==7:
        print(A[0],end="")
        for j in range(3):
            if b[i][j]==0:
                print("+",end="")
            else:
                print("-",end="")
            print(A[j+1],end="")
        print("=7")
        break
    

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    int ans = 0;
    while (1) {
        bool ok = true;

        rep(i, N) {
            if (h[i] != 0) {
                ok = false;
                ans++;
                for (int j = i; j < N; j++) {
                    if (h[j] == 0) {
                        break;
                    }
                    h[j]--;
                }
                break;
            }
        }

        if (ok) {
            break;
        }
    }

    cout << ans << endl;
}


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

class Program
{
    static string S;

    public static void Main(string[] args)
    {
        S = Input.NextString();

        var s0 = S.Substring(0, 2);
        var s1 = S.Substring(2, 2);

        bool canMMYY = IsMonth(int.Parse(s0));
        bool canYYMM = IsMonth(int.Parse(s1));

        string s = "";
        if (canMMYY)
        {
            if (canYYMM)
            {
                s = "AMBIGUOUS";
            }
            else
            {
                s = "MMYY";
            }
        }
        else
        {
            if (canYYMM)
            {
                s = "YYMM";
            }
            else
            {
                s = "NA";
            }
        }

        Console.WriteLine(s);
    }

    static bool IsMonth(int x)
    {
        if (1 <= x && x <= 12)
        {
            return true;
        }
        return false;
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 13268
package main
import (
  "fmt"
  "math"
  "os"
  "strconv"
)
func main() {
  var k,n int64
  fmt.Scan(&k)
  for i:=int64(0);i<9;i++ {
    if i == k { os.Exit(0) }
    fmt.Println(i+1)
  }
  n = 19
  for i:=k-9;i>0;i-- {
    fmt.Println(f(n))
    n = f(n+1)
  }
}
func f(n int64) int64 {
  var u int = int(math.Log10(float64(n)))+1
  var e int64 = 10
  var m int64 = 10*int64(float64(n)/10.0+1)-1
  for d:=1;d<u;d++ {
    e *= 10
    x := e*int64(float64(n)/float64(e)+1)-1
    if float64(m)/float64(s(m)) > float64(x)/float64(s(x)) { m = x }
  }
  return m
}
func s(n int64) int64 {
  var s string
  var m,t int64
  s = strconv.FormatInt(n,10)
  m = 0
  for i:=0;i<len(s);i++ {
    t,_ = strconv.ParseInt(s[i:i+1],10,64)
    m += t
  }
  return m
}

Measured memory_bytes: 1024
# coding:utf-8

def main():
    N = int(input())
    s = input()
    count_white = 0
    count_black = 0
    count_border = N
    temp = ""
    patern3_white = [0]*N
    patern3_black = [0]*N
    # patern3 = []
    if (not "." in s) or (not "#" in s):
        print(0)
        return

    for i in s:
        if i == ".":
            count_white += 1
        elif i == "#":
            count_black += 1

    for i in range(N-1):
        if i == 0:
            if s[0] == "#":
                patern3_white[0] = 1
                patern3_black[0] = count_white
            else:
                patern3_white[0] = 0
                patern3_black[0] = count_white -1
        else :
            if s[i] == "#":
                patern3_white[i] = patern3_white[i-1] + 1
                patern3_black[i] = patern3_black[i-1]
            else :
                patern3_white[i] = patern3_white[i-1]
                patern3_black[i] = patern3_black[i-1] - 1
        # patern3.append(patern3_white[i] + patern3_black[i])

        if count_border > patern3_white[i] + patern3_black[i] :
            count_border = patern3_white[i] + patern3_black[i]

    # print(patern3_black)
    # print(patern3_white)
    # print(patern3)
    # print()
    # count_border = min(patern3)
    # print(count_white)
    # print(count_black)
    # print(count_border)
    print(min(count_white,count_black,count_border))

if __name__ == "__main__":
    main()

Measured memory_bytes: 12764
<?php

fscanf(STDIN, "%d %d", $n, $k);
const MAX = 2005;
const MOD = 1000000007;

function extGcd($a, $b, &$x, &$y) {
    if ($b === 0) {
        $x = 1;
        $y = 0;
        return $a;
    }

    $d = extGcd($b, $a % $b, $y, $x);
    $y -= floor($a / $b) * $x;
    return $d;
}

$fac = []; $fac[0] = 1; $fac[1] = 1;
$inv = []; $inv[1] = 1;
$finv = []; $finv[0] = 1; $finv[1] = 1;

for ($i = 2; $i < MAX; ++$i) {
    $fac[$i] = $fac[$i - 1] * $i % MOD;

    $x; $y; extGcd($i, MOD, $x, $y);
    $x = ($x % MOD + MOD) % MOD;
    $inv[$i] = $x;

    $finv[$i] = $finv[$i - 1] * $inv[$i] % MOD;
}

function COM($n, $k) {
    if ($n < $k) {
        return 0;
    }

    if ($n < 0 || $k < 0) {
        return 0;
    }

    global $fac;
    global $finv;

    return $fac[$n] * ($finv[$k] * $finv[$n - $k] % MOD) % MOD;
}

for ($i = 1; $i <= $k; ++$i) {
    echo COM($n - $k + 1, $i) * COM($k - 1, $i - 1) % MOD, PHP_EOL;
}


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

ll dp[11111];

int main() {
    int N, W;
    cin >> N >> W;
    for (int i = 0, v, w; i < N; i++) {
        cin >> v >> w;
        for (int j = w; j <= W; j++) {
            dp[j] = max(dp[j], dp[j - w] + v);
        }
    }
    ll ans = 0;
    for (int j = 0; j <= W; j++) ans = max(ans, dp[j]);
    cout << ans << endl;
}


Measured memory_bytes: 3160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            if (a > b) {
                long temp = a;
                a = b;
                b = temp;
            }
            long sol = a - 1;
            long lo = 0;
            long hi = b - 1;
            while (lo < hi) {
                long mi = (lo + hi + 1) / 2;
                long low = 0;
                long high = mi - 1;
                while (low < high) {
                    long mid = (low + high) / 2;
                    if ((mi - mid) * (a + 1 + mid) >
                            (mi - (mid + 1)) * (a + 2 + mid)) {
                        high = mid;
                    } else {
                        low = mid + 1;
                    }
                }
                if ((mi - low) * (a + 1 + low) < a * b) {
                    lo = mi;
                } else {
                    hi = mi - 1;
                }
            }
            System.out.println(sol + lo);
        }
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21716
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		System.out.print(A.charAt(0));
		System.out.print(B.charAt(0));
		System.out.println(C.charAt(0));
	}
}

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

int n,m,a[100010],ans;

 struct dsu
{
	int fa[200010],rank[200010];
	
	void init(int n)
	{
		for(int i=1;i<=n;i++)
		{
			fa[i]=i;
		}
	}
	
	int find(int x)
	{
		if(fa[x]==x)
		{
			return x;
		}
		return fa[x]=find(fa[x]);
	}
	
	void union_(int x,int y)
	{
		int fx=find(x);
		int fy=find(y);
		if(fx==fy)
		{
			return ;
		}
		if(rank[fx]<rank[fy])
		{
			fa[fx]=fy;
		}
		else
		{
			fa[fy]=fx;
			if(rank[fx]==rank[fy])
			{
				rank[x]++;
			}
		}
	}
	
	int same(int x,int y)
	{
		return find(x)==find(y);
	}
}b;

int main()
{
	cin>>n>>m;
	b.init(n); 
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]); 
	} 
	for(int i=1;i<=m;i++)
	{
		int from,to;
		scanf("%d%d",&from,&to);
		b.union_(from,to);
	}
	for(int i=1;i<=n;i++)
	{
		if(b.same(a[i],i))
		{
			ans++;
		}
	}
	printf("%d\n",ans);
}

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

int main() {
    string S, T;
    cin >> S >> T;
    vector<string> anslist;

    bool next = false;
    for (long long i = 0; i < S.size(); i++) {
        long long matchCnt = 0;
        for (long long j = 0; j < T.size(); j++) {
            if (i + j >= S.size()) {
                continue;
            }
            if (S[i + j] == '?' || S[i + j] == T[j]) {
                matchCnt++;
                continue;
            }
        }
        if (matchCnt == T.size()) {
            string str = S;
            for (long long j = 0; j < T.size(); j++) {
                str[i + j] = T[j];
            }
            for (long long i = 0; i < str.size(); i++) {
                if (str[i] == '?') {
                    str[i] = 'a';
                }
            }
            anslist.push_back(str);
        }
    }
    if (anslist.size() > 0) {
        sort(anslist.begin(), anslist.end());
        cout << anslist[0] << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}


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

using namespace std;

int N, K;
bool know[110][110];
int out[110];

void solve() {
	vector<int> res;
	
	for (int i = 0; i < N; i++) {
		bool flag = true;
		for (int j = 0; j < K; j++) {
			flag &= know[i][out[j]];
		}
		if (flag) res.push_back(i);
	}
	
	if ((int)res.size() == 1) {
		cout << res[0] + 1 << endl;
	} else {
		cout << -1 << endl;
	}
}

int main() {
	while (1) {
		cin >> N; if (N == 0) break;
		
		memset(know, 0, sizeof(know));
		for (int i = 0; i < N; i++) {
			int M; cin >> M;
			for (int j = 0; j < M; j++) {
				int p; cin >> p;
				know[i][p] = true;
			}
		}
		
		cin >> K;
		for (int i = 0; i < K; i++) cin >> out[i];
		
		solve();
	}
	
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

int main(void) {
    int n;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    FOR(i, n , 1000) {
        if (i == (i / 100) * 111) {
            cout << i << "\n";
            break;
        }
    }
    
    return 0;
}

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

using namespace std;

class UnionFind
{
public:
  vector<int> r;
  UnionFind(int N) {
    r = vector<int>(N, -1);
  }

  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }
  
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if(r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  int size(int x) {
    return -r[root(x)];
  }
};

int main(int argc, char const *argv[])
{
  int N, M;
  cin >> N >> M;

  // 友人集合を作る
  UnionFind UF(N);
  for(int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A -= 1; B -= 1;
    UF.unite(A, B);
  }

  // 要素数が最大の友達集合を求める
  int ans = 0;
  for(int i = 0; i < N; i++){
    ans = max(ans, UF.size(i));
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c&&c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N=510;
int n,m;
char a[N][N];
void readData(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
}
void print(){
	for(int i=1;i<=n;i++,puts("")){
		putchar('#');
		for(int j=2;j<m;j++)
			if(a[i][j]=='#') putchar('#');
			else putchar((i&1)?'#':'.');
		putchar('.');
	}
	puts("");
	for(int i=1;i<=n;i++,puts("")){
		putchar('.');
		for(int j=2;j<m;j++)
			if(a[i][j]=='#') putchar('#');
			else putchar(!(i&1)?'#':'.');
		putchar('#');
	}
}
int main(){
	readData();
	print();
	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

int N;
long long K;
long long A[100000];
long long C[40][2];

long long max(long long x, long long y) {
    return x > y ? x : y;
}

int main() {
    scanf("%d %lld", &N, &K);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
        for (int j = 0; j < 40; j++) {
            C[j][A[i] >> j & 1]++;
        }
    }
    long long ans = 0;
    long long curr = 0;
    for (int i = 39; i >= 0; i--) {
        if (K >> i & 1) {
            long long cand = curr;
            cand += C[i][1] << i;
            for (int j = i - 1; j >= 0; j--) {
                cand += max(C[j][0], C[j][1]) << j;
            }
            ans = max(ans, cand);
        }
        curr += C[i][~K >> i & 1] << i;
    }
    ans = max(ans, curr);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace AtCoder
{
    class Program
    {
        static int N;
        static int M;
        static List<int> P;
        
        static void Main(string[] args)
        {
            //[summary]C - Switches
            var line = ReadLine();
            N = line[0];
            M = line[1];
            
            var switches = GetSwitches();
            P = ReadLine();
            int ans = 0;
            
            for(int i = 0; i < Math.Pow(2, N); i++)
            {
                var s = Convert.ToString(i, 2);
                var binary = s.PadLeft(N, '0');
                
                if(IsAllLights(switches, binary))
                {
                    ans++;    
                }
            }
            
            Console.WriteLine(ans);
        }
        
        static bool IsAllLights(List<List<int>> switches, string binary)
        {
            for(int i = 0; i < M; i++)
            {
                int count = CountOns(switches[i], binary);
                    
                if(count % 2 != P[i])
                {
                    return false;    
                }
            }
            
            return true;
        }
        
        static int CountOns(List<int> switches, string binary)
        {
            int count = 0;
            
            foreach(var s in switches)
            {
                if(binary[s] == '1')
                {
                    count++;
                }  
            }
            
            return count;
        }
        
        static List<List<int>> GetSwitches()
        {
            var switches = new List<List<int>>();
            
            for(int i = 0; i < M; i++)
            {
                var line = ReadLine();
                var s = line.Skip(1).Select(x => x - 1).ToList();
                
                switches.Add(s);
            }
            
            return switches;
        }
 
        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');
 
            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

int main() {
	int n;
	cin>>n;
	vector<long long> a;
	a.push_back(2);
	a.push_back(1);
	for(int i=2;i<=n;++i) {
		a.push_back(a[i-1] + a[i-2]);
	}
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << min(c,b/a) << endl; return 0;
}

Measured memory_bytes: 256
a = [int(x) for x in input().split()]
count1=0
count0=0
count2=0
if a[3]>a[1]:
   count1=a[0]
if a[3]<=a[1]:
    count1=a[3]
if a[3]-a[1]-a[0]>0:
    count2=-(a[3]-a[1]-a[0])
print(count1+count2)


Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
int main(){
	int D; cin >> D; 
	int C[30] = {}; 
	for(int i = 1; i <= 26; i++) cin >> C[i]; 
	int S[370][30] = {}; 
	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= 26; j++){
			cin >> S[i][j]; 
		}
	}
	int T[370] = {}; 
	for(int i = 1; i <= D; i++) cin >> T[i]; 
	int now = 0; 
	int L[30] = {}; 
	for(int i = 1; i <= D; i++){
		now += S[i][T[i]]; 
		L[T[i]] = i; 
		for(int j = 1; j <= 26; j++){
			if(j == T[i]) continue; 
			now -= C[j] * (i - L[j]); 
		}
		cout << now << endl; 
	}
}

Measured memory_bytes: 3608
x = [int(x) for x in input().split()]

a = x[0]
b = x[1]
c = x[2]
X = x[3]


if (a+b+c) == 0:
    print(0)
else:
    if (a+b) >= X:
        print(min([a,X]))
    else:
        extra = X-a-b
        print(a-extra)


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

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

    if(a>b) {
        for(int i=0; i<a; i++) cout<<b;
    }
    else for(int i=0; i<b; i++) cout<<a;

    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
b = gets.to_s.split.map(&:to_i)
a = []
beforeNum = 10**6
b.each.with_index do |c, i|
  a[i] = c > beforeNum ? beforeNum : c
  beforeNum = c
  a[i + 1] = c
end
puts a.inject(:+)

Measured memory_bytes: 3836
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=54;

struct matrix
{
    ll mat[N][N];
    
    matrix()
    {
        memset(mat,0,sizeof(mat));
    }
    
    void iden()
    {
        rep(i,0,N)
        mat[i][i]=1;
    }
    
    matrix operator *(matrix other)
    {
        matrix res;
        
        rep(i,0,N)
        {
            rep(j,0,N)
            {
                ll here=0;
                
                rep(k,0,N)
                here=(here+(mat[i][k]*other.mat[k][j])%mod)%mod;
                
                res.mat[i][j]=here;
            }
        }
        
        return res;
    }
};

matrix me(matrix a,ll b)
{
    matrix res;
    
    res.iden();
    
    while(b)
    {
        if(b&1)
        res=res*a;
        
        b>>=1;
        
        a=a*a;
    }
    
    return res;
}

int main()                  
{
    int n; ll k;
    
    scn(n); lscn(k);
    
    matrix a;
    
    rep(i,0,n)
    {
        rep(j,0,n)
        lscn(a.mat[i][j]);
    }
    
    a=me(a,k);
    
    ll ans=0;
    
    rep(i,0,n)
    {
        rep(j,0,n)
        ans=(ans+a.mat[i][j])%mod;
    }
    
    lpri(ans);
} 

Measured memory_bytes: 384
#include <iostream>
#include <boost/math/common_factor.hpp>
#include <boost/bind.hpp>
using namespace std;
using namespace boost;
using namespace math;

int main(){
  int a, b;

  while(cin >> a >> b){
    
    cout << gcd(a, b) <<  ' ';
    cout << lcm(a, b) << endl;
    
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        int a=sc.nextInt(),v=sc.nextInt(),
        		b=sc.nextInt(),w=sc.nextInt(),t=sc.nextInt();
        if(v<=w)ret("NO");
        int d=abs(a-b),dv=abs(v-w);
        if((d+dv-1)/dv<=t)ret("YES");

        out.println("NO");
     	out.flush();
    }
        
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x,y,c;
	P(int  x, int y, int c) {
	  this.x=x;
	  this.y=y;
	  this.c=c;
	}
}

//
//class P implements Comparable<P>{
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//
//    public int compareTo(P p){
//        return Long.signum(s-p.s);
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 33132
#include <iostream>
using namespace std;
int main(void){
    int N, k;
    cin >> N >> k;
    long long int t = 0;
    for(int i = 1; i < N; i++){
        t += t / (k - 1) + 1;
    }
    cout << t << endl;
    return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	long n, i, m, minM = pow(10, 13);
	cin >> n;
	for(i = 1; i <= sqrt(n); i++)
	{
		if(n % i == 0)
		{
			m = n / i;
			m--;
			m += i-1;
			minM = (minM > m? m: minM);
		}
	}
	cout << minM << endl;
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  bool bl = true;
  h[0] -= 1;
  for (int i = 1; i <= n-1; i++) {
    if (h[i] > h[i-1]) h[i]--;
    else if (h[i] < h[i-1]) bl = false;
  }
  if (bl) {
  cout << "Yes" << '\n';
  } else {
  cout << "No" << '\n';
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1000111;

const ll MOD = 1000000007LL;

void solve() {

}

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

    ll L, R;
    cin >> L >> R;

    ll cp = L;

    while (L <= R) {
        if (L%2019 == 0) {
            cout << 0;
            return 0;
        }
        L++;
    }

    ll ans = LLONG_MAX;
    for (ll i=cp; i<=R; i++) {
        for (ll j=i+1; j<=R; j++) {
            ll tmp = (i%2019) * (j%2019);
            tmp %= 2019;
            ans = min(ans, tmp);
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.StringBuilder;
public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        StringBuilder bu = new StringBuilder();
        int h=sc.nextInt();
            for(int i=1;i<=h;i++){
                int x=i;
                    if(x%3==0){
                        bu.append(" ").append(i);
                    }else{
                        while(x!=0){
                            if(x%10==3){
                                bu.append(" ").append(i);
                                break;
                            }else{
                                x/=10;
                            }
                        }
                    }
            }
        System.out.println(bu);
    }
}

Measured memory_bytes: 27264
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
        switch(s){
          case "A":
            System.out.println("T");
            break;
          case "T":
            System.out.println("A");
            break;
          case "G":
            System.out.println("C");
            break;
          case "C":
            System.out.println("G");
            break;
          default :
            break;
        }
	}
}

Measured memory_bytes: 21460