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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
//#define ld long double
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mpp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define repr(x,n,j)for(ll x=n;x>j;x--)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;
typedef long double ld;
bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}




ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    a-=b;
    if(a<0)a+=mod;
    return a%mod;
}
struct CustomCompare
{
    bool operator()(ll a,ll b)
    {
        return a>b;
    }
};

const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}



int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
sieve();
ll n; cin>>n;
ll ans=1;

rep(i,1,n-1)
{
    ll res = n - i;
    ll prev = -1 ,p = 1,cnt=0;
    while(res>1)
    {
        cnt = 0;
        ll x = spf[res];
        while(res%x==0)res/=x,cnt++;
        p*=(cnt+1);
    }
    ans += p;
}
cout<<ans<<"\n";
return 0;
}
/*
4
1
1 2 1

*/


Measured memory_bytes: 42184
#include<stdio.h>
int A[1000000],n;
int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left + right)/2;
    if(key==A[mid]){
return 1;}
    else if(key > A[mid])left = mid + 1;
    else if(key < A[mid])right = mid;
  }
  return 0;
}
int main(){
  int i,q,k,sum = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarySearch(k))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

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

/*
templates for competitive programming
type long long -> type ll 
define constants : EPS, INF, MOD, PI
define macros : REP, FOR, ALL, SORT, REVERSE
define number theory functions: qp(a, b), qp(a, b, mo), gcd(a, b)
define dx, dy
*/
   typedef long long unsigned int ll;

   const double EPS = (1e-7);
   const int INF =(1e9);
   const double PI = (acos(-1));
   const int MOD = (int(1e9) + 7);

   #define REP(i, n) for(int i = 0; i < (int)(n); i++)
   #define FOR(i, a, b) for (int i = (a); i < (b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())

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

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

void solve() {

}

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll N;
   cin >> N;
   vector<ll> A(N), B(N), C(N);
   REP(i, N){
       cin >> A[i];
   }
   REP(i,N){
       cin >> B[i];
   }
   REP(i, N){
       cin >> C[i];
   }
   SORT(A);
   SORT(B);
   SORT(C);
   ll ans = 0;
   REP(i, N){
       ll x = lower_bound(ALL(A), B[i]) - A.begin();
       ll y = C.end() - upper_bound(ALL(C), B[i]);
       ans += x * y;
   }
   cout << ans << endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
signed main(){
	int n;
	cin >> n;
	int x[n],y[n];
	ll h[n];
	REP(i,n){
		cin >> x[i] >> y[i] >> h[i];
	}
	int non_zero;
	REP(i,n){
		if(h[i] != 0){
			non_zero = i;
		}
	}
	for(int cx = 0; cx <= 100; cx++){
		for(int cy = 0; cy <= 100; cy++){
			ll H = h[non_zero] + abs(x[non_zero] - cx) + abs(y[non_zero] - cy);
			REP(i,n){
				if(h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), (ll)0)){
					goto no;
				}
			}
			cout << cx << " " << cy << " " << H << endl;
			return 0;
			no:;
		}
	}
}

Measured memory_bytes: 256
x1,y1,x2,y2 = [int(i) for i in input().split()]

x3 = x2 + y1-y2
y3 = y2 + x2-x1
x4 = x3 + y2-y3
y4 = y3 + x3-x2
print(x3,y3,x4,y4)


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

int main(){
    int n;
    while( cin >> n ){
        ll dp[10][10];
        memset( dp, 0, sizeof dp );
        for( int i = 1; i <= n; i++ ){
            int nn = i;
            int right = nn%10;
            int left = right;
            while( nn ){
                left = nn%10;
                nn /= 10;
            }
            dp[left][right]++;
        }
        ll ans = 0;
        for( int i = 0; i <= 9; i++ ){
            for( int j = 0; j <= 9; j++ ){
                ans = ans+dp[i][j]*dp[j][i];
            }
        }
        cout << ans << "\n";
    }
}


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

using namespace std;

#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
typedef long long ll;
/////////////////////

int const N = 5e3 + 41;
int const M = 241;
int const L = 13;

int n, m;
int a[N];
int b[N][M];
ll ans;
int len[N * 2];
int maxi[M][N][L];
ll pref[N];

void buildsparse(){
	fi(0, L) len[(1<<i)] = i;
	fi(1, N) if(!len[i]) len[i] = len[i-1];
	fo(0, m){
		fi(0, n) maxi[o][i][0] = b[i][o];
		fj(1, L){
			for(int i=0;i+(1<<j)<=n;++i){
				maxi[o][i][j] = max(maxi[o][i][j-1], maxi[o][i+(1<<(j-1))][j-1]);
			}
		}
	}
}

int getmax(int id, int l, int r){
	int d = len[r-l+1];
	return max(maxi[id][l][d], maxi[id][r-(1<<d)+1][d]);
}

ll d[N];
int bpos[N];

ll getval(int l, int r){
	ll ret = 0;
	fi(0, m) ret += getmax(i, l, r);
	return ret;
}

void buildpref(){
	fi(0, n){
		if(i) pref[i] = pref[i-1];
		pref[i] += a[i];
	}
}

