akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=200005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n;
vvi g;
vl dp,DP,sz;

void dfs(int v,int p){
	sz[v]=dp[v]=1;
	for(auto u:g[v]) if(u!=p){
		dfs(u,v);
		sz[v]+=sz[u];
		(dp[v]*=dp[u]*nCk(sz[v]-1,sz[u])%mod)%=mod;
	}
}

void DFS(int v,int p,ll t=1){
	if(v) (DP[v]*=t*nCk(n-1,sz[v]-1)%mod)%=mod;
	int s=n-1;
	for(auto u:g[v]) if(u!=p) s-=sz[u];
	for(auto u:g[v]) if(u!=p){
		s+=sz[u];
		(t*=nCk(s,sz[u])*dp[u]%mod)%=mod;
	}
	for(auto u:g[v]) if(u!=p){
		DFS(u,v,Div(t,dp[u]*nCk(s,sz[u])%mod));
	}
}

int main(){
	Init();
	cin>>n;
	g=vvi(n);
	dp=DP=sz=vl(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1);
	DP=dp;
	DFS(0,-1);
	for(auto i:DP) cout<<i<<endl;
}

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

double bmi(double w, double h);

int main(void){
  int n;
  double p,h,w;
  double delta;
  double retval=10000;
  while(1){
    cin>>n;
    if(n==0)break;
    delta=10000000;
    for(int i=0;i<n;i++){
      cin>>p>>h>>w;
      if(abs(bmi(w,h)-22)<delta){
        delta=abs(bmi(w,h)-22);
        retval=p;
      }
    }
    cout<<retval<<endl;
  }
  return 0;
}

double bmi(double w, double h){
  return w/((h/100)*(h/100));
}



Measured memory_bytes: 3208
n, a, b = gets.split.map(&:to_i)
h = Array.new(n) { gets.to_i }

ans = (1..10**9).bsearch do |i|
  sum = 0
  h.each { |e| sum += e - b * i > 0 ? (e - b * i + a - b - 1) / (a - b) : 0 }
  sum <= i
end

puts ans


Measured memory_bytes: 15168
#include<stdio.h>
#include<string.h>
int main(void)
{
	char x[10],r;  
	int n,a[10],b[10],c[10],i,k,t;
	scanf("%d",&n);
	while(1){
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf(" %c",&x[i]);
			a[i]=0; b[i]=0; c[i]=i;
			for(k=0;k<n-1;k++){
				scanf("%d",&t);
				if(t==0) a[i]++;
				if(t==1) b[i]++;
			}
		}
		for(i=0;i<n-1;i++){
			for(k=i+1;k<n;k++){
				if((a[i]<a[k]) || (a[i]==a[k] && b[i]>b[k]) || (a[i]==a[k] && b[i]==b[k] && c[i]>c[k])){
					t=a[i]; a[i]=a[k]; a[k]=t;
					t=b[i]; b[i]=b[k]; b[k]=t;
					t=c[i]; c[i]=c[k]; c[k]=t;
					r=x[i]; x[i]=x[k]; x[k]=r;
				}
			}
		}
		for(i=0;i<n;i++) printf("%c\n",x[i]);
		scanf("%d",&n);
	}
	return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

template< class Abel > struct UnionFind {
  vector< int > par;
  vector< int > rank;
  vector< Abel > diff_weight;
  
  UnionFind(int n = 1, Abel SUM_UNITY = 0) {
    init(n, SUM_UNITY);
  }

  void init(int n = 1, Abel SUM_UNITY = 0) {
    par.resize(n); rank.resize(n), diff_weight.resize(n);
    for(int i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
      diff_weight[i] = SUM_UNITY;
    }
  }
  
  int root(int x) {
    if (par[x] == x) return x;
    // 累積和をとる
    int r = root(par[x]);
    diff_weight[x] += diff_weight[par[x]];
    return par[x] = r;
  }

  Abel weight(int x) {
    // 経路圧縮をする
    root(x);
    return diff_weight[x];
  }

  Abel diff(int x, int y) {
    return weight(y) - weight(x);
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  // weight(x) - weight(y) = wとなるようにmerge
  bool merge(int x, int y, Abel w) {
    // xとyそれぞれについてrootとの重み付き補正
    w += weight(x); w -= weight(y);
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) {
      swap(x, y);
      w = -w;
    }
    if (rank[x] == rank[y]) {
      ++rank[x];
    }
    par[y] = x;

    // xがyの大和になるので、xとyの差分をdiff_weight[y]に記録
    diff_weight[y] = w;
    return true;
  }
};

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

  CIN(N, Q);
  UnionFind< int > uf(N + 1);
  
  REP(qi, Q) {
    CIN(c);
    if (c == 0) {
      // merge
      CIN(x, y, z);
      uf.merge(x, y, z);
    } else {
      string ans;
      // judge
      CIN(x, y);
      if (!uf.issame(x, y)) {
	// 差が判断できないのは親が異なる時
	ans = "?";
      } else {
	ans = to_string(uf.diff(x, y));
      }
      cout << ans << endl;
    }
  }

  return 0;
}




