akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int dat[100000][26][26];
int sbst[100000];
class trie
{
public:
	int nxt[400001][26];
	int cnt[400001];
	int flag[400001];
	int pt;
	void init()
	{
		pt = 1;
		fill(nxt[0], nxt[0] + 26, -1);
	}
	void add(string s)
	{
		int now = 0;
		cnt[0]++;
		for (int i = 0; i < s.size(); i++)
		{
			if (nxt[now][s[i] - 'a'] == -1)
			{
				fill(nxt[pt], nxt[pt] + 26, -1);
				nxt[now][s[i] - 'a'] = pt++;
			}
			now = nxt[now][s[i] - 'a'];
			cnt[now]++;
		}
		flag[now]++;
	}
	void calc(string s, int p)
	{
		int now = 0;
		for (int i = 0; i < s.size(); i++)
		{
			for (int j = 0; j < 26; j++)
			{
				if (s[i] - 'a' == j)continue;
				if (nxt[now][j] != -1)
				{
					dat[p][j][s[i] - 'a'] += cnt[nxt[now][j]];
				}
			}
			now = nxt[now][s[i] - 'a'];
			sbst[p] += flag[now];
		}
	}
};
trie tr;
int main()
{
	int num;
	scanf("%d", &num);
	vector<string>vec;
	tr.init();
	for (int i = 0; i < num; i++)
	{
		string s;
		cin >> s;
		vec.push_back(s);
		tr.add(s);
	}
	for (int i = 0; i < vec.size(); i++)tr.calc(vec[i], i);
	int query;
	scanf("%d", &query);
	for (int p = 0; p < query; p++)
	{
		int z;
		scanf("%d", &z);
		z--;
		string s;
		cin >> s;
		int ans = 0;
		for (int i = 0; i < 26; i++)
		{
			for (int j = i + 1; j < 26; j++)
			{
				ans += dat[z][s[i]-'a'][s[j]-'a'];
			}
		}
		printf("%d\n", ans + sbst[z]);
	}
}

Measured memory_bytes: 287860
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll X, Y;