ll getsum(int l, int r){
	if(l > r) return 0;
	ll ret = pref[r];
	if(l) ret -= pref[l-1];
	return ret;
}

void rec(int tl, int tr, int bl, int br){
	if(tl > tr) return;
	int tm = (tl+tr)/2;
	if(tm == 0){
		int asd = 1;
	}
	int bp = -1;
	ll bv = 0;
	fi(max(tm, bl), br+1){
		ll cur = getval(tm, i);
		cur -= getsum(tm, i-1);
		if(cur > bv){
			bv = cur;
			bp = i;
		}
	}
	d[tm] = bv;
	bpos[tm] = bp;
	rec(tl, tm-1, bl, bp);
	rec(tm+1, tr, bp, br);
}



void solve(){
	buildsparse();
	buildpref();
	rec(0, n-1, 0, n-1);
	fi(0, n) ans = max(ans, d[i]);
	//fi(0, n) cerr << d[i] << " " << bpos[i] << endl;
}

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

	scanf("%d %d",&n,&m);
	fi(0, n-1) scanf("%d",&a[i]);
	fi(0, n) fj(0, m) scanf("%d",&b[i][j]);

	solve();

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

	return 0;
}

Measured memory_bytes: 58624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll h, w; cin >> h >> w;
	vector<string> c(h);
	REP(i, h) cin >> c[i];

	ll ans = 0;
	REP(i, w - 1) {
		vvl cost(h * 2, vl(h, 0)); // cost[差][iの地表からの高さ]
		REP(j, h) { // iのほうが高いとき
			FOR(k, j, h) {
				cost[h + j][k] = c[k][i] == c[k - j][i + 1] ? 1 : 0;
				if (k > 0) cost[h + j][k] += cost[h + j][k - 1];
			}
		}
		REP(j, h) { // iのほうが低いとき
			FOR(k, j, h) { // j の地表からの高さ
				cost[h - j][k - j] = c[k - j][i] == c[k][i + 1] ? 1 : 0;
				if (k - j > 0) cost[h - j][k - j] += cost[h - j][k - j - 1];
			}
		}

		vvl dp(h + 1, vl(h + 1, TEN(10)));
		dp[h][h] = 0;
		for (ll j = h; j > 0; j--) {
			for (ll k = h; k > 0; k--) {
				if (k > 0) dp[j][k - 1] = min(dp[j][k - 1], dp[j][k] + cost[j - k + h][j - 1]);
				if (j > 0) dp[j - 1][k] = min(dp[j - 1][k], dp[j][k] + cost[j - k + h][j - 1]);
			}
		}
		ll mi = TEN(10);
		REP(i, h+1) mi = min(mi, dp[i][0]);
		REP(i, h+1) mi = min(mi, dp[0][i]);
		ans += mi;

	}

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

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