Measured memory_bytes: 4176
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, A, B; string s;
int main() {
	cin >> N >> A >> B >> s;
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a') {
			if (cnt1 < A + B) cnt1++, cout << "Yes" << endl;
			else cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			if (cnt1 < A + B && cnt2 < B) cnt1++, cnt2++, cout << "Yes" << endl;
			else cout << "No" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	string S,T; cin >> S >> T;
	vector<int> sm(S.size()+1),tm(T.size()+1);
	for(int i=0;i<S.size();++i) sm[i+1]=sm[i]+(S[i]=='A'?1:2);
	for(int i=0;i<T.size();++i) tm[i+1]=tm[i]+(T[i]=='A'?1:2);
	int q; cin >> q;
	while(q--) {
		int a,b,c,d; cin >> a >> b >> c >> d;
		--a, --c;
		bool f=(sm[b]-sm[a])%3==(tm[d]-tm[c])%3;
		cout << (f?"YES":"NO") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end


 
int main(){
  int n; scanf("%d",&n);
  vector<string> a(n);
  rep(i,0,n)cin>>a[i];
  map<string,int> mp;
  rep(i,0,n){
    sort(ALL(a[i]));
    mp[a[i]]++;
  }
  ll ans=0;
  for(pair<string,int> p:mp){
    if(mp[p.first]==1)continue;
    ans+=1LL*(mp[p.first])*(mp[p.first]-1)/2;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
int main(){
    int aa,bb;
    string a,b;
    cin>>a>>b;
    aa=a.length(),bb=b.length();
    if(aa==bb){for(int i=0;i<aa;i++)cout<<a[i]<<b[i];cout<<endl;}else
    if(aa==bb+1){for(int i=0;i<bb;i++)cout<<a[i]<<b[i];cout<<a[aa-1]<<endl;}
    return 0;
}

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

using namespace std;

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

  int next = 1;
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    if (tmp == next)
      ++next;
  }

  if (next != 1)
    next = n - next + 1;
  else
    next = -1;

  cout << next << endl;
}

Measured memory_bytes: 256
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

// vector set 等
#include <map>
#include <set>
#include <vector>

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto& i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

signed main() {
  //入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  long ans;
  ans = 0;
  cin >> n;

  vector<long> charas(n);
  REP(i, n) { cin >> charas[i]; }
  sort(charas.begin(), charas.end());

  FOR(i, 1, n - 1) { ans += charas[n - 1 - i / 2]; }

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

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

using namespace std;
string s;
int Min=999999;//a==W,,b=E
int num[1000005];
int main()
{
    int n;
    int tmp;
    cin>>n>>s;
    tmp=0;
    for(int i=0;i<n;i++){
        num[i]=tmp;
        if(s[i]=='W') tmp++;
    }
    tmp=0;
    for(int i=n-1;i>=0;i--){
        num[i]+=tmp;
        if(s[i]=='E') tmp++;
    }
    for(int i=0;i<n;i++)
        Min=min(Min,num[i]);
    cout<<Min<<endl;
    return 0;
}


Measured memory_bytes: 1796
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N;cin >> N;
    vector<long long>retu(N);
    for(int i = 0;i<N;i++)cin >> retu.at(i);
    vector<long long> rui(N+1,0);
    map<long long,int> M;
    M[0]++;
    for(int i = 0;i<N;i++){
        rui.at(i+1) = rui.at(i) + retu.at(i);
        M[rui.at(i+1)]++;
    }
    long long ans = 0;

    for(auto A : M){
        long long amount = A.second;
        ans += amount*(amount-1)/2;
    }

    cout << ans << endl;


    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 15872
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long q = tmp[0], h = tmp[1], s = tmp[2], d = tmp[3];
    long n = readln.chomp.to!long;

    long div = n / 2, rem = n % 2;
    long l = min(4 * q, 2 * h, s);

    writeln(min(2 * l, d) * div + l * rem);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
   
  
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    
    int sum=(h2-h1)*60+(m2-m1);
    cout<<sum-k;
       
     
	return 0;
}

    

Measured memory_bytes: 3532
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX
using namespace std;

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout<<#x<<": "<<x<<endl
typedef long long ll;
llong N;

/* 2017/01/18 問題 -----  abc052 c /Link ----- */
/* -----解説等-----
問題:


*/

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string SU;
    string SR;
    string SD;
    string SL;
    FOR(i, 0, d - b) {
        SU += "U";
        SD += "D";
    }
    FOR(i, 0, c - a) {
        SR += "R";
        SL += "L";
    }
    string SS = SU + SR + SD + SL + "L" + "U" + SU + SR +"R" + "D" + "R" + SD + "D" + SL + "L" + "U";
    cout << SS << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int s = scan.nextInt();
        int w = scan.nextInt();
        if (w >= s) {
            System.out.print("unsafe");
        } else {
            System.out.print("safe");
        }
    }
}