int main()
{
    ios::sync_with_stdio(false);
    cin >> X >> Y;
    int ans = 0;
    while (X<=Y){
        X*=2;
        ++ans;
    }
    CO(ans);
    return 0;
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

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

    vector<int> r, g, b;

    rep(i, N)
    {
        if(S[i]=='R')
        {
            r.push_back(i);
        }
        else if(S[i]=='G')
        {
            g.push_back(i);
        }
        else
        {
            b.push_back(i);
        }
        
    }

    

    ll ans = r.size()*g.size()*b.size();
    
    for(int i=0; i<N; i++)
    {
        for(int j=i+1; j<N; j++)
        {
            int k=2*j-i;

            if(S[i]!=S[j]&&S[j]!=S[k]&&S[k]!=S[i]&&j<k&&k<N)
                ans--;
        }
    }

 

    cout << ans << endl;
    
 

 

 

    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
count = 0

if 1 in a:
    pass
else:
    print(-1)
    exit()

no = 1
for i in range(len(a)):
    if a[i]==no:
        no += 1
    else:
        count += 1

print(count)

Measured memory_bytes: 72012
fun main(args: Array<String>){
    val (N, M, K) = readLine()!!.split(" ").map { it.toInt() }
    val uf = UnionFind(N)
    val friend = IntArray(N + 1)

    repeat(M){
        val (A, B) = readLine()!!.split(" ").map { it.toInt() }
        uf.unite(A, B)
        friend[A]++
        friend[B]++
    }

    val size = IntArray(N+1)
    for(i in size.indices){
        size[i] = uf.unionSize(i) - friend[i] - 1
    }

    repeat(K){
        val (C, D) = readLine()!!.split(" ").map { it.toInt() }
        if(uf.isSameUnion(C, D)){
            size[C]--
            size[D]--
        }
    }

    println(size.drop(1).joinToString(separator = " "))
}

class UnionFind(n: Int) {

    private val parent = IntArray(n + 1) { i -> i }
    private val size = IntArray(n + 1){ i -> 1 }

    fun root(x: Int): Int {
        if (parent[x] == x) {
            return x
        } else {
            parent[x] = root(parent[x])
            return parent[x]
        }
    }

    fun unite(x: Int, y: Int) {
        val rx = root(x)
        val ry = root(y)
        if (rx != ry) {
            parent[rx] = ry
            size[ry] += size[rx]
        }
    }

    fun isSameUnion(x: Int, y: Int): Boolean {
        return root(x) == root(y)
    }

    fun unionSize(x: Int): Int{
        return size[root(x)]
    }
}

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

const int N = 100100;
vector <int> G[N];
int vis[N];
deque <int> ans;

void dfs(int u) {
  vis[u] = 1;
  for (int v : G[u]) {
    if (vis[v]) continue;
    ans.push_back(v);
    dfs(v);
    break;
  }
}

void dfs2(int u) {
  vis[u] = 1;
  for (int v : G[u]) {
    if (vis[v]) continue;
    ans.push_front(v);
    dfs2(v);
    break;
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0, u, v; i < m; i ++)
    scanf("%d %d", &u, &v), G[u].push_back(v), G[v].push_back(u);
  for (int i = 1; i <= n; i ++) {
    if (G[i].empty()) continue;
    ans.push_back(i);
    dfs(i); dfs2(i); break;
  }
  printf("%d\n", ans.size());
  while (ans.size())
    printf("%d%c", ans.back(), " \n"[ans.size() == 1]), ans.pop_back();
  return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int H, W;

//解法
void solve() {

	vector<vector<char>> vec(H, vector<char>(W));

	vector<bool> h(H, false), w(W, false);

	rep(i, H) rep(j, W) {
		cin >> vec[i][j];
		if (vec[i][j] == '#') {
			h[i] = true;
			w[j] = true;
		}
	}

	rep(i, H) {
		if (h[i]) {
			rep(j, W) {
				if (w[j]) {
					cout << vec[i][j];
				}
			}
			cout << endl;
		}
	}

	return;
}

int main() {
	//入力
	cin >> H >> W;
	solve();
	//cout << endl;
	return 0;
}


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

using namespace std;

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

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

	sort(v.begin(), v.end());

	for (int i = 0; i < n - 1; i++) {
		v[i + 1] = (v[i] + v[i + 1]) / 2.0;
	}

	cout << v[n - 1] << endl;

	return 0;
}

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

signed main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<pair<int, int>> v;
	rep(i, n) {
		int p;
		cin >> p;
		v.push_back(make_pair(p, 1));
	}
	rep(i, m) {
		int p;
		cin >> p;
		v.push_back(make_pair(p, 0));
	}
	v.push_back(make_pair(x, 1));
	v.push_back(make_pair(y, 0));
	sort(v.begin(), v.end());
	bool ok = true;
	rep(i, v.size() - 1) {
		if(v[i].second == 0 && v[i + 1].second == 1) {
			ok = false;
		}
	}
	if(ok) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	//A
	/*
	int a, b;
	cin >> a;
	cin >> b;

	if ((a <= 0) && (b >= 0)) {
		cout << "Zero";
	}
	else if(a>0){
		cout << "Positive";
	}
	else {
		if ((b - a) % 2 == 0) {
			cout << "Negative";
		}
		else {
			cout << "Positive";
		}
	}
	
	return 0;*/

	//B
	/*int n, m;
	int x;
	int y;
	int flag[100000];
	int ball[100000];
	cin >> n;
	cin >> m;
	int i,c;
	
	for (i = 0; i < 100000; i++) {
		flag[i] = 0;
		ball[i] = 1;
	}
	flag[0] = 1;
	for (i = 0; i < m; i++) {
		cin >> x;
		cin >> y;

		if (flag[x-1] == 1) {
			flag[y-1] = 1;
		}
		ball[x - 1]--;
		if (ball[x - 1] == 0) {
			flag[x - 1] = 0;
		}
		ball[y - 1]++;
	}
	c = 0;
	for (i = 0; i < n; i++) {
		if (flag[i] == 1) {
			c++;
		}
	}
	cout << c;
	return 0;*/
	
	//C
	int n,l;
	cin >> n;
	cin >> l;
	long long int a[100000];
	int i;
	int flag;
	flag = -1;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] >= l) {
			flag = i;
			break;
		}
	}

	if (flag == -1) {
		cout << "Impossible\n";
	}
	else {
		cout << "Possible\n";
		for (i = 0; i < flag; i++) {
			cout << i+1;
			cout <<'\n';
		}
		for (i = n-2; i >= flag; i--) {
			cout << i+1;
			cout << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
long double chg_DegRad(long double deg) {
	return deg * PI / 180.0;
}

//radian → degree
long double chg_RadDeg(long double rad) {
	return rad * 180.0 / PI;
}
 
//桁数
ll CountDigit(ll n) {
	ll digit = 1;
	while ((n /= 10) != 0) digit++;
	return digit;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}

//abs()平均
//pow(,)累乗


//提出コード↓


ll n, sm;
ll a[1000000];
map<ll,ll> m;

ll way_c(ll x) {
	ll c = 0;
	rep(i, x) c += i;
	return c;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		m[a[i]]++;
	}
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		sm += way_c(itr->second);
	}
	rep(i, n) {
		cout << sm - m[a[i]] + 1 << endl;
	}


	return 0;
}



Measured memory_bytes: 11904
n = gets.to_i

