akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

int N, A, B, C, D;
map<int, int> memo;
int solve(int num)
{
    if (num == 0)
        return 0;
    if (num == 1)
        return D;
    if (memo.count(num))
    {
        return memo[num];
    }

    int cost = INF;
    int add;

    if (cost / D > num)
        cost = D * num;

    if (num % 2 == 0)
    {
        add = A;
        cost = min(cost, solve(num / 2) + add);
    }
    else
    {
        int tmp = num;
        while (true)
        {
            tmp++;
            if (tmp % 2 == 0)
            {
                add = A + D * abs(num - tmp);
                cost = min(cost, solve(tmp / 2) + add);
                break;
            }
        }
        tmp = num;
        while (true)
        {
            tmp--;
            if (tmp % 2 == 0)
            {
                add = A + D * abs(num - tmp);
                cost = min(cost, solve(tmp / 2) + add);
                break;
            }
        }
    }

    if (num % 3 == 0)
    {
        add = B;
        cost = min(cost, solve(num / 3) + add);
    }
    else
    {
        int tmp = num;
        while (true)
        {
            tmp++;
            if (tmp % 3 == 0)
            {
                add = B + D * abs(num - tmp);
                cost = min(cost, solve(tmp / 3) + add);
                break;
            }
        }
        tmp = num;
        while (true)
        {
            tmp--;
            if (tmp % 3 == 0)
            {
                add = B + D * abs(num - tmp);
                cost = min(cost, solve(tmp / 3) + add);
                break;
            }
        }
    }

    if (num % 5 == 0)
    {
        add = C;
        cost = min(cost, solve(num / 5) + add);
    }
    else
    {
        int tmp = num;
        while (true)
        {
            tmp++;
            if (tmp % 5 == 0)
            {
                add = C + D * abs(num - tmp);
                cost = min(cost, solve(tmp / 5) + add);
                break;
            }
        }
        tmp = num;
        while (true)
        {
            tmp--;
            if (tmp % 5 == 0)
            {
                add = C + D * abs(num - tmp);
                cost = min(cost, solve(tmp / 5) + add);
                break;
            }
        }
    }
    memo[num] = cost;
    return cost;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int T;
    cin >> T;
    REP(i, T)
    {
        cin >> N >> A >> B >> C >> D;
        memo.clear();
        cout << solve(N) << endl;
    }

    return 0;
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

vector<ll> G[200010];
stack<ll> col[200010];
ll C[200010];
ll ans[200010];

ll seg[524288];
ll app[200010];
ll N;

void raq(ll s = 0, ll t = 262143, ll v = 1, ll k = 1, ll l = 0, ll r = 262143) {
	if (t < l || r < s)return;
	if (s <= l && r <= t) {
		seg[k] += v;
		return;
	}
	raq(s, t, v, k * 2, l, (l + r) / 2);
	raq(s, t, v, k * 2 + 1, (l + r) / 2 + 1, r);
}

ll gets(ll x) {
	x += 262144;
	ll ans = 0;
	while (x) {
		ans += seg[x];
		x /= 2;
	}
	return ans;
}

void pini(ll x, ll v) {
	ll a = gets(x);
	raq(x, x, v - a);
}

ll alc = 0;

void euler(ll c, ll p) {
	for (ll i : G[c]) {
		if (i == p)continue;
		col[C[c]].push(gets(C[c]));
		pini(C[c], 0);
		raq();
		raq(C[i], C[i], -1);
		euler(i, c);
	}

	if (p == 0) {
		for (ll i = 1;i <= N;i++) {
			ll gc = gets(i);
			ans[i] += gc * (gc - 1) / 2;
		}
		return;
	}
	ll gc = gets(C[p]);
	ans[C[p]] += gc * (gc - 1) / 2;
	pini(C[p], col[C[p]].top());
	col[C[p]].pop();
	return;
}

int main() {
	for (ll i = 0;i < 200010;i++)ans[i] = app[i] = C[i] = 0;
	for (ll i = 0;i < 524288;i++)seg[i] = 0;
	ll a, b;
	cin >> N;
	for (ll i = 1;i <= N;i++) {
		cin >> C[i];
		app[C[i]]++;
	}
	for (ll i = 1;i < N;i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (ll i = 1;i <= N;i++) {
		col[i].push(0);
	}
	raq();
	pini(C[1], 0);

	euler(1, 0);
	for (ll i = 1;i <= N;i++) {
		if (app[i] == 0)cout << 0 << endl;
		else
			cout << N * (N - 1) / 2 - ans[i] + app[i] << endl;
	}
}


Measured memory_bytes: 178124
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n;
    int ans = 0;
    int a[100];
    cin >> n;
    rep (i, n) {
        cin >> a[i];
        rep (j, i) {
            ans = max(abs(a[i] - a[j]), ans);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

void OutputEdges(const vector<int> &g1, const vector<int> &g2)
{
    for (const int v1 : g1)
    {
        for (const int v2 : g2)
        {
            cout << v1 << ' ' << v2 << endl;
        }
    }
}

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

    vector<vector<int>> groups;
    if (N % 2 == 0)
    {
        for (int i = 1; i <= N / 2; ++i)
        {
            groups.push_back({ i, N - i + 1 });
        }
    }
    else
    {
        for (int i = 1; i <= N / 2; ++i)
        {
            groups.push_back({ i, N - i });
        }
        groups.push_back({ N });
    }

    int groupNum = static_cast<int>(groups.size());
    if (N % 2 == 0)
    {
        cout << groupNum * (groupNum - 1) / 2 * 4 << endl;
    }
    else
    {
        cout << (groupNum - 1) * (groupNum - 2) / 2 * 4
            + (groupNum - 1) * 2 << endl;
    }

    for (int i = 0; i < groupNum; ++i)
    {
        for (int j = i + 1; j < groupNum; ++j)
        {
            OutputEdges(groups[i], groups[j]);
        }
    }
}

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

int main(){
	
	int n;
	while(cin>>n){
		if(n!=0){
	while(n>0){
		int pm,pe,pj;
		cin>>pm>>pe>>pj;
		if(pm==100||pe==100||pj==100||(pm+pe)/2>=90||(pm+pe+pj)/3>=80)
			cout<<"A"<<endl;
		else if((pm+pe+pj)/3>=70||((pm+pe+pj)/3>=50&&pm>=80||pe>=80))
			cout<<"B"<<endl;
		else
			cout<<"C"<<endl;
		n--;
	}
	}
		else
			break;
	}

	

}

Measured memory_bytes: 1156
import sys
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

ls = rvfunc(int)(reader())
#print(ls)
n,d=ls[0]
dst = vfunc(lambda ab:(ab[0]**2+ab[1]**2)**0.5<=d)(ls[1:])
print(sum(dst))


Measured memory_bytes: 170304
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N;
    cin >> N;
    vector<vector<char>> s(N, vector<char>(10));
    FOR(i, 0, N) {
        FOR(j, 0, 10) {
            cin >> s[i][j];
        }
        sort(ALL(s[i]));
    }
    sort(ALL(s));
    set<vector<char>> se;
    for (auto v : s) {
        se.insert(v);
    }
    ll ans = 0;
    for (auto v : se) {
        ll tmp = COUNT(s, v);
        ans += (tmp - 1) * tmp / 2;
    }
    cout << ans << endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------


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

	int a,b;cin>>a>>b;
	cout<<(a+b)/2<<endl;

	return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[405][405];
bool S[405][405];
ll ans;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
int main(void){
    int a,b; cin>>a>>b;
    for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cin>>s[i][j];
		}
	}
	queue<P> que;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(s[i][j]=='#'&&S[i][j]==false){
				ll count=1;
				ll countans=0;
				que.push(P(i,j));
				S[i][j]=true;
				while(que.size()){
					P p=que.front(); que.pop();
					for(int k=0;k<4;k++){
						int nx=p.first+dx[k],ny=p.second+dy[k];
						if(nx>=0&&nx<a&&ny>=0&&ny<b&&S[nx][ny]==false){
							if(s[p.first][p.second]=='#'){
								if(s[nx][ny]=='.'){
									countans++;
									que.push(P(nx,ny));
									S[nx][ny]=true;
								}
							}else{
								if(s[nx][ny]=='#'){
									count++;
									que.push(P(nx,ny));
									S[nx][ny]=true;
								}
							}
						}
					}
				}
				ans=ans+count*countans;
			}
		}
	}
	cout<<ans<<endl;
    
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>


