akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	while(k--){
		if(b<=a){
			b=b*2;
		}
		else if(c<=b){
			c=c*2;
		}
	}
	if(c>b && b>a){
		printf("Yes\n");
	}
	else printf("No\n");
} 

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#define pp push_back
using namespace std;
vector<char> key[10];

void Init(){
  key[0].pp(' ');
  key[1].pp('\'');key[1].pp(',');key[1].pp('.');key[1].pp('!');key[1].pp('?');
  int index =2,counter=0;
  for(int i=0;i<26;i++){
    key[index].pp((char)('a'+i));
    counter++;
    if(((index == 7||index == 9)&&counter%4==0)|| (!(index==7||index==9)&&counter%3 == 0)){
      counter = 0;
      index++;
    }
  }
  counter = 0;index =2;
  for(int i=0;i<26;i++){
    key[index].pp((char)('A'+i));
    counter++;
    if(((index == 7||index == 9)&&counter%4==0)|| (!(index==7||index==9)&&counter%3 == 0)){
      counter = 0;
      index++;
    }
  }
}

int main(){
  string s;
  Init();
  /*
  for(int i=1;i<=9;i++){
    cout << i << "-th ";
    for(int j=0;j<key[i].size();j++){
      cout << key[i][j] << " ";
    }
    cout << endl;
  }
  */
  int st,cnt,div;
  while(cin >> s){
    st = cnt = 0;
    for(int i=0;i<s.length();i++){
      if(s[st] != s[i+1] || i == s.length()-1){
	if(s[st] == '0'){
	  if(cnt == 0){
	    st = i+1;
	  }else{
	    for(int j=0;j<cnt;j++){
	      cout << ' ';
	    }
	    st = i+1;
	  }
	  cnt = 0;
	}
	else{
	  if(s[st] == '7' || s[st] == '9')div = 8;
	  else if(s[st] == '1')div = 5;
	  else div = 6;
	  
	  
	  cout << key[(int)(s[st]-'0')][cnt%div];
	}
	st = i+1;
	cnt = 0;
      }
      else{
	cnt++;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
five_hund = int(input())
hund = int(input())
fifty = int(input())
total = int(input())

ptn = 0

for i in range(0, five_hund+1):
  for j in range(0, hund+1):
    for k in range(0, fifty+1):
      if total == i * 500 + j * 100 + k * 50:
        ptn += 1
    
print(ptn)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true, flag = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };
string abc = "abcdefghijklmnopqrstuvwxyz";
ll nCr[51][51] = {0};

void comb_table(int N) {
	 for (int i = 0;i <= N;++i) {
		 for (int j = 0;j <= i;++j) {
			 if (j == 0 || j == i) {
				 nCr[i][j] = 1LL;
			}
			else {
				 nCr[i][j] = (nCr[i - 1][j - 1] + nCr[i - 1][j]);	
			}	
		}
	}
}

int main() {
	ll n, a, b;
	double ave = 0;
	ll ans = 0;
	cin >> n >> a >> b;
	vector<double>v(n);
	for (int i = 0;i < n;i++) {
		cin >> v[i];
	}
	sort(v.rbegin(), v.rend());
	for (int i = 0;i < a;i++)ave += v[i];
	ave /= a;
	comb_table(n);
	int count = 0, acount = 0;
	if (v[0] != v[a - 1]) {
		for (int j = 0;j < n;j++) {
			if (v[j] == v[a - 1]) {
				count++;
				if (j < a)acount++;
			}
		}
		ans += nCr[count][acount];
	}
	else {
		for (int i = a - 1;i < b;i++) {
			if (v[0] != v[i])fl = false;
			if (fl) {
				count = 0;
				for (int j = 0;j < n;j++) {
					if (v[0] == v[j])count++;
				}
				ans += nCr[count][i + 1];
				fl = true;
			}
		}
	}
	cout << setprecision(24) << ave << endl;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,m,a,i,r=0;
int main(){
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&a);
        r+=a;
    }
    if(n-r>=0)printf("%d",n-r);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 1736
H, W = map(int, input().split())
A = [input() for _ in range(H)]

h = {i: False for i in range(H)}
w = {i: False for i in range(W)}

for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            h[i] = True
            w[j] = True

for i in range(H):
    s = ""
    for j in range(W):
        if h[i] and w[j]:
            s += A[i][j]

    if s != "":
        print(s)

Measured memory_bytes: 9096
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

int a,b,c;
bool input(){
	cin>>a>>b>>c;
	if(c==0)return false;
	return true;
}

int calc(int zei, int val){
	return val*(zei+100)/100;
}
void solve(){
	
	int maxi = -1;
	reps(i,1,1001){
		reps(j,1,1001){
			int t1 = calc(a,j) + calc(a, i);
			int t2 = calc(b,j) + calc(b, i);
			
			if(t1==c)maxi=max(maxi,t2);
		}
	}
	cout<<maxi<<endl;
}

int main(){
	while(input())solve();
}

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

int gcd(int a,int b){
    return !b?a:gcd(b,a%b);
}

int main(){
   int n;
   scanf("%d",&n);
   int sum=0;
   for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
        for(int k=1;k<=n;k++){
            sum+=gcd(i,gcd(j,k));
        }
    }
   }
   printf("%d",sum);
   return 0;
}


Measured memory_bytes: 3832
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n, k, s;
vector<ll> ans;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>k>>s;
    for (int i = 0; i < k; i++)
    {
        ans.push_back(s);
    }
    if(s==1000000000){
        ll j=s-1;
        for(int i=k;i<n;i++){
            ans.push_back(j);
        }
    }
    else{
        ll j=1;
        for(int i=k;i<n;i++){
            ans.push_back(s+j);
        }
    }
    for(int i=0;i<n;i++)
    cout << ans[i] << "\n";
}



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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

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

	ll sum = 0;
	REP(i,m) {
		cin >> t;
		sum += t;
	}

	if(n-sum < 0) {
		cout << -1 << endl;
	} else {
		cout << n-sum << endl;
	}

}



Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int N,M;
long long cost[1000][1000];
int main(){
  cin>>N>>M;
  FOR(i,0,N){
    FOR(j,0,N){
      cost[i][j]=10e15;
    }
  }
  FOR(i,0,N){
    cost[i][i]=0;
  }
  FOR(i,0,M){
    int A,B,C;
    cin>>A>>B>>C;
    A--;
    B--;
    cost[A][B]=-C;
  }
  FOR(k,0,N){
    FOR(i,0,N){
      FOR(j,0,N){
        cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
      }
    }
  }
  if(cost[0][0]!=0){
    cout<<"inf"<<endl;
  }else{
    cout<<-cost[0][N-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 8064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin>>S;
    reverse(S.begin(),S.end());
    int a = S[0] - '0';
    if(a==3){
        cout<<"bon"<<endl;
    }
    else if( a == 0||a==1||a==6||a==8){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, q, time, cnt_time = 0;
    string name;
    queue<pair<string, int> > que;
    cin >> n >> q;
    REP(i, n) {
        cin >> name >> time;
        que.push(make_pair(name, time));
    }
    while (!que.empty()) {
        pair<string, int> top = que.front();
        que.pop();
        if (top.second <= q) {
            cnt_time += top.second;
            cout << top.first << " " << cnt_time << endl;
        } else {
            cnt_time += q;
            que.push(make_pair(top.first, top.second - q));
        }
    }
}


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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
const int N = 100005;
int x;
int main() {
    
    scanf("%d", &x);
    printf("%d\n", 360 / __gcd(360, x));
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 107;

int k;
int n;
bool bad[M];

void read() {
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    int x;
    cin >> x;
    bad[x] = true;
  }
}

bool good(int x) {
  if (x == 0)
    return !bad[0];

  while (x) {
    if (bad[x % 10])
      return false;
    x /= 10;
  }

  return true;
}



void kill() {
  while (!good(n))
    ++n;
  cout << n << endl;
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
int n,tot;
const int N=5010,mod=1e9+7;
int head[N],to[N<<1],nt[N<<1],siz[N],f[N],dp[N][N],t[N];
void add(int f,int t)
{
	to[++tot]=t;nt[tot]=head[f];head[f]=tot;
}
void dfs(int x,int fa)
{
	siz[x]=1;dp[x][1]=1;
	for(int i=head[x];i;i=nt[i])
		if(to[i]!=fa)
		{
			dfs(to[i],x);
			for(int j=0;j<=siz[x];++j)t[j]=dp[x][j],dp[x][j]=0;
			for(int j=0;j<=siz[x];++j)
				for(int k=0;k<=siz[to[i]];++k)
					dp[x][j+k]=((LL)dp[x][j+k]+(LL)t[j]*dp[to[i]][k])%mod;				
			siz[x]+=siz[to[i]];
		}
	for(int i=0;i<=siz[x];++i)
		dp[x][0]=((LL)dp[x][0]-(LL)dp[x][i]*f[i])%mod;
}
int main()
{
	cin>>n;
	for(int i=1,x,y;i<n;++i)
		scanf("%d%d",&x,&y),add(x,y),add(y,x);
	f[0]=1;
	for(int i=2;i<=n;i+=2)f[i]=(LL)f[i-2]*(i-1)%mod;
	dfs(1,0);
	cout<<(mod-dp[1][0])%mod;
	return 0;
}

Measured memory_bytes: 97280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, K, S);
  ll ans = 0;
  rep(i, 0, K + 1) {
    if (i > S) break;
    rep(j, 0, K + 1) {
      if (i + j > S) break;
      int k = S - (i + j);
      if (k > K) continue;
      if (i + j + k == S) {
        ans++;
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;
int a[300000];
bool vis[300000];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    FOR(i, 1, n+1){
        cin >> a[i];
        vis[i]=0;
    }
    int y=1;
    int cnt=0;
    while(vis[y]==0&&y!=2){
        vis[y]=1;
        cnt++;
        y=a[y];
    }
    if(vis[y]==1){
        cout << "-1" << endl;
    }else{
        cout << cnt << endl;
    }


}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
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();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#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(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    cin>>a;
    if(a%2==0){
        cout <<a/2<<endl;
    }else{
        cout << a/2 +1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;

vector<ll> A;
ll fcn(ll b){
   ll ret = 0;
   for(int i = 0; i < (int)A.size();i++) ret += abs(A[i]-b-i-1);
   return ret;
}

ll fcnd(ll b) {
   return fcn(b+1) - fcn(b);
}

int main(void) {
   ll N;
   cin>>N;
   A.resize(N);
   rep(i,0,N) cin>>A[i];
   ll le = (ll)-1e9;
   ll re = (ll)1e9;
   while(1) {
      ll ne = (le+re)/2;
      if (le == ne || re == ne) break;
      if (fcnd(ne)>0) re = ne;
      else le = ne;
   }
   // cout<<le<<" "<<re<<endl;
   // cout<<fcn(le)<<" "<<fcn(re)<<endl;
   ll ans = min(fcn(le),fcn(re));
   cout<<ans<<endl; 






   return 0;
}

Measured memory_bytes: 1792
#import<bits/stdc++.h>
using namespace std;
int a,b,c,i,j,k,l,m,n,s,x,y,z,w[105];
main()
{
scanf("%d%d",&n,&k);
for(;i++<n;){scanf("%d",&x);s+=x;if(s>k)return printf("%d",i),0;}
printf("%d",n+1);
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())

#ここまでのパテーン
#dp[y][x]=dp[y][x-1]*y +dp[y-1][x]*x

dp=[[0]*(d) for _ in range(c)]
dp[a-1][b-1]=1
mod=998244353

if a==c and b==d:
    print(1)
    exit()

if a==c:
    print((a**(d-b))%mod)
    exit()
if b==d:
    print((b**(c-a))%mod)
    exit()


for y in range(a-1,c):
    for x in range(b-1,d):
        
        dp[y][x]+=dp[y][x-1]*(y+1)+dp[y-1][x]*(x+1)-dp[y-1][x-1]*x*y
        dp[y][x]=dp[y][x]%mod
        #print(y,x,dp[y][x])

print(dp[-1][-1]%mod)



Measured memory_bytes: 133808
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  string s;
  cin >> s;

  int alph[26] = {};

  alph[s[0] - 'A']++;
  alph[s[1] - 'A']++;
  alph[s[2] - 'A']++;
  alph[s[3] - 'A']++;
  int ok = 1;
  for (int i = 0; i < 26; i++){
    if (alph[i] != 0 && alph[i] != 2){
      ok = 0;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////

int main(){

   int n,k;
   I2(n,k);
   int res = 0;
   while(n){
       res++;
       n/=k;
   }
   cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

int n;
int array[2000];

bool solve(int i, int m)
{
    if(m == 0)
        return true;
    if(i >= n)
        return false;
    bool ret = solve(i + 1, m) || solve(i + 1, m - array[i]);
    return ret;
}

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", &array[i]);
    int q;
    scanf("%d", &q);
    int m;
    for(int i = 0; i < q; i++)
    {
        scanf("%d", &m);
        if(solve(0, m))
            printf("yes\n");
        else
            printf("no\n");
    }
}


Measured memory_bytes: 3144
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = new string[](3);
	foreach (i; 0..3)
		S[i] = RD!string;
	
	size_t pos;
	while (true)
	{
		if (S[pos].empty) break;
		auto c = S[pos].front; S[pos].popFront;
		if (c == 'a')
			pos = 0;
		else if (c == 'b')
			pos = 1;
		else
			pos = 2;
		
	}
	
	writeln(pos == 0 ? "A" : pos == 1 ? "B" : "C");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n, m, k;
	int a, b;
	cin >> n;
	for(int i=1;i<10;i++){
		m = n-i*100;
		if(m<100){
			a = i;
			break;
		}
	}
	for(int i=1;i<10;i++){
		k = m-i*10;
		if(k<10){
			b = k;
			break;
		}
	}
	if(a == b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,mmm,i,k,j,aa,ans=0;
	cin>>n>>mmm;
	map<ll,int> m,mm;
	for(i=1;i<=mmm;i++){
		mm[i]=1;
	}
	for(i=0;i<n;i++){
		cin>>k;
		m.clear();
		for(j=0;j<k;j++){
			cin>>aa;
			m[aa]=1;
		}for(auto x:mm){
			if(x.second==1){
				if(m[x.first]==0){
					mm[x.first]=0;
				}
			}
		}
	}for(auto x:mm){
		if(x.second==1)	ans++;
	}cout<<ans;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;

namespace hello_world
{class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int A = int.Parse(input[0]);
			int B = int.Parse(input[1]);
			int H = int.Parse(input[2]);
			int M = int.Parse(input[3]);
		 double answer;
			var angle = (60 * H + M) * 5.5f;
			var cos = Math.Cos(angle * (Math.PI / 180));
			answer=A*A+B*B-2*A*B*cos;
			Console.WriteLine(System.Math.Sqrt(answer));

	

		}
	}

}

	

Measured memory_bytes: 27996
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	string s;int k, sum = 0, su = 0;cin >> k >> s;
	rep(i, k) {
		if (s[i] == 'R') sum++;
		else su++;
	}
	if (sum > su) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;
int main(){
  ll n,q;cin >> n;
  ll a[n];
  vector<ll> num(100005,0);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
    num[a[i]]++;
  }
  cin>>q;
  ll b[q],c[q];
  rep(i,q){
  cin >> b[i] >> c[i];
  }
  rep(i,q){
    sum+=(c[i]-b[i])*num[b[i]];
    num[c[i]]+=num[b[i]];
    num[b[i]]=0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 6348
# include <stdio.h>
# include <string.h>
# include <iostream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int M = 5e5 + 10;
const int mod = 1e9 + 7;

int n, a[M];
bool ok[M];

inline bool chk(int l, int r) {
  int le = 0, ri = 0;
  for (int i = l; i <= r; ++ i) {
    if(a[i] < l || a[i] > r) return false;
    if(a[i] < i) {
      if(a[i] < le) return false;
      le = a[i];
    }
    if(a[i] > i) {
      if(a[i] < ri) return false;
      ri = a[i];
    }
  }
  return true;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while(cin >> n) {
    bool flag = 0;
    ok[0] = 1;
    for (int i = 1; i <= n; ++ i) cin >> a[i];
    for (int i = 1; i <= n; ++ i) ok[i] = (a[i] == i);
    
    for (int i = 2; i < n; ++ i)
      if(!ok[i-1] && !ok[i] && !ok[i+1]) {
        puts("No");
        flag = 1;
        break;
      }
    if(flag) continue;
    
    for (int i = 1; i <= n; ++ i) {
      if(!ok[i]) {
        int cur = 1;
        int l = i, r = i;
        while(r <= n && (ok[r] ^ cur)) ++r, cur ^= 1;
        if(chk(l, r - 1) == false) {
          puts("No");
          flag = 1;
          break;
        }
        i = r - 1;
      }
    } 
  
    if(!flag) puts("Yes");
  }
  return 0;
}




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

N = int(input())
re_sum = 0
re_min = 101

for _ in range(N):
    s = int(input())
    re_sum += s
    if s % 10 != 0:
        re_min = min(re_min, s)

if re_sum % 10 == 0:
    if re_min == 101:
        re_sum = 0
    else:
        re_sum -= re_min
        
print(re_sum)

Measured memory_bytes: 3060
// AOJ 2581 Derangement
// 2018.3.9 bal4u

#include <stdio.h>
#include <string.h>

#define QMAX 10000
typedef struct { int t, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x10101010
#define MAX 205
typedef struct { int to, rev; int cap, cost; } EDGE;
EDGE edge[MAX][MAX]; int hi[MAX];
int V;				// 頂点数
int potential[MAX], dist[MAX], prevv[MAX], preve[MAX];

void add_edge(int from, int to, int cap, int cost)
{
	int f, t;
	EDGE *ep;

	f = hi[from]++, t = hi[to]++;
	ep = &edge[from][f], ep->to = to, ep->cap = cap, ep->cost = cost, ep->rev = t; 
	ep = &edge[to][t], ep->to = from, ep->cap = 0, ep->cost = -cost, ep->rev = f;
}

int minCostFlow(int S, int T, int F)
{
	int i, v, nv, t, nt, ret;
	EDGE *ep;

	ret = 0;
//	memset(potential, 0, V << 2);
  
	while (F > 0) {
		memset(dist, INF, V << 2);
		qsize = 0;
		enq(S, 0), dist[S] = 0;
		while (qsize) {
			v = que[0].s, t = que[0].t, deq();
			if (dist[v] < t) continue;
			for (i = 0; i < hi[v]; i++) {
				ep = &edge[v][i];
				if (ep->cap <= 0) continue;
				nv = ep->to;
				nt = t + ep->cost - potential[nv] + potential[v];
				if(dist[nv] > nt) {
					dist[nv] = nt;
					prevv[nv] = v, preve[nv] = i;
					enq(nv, nt);
				}
			}
		}
		if (dist[T] == INF) return -1;
		for (v = 0; v < V; v++) potential[v] += dist[v];

		t = F;
		for (v = T; v != S; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			if (t > ep->cap) t = ep->cap;
		}
		F -= t;

		ret += t * potential[T];
		for (v = T; v != S; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			ep->cap -= t;
			edge[v][ep->rev].cap += t;
		}
	}
	return ret;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, p, i, j;
	int source, sink;

	n = in();
	source = n << 1, sink = source+1, V = sink+1;

	for (i = 0; i < n; i++) {
		add_edge(source, i, 1, 0);

		p = in();
		for (j = 0; j < i; j++) if (p != j+1)
			add_edge(i, n+j, 1, (i-j)*p);
		for (     ; j < n; j++) if (p != j+1)
			add_edge(i, n+j, 1, (j-i)*p);

		add_edge(n+i, sink, 1, 0);
	}

	printf("%d\n", minCostFlow(source, sink, n));
	return 0;
}


Measured memory_bytes: 2516
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   

    long double d;
    ll l;
    cin >> l;
    d = (long double)l / 3;
    cout << setprecision(10) << d*d*d << endl;



}

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;


int main() {
    int a, b; cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
class P{
  static void Main(){
    int val = int.Parse(Console.ReadLine());
    int kekka;
    string s = "No";
    for(int i=1;i<=9;i++){
      if(val%i==0){
        if(val/i<=9){s = "Yes";break;}
      }
    }
    Console.WriteLine(s);
  }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        if(n-m >=2 || m-n >= 2) System.out.println(0);
        else {
            long a = 1;
            long b = 1;
            for(int i=n; i>=2; i--) {
                a *= i;
                a = a%1000000007;
            }
            for(int i=m; i>=2; i--) {
                b *= i;
                b = b%1000000007;
            }
            if(n != m)System.out.println((a*b) % 1000000007);
            else System.out.println((2*a*b) % 1000000007);
        }
        
    }

}


Measured memory_bytes: 21584
N, W = map(int, input().split())
max_v = 100 * 10**3
dp = [float("inf")] * (max_v + 1)
dp[0] = 0

for _ in range(N):
    w, v = map(int, input().split())
    for dp_v in reversed(range(max_v+1)):
        dp_w = dp[dp_v]
        if (dp_v == 0 or dp_w < float("inf")) and dp_v + v <= max_v:
            dp[dp_v + v] = min(dp[dp_v + v], dp[dp_v] + w)

ans = 0
for v, w in enumerate(dp):
    if w <= W:
        ans = max(ans, v)

print(ans)

Measured memory_bytes: 86984
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static class Page{
		String page_name;
		int page_number;
		int[][] btns;
		int[] links;
		
		public Page(String page_name, int page_number, int[][] btns, int[] links) {
			super();
			this.page_name = page_name;
			this.page_number = page_number;
			this.btns = btns;
			this.links = links;
		}
		
		public int touch(int x, int y){
			for(int i = 0; i < btns.length; i++){
				final int lu_x = btns[i][0];
				final int lu_y = btns[i][1];
				final int rd_x = btns[i][2];
				final int rd_y = btns[i][3];
				
				if(lu_x <= x && x <= rd_x && lu_y <= y && y <= rd_y){
					return links[i]; 
				}
			}
			
			return -1;
		}
	}
	
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			final int W = sc.nextInt();
			final int H = sc.nextInt();
			
			String[] name = new String[n];
			int[] btns = new int[n];
			int[][][] rects = new int[n][][];
			String[][] links = new String[n][];
			
			HashMap<String, Integer> map = new HashMap<String, Integer>();
			
			for(int i = 0; i < n; i++){
				name[i] = sc.next();
				final int k = sc.nextInt();
				btns[i] = k;
				
				rects[i] = new int[k][4];
				links[i] = new String[k];
				for(int j = 0; j < k; j++){
					rects[i][j][0] = sc.nextInt();
					rects[i][j][1] = sc.nextInt();
					rects[i][j][2] = sc.nextInt();
					rects[i][j][3] = sc.nextInt();
					links[i][j] = sc.next();
				}
				
				map.put(name[i], i);
			}
			
			Page[] pages = new Page[n];
			for(int i = 0; i < n; i++){
				int[] link = new int[btns[i]];
				for(int j = 0; j < btns[i]; j++){
					link[j] = map.get(links[i][j]);
				}
				
				pages[i] = new Page(name[i], i, rects[i], link);
			}
			
			ArrayList<Integer> history = new ArrayList<Integer>();
			history.add(0);
			int size = 1;
			int cur_pos = 0;
			
			int cur_page = 0;
			final int q = sc.nextInt();
			for(int t = 0; t < q; t++){
				String input = sc.next();
				
				if("forward".equals(input)){
					if(cur_pos < size - 1){
						cur_pos++;
						cur_page = history.get(cur_pos);
					}
				}else if("back".equals(input)){
					if(cur_pos > 0){
						cur_pos--;
						cur_page = history.get(cur_pos);
					}
				}else if("click".equals(input)){
					final int x = sc.nextInt();
					final int y = sc.nextInt();
					
					int ret = pages[cur_page].touch(x, y);
					
					if(ret >= 0){
						cur_pos++;
						cur_page = ret;
						history.add(cur_pos, cur_page);
						size = cur_pos + 1;
					}
				}else if("show".equals(input)){
					//System.out.println(cur_pos + " " + size + " " + history);
					System.out.println(pages[cur_page].page_name);
				}
			}
			
		}
	}

}

Measured memory_bytes: 25948
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
    int n;
    scanf("%d", &n);

    int now = 0, x = 0, y = 0;

    for (int i = 0; i < n; i++)
    {
        int ti, xi, yi;
        scanf("%d %d %d", &ti, &xi, &yi);

        int dist = abs(x - xi) + abs(y - yi);

        if (dist > ti - now || (ti - now - dist) % 2 != 0)
        {
            printf("No\n");
            return 0;
        }

        now = ti;
        x = xi;
        y = yi;

    }

    printf("Yes\n");

    return 0;
}

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

using namespace std;

int main()
{
    int n,m;
    double x;
    cin>>n;
    if(n%2==0)
        m=n/2;
    else
        m=n/2+1;
    x=(double)m/n;
    printf("%.10f\n",x);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll N = 2000009;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
ll mod = 1e9+7;
ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
vector<ll> g[N];
ll score[N];
void dfs(ll v,ll p){
     score[v]+=score[p];
     for(auto u:g[v]){
          if(u==p)continue;
          dfs(u,v);
     }
}
 int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
     // #endif
     ll t = 1;
     // cin>>t;
     while(t--){
          ll n,q;cin>>n>>q;
          for(int i = 0;i<n-1;i++){
               ll v,u;cin>>v>>u;v--;u--;
               g[v].push_back(u);
               g[u].push_back(v);
          }
          memset(score,0,sizeof(score));
          for(int i =0;i<q;i++){
               ll p,x;cin>>p>>x;
               p--;
               score[p]+=x;
          }
          dfs(0,-1);
          for(int i = 0;i<n;i++){
               cout<<score[i]<<" ";
          }
     }
}            


Measured memory_bytes: 80512
a,b,c,x,y = map(int,input().split())

sum_ab = a + b
double_c = c * 2
cheaper = sum_ab if sum_ab <= double_c else double_c
lesser = x if x < y else y
moreer = x if x >= y else y
base_cost = cheaper * lesser
additional = 0
if x - y > 0:
  additional = (x-y) * a
else:
  additional = (y-x) * b
total_p1 = base_cost + additional
total_p2 = moreer * double_c
print(min(total_p1, total_p2))

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

ll findgcd(ll,ll);

int main(){
  int i;
  int c1=0,c0=0;
  string S;
  cin >> S;
  for(i=0;i<S.size();i++){
    if(S[i] == '1') c1++;
    else c0++;
  }
  cout << 2*min(c1,c0) << endl;
}
  

Measured memory_bytes: 512
#include <cstdio>

int a[605][605],n,d1,d2,c;

void Color(int d)
{
    int b=0;
    while(!(d&3))d>>=2,++b;
    for(int i=0;i<(n<<1);++i)
        for(int j=0;j<(n<<1);++j)
            if(d&1)a[i][j]|=((i>>b)+(j>>b))&1;
            else a[i][j]|=i>>b&1;
}

int main()
{
    scanf("%d%d%d",&n,&d1,&d2);
    Color(d1),Color(d2);
    for(int i=0;i<(n<<1);++i)
        for(int j=0;j<(n<<1);++j)
            if(!a[i][j]&&++c<=n*n)
                printf("%d %d\n",i,j);
    return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 200010;
const int mod = 1e9 + 7;

struct A{ int x, v;} a[N];

bool cmp(A a, A b) { return a.x < b.x;}

int h[N], l[N], r[N], q[N];
LL f[N];
int main()
{
	int n;
	scanf("%d", &n);
	Rep(i, n){
		scanf("%d%d", &a[i].x, &a[i].v);
		h[i] = a[i].v;
	}
	sort(h + 1, h + 1 + n);
	Rep(i, n) a[i].v = lower_bound(h + 1, h + 1 + n, a[i].v) - h;
	sort(a + 1, a + 1 + n, cmp);
	 
	l[n + 1] = 1e9;
	Rep(i, n) r[i] = max(r[i - 1], a[i].v);
	for (int i = n; i; i --) l[i] = min(l[i + 1], a[i].v);
	
	int ta = 0, he = 0;
	f[0] = 1, ta ++;
	LL sum = 1, ans = 0;
	Rep(i, n){
		//printf("%d %d\n", l[i], r[i]);
		while (r[q[he]] < l[i] - 1){
			if (he) sum = (sum - f[q[he]]+ mod) % mod;
			he ++;
		}
		f[i] = sum, q[++ ta] = i, sum = (sum + f[i]) % mod;
		if (r[i] == n) ans = (ans + f[i]) % mod;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}
/*
3
2 5
6 1
3 7
*/


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <long> v(n);
	for (auto &x : v){
		cin >> x;
		x*=2;
	}
	long ans = 0;	
	vector <long> res;
	for (int i = 0; i < n; ++i){
		ans += (i%2 ? -1: 1)*v[i];				
	}
	res.emplace_back(ans/2);
	for (int i = 0; i < n - 1; ++i){
		ans = ans + (i%2 ? 1 : -1)*v[i];
		res.emplace_back(ans);
	}
	for (int i = 1; i < n; ++i){
		res[i] = (i%2 ? -1 : 1)*res[i]  + (i%2 ? 1 : -1)*res[0];
	} 
	for (auto x : res){
		cout << x << " ";
	}
	return 0;
}


Measured memory_bytes: 3060
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
const ll M=2e5+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll n,a,b;

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> a >> b;
	if (n==1 && a!=b) RET(0);
	if (a==b)RET(1);
	if (a>b) RET(0);
    ll mi=n*a,mx=n*b;
    mi+=b-a;
    mx+=a-b;
    RET(mx-mi+1);
}    


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N);
  int cnt = 0;
  rep(i, N){
    cin >> A.at(i);
    if(A.at(i) % 2 == 1){
      cnt++;
    }
  }
  if(cnt % 2 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = min(a, b) + min(c, d);
  cout << ans;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
ll n,wt;
ll w[102], v[102];
ll dp[102][100005]; 
ll f(ll idx, ll wt)
{
	if(wt < 0)
		return -1e18;
	if(idx == n)
		return 0;
	if(dp[idx][wt] != -1)
		return dp[idx][wt];	
	return dp[idx][wt] = max(f(idx+1, wt), f(idx+1, wt-w[idx])+v[idx]);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>wt;
	ll i;
	for(i=0;i<n;i++)
		cin>>w[i]>>v[i];
	for(i=0;i<102;i++)
		for(int j=0;j<100005;j++)
			dp[i][j]=-1;
	cout<<f(0, wt)<<nl;
	return 0;
}

Measured memory_bytes: 83308
#include <stdio.h>
 
int main(void)
{
    int hen1, hen2, taikaku;
    int tyouhoukei, hishigata; 
     
    tyouhoukei = 0;
    hishigata = 0;
     
    while(scanf("%d, %d, %d" , &hen1, &hen2, &taikaku) != EOF){
         
        if ((hen1 * hen1) + (hen2 * hen2) == (taikaku * taikaku)){
            tyouhoukei++;
        }
         
        else if (hen1 == hen2){
            hishigata++;
        }
    }
     
    printf("%d\n" , tyouhoukei);
    printf("%d\n" , hishigata);
     
    return (0);
}

Measured memory_bytes: 596
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;


int main() {
	ll a, b;
	cin >> a >> b;
	ll x = a * b;
	if (a < b) {
		ll t = a;
		a = b;
		b = t;
	}
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	cout << x / b << endl;

}


Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
sum_v=0
sum_c=0
for i in range(n):
	if v[i]-c[i]>=0:
		sum_v+=v[i]
		sum_c+=c[i]
		ans.append(sum_v-sum_c)
try:
	print(max(ans))
except ValueError:
	print("0")


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF            1e9
#define INFLL          1e18
#define EPS            1e-9
#define REP(i,n)       for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)      for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(ll i=(n);i>0;--i)
#define REPC(i,obj)    for(auto i:obj)
#define ALL(obj)       (obj).begin(),(obj).end()
#define SETP(n)        cout<<fixed<<setprecision(n)
#define VEC2(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VEC2I(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T, ll h, ll w>using vec2 = vector<vector<T>>;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll m = in(), n = in();
	vector<vector<ll>>dist(m);
	vector<ll> indeg(m, 0);
	REP(i, n) {
		ll x = in() - 1, y = in() - 1;
		dist[x].push_back(y);
		++indeg[y];
	}
	ll cnt = 0;
	while (true) {
		REP(i, m) {
			if (indeg[i] == 0) {
				cout << i + 1 << endl;
				--indeg[i];
				if (++cnt == m) return 0;
				REPC(j, dist[i]) --indeg[j];
			}
		}
	}
}


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

int main(){
  int n;
  cin>>n;
  vector<int> c(n-1),s(n-1),f(n-1);
  rep(i,n-1){
    cin>>c[i]>>s[i]>>f[i];
  }
  vector<int> ans(n);
  for(int i = 0; i < n-1; i++){
    int now=0;
    for(int j = i; j < n-1; j++){
      if(now < s[j]) now+=s[j]-now;
      else if(now%f[j]!=0) now+=f[j]-now%f[j];
      now += c[j];
    }
    ans[i] = now;
  }
  rep(i,n){
    cout<<ans[i]<<endl;
  }
}


Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define link(x) for(edge *j=h[x];j;j=j->next)
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,r,l) for(int i=r;i>=l;i--)
const int MAXN=3e5+10;
const double eps=1e-8;
const int mod=1e9+9;
#define ll long long
using namespace std;
struct edge{int t,v;edge*next;}e[MAXN<<1],*h[MAXN],*o=e;
void add(int x,int y,int vul){o->t=y;o->v=vul;o->next=h[x];h[x]=o++;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return x*f;
}

char str[MAXN];

int main(){
    scanf("%s",str+1);
    if(str[2]=='B')puts("ARC");
    else puts("ABC");
    return 0;
}



Measured memory_bytes: 3628
#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;



int main(){

	ll X;
	scanf("%lld",&X);

	for(ll a = -120; a <= 120; a++){
		for(ll b = -120; b <= 120; b++){

			if(a*a*a*a*a-b*b*b*b*b == X){

				printf("%lld %lld\n",a,b);
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3796