n.times do
  xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f)

  d = Math.sqrt((xb - xa)**2 + (yb - ya)**2)

  if ra > d + rb
    puts '2'
  elsif rb > d + ra
    puts '-2'
  elsif ra + rb >= d
    puts '1'
  else
    puts '0'
  end
end

Measured memory_bytes: 8688
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;


//=============prime_factor============================
vector<ll> prime_factor(ll N)
{
  vector<ll> res;
  for (ll i = 2; i * i <= N; ++i) {
    if (N % i == 0) {
      ll cnt = 0;
      while (N % i == 0) {
        N /= i;
        cnt += 1;
      }
      res.push_back(i);
    }
  }
  if (N != 1) {
    res.push_back(N);
  }
  return res;
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  ll gcd = A.at(0);
  for (ll i = 0; i < N; ++i) {
    gcd = __gcd(gcd, A.at(i));
  }
  bool setwise = true;
  if (gcd != 1) {
    setwise = false;
  }
  vector<bool> factor(pow(10, 6) + 1, false);
  bool pairwise = true;
  for (ll i = N - 1; i >= 0; --i) {
    vector<ll> temp = prime_factor(A.at(i));
    for (ll j = 0; j < temp.size(); ++j) {
      if (factor.at(temp.at(j))) {
        pairwise = false;
        break;
      }
      factor.at(temp.at(j)) = true;
    }
    if (!pairwise) {
      break;
    }
  }
  if (pairwise) {
    cout << "pairwise coprime" << "\n";
  }
  else if (setwise) {
    cout << "setwise coprime" << "\n";
  }
  else {
    cout << "not coprime" << "\n";
  }
}


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

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans    = 0;
  ll tmp[4] = { a *d, a *c, b *c, b *d };
  ans = max(tmp[0], max(tmp[1], max(tmp[2], tmp[3])));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int k,a,b,c;
  bool flag = true;
  cin >> k >> a >> b;
  c = k;
  while(c <= b)
  {
    if (c >= a)
    {
      cout << "OK" << endl;
      flag = false;
      break;
	}
    c += k;
  }
  if (flag)
  {
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3616
import java.util.*;

class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
  	int s = sc.nextInt();
  	int w = sc.nextInt();
  
  	if(s <= w){
    	System.out.println("unsafe");
  	} 	else {
    	System.out.println("safe");
  	}
  }
}

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