int main () {

 int n;
 cin >> n;
 
 bool flag= false;
 int r;
 while(n>0)
 {
 	r=n%10;
 	n=n/10;
 	
 	if(r==7)
 	{
		 flag=true;
		 break;
	 }
 }

  if(flag)
  {
	  cout << "Yes";
  }
  else
  {
		cout << "No";
  }
 
	return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>

int main(){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0){
			break;
		}if(x <= y){
		  printf("%d %d\n",x,y);
		}else{
		  printf("%d %d\n",y,x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
using ll=long long int;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        ans+=(vec[i]-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=[0]*n
y=[0]*n
z=[0]*n
for i in range(n):
  x[i],y[i],z[i]=map(int,input().split())
ans=0
d=[(1,1,1),(-1,1,1),(1,-1,1),(1,1,-1),(-1,-1,1),(1,-1,-1),(-1,1,-1),(-1,-1,-1)]
for p,q,r in d:
  ans=max(ans,sum(sorted([p*x[i]+q*y[i]+r*z[i] for i in range(n)])[::-1][:m]))
print(ans)

Measured memory_bytes: 73968
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N, M;
  while (cin >> N >> M) {
    vector<int> cnt(M, 0);
    for (int i = 0; i < N; i++) {
      int K;
      cin >> K;
      for (int j = 0; j < K; j++) {
        int A;
        cin >> A;
        --A;
        ++cnt[A];
      }
    }
    int res = 0;
    for (int i = 0; i < M; i++) if (cnt[i] == N) ++res;
    cout << res << endl;
  }
  return 0;
}


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

int main()
{
    long long int n,i,j,mask;
    cin>>n;

    vector<long long int> dp(1<<n);

    long long int can[n][n];

    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            cin>>can[i][j];
    dp[0]=1;
    for(i=0;i<n;i++)
    {
        for(mask=0;mask<(1<<n);mask++)
        {
            for(j=0;j<n;j++)
            {
                if(__builtin_popcount(mask)==i&&can[i][j]&&!(mask&(1<<j)))
                {
                    long long int temp=mask^(1<<j);
                    dp[temp]=(dp[temp]+dp[mask])%mod;
                }
            }
        }
    }

    cout<<dp[(1<<n)-1];
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int n;cin>>n;
  long a;
  int an[100100];rep(i,100100)an[i]=0;
  int cnt = 0;
  rep(i,n) {
    cin>>a;
    if (a > 100000) cnt++;
    else an[a] ++;
  }
  
  rep(i,100100) {
    if (an[i] == 0) continue;
    if (an[i] > i) cnt += an[i]-i;
    else if (an[i] < i) cnt += an[i];
  }
  cout<<cnt;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}



Measured memory_bytes: 2040
#include<iostream>
using namespace std;
void sort(int[]);
int main()
{
	int list[10];
	for(int i=0;i<10;i++)
		cin>>list[i];
	sort(list);
	cout<<list[9]<<endl<<list[8]<<endl<<list[7]<<endl;
	return 0;
}
void sort(int list[10])
{
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<9;j++)
			if(list[j+1]<list[j])
			{
				int temp=list[j];
				list[j]=list[j+1];
				list[j+1]=temp;
			}
	}
}

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

int main()
{
    int a;
    while(1){
        a = 0;
        string x;
        cin >> x;
        if(x == "0"){
            break;
        }
        for(int i = 0; i < x.size(); i++){
            a += x.at(i) - '0';
        }
        cout << a << endl;
    }
}


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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	ll tmp;
	ll h, w;
	cin >> h >> w;
	vector<string> mp;
	string s;
	REP(i, h) {
		cin >> s;
		mp.push_back(s);
	}
	int co[h][w];
	queue<pair<int, int>> q;
	REP(i,h) REP(j, w) {
		co[i][j] = -1;
		if(mp[i][j] == '#'){
			q.push(make_pair(i, j));
			co[i][j] = 0;
		}
	}
	int x, y;
	while(!q.empty()){
		x = q.front().first;
		y = q.front().second;
		tmp = co[x][y];
		q.pop();
		if(x+1 < h && mp[x+1][y] == '.'){
			q.push(make_pair(x+1, y));
			mp[x+1][y] = '#';
			co[x+1][y] = tmp+1;
		}
		if(x-1 >= 0 && mp[x-1][y] == '.'){
			q.push(make_pair(x-1, y));
			mp[x-1][y] = '#';
			co[x-1][y] = tmp+1;
		}
		if(y-1 >= 0 && mp[x][y-1] == '.'){
			q.push(make_pair(x, y-1));
			mp[x][y-1] = '#';
			co[x][y-1] = tmp+1;
		}
		if(y+1 < w && mp[x][y+1] == '.'){
			q.push(make_pair(x, y+1));
			mp[x][y+1] = '#';
			co[x][y+1] = tmp+1;
		}
	}
	REP(i,h) REP(j, w) ans = max(ans, (ll)co[i][j]);
	cout << ans << endl;
}


Measured memory_bytes: 13456
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,k,fa[20][N],q,i,l[N],r[N],x[N],j;
long long ans[N],faf[20][N];
int main()
{
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;++i)
		scanf("%d",&x[i]);
	scanf("%d",&q);
	for(i=1;i<=q;++i)
		scanf("%d %d",&l[i],&r[i]);
	x[0]=-k-1;
	x[n+1]=x[n]+k+1;
	for(i=n;i>=1;--i)
	{
		fa[0][i]=upper_bound(x+1,x+1+n,x[i]-k)-x-1;
		faf[0][i]=i;
	}
	for(i=1;i<20;++i)
		for(j=1;j<=n;++j)
		{
			fa[i][j]=fa[i-1][fa[i-1][j]];
			faf[i][j]=faf[i-1][j]+faf[i-1][fa[i-1][j]];
		}
	for(i=1;i<=q;++i)
	{
		int p=r[i];
		for(j=19;j>=0;--j)
			if(fa[j][p]>=l[i])
			{
				ans[i]+=faf[j][p];
				p=fa[j][p];
			}
		ans[i]+=faf[0][p];
	}

	for(i=1;i<=n;++i)
	{
		fa[0][i]=lower_bound(x+1,x+2+n,x[i]+k)-x;
		faf[0][i]=i-1;
	}
	fa[0][n+1]=n+1;
	for(i=1;i<20;++i)
		for(j=1;j<=n+1;++j)
		{
			fa[i][j]=fa[i-1][fa[i-1][j]];
			faf[i][j]=faf[i-1][j]+faf[i-1][fa[i-1][j]];
		}
	for(i=1;i<=q;++i)
	{
		int p=l[i];
		for(j=19;j>=0;--j)
			if(fa[j][p]<=r[i])
			{
				ans[i]-=faf[j][p];
				p=fa[j][p];
			}
		ans[i]-=faf[0][p];
	}
	for(i=1;i<=q;++i)
		printf("%lld\n",ans[i]);
}


Measured memory_bytes: 54564
N = input()
zero_flag = False
one_flag = False
for i in N[::-1]:
    if i == "0" :
        zero_flag = True
    elif i == "1" and zero_flag:
        one_flag = True
        break
    else:
        break
ans = sum([ int(i) for i in N])
if one_flag:
    ans += 9
print(ans)

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

const int MAX = 44;
int MEM[MAX];