Measured memory_bytes: 35764
#include <cstring>
#include <cstdio>
#define MOD 1000000007
typedef long long ll;
inline ll quick_pow(ll a, int n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
int sum[200005], arr[200005], app[200005], pre[200005], val[200005], n;
inline void modify(int pos, int x)
{
	for (; pos <= n; pos += pos & -pos)
		(sum[pos] += x) %= MOD;
}
inline int query(int pos)
{
	int res = 0;
	for (; pos; pos -= pos & -pos)
		(res += sum[pos]) %= MOD;
	return res;
}
int main()
{
	// freopen("AGC023-E.in", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		app[arr[i]]++;
	}
	for (int i = n; i; i--)
		app[i] += app[i + 1];
	ll coef = 1, ans = 0;
	for (int i = 1; i <= n; i++)
	{
		app[i] -= n - i;
		if (app[i] <= 0)
		{
			puts("0");
			return 0;
		}
		if (app[i] == 1)
			pre[i] = i;
		else
		{
			pre[i] = pre[i - 1];
			val[i] = (ll)(app[i] - 1) * quick_pow(app[i], MOD - 2) % MOD;
			if (val[i - 1])
				val[i] = (ll)val[i] * val[i - 1] % MOD;
		}
		coef = coef * app[i] % MOD;
	}
	for (int i = 0; i < n; i++)
	{
		(ans += coef * (query(arr[i]) - query(pre[arr[i]])) % MOD * val[arr[i]]) %= MOD;
		modify(arr[i], quick_pow(val[arr[i]], MOD - 2));
	}
	memset(sum, 0, sizeof(sum));
	for (int i = 0; i < n; i++)
	{
		(ans += coef * (i - query(arr[i])) * 2) %= MOD;
		modify(arr[i], 1);
	}
	memset(sum, 0, sizeof(sum));
	for (int i = n - 1; i >= 0; i--)
	{
		if (val[arr[i]])
		{
			(ans -= coef * (query(arr[i] - 1) - query(pre[arr[i]])) % MOD * val[arr[i]]) %= MOD;
			modify(arr[i], quick_pow(val[arr[i]], MOD - 2));
		}
	}
	printf("%lld\n", (ans + MOD) * (MOD + 1) / 2 % MOD);
	return 0;
}


Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 22:00:58 2018