void solve(long long A, long long B, long long C, long long K){
    vector<long long> abc = {A,B,C};
    auto max = *max_element(abc.begin(), abc.end());
    cout << accumulate(abc.begin(), abc.end(), 0) + (int)(pow(2, K) * max) - max << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    lint passed = 0,p2=0;
    REP(i,SZ(s)){
        if(s[i]=='a'){
            if(a+b>passed){
                passed++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
        if (s[i] == 'b')
        {
            if (a + b > passed&&p2<b)
            {
                passed++;
                p2++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        if (s[i] == 'c')
            cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  vector<int> a(100010, 0);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    if (k != 0) a[k - 1]++;
    a[k]++;
    a[k + 1]++;
  }
  int ans = 0;
  for (int i = 0; i < 100010; i++) {
    ans = max(ans, a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
n=int(input())
S=[]
T=[]
time=0
for i in range(n):
    s,t=map(str,input().split())
    S.append(s)
    T.append(int(t))
x=input()
for i in range(50):
    if S[i]==x:
        break
for j in range(i+1,n):
    time+=T[j]
print(time)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		double yokin = 100;
		long X = scanner.nextLong();
		int i = 0;
		while(yokin < X) {
			yokin = Math.floor(yokin * 1.01);
			i++;
		}
		System.out.println(i);
	}
}


Measured memory_bytes: 35860
#include <bits/stdc++.h>
#define _itr ::iterator
#define forn(i, x, y) for (ll i = x; i < y; ++i)
#define ford(i, x, y) for (ll i = x; i > y; --i)
#define forne(i, x, y) for (ll i = x; i <= y; ++i)
#define forde(i, x, y) for (ll i = x; i >= y; --i)
#define rd(x) cin >> x; cin.ignore();
#define rdstr(x) getline(cin, x);
#define rdarr(x, y) for (ll i = 0; i < y; ++i) cin >> x[i];
#define rdmtr(x, y, z) for (ll i = 0; i < y; ++i) for (ll j = 0; j < z; ++j) cin >> x[i][j];
#define pb push_back

#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef long double ld;

const ll MaxN = 2e5 + 7;
const ll MaxM = 5e3 + 7;
const ll Mdl = 1e9 + 7;
const ll INF = 1e18 + 7;

typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef ll arr[MaxN];

ll REPIT = 1;

const bool MQ = false;

string s, t;

void Solve()
{
    rdstr(s); rdstr(t);
    ll m = s.size(), n = t.size();
    ll res = n;
    for (ll i = 0; i <= m - n; ++i)
    {
        ll cur = n;
        for (ll j = 0; j < n; ++j)
        {
            if (s[i + j] == t[j]) --cur;
        }
        res = min(cur, res);
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef OFFLINE
    freopen("input.inp", "r", stdin);
    #endif
    if (MQ == true)
    {
        rd(REPIT);
    }
    while (REPIT--) Solve();
    cout.flush();
    #ifdef OFFLINE
    fclose(stdin);
    #endif
}


Measured memory_bytes: 3656
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i = 1;i <= 3000;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(x == 0 && y == 0){
                break;
            }
            if(x <= y){
                System.out.println(x + " " + y);
            }else{
                System.out.println(y + " " + x);
            }
            
        }
    }
}


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

int main(){
	int N;
	cin >> N;
	vector<double> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	double b = 1, ans = 0;
	for (int i = 0;i < N - 1;i++) {
		b *= 2;
		ans += A[i] / b;
	}
	ans += A[N - 1] / b;
	printf("%.10f", ans);
}

Measured memory_bytes: 256
#include<stdio.h>

char n[20][20],m[20][20];
int i,j,a;

void s(int x,int y){
	n[x][y]='0';
	if(n[x+1][y]=='1')s(x+1,y);
	if(n[x][y+1]=='1')s(x,y+1);
	if(n[x-1][y]=='1')s(x-1,y);
	if(n[x][y-1]=='1')s(x,y-1);
}

int main(){
	while(scanf("%s",n[0])!=EOF){
		a=0;
		for(i=1;i<12;i++)scanf("%s",n[i]);
		for(i=0;i<12;i++){
			for(j=0;j<12;j++){
				if(n[i][j]=='1')s(i,j),a++;
			}
		}
		printf("%d\n",a);
	}
	
	return 0;
}

Measured memory_bytes: 0
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

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


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    a, b = input().split()
    a = int(a)
    b = b.split('.')
    if len(b) == 1:
        print(a * int(b[0]))
        return
    k = pow(10, len(b[1]))
    s = a * (int(b[0]) * k + int(b[1])) // k
    print(s)
main()


Measured memory_bytes: 65040
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main() {
  cin >> a >> b;
  c = a;
  bool ans = false;
  if(a % b == 0 || b % a == 0){
    cout << max(a,b) << endl;
    return 0;
  }
  while(!(ans)){
    a += c;
    if(a % b == 0){
      ans = true;
    }
  }
  cout << a << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int a,b,c,d; cin >> a >> b >> c >> d;
  cout << min(a,b)+min(c,d) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i,j,n;
    scanf("%d",&n);
    char ch[10000],c,m;
    c=getchar();
    gets(ch);
    for(i=0;ch[i]!='\0';i++)
    {
        ch[i]=ch[i]+n;
        if(ch[i]>'Z')
        {
            ch[i]=ch[i]-'Z';
            ch[i]='A'+ch[i]-1;
        }
    }
    printf("%s\n",ch);
    return 0;
}


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

typedef long long ll;
ll s[51] = {1};
ll p[51] = {1};

ll f(ll N, ll X) {
  if (N == 0 && X == 1) {
    return 1;
  } else if (X <= 1) {
    return 0;
  } else if (1 < X && X <= 1 + s[N - 1]) {
    return f(N - 1, X - 1);
  } else if (X == 2 + s[N - 1]) {
    return p[N - 1] + 1;
  } else if (2 + s[N - 1] < X && X <= 2 + 2 * s[N - 1]) {
    return p[N - 1] + 1 + f(N - 1, X - 2 - s[N - 1]);
  } else {
    return 2 * p[N - 1] + 1;
  }
}

int main() {
  ll N, X;
  cin >> N >> X;

  for (ll i = 1; i <= N; i++) {
    s[i] = 2 * s[i - 1] + 3;
    p[i] = 2 * p[i - 1] + 1;
  }

  cout << f(N, X) << endl;
  return 0;
}

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

using System.Linq;
public class abc178_b {

    static DateTime START_TIME;
    public static void Main() {
        START_TIME = DateTime.Now;
#if MYTEST
        while (true) {
            System.Console.Error.WriteLine("TEST MODE>");
            START_TIME = DateTime.Now;
            System.Console.WriteLine(Answer());  // debug
            System.Console.WriteLine($"{(DateTime.Now - START_TIME).Seconds} sec.");
        }
#else
        System.Console.WriteLine(Answer());
#endif
    }
    public static void debugOut(string str) {
#if MYTEST
        System.Console.Error.Write(str);
#endif
    }
    public static string Answer() {
        var p = System.Console.ReadLine().Trim().Split(' ');
        var a = long.Parse(p[0]);
        var b = long.Parse(p[1]);
        var c = long.Parse(p[2]);
        var d = long.Parse(p[3]);

        var max = (long)Math.Max(Math.Max(a * c, a * d), Math.Max(b * c, b * d));
        return max.ToString();
    }
}


Measured memory_bytes: 29620
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int hp[100005]={};
bool Attack(int cnt , int a, int b, int mNum)
{
	int d = a-b;
	int sumCnt = 0;
	for(int i=0;i<mNum;i++){
		int e = hp[i] - b*cnt;
		if (e <= 0){continue;}
		sumCnt += (e+(d-1))/d;
		if (cnt < sumCnt ){return false;}
	}
	return true;
}

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	// 入力
	int N , A , B;
	cin >> N >> A >> B;
	int maxHp = 0;
	for(int i=0;i<N;i++)
	{
		cin >> hp[i];
		maxHp = max(maxHp,hp[i]);
	}

	// 二分探索  ng < ok
	if ( Attack(1,A,B,N) ){printf("1\n");return 0;}
	int ng = 1;
	int ok = max( 2, (maxHp+(B-1))/B );
	while(1){
		if(ng+1==ok){break;}
		int mid = (ng+ok)/2;
		if ( Attack(mid,A,B,N) ){ok=mid;}else{ng=mid;}
	}

	printf("%d\n",ok);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, std::vector<long long> A){
    vector<int> B(N + 1);
    for (int i = 0; i < N; ++i) {
        B[i + 1] = B[i] + A[i];
    }

    int res = abs(B[N] - B[1] - B[1]);

    for (int i = 1; i < N; ++i) {
        res = min(res, abs(B[N] - B[i] - B[i]));
    }

    cout << res << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3456
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
#define READINT(X) if(ci-cn+16>cm){while((ct=readchar())>='0')(X)=(X)*10+ct-'0';}else{while((ct=*ci++)>='0')(X)=(X)*10+ct-'0';}

using namespace std;

uint16_t d, k;
uint32_t M = 0;
int_fast64_t c, sd = 0, sc = 0;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;

inline char readchar() {
    if(ci-cn==cm){fread_unlocked(cn,1,cm,stdin);ci=cn;}
    return *ci++;
}

int main() {
    READINT(M);
    while(M--) {
        d = 0;
        READINT(d);
        c = 0;
        READINT(c);
        sc += c;
        sd += c * d;
    }
    printf("%lld\n", --sc + --sd / 9);
	return 0;
}

Measured memory_bytes: 256
using Yorukatsu019.Questions;
using Yorukatsu019.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu019.Questions
{
    /// <summary>
    /// ABC117 B
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            int n = inputStream.ReadInt();
            var l = inputStream.ReadIntArray();

            Array.Sort(l);
            Array.Reverse(l);
            if (l[0] < l.Skip(1).Sum())
            {
                yield return "Yes";
            }
            else
            {
                yield return "No";
            }
        }
    }
}


namespace Yorukatsu019
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu019.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu019.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int main() {
    map<ll, ll> m;
    for (ll i = 0;i < 6;++i) {
        ll a;
        cin >> a;
        m[a]++;
    }
    for (auto p : m) {
        if (p.second > 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <type_traits>
#include <limits>
#include <tuple>

template <class Tp>
class lines {
  // based on Li Chao tree
  std::map<Tp, size_t> enc;
  std::vector<Tp> dec;
  std::vector<std::pair<Tp, Tp>> c;
  size_t m = 1;
  Tp inf = std::numeric_limits<Tp>::max() / 8;

private:
  void init_resize(size_t n) {
    while (m < n+n) m <<= 1;
    c.assign(m, {0, inf});
  }

  void inspect() const {
    for (size_t i = 1; i < m; ++i) {
      std::string s = (c[i].first < inf? std::to_string(c[i].first) : "inf");
      std::string t = (c[i].second < inf? std::to_string(c[i].second) : "inf");
      fprintf(stderr, "(%s, %s)%c", s.c_str(), t.c_str(), (i&(i+1))? ' ':'\n');
    }
  }

public:
  template <class ForwardIt>
  lines(ForwardIt first, ForwardIt last): dec(first, last) {
    static_assert(std::is_same<typename ForwardIt::value_type, Tp>::value, "Type mismatch");
    //std::sort(dec.begin(), dec.end());
    size_t n = dec.size();
    init_resize(n);
    // while (dec.size() < m/2) dec.push_back(dec.back()+1);
    dec.resize(m/2, dec.back());
    for (size_t i = 0; i < m/2; ++i) enc.emplace(dec[i], i);
  }

  void append(Tp a, Tp b) {
    size_t l = 0;
    size_t j = 1;
    size_t h = 1;
    size_t w = m/2;
    while (w > 0 && l+w-1 < dec.size()) {
      Tp xl = dec[l];
      Tp xm = dec[l+w/2];
      Tp xr = dec[l+w-1];

      Tp a0, b0;
      std::tie(a0, b0) = c[j];

      Tp yl0 = a0*xl + b0;
      Tp ym0 = a0*xm + b0;
      Tp yr0 = a0*xr + b0;

      Tp yl = a*xl + b;
      Tp ym = a*xm + b;
      Tp yr = a*xr + b;

      if (yl0 <= yl && yr0 <= yr) break;
      if (yl0 >= yl && yr0 >= yr) {
        c[j] = {a, b};
        break;
      }

      h <<= 1;
      w >>= 1;

      if (ym0 >= ym) {
        c[j] = {a, b};
        a = a0;
        b = b0;
        j <<= 1;
        if (yr0 < yr) {
          j |= 1;
          l += w;
        }
      } else {
        j <<= 1;
        if (yr0 >= yr) {
          j |= 1;
          l += w;
        }
      }
    }
  }

  Tp min_at(Tp x) const {
    size_t i = enc.at(x) + m/2;
    Tp y = inf;
    while (i > 0) {
      Tp a, b;
      std::tie(a, b) = c[i];
      y = std::min(y, a*x+b);
      i >>= 1;
    }
    return y;
  }
};

int main() {
  size_t N;
  intmax_t C;
  scanf("%zu %jd", &N, &C);

  std::vector<intmax_t> h(N);
  for (auto& hi: h) scanf("%jd", &hi);

  lines<intmax_t> cht(h.begin(), h.end());

  std::vector<intmax_t> dp(N);
  for (size_t i = 0; i+1 < N; ++i) {
    cht.append(-2*h[i], h[i]*h[i]+dp[i]);
    dp[i+1] = cht.min_at(h[i+1]) + h[i+1]*h[i+1] + C;
  }

  printf("%jd\n", dp[N-1]);
}


Measured memory_bytes: 26880
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n,k; cin>>n>>k;
    vector<ll> p(n), c(n);
    for( ll &i : p){
        cin>>i;
    } 
    for(ll &i : p){
        i--;
    }
    for(ll &i : c){
        cin>>i;
    }
    ll ans = -LLONG_MAX;
    for(int i = 0 ; i < n; i++){
        int curr = i;
        ll cycle_score = 0;
        int cnt = 0;
        while(true){
            cycle_score+= c[curr];
            curr = p[curr];
            cnt++;
            if(curr==i) break;
            
        }
        ll single = 0;
        int cnt2 = 0;
        while(true){
            cnt2++;
            single += c[curr];
            if(cnt2 > k){
                break;
            }
            int num = (k-cnt2)/cnt;
            ans = max(ans, single + max(0LL,cycle_score)*num);
            curr = p[curr];
            if(curr==i) break;
        }
       
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  ll N,i,ans = 0;scanf("%lld",&N);
  ll A[N];
  for(i=0;i<N;i++) scanf("%lld",&A[i]);
  for(i=1;i<N;i++){
    if(A[i] < A[i-1]){
      ans += A[i-1]-A[i];
      A[i] = A[i-1];
    }
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define add(a,b) a=((a)+(b))%1000000007
#define min(a,b) (a<b?a:b)
#define mod 1000000007
#define Mod 1000000005
#define ll long long
#define N 1000
//#define file
using namespace std;

ll f[71][71][72],jc[N+1],Jc[N+1],ans;
int d[71],n,m,i,j,k,l,x,y;
char a[71];
bool bz[71];

ll qpower(ll a,int b) {ll ans=1; while (b) {if (b&1) ans=ans*a%mod;a=a*a%mod;b>>=1;} return ans;};
ll C(int n,int m) {if (n<m) return 0;return jc[n]*Jc[m]%mod*Jc[n-m]%mod;}

int main()
{
	#ifdef file
	freopen("arc089F.in","r",stdin);
//	freopen("a.out","w",stdout);
	#endif
	
	jc[0]=1;
	fo(i,1,N) jc[i]=jc[i-1]*i%mod;
	Jc[N]=qpower(jc[N],Mod);
	fd(i,N-1,0) Jc[i]=Jc[i+1]*(i+1)%mod;
	
	scanf("%d%d",&n,&m);
	scanf("%s",a+1);
	ans=1;
	fo(x,0,n)
	{
		fo(y,0,n)
		if (x || y)
		{
			memset(bz,0,sizeof(bz)),k=l=0;
			fo(i,1,x)
			{
				fo(j,1,m) if (!bz[j] && a[j]=='r') break;
				fo(k,j,m) if (!bz[k] && a[k]=='b') break;
				if (k>m) break;
				bz[j]=bz[k]=1;
			}
			if (k>m) continue;
			fo(i,1,m) if (l<y && !bz[i] && a[i]=='r') ++l,bz[i]=1;
			if (l<y) continue;
			
			l=0;
			fd(j,m,1)
			if (bz[j] && a[j]=='b')
			{
				d[++l]=0;
				fo(k,j,m) d[l]+=!bz[k];
			}
			
			memset(f,0,sizeof(f)),f[0][0][0]=1;
			fo(i,0,x-1)
			{
				fo(j,0,d[x])
				{
					fo(k,0,d[x])
					if (f[i][j][k])
					{
						if (k<d[x]) add(f[i][j][k+1],f[i][j][k]);
						fo(l,1,x-i)
						if (j+l*k<=d[i+l])
						add(f[i+l][j+l*k][k+1],f[i][j][k]*C(i+l+y,l));
						else break;
					}
				}
			}
			
			fo(j,0,d[x])
			{
				fo(k,0,d[x]+1)
				{
					fo(l,0,n)
					add(ans,f[x][j][k]*C(l+(y+2*j+x*3)-1,(y+2*j+x*3)-1)%mod*C(n-(x+y-1)-2*j-l,x+y));
				}
			}
		}
	}
	printf("%lld\n",ans);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 6684
n = int(input())
a = list(map(int, input().split()))
q = int(input())
numl = [0] * 100005
resl = []
suma = sum(a)
for i in range(n):
    numl[a[i]]+=1
for i in range(q):
    b, c = map(int, input().split())
    bn = numl[b]
    suma += (c - b)* bn
    resl.append(suma)
    numl[b] -= bn
    numl[c] += bn
for i in resl:
    print(i)

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A == 1) A = 14;
  if (B == 1) B = 14;
  if (A > B) {
    cout << "Alice" << endl;
  } else if (A < B) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
}


Measured memory_bytes: 256
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=1e5+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll a,b,c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>a>>b>>c;
	ll ans=min(c,max(b,0ll))*2;
	c-=ans/2;
	b-=ans/2;
	ans+=min(c,a+1);
	cout<<ans+b;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static int M, N, res = Integer.MIN_VALUE;
    public static BitSet[] map;
    public static int[][] dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            N = sc.nextInt();
            M = sc.nextInt();
            res = Integer.MIN_VALUE;
            if (N == 0 && M == 0) break;
//            sc.nextLine();
            map = new BitSet[N];
            for (int i = 0; i < N; i++) {
                map[i] = new BitSet(M);
            }
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++) {
                    map[i].set(j, sc.nextInt() == 1);
                }
            }
            int ro = (1 << N) - 1, co = (1 << M) - 1;
            for (int i = ro; i >= 0; --i) {
                solve(i);
            }
            System.out.println(res);
        }
    }

    public static void solve(int ro) {
        int tro = ro;
        for (int i = 0; i < N; i++) {
            if ((ro & 1) == 1) {
                map[i].flip(0, M);
            }
            ro >>= 1;
        }
        int sum = 0;
        for (int j = 0; j < M; j++) {
            int cnt = 0;
            for (int i = 0; i < N; i++) {
                cnt += map[i].get(j) ? 1 : 0;
            }
            cnt = Math.max(cnt, N - cnt);
            sum += cnt;
        }
        res = Math.max(res, sum);
        for (int i = 0; i < N; i++) {
            if ((tro & 1) == 1) {
                map[i].flip(0, M);
            }
            tro >>= 1;
        }
    }

    public static void swap(char[] chs, int i, int j) {
        char tmp = chs[i];
        chs[i] = chs[j];
        chs[j] = tmp;
    }


}