int main(void) {
  char s[100][100];
  int t[101] = {}, y[101] = {};
  int h, w, i, j;
  scanf("%d %d", &h, &w);
  for(i=0; i<h; i++) scanf("%s", s[i]);
  for(i=0; i<h; i++){
    for(j=0; j<w; j++){
      if(s[i][j] == '#') {t[i]=1; y[j]=1;}
    }
  }
  for(i=0; i<h; i++){
    for(j=0; j<w; j++){
      if(t[i]==1 && y[j]==1) printf("%c", s[i][j]);
    }
    if(t[i]==1) putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 128
s = list(input())
for i in range(len(s)):
  s[i] = int(s[i])
c = 0
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    s[i] += 1
    s[i] %= 2
    c += 1
if c > len(s) // 2:
  print(len(s)-c)
else:
  print(c)

Measured memory_bytes: 3956
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>

using namespace std;

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

class P{
	public:
	int x,y,val;
	P(int x,int y,int val):x(x),y(y),val(val){}
};

int main(){
	
	A:;
	int w,h;
	cin>>w>>h;
	if(w==0 && h==0)return 0;
	
	vector<int> tall[33];
	vector<int> wall[33];
	
	rep(i,h){
		rep(j,w-1){
			int a;
			cin>>a;
			tall[i].push_back(a);
		}
		
		if(i==h-1)continue;
		rep(j,w){
			int a;
			cin>>a;
			wall[i].push_back(a);
		}
	}
	
	queue<P> que;
	que.push(P(0,0,0));
	
	int visit[33][33]={0};
	int ans = 0;
	while(1){
		if(que.empty())break;
		
		P u = que.front();
		que.pop();
		
		int x = u.x;
		int y = u.y;
		int val = u.val;
		
		if(visit[x][y]==1)continue;
		visit[x][y]=1;
		
		if(x==w-1 && y==h-1){
			ans = val;
			break;
		}
		
		if(x<w-1 && tall[y][x]==0)que.push(P(x+1,y,val+1));
		if(x-1>=0 && tall[y][x-1]==0)que.push(P(x-1,y,val+1));
		if(y<h-1 && wall[y][x]==0)que.push(P(x,y+1,val+1));
		if(y-1>=0 && wall[y-1][x]==0)que.push(P(x,y-1,val+1));
	}
	
	if(ans==0)puts("0");
	else printf("%d\n",ans+1);
	
	goto A;
}

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

typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    if (A < 6) cout << "0\n";
    else if (A < 13) cout << B / 2 << "\n";
    else cout << B << "\n";
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
  so:array[0..24] of integer = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97);
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Readln(n);
    count:=0;
    max  :=0;
    min  :=100;

    for j:=1 to n do begin //sagasu
      count:=0;
      if j mod 2 <> 0 then begin
        for i := 1 to 35 do //kazoeru
          if j mod (i*2-1) = 0 then
            inc(count);
        if count=7 then
          inc(max);
      end;
    end;

    Writeln(max);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

using namespace std;

int i,j,k;

int main(){
    long n;
    cin >>n;
    long a[n];
    int b[n+1];
    long ansum=0;
    REP(i,n+1){
        b[i]=0;
    }
    REP(i,n){
        cin>>a[i];
        ansum+=b[a[i]];
        b[a[i]]++;
    }
    REP(i,n){
        long ans;
        ans=ansum-b[a[i]]+1;
        
        cout<<ans<<endl;
    }

    
    
    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e3+5;

int main()
{
    LL a,b,c;
    cin >> a >> b;
    c = __gcd(a,b);
    cout << a*b/c << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
struct Puzzle {
	int st[9];
	int space, len;
	bool operator < (const Puzzle& rhs) const {
		for (int i = 0; i < 9; i++) {
			if (st[i] == rhs.st[i]) continue;
			return st[i] < rhs.st[i];
		}
		return false;
	}
} in;
bool isTarget(Puzzle p) {
	for (int i = 0; i < 9; i++) {
		if (p.st[i] != i + 1) return false;
	}
	return true;
}
int bfs() {
	queue<Puzzle> q;
	set<Puzzle> s;
	q.push(in);
	s.insert(in);
	while (!q.empty()) {
		Puzzle u = q.front(), v;
		q.pop();
		if (isTarget(u)) return u.len;
		int sx = u.space / 3, sy = u.space % 3;
		for (int i = 0; i < 4; i++) {
			int tx = sx + dx[i], ty = sy + dy[i];
			if (tx < 0 || ty < 0 || tx >= 3 || ty >= 3) continue;
			v = u;
			v.space = tx * 3 + ty;
			v.len++;
			swap(v.st[u.space], v.st[v.space]);
			if (!s.count(v)) {
				s.insert(v);
				q.push(v);
			}
		}
	}
}
int main() {
    for (int i = 0; i < 9; i++) {
    	scanf("%d", &in.st[i]);
    	if (in.st[i] == 0) {
    		in.space = i;
    		in.st[i] = 9;
		}
	}
	in.len = 0;
	printf("%d\n", bfs());
	return 0;
}


Measured memory_bytes: 20204
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n;
  cin>>n;
  vector<int>x(n);
  for(int i=0;i<n;i++)cin>>x[i];
  vector<int>copy=x;
  sort(copy.begin(),copy.end());
  int a=copy[n/2-1];
  int b=copy[n/2];
  for(int i=0;i<n;i++){
    if(x[i]>=b)cout<<a<<endl;
    else cout<<b<<endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
typedef long long LL;
const int maxN = 307;
LL O;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int n, K;
LL C[maxN][maxN];
LL f[maxN][maxN], g[maxN][maxN];

int main() {

	n = ri(), K = ri(), O = ri();
	rep (i, 0, n) {
		C[i][0] = 1;
		rep (j, 1, i) C[i][j] = (C[i-1][j] + C[i-1][j-1]) % O;
	}
	rep (i, 0, K) f[0][i] = 1;
	g[0][K] = 0; per (x, K-1, 0) g[0][x] = (g[0][x+1] + f[0][x+1]) % O;
	rep (i, 1, n) {
		rep (x, 0, K) {
			For (a, 0, i) { int b = i - 1 - a;
				f[i][x] += g[b][x] * f[a][x] % O * C[a+b][a] % O;
			}
			f[i][x] %= O;
		}
		g[i][K] = 0; per (x, K-1, 0) g[i][x] = (g[i][x+1] + f[i][x+1]) % O;
	}
	printf("%lld\n", f[n][0]);

	return 0;
}


Measured memory_bytes: 2432
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    class UnionFind:
        def __init__(self, N: int):
            """
            N:要素数
            root:各要素の親要素の番号を格納するリスト.
                 ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
            rank:ランク
            """
            self.N = N
            self.root = [-1] * N
            self.rank = [0] * N

        def __repr__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

        def find(self, x: int):
            """頂点xの根を見つける"""
            if self.root[x] < 0:
                return x
            else:
                while self.root[x] >= 0:
                    x = self.root[x]
                return x

        def union(self, x: int, y: int):
            """x,yが属する木をunion"""
            # 根を比較する
            # すでに同じ木に属していた場合は何もしない.
            # 違う木に属していた場合はrankを見てくっつける方を決める.
            # rankが同じ時はrankを1増やす
            x = self.find(x)
            y = self.find(y)
            if x == y:
                return
            elif self.rank[x] > self.rank[y]:
                self.root[x] += self.root[y]
                self.root[y] = x
            else:
                self.root[y] += self.root[x]
                self.root[x] = y
                if self.rank[x] == self.rank[y]:
                    self.rank[y] += 1

        def same(self, x: int, y: int):
            """xとyが同じグループに属するかどうか"""
            return self.find(x) == self.find(y)

        def count(self, x):
            """頂点xが属する木のサイズを返す"""
            return - self.root[self.find(x)]

        def members(self, x):
            """xが属する木の要素を列挙"""
            _root = self.find(x)
            return [i for i in range(self.N) if self.find == _root]

        def roots(self):
            """森の根を列挙"""
            return [i for i, x in enumerate(self.root) if x < 0]

        def group_count(self):
            """連結成分の数"""
            return len(self.roots())

        def all_group_members(self):
            """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
            return {r: self.members(r) for r in self.roots()}
        
    N,M=MI()
    uf=UnionFind(N)
    for _ in range(M):
        a,b=MI()
        a-=1
        b-=1
        uf.union(a,b)
        
    cnt=uf.group_count()
    print(cnt-1)

main()


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

int main(){
    int n,m;
    cin >> n >> m;
    int a[n];
    rep(i,n)cin >> a[i];
    int sum=0;
    ll ans=0;
    map<int,int>t;
    rep(i,n){
      sum+=a[i];
      sum%=m;
      t[sum]++;
      if(sum==0)ans+=t[sum];
      else ans += t[sum]-1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
n,k=map(int,input().split())
r1=1
t=1
import math
mod=10**9+7
dif=n-k
for i in range(k):
  if i==0:r1=dif+1
  else:
    r1=r1*(k-i)*(dif+1-i)*pow((i*i+i), mod-2, mod)%mod
  print(r1)

Measured memory_bytes: 3316
import sys

# n = 10 ** 5
# データ読み込み関係
n = int(input())

a = list(map(int, input().split(' ')))

record = {}

possible = True

# 状況が実現可能か確認
for e in a:
    if(e in record.keys()):
        record[e] += 1
        if(record[e] == 2):
            if(e == 0):
                possible = False
                break
        if(record[e] == 3):
            possible = False
            break
    else:
        record[e] = 1

if(possible == False):
    print(0)
    sys.exit()

multiCount = int(n / 2)

print(2 ** multiCount % (10 ** 9 + 7))

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

int main(){
    string n;
    cin >> n;
    if(n[0] == '9' || n[1] == '9')
        cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}


Measured memory_bytes: 256
Q, H, S, D = map(int, input().split())
N = int(input())
n = N // 2 * 2
ans =  min(n * Q * 4, n * H * 2, n * S, n * D // 2)
if N % 2 == 1:
    ans += min(Q * 4, H * 2, S)
print(ans)

Measured memory_bytes: 9148
#include <stdio.h>
int main ()
{
  int i,j,num,tmp,count=0,min,A[100];

  scanf("%d",&num);

  for(i=0;i<num;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=0;i<num;i++)
    {
      min=i;
      for(j=i;j<num;j++)
	{
	  if(A[j]<A[min])
	    {
	      min=j;
	    }
	}
      tmp=A[i];
      A[i]=A[min];
      A[min]=tmp;
      if(i!=min) count++;
    }
  for(i=0;i<num-1;i++)
    {
      printf("%d ",A[i]);
    }
  printf("%d",A[num-1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}    

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    string s;
    cin >> s;ll ans=0;
    for(ll i=0;i<4;i++){
        if(s[i]=='+')ans++;
        else ans--
    ;}cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
signed main(){
  string s,t,ts,tt;
  ll sat,sbt,tat,tbt;
  ll q;
  cin >> s>>t>>q;
  ll query[4];
  ll ssum[s.size()][2];
  ll tsum[t.size()][2];
  fill(ssum[0],ssum[s.size()],0);
  fill(tsum[0],tsum[t.size()],0);

  for(int i=0;i<s.size();i++){
    if(s[i]=='A') ssum[i][0]++;
    else ssum[i][1]++;
    if(i!=0){
      ssum[i][0] += ssum[i-1][0];
      ssum[i][1] += ssum[i-1][1];
    }
  }
  for(int i=0;i<t.size();i++){
    if(t[i]=='A') tsum[i][0]++;
    else tsum[i][1]++;
    if(i!=0){
      tsum[i][0] += tsum[i-1][0];
      tsum[i][1] += tsum[i-1][1];
    }
  }
  for(int i=0;i<q;i++){
    for(int j=0;j<4;j++){
      cin >> query[j];
      query[j]--;
    }
    sat = ssum[query[1]][0];
    sbt = ssum[query[1]][1];

    tat = tsum[query[3]][0];
    tbt = tsum[query[3]][1];
    if(query[0]!=0){
      sat -= ssum[query[0]-1][0];
      sbt -= ssum[query[0]-1][1];
    }
    if(query[2]!=0){
      tat -= tsum[query[2]-1][0];
      tbt -= tsum[query[2]-1][1];
    }
    sbt += sat*2;
    tbt += tat*2; 
    if(sbt%3==tbt%3){
      cout <<"YES\n";
    }else{
      cout <<"NO\n";
    }
  }
}


Measured memory_bytes: 3968
import bisect

n=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))

sum=0
for bb in b:
    x=bisect.bisect_left(a,bb)
    y=bisect.bisect_right(c,bb)
    sum+=x*(n-y)
print(sum)

Measured memory_bytes: 23968
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n,w;
cin >> n >> w;
vector<i64> weight(n),value(n);
rep(i,n){
    cin >> weight[i] >> value[i];
}
vector<i64> dp(w + 1,0);
dp[0] = 0;
rep(i,n) {
    for (i64 j = w; 0 < j; j--) {
        if(j - weight[i] >= 0){
            dp[j] = max(dp[j - weight[i]] + value[i],dp[j]);
        }else{
            dp[j] = max(dp[j],dp[j - 1]);
        }
    }
}
/*for(auto v:dp){
    cout << v << endl;
}*/
cout << dp[w] << endl;
}

Measured memory_bytes: 3968
N,D,A = map(int,input().split())
data = [list(map(int,input().split())) for i in range(N)]

from math import ceil

B = []
for i in range(N):
    B.append((data[i][0],ceil(data[i][1]/A)))

B = [(0,0)] + sorted(B)

C = [0]  #C[i] = (X[j] <= X[i]+2*D たる最大の j)
for i in range(1,N+1):
    a = i
    b = N+1
    while a+1 < b:
        mid = (a+b)//2
        if B[mid][0] <= B[i][0] + 2*D:
            a = mid
        else:
            b = mid
    C.append(a)

D = [0]*(N+2)  #D[i] = (i番目の敵が攻撃される回数)
ans = 0
for i in range(1,N+1):
    D[i] = max(0,D[i-1]+D[i])
    if D[i] >= B[i][1]:
        continue
    else:
        k = -D[i]+B[i][1]
        D[i] += k
        D[C[i]+1] -= k
        ans += k
print(ans)

Measured memory_bytes: 132292
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {

	string S;
	cin >> S;
	int flag = 0;

	for (int i = 0; i < S.length() - 1; i++) {
		for (int j = i + 1; j < S.length(); j++) {
			if (S[i] == S[j]) {
				flag++;
				break;
			}
		}
	}
	
	

	if (flag >= 1)
		cout << "no";
	else
		cout << "yes";
	return 0;
}

Measured memory_bytes: 256
x = []
for i in range(3):
    x1 , y1, z1 =[int(i) for i in input().split()]
    x.append(x1)
    x.append(y1)
    x.append(z1)

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))

for i in range(n):
    for j in range(9):
        if s[i] == x[j]:
            x[j] = 0

if x[0]==x[1]==x[2] or x[3]==x[4]==x[5] or x[6]==x[7]==x[8] or x[0] == x[4] == x[8] or x[2] == x[4] == x[6] or x[0] == x[3]==x[6] or x[1] == x[4] ==x[7] or x[2] ==x[5] ==x[8]:
    print('Yes') 
else:
    print('No')

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

int main() {
  string s; cin >>s;
  int a=0, b=0;
  // aは0101…に、bは1010…にするのに必要な枚数
  for (int i=0; i<s.size(); i++){
    if (s.at(i)=='0'){
      if (i%2==0) b++;
      else a++;
    }else if (s.at(i)=='1'){
      if (i%2==0) a++;
      else b++;
    }
  }
  int ans = min(a,b);
  cout <<ans;
  cout <<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;
    string res = "Yes";

    REP(i,S.size())
    {
        if(i == A)
        {
            if(S[i] != '-')res = "No";
        }
        else
        {
            if(S[i] == '-')res = "No";            
        }
    }


    cout << res << endl;
    return 0;
}


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

const int M=100010;
bool stu[410][410];
int n,m,a[M],b[M];
bool cant[410];

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d%d",a+i,b+i);
    for(int i=1;i<=n;i++)
    {
        stu[i][i]=1;
        for(int j=m;j>=1;j--)
        {
            bool x=stu[i][a[j]],y=stu[i][b[j]];
            if(x&&y){cant[i]=1;break;}
            else if(x) stu[i][b[j]]=1;
            else if(y) stu[i][a[j]]=1;
        }
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(cant[i]) continue;
        for(int j=i+1;j<=n;j++)
        {
            if(cant[j]) continue;
            bool flag=1;
            for(int k=1;k<=n;k++)
                if(stu[i][k]&&stu[j][k]) flag=0;
            ans+=flag;
        }
    }
    printf("%d\n",ans);
    return 0;
}
//asdsdhuivhxcivbghlawhfuhssdfasfsdfs

Measured memory_bytes: 1152
N = int(input())
A = list(map(int, input().split()))
dp = [[0,0] for i in range(N+1)]
dp[0][1] = -10**20

for i in range(N):
    dp[i+1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
    dp[i+1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])

print(dp[-1][0])


Measured memory_bytes: 25644
import fractions
from functools import reduce


n, m = map(int, input().split())
A = list(set(map(int, input().split())))

hA = [a//2 for a in A]
lcm = 1
for a in hA:
    lcm = (lcm * a) // fractions.gcd(lcm, a)
    if lcm > m:
        print(0)
        break
else:
    for a in A:
        if lcm % a == 0:
            print(0)
            break
    else:
        if (m//lcm) % 2 == 0:
            print(m//lcm//2)
        else:
            print(m//lcm//2 + 1)


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

int main() {
	int A, B;
	cin >> A >> B;
	int cnt = 0;
	for(int i = A; i <= B; i++){
		string i_string = to_string(i);
		string i_former = i_string.substr(0, i_string.size() / 2);
		string i_latter = i_string.substr(i_string.size() / 2 + 1, i_string.size() / 2);
		reverse(i_latter.begin(), i_latter.end());
		if(i_former == i_latter){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    if (B >= C && C >= A){
    System.out.println("Yes");
    }
    else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21712
object Main extends App {
  val n = readInt()
  (1 to n).foreach { i =>
    val arr = readLine().split(" ").map(_.toDouble)
    val (x1, y1) = (arr(0), arr(1))
    val (x2, y2) = (arr(2), arr(3))
    val (x3, y3) = (arr(4), arr(5))
    val (x4, y4) = (arr(6), arr(7))
    if (Math.abs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) < 1e-10) println("YES") else println("NO")
  }
}

Measured memory_bytes: 43972
#include <iostream>
#include <vector>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, x, count;

  while(1) {
    count = 0;
    cin >> n >> x;
    if(n == 0 && x == 0) break;

    for(int i=1; i<=n; i++) {
      for(int j=i+1; j<=n; j++) {
        for(int k=j+1; k<=n; k++) {
          if(i + j + k == x) count++;
        }
      }
    }
    cout << count << "\n";
  }
  return 0;
}



Measured memory_bytes: 3140
using System;

class Atcoder70
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        double a = double.Parse(input[0]);
        double b = double.Parse(input[1]);

        double average = (a + b) / 2.0;

        Console.WriteLine(Math.Ceiling(average));
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



char buf[105];

int main(){

	scanf("%s",buf);

	int len;
	for(len = 0; buf[len] != '\0'; len++);

	int ans = 0;

	for(int i = 0; i < len/2; i++){
		if(buf[i] != buf[(len-1)-i]){
			ans++;
		}
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
  int n,m; cin>>n>>m;
  if(n>=m){cout<<0; return 0;}
  
  int M[m]; int D[m-1];
  for(int i=0;i<m;i++){cin>>M[i];}
  sort(M,M+m);
  
  for(int i=0;i<m-1;i++){D[i]=M[i+1]-M[i];}
  sort(D,D+m-1);
  
  ll sum=0;
  for(int i=0;i<m-n;i++){sum=sum+(ll)D[i];}
  cout<<sum;
  
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    int n;//回数
    cin>>n;
    int i;//回した回数
    long long ma,mi;
    ma=0;
    mi=0;
    long long x;
    x=0;
    i=0;
    while(n>i)
    {
        i++;
        long long a;
        cin>>a;
        if(i==1)
        {
            ma=a;
            mi=a;
        }
        else
        {
            ma=max(ma,a);
            mi=min(mi,a);
        }
        x=x+a;
        
    }
    
    cout<<mi<<" "<<ma<<" "<<x<<endl;

   return 0;
}



Measured memory_bytes: 3108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int diff = b-a;
        int count = 0;
        
        
        
        for(int i=1;i<diff;i++) {
            count +=i;
        } 
        System.out.println(count-a);
        
        
    }
}

Measured memory_bytes: 22100
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a;a%=b;return gcd(b,a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
void solveforthiscase(const int & test)
{
cin>>n;
cout<<n+(n*n)+(n*n*n);









return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE 
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout); 
    // freopen("error.txt", "w", stderr); 
    // #endif 
    clock_t start, end;
    start = clock(); 
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    solveforthiscase(i);
    end = clock(); 
    long double t_t = (long double)(end - start) /(long double)(CLOCKS_PER_SEC); 
    cerr << (long double)t_t*1000<< " ms ";
}


Measured memory_bytes: 3824
#include <iostream>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
typedef long long ll;
ll pow(ll a)
{
    return a*a*a*a*a;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x,a,b;
    int flag=0;
    cin>>x;
    For(i,-200,200)
    {
        For(j,-200,200)
        {
            if(pow((ll)i)-pow((ll)j)==x)
            {
                flag=1;
                cout<<i<<' '<<j<<endl;
            }
        }
        if(flag)break;
    }
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int k = stdIn.nextInt(); //お菓子の個数
		boolean[] flag = new boolean[n];
		
		for(int i = 0; i < k; i++) {
			int d = stdIn.nextInt();
			
			for(int j = 0; j < d; j++) {
				int a = stdIn.nextInt();
				if(flag[a-1]==false) {
					flag[a-1] = true;
				}
			}
			
			
		}
		
		long cnt = 0;
		for(int i = 0; i < n; i++) {
			if(flag[i]==false) {
				cnt++;
			}
		}
		System.out.println(cnt);
		
	}

}


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

int N,K,H[100010],dp[200010] = {0};

int main(){
	cin >> N >> K;
	for(int i=1;i<=N;i++){
		cin >> H[i];
		dp[i] = 2e9;
	}
	dp[1] = 0;
	for(int i=1;i<N;i++){
		for(int j=1;j<=K;j++){
			dp[i+j] = min(dp[i+j],dp[i]+abs(H[i]-H[i+j]));
		}
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            int k = NextInt, a = NextInt, b = NextInt;
            for (int i = a; i <= b; i++)
            {
                if (i % k == 0)
                {
                    System.Console.WriteLine("OK");
                    return;
                }
            }

            System.Console.WriteLine("NG");
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 27884
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; vl ai(n); ll count = 0; vl bi(n);
  rep(i,n){ ll x,y; cin >> x >> y; ai[i] = x; bi[i] = y; }
  
  for(ll i=n-1; i >= 0; i--){
    if((ai[i] + count - bi[i]) % bi[i] == 0) continue;
    else count += bi[i] - ((ai[i] + count) % bi[i]);
  }
  
  cout << count << endl;
}

Measured memory_bytes: 1792
from heapq import heappush, heappop

n = int(input())

tasks = []

for _ in range(n):
  time, delivery = map(int, input().split())
  heappush(tasks, (delivery, time))

now = 0

for _ in range(n):
  delivery, time = heappop(tasks)
  now += time
  if now > delivery:
    print("No")
    break
else:
  print("Yes")
  

Measured memory_bytes: 73972
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;char ch[300005];
	scanf("%d",&n);
	scanf("%s",ch);
	int p=0,w=0,e=0,ans=300005;
	for(int i=0;i<n;i++)
		if(ch[i]=='E')e++;
	for(int i=0;i<n;i++)
	{
		if(ch[i]=='E')e--;
		ans=min(ans,w+e);
		if(ch[i]=='W')w++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=1000;

int main(){
    
    int x,y,z,k;
    ll a[maxn],b[maxn],c[maxn];
    vector<ll> ABcake;
    vector<ll> ABCcake;
    
    cin >> x>>y>>z>>k;
    
    rep(i,x){
        cin >>a[i];
    }
    rep(i,y){
        cin >>b[i];
    }
    rep(i,z){
        cin >>c[i];
    }
    
    sort(c,c+z);
    
    rep(i,x){
        rep(j,y){
            ABcake.push_back(a[i]+b[j]);
        }
    }
    
    sort(all(ABcake));
    
    for(int i=1;i<=min(k,x*y);i++){
        for(int j=1;j<=min(k,z);j++){
            ABCcake.push_back(ABcake[x*y-i]+c[z-j]);
        }
    }
    
    sort(all(ABCcake));
    
    for(int i=1;i<=k;i++){
        cout << ABCcake[(int)ABCcake.size()-i]<<endl;
    }
    
    return 0;
}


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

int main(){
  int n,sum=0;cin>>n;
  vector<int> x(n,0);
  REP(i,n){
    cin>>x.at(i);
    sum+=x.at(i);
  }
  sort(x.begin(),x.end(),greater<int>());
  cout<<(x.at(0)<sum-x.at(0)?"Yes":"No");
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

bool ok(ll N, vi &A, ll k) {
  multiset<ll, greater<ll>> s;
  for (ll i = 0; i < k; i++) s.insert(-1);
  for (ll i = 0; i < N; i++) {
    if (s.upper_bound(A[i]) == s.end()) {
      return false;
    }
    auto j = s.upper_bound(A[i]);
    s.erase(j);
    s.insert(A[i]);
  }
  return true;
}

int main() {
  ll N;
  cin >> N;
  vi A(N);
  for (ll i = 0; i < N; i++) cin >> A[i];

  ll l = 0, r = N;
  while (r - l > 1) {
    ll k = (r + l) / 2;

    if (ok(N, A, k)) {
      r = k;
    } else {
      l = k;
    }
  }

  cout << r << endl;
}


Measured memory_bytes: 7168
#include <stdio.h>
 
int main(void)
{
    int S;
    scanf("%d", &S);
 
    int sec = S % 60;
    int min = ((S - sec) % 3600) / 60;
    int hour = (S - sec - min * 60) / 3600;
    printf("%d:%d:%d\n", hour, min, sec);
 
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

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


int N;
vector<int> a;
vector<pair<int,int>> syusseki;
int main() {
    cin >> N;
    syusseki.resize(N);
    rep(i,N) {
        int temp; cin >> temp;
        syusseki[i] = make_pair(temp, i);
    }
    sort(syusseki.begin(), syusseki.end());
    rep(i,N) cout << syusseki[i].second + 1 << endl;
    return 0;
}

Measured memory_bytes: 1664
def main():
  import sys
  from numpy import int32
  from scipy.sparse import csr_matrix
  from scipy.sparse.csgraph import floyd_warshall
  t=int32(sys.stdin.buffer.read().split())
  n,m,l=t[:3]
  t=t[3:]
  m*=3
  print('\n'.join(map(str,map(int,floyd_warshall(floyd_warshall(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1))))
main()

Measured memory_bytes: 30792
n,w=list(map(int,input().split()))
gds=[list(map(int,input().split())) for _ in range(n)]

dp={0:0}

for cw,cv in gds:
    tmp={}

    for key,value in dp.items():
        if key in tmp:
            tmp[key]=max(tmp[key],value)
        else:
            tmp[key]=value
        
        if cw+key<=w:
            if cw+key in tmp:
                tmp[cw+key]=max(tmp[cw+key],value+cv)
            else:
                tmp[cw+key]=value+cv
    
    dp=tmp

print(max(dp.values()))


Measured memory_bytes: 73952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

//grid
int h, w;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int ddx[8] = {1,1,0,-1,-1,-1,0,1,};
int ddy[8] = {0,1,1,1,0,-1,-1,-1};
inline bool inside(int x, int y) {return x >= 0 and x < h and y >= 0 and y < w;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    char maze[n][n];
    bool out = true;
    REP(i,n) REP(j,n){
        cin >> maze[i][j];
        if(maze[i][j] == '#') out = false;
    }
    if(out) err();
    V<bool> tate(n, false);
    REP(j,n) REP(i,n) if(maze[i][j] == '#') tate[j] = true;
    int allblack = 0;
    int allblack_tate = 0;
    REP(j,n){
        bool flg = true;
        REP(i,n) if(maze[i][j] == '.') flg = false;
        if(flg) allblack_tate++;
    }
    ll hoge = 1e7;
    REP(i,n){
        ll cou = 0;
        REP(j,n) if(maze[i][j] == '.') cou++;
        if(cou == 0) allblack++;
        else chmin(hoge, cou + (tate[i] ? 0 : 1));
    }
    if(allblack) cout << n - allblack_tate  << endl;
    else cout << n  + hoge - allblack_tate << endl;
}

Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
int  main (){
  string a[105][105];
  int n,l;
  cin>>n>>l;
  for(int i=0;i<n;i++){
    cin>>a[0][i];
  }
  sort(a[0],a[0]+n);
  for(int i=0;i<n;i++){
    cout<<a[0][i];
  }
  cout<<"\n";
  return(0);
}

  


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> vectorV;
  for (int i = 0;i < n;i++) {
    int v;
    scanf("%d", &v);
    vectorV.push_back(v);
  }

  std::sort(vectorV.begin(), vectorV.end());
  float sumValue = 0;
  sumValue = (vectorV[0] + vectorV[1]) / (float)2;
  for(int i = 2; i < (int)vectorV.size(); ++i) {
    sumValue += vectorV[i];
    sumValue /= (float)2;
  }
  cout << sumValue << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1000000007;

int main(){
	int N;
	cin >> N;
	ll ans = 1;
	for (int i = 1; i < N+1; i++){
		ans = (ans*i)%MOD;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin >> N;
  cin >> A;
  int u = N % 500;
  if (u <= A){
  	cout << "Yes" << endl;
  } else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256