akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
import math
from itertools import accumulate
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def floor(a, b): return -(-a // b)


def zz(): return list(map(int, sys.stdin.readline().split()))


def z(): return int(sys.stdin.readline())


def S(): return sys.stdin.readline()[:-1]


def C(line): return [sys.stdin.readline() for _ in range(line)]


S = C(3)
print(S[0][0], S[1][1], S[2][2], sep='')


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

// #define TEST_CASES
using ll = long long;
#define ff first
#define ss second
const int N = 1e5 + 10;

int v[200];

void solve()
{
	bool ok = 0;
	for (int i = 0; i < 4; i++)
	{ char x; cin>>x; v[x]++; }
	for (int i = 0; i < 200; i++)
		ok |= v[i] & 1 | v[i] == 4;
	cout<<(not ok ? "Yes" : "No")<<endl;
}

int main()
{
	int t = 1;
#ifdef TEST_CASES
	cin>>t;
#endif
	while(t--)
	{
		solve();
	}
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a.sort()

M = 1000005
cnt = [0] * M

for i in range(n):
    if cnt[a[i]] != 0:
        cnt[a[i]] = 2
        continue
    for j in range(a[i], M, a[i]):
        cnt[j] += 1

ans = 0

for i in range(n):
    if cnt[a[i]] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 104264
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
using namespace std;

int value(char a)
{
	if(a=='T') return 10;
	if(a=='J') return 10;
	if(a=='Q') return 10;
	if(a=='K') return 10;
	if(a=='A') return 11;

	return a-'0';
}

int main()
{
	int N;
	cin >> N;
	while(N--)
	{
		bool one=false;
		int ans=0;
		for(int i=0; i<2; i++)
		{
			char c;
			cin >> c;
			ans+=value(c);
			if(c=='A') one=true;
			if(ans>21) ans-=10;
		}

		string s;
		for(int i=0; i<8; i++)
		{
			char c;
			cin >> c;
			s+=c;
		}

		if(ans==21)
		{
			cout << "blackjack" << endl;
			continue;
		}

		for(int i=0; i<8; i++)
		{
			if( ans<=16 || (ans==17 && one) )
			{
				if(value(s[i])) ans+=value(s[i]);
				if(s[i]=='A')
				{
					if(ans>21) ans-=10;
					else one=1;
				}

				if(ans>21&&one)
				{
					ans-=10;
					one=0;
				}
			}
			
		}

		if(ans>21) cout << "bust" << endl;
		else cout << ans << endl;

	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int a[200010],r[200010],l[200010];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i+1];
  stack<int> s;
  for(int i=0;i<=n+1;i++){
    while(!s.empty()&&a[s.top()]>a[i]){
      r[s.top()]=i;
      s.pop();
    }
    if(!s.empty()) l[i]=s.top();
    s.push(i);
  }
  ll ans=0;
  for(int i=1;i<=n;i++){
    ans+=1LL*a[i]*(r[i]-i)*(i-l[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	string a,b;
	cin>>a;
	map<string,int> mp;
	mp[a]++;
	bool isMeet = true;
	for( int i=1; i<n; i++ ) 
	{
		cin >> b;
		mp[b]++;
		if( mp[b]>1 || b[0]!=a[a.size()-1])
			isMeet = false;
		a = b;
	}
	if( isMeet )
		cout << "Yes"<<endl;
	else
		cout <<"No" <<endl; 
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll n,k;
string s;

int main(){
	cin >> n >> k >> s;
	rep(i,n){
		if(s[i] == '1')s[i] = '0';
		else break; 
	}
	reverse(ALL(s));
	rep(i,n){
		if(s[i] == '1')s[i] = '0';
		else break;
	}
	reverse(ALL(s));
	// cout << s << endl;
	int cnt = 0;
	bool f = 0;
	vector<ll> v;
	rep(i,n){
		if(!f){
			if(s[i] == '0')cnt++;
			else {
				f = 1;
				v.push_back(cnt);
				cnt = 1;
			}
		}
		else {
			if(s[i] == '1')cnt++;
			else {
				f = 0;
				v.push_back(cnt);
				cnt = 1;
			}
		}
	}
	if(cnt > 0)v.push_back(cnt);
	v.push_back(0);
	reverse(ALL(v));
	v.push_back(0);
	reverse(ALL(v));
	// rep(i,v.size())cout << v[i] << " ";
	// cout << endl;
	ll ans = 0;
	for(ll i = 0;i < v.size();i += 2){
		ll sum = 0;
		rep(j,2*k+1){
			if(i+j >= v.size())break;
			sum += v[i+j];
		}
		// cout << i << ":" << sum << endl;
		ans = max(ans,sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1528
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    n = gets.chomp.to_i
    ary = gets.chomp.split.map(&:to_i)

    nums = Array.new(n)

    ary.each_with_index do |a, i|
      nums[i] = [a, i]
    end

    nums.sort!

    nums.each do |(a, i)|
      print "#{i+1} "
    end
    puts ""

  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 19712
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/
  int N, D;
  cin >> N >> D;

  vector<ll> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    cin >> Y[i];
  }

  int res = 0;
  //D = D * D;
  for (int i = 0; i < N; i++) {
    ll temp = X[i] * X[i] + Y[i] * Y[i];
    //cout << temp << endl;
    if (sqrt(temp) <= D) res++;
    //if (temp <= D) res++;
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 6444
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

vector<vector<int>> v(100005);
int dp[100005];

int go(int i){
    if(dp[i]!=-1){
        return dp[i];
    }

    int path = 0;
    for(auto x: v[i]){
        path = max(path, 1 + go(x));
    }

    return dp[i]=path;
}

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

    memset(dp, -1, sizeof(dp));

    int ans = 0;
    for(int i = 0; i <= n; i++){
       ans = max(ans, go(i));
    }
    
    cout << ans << endl;
    

}


Measured memory_bytes: 10928
// ※※※ 解答不能 ※※※
// Doju 氏.
// https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4218580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repx(i, a, b) for(int i = a; i < b; i++)
const int MOD = 998244353;
char s[2002];
int dp[2][2002], inv[2002];

void add(int &a, int b){
    a = a + b < MOD ? a + b : a + b - MOD;
}
int mul(int a, int b){
    return 1LL * a * b % MOD;
}

int main(){
    scanf("%s", s + 1);
    int N = strlen(s + 1);
    inv[1] = 1;
    repx(i, 2, N + 2) inv[i] = MOD - mul(MOD / i, inv[MOD % i]);
    dp[0][0] = 1;
    rep(i, N){
        int i_ = i & 1, _i = i_ ^ 1;
        rep(j, i + 2) dp[_i][j] = 0;
        rep(j, i + 1){
            int v = dp[i_][j];
            int r = j + '2' - s[i + 1];
            int b = i - j + s[i + 1] - '0';
            if(r > 0) add(dp[_i][r - 1], v);
            if(b > 0) add(dp[_i][r], v);
        }
    }
    int n = N & 1, ans = 0, bin = 1;
    rep(i, N + 1){
        add(ans, mul(dp[n][i], bin));
        bin = mul(bin, mul(N - i, inv[i + 1]));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import sys
import functools

mod = 1e9 + 7
n = int(input())
if n == 1:
    print(1)
    sys.exit()

fact = [1] * (n+1)

for i in range(2, n+1):
    for j in range(2, 32):
        if i == 0:
            break
        while True:
            if i % j == 0:
                i /= j
                fact[j] += 1
            else:
                break
    if i != 0:
        fact[int(i)] += 1

print(int(functools.reduce(lambda x, y: (x * y) % mod, fact[2:])))


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll n,k;
	cin>>n>>k;
	vector<ll> vis(n+1,0);
	for(ll i=0;i<k;i++){
		ll len;
		cin>>len;
		for(ll j=0;j<len;j++){
			ll x;
			cin>>x;
			vis[x]=1;
		}
	}
	ll res=0;
	for(ll i=1;i<=n;i++)
	if(!vis[i])
	res++;
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3656
package main

import "fmt"

func slove(a int, b int, k int) bool {
  for i:=1; k*i<=b; i++ {
    if a <= k*i {
      return true
    }
  }
  return false
}

func main() {
  var k, a, b int
  fmt.Scan(&k)
  fmt.Scan(&a)
  fmt.Scan(&b)
  
  if slove(a, b, k) {
    fmt.Println("OK")
  } else {
    fmt.Println("NG")
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct rgb { ll r, g, b; };

int main() {
  int N; cin >> N;
  string S; cin >> S;
  rgb l[N] = {}, r[N] = {};
  repr(i,1,N) {
    if (S[i]=='R') r[0].r++;
    if (S[i]=='G') r[0].g++;
    if (S[i]=='B') r[0].b++;
  }
  repr(i,1,N) {
    l[i] = { l[i-1].r, l[i-1].g, l[i-1].b };
    r[i] = { r[i-1].r, r[i-1].g, r[i-1].b };
    if (S[i-1]=='R') l[i].r++;
    if (S[i-1]=='G') l[i].g++;
    if (S[i-1]=='B') l[i].b++;
    if (S[i]=='R') r[i].r--;
    if (S[i]=='G') r[i].g--;
    if (S[i]=='B') r[i].b--;
  }
  // rep(i,N) {
  //   cout << l[i].r << "-" << l[i].g << "-" << l[i].b << " ";
  //   cout << r[i].r << "-" << r[i].g << "-" << r[i].b << endl;
  // }

  ll result = 0;
  repr(i,1,N-1) {
    if (S[i]=='R') result += l[i].g*r[i].b + l[i].b*r[i].g;
    if (S[i]=='G') result += l[i].r*r[i].b + l[i].b*r[i].r;
    if (S[i]=='B') result += l[i].r*r[i].g + l[i].g*r[i].r;
  }

  rep(i,N) for (int j=1; i+j*2<N; j++) {
    if (S[i]!=S[i+j]&&S[i+j]!=S[i+j*2]&&S[i]!=S[i+j*2]) result--;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3760
# AtCoder Beginner Contest 124
# https://atcoder.jp/contests/abc124
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def grouping(N, S):
    group = []
    s = S[0]
    c = 1
    for i in range(1, N):
        if S[i] == s:
            c += 1
        else:
            group.append((s, c))
            s = S[i]
            c = 1
    group.append((s, c))
    return group

def main(N, K, S):
    g = grouping(N, S)
    glen = len(g)
    # 累積和(cumsum)
    cs = [0] * (glen + 1)
    for i in range(glen):
        cs[i+1] = cs[i] + g[i][1]
    nm = 0
    for i in range(glen):
        if g[i][0] == '0':
            n = cs[min(i + 2*K, glen)] - cs[i]
        else:
            n = cs[min(i + 2*K+1, glen)] - cs[i]
        if n > nm:
            nm = n
    print(nm)

N, K = i2nn()
S = i2s()
main(N, K, S)


Measured memory_bytes: 14284
#include<bits/stdc++.h>
     
    using namespace std;
     
    #define endl '\n'
     
    typedef long long ll;
     
    struct block{
    	ll s, w, v;
    };
     
    bool cmp(block a, block b){
    	return a.s + a.w > b.s + b.w;
    }
     
    int main(){
    	ios_base::sync_with_stdio(0);
    	cin.tie(0);
     
    	const ll maxn = 1e5 + 4;
    	
    	ll n;
    	cin >> n;
    	vector<block> a(n);
     
    	for(ll i = 0; i < n; i++)
    		cin >> a[i].w >> a[i].s >> a[i].v;
     
    	sort(a.begin(), a.end(), cmp);
    	
    	vector<vector<ll>> dp(2, vector<ll>(maxn));
    	
    	for(ll i = n - 1; i >= 0; i--){
    		
    		for(ll j = 0; j < maxn; j++){
    			dp[i % 2][j] = dp[(i + 1) % 2][j];
    			if(j >= a[i].w)
    				dp[i % 2][j] = max(dp[i % 2][j], a[i].v + dp[(i + 1) % 2][min(j - a[i].w, a[i].s)]);
    		}
    	}
    	
    	ll ans = 0;
    	for(ll i = 0; i < maxn; i++)
    		ans = max(ans, dp[0][i]);
    	
    	cout << ans << endl;
    	
    	return 0;
    }

Measured memory_bytes: 2688
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        d: [usize; n],
    }
    let mut ans = 0;
    for i in 0..n - 1 {
        for j in i + 1..n {
            ans += d[i] * d[j];
        }
    }
    println!("{}", ans);
}


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

int bubbleSort(int ary[], int num);

void printArray(int ary[], int num){
    for (int i=0; i<num; i++){if(i==num -1) cout << ary[i] << endl; else cout << ary[i] << ' ';}
}

int main(){
    int n, a[100];
    cin >> n;
    for(int i=0; i<n; i++){cin >> a[i];}
    int count = 0;
    count = bubbleSort(a, n);
    printArray(a, n);
    cout << count << '\n';

    return 0;
}
int bubbleSort(int ary[], int num){
    int count=0;
    bool flag = 1;
    for(int i=0; flag; i++){
        flag = 0;
        for (int j=num-1; j>i; j--){
            if (ary[j] < ary[j-1]){
                swap(ary[j], ary[j-1]);
                flag = 1;
                count += 1;
            }
        }
    }
    return count;
    
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;

double f(double x1, double y1, double x2, double y2){
	return abs(x1*y2 - x2*y1) / 2;
}

bool solve(){
	vector<double> x,y;
	double in;
	while(cin>>in){
		x.push_back(in);
		char ch;
		cin>> ch>> in;
		y.push_back(in);
	}
	int n = x.size();
	for(int i=0;i<n;i++){
		x[n-1-i] -= x[0];
		y[n-1-i] -= y[0];
	}
	double ans = 0;
	for(int i=1;i<n-1;i++){
		ans += f(x[i],y[i], x[i+1],y[i+1]);
	}
	cout<< ans<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();
	return 0;
}

 

Measured memory_bytes: 1304
/*
022 2
0 1
1 0
2 3
0 0 0
0 1 0
*/
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

const int N = 4001;
int i, j, k, m, n, rn, bn;
string s;
int a[N][N];
int cred[N], cblue[N];

void add(int& x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

void solve() {
    n = SZ(s);
    CL(0, cred); CL(0, cblue); CL(0, a);
    rn = 0; bn = 0;

    F0(i, n) {
        if (i > 0) {
            cred[i] = cred[i - 1];
            cblue[i] = cblue[i - 1];
        }
        if (s[i] == '0') {
            cred[i] += 2;
            rn += 2;
        } else if (s[i] == '1') {
            cred[i]++;
            cblue[i]++;
            rn++;
            bn++;
        } else {
            cblue[i] += 2;
            bn += 2;
        }
    }

    a[0][0] = 1;
    for (int i = 0; i <= rn; i++) for (int j = 0; j <= bn; j++) {
        if (i < rn && (i + j >= n || i + 1 <= cred[i + j])) add(a[i + 1][j], a[i][j]);
        if (j < bn && (i + j >= n || j + 1 <= cblue[i + j])) add(a[i][j + 1], a[i][j]);
    }
    cout << a[rn][bn] << endl;
}

int main() {
    //freopen("x.in", "r", stdin);
    while (cin >> s) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 62848
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, M;
  cin >> N >> M;

  ll ans_max = M / N;

  repr(i, ans_max) {
    if (M % i == 0 && i * N <= M) {
      RETURN(i);
    }
  }

  return 0;
}

Measured memory_bytes: 3576
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt(), t = sc.nextInt();
		System.out.println(X-t<0 ? 0 : X-t);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35752
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string x;
	cin>>x;
	if(x[1]=='B')
	{
		cout<<"ARC"<<"\n";
	}
	else
	{
		cout<<"ABC"<<"\n";
	}
	return 0;
}


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

#define maxn 200002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n, cnt;
priority_queue<ii, vector<ii>, greater<ii> > pq;
vector<int> a[maxn];
ii val[maxn];

struct segmentTree {
    ii st[maxn*4];

    segmentTree() {
        FOR(i, 1, maxn*4-1) st[i] = ii(inf, inf);
    }

    void update(int pos, ii val, int l=1, int r=n, int id=1) {
        if (pos<l || pos>r) return;
        if (l==pos && pos==r) {
            st[id] = min(st[id], val);
            return;
        }
        int mid = (l+r)/2;
        update(pos, val, l, mid, id*2);
        update(pos, val, mid+1, r, id*2+1);
        st[id] = min(st[id*2], st[id*2+1]);
    }

    ii get(int u, int v, int l=1, int r=n, int id=1) {
        if (u>r || v<l) return ii(inf, inf);
        if (u<=l && r<=v) return st[id];
        int mid = (l+r)/2;
        return min(get(u, v, l, mid, id*2), get(u, v, mid+1, r, id*2+1));
    }
} b[2];

int solve(int l, int r) {
    if (l>=r) return -1;
    ++cnt;
    ii tmp1 = b[l%2].get(l, r), tmp2 = b[(l+1)%2].get(tmp1.se+1, r);
    int tmp = cnt;
    val[tmp] = ii(tmp1.fi, tmp2.fi);
    a[tmp].push_back(solve(l, tmp1.se-1));
    a[tmp].push_back(solve(tmp1.se+1, tmp2.se-1));
    a[tmp].push_back(solve(tmp2.se+1, r));
    return tmp;
}

int main() {
    //freopen("youngmaids.inp", "r", stdin);
    //freopen("youngmaids.ans", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    scanf("%d", &n);
    FOR(i, 1, n) {
        int x; scanf("%d", &x);
        b[i%2].update(i, ii(x, i));
    }
    //Debug(b[0].get(1, 5).se);
    solve(1, n);
    pq.push(ii(val[1].fi, 1));
    while (pq.sz()) {
        int u = pq.top().se; pq.pop();
        printf("%d %d ", val[u].fi, val[u].se);
        REP(i, a[u].sz()) {
            int v = a[u][i];
            if (v!=-1) pq.push(ii(val[v].fi, v));
        }
    }
}


Measured memory_bytes: 57728
import math


def main():
    a, b, x = map(int, input().split(' '))

    if (2*x) >= (a * a * b):
        theta = math.atan(2*(a * a * b - x) / (a * a * a))
    else:
        theta = (0.5 * math.pi) - math.atan(2 * x / (a * (b * b)))
    d = math.degrees(theta)
    print(d)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n = int(input())
vc = [[int(i) for i in input().split()] for i in range(2)] 
xy = []
for i in range(n):
    xy.append(vc[0][i]-vc[1][i])
ans = 0
for i in range(n):
    if 0 < xy[i]:
        ans += xy[i]
print(ans) 


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


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



	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long da,db,dc,dd;
	da = a*c;
	db = a*d;
	dc = b*c;
	dd = b*d;

	dd = max(dd,dc);
	da = max(da,db);
	cout<<max(dd,da)<<"\n";

    return 0;
		
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;

int main() {
  int n, r;
  cin >> n >> r;
  if (n < 10) {
    cout << r + 100 * (10 - n) << endl;
  }
  else {
    cout << r << endl;
  }

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	int main() { 
	    
	    int n;
	    cin >> n;
	    vector<int> arr(n,0);

	    for(int i=0;i<n ;i++){
	    	cin >> arr[i];
	    }
        cout << arr[n-1];
	    for(int i=1; i<n;i++){
	    	cout << " " << arr[n-1-i];
	    }
cout << endl;


	    return 0;
	}


Measured memory_bytes: 3024
def gcd(x,y):
    if x<y:
        x,y = y,x
    while y>0:
        x,y = y,x%y
    return x
N = int(input())
T = list(set([int(input()) for _ in range(N)]))
t = 1
b = T[0]
for i in range(1,len(T)):
    a = gcd(T[i],b)
    b = a*(T[i]//a)*(b//a)
print(b)

Measured memory_bytes: 3060
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main() {
    int q, x;
    char com[20];
    list<int> v;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%s", com);
        if (com[0] == 'i') {
            scanf("%d", &x);
            v.push_front(x);
        } else if (com[6] == 'L') {
            v.pop_back();
        } else if (com[6] == 'F') {
            v.pop_front();
        } else if (com[0] == 'd') {
            scanf("%d", &x);
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 33876
#include<iostream>
#include<algorithm>
using namespace std;
int a[101];
int main()
{
    int n,m,x=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        x=x+a[i];
    }
    sort(a,a+n);
    m=m-x;
    m=m/a[0];
    cout<<n+m;
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> qs(q);
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    qs[i] = {a, b, c, d};
  }

  int ans = 0;
  vector<int> v;

  function<void(int, int, vector<int> &)> dfs = [&](int cur, int depth, vector<int> &v) {
    if (depth == 0) {
      int sum = 0;
      for (auto &qq : qs) {
        if (v[qq[1]] - v[qq[0]] == qq[2])
          sum += qq[3];
      }
      ans = max(ans, sum);
      return;
    }

    for (int i = cur; i < m; i++) {
      v.push_back(i);
      dfs(i, depth - 1, v);
      v.pop_back();
    }
  };
  dfs(0, n, v);

  cout << ans << endl;

  return 0;
}


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

int main() {
  
     int n,x,t;
     cin>>n>>x>>t;
     int z;
     if(n%x==0)
     {
         z=n/x;
     }else{
         z=n/x;
         z++;
     }
     
     cout<<t*z;
     
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, m;

unordered_map<int, int> cnt;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);

    cnt[a] += 1;
    cnt[b] += 1;
  }

  for (auto &e : cnt) {
    if (e.second % 2 == 1) {
      printf("NO\n");
      return 0;
    }
  }

  printf("YES\n");

  return 0;
}


Measured memory_bytes: 3876
import itertools

num = int(input())

kizyun = [i+1 for i in range(num)]

retu = list(itertools.permutations(kizyun, num))  

tansaku1 = input().split()
for i in range(len(tansaku1)):
  tansaku1[i] = int(tansaku1[i])
tansaku1 = tuple(tansaku1)

tansaku2 = input().split()
for i in range(len(tansaku2)):
  tansaku2[i] = int(tansaku2[i])
tansaku2 = tuple(tansaku2)

a = 0
b = 0

for i in range(len(retu)):
  if retu[i] == tansaku1:
    a = i+1
  if retu[i] == tansaku2:
    b = i+1

ans = abs(a-b)

print(ans)


Measured memory_bytes: 8052
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
int a,s,d,f,g,h,j,i;
scanf("%d",&a);
if(a%10==9) printf("Yes\n");
else if(a/10==9) printf("Yes\n");
else printf("No\n");
return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    class Reader {
        BufferedReader in;

        Reader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        Reader(String name) throws IOException {
            in = new BufferedReader(new FileReader(name));
        }

        StringTokenizer tokin = new StringTokenizer("");

        String next() throws IOException {
            if (!tokin.hasMoreTokens()) {
                tokin = new StringTokenizer(in.readLine());
            }
            return tokin.nextToken();
        }

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

        boolean hasNext() throws IOException {
            if (tokin.hasMoreTokens()) {
                return true;
            } else {
                String s = in.readLine();
                while (s != null && s.length() == 0) {
                    s = in.readLine();
                }
                if (s == null) {
                    return false;
                } else {
                    tokin = new StringTokenizer(s);
                    return true;
                }
            }
        }
    }

    class Writer {
        PrintWriter cout;

        Writer() throws IOException {
            cout = new PrintWriter(System.out);
        }

        Writer(String name) throws IOException {
            cout = new PrintWriter(new FileWriter(name));
        }

        StringBuilder out = new StringBuilder();

        void print(Object a) {
            out.append(a);
        }

        void close() {
            cout.print(out.toString());
            cout.close();
        }
    }

    long m = (long) 1e9 + 7;

    long pow(long a, long n) {
        if (n == 0) {
            return 1;
        }
        if (n == 1) {
            return a % m;
        }
        if (n % 2 == 0) {
            long b = pow(a, n / 2);
            return (b * b) % m;
        } else {
            return (pow(a, n - 1) * a) % m;
        }
    }

    void run() throws IOException {
        Reader in = new Reader();
        Writer out = new Writer();
        long n = in.nextInt();
        long ans = pow(10, n) - (2 * (pow(9, n) - pow(8, n)) + pow(8, n));
        while (ans < 0) {
            ans += m;
        }
        out.print(ans % m);
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}

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

void solve(long long sx, long long sy, long long tx, long long ty){
    for(int i=0; i<ty-sy; i++){ cout << "U"; }
    for(int i=0; i<tx-sx; i++){ cout << "R"; }
    for(int i=0; i<ty-sy; i++){ cout << "D"; }
    for(int i=0; i<tx-sx; i++){ cout << "L"; }

    cout << "L";
    for(int i=0; i<ty-sy+1; i++){ cout << "U"; }
    for(int i=0; i<tx-sx+1; i++){ cout << "R"; }
    cout << "DR";
    for(int i=0; i<ty-sy+1; i++){ cout << "D"; }
    for(int i=0; i<tx-sx+1; i++){ cout << "L"; }
    cout << "U" << endl;
}

int main(){
    long long sx;
    scanf("%lld",&sx);
    long long sy;
    scanf("%lld",&sy);
    long long tx;
    scanf("%lld",&tx);
    long long ty;
    scanf("%lld",&ty);
    solve(sx, sy, tx, ty);
    return 0;
}


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

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N)cin >> a[i];
	int sum = 0;
	rep(i, N)sum ^= a[i];
	rep(i, N)cout << (int)(sum ^ a[i]) << " ";
}



Measured memory_bytes: 4040
#include<iostream>
#include<cmath>
using namespace std;
char orig[1145],tmp;
string a,b;
int main () {
	cin>>a>>b;
	for (int i=0,len=a.size();i<len;++i) orig[i*2]=a[i];
	for (int i=0,len=b.size();i<len;++i) orig[i*2+1]=b[i];
	cout<<orig<<endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

string s;

int main()
{
	cin>>s;
	rep(i,s.size()) cout<<'x';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
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() {

    string S;
    cin >> S;

    ll N = S.size();
    vector<ll> s(26);

    rep(i, N) {
        s[S[i] - 'a'] = i + 1;
    }

    if (N != 26) {
        char tale;
        rep(i, 26) {
            if (s[i] == 0) {
                tale = 'a' + i;
                break;
            }
        }
        cout << S + tale;
    }
    else {
        for (int i = 25; 0 <= i; i--) {
            if (S[i] < S[i + 1]) {
                char mn = S[i + 1];
                for (int j = i + 1; j < 26; j++) {
                    if (S[j] > S[i]) chmin(mn, S[j]);
                }
                cout << S.substr(0, i) + mn;
                return 0;
            }
        }
        cout << -1;
    }

    return 0;
}


Measured memory_bytes: 3608
#include <unordered_map>
#include <iostream>

using namespace std;

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

    unordered_map<long long, long long> num_count;
    for (int i = 0; i < N; i++) {
        long long ai;
        cin >> ai;
        num_count[ai]++;
    }

    long long remove = 0;
    for (auto num_count_pair: num_count) {
        long long num_remove = num_count_pair.second - num_count_pair.first;
        if (num_remove < 0) {
            num_remove = num_count_pair.second;
        }
        remove += num_remove;
    }
    cout << remove << endl;

    return 0;
};


Measured memory_bytes: 4260
//AtCoder ABC084 B - Postal Code
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll A,B;
    string S;
    cin>>A>>B;
    cin>>S;
    bool ans=(A+B+1==S.size());
    for(ll i=0;i<S.size();++i){
        if(i==A){
            if(S[i]!='-')ans=false;
        }else{
            if(S[i]>='0'&&S[i]<='9'){
            } else {
                ans=false;
            }
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

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

int main() {
  
  int n,m;
  cin >> n >> m;
  
  double sum = 0;
  int count = 0;
  
  vector<int> a(n);
  for(int i = 0; i<n; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  for(int i = 0; i<n; i++){
    if ( sum / ( 4 * m ) <= a.at(i) ){
      count++;
    }
  }
  
  if ( m <= count ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n, a; scanf("%d%d", &n, &a);
	printf("%d", n*n-a);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    ll A,B; cin >> A >> B;

    if ((A+B)%2 == 0){
        cout << (A+B)/2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 3616
import heapq

INF = 10 ** 5


class MinCostFlow:
    """
    最小費用流の ダイクストラ版
    蟻本 P.203
    """

    def __init__(self, V):
        self.V = V
        self.G = [[] for _ in range(V)]
        # 最小コスト見つかったあとに, route を取得するために使用
        self.prevv = [INF] * V
        self.preve = [INF] * V

        self.h = [0] * V  # ポテンシャル

    def add_edge(self, from_, to_, cap, cost):
        """
        from から to へ向かう容量 cap, コスト cost の辺をグラフに追加
        """
        self.G[from_].append([to_, cap, cost, len(self.G[to_])])
        self.G[to_].append([from_, 0, -cost, len(self.G[from_]) - 1])

    def _get_dist(self, s, t, f):
        """
        prevv,preve から 最大で流せる量を返す

        :param s: 始点
        :param t: 終点
        :param f: 最大で流したい量
        :return:
        """
        d = f
        v = t
        while v != s:
            pre_v = self.prevv[v]
            pre_edge = self.preve[v]
            d = min(d, self.G[pre_v][pre_edge][1])  # 1:cap のindex
            v = pre_v
        return d

    def _update_cap(self, s, t, d):
        """ capacity 更新 """
        v = t
        while v != s:
            pre_v = self.prevv[v]
            pre_e = self.preve[v]
            e = self.G[pre_v][pre_e]  # type:list
            e[1] -= d  # cap 更新
            rev = e[3]  # type:int
            self.G[v][rev][1] += d  # 逆辺のcap更新

            v = pre_v

    def solve(self, s, t, f):
        res = 0
        self.h = [0] * self.V
        dist = [INF] * self.V  # 最短経路
        while f > 0:
            que = []  # priority queue (<最短距離, 頂点の番号>) を要素にもつ. ダイクストラ用
            for i in range(self.V):
                dist[i] = INF
            dist[s] = 0

            heapq.heappush(que, (0, s))

            while que:

                p = heapq.heappop(que)
                v = p[1]  # 注目する頂点
                if (dist[v] < p[0]): continue

                for i in range(len(self.G[v])):
                    e = self.G[v][i]
                    to_ = e[0]
                    cap = e[1]
                    cost = e[2]

                    if cap <= 0: continue

                    # u -> v のとき, dist[v] は dist[u] + cost + h(u) -h(v) # p.202
                    if dist[to_] > dist[v] + cost + self.h[v] - self.h[to_]:
                        dist[to_] = dist[v] + cost + self.h[v] - self.h[to_]
                        self.prevv[to_] = v
                        self.preve[to_] = i
                        heapq.heappush(que, (dist[to_], to_))

            if dist[t] == INF:  # 経路なし(これ以上流せない)
                return -1

            for v in range(self.V):
                self.h[v] += dist[v]

            # 流せる量を取得
            d = self._get_dist(s, t, f)
            res += d * self.h[t]
            f -= d

            # update capacity
            self._update_cap(s, t, d)

        return res


v,e,f = [int(_) for _ in input().split()]
mcf = MinCostFlow(v)
for i in range(e):
    mcf.add_edge( *[int(_) for _ in input().split()])
print(mcf.solve(0,v-1,f))



Measured memory_bytes: 6004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll m,n,i,s=0,c=0;
  cin>>n>>m;
  ll a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    s+=a[i];
  }
  sort(a,a+n);
  float x=(float)s/(4*m);
  ll val=(s/(4*m));
  ll val1=ceil(x);
  //cout<<val<<endl;
  if(val!=val1)
  {
    for(i=n-1;i>=0;i--)
    {   
      if(a[i]>val)
      c++;
    }
  }
  else
  {
    for(i=n-1;i>=0;i--)
    {
      if(a[i]>=val)
      c++;
    }
  }
  //cout<<c<<endl;
  if(c>=m)
  cout<<"Yes";
  else
  cout<<"No";
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void makegraph(int x,vector<vec> &v){rep(i,x-1){int a=in(),b=in();v[a].pb(b);v[b].pb(a);}}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 355050

ll n,m,k;

struct edge{
    int from,to;
    ll cost;
};
struct UnionFind{
    vector<ll> par,sizes;
    UnionFind(int nn):par(nn+1),sizes(nn+1,1){
        rep2(i,1,nn)par[i]=i;
    }
    int find(int x){
        return (x==par[x]?x:par[x]=find(par[x]));
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return ;
        if(sizes[x]<sizes[y]){
            swap(x,y);
        }
        par[y]=x;
        sizes[x]+=sizes[y];
    }
    bool same(int x,int y) {return (find(x)==find(y));}
    ll size(int x) {return sizes[find(x)];}
};
ll x[N];
ll largest[N];
vec G[N];
ll sz[N];
int ans;
vector<edge> E;
void dfs(int x){
    if(sz[x]>=E[x].cost)return;
    ans++;
    for(auto e:G[x]){
        dfs(e);
    }
}
main(){
    n=in();m=in();
    if(m==0){cout<<0;return 0;}
    UnionFind u(n+1+m);
    rep2(i,1,n){
        x[i]=lin();
        u.sizes[i]=x[i];
    }
    rep(i,m){
        int a=in(),b=in();
        ll c=lin();
        E.pb(edge{a,b,c});
    }
    sort(ALL(E),[](edge x,edge y){
        return x.cost<y.cost;
    });
    rep(i,n+1)largest[i]=-1;
      rep(i,m){
        int a=E[i].from,b=E[i].to;
        if(u.same(a,b)){
            G[i].pb(largest[u.find(a)]);
            sz[i]=u.size(a);
            largest[u.find(a)]=i;
        }
        else{
            int p1=u.find(a),p2=u.find(b);
            if(largest[p1]!=-1){
                G[i].pb(largest[p1]);
            }
            if(largest[p2]!=-1)G[i].pb(largest[p2]);
            u.unite(a,b);
            largest[u.find(a)]=i;
            ll xx=u.size(a);
            sz[i]=xx;
        }
    }
    dfs(m-1);
    cout<<ans;
}

Measured memory_bytes: 26224
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, x; cin >> a >> b >> x;
    if(2*x >= a*a*b) cout << fixed << setprecision(8) << atan(2.0*(b-x/(1.0*a*a))/(1.0*a))*180/M_PI << endl;
    else cout << fixed << setprecision(8) << atan((1.0*a*b*b)/(2.0*x))*180/M_PI << endl;
}

Measured memory_bytes: 256
/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#ifdef ARYANC403
    #include "/home/aryan/codes/PastCodes/template/header.h"
#else
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
    #pragma GCC optimize ("-ffloat-store")
    #include<iostream>
    #include<bits/stdc++.h>
    #define dbg(args...)
#endif

using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    map<lli,lli> mm;
    fo(i,n)
    {
        cin>>in;
        mm[in]++;
    }

    lli ans=1;

    for(lli i=0;i<n;i++)
    {
        const lli d=abs(i-(n-i-1));
        ans=(ans*mm[d])%mod;
        mm[d]--;
    }

    cout<<ans<<endl;



}   aryanc403();
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> cnt(100001, 0);
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		cnt[a]++;
	}
	int ans = 0;
	for (int i = 0; i < 100000;i++)
		ans = max(ans, (i == 0 ? 0 : cnt[i - 1]) + cnt[i] + cnt[i + 1]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640