class Point {
    public Point(int x, int y, int d) {
        this.x = x;
        this.y = y;
        this.d = d;
    }

    public int x, y, d;

}



Measured memory_bytes: 69960
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))
"""lines:グラフの隣接リスト　dict型　lines[s]に辺が入る　defaultdict(set)で作る
 cost:辺の間の容量
 N：nodeの数（最終インデックスでない）
 start:sorceのnode
 Goal:sinkのnode"""
def ford_fulkerson(lines,cost,N,start,Goal):#linesとcostは上のように受け取っておく
     ans = 0
     INF = float('inf')
     def ford_in(s):#listはミュータブルだからnonlocalにしなくて良い
         nonlocal ans
         route = [0]*N
         ed = [True]*N
         ed[s] = False
         route[s] = -1
         que = deque([])
         que.append([s,INF])
         while que:
             s,flow = que.pop()
             for t in lines[s]:
                 if ed[t]:
                     flow = min(flow,cost[s][t])
                     que.append([t,flow])
                     ed[t] = False
                     route[t] = s
                     if t == Goal:
                         ans += flow
                         break
             else:
                 continue
             break
         else:
             return False

         t = Goal
         s = route[t]
         while s != -1:
             cost[s][t] -= flow
             if cost[s][t] ==0:
                 lines[s].remove(t)
             if cost[t][s] ==0:
                 lines[t].add(s)
             cost[t][s] += flow
             t = s
             s = route[t]

         return True

     while True:
         if ford_in(start):
             continue
         else:
             break
     return ans

