akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)

const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b;
}

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

int main(){
    int N,M,X,Y;
    int x[101]={0};
    int y[101]={0};
    cin >> N >> M >> X >> Y;
    for(int i=1;i<N+1;i++){
        cin >> x[i];
    }
    for(int i=1;i<M+1;i++){
        cin >> y[i];
    }
    x[0] = X;
    y[0] = Y;
    for(int i=0;i<N+1;i++){
        for(int j=0;j<M+1;j++){
            if(x[i]>=y[j]){
                cout << "War" << '\n';
                return 0;
            }
        }
    }
    cout << "No War" << '\n';    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string n;
cin>>n;
rep(i,3){
    if(n[i]=='1')n[i]='9';
    else if(n[i]=='9')n[i]='1';
}
cout<<n<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 110;
const int MAXM = 30*30*16*16+10;
const int MAXK = 30;
const i64 INF = 1000000000000000000LL;
//const int INF = 1000000000;
//const int MOD = 998244353;
//const int MOD = 1000000007;
//const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

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

int n, k;
char s[MAXN];

struct matrix
{
	ll v[2][2];
	matrix ()
	{
		v[0][0] = v[1][1] = 0;
		v[0][1] = v[1][0] = INF;
	}
}A, B, C, X, Y;

matrix operator * (const matrix &A, const matrix &B)
{
	matrix C;
	for (int i = 0; i < 2; ++ i)
		for (int j = 0; j < 2; ++ j)
		{
			C.v[i][j] = INF;
			for (int k = 0; k < 2; ++ k)
				C.v[i][j] = min(C.v[i][j], A.v[i][k]+B.v[k][j]);
		}
	return C;
}

matrix power(const matrix &A, ll b)
{
	matrix C;
	if (b == 0)
	{
		return C;
	}
	C = power(A, b/2);
	C = C*C;
	if (b%2) C = C*A;
	return C;
}

void solve()
{
	cin >> s+1 >> k;
	n = strlen(s+1);
	A.v[0][0] = INF; A.v[0][1] = 0;
	A.v[1][0] = 1; A.v[1][1] = 1;
	B.v[0][0] = 0; B.v[0][1] = 0;
	B.v[1][0] = 1; B.v[1][1] = 1;
	for (int i = 1; i <= n; ++ i)
	{
		int cur = s[i];
		int pre = i == 1 ? s[n] : s[i-1];
		if (cur == pre)
			C = A*C;
		else
			C = B*C;
		pre = s[i-1];
		if (cur == pre)
			X = A*X;
		else
			X = B*X;
	}
	Y = power(C, k-1);
	X = Y*X;
	ll ans = min({X.v[0][0], X.v[0][1], X.v[1][0], X.v[1][1]});
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int n;
	int s=0,m;
	cin>>n>>m;
	v vec(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>vec[i];
		s+=vec[i];
	}
	//debug(s);
	int mini=s/(4*m)+((s%(4*m))?1:0);
	int ans=0;
	//debug(mini);
	for (int i = 0; i < n; ++i)
	{
		int val=vec[i];
		if(val>=mini)ans++;
	}
	//debug(ans);
	if(ans>=m)cout<<"Yes";
	else cout<<"No";
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
from math import ceil
A,B,C,D,E,F = map(int,input().split())
am,bm,cm,dm=ceil(31/A),ceil(31/B),ceil(F*E/(100+E)/C)+1,ceil(F*E/(100+E)/D)+1
temp = []
for a in range(am):
    for b in range(bm):
        for c in range(cm):
            for d in range(dm):
                w = 100*a*A+100*b*B
                s = c*C+d*D
                if w + s > F:
                    break
                else:
                    if w / 100 * E >= s:
                        temp.append([w+s,s])
print(*sorted(temp, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

Measured memory_bytes: 138424
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
	//作るときはParentの値を全て-1にする
	//こうするとすべてバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}
	//AとBをくっつける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついているからくっつけない
			return false;
		}
		//大きい方(A)に小さいほう(B)をくっつけたい
		//大小が逆だったらひっくり返しちゃう
		if (size(A) < size(B)) swap(A, B);
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
	//AとBが同じグループにいるか
	bool same(int A, int B) { return root(A) == root(B); }
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> x(m), y(m), z(m);
	rep(i, m) cin >> x[i] >> y[i] >> z[i];
	UnionFind Uni(n + 1);
	rep(i, m) {
		x[i]--; y[i]--;
		Uni.connect(x[i], y[i]);
	}
	set<int> st;
	rep(i, n) {
		int a = Uni.root(i);
		st.insert(a);
	}
	dunk(st.size());
	return 0;
}


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

const int N = 100;
const int E = 8;
const int INF = 1 << 29;

struct data{
  int n,ebit,r,c;
};

struct event{
  int a,b,c;
};

int n,m,e,s,t,r;
vector<int> ev[N];
vector<int> G[N];
event v[E];
  int d[N][N][1<<E];

int dijk(){
  queue<data> Q;
  data u,u2;

  for(int i=0;i<N;i++) for(int j=0;j<N;j++) for(int k=0;k<(1<<E);k++) d[i][j][k] = INF;
  d[s][0][0] = 0;
  u = (data){s,0,0,0};
  for(int i=0;i<ev[s].size();i++){
    u.ebit |= 1 << ev[s][i];
  }
  
  for(Q.push(u); !Q.empty();){
    u = Q.front();
    Q.pop();

    if(u.n == t) return u.c;
    if(u.r >= r) {
      u2 = (data){s, u.ebit, 0, u.c+1};
      if(d[u2.n][u2.r][u2.ebit] > u2.c){
        d[u2.n][u2.r][u2.ebit] = u2.c;
        Q.push(u2);
      }
      continue;
    }
    
    for(int i=0;i<G[u.n].size();i++){
      u2 = (data){G[u.n][i], u.ebit, u.r+1, u.c+1};
      for(int j=0;j<ev[u2.n].size();j++){
        u2.ebit |= 1 << ev[u2.n][j];
      }
      if(d[u2.n][u2.r][u2.ebit] > u2.c){
        d[u2.n][u2.r][u2.ebit] = u2.c;
        Q.push(u2);
      }
    }

    for(int i=0;i<e;i++){
      if((u.ebit & (1 << i)) == 0 || v[i].a != u.n && v[i].b != u.n) continue;
      u2 = (data){v[i].a, u.ebit, u.r+1, u.c+1};
      if(u.n == v[i].a) u2.n = v[i].b;
      for(int j=0;j<ev[u2.n].size();j++){
        u2.ebit |= 1 << ev[u2.n][j];
      }
      if(d[u2.n][u2.r][u2.ebit] > u2.c){
        d[u2.n][u2.r][u2.ebit] = u2.c;
        Q.push(u2);
      }
    }

    u2 = (data){s, u.ebit, 0, u.c+1};
    if(d[u2.n][u2.r][u2.ebit] > u2.c){
      d[u2.n][u2.r][u2.ebit] = u2.c;
      Q.push(u2);
    }
  }

  return -1;
}

void solve(){
  cout << dijk() << endl;
}

int main(){
  while(cin >> n >> m >> e >> s >> t >> r){
    for(int i=0;i<n;i++) G[i].clear(), ev[i].clear();

    for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    for(int i=0;i<e;i++){
      cin >> v[i].a >> v[i].b >> v[i].c;
      ev[v[i].c].push_back(i);
    }
    solve();
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	int k;
	cin >> s >> k;

	int n = s.size();
	int now = 0;
	while (k != 0) {
		if (now == n - 1) {
			int addCnt = k % 26;
			for (int i = 0; i < addCnt; i++) {
				s[now] = s[now] == 'z' ? 'a' : s[now] + 1;
			}
			break;
		}

		if (s[now] == 'a') {
			now++;
			continue;
		}

		int alphabetNum = s[now] - 'a';
		int turn = 26 - alphabetNum;
		if (turn <= k) {
			s[now] = 'a';
			k -= turn;
		}

		now++;
	}

	cout << s << endl;
	return 0;
}


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

using ll = long long;

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

	if (x % y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp1 = [[0] * (m + 1) for _ in range(n + 1)] # ends with (i, j)
dp2 = [[0] * (m + 1) for _ in range(n + 1)] # cumsum

dp1[0][0] = 1
for i in range(n + 1):
    dp2[i][0] = 1
for j in range(m + 1):
    dp2[0][j] = 1

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp1[i+1][j+1] = dp2[i][j]
        else:
            dp1[i+1][j+1] = 0
        dp2[i+1][j+1] = (dp1[i+1][j+1] + dp2[i][j+1] + dp2[i+1][j] - dp2[i][j]) % (10 ** 9 + 7)


print(dp2[-1][-1])


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

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define fill(a,v)  memset(a, v, sizeof (a))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

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

const int N=501000;
const int MOD = 1e9 + 7 ;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
	faster;

    int n, arr[50], res = 0;

    cin >> n;
    for(int i = 0; i < n; ++i)	cin >> arr[i];

    for(int i = 0; i < n; ++i)
    	for(int j = i+1; j < n; ++j)
    		res += arr[i]*arr[j];

    cout << res;
	return 0;
}

// READ
// THINK
// CODE 
// DEBUG 
// AC	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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 init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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

int main() {
	init();

	int N; cin >> N;
	vector<ll>vec(N);
	rep(i, 0, N)cin >> vec[i];
	int ans = vec[0];
	rep(i, 0, N) {
		ans = gcd(ans, vec[i]);
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
#define ll long long

using namespace std;


#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

const ll inf =1000000007;
typedef pair<ll,ll> Pair;


typedef vector<ll> vl;

void asolve(){
    rep(i,5){
        ll a;
        cin >>a;
        if(a==0){
            kaku(i+1);
        }
    }

}

void bsolve(){
    ll x,y;
    cin >> x >>y;
    if(y%2==0 && y<=4*x && y>=2*x){
        cout <<"Yes"<< endl;
    }
    else {
        cout <<"No" << endl;
    }

}

void csolve(){

}

void dsolve(){

}

int main(){
    bsolve();
}

Measured memory_bytes: 3648
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main(){
    int a;
    cin >> a;
    int buf = max(1,(int)floor(sqrt(a*2))-10);
    int smallest = 0;
    while(true){
        if((buf * (buf + 1)) / 2 >= a){
            smallest = buf;
            break;
        }
        buf++;
    }
    cout << smallest << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a[101];int n,i;
int main(){
    scanf("%d%*d",&n);
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++) cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
#define For(i,a,b) for(i=(a),i<=(b);++i)
#define Forward(i,a,b) for(i=(a),i>=(b);--i)
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
template<typename T>inline void read(T &x)
{
	T f=1;x=0;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+(c^48);
	x*=f;
}
using namespace std;
const int MAXN=1010;
static int n,k;
inline void init()
{
	read(n);read(k);
}
static long long ans;
inline void solve()
{
	ans=1ll*(n-k)*(n-k+1)/2;
	static int las;
	Rep(l,k,n-1)for(register int i=l+1;i<=n-l;i=las+1)
	{
		las=(n-l)/((n-l)/i);
		ans+=(n-l)/i*(las-i+1);
	}
	if(k==0)cout<<1ll*n*n<<endl;
	else cout<<ans<<endl;
}
int main()
{
	init();
	solve();
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

int32_t main(){fast ;
	int n , m ;
	cin >> n >> m ;
	vector<pii> v(n) ;
	
	for(int i = 0 ; i < n ; i++)
		cin >> v[i].ff >> v[i].ss ;
		
	sort(all(v)) ;
	int ans = 0 ;
	for(int i = 0 ; i < n ; i++){
		if(m - v[i].ss >= 0){
			ans += v[i].ss * v[i].ff ;
			m -= v[i].ss ;
		}
		else{
			ans += m*v[i].ff ;
			break ;
		}
	}
		
	cout << ans << endl ;
}




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

typedef long long ll;

using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
string S[3];

int main(){
    fastStream();
    cin >> N;
    for(int i= 0; i< 3; i++)cin >> S[i];
    ll ans = 0;
    for(int i = 0; i < N; i++){
        set<char> st;
        for(int j = 0; j < 3; j++){
            st.insert(S[j][i]);
        }
        ans += (int)st.size() - 1;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    veci A(N),B(M);
    REP(i,N) cin >> A[i];
    REP(i,M) cin >> B[i];
    sort(A.begin(),A.end(),greater<int>());
    sort(B.begin(),B.end());
    for(int i = X+1; i <= Y; i++) {
        if(A[0] < i && i <= B[0]) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int N; cin>>N;
    vector<int> T(N);
    REP(i,N)cin>>T[i];
    
    int M; cin>>M;
    REP(i,M){
        int P,X; cin>>P>>X;
        P--;
        int ans=0;
        REP(j,N){
            if(j==P){
                ans+=X;
            }else{
                ans+=T[j];
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
def solve():
    R, G, B, N = map(int, input().split())
    LIM = 3001
    ans = 0
    for r in range(LIM):
        for g in range(LIM):
            if R * r + G * g > N:
                break
            Bb = N - R * r - G * g
            if Bb % B == 0:
                ans += 1
    return ans


print(solve())


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

#define ll             long long
#define gcd(a,b)       __gcd(a,b)
#define lcm(a,b)       a*(b/gcd(a,b))
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define mii            map<int, int>
#define mll            map<ll, ll>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define mt             make_tuple
#define lb             lower_bound
#define ub             upper_bound
#define ff             first
#define ss             second
#define all(v)         v.begin(),v.end()
#define fill(a,b)      memset(a,b,sizeof a)
#define smax(a, b)     a=max(a, b)
#define smin(a, b)     a=min(a, b)
#define sqr(x)         x*x
#define cube(x)        x*x*x
#define asort(a, n)    sort(a+1, a+n+1)
#define FOR(i, l, r)   for(int i=l;i<=r;i++)
#define ROF(i, l, r)   for(int i=r;i>=l;i--)
#define endl           '\n'

int in() {
    int n;
    scanf("%d",&n);
    return n;
}

ll Lin() {
    ll n;
    scanf("%lld",&n);
    return n;
}

double Din() {
    double n;
    scanf("%lf",&n);
    return n;
}

const double gama = 0.57721566490;
const double eps = 0.00000001;
const ll inf = 1e17;
const ll mod = 1e9 + 7;
const int N = 1e6 + 5;


vi p;

int main() {
    p.pb(1);
    for(int i=2; i<=1000; i++) {
        for(int j=i*i; j<=1000; j*=i)
            p.pb(j);
    }
    sort(all(p));
    int x=in();
    for(int i=(int)p.size()-1; i>=0; i--) {
        if(p[i]<=x)
            return !printf("%d\n", p[i]);
    }
    return 0;
}







Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

def solve(a, b, c):
    if (a,b,c) == (5,5,7) or (a,b,c) == (5,7,5) or (a,b,c) == (7,5,5):
        print('YES')
    else:
        print('NO')

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    a = int(ws[0])
    b = int(ws[1])
    c = int(ws[2])
    return (a, b, c,)

def main():
    solve(*readQuestion())

# Uncomment before submission
main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
string s;
string table[10] = { "", ".,!? ", "abc", "def",
"ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };

int main(){
	cin >> n;
	REP(i, n){
		cin >> s;
		string ans = "";
		REP(i, s.size()){
			int k = s[i] - '0';
			if (k != 0){
				int co = -1;
				while (s[i] != '0'){
					co++;
					i++;
					if (co > table[k].size() - 1)co = 0;
				}
				ans += table[k][co];
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

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

    int N;
    cin >> N;

    vector<int> B;
    B.reserve(N);

    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        auto it = upper_bound(B.begin(), B.end(), a, greater<>());
        if (it == B.end())
        {
            B.push_back(a);
        } else
        {
            *it = a;
        }
    }

    cout << B.size() << "\n";


}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000; // 2*(10^5)
vvec g(nmax);

vector<int> divisor(const int n){
  vector<int> ret;
  for(int i=1;i*i<=n;i++){
    if(n % i == 0){
      ret.push_back(i);
      if(i*i!= n) ret.push_back(n/i);
    }
  }
  sort(ret.begin(),ret.end());
  return ret;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;

    map<int,int> mp;
    mp[n]++;
    vec y=divisor(n-1);

    rep(i,y.size()){
        if(2<=y[i]){
            mp[y[i]]++;
            // if(mp[y[i]]==1) cout<<y[i]<<endl;
        }
    }
    
    int ans=0;
    for(int k=2;k*k<=n;k++){
        int nn=n;
        while(k<nn){
            if(nn%k==0) nn/=k;
            else if(nn%k==1) nn=1;
            else break;
        }
        if(nn%k==0) nn/=k;
        if(nn==1){
            mp[k]++;
            /// if(mp[k]==1) cout<<k<<endl;
        }
    }

    cout<<mp.size()<<endl;

}

Measured memory_bytes: 4992
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
/* inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} */
/* template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} */

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
    unsigned long long k;
    string S;
    cin >> S >> k;
    /* 
      if ( S.rfind('1') == string::npos ) {
          cout << S.at(0) << endl;
          return 0;
      }  
      unsigned long long i1 = S.rfind('1') + 1;
      if ( i1 >= k ) {
          cout << "1" << endl;
          return 0;
      }
      cout << S.at(i1) << endl;
     */
    int  i = 0;
    for(auto itr = S.begin(); itr != S.end(); ++itr){
        if( *itr != '1' || i==S.length()-1 ){
            cout << S[i] << endl;
            return 0;
        }else if( i+1 == k){
            cout << S[i] << endl;
            return 0;
        }else{
        i++;
        }
    }
}


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

const int N = 2e5 + 10, mod = 1e9 + 7;



int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        vector<int> h(2), s(2);
        scanf("%d%d%d%d", &h[0], &s[0], &h[1], &s[1]);
        bool st = 0;
        while(1) {
            h[1 - st] -= s[st];
            if(h[1 - st] <= 0) break;
            st = 1 - st;
        }
        if(!st) puts("Yes");
        else puts("No");
    }    
    return 0;
}

Measured memory_bytes: 3692
import java.util.Scanner;
import java.math.*;
import java.text.*;
public class Main {

	private static boolean[] isNotPrime = new boolean[10000000];

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		primeTable();
		while(input.hasNextInt()){
			int n = input.nextInt();
			if(n<2){
				System.out.println(0);
				continue;
			}
			int cnt = 0;
			for(int i=2;i<=n;i++){
				if(!isNotPrime[i]) cnt++;
			}
			System.out.println(cnt);
		}
	}

	private static void primeTable() {
		for(int i=2;i*i<10000000;i++){
			if(!isNotPrime[i]){
				for(int j=2*i; j<10000000;j+=i){
					isNotPrime[j] = true;
				}
			}
		}
	}

}

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

ll n;
string ans;

int main() {
  cin >> n;
  while (n > 0) {
    ans += 'a' + (n-1) % 26;
    n--;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int N=10000;
const long INF=1000000000;

int main(){
	int n;
	vector<pair<int,long> > adj[N]; //????????????????????°???????????£??\???????????¨???
	
	//??\???
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		int u, k;
		scanf(" %d %d", &u, &k);
		
		for(int j=0; j<k; ++j){
			int v;
			long c;
			scanf(" %d %ld", &v, &c);
			adj[u].push_back(make_pair(v,c)); //v??¨??£??\????????????????????¨??????????????????c
		} 	
	}
		
	//PriorityQueue?????¨??????Dijkstra???
	priority_queue<pair<long,int> > pq;
	
	int visit[N]={0};
	
	long cost[N];
	for(int i=0; i<N; ++i) cost[i]=INF;
	cost[0]=0; //?§?????????????????????§?§??????????	
	pq.push(make_pair(0, 0));
	visit[0]=-1; //?¨??????????
	
	while(!pq.empty()){
		pair<long,int> p=pq.top(); //pq??????????????§cost???????°?????????????????????????
		pq.pop();
		
		long u=p.second;
		visit[u]=-1; //????????????????¨???????????????????
		
		//????°??????¨???????????????????????§???????????°??????
		if(cost[u] < p.first*(-1)) continue;	
		
		//??£??\???????????????????????????
		for(int j=0; j<adj[u].size(); ++j){
			long v=adj[u][j].first; //u?????£??\????????????
			if(visit[v]==-1) continue;
			
			if(cost[v] > cost[u]+adj[u][j].second){
				cost[v] = cost[u]+adj[u][j].second;
				pq.push(make_pair(cost[v]*(-1), v));
				visit[v]=1;
			}
		}
		
	}
	
	for(int i=0; i<n; ++i)
		printf("%d %ld\n", i, (cost[i]==INF ? -1 : cost[i]));
}

Measured memory_bytes: 10508
#include<iostream>
#include<string>
#include <cstdio>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n;

int main(void) {
	cin >> n;
	int sum = 0;
	int pmax = 0;
	for (int i = 0; i < n; i++) {
		int pi;
		cin >> pi;
		sum += pi;
		if (pi > pmax)
			pmax = pi;
	}
	cout << sum - pmax / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		DateTime st=DateTime.Now;
		int[][] h=new int[n+1][];
		int[] d=new int[n+1];
		int[] b=new int[n+1];
		for(int i = 1;i<=n;i++) {
			h[i]=sc.Ia;
		}
		int p=1,c=0;
		bool bo=true;
		while(bo){
			bo=false;
			for(int i = 1;i<=n;i++) {
				if(d[i]==n-1||b[i]==p){continue;}
				if(i==h[h[i][d[i]]][d[h[i][d[i]]]]&&b[h[i][d[i]]]!=p){
					int v=h[i][d[i]];
					b[v]=p;
					d[i]++;
					d[v]++;
					if(d[i]==n-1){c++;}
					if(d[v]==n-1){c++;}
					bo=true;
				}
				b[i]=p;
			}
			if(c==n){break;}
			p++;
			if(!bo){p=-1;break;}
			if((DateTime.Now-st).TotalMilliseconds>1900){p=n*(n-1)/2;break;}
		}
		Console.WriteLine("{0}",p);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 43436
#include <iostream>
#include<vector>
#include<array>
#include<cmath>
#include <algorithm>

using namespace std;
#define ull unsigned long long

int main() {
	// 初期処理(iostream軽くする)
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	ull n;
	cin >> n;
	vector<ull> v;

	for (ull i = 0; i < n; i++) {
		if (((i+1) % 3 == 0)||((i+1)%5==0)) {
			v.push_back(0);
		}else {
			v.push_back(i+1);
		}
	}
	ull sum = 0;
	for (ull i = 0; i < n; i++) {
		sum += v[i];
	}
	cout << sum;
	return 0;
}

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

int main() {
    int A,A2,B,C,D,E;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cin >> E;

    if (A == 0) cout << D+B*E << endl;
    else if (A > 0) cout << (B-A)*E << endl;
    else {
        A2 = -1 * A;
        cout << A2 * C + D + B * E << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
a, b = map(int, input().split())
if a == b == 1:
    print("Draw")
elif a == 1:
    print("Alice")
elif b == 1:
    print("Bob")
else:
    if a > b:
        print("Alice")
    elif a < b:
        print("Bob")
    else:
        print("Draw")


Measured memory_bytes: 2940
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vector<pair<int,int>> P;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        P.emplace_back(x, y);
    }

    long long res = 0;
    const long long INF = 1LL << 40;
    vector<long long> maxs(4, -INF);
    vector<long long> mins(4, INF);
    for (int i = 0; i < n; ++i) {
        int x = P[i].first, y = P[i].second;
        for (int j = 0; j < 4; ++j) {
            long long val = 0;
            if (j & 1) {
                val += x;
            } else {
                val -= 1;
            }
            if (j & 2) {
                val += y;
            } else {
                val -= y;
            }
            maxs[j] = max(maxs[j], val);
            mins[j] = min(mins[j], val);
        }
    }
    for (int i = 0; i < 4; ++i) {
        res = max(res, maxs[i] - mins[i]);
    }
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 5260
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define pb push_back
#define arrinp(v) for(auto &i:v) cin>>i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
using namespace std;
const int mod=1e9+7;
int power(int x, int y) 
{ 
    int res = 1;     // Initialize result 
    for(int i=0;i<y;i++){
    	res=res*x%mod;
    }
    return res; 
}
signed 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);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        int n;
        cin>>n;
        int a[n],b[n];
        map<int,int> ma,mb;
        for(int i=0;i<n;i++){
        	cin>>a[i];
        	ma[a[i]]++;
        }
        for(int i=0;i<n;i++){
        	cin>>b[i];
        	mb[b[i]]++;
        }
        for(auto i:ma){
        	if(ma[i.first]+mb[i.first]>n){
        		cout<<"No"<<endl;
        		return 0;
        	}
        }
        sort(b,b+n,greater<int>());
        for(int i=0;i<n;i++){
        	if(a[i]!=b[i]){
        		continue;
        	}
        	for(int j=0;j<n;j++){
        		if(i!=j and a[i]!=b[j] and a[j]!=b[i]){
        			swap(b[i],b[j]);
        			break;
        		}
        	}
        }
        cout<<"Yes"<<endl;
        for(int i=0;i<n;i++){
        	cout<<b[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

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

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

typedef long long ll;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int ans = 1;
    if(n==1){
        cout << m << endl;
        return 0;
    }
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            if(i<=m/n){
                ans = max(i,ans);
            }
            if(m/i<=m/n){
                ans = max(m/i,ans);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = input()
n = n[::-1] + '0'
inf = 10 ** 9
dp = [[inf for _ in range(2)] for _ in range(len(n) + 1)]
dp[0][0] = 0
dp[0][1] = 2
for i in range(len(n)):
        n_i = int(n[i])
        dp[i + 1][0] = min(dp[i][0] + n_i, dp[i][1] + n_i)
        dp[i + 1][1] = min(dp[i][0] + 11 - n_i, dp[i][1] + 9 - n_i)
print(min(dp[-1][0], dp[-1][1]))

Measured memory_bytes: 178140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
 
vector<int> s[2];
vector<ull> u[2];
 
const int N = 500;
int n;
int val[2][N];
int d[N][N];
 
void flip() {
  rep(i,n)rep(j,i) {
    swap(d[i][j], d[j][i]);
  }
}
bool solve() {
  rep(i,n)rep(j,n) d[i][j] = -1;
  rep(k,2) {
    rep(i,n) {
      int x = val[k][i];
      if (s[k][i] != x) {
        rep(j,n) {
          if (d[i][j] == !x) return false;
          d[i][j] = x;
        }
      }
    }
    flip();
  }
  rep(_,2) {
    rep(k,2) {
      rep(i,n) {
        int x = val[k][i];
        if (s[k][i] == x) {
          vector<int> p;
          bool ok = false;
          rep(j,n) {
            if (d[i][j] == -1) p.push_back(j);
            if (d[i][j] == x) ok = true;
          }
          if (ok) continue;
          if (p.size() == 0) return false;
          if (p.size() == 1) {
            d[i][p[0]] = x;
          }
        }
      }
      flip();
    }
  }
 
  vector<int> is, js;
  rep(i,n) {
    bool filled = true;
    rep(j,n) if (d[i][j] == -1) filled = false;
    if (!filled) is.push_back(i);
  }
  rep(j,n) {
    bool filled = true;
    rep(i,n) if (d[i][j] == -1) filled = false;
    if (!filled) js.push_back(j);
  }
  rep(i,is.size())rep(j,js.size()) {
    d[is[i]][js[j]] = (i+j)%2;
  }
  return true;
}
 
ull ans[N][N];
 
int main() {
  cin >> n;
  rep(i,2) {
    s[i] = vector<int>(n);
    rep(j,n) cin >> s[i][j];
  }
  rep(i,2) {
    u[i] = vector<ull>(n);
    rep(j,n) cin >> u[i][j];
  }
 
  rep(b,64) {
    rep(i,2)rep(j,n) val[i][j] = u[i][j]>>b&1;
    if (!solve()) {
      cout << "-1" << endl;
      return 0;
    }
    rep(i,n)rep(j,n) ans[i][j] |= ull(d[i][j])<<b;
  }
  rep(i,n) {
    rep(j,n) {
      cout<<ans[i][j]<<(j==n-1?'\n':' ');
    }
  }
  return 0;
}

Measured memory_bytes: 8408
#include <stdio.h>
#define MAXN 200000
#define MAXM 200000

int main()
{
    int N, M;
    int island_from_1[MAXN] = {0};
    int island_to_N[MAXN] = {0};
    scanf("%d%d", &N, &M);
    for (int i = 0; i < M; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        if (a == 1) island_from_1[b-1] = 1;
        if (b == N) island_to_N[a-1] = 1;
    }
    for (int i = 0; i < N; i++)
        if (island_from_1[i] && island_to_N[i]) {
            puts("POSSIBLE");
            return 0;
        }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

int main(void){
  LL n;
  cin >> n;
  vector<int> a(n);
  repl(i, n) cin >> a[i];
  LL m = 0;
  vector<int> b(n);
  vector<int> b_ind(n);

  for (LL i = n-1; 0 <= i; i--) {
    if (n / 2 < i+1) {
      if (a[i] == 1) {
        b_ind[m] = i+1;
        m ++;
      }
      b[i] = a[i];
    } else {
      int sum = 0;
      for (LL j = 2; j <= n / (i + 1); j ++) {
        sum += b[(i + 1) * j - 1];
      }
      if ((sum % 2) == a[i]) b[i] = 0;
      else {
        b_ind[m] = i+1;
        m ++;
        b[i] = 1;
      }
    }
  }

  cout << m << endl;
  for (int i = m-1; 0 <= i; i--) cout << b_ind[i] << ' ';

  cout << endl;


  return 0;
}

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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            if (input[0] == input[1])
            {
                if (input[1]==input[2])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef pair <ll ,ll> pll;
typedef pair <int ,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define print(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 3e5;
const double PI = 3.141592653589 , eps = 1e-9;

int n , ans;
vector <int> x , y;
map <pii , int> id;
vector <bool> was;

int dfs(int i , int p , int q){
    int cur_id = id[{x[i] - p , y[i] - q}] - 1;
    was[i] = true;
    if (cur_id == -1) return 1;
    if (was[cur_id]) return 0;
    return dfs(cur_id , p , q);
}

void solve(int p , int q){
    if (p == 0 && q == 0) return;
    was.assign(n , false);
    int cur = 0;
    for (int i = 0; i < n; i++){
        if (was[i]) continue;
        cur += dfs(i , p , q);
    }
    ans = min(ans , cur);
}

void solve(){
    cin >> n;
    ans = n;
    x.resize(n);
    y.resize(n);
    for (int i = 0; i < n; i ++){
        cin >> x[i] >> y[i];
        id[{x[i] , y[i]}] = i + 1;
    }

    for (int i = 0; i < n; i ++){
        for (int j = 0; j < n; j ++){
            solve(x[i] - x[j] , y[i] - y[j]);
        }
    }
    cout << ans;
}


int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    #endif

    for (int t = 1; t--;) solve();

    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


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

int main(){
    int n ,t,a;
    cin >> n;
    cin >> t >> a;
    vector<P> p(n);
    rep(i,n) {
        p[i].first = i+1;
        cin >> p[i].second;
    }
    double mn = 1000000000;
    int ans;
    rep(i,n){
        double temp = t - 0.006 * p[i].second;
        if (abs(a - temp) < mn){
            ans = p[i].first;
            mn = abs(a - temp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M, X, Y =map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(j) for j in input().split()]
x.sort()
y.sort()
if (x[N-1]<Y) and (x[N-1]<y[0]) and (X<y[0]):
  print('No War')
else:
  print('War')

Measured memory_bytes: 3060