akhauriyash/Code-Regression huggingface dataset:
from collections import deque
n, d, a = map(int, input().split())
monster = []
for i in range(n):
    monster.append(list(map(int, input().split())))

d *= 2
monster.sort()

count = 0
damage_total = 0
q = deque([])

for i in range(n):
    x = monster[i][0]
    h = monster[i][1]
    while len(q) > 0 and q[0][0] < x:
        damage_total -= q[0][1]
        q.popleft()

    h -= damage_total
    if h > 0:
        count_now = (h + a - 1) // a
        count += count_now
        damage_now = a * count_now
        damage_total += damage_now
        q.append([x + d, damage_now])

print(count)

Measured memory_bytes: 66368
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll n; cin >> n;
    vector<int> ans;
    while(n > 0) {
        n--;
        ans.pb(n % 26);
        n /= 26;
    }
    for(int i = ans.size() - 1; i >= 0; --i) {
        cout << char(ans[i] + 'a');
    }
    cout << endl;
}


Measured memory_bytes: 3588
console.log((args=>{
  const [[N],A] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const a = Array(N+1).fill(0), MOD = 1e9+7;
  a[0] = 3;
  let c = 1;
  for ( let i = 0; i < N; i++ ) {
    c = c * a[A[i]] % MOD;
    a[A[i]]--;
    a[A[i]+1]++
  }
  return `${c}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 39888
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    vector<vector<P>> adj(n);
    rep(i, n) {
        int u, k, v, c;
        cin>>u>>k;
        rep(j, k) {
            cin>>v>>c;
            adj[u].push_back(P(c, v));
        }
    }

    priority_queue<P, vector<P>, greater<P>> q;
    vector<int> wmap(n, -1);
    q.push(P(0, 0));
    while (!q.empty()) {
        P p = q.top(); q.pop();
        int w = p.first;
        int v = p.second;
        if (wmap[v] != -1) continue;

        wmap[v] = w;
        for (auto e : adj[v]) {
            q.push(P(e.first + w, e.second));
        }
    }

    rep(i, n) cout<<i<<" "<<wmap[i]<<endl;
}


Measured memory_bytes: 11736
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;

//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
	string a, b;
	cin>>a>>b;
	string na="",nb="";
	fo(i,stoll(b))na+=a;
	fo(i,stoll(a))nb+=b;
	if(na<nb)cout<<na;
	else cout<<nb;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

}

Measured memory_bytes: 2560
import fractions
from functools import reduce


def gcd(L):
    return reduce(fractions.gcd, L)

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

x_gap = [abs(x[i] - X) for i in range(N)]

ans = gcd(x_gap)
print(ans)


Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<string> w(n);
	for(int i =0;i<n;i++)
		cin >> w[i];
	bool siritori=true;
	
	for(int i=0;i<n-1;i++){
		int t = w[i].size()-1;
		if((w[i+1])[0] != (w[i])[t] )
			siritori=false;
	}
	sort(w.begin(),w.end());
	for(int i=0;i<n-1;i++){
		if(w[i] == w[i+1])
			siritori=false;
	}
	if(siritori)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
}


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

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

int main() {
  int h, w;
  cin >> h >> w;
  int c[10][10];
  REP(i, 10) {
    REP(j, 10) { cin >> c[i][j]; }
  }
  int a[h][w];
  REP(i, h) {
    REP(j, w) { cin >> a[i][j]; }
  }

  REP(k, 10) {
    REP(i, 10) {
      REP(j, 10) { c[i][j] = min(c[i][j], c[i][k]+c[k][j]); }
    }
  }
  int ans = 0;
  REP(i, h) {
    REP(j, w) {
      if (a[i][j] == -1) {
        continue;
      } else {
        ans += c[a[i][j]][1];
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i,n) for( ll i=0 ; i<n ; i++ )
#define f(i, a, b) for( ll i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll fact(ll n)
{
    ll ans = 1e14;
    for(ll i = 1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll sol = (i - 1) + (n/i - 1);
            ans = min(ans,sol);
        }
    }
    return ans;
}
int visited[200000] = {0};
vector<vector<int> > v(200000);
int dfs(int x)
{
    int ans = 0;
    if(visited[x]==0)
    {
        visited[x] = 1;
        ans++;
        int a = v[x].size();
        for(int j = 0; j<a; j++)
        {
            int data = v[x][j];
            ans = ans + dfs(data);
        }
    }
    return ans;
}
void primefactors(int n)
{
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        cout << n << " ";

}
double fib(int n)
{
    double sol1,sol2;
    sol1 = (1 + sqrt(5))/2;
    sol2 = (1 - sqrt(5))/2;
    sol1 = pow(sol1,n);
    sol2 = pow(sol2,n);
    double ans = sol1 - sol2;
    ans = ans/sqrt(5);
    //ans = int(ans);
    return ans;
}

ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}

ll index(ll n)
{
    n = double(n);
    double sol = n*n + n;
    sol = sol*2 + 1;
    double ans = -1 + sqrt(sol);
    ans = ans/2;
    ans = ll(ans);
    return ans;
}
vector<ll> SieveOfEratosthenes(ll n,ll a)
{

    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    vector<ll>v;
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {

            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for (ll p= a; p<=n; p++)
       if (prime[p])
          v.push_back(p);
    return v;
}
int main()
{
    ll a,b;
    cin>>a>>b;
    if(a*500>=b)
        cout<<"Yes";
    else
        cout<<"No";


}


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

#define int long long

using namespace std;

int dp[100010];
bool vis[100010];
vector <int> v[100010];

void dfs(int x)
{
    vis[x] = true;
    dp[x] = 0;

    for(int i:v[x])
    {
        if(!vis[i])
            dfs(i);

        dp[x] = max(dp[x],dp[i]+1);
    }
}

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

    for(int i=0;i<m;i++)
    {
        int x,y;
        cin >> x >> y;

        v[x].push_back(y);
    }

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
            dfs(i);
    }

    int ans = 0;

    for(int i=1;i<=n;i++)
        ans = max(ans,dp[i]);

    cout << ans << endl;
}

Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,A,B;

int main() {
	
	cout << fixed << setprecision(18);
	cin>>N>>A>>B;
	if(abs(B-A)%2==0){
		cout<<abs(B-A)/2<<endl;
	}else{
		long long int res1,res2;
		res1=min(A,B);
		res1+=(max(A,B)-min(A,B)-1)/2;
		A=N+1-A;
		B=N+1-B;
		res2=min(A,B);
		res2+=(max(A,B)-min(A,B)-1)/2;
		cout<<min(res1,res2)<<endl;
	}
} 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int k,a,b,i,t=0;
  scanf("%d",&k);
  scanf("%d%d",&a,&b);
  for(i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      t=1;
      printf("OK");
      break;
    }
  }
  if(i-b==1 && t!=1)
  {
    printf("NG");
  }
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;

int dp[30][1010];
int main() {
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for (int i = 0; i < N; i++) cin >> V[i];
    for (int i = 0; i < N; i++) cin >> C[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (V[i] > C[i]) ans += V[i] - C[i];
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int N,L;
    cin >> N >> L;
    // vector<string> S;
    vector<vector<char> > C(N,vector<char>(L));

    for(int i=0; i<N; ++i)
    {
        string str;
        cin >> str;
        // S.push_back(str);
        for (int j=0; j<L; ++j)
        {
            C[i][j] = str[j];
        }
    }

    sort(C.begin(),C.end());

    for (int i=0; i<N; ++i)
    {
        for (int j=0; j<L; ++j)
        {
            cout << C[i][j];
        }
    }
    cout << endl;
    return 0;
}

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

using namespace std;

const int _base = 1e9 + 7;

template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;

int main() {
  string T, P;

  cin >> T;
  cin >> P;
  RH rh(T), rh2(P);
  for(int i = 0; i + P.size() <= T.size(); i++) {
    if(rh.get(i, i + P.size()) == rh2.get(0, P.size())) {
      cout << i << endl;
    }
  }
}


Measured memory_bytes: 11912
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007LL;
set<int> G[100000];
int C[100000];
P dfs(int v, int p) {
	P ret(0, v);
	for (int to : G[v]) {
		if (to == p) continue;
		ret = max(ret, dfs(to, v));
	}
	if (C[v]) ret.first++;
	return ret;
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].insert(y);
		G[y].insert(x);
	}
	string c;
	cin >> c;
	int sum = 0;
	for (int i = 0; i < N; i++) C[i] = (c[i] == 'W'), sum += C[i];
	if (sum == 0) {
		cout << 0 << endl;
		return 0;
	}
	else if (sum == 1) {
		cout << 1 << endl;
		return 0;
	}
	queue<int> Q;
	for (int i = 0; i < N; i++) if (G[i].size() == 1) Q.push(i);
	while (!Q.empty()) {
		int x = Q.front();
		Q.pop();
		if (C[x] == 0) {
			C[x] = 2;
			int y = *G[x].begin();
			G[y].erase(x);
			if (G[y].size() == 1) Q.push(y);
		}
	}
	sum = -2;
	int root;
	for (int i = 0; i < N; i++) {
		if (C[i] != 2) {
			C[i] ^= (G[i].size() & 1);
			sum += 2 + C[i];
			root = i;
		}
	}
	P ans = dfs(root, -1);
	ans = dfs(ans.second, -1);
	cout << sum - 2 * ans.first << endl;
}


Measured memory_bytes: 22784
//42
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>

using namespace std;

int main(){
  pair<string,int> t[3][8];
  vector<pair<string,int> > v;
  for(int i=0;i<3;i++){
    for(int j=0;j<8;j++){
      cin>>t[i][j].second>>t[i][j].first;
    }
    sort(t[i],t[i]+8);
    for(int j=0;j<2;j++){
      cout<<t[i][j].second<<' '<<t[i][j].first<<endl;
    }
    v.insert(v.end(),t[i]+2,t[i]+8);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<2;i++){
    cout<<v[i].second<<' '<<v[i].first<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import heapq
def main():
    n,m = map(int,input().split())
    lb = [[] for _ in range(10**5+5)]
    for _ in range(n):
        a,b = map(int,input().split())
        lb[a].append(b)
    res = 0
    q = []
    heapq.heapify(q)
    for i in range(1,m+1):
        for b in lb[i]:
            heapq.heappush(q,b * (-1))
        if q:
            res += heapq.heappop(q) * (-1)

    print(res)

main()

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

}

Measured memory_bytes: 128
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    //vector<ll> X(N);
    //string s;
    //in >> s;
    //vector<string> s;
    //s.resize(N);
    ll N,M;
    in >> N>>M;
    vector<ll> H(N),f(N);
    vector<ll> A(M),B(M);
    ll ans = 0;
    
    REP(i,N){
        in >> H[i];
        f[i]=1;
    }
    
    REP(i,M){
        in >> A[i] >> B[i];

        if(H[A[i]-1] > H[B[i]-1] ){
            f[B[i]-1] = 0;
        }else if(H[A[i]-1] < H[B[i]-1]){
            f[A[i]-1] = 0;
        }else if(H[A[i]-1] == H[B[i]-1]){
            f[B[i]-1]=0;
            f[A[i]-1]=0;
        }
    }

    REP(i,N){
        ans += f[i];
    }


    out << ans << endl;


}

Measured memory_bytes: 6376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int c[1000006];
vector<int> V;
set<int> S;
multiset<int> T;

int N, A[200005];

int dp[200005];

int main(void) {
	cin >> N;
	int Am = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]);
		S.insert(A[i]);
		T.insert(A[i]);
		Am = max(Am, A[i]);
	}

	//sort(V.begin(), V.end());

	

	for(auto y: V){
		if (c[y] >= 1) { c[y] = 2; }
		else if (c[y] >= 0) { c[y]++;
		for (long long int j = y*2; j <= Am; j+=y) {
			c[(int) j] = -1;
		}
		}
	}


	int ans = 0;

	for (int i = 1; i <= N; i++) {
		//if (T.count(A[i]) >= 2) { continue; }
		if (c[A[i]] == 1) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(void)
{
	char s[20];
	char t[20];
	char u[20];
	int a,b;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	int result = strcmp(s,u);
	if(result == 0){
		printf("%d %d\n",a-1,b);
	}
	else{
		printf("%d %d\n",a,b-1);
	}
	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split(' ')))
four = [i for i in A if i % 4 == 0]
notFour = [i for i in A if i % 4 != 0]
two = [i for i in notFour if i % 2 == 0]
a = len(four)
b = len(two)
if N <= 2*a + 1 or N == b or b >= N - 2*a:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string ans="";
  for(int i=0;i<ty-sy;i++)
    ans+='U';
  for(int i=0;i<tx-sx;i++)
    ans+='R';
  for(int i=0;i<ty-sy;i++)
    ans+='D';
  for(int i=0;i<tx-sx;i++)
    ans+='L';
  ans+='L';
  for(int i=0;i<ty-sy+1;i++)
    ans+='U';
  for(int i=0;i<tx-sx+1;i++)
    ans+='R';
  ans+='D';
  ans+='R';
  for(int i=0;i<ty-sy+1;i++)
    ans+='D';
  for(int i=0;i<tx-sx+1;i++)
    ans+='L';
  ans+='U';
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    
    int A,B,ans;

    scanf("%d %d",&A,&B);

    if(A == 1){
        if(B == 2){
            ans = 3;
        }else{
            ans = 2;
        }
    }else if(A == 2){
        if(B == 1){
            ans = 3;
        }else{
            ans = 1;
        }
    }else{
        if(B == 1){
            ans = 2;
        }else{
            ans = 1;
        }
    }

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double ld;
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define pb push_back
#define pf push_front
#define mp map<ll,ll>
#define INF 1000000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    else
    {
        return gcd(b%a,a);   
    }
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int f(char c)
{
    return (int)c-48;
}
/**********************************************************************
***********************************************************************
*********************ACTUAL CODE BEGINS HERE***************************/
int h,w;
int c1,c2,d1,d2;
string s[1005];
int visited[1005][1005];
int check[1005][1005];
int x,y;
int ch(int i,int j)
{
   if(i>0&&i<=h&&j>0&&j<=w)
   {
       return 1;   
   }
   else
   {
       return 0;   
   }
}
queue<pair<int,int>> stk;
int count;
void path(int i,int j,int mark)
{   
    if(check[i+1][j]==0&&i+1<=h)
    {    
        check[i+1][j]=1;
        visited[i+1][j]=mark;
        path(i+1,j,mark);
    }
    if(check[i][j+1]==0&&j+1<=w)
    {   
        check[i][j+1]=1;
        visited[i][j+1]=mark;
        path(i,j+1,mark);
    }
    if(check[i][j-1]==0&&j-1>0)
    {   
        check[i][j-1]=1;
        visited[i][j-1]=mark;
        path(i,j-1,mark);
    }
    if(check[i-1][j]==0&&i-1>0)
    {   
        check[i-1][j]=1;
        visited[i-1][j]=mark;
        path(i-1,j,mark);
    }
    for(int a=i-2;a<=i+2;a++)
    {
        for(int b=j-2;b<=j+2;b++)
        {
            if(ch(a,b))
            {
                if(check[a][b]==0&&visited[a][b]==0)
                {    
                    stk.push({a,b});
                    visited[a][b]=mark+1;
                }
            }
        }
    }
} 
int main()
{   
    fast;
    cin>>h>>w;
    cin>>c1>>c2>>d1>>d2;
    visited[c1][c2]=2;
    for(int i=1;i<=h;i++)
    {
        cin>>s[i];
        s[i]='#'+s[i];
    }
    if(s[d1][d2]=='#')
    {
        //cout<<-1;
        //return 0;
    }
    stk.push({c1,c2});
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(s[i][j]=='#')
            {
                visited[i][j]=1;
                check[i][j]=1;
            }
        }
    }
    int mark=2;
    while(!stk.empty())
    {   
        int a,b;
        a=(stk.front()).first;
        b=(stk.front()).second;
        stk.pop();
        if(visited[a][b]!=0&&check[a][b]==0)
        {   
            //cout<<a<<" "<<b<<endl;
            check[a][b]=1;
            path(a,b,visited[a][b]);
        }
    }
    /*for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cout<<visited[i][j]<<" ";
        }
        cout<<endl;
    }*/
    if(check[d1][d2]!=0)
    {
          cout<<visited[d1][d2]-visited[c1][c2];
    }
    else
    {
        cout<<-1;   
    }
    return 0;
}

Measured memory_bytes: 12600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d,t,s;
  cin >> d >> t >> s;
  if(d>10000 || t>10000 || s>10000){
  cout << "No" <<endl; 
  }
  if(d <= t*s){
    cout << "Yes" <<endl;
  }
  if(d > t*s){
   cout << "No" <<endl;  
  }
}

Measured memory_bytes: 3644
N, K =map(int, input().split())
win = 1
cnt = 0

def DFS(i, win):
    if(i < K):
        win *= 0.5
        i *= 2
        return DFS(i, win)
    else:
        return win
    
for i in range(1, N+1):
    cnt += DFS(i, 1/N)
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
double ans = 0.0;

int main()
{
ll n,k;
cin >> n>>k;
rep(i,n){
    ll temp=i+1;
    double p=1/(double)n;
    while(temp<k){
        p=p*0.5;
        temp=temp*2;
    }
    ans+=p;
}

cout<<fixed<<setprecision(10)<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, x, mn=1e9, c[15], a[15][15];
int main() {
	int i, j, k;
	cin >> n >> m >> x;
	for(i=0; i<n; i++) {
		cin >> c[i];
		for(j=0; j<m; j++) cin >> a[i][j];
	}
	for(k=0; k<1<<n; k++) {
		int sc=0, sa[15]={};
		for(i=0; i<n; i++) {
			if(k>>i & 1) {
				sc += c[i];
				for(j=0; j<m; j++) sa[j] += a[i][j];
			}
		}
		for(j=0; j<m; j++) if(sa[j] < x) break;
		if(j==m) mn = min(mn, sc);
	}
	cout << (mn==1e9 ? -1 : mn);
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
#define int long long
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
typedef pair<int,int> P;
signed main(){
    int a,b;
    cin >> a >> b;
    int table[a+1][b+1] = {};
    rep(i,a){
        table[i][b/2] = 1;
    }
    rep(i,b){
        table[a/2][i] = 1;
    }
    int cnt = 0;
    rep(i,a){
        rep(j,b){
            if(table[i][j] == 0) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
    #include <stdio.h>
    #include <string>
    #include <math.h>
    #include<algorithm>
    #include <numeric>
    using namespace std;
 
    int main(){
      long long N;
      long long x;
      cin >> N >> x;
      long long a[N];
      for(int i=0;i<N;i++){
       cin >> a[i]; 
      }
      long long ans=0;
      sort(a,a+N);
      for(int i=0;i<N-1;i++){
       if(x>=a[i]){
        ans++;
         x-=a[i];
       }
      }
      if(x==a[N-1]) ans++;
      cout << ans << endl;
      return 0;}

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

int main(void){
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    
    if(k > 41){
        for(int i = 0;i < n;i++){
            cout << n;
            if(i < n-1)cout << " ";
        }
    } else {
        for(int K = 0;K < k;K++){
            vector<int> b(n,0);
            for(int i = 0;i < n;i++){
                int l = max(0,i-a[i]);
                int r = min(n-1,i+a[i]);
                b[l]++;
                if(r+1 < n)b[r+1]--;
            }
            for(int i = 1;i < n;i++)b[i] += b[i-1];
            
            for(int i = 0;i < n;i++)a[i] = b[i];
        }
        
        for(int i = 0;i < n;i++){
            cout << a[i];
            if(i < n-1)cout << " ";
        }
    }
}

Measured memory_bytes: 5100
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
#define M 1000000007

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    unordered_map<int,int>m;
    while(k--)
    {
        int d;
        cin>>d;
        while(d--)
        {
            int a;
            cin>>a;
            m[a]++;
        }
    }
    cout<<n-m.size()<<endl;
}

Measured memory_bytes: 3660
#include<stdio.h>

int main()
{
	int a,b,c,d,x;
	int i = 0;
	
	scanf( "%d %d %d",&a, &b, &c);
	
	for( x=a; x<=b; x++ )
	{
		d = c%x;
		
		if(d == 0)
		{
			i++;
		}
	}
	
	printf( "%d\n",i );
	
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int X = 101000;

int odd[X];
int even[X];
int main(){
    int n;
    cin >> n;
    int o, e;
    REP(i,n/2){
        cin >> o >> e;
        //cout << o << " " << e << endl;
        odd[o]++;
        even[e]++;
    }

    int max_o = -1;
    int max_e = -1;
    int index_o;
    int index_e;
    REP(i,X){
       int oo = odd[i];
       int ee = even[i];
       if(oo > max_o){
           max_o = oo;
           index_o = i;
       }
       if(ee > max_e){
           max_e = ee;
           index_e = i;
       }
    }
    bool same = false;
    if(index_e == index_o) same = true;

    sort(odd, odd+X, greater<int>());
    sort(even, even+X, greater<int>());


    //printf("o:%d\te:%d\n",max_o,max_e);
    int ans = 0;
    if(!same){
        REP(i,X-1){
            ans += odd[i+1];
            ans += even[i+1];
        }
    }
    else{
        if(odd[1] > even[1]){
            ans += odd[0];
            ans += even[1];
        }
        else{
            ans += odd[1];
            ans += even[0];
        }
        for(int i = 1; i < X-1; i++){
            ans += odd[i+1];
            ans += even[i+1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using namespace std;

constexpr int MOD = 1000000007;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

inline int popcount(ll x) { return __builtin_popcountll(x); }
inline int div2num(ll x) { return __builtin_ctzll(x); }
inline bool bit(ll x, int b) { return (x >> b) & 1; }

template <class T>
string to_string(T s);
template <class S, class T>
string to_string(pair<S, T> p);
string to_string(string s) { return s; }
string to_string(const char s[]) { return to_string(string(s)); }

template <class T>
string to_string(T v) {
  if (v.empty()) return "{}";
  string ret = "{";
  for (auto x : v) ret += to_string(x) + ",";
  ret.back() = '}';
  return ret;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + ":" + to_string(p.second) + "}";
}
void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

int main() {
  int N;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  REP(i, N) cin >> V[i + 1] >> W[i + 1];
  int Q;
  cin >> Q;
  constexpr int b = 9;
  vector<pair<int, int>> l1, l2, tmp;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    l1.clear();
    l2.clear();
    auto gen = [&](vector<pair<int, int>> &l, int thr) {
      l.emplace_back(0, 0);
      while (v >= thr) {
        int p1 = 0, p2 = 0;
        while (p1 < l.size() || p2 < l.size()) {
          if (p1 < l.size() && l[p1].first < l[p2].first + W[v]) {
            if (tmp.empty() || tmp.back().second < l[p1].second)
              tmp.emplace_back(l[p1]);
            p1++;
          } else {
            if (tmp.empty() || tmp.back().second < l[p2].second + V[v])
              tmp.emplace_back(l[p2].first + W[v], l[p2].second + V[v]);
            p2++;
          }
        }
        v /= 2;
        swap(l, tmp);
        tmp.clear();
      }
    };
    gen(l1, 1 << b);
    gen(l2, 1);
    int p1 = 0, p2 = 0;
    while (p2 + 1 < l2.size() && l1[p1].first + l2[p2 + 1].first <= L) p2++;
    int ans = l1[p1].second + l2[p2].second;
    while (++p1 < l1.size() && l1[p1].first <= L) {
      while (l1[p1].first + l2[p2].first > L) p2--;
      ans = max(ans, l1[p1].second + l2[p2].second);
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 5376
N=int(input())
inp=list(map(int, input().strip().split(' ')))
Xsort=sorted(inp)
med = int(N/2)
for i in range(N):
  if Xsort[med-1] >= inp[i] :
    print(Xsort[med])
  else:
    print(Xsort[med-1])

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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

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

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}


int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);
	
	int n;
	string s;
	cin >> n >> s;
	int cont=0;
	for(int i=0;i<n-2;i++)
	{
		if(s[i]=='A' and s[i+1] == 'B' and s[i+2]=='C')
		cont++;
	}
	cout << cont;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return (b!=0 ? gcd(b,a%b) : a);}
int main(void){
  ll i,n,a,result=0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    if(i==0) result=a;
    else result = gcd(result,a);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int n,k,ans;
int a[100001],depth[100001];
Vi v[100001];
int dfs(int N)
{
	for(int next:v[N])
	{
		dfs(next);
		if(N!=1 && depth[next]==k-1)ans++;
		else depth[N]=max(depth[N],depth[next]+1);
	}
}
int main(){
	scanf("%d%d",&n,&k);
	fup(i,1,n,1)
	{
		scanf("%d",a+i);
		if(i!=1)v[a[i]].pb(i);
	}
	if(k==1)
	{
		int c=0;
		fup(i,1,n,1)if(a[i]!=1)c++;
		return !printf("%d",c);
	}
	if(a[1]!=1)ans++;
	a[1]=1;
	dfs(1);
	printf("%d",ans);
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, T, A;
    cin >> N >> T >> A;
    int e = 1,ans;
  double f = 1e9;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
    for(int i = 0; i < N; i++){
      double b = T - H[i] * 0.006;
        if(abs(A - b) < f){
          ans = e;
          f = abs(A - b);
        }
      e++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CWriteAndErase {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi A(n);
        in >> A;
        unordered_set<int> S;
        trav(x, A) {
            if (S.count(x)) {
                S.erase(x);
            } else {
                S.insert(x);
            }
        }
        int res = sz(S);
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CWriteAndErase solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 4772
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
const long double Ma_PI = 3.1415926535897932384626433832795028841971L;
#define eps 1e-7
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
//#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
#define int ll
void solve(){
    int k, x;
    cin >> k >> x;
    x -= k * 500;
    if (x <= 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
#undef int
int main() {
    init();
    solve();
}

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

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    if (( N % X ) == 0) cout << (( N / X ) ) * T << endl;
    else cout << (( N / X ) + 1 ) * T << endl;
    return 0;
}

Measured memory_bytes: 3592
N,M = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]
A.sort()

ans = 0
for i in range(N):
	if M > A[i][1]:
		ans += A[i][0]*A[i][1]
		M -= A[i][1]
	else:
		ans += A[i][0]*M
		break

print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR (i, 0, n)
#define pb push_back
#define print(x) cout << (x) << endl
#define print2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl

int dh[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dw[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int h, w;
bool in(int x, int y)
{
    return 0 <= x and x < h and 0 <= y and y < w;
}

int main()
{
    cin >> h >> w;
    vector<string> field;
    rep (i, h) {
        string s;
        cin >> s;
        field.pb(s);
    }
    vector<string> answer = field;

    rep (i, h) {
        rep (j, w) {
            if (field[i][j] == '#')
                continue;
            int cnt = 0, x, y;

            rep (k, 8) {
                x = i + dh[k], y = j + dw[k];
                if (in(x, y) and field[x][y] == '#')
                    cnt++;
            }
            answer[i][j] = char('0' + cnt);
        }
    }

    rep (i, h) {
        print(answer[i]);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int a,b;
cin >> a >> b;
if (a>b) {
cout << "a > b" << endl;
} else if (a<b) {
cout << "a < b" << endl;
} else {
cout << "a == b" << endl;
}
}



Measured memory_bytes: 3076
N = int(input())
a = [[int(i) for i in input().split()] for j in range(2)]
ame = [0]*N
ame[0] = a[0][0]+sum(a[1])
for t in range(0,N-1):
    ame[t+1] = ame[t] + a[0][t+1] - a[1][t]
print(max(ame))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

int n, t;
int v[101010];

int main()
{
	scanf("%d%d", &n, &t);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &v[i]);
	}
	int min1 = v[1], cntm = 1, max1 = -1, cntmx = 0, ans = 0, cur = 0;
	for(int i = 2; i <= n; ++i)
	{
		if(v[i] - min1 > max1)
		{
			max1 = v[i] - min1;
			cntmx = cur = 1;
			ans = 0;
		}
		else
		if(v[i] - min1 == max1)
		{
			cntmx++;
			cur = min(cntm, cntmx);
		}
		if(v[i] == min1)
			cntm++;
		else
			if(v[i] < min1)
			{
				cntm = 1;
				min1 = v[i];
				ans += cur;
				cur = 0;
				//cout<<i<<" "<<cur<<" "<<ans<<endl;
			}
	}
	ans += cur;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 640
import math
N = int(input())
P = [int(i) for i in input().split(" ")]
Q = [int(i) for i in input().split(" ")]

p = [1]*N
q = [1]*N

a = 1
b = 1

for i in range(N-1):
  a += (sum(p[:P[i]-1]))*math.factorial(N-(i+1))
  b += (sum(q[:Q[i]-1]))*math.factorial(N-(i+1))
  p[P[i]-1]=0
  q[Q[i]-1]=0
  

print(abs(a-b))

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = c <= a + b + 1 ? c + b : a + 2 * b + 1;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
	if(y == 0) return x;
	else return gcd(y, x % y);
}

int main(){
	ll a, b;
	while(cin >> a >> b){
		ll x = gcd(a, b);
		cout << x << " " << a * b / x << endl;
	}
	return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;

 
 
int32_t main()
{
    fast_io;
    int n;
    cin>>n;
    vi a(n);
    c(a,n);
    vii dp(n+1,vi(n+1,0));
    for(int i=0;i<n;i++)
    dp[i][i]=a[i];

    for(int d=1;d<n;d++)
    {
        for(int i=0;i<n-d;i++)
        dp[i][i+d]=max(a[i]-dp[i+1][i+d],a[i+d]-dp[i][i+d-1]);
    }

    cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 73672
N, K = [int(nk) for nk in input().split()]
S = input()

happy = 0
howmany_LR_or_RL = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    happy += 1
  else: # S[i] != S[i+1]:
    howmany_LR_or_RL += 1

mx_turn =  howmany_LR_or_RL // 2
mx_turn_include_0N = mx_turn + 1
if howmany_LR_or_RL % 2 == 0:
  if K <= mx_turn:
    happy += K * 2
  else: # mx_turn_include_0N <= K:
    happy += (mx_turn_include_0N - 2) * 2
    happy += 2

else: # howmany_LR_or_RL % 2 == 1:
  if K <= mx_turn:
    happy += K * 2
  else: # mx_turn_include_0N <= K:
    happy += mx_turn * 2
    happy += 1

print(happy)

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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    int res = 0;
    bool flag = true;
    for(int i = 0; i < n; ++i){
        if(res < i * 10)
            flag = false;
        res = max(res, i * 10 + a[i]);
    }

    res = (n - 1) * 10;
    for(int i = n - 1; i >= 0; --i){
        if(res > i * 10)
            flag = false;
        res = min(res, i * 10 - a[i]);
    }

    cout << (flag ? "yes" : "no") << endl;
}



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

int main() {
    ll n; cin >> n;
    ll ans = 0;

    for(ll i = 1; i <= n; i++) {
        if(i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }

    cout << ans;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int num = Integer.parseInt(str);
        double max = 0;

        for(int i=1;i<=num;i++){
            if(num==1){
                max=1;
                break;
            }
            for(int j=2;j<num;j++){
                if(Math.pow(i, j)>num){
                    break;
                }
                max = Math.max(max, Math.pow(i, j));
            }
        }
        System.out.println((int)max);
    }
}

Measured memory_bytes: 22996
#include <iostream>

using namespace std;

int main(void){
    int a, b, c, k, l, sum;
    cin >> a >> b >> c >> k;
    sum = 0;
    if((k == a) || (k < a)) {
        sum += k;
        k -= a;
    }else if (k > a) {
        sum += a;
        k -= (a + b);
    }
    
    if (k > 0) {
        sum -= k;
    }

    cout << sum << endl;

    return 0;
}


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

int main(){
  string str; cin >> str;
  string ans;
  for(int i=0; i<3; i++){
    if(str.at(i) == '1'){
      ans += '9';
    }else{
      ans += '1';
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256