N = int(input())
red = []
blue = []
for _ in range(N):
    a,b = inpl()
    red.append((a,b))
for _ in range(N):
    c,d = inpl()
    blue.append((c,d))

lines = defaultdict(set)
nnum = 2*N+2
cost = [[0]*nnum for i in range(nnum)]
for j in range(1,N+1):
    lines[0].add(j)
    cost[0][j] = 1
for k in range(N+1,2*N+1):
    lines[k].add(2*N + 1)
    cost[k][2*N+1]=1
for rd,r in enumerate(red):
    for bd,b in enumerate(blue):
        if (r[0] < b[0]) and (r[1]<b[1]):
            lines[rd+1].add(bd+1+N)
            cost[rd+1][bd+1+N]=1

print(ford_fulkerson(lines,cost,2*N+2,0,2*N+1))


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

int main() {
  int N;
  cin >> N;
  long long ans = 1;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      ans = 0;
      cout << 0 << endl;
      break;
    }
  }
  for (int i = 0; i < N; i++) {
    if (ans == 0) {
      break;
    }
    if (A[i] > 1000000000000000000/ans) {
      ans = -1;
      cout << ans << endl;
      break;
    }
    ans *= A[i];
  }
  
  if (ans != -1 && ans != 0) {
    cout << ans << endl;
  }
}