@author: maezawa
"""
h, w = list(map(int, input().split()))
a = []
for i in range(h):
    a.append(list(map(int, input().split())))
    
#print(*a, sep='\n')

pos = [1, 1]
route = []
for i in range(h):
    if i%2 == 0:
        route.extend([[i+1,j] for j in range(1,w+1)])
    else:
        route.extend([[i+1,j] for j in reversed(range(1,w+1))])
cnt = 0
move =[]
i = 0
while i<w*h-1:
    if a[pos[0]-1][pos[1]-1]%2 == 0:
        i += 1
        pos[0] = route[i][0]
        pos[1] = route[i][1]
        continue
    else:
        a[pos[0]-1][pos[1]-1] -= 1
        y1 = pos[0]
        x1 = pos[1]
        i += 1
        pos[0] = route[i][0]        
        pos[1] = route[i][1]         
        a[pos[0]-1][pos[1]-1] += 1
        y2 = pos[0]
        x2 = pos[1]
        move.append([y1,x1,y2,x2])
        cnt += 1
  
print(cnt)
for i in range(len(move)):
    print(*move[i])      
        
        

Measured memory_bytes: 55992
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a,b;
    cin>>a>>b;
    int cnt=0;
    if(a>b) cnt=a+a-1;
    if(a<b) cnt=b+b-1;
    if(a==b) cnt =a+b;
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e5 + 10;
#define fi first
#define se second
#define pb push_back
char a[N];
int b[N];
int main() {
    ios::sync_with_stdio(false);
    cin>>a+1;
    int n=strlen(a+1);
    for(int i=1;i<=n;i++){
        if(a[i]=='<'){
            b[i+1]=b[i]+1;
        }
    }
    for(int i=n;i>=1;i--){
        if(a[i]=='>'){
            b[i]=max(b[i],b[i+1]+1);
        }
    }
    LL ans=0;
    for(int i=1;i<=n+1;i++)ans+=b[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int a,b;
	long int n = 0;
	cin >> a>> b;
	int i = 0;
	for (int j = b;j > 0;j /= 10) {
		i++;
	}
	n = pow(10, i)*a + b;
	for (int j = 1;j <= 1000;j++) {
		if (pow(j, 2) == n) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int a, b;
  cin >> a >> b;

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}


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

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

  int f[50][3] = {0};

  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      char c;
      cin >> c;

      if (c == 'W') f[i][0]++;
      if (c == 'B') f[i][1]++;
      if (c == 'R') f[i][2]++;
    }
  }

  int mini = 1e9;
  for (int i = 0; i < n - 2; i++){
    for (int j = i + 1; j < n - 1; j++){
      int cnt = 0;
      for (int k = 0; k < n; k++){
        if (k <= i) {
          cnt += (m - f[k][0]);
        } else if (k <= j){
          cnt += (m - f[k][1]);
        } else {
          cnt += (m - f[k][2]);
        }
      }
      mini = min(mini, cnt);
    }
  }

  cout << mini << endl;
}

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int a, b;
    cin >> a >> b;
    printf("%d %d %.10f\n", a/b, a%b, (double)a/b);
    return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		int students;
		double total = 0.0;
		double average = 0.0;
		double var = 0.0;
		
		do {
			students = scan.nextInt();
			
			if (students == 0) break;
			
			total = 0.0;
			var = 0.0;
			int point[] = new int[students];
			
			for (int i = 0; i < students; i++) {
				point[i] = scan.nextInt();
				total += (double)point[i];
			}
			
			average = total / (double)students;
			
			for (int i = 0; i < students; i++) {
				var += ((point[i] - average) * (point[i] - average));
			}
			
			System.out.println(Math.sqrt((var / students)));
			
		} while (scan.hasNext());
		
		scan.close();
	}
}



Measured memory_bytes: 31184
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n, k;
    cin>>n>>k;
    set<pair<int, int> > st;
    for(int i = 1;i<=n-1;i++){
        for(int j=i+1;j<=n;j++){
            st.insert(make_pair(i, j));
        }
    }

    if(k > (n-2)*(n-1)/2) {
        cout<<-1<<endl;
        return 0;
    }
    queue<pair<int, int> > que;
    for(int i = 1;i<=n-2;i++){
        for(int j = i+1;j<=n-1;j++){
            que.push(make_pair(i, j));
        }
    }
    rep(i, k){
        auto p = que.front();que.pop();
        st.erase(p);
    }
    cout<<st.size()<<endl;
    for(auto p : st) {
        cout<<p.first<<" "<<p.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
	int n,a;
	cin >> n;
	int max = -1000001;
	int min =  1000001;
	long sum = 0;
	for(int i=0;i<n;i++){
		cin >> a;
		sum = sum + a;
		if(max<a) max = a;
		if(min>a) min = a;
	}
	cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int N;
int A[2][105];

int main(void)
{
	cin >> N;
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < N; j++){
			cin >> A[i][j];
		}
	}
	
	int ans = 0, sum;
	for(int i = 0; i < N; i++){
		sum = 0;
		for(int j = 0; j <= i; j++) sum += A[0][j];
		for(int j = i; j < N; j++) sum += A[1][j];
		ans = max(ans, sum);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=1e5+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
int n,a[N];

int main()
{
	read(n);
	Rep(i,1,n)read(a[i]);
//	if(n==1)return printf("%d\n",a[1]),0;
	sort(a+1,a+n+1);
	double ans=1.*(a[1]+a[2])/2;
	Rep(i,3,n)ans=(double)(ans+a[i])/2;
	printf("%lf\n",ans);
	return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

int N, M;
int dp[301][301][301];
vector< pair< int, int > > ween[300];


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

  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    ween[b].emplace_back(a, c);
  }

  dp[0][0][0] = 1;

  auto check = [&](int r, int a, int b, int c)
  {
    for(auto &s : ween[r - 1]) {
      int ret = 0;
      ret += a > s.first;
      ret += b > s.first;
      ret += c > s.first;
      if(ret != s.second) return (false);
    }
    return (true);
  };

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      for(int k = 0; k < N; k++) {
        int l = max({i, j, k}) + 1;
        if(check(l, l, j, k)) (dp[l][j][k] += dp[i][j][k]) %= mod;
        if(check(l, i, l, k)) (dp[i][l][k] += dp[i][j][k]) %= mod;
        if(check(l, i, j, l)) (dp[i][j][l] += dp[i][j][k]) %= mod;
      }
    }
  }

  int ret = 0;
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= N; j++) {
      (ret += dp[i][j][N]) %= mod;
      (ret += dp[i][N][j]) %= mod;
      (ret += dp[N][i][j]) %= mod;
    }
  }

  cout << ret << endl;

}


Measured memory_bytes: 106880
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a[7];
	int	i;
	string x;
	for(i=1;i<7;i++){
		cin>>a[i];
	}
	cin>>x;
	for(i=0;i<x.size();i++){
		if(x[i]=='N'){
			swap(a[1],a[5]);
			swap(a[1],a[6]);
			swap(a[1],a[2]);
		}
		else if(x[i]=='S'){
			swap(a[1],a[2]);
			swap(a[1],a[6]);
			swap(a[1],a[5]);
		}
		else if(x[i]=='W'){
			swap(a[1],a[4]);
			swap(a[1],a[6]);
			swap(a[1],a[3]);
		}
		else{
			swap(a[1],a[3]);
			swap(a[1],a[6]);
			swap(a[1],a[4]);
		}
	}
	cout<<a[1]<<endl;
	return 0;
}
			


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

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

  ll n, m;
  cin >> n >> m;
  ll x = 100 * (n - m) + 1900 * m;
  ll ans = x * (1 << m);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int x, n, a;
	cin >> x >> n;
	map<int, bool> mp;
	for(int i = 0; i < n; i++){
		cin >> a;
		mp[a] = true;
	}

	if( mp[x] == false ){
		cout << x << endl;
		return 0;
	}

	for(int i = 1; ; i++){
		if( mp[x-i] == false ){
			cout << x-i << endl;
			return 0;
		}
		if( mp[x+i] == false ){
			cout << x+i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3660
program abc121b
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,c,i,ans
    integer(int32), allocatable:: b(:), a(:,:)

    read*, n,m,c
    allocate(b(m))
    allocate(a(m,n))
    read*, b(:)
    do i=1,n
        read*, a(:,i)
    end do
    ans=0
    do i=1,n
        if (sum(a(:,i)*b(:))+c > 0)ans=ans+1
    end do
    print'(i0)', ans
end program abc121b

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n;cin>>n;
  vector<string> s(n);
  vi t(n);
  rep(i,n){
    cin>>s.at(i)>>t.at(i);
  }
  string x;cin>>x;
  bool fl=false;
  int ans=0;
  rep(i,n){
    if(fl){
      ans+=t.at(i);
    }
    if(s.at(i)==x) fl=true;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    ll tmpa;
    vector<ll> a;

    cin >> n;
    rep(i, n){
        cin >> tmpa;
        a.push_back(tmpa);
    }

    vsort(a);

    // xCy
    ll x, y;
    x = a[n-1];
    
    auto itr = lower_bound(all(a), x/2);
    ll ind = distance(a.begin(), itr);

    // vdebug(a);
    // cout << ind << " " << x << endl;

    if(x%2 == 0){
        if(abs(x/2 - a[ind]) < abs(x/2 - a[ind-1])){
            y = a[ind];
        }else{
            y = a[ind-1];
        }
    }else{
        if(x/2 == a[ind] || x/2 + 1 == a[ind]){
            y = a[ind];
        }else if(abs(x/2 - a[ind-1]) < abs(x/2 + 1 - a[ind])){
            y = a[ind-1];
        }else{
            y = a[ind];
        }
    }

    //vdebug(a);
    cout << x << " " << y << endl;

    return 0;
}


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

int main() {
	long long x, y;
	cin >> x >> y;

	for (long long i = 1; ; i++) {
		if (x * i % y != 0 || x < y) {
			cout << x * i << endl;
			break;
		}
		else if (x * i % y == 0 || x == y || x * i > 1000000000000000000 || x == 1 || y == 1) {
			cout << -1 << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;

int main(){
  int x, n;
  cin >> x >> n;
  vector<bool> ban(200);
  for(int i = 0; i < n; i ++){
    int y; cin >> y;
    ban[y] = 1;
  }
  int ans = 200;
  for(int i = -100; i <= 111; i ++){
    if(i >= 0 && ban[i])
      continue;
    if(abs(i - x) < abs(ans - x))
      ans = i;
  }
  cout << ans;
}


Measured memory_bytes: 3608
using System;

namespace B___One_Clue
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var k = int.Parse(input[0]);
            var x = int.Parse(input[1]);
            for(var i=x-k+1; i<=x+k-1; i++)
            {
                Console.Write(i);
                if(i<x+k-1)
                {
                    Console.Write(" ");
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define MIN(a, b) (a < b ? a : b)
using namespace std;

int N;
string A;

int main() {
  cin >> N >> A;
  for(int i = 0; i < MIN(N, A.size()); i++) {
    cout << A[i];
  }
  if(A.size() > N) cout << "...\n";
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 55;

int n, x, d;
int m[MAX];
vi e[MAX];
ll ds[MAX];
int dq[MAX];

void dfs1(int x, int p = -1) {
	dq[x] = 1;
	ds[x] = m[x];
	for (int y : e[x]) {
		if (y == p) continue;
		dfs1(y, x);
		ds[x] += ds[y];
		dq[x] += dq[y];
	}
}

struct Don {
	ll q, w, c;
	Don () {};
	Don (ll q, ll w, ll c) : q(q), w(w), c(c) {};
	bool operator<(const Don & a) {
		return c * a.w - a.c * w > 0;
	}
};

vector<Don> a, b;

ll const INF = 1e9 + 41;
int const MAXQ = MAX * MAX * MAX;
ll dp[2][MAXQ];

void setval(int id) {
	fi(0, MAXQ - 1) {
		dp[id][i] = INF;
	}
}

ll mult(ll a, ll b) {
	if (a == 0) return 0;
	if (b == 0) return 0;
	if (a > INF || b > INF) return INF;
	return min(INF, a * b);
}

void solve() {
	dfs1(1);
	ll q = x / ds[1];
	a.pb(Don(min(q, 50LL), ds[1], dq[1]));
	if (q > 50) {
		b.pb(Don(q - 50, ds[1], dq[1]));
	}
	fi(2, n) {
		ll q = x / ds[i];
		q = min(q, (ll) d);
		a.pb(Don(min(q, 50LL), ds[i], dq[i]));
		if (q > 50) {
			b.pb(Don(q - 50, ds[i], dq[i]));
		}				
	}
	sort(b.begin(), b.end());

	setval(0);
	setval(1);
	dp[0][0] = 0;
	fi(0, sz(a) - 1) {
		setval(1);
		fj(0, MAXQ - 1) {
			for (ll take = 0; take <= a[i].q; take++) {
				ll c1 = mult(take, a[i].w);
				if (c1 + dp[0][j] >= INF) continue;
				assert(j + take * a[i].c < MAXQ);
				dp[1][j + take * a[i].c] = min(dp[1][j + take * a[i].c], dp[0][j] + c1);
			}
		}
		memcpy(dp[0], dp[1], sizeof(dp[0]));	
	}			

	ll ans = 0;
	fi(0, MAXQ - 1) {
		int rem = x - dp[0][i];
		if (rem < 0) continue;
		int cur = i;
		fj(0, sz(b) - 1) {
			ll mini = min(b[j].q, rem / b[j].w);
			cur += mini * b[j].c;
			rem -= b[j].w * mini;
		}
		ans = max(ans, (ll) cur);
	}

	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d %d %d", &n, &x, &d);
	scanf("%d", &m[1]);
	fi(2, n) {
		int p;
		scanf("%d %d", &m[i], &p);
		e[p].pb(i);
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

string s;


int main(){
    cin >> s;
    if(s[0] == 'S') cout << "Cloudy" << endl;
    else if (s[0] == 'C') cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    


return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

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

    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int cnt = 1;
    int minnum = v[0];
    REP(i,1,n) {
        if(v[i]<minnum) {
            cnt++;
            minnum = v[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

ll V;
vector<vector<ll>> G;
vector<ll> match;
vector<int> used;

void add_edge(ll u, ll v) {
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(ll v) {
	used[v] = 1;
	for (int i = 0; i < G[v].size(); i++) {
		ll u = G[v][i], w = match[u];
		if (w < 0 || ((used[w] == 0) && dfs(w))) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

ll bipartite_matching() {
	ll res = 0;
	for (int i = 0; i < (int)match.size();i++)match[i] = -1;
	for (int v = 0;v < V;v++) {
		if (match[v] < 0) {
			for (int i = 0; i < (int)used.size();i++)used[i] = 0;
			if (dfs(v))res++;
		}
	}
	return res;
}

/* use example */
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll X, Y, E; cin >> X >> Y >> E;
	V = X + Y; // initialize V [0..index]
	G.resize(V); used.resize(V); match.resize(V); // initialize G used match
	for (int i = 0; i < E;i++) {
		ll x, y; cin >> x >> y;
		add_edge(x, y + X);
	}
	cout << bipartite_matching() << endl;
	return 0;
}



Measured memory_bytes: 3276
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int a, b, ans; 

int main(){

	scanf("%d%d", &a, &b);
	if(a == 1 && b == 1)
		puts("1000000");
	else{
		if(a == 1) ans += 300000;
		if(a == 2) ans += 200000;
		if(a == 3) ans += 100000;
		if(b == 1) ans += 300000;
		if(b == 2) ans += 200000;
		if(b == 3) ans += 100000;
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)  # aを優先度付きキューに

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  # 計算誤差の関係で-1を2回かけてます
print(-sum(a))

Measured memory_bytes: 72216
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    cnt = collections.Counter(S)
    if abs(cnt['a'] - cnt['b']) > 1 or abs(cnt['a'] - cnt['c']) > 1 or abs(cnt['b'] - cnt['c']) > 1:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10168
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>

#define INF 100000000
#define ll long long

using namespace std;

int main() {
	int a[5] = {};
	int b[5] = {};
	int c[5][5] = {};
	
	for (int i = 1; i <= 3 ; i++)
	{
		for (int j = 1; j <= 3; j++)
		{
			cin >> c[i][j];
		}
	}
	
	for (int i = 0; i <=100 ; i++)
	{
		a[1] = i;
		if (c[1][1] - a[1] >= 0) {
			b[1] = c[1][1] - a[1];
		}
		else {
			continue;
		}
		if (c[1][2] - a[1] >= 0) {
			b[2] = c[1][2] - a[1];
		}
		else {
			continue;
		}

		if (c[1][3] - a[1] >= 0) {
			b[3] = c[1][3] - a[1];
		}
		else {
			continue;
		}

		if (c[2][1] - b[1] >= 0) {
			a[2] = c[2][1] - b[1];
		}
		else {
			continue;
		}

		if (c[3][1] - b[1] >= 0) {
			a[3] = c[3][1] - b[1];
		}
		else {
			continue;
		}

		int cnt = 0;
		for (int i = 1; i <= 3; i++)
		{
			for (int j = 1; j <= 3; j++)
			{
				if (c[i][j] == a[i] + b[j])
				{
					cnt++;
				}
			}
		}
		if (cnt == 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,x;
ll a[2000];
ll b[2000];
int main(){
  cin>>N>>x;
  for(int i=0;i<N;i++){
    cin>>a[i];
    b[i]=a[i];
  }

  ll ans=(1LL<<60);
  for(int i=0;i<N;i++){
    ll cost=i*x;
    if( cost > ans )break;
    
    for(int j=0;j<N;j++){
      b[j]=min(b[j],a[ (j-i+N)%N ]);
      cost+=b[j];
    }
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {
	int n;
	vector<ll> a, b;
	cin >> n;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	ll cnt = 0;
	for (int i = n - 1; i >= 0; --i) {
		if ((a[i]+cnt) % b[i] == 0) {
			continue;
		}
		else {
			cnt += (b[i] - (a[i]+cnt) % b[i]);
		}
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

const int MAXN = 200200;
using ll = long long;

int N, H, W;
int par[MAXN];
int flag[MAXN];
vector<tuple<int, int, int>> edges;

int getPar(int v) {
   if (v != par[v]) {
      par[v] = getPar(par[v]);
   }
   return par[v];
}

bool merge(int v, int u) {
   v = getPar(v);
   u = getPar(u);
   if (v == u) {
      if (flag[v]) return false;
      flag[v] = true;
      return true;
   }
   if (flag[v] && flag[u]) return false;
   par[u] = v;
   flag[v] |= flag[u];
   return true;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin >> N >> H >> W;
   for (int i = 0; i < N; ++i) {
      int r, c, z;
      cin >> r >> c >> z;
      --r, --c; c += H;
      edges.emplace_back(z, r, c);
   }
   iota(par, par + H + W, 0);
   sort(edges.rbegin(), edges.rend());
   ll ans = 0;
   for (auto e : edges) {
      if (merge(get<1>(e), get<2>(e))) {
         ans += get<0>(e);
      }
   }
   cout << ans << "\n";
   return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)  cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    double amid = n%2 ? a[n/2] : (a[n/2]+a[n/2-1])/2.0;
    double bmid = n%2 ? b[n/2] : (b[n/2]+b[n/2-1])/2.0;
    cout << (n%2 ? (int)(bmid-amid)+1 : (int)((bmid-amid)*2)+1) << endl;
    return 0;
}

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 set<char>s;
 for (int i=1;i<=3;i++)
 {
   char c;
   cin>>c;
   s.insert(c);
 }if(s.size()==1)
 {
   cout<<"No"<<endl;
 }
 else
 {cout<<"Yes"<<endl;}

}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if(a==0) cout<<'0'<<endl;
    else if(n%(a+b)>a) cout<<(n/(a+b))*a+a<<endl;
    else cout<<(n/(a+b))*a+n%(a+b)<<endl;
    return 0;
}

Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    char c;
    cin>>c;
    if(isupper(c)) cout<<"A";
    else cout<<"a";
}

Measured memory_bytes: 3632
from collections import deque
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]


first_black = sum([row.count('#') for row in G])
que = deque([(0, 0)])
dist = [[-1] * W for i in range(H)]
dist[0][0] = 0
direction = [(0, 1), (0, -1), (1, 0), (-1, 0)]

while que:
    nh, nw = que.pop()
    for dh, dw in direction:
        if not ((0 <= nh + dh < H) & (0 <= nw + dw < W)):
            continue
        if G[nh + dh][nw + dw] == '#':
            continue
        if dist[nh + dh][nw + dw] > 0:
            continue

        dist[nh + dh][nw + dw] = dist[nh][nw] + 1
        que.appendleft((nh + dh, nw + dw))


if dist[-1][-1] != -1:
    print(H * W - dist[-1][-1] - first_black - 1)
else:
    print(-1)


Measured memory_bytes: 3316
N=int(input())
AB=[[0,0]]
for i in range(N):
  AB.append(list(map(int, input().split())))

AB = sorted(AB, key=lambda x: x[1], reverse=False)


judge="Yes"
for i in range(N):
  AB[i+1][0]+=AB[i][0]
  if AB[i+1][0]>AB[i+1][1]:
    judge="No"
    
print(judge)

Measured memory_bytes: 90200
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b;
    cin>>c>>d;
    if(a+1==c)cout<<"1"<<endl;
    else cout<<"0"<<endl;
}


Measured memory_bytes: 256