int fibonacci(int i) {
  if (MEM[i] != -1) return MEM[i];
  if (i == 0 || i == 1) return 1;
  MEM[i - 2] = fibonacci(i - 2);
  MEM[i - 1] = fibonacci(i - 1);
  return MEM[i - 2] + MEM[i - 1];
}

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

  for (int i = 0; i <= MAX; i++) MEM[i] = -1;

  int i;
  cin >> i;

  cout << fibonacci(i) << endl;

  return 0;
}

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

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

int N;

bool parity(int n, int r) {
    return n == (r | (n - r));
}

vector<int> getPositions(const string& str, const string& find_word) {
    vector<int> res;
    string::size_type pos = str.find(find_word);
    while (pos != string::npos) {
      res.push_back(pos);
      pos = str.find(find_word, pos + find_word.length());
    }
    return res;
}

int calc(vector<int> poss) {
    int res = 0;
    for (auto pos : poss) {
        res ^= parity(N-1, pos);
    }
    return res;
}

int main() {
    cin >> N;
    string s; cin >> s;
    vector<int> twos = getPositions(s, "2");
    vector<int> threes = getPositions(s, "3");
    if (!twos.empty()) {
        cout << calc(twos) << endl;
    } else if (!threes.empty()) {
        cout << 2*calc(threes) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


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


int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) cin >> vec[i];

	int count = 0;
	int min_num = n + 1;
	for (int i = 0; i < n; i++) {
		if (vec[i] == 1) {
			count++;
			break;
		}

		if (vec[i] < min_num) {
			min_num = vec[i];
			count++;
		}
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> t(D);
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    t[i]=k+1;
  }
  int M=5500000,ans=mzint;
  while(M--){
    vector<pair<int,int>> AAA={make_pair(rand()%D,rand()%26),make_pair(rand()%D,rand()%26),make_pair(rand()%D,rand()%26)};
    vector<int> BBB={t[AAA[0].first],t[AAA[1].first],t[AAA[2].first]};
    int ans2=ans;
    for(int aaa=0;aaa<3;aaa++){
    int d=AAA[aaa].first,q=AAA[aaa].second;
    ans+=s[d][q]-s[d][t[d]-1];
    int mae=-1,ato=D;
    for(int i=d-1;i>=0;i--){
      if(t[i]==t[d]){
        mae=i;
        break;
      }
    }
    for(int i=d+1;i<D;i++){
      if(t[i]==t[d]){
        ato=i;
        break;
      }
    }
    ans-=(ato-d)*(d-mae)*c[t[d]-1];
    mae=-1,ato=D;
    for(int i=d;i>=0;i--){
      if(t[i]==q+1){
        mae=i;
        break;
      }
    }
    for(int i=d;i<D;i++){
      if(t[i]==q+1){
        ato=i;
        break;
      }
    }
    ans+=(ato-d)*(d-mae)*c[q];
    t[d]=q+1;
    }
    if(ans2>ans){
      ans=ans2;
      t[AAA[0].first]=BBB[0];
      t[AAA[1].first]=BBB[1];
      t[AAA[2].first]=BBB[2];
    }
  }
  for(int i:t)
    cout<<i<<endl;
}

Measured memory_bytes: 3736
#include<iostream>
#include<algorithm>

using namespace std;

const int MAX = 1e5+1;

int mp[MAX] = {0};
int main(){
	int n;
	cin >> n;
	
	for(int i = 0;i < n;i++){
		int ta;
		cin >> ta;
		if(ta == 0){
			mp[ta]++;
			mp[ta + 1]++;
		}else if(ta == (MAX - 1)){
			mp[ta]++;
			mp[ta - 1]++;
		}else{
			mp[ta]++;
			mp[ta - 1]++;
			mp[ta + 1]++;
		}
	}
	
	int ans = 0;
	for(int i = 0;i < MAX;i++){
		ans = max(ans,mp[i]);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val t=s.next.toCharArray
		val a=(0 until t.length).count(i=>i%2+'0'==t(i))
		val b=(0 until t.length).count(i=>(i+1)%2+'0'==t(i))
		println(math.min(a,b))
	}
}