Measured memory_bytes: 3988
#include <iostream>

using namespace std;

int GCD(int a, int b)
{
	if(a % b == 0) { return b; }

	if(b % a == 0) { return a; }

	if(a > b) { return GCD(a % b, b); }

	if(a < b) { return GCD(a, b % a); }
}

int LCM(int a, int b)
{
	return a / GCD(a, b) * b;
}

int main()
{
	int a, b;

	while(cin >> a >> b)
	{
		cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  ulong[] NM = readln.chomp.split.to!(ulong[]);
  ulong N = NM[0],
        M = NM[1];
  ulong x = 1900*M + 100*(N - M);
  ulong p = 1;
  foreach (_; 0..M) { p <<= 1; }
  writeln(x*p);
}


Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
for($i=0;$i<=25;$i++){
  for($k=0;$k<=14;$k++){
    $ans = 4*$i + 7*$k;
    if($ans == $N){
      echo 'Yes';
      exit;
    }
  }
}
echo 'No';

Measured memory_bytes: 3576
use std::io;
use std::cmp::max;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let n:i32 = procon_read()[0];
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut s = buf.trim().chars().collect::<Vec<char>>();
	let mut x = 0;
	let mut maxi = 0;
	for i in s {
		if i == 'I' {
			x += 1;
		}else{
			x -= 1;
		}
		maxi = max(x, maxi);
	}
	println!("{}", maxi);
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a,b,c;
    c=0;
    cin>>a>>b;
    if (a>b){
        c=a;
        a=a-1;
        if (a>b)
            c=c+a;
        else
            c=c+b;
    }
    else    {
        c=b;
        b=b-1;
        if (a>b)
            c=c+a;
        else
            c=c+b;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
print(n*2//gcd(n, 2))

Measured memory_bytes: 63340
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int n,k;
vector<int> a;
vector<int> b;
void add(int l, int r, int delta)
{
	a[l]+=delta;
	if(r!=n-1)
		a[r+1]-=delta;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    a.resize(n);
    for(int i=0;i<n;++i)
    	a[i]=0;
    b.resize(n);
    for(auto &i: b)
    	cin>>i;
    while(k--)
    {
    	for(int i=0;i<n;++i)
    	{
    		add(max(0,i-b[i]),min(n-1,i+b[i]),1);
    	}
    	for(int i=1;i<n;++i)
    		a[i]+=a[i-1];
    	bool flag=true;
    	for(int i=0;i<n;++i)
    	{
    		if(a[i]!=n)
    		{
    			flag=false;break;
    		}
    	}
    	b=a;
    	if(flag)
    		break;
    	for(int i=0;i<n;++i)
    		a[i]=0;
    }
    for(int i=0;i<n;++i)
    {
    	cout<<b[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
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...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    string S,T;
    cin>>S>>T;
    int N = S.size(),M=T.size();
    int ans=10009;
    for (size_t i = 0; i+M <= N; i++)
    {
        int cnt=0;
        for (size_t j = 0; j < M; j++)
        {
            if(S[i+j]!=T[j])cnt++;
        }
        chmin(ans,cnt);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        int answer = Math.min(N * A, B);
        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int r, d;
    vector<long long int> x(11);
    cin >> r >> d >> x[0];
    for (int i = 1; i < 11; i++)
    {
        x[i] = r * x[i - 1] - d;
        cout << x[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256