Measured memory_bytes: 31576
#include<iostream>
#include<cstring>
#include <math.h> 
using namespace std;
int main(){
    string x;
    cin >> x;
    int n = x.size();
    int b = 0;
    for(int i = 0; i < n; i++){
        b += x[i] -48;
    }
    if(b%9==0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}


Measured memory_bytes: 3664
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())
    P = [int(s) - 1 for s in readline().split()]
    C = list(map(int, readline().split()))

    ans = -INF
    for i in range(N):
        seen = [False] * N
        s = 0
        s_max = -INF
        scores = []
        k = 0

        while k < K and not seen[i]:
            seen[i] = True
            s += C[P[i]]
            scores.append(s)
            if s_max < s:
                s_max = s
            i = P[i]
            k += 1

        if k == K and ans < s_max:
            ans = s_max
        elif scores[-1] > 0:
            tmp = max(
                s_max,
                scores[-1] * (K // k) + max(0, max(scores[: K % k], default=0)),
                scores[-1] * (K // k - 1) + s_max,
            )
            if ans < tmp:
                ans = tmp
        else:
            if ans < s_max:
                ans = s_max

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 98620
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

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

int main(void){
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> r,g,w;
  vector<p> ans;
  int tmp;
  for(int i=0;i<A;i++){
    cin >> tmp;
    r.push_back(tmp);
  }
  sort(r.begin(),r.end(),greater<int>());
  for(int i=0;i<B;i++){
    cin >> tmp;
    g.push_back(tmp);
  }
  sort(g.begin(),g.end(),greater<int>());
  for(int i=0;i<C;i++){
    cin >> tmp;
    w.push_back(tmp);
  }
  sort(w.begin(),w.end(),greater<int>());
  for(int i=0;i<X;i++){
    ans.push_back(make_pair(r[i],'r'));
  }
  for(int i=0;i<Y;i++){
    ans.push_back(make_pair(g[i],'g'));
  }
  for(int i=0;i<w.size();i++){
    ans.push_back(make_pair(w[i],'w'));
  }
  sort(ans.begin(),ans.end());//,greater<int>());
  int curx,cury;
  curx=0;
  cury=0;
  int numw=0;
  ll sum=0;
  for(int i=ans.size()-1;i>=0;i--){
    if(curx <= X && cury <= Y && curx + cury + numw >= X+Y){
      break;
    }
    p item = ans[i];
    char c = item.second;
    if(c == 'w'){
      numw++;
      sum += item.first;
    }else if(c == 'r'){
      curx++;
      sum += item.first;
    }else{
      cury++;
      sum += item.first;
    }
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll N,M;

struct UnionFind{
    vector<int> par;
    vector<ll> S;

    UnionFind(int N):par(N),S(N){
        rep(i,N){
          par[i] = i;
          S[i] = 1;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }
    
    bool same(int x,int y){
      return root(x) == root(y);
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(!same(x,y)){
            S[root(x)] += S[root(y)];
            S[root(y)] = S[root(x)];
        }
        if(rx == ry)return;
        if(S[x] >= S[y]){
          par[ry] = rx;
        }else{
          par[rx] = ry;
        }
    }

    ll SIZE(int x){
        return S[root(x)];
    }
};



int main(){
   cin >> N >> M;
   UnionFind UF(N);
   rep(i,M){
      ll a,b;
      cin >> a >> b;
      a--;b--;
      UF.unite(a,b);
   }
   ll ans = 0;
   rep(i,N){
      ans = max(ans,UF.SIZE(i));
   }
   cout << ans << endl;
}

Measured memory_bytes: 5632
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()

h = l()

co = 0
k = h[0]
al = []
for i in range(1,n):
    if k >= h[i]:
        co += 1
        k = h[i]
    else:
        al.append(co)
        co = 0
        k = h[i]
al.append(co)
print(max(al))



Measured memory_bytes: 14628
w, h, x, y, r =map(int, input().split())

if x>=0 and y>=0:
    if w-(x+r)>=0:
        if h-(y+r)>=0:
            print("Yes")
        else:
            print("No")
# else:
#     if w - (x + r) > 0:
#         if h - (y + r) > 0:
#             print("Yes")
#         else:
#             print("No")
    else:
        print("No")

else:
    print("No")


Measured memory_bytes: 5596
import math
A, B = map(int, input().strip().split())

divisors = []

minAB = min(A,B)
maxAB = max(A,B)
upper = int(math.sqrt(minAB+1) + 1)
ans = 1

for i in range(1, upper):
    if minAB % i == 0:
        divisors.append(i)
        if i != minAB//i:
            divisors.append(minAB//i)

divisors.sort()
#print(divisors)

flag = [True] * len(divisors)
for i, num in enumerate(divisors):
    if maxAB % num != 0:
        flag[i] = False
        continue
    for x in divisors:
        if x == 1 :
            continue
        if x > math.sqrt(num):
            break
        if num % x ==0:
            flag[i] = False
            break

print(flag.count(True))

Measured memory_bytes: 3316
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = c[0]
jud = []
for i in range(n):
    if i not in jud:
        l = []
        j = p[i] - 1
        while j not in jud:
            jud.append(j)
            l.append(c[p[j]-1])
            j = p[j] - 1
        le = len(l)
        su = sum(l)
        l *= 2
        if su > 0:
            v = (k//le)*su
            ans = max(ans, v)
        for ii in range(le):
            val = 0
            for cnt in range(0, le):
                val += l[ii + cnt]
                if su > 0:
                    v = val + ((k - cnt - 1)//le)*su
                    ans = max(ans, v)
                else:
                    ans = max(ans, val)

print(ans)

Measured memory_bytes: 74468
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int md = 1e9 + 7;
const int maxn = 405;
LL dp[maxn][maxn];
LL sum[maxn][maxn], pw[maxn][maxn];
int A[maxn], B[maxn];

int main(){
    int N, C;
    scanf("%d%d", &N, &C);
    for(int i = 1; i <= N; i++){
        scanf("%d", &A[i]);
    }
    for(int i = 1; i <= N; i++){
        scanf("%d", &B[i]);
    }
    for(int x = 1; x < maxn; x++){
        pw[x][0] = 1;
        for(int a = 1; a <= C; a++){
            pw[x][a] = pw[x][a - 1] * x % md;
        }
    }
    for(int i = 1; i <= N; i++){
        for(int a = 0; a <= C; a++){
            sum[i][a] = 0;
            for(int x = A[i]; x <= B[i]; x++){
                sum[i][a] = (sum[i][a] + pw[x][a]) % md;
            }
        }
    }
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= C; j++){
            for(int a = 0; a <= C; a++) if(j >= a){
                dp[i][j] = (dp[i][j] + dp[i - 1][j - a] * sum[i][a] % md) % md;
            }
        }
    }
    printf("%lld\n", dp[N][C]);
    return 0;
}


Measured memory_bytes: 4096
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val restaurants = Array.fill(n)(readLine().split(" "))
    .map(list => (list(0), list(1).toInt))

  def solve() = {
    restaurants.zipWithIndex.sortBy { case ((name, score), _) => (name, -score) }.map(_._2 + 1).mkString("\n")
  }

  println(solve())

}



Measured memory_bytes: 54840
using System;

class ITP1_3_B {
    public static void Main() {

        int[] Input = new int[10000];
        int Count = 0;

        for (int i = 0; i < 10000; i++) {
            int Num = int.Parse(Console.ReadLine());
            if (Num == 0) break;
            Input[i] = Num;
            Count++;
        }

        for (int i = 0; i < Count; i++) {
            Console.WriteLine("Case {0}: {1}", i + 1, Input[i]);
        }
    }
}

Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int n;
int dn[299];
int query(int x){
  cout<<"?";
  for(int i=1;i<=n;i++)cout<<" "<<i+x;
  cout<<endl;
  cout.flush();
  string s;
  cin>>s;
  if(s[0]=='R')return 0;
  else return 1;
}
int query(vector<int> a){
  cout<<"?";
  for(auto i:a)cout<<" "<<i+1;
  cout<<endl;
  cout.flush();
  string s;
  cin>>s;
  if(s[0]=='R')return 0;
  else return 1;
}
vector<int>a[3];
void solve(int x){
  a[2].clear();
  int y=1-x;
  a[2]=a[x];
  for(auto i:a[y]){
    a[2].push_back(i);
    dn[i]=query(a[2]);
    a[2].pop_back();
  }
}
int main(){
  cin>>n;
  int s=query(0);
  int l=1,r=n-1,mid,ans=0;
  while(l<=r){
    mid=(l+r)>>1;
    int t=query(mid);
    if(t==s)ans=mid,l=mid+1;
    else r=mid-1;
  }
//  cout<<ans<<endl;
  dn[ans]=s;dn[ans+n]=1^s;
  for(int i=ans+1;i<ans+n;i++)a[0].push_back(i);
  for(int i=ans+n+1;i<ans+n+n;i++)a[1].push_back(i%(2*n));
  for(int i=0;i<2;i++)solve(i);
  cout<<"! ";
  for(int i=0;i<2*n;i++)cout<<(dn[i]?'B':'R');
  cout<<endl;
  return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

int main(){
	string str;
	while(1){
		cin>>str;
		if(str=="-")break;
		int m,h;
		cin>>m;
		rep(i,0,m){
			cin >> h;
			str = str.substr(h)+str.substr(0,h);
		}
		cout<<str<<endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define ll long long
#define mod 998244353
#define db double
using namespace std;
inline ll read(){
	ll res=0,f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-f;ch=getchar();}
	while(isdigit(ch)) {res=(res<<1)+(res<<3)+(ch^48);ch=getchar();}
	return res*f;
}
const int N=1e6+5;
struct Vector{ll v;db t;}q[N];
ll t[N],v[N];
ll n,x,y,L;
ll l,r;
inline void merge(Vector &a,Vector b){
	a.t=(a.t*a.v+b.t*b.v)/(a.v+b.v);
	a.v+=b.v;
}
int main(){
	n=read();L=read();
	l=1,r=0;
	for(ll i=1;i<=n;i++){
		t[i]=read();v[i]=read();
		while(x+v[i]>L){
			ll del=min(q[l].v,x+v[i]-L);
			q[l].v-=del;
			x-=del,y-=del*q[l].t;
			if(!q[l].v) ++l;
		}
		q[++r].v=v[i];q[r].t=t[i];
		y+=v[i]*t[i],x+=v[i];
		while(l<r && q[r].t<q[r-1].t) merge(q[r-1],q[r]),--r;
        printf("%lf\n",(db)y/L);
	}
	return 0;
}

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

using namespace std;

int prime_factor(long long n) {
	int res = 0;
	for(long long i = 2; i*i <= n; i++) {
		if(n % i == 0) {
			res++;
			while(n % i == 0) n = n/i;
		}
	}
	if(n > 1) res++;
	return res;
} 

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

	long long a, b;
	cin >> a >> b;
	
	cout << prime_factor(__gcd(a, b)) + 1;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    ll gedoku = A + B;
    ll doku = C;
    if (doku - 1 <= gedoku){
        cout << B + C << endl;
    }
    else{
        cout << A + 2 * B + 1 << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>

#define MAX_L 3006

using namespace std;

int f(int a, int b);
void printPath(int x, int y);

char firstInput[MAX_L], secondInput[MAX_L];

int fInputL, sInputL;

int dp[MAX_L][MAX_L];

int main() {

	scanf("%s %s", firstInput, secondInput);

	fInputL = strlen(firstInput);
	sInputL = strlen(secondInput);

	int i, j;
	for(i = 0; i < fInputL+3; i++) {
		for(j = 0; j < sInputL+3; j++) {
			dp[i][j] = -1;
		}
	}

  f(0, 0);

	printPath(0, 0);
	printf("\n");
}

int f(int a, int b) {
	
	if(a == fInputL || b == sInputL)
		return dp[a][b] = 0;

	if(dp[a][b] != -1)
		return dp[a][b];

	if(firstInput[a] == secondInput[b])
		return dp[a][b] = 1 + f(a+1, b+1);
	
	return dp[a][b] = max(f(a+1, b), f(a, b+1));
}

void printPath(int x, int y) {

	if(x == fInputL || y == sInputL)
		return;

	if(firstInput[x] == secondInput[y]) {
		printf("%c", firstInput[x]);
		printPath(x+1, y+1);
		return;
	}

	if(dp[x+1][y] == dp[x][y]) {
		printPath(x+1, y);
	} else {
		printPath(x, y+1);
	}
}

Measured memory_bytes: 35712
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
    
    
import copy
U=copy.deepcopy(A)
del U[U.index(max(U))]
X=max(U)
Q=max(A)
Z=A.index(Q)
for i in range(N):
    if i==Z:
        print(X)
    else:
        print(Q)

Measured memory_bytes: 14564
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ATaskSchedulingProblem {
public:
	void solve(istream& in, ostream& out) {
        int a, b, c;
        in >> a >> b >> c;
        int A, B, C;
        A = abs(a - b);
        B = abs(b - c);
        C = abs(c - a);
        vector<int> x(3);
        x[0] = A;
        x[1] = B;
        x[2] = C;
        sort(x.begin(),x.end());
        out << x[0] + x[1] << endl;
	}
};

int main() {
	ATaskSchedulingProblem solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int k,a,b;
   cin>>k>>a>>b;

   a--;
   long int div1 = a / k;
   long int div2 = b / k;

   if(div2 > div1)
    cout<<"OK";
  else
    cout<<"NG";

   return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int life1, atk1;
	int life2, atk2;
	int i;

	scanf("%d%d%d%d", &life1, &atk1, &life2, &atk2);

	for (i = 0; life1 > 0 && life2 > 0; i++)
	{
		life2 -= atk1;
		life1 -= atk2;
	}

	if (life2 <= 0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}

	return 0;
}

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

typedef long long ll;

int main(){
  ll n,m;
  cin >> n >> m;
  ll ans=1;
  if(n==1){
    cout << m << endl;
  }
  else{
    for(ll i=2;i*i<=m;i++){
      ll count=0;
      while(m%i==0){
        count++;
        m/=i;
      }
      ll x=count/n;
      ans*=(ll)pow(i,x);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  int ans = abs(abs(x) - abs(y));
  if((x > 0 && y > 0) || (x < 0 && y < 0)) {
    if(x > y) {
      ans += 2;
    } else {
      ans += 0;
    }
  } else if(x == 0) {
    if(y < 0) { ans += 1; }
  } else if(y == 0) {
    if(x > 0) { ans += 1; }
  } else {
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//再帰関数
using System;

namespace tst
{
    class Program
    {
        public static int N;
        public static int A;
        public static int B;
        public static int C;

        public static int Gousei(int cnt, int a, int b, int c,int[] L)
        {
            //先にABCに一番近くなるように合成し、最後に+1-1して帳尻合わせる
            //終了条件
            if (cnt == N)
            {
                if (a>0 && b>0 && c>0)
                {
                    return Math.Abs(a - A) + Math.Abs(b - B) + Math.Abs(c - C) - 30;
                } else return 1000000000;
            }
            //再帰
            int ret0 = Gousei(cnt + 1, a       , b         , c         ,L);
            int ret1 = Gousei(cnt + 1, a+L[cnt], b         , c         ,L)+10;
            int ret2 = Gousei(cnt + 1, a       , b + L[cnt], c         ,L)+10;
            int ret3 = Gousei(cnt + 1, a       , b         , c + L[cnt],L)+10;
            return Min4(ret0, ret1, ret2, ret3);
        }
        public static int Min4(int x0, int x1, int x2,int x3)
        {   //4つのうち最小値を返す関数
            int[] X = new int[4];
            X[0] = x0;
            X[1] = x1;
            X[2] = x2;
            X[3] = x3;
            int min = X[0];
            for (int i = 1; i <= 3; i++)
            {
                if (X[i] < min)
                {
                    min = X[i];
                }
            }
            return min;
        }
        public static void Main()
        {
            string[] T = Console.ReadLine().Split(' ');
            //持っている竹の数n、持ってる竹の配列L、作りたい竹の長さa,b,c(ただし、a>b>c)
            N = int.Parse(T[0]);
            int[] L = new int[N];
            A = int.Parse(T[1]);
            B = int.Parse(T[2]);
            C = int.Parse(T[3]);
            for (int i=0; i<N; i++)
            {
                L[i] = int.Parse(Console.ReadLine());
            }
            //関数実行
            Console.WriteLine(Gousei(0,0,0,0,L));
        }

    }
 }

Measured memory_bytes: 13140
def main():
    n = int(input())
    a = [0,0]
    for i in range(1, n+1):
        a[0] += 1
        a[1] = a[1] + 1 if i % 2 != 0 else a[1]
    print(a[1] / a[0])

if __name__ == '__main__':
    main()

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

int main() {

    char c;
    int a, b;
    for(int i = 0;;i++){
        cin >> a >> c >> b;
        if(c == '+'){
        cout << a+b << endl;
        }
        else if(c == '*'){
        cout << a*b << endl;
        }
        else if(c == '/'){
        cout << a/b << endl;
        }
        else if(c == '-'){
        cout << a-b << endl;
        }
        else if(c == '?')break;
    }
}



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


int main(){
  int N, B, check = 0 ;
  cin >> N ;
  vector<int> A(N) ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }  
  sort(A.begin(), A.end()) ;
  for(int i=0;i<N-1;i++){
    if(A[i] == A[i+1]){
      check = 1 ;
      break ;
    }  
  }  
  
  if(check == 1){
    cout << "NO" << endl ;
  }  
  else{
    cout << "YES" << endl ;
  }  
  return 0 ;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <locale.h>
#include <ctype.h>
#include <signal.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
int main()
{
long long int a,b,c;
scanf("%lld%lld",&a,&b);
if(b<=a*2) 
{
	printf("%lld",b/2);
}
else
{
	c=a;
	b-=a*2;
	c+=b/4;
	printf("%lld",c);
}
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

#define L 14
#define M 1000000

char H[M][L];

int getChar(char m){
    if(m=='A')
        return 1;
    else if(m=='C')
        return 2;
    else if(m=='G')
        return 3;
    else if(m=='T')
        return 4;
    else
        return 0;
}

int h1(int key){
    return key%M;
}

int h2(int key){
    return 1+(key%(M-1));
}

long long getkey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum+=p*getChar(str[i]);
        p*=5;
    }
    return sum;
}

int find(char str[]){
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)
            return 1;
        else if(strlen(H[h])==0)
            return 0;
    }
}

int insert(char str[]){
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)
            return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
}

int main(){
    int i,n;
    char str[L],com[7];
    
    scanf("%d",&n);

    for(i=0;i<M;i++)
        H[i][0]='\0';
    for(i=0;i<n;i++){
        scanf("%s %s", com, str);
    
        if(com[0]=='i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 14280
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,ans = 0;
	cin >> N;
	long long asum = 0,bsum = 0;
	vector<ll> a(N),b(N);
	rep(i,N){
		cin >> a[i];
		asum += a[i];
	}
	rep(i,N){
		cin >> b[i];
		bsum += b[i];
	}
	vector<int> minus,plus;
	if(asum >= bsum){
		for(int i=0;i<N;i++){
			if(b[i]>a[i])minus.push_back(abs(a[i]-b[i]));
			else if(a[i]>b[i])plus.push_back(a[i]-b[i]);	
		}
		sort(ALL(minus));
		sort(ALL(plus),greater<>());
		//一番マイナスが大きいやつに一番プラスが大きいやつをぶつけていく
		int mp = 0;
		int pp = 0;
		for(int i=0;i<minus.size();i++){
			ans ++;
			while(minus[i]){
				if(plus[pp]>=minus[i]){
					plus[pp] -= minus[i];
					minus[i] = 0;
					if(i==minus.size()-1)ans++;
				}else{
					ans++;
					minus[i] -= plus[pp];
					pp++;
				}
			}
		}
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 2428
#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)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

class UF {
private:
	vector<ll> par, sz, rank;
public:
	UF(ll n) : par(n), sz(n), rank(n) {
		REP(i, n) {
			par[i] = i;
			sz[i] = 1;
			rank[i] = 0;
		}
	}
	ll find(ll x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}
	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if (x != y) {
			if (rank[x] < rank[y]) {
				par[x] = y;
				sz[y] += sz[x];
			} else {
				par[y] = x;
				sz[x] += sz[y];
				if (rank[x] == rank[y]) {
					rank[x]++;
				}
			}
		}
	}
	bool same(ll x, ll y) {
		return find(x) == find(y);
	}
	ll size(ll n) {
		return sz[find(n)];
	}
};
signed main() {
	ll n = in(), q = in();
	UF uf(n);
	REP(i, q) {
		ll com = in(), x = in(), y = in();
		if (com == 0) {
			uf.unite(x, y);
		} else {
			cout << uf.same(x, y) << endl;
		}
	}
}


Measured memory_bytes: 3228
import sys

input = sys.stdin.readline

N, M = list(map(int, input().split(" ")))
m = set()

for _ in range(M):
    a, b = list(map(int, input().split(" ")))
    if a < b:
        m.add((a,b))
    else:
        m.add((b,a))


for i in range(2, N):
    if (1, i) in m and (i, N) in m:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 37532