akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int a,b,t; cin >> a >> b >> t;

    int res = 0;
    int step = 0;
    while ((step+1) * a <= t) {
        res += b;
        step += 1;
    }
    cout << res << endl;
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#define N 10003
#define IL inline
#define REP(a,b,c) for(a=b;a<=c;a++)
#define PER(a,b,c) for(a=b;a>=c;a--)
using namespace std;
typedef long long lol;
const lol mod=1e9+7;
int n,a,b,c;lol fac[N],inv[N];
IL lol C(int n,int m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
IL lol qpow(lol a,int b){lol res=1;while(b){if(b&1)res=res*a%mod;a=a*a%mod,b>>=1;}return res;}
IL lol f(int n,int m){
	if(!n)return m==0;
	return C(n+m-1,m)*inv[n]%mod;
}
int main(){
  scanf("%d%d%d%d",&n,&a,&b,&c);fac[0]=1;int x1,x2,x3,x4,S,up=n<<1,ans=0;
	if(b&1){printf("0");return 0;}
	REP(x1,1,up)fac[x1]=fac[x1-1]*x1%mod;inv[up]=qpow(fac[up],mod-2);
  PER(x1,up,1)inv[x1-1]=inv[x1]*x1%mod;
	x4=b>>1;
	for(x2=0;x2<=a&&x2<=c;x2++)
		for(x1=a-x2,S=c-x2,x3=0;S>=0;x3++,S-=3)
			ans=(ans+fac[x1+x2+x3+x4]*inv[x1]%mod*inv[x2]%mod*inv[x3]%mod*f(x4,S))%mod;
	printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a, b, c[ohara], d, tmp, tmpp, m, h, w, x, y, sum, pos, k, s[ohara], f[ohara];
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n;
    rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
    rep(i, n)
    {
        ll nowti = 0;
        rrep(j, i, n - 1)
        {
            if (nowti <= s[j])
                nowti = s[j];
            else
            {
                tmp = nowti / f[j];
                if (nowti % f[j] != 0)
                    tmp++;
                nowti = tmp * f[j];
            }
            nowti += c[j];
        }
        Cout(nowti);
    }
    return 0;
}


Measured memory_bytes: 4352
#include <cstdio>
#define N 200010
using namespace std;

int n, a[N], x[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for (int i = n; i; --i) {
		x[i] = a[i];
		for (int j = 2; j <= n / i; ++j)
			x[i] ^= x[i * j];
		if (x[i])
			++x[0];
	}
	printf("%d\n", x[0]);
	for (int i = 1; i <= n; ++i)
		if (x[i])
			printf("%d ", i);
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<si> vsi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vsi> vvsi;



// void dp(sp_1, sp_2.....)
// {
// 	if()//exit statement
// 	if()//using the memoization 
// 	ll ans = //default/dummy answerabc129_a.cpp
// 	//recursions
// 			//max/min
// 	return memo[][].. = ans;

// }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	cout.tie(NULL);
 	//memset(memo, -1, sizeof memo);
 	ll a[3], sum = 0;
 	ll maxo = -1;
 	for(int i = 0 ; i <3; i++)
 	{
 		cin>>a[i];
 		sum+=a[i];
 		maxo = max(a[i], maxo);
 	}
 	cout<<sum-maxo<<endl;
	return 0;
}

Measured memory_bytes: 256
s=str(input())

a=0
b=0

for i in range(len(s)):
    if i%2 == 0:
        if "L" in s[i]:
            a+=1

for i in range(len(s)):
    if i%2 != 0:
        if "R" in s[i]:
            b+=1


if a>0 or b>0:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007

int main()
{
    int a,p;
    cin >> a >> p;
    int ans=p/2;
    int num=p%2;
    num+=a*3;
    ans+=(num/2);
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll k;
    cin >> k;

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

    vector<int> b(2e5 + 1, -1), c(n, -1);
    for (int i = 0; i < n * 2; i++) {
        int &t = b[a[i % n]];
        if (0 <= t && t < n) {
            c[t] = i;
        }
        t = i;
    }

    vector<ll> e(n, -1);
    ll l = 0;
    ll nk = n * k;
    for (;;) {
        int i0 = l % n;
        if (e[i0] >= 0) {
            ll d = l - e[i0];
            //cout << d << ' ' << l << ' ' << e[i0] << endl;
            l += (nk - l) / d * d;
        }
        e[i0] = l;
        int i1 = c[i0];
        ll l1 = l + i1 - i0 + 1;
        if (l1 > nk) break;

        l = l1;
    }

    for (auto &i : b) {
        i = -1;
    }
    vector<int> s;
    for (int i = n - (int)(nk - l); i < n; i++) {
        if (b[a[i]] >= 0) {
            while (1) {
                int t = s.back();
                b[t] = -1;
                s.pop_back();
                if (t == a[i]) break;
            }
        } else {
            s.push_back(a[i]);
            b[a[i]] = 0;
        }
    }
    int m = (int)s.size();
    for (int i = 0; i < m; i++) {
        cout << s[i];
        if (i != m - 1) cout << ' ';
    }
    cout << endl;

    //sに同じ数が含まれることはない 相殺されるイメージ なんかヨッシーのたまごみたいな
    //はさまれた数はなかったことになるのでカウントしにくい
    //Aは2*10^5通りしかないのではさむパターンは列挙できる
    // 3 5 2 1 6 2 5
    //K周する中で最初の削除がいつになるか sに残ってたやつと反応するのが多そう そうでないとしてもあとで反応する可能性はある
    //最初がsに残ってたやつじゃない場合、初回ループと同じ場所で消えることになる だから何
    //それぞれのはさむパターンが何回現れるか
    //元のN*Kの長い数列を考える 
    // 1 2 3 2 1
    //数列の先頭は消える 1周目で消えるか、2周目の先頭で消える
    //1周目で消えたとき、sは空になる 2周目の先頭で消えたときも空になる
    //空になった直後の要素が消えるときもsは空になる
    //削除する区間は
    //sは常に元の数列の（連続とは限らない）部分列 長さは最大でもN
    //先頭の数はいつ消えるか 他の数に関係なく次に現れたとき
    //各Aについて次いつ自分と同じ数が現れるか求めておく

    return 0;
}

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

typedef long long ll;
ll mod = 1000000007;
ll dp[2001][2001];
ll sm[2001][2001];
bool vis[2001][2001];
bool vis_sm[2001][2001];

int main() {
  for(int i = 0; i <= 2000; i++) dp[i][1] = 1;
  for(int i = 0; i <= 2000; i++) sm[i][1] = dp[i][1] + (i == 0 ? 0 : sm[i - 1][1]);
  for(int i = 2; i <= 2000; i++) {
    for(int j = 0; j <= 2000; j++) {
      dp[j][i] = j == 0 ? 1 : sm[j][i - 1];
      sm[j][i] = ((j == 0 ? 0 : sm[j - 1][i]) + dp[j][i]) % mod;
    }
  }
  int S;
  cin >> S;
  ll ml = S / 3;
  ll ans = 0;
  for(int i = 1; i <= ml; i++) {
    ans = ans + dp[S - 3 * i][i];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 66176
n = int(input())
s = [0] * n
for i in range(n):
    s[i] = int(input())

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    s.sort()
    for i in range(n):
        if s[i] % 10 != 0:
            print(ans - s[i])
            exit()
        
    print(0)

Measured memory_bytes: 3060
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int A,B;cin>>A>>B;
  if(13 <= A) {
    p(B);
  } else if (6 <= A && A <= 12) {
    p(B/2);
  } else {
    p(0);
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

template<unsigned int N = 50>
struct Comb {
  long long c[N+1][N+1];

  constexpr Comb() noexcept : c() {
    for (size_t i = 0; i <= N; ++i) {
      for (size_t j = 0; j <= N; ++j) {
        if (j == 0 or j == i) c[i][j] = 1LL;
        else c[i][j] = c[i-1][j-1] + c[i-1][j];
      }
    }
  }
  constexpr long long comb(unsigned int n, unsigned int k) const noexcept {
    return c[n][k];
  }
};

int main() {
  int n, a, b; cin>>n>>a>>b;
  vector<long long> v(n);
  rep(i, n) cin>>v[i];
  sort(v.begin(), v.end(), greater<long long>());

  double ans = 0;
  rep(i, a) ans += v[i];
  cout<<fixed<<setprecision(10)<<ans/a<<endl;

  Comb<> mc;
  long long cnt = 0;
  int total = 0;
  rep(i, n) if (v[i] == v[a-1]) ++total;
  if (v[0] == v[a-1]) {
    int tmp = -1;
    REP(j, a, b+1) {
      int inner = 0;
      rep(i, n) if (v[i] == v[a-1] and i < j) ++inner;
      if (tmp != inner) {
        tmp = inner;
        cnt += mc.comb(total, inner);
      }
    }
  } else {
    int inner = 0;
    rep(i, n) if (v[i] == v[a-1] and i < a) ++inner; 
    cnt += mc.comb(total, inner);
  }
  print(cnt);

  return 0;
}


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

struct Move { int source, target; };

size_t solve(int N, vector<Move> moves)
{
    auto counts = vector<int>(N, 1);
    auto red_possible = vector<bool>(N);
    red_possible[0] = true;

    for (auto move : moves)
    {
        counts[move.source]--;
        counts[move.target]++;

        if (red_possible[move.source])
        {
            red_possible[move.target] = true;
            if (counts[move.source] == 0)
                red_possible[move.source] = false;
        }
    }

    return count(begin(red_possible), end(red_possible), true);
}

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

    auto moves = vector<Move>(M);
    for (auto i = 0; i < M; i++)
    {
        int x, y; scanf("%d %d", &x, &y);
        x--; y--;
        moves[i] = {x, y};
    }

    cout << solve(N, moves) << endl;
}




Measured memory_bytes: 2176
//B
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct node
{
	string s;
	int score;
	int id;
}a[110];
int comparison(const node &a,const node &b)
{
    if(a.s!=b.s) return a.s<b.s;
    else return a.score>b.score;
}
int main()
{
	int t;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].s;
		scanf("%d",&a[i].score);
		a[i].id=i;
	}
	
	sort(a+1,a+1+n,comparison);
	
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",a[i].id);
	}

	
}

Measured memory_bytes: 256
#include<cstdio>
#define min(a,b) ((a)<(b)? (a):(b))
#define max(a,b) ((a)>(b)? (a):(b))
int d[15][15],f[305][305];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(register int x=1;x<=n;++x) {
		for(register int y=1;y<=m;++y) {
			scanf("%d",&d[x][y]);
		}	
	}
	for(register int i=0;i<=100;++i) {
		for(register int j=0;j<=100;++j) {
			for(register int x=1;x<=n;++x) {
				for(register int y=1;y<=m;++y) {
					f[i][j]=max(f[i][j],d[x][y]-i*x-j*y);
				}
			}
			//if(f[i][j]>0) printf("%d ",f[i][j]);
		}
		//printf("\n");
	}
//	getchar();getchar();
	for(register int x=1;x<=n;++x) {
		for(register int y=1;y<=m;++y) {
			int minn=105;
			for(register int i=0;i<=100;++i) {
				for(register int j=0;j<=100;++j) {
					minn=min(minn,f[i][j]+i*x+j*y);
				}
			}
			if(minn!=d[x][y])  {printf("Impossible\n");return 0;}
		}
	}
	printf("Possible\n");
	printf("202 10401\n");
	for(register int x=1;x<=100;++x) printf("%d %d X\n",x,x+1);
	for(register int x=102;x<=201;++x) printf("%d %d Y\n",x,x+1);
	for(register int i=0;i<=100;++i) {
		for(register int j=0;j<=100;++j) {
			printf("%d %d %d\n",i+1,202-j,f[i][j]);
		}
	}
	printf("1 202\n");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
	string a;
	cin >> a;
	if(a[0]=='1'){
		cout<<"Hello World\n"<<endl;
	}
	else{
		int b,c,d;
		cin >> b;
		cin >> c;
		d=c+b;
		cout<< d <<endl;
	}
}


Measured memory_bytes: 256
#2:35

S = input()

lnum = list()
for i in range(len(S)-2):
    num = int(S[i:i+3])
    lnum.append(num)
    #print(num)

for i in range(len(lnum)):
    lnum[i] = abs(753 - lnum[i])

print(min(lnum))

Measured memory_bytes: 3060
X = int(input())
is_prime = [True] * (X + 1)
is_prime[1] = False
for i in range(2, X + 1):
    if not is_prime[i]:
        continue
    now = i
    while now + i <= X:
        now += i
        is_prime[now] = False
candidate = X
while True:
    candidate_prime = True
    for i in range(2, X + 1):
        if i ** 2 > X:
            break
        if not is_prime[i]:
            continue
        if candidate % i == 0:
            candidate_prime = False

    if candidate_prime:
        print(candidate)
        exit()
    else:
        candidate += 1


Measured memory_bytes: 3828
import numpy as np
N, W = map(int, input().split())
ndp = np.zeros(W+1, dtype= np.int64)
for _ in range(N):
    w, v = map(int,input().split())

    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    # 離散より連続で扱った方が簡単になる。
    np.maximum(ndp[:-w] + v, ndp[w:], out = ndp[w:])
print(ndp[-1])


Measured memory_bytes: 14612
import bisect

N,M,K=map(int,input().split())
list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))


totaltame_a=[0]
for a in list_a:
    temp_a=totaltame_a[-1]+a
    if temp_a>K:
        break
    else:
        totaltame_a.append(temp_a)


totaltime_b=[0]
for b in list_b:
    totaltime_b.append(totaltime_b[-1]+b)

ans=0

for i in range (len(totaltame_a)):
    Kb=K-totaltame_a[i]
    j=bisect.bisect_right(totaltime_b,Kb)-1
    if i+j>ans:
        ans=i+j
    else:
        pass

print(ans)

Measured memory_bytes: 40828
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	vector<int>v(3);
	for (int i = 0; i < 3; i++)cin >> v[i];
	sort(v.begin(), v.end());
	cout << v[2] * 10 + v[1] + v[0] << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
wList = []
for i in range(n):
    w = int(input())
    wList.append(w)
minP = max(wList)-1
maxP = sum(wList)
def countD(mid, wList):
    curr = 0
    count = 0
    for w in wList:
        if curr+w > mid:
            count+=1
            curr = w
        else:
            curr+=w
    if curr > 0:
        count+=1
    return count
while maxP - minP > 1:
    mid = (minP + maxP)//2
    days = countD(mid, wList)
    if days <= k:
        maxP = mid
    else:
        minP = mid
print(maxP)


Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int cnt = 0;
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> xy(n);

    REP(i, n)
    {
        int a;
        cin >> a;
        REP(j,a){
            pair<int, int> d;
            cin >> d.first >> d.second;
            d.first--;
            xy[i].push_back(d);
        }
    }

    uint S = pow(2, n) - 1;
    for (uint T = S;; T = (T - 1) & S)
    {
        vector<int> tc(n,0);
        vector<int> fc(n,0);
        if (T == 0)
        {
            break;
        }
        int onenum = 0;
        int ic = 0;
        bool flag = false;

        for (uint i = 1; i <= S; i *= 2)
        {
            if(i&T){
                onenum++;
                REP(j, xy[ic].size())
                {
                    if(xy[ic][j].second == 1){
                        if ( T & (uint)pow(2, xy[ic][j].first))
                        {

                        }
                        else{
                            flag = true;
                            break;
                        }
                    }
                    else{
                        if ( T & (uint)pow(2, xy[ic][j].first))
                        {
                            flag = true;
                            break;
                        }
                    }
                    if(flag){
                        break;
                    }
                }
            }
            ic++;
        }

        if(flag){
            continue;
        }

        cnt = max(cnt, onenum);

    }

    cout << cnt << endl;

    return 0;
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,a;
	cin>>n>>a;
	n%=500;
	if (n>a){
		cout<<"No";
	}
	else {
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
  static void Main(string[] args)
  {
    int price=int.Parse(Console.ReadLine());
    
    int index=1;
    while(index*1000<price)
    {
      index++;
    }
    
    int charge=index*1000-price;
    Console.WriteLine(charge);    
  }
}

Measured memory_bytes: 27544
import java.util.*;
import java.io.*;

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        long a = nextInt();
        long res = a + a * a + a * a * a;
        outln(res);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 33012
#include<stdio.h>
#include<stdlib.h>
int a[100005], b[100005];
int asca(const void* x, const void* y)
{
	return a[*(int*)x] - a[*(int*)y];
}
int ascb(const void* x, const void* y)
{
	return b[*(int*)x] - b[*(int*)y];
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int i;
	for (i = 0; i < n - 1; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		if (a[i] > b[i])
		{
			a[i] ^= b[i];
			b[i] ^= a[i];
			a[i] ^= b[i];
		}
	}
	long long int p = 1000000007;
	int c[100005], d[100005];
	for (i = 0; i < n - 1; i++)
		c[i] = d[i] = i;
	qsort(c, n - 1, sizeof(int), asca);
	qsort(d, n - 1, sizeof(int), ascb);
	long long int count[100005];
	for (i = 0; i < n + 2; i++)
		count[i] = 1;
	int m = 0, q[100005];
	q[m] = 1;
	m++;
	int min, mid, max;
	long long int ans = k;
	int visited[100005];
	for (i = 0; i < n + 2; i++)
		visited[i] = 0;
	int Q;
	while (m > 0)
	{
		m--;
		min = 0;
		max = n - 1;
		Q = q[m];
		visited[Q] = 1;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (a[c[mid]] < Q)
				min = mid;
			else
				max = mid;
		}
		if (a[c[min]] < Q)
			min++;
		if (min < n - 1)
		{
			while (a[c[min]] == Q)
			{
				if (visited[b[c[min]]] == 0)
				{
					if (count[Q] >= k)
					{
						printf("0\n");
						return 0;
					}
					ans *= k - count[Q];
					ans %= p;
					count[Q]++;
					count[b[c[min]]]++;
					q[m] = b[c[min]];
					m++;
					visited[b[c[min]]] = 1;
				}
				min++;
				if (min == n - 1)
					break;
			}
		}
		min = 0;
		max = n - 1;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (b[d[mid]] < Q)
				min = mid;
			else
				max = mid;
		}
		if (b[d[min]] < Q)
			min++;
		if (min < n - 1)
		{
			while (b[d[min]] == Q)
			{
				if (visited[a[d[min]]] == 0)
				{
					if (count[Q] >= k)
					{
						printf("0\n");
						return 0;
					}
					ans *= k - count[Q];
					ans %= p;
					count[Q]++;
					count[a[d[min]]]++;
					q[m] = a[d[min]];
					m++;
					visited[a[d[min]]] = 1;
				}
				min++;
				if (min == n - 1)
					break;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3728
import sys

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))

nchg=0
def merge(left, mid, right):
    global a, nchg
    i=0
    j=0
    ll = a[left:mid+1]
    rr = a[mid+1:right+1]
    n1 = mid-left+1
    n2 = right-mid
    while i<n1 or j<n2:
        if i==n1:
            a[left+i+j] = rr[j]
            j += 1
            nchg += n1-i
            continue
        if j==n2:
            a[left+i+j] = ll[i]
            i += 1
            continue
        if ll[i] <= rr[j]:
            a[left+i+j] = ll[i]
            i += 1
        else:
            a[left+i+j] = rr[j]
            nchg += n1-i
            j += 1


def mergesort(left, right):
    if right-left>0:
        mid=(left+right)//2
        mergesort(left, mid)
        mergesort(mid+1, right)
        merge(left, mid, right)


mergesort(0, n-1)
print(nchg)


Measured memory_bytes: 27592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
#define pi (acos(-1))
///#define for(i,a,b) for(i=(a);i<(b);++i)
///freopen("input.txt","r",stdin);
///   freopen("output.txt","w",stdout);
ll fre[500005];
ll a[500005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,k,l,m;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        fre[a[i]]++;
    }
    ll sum=0;
    for(i=1; i<=n; i++)
    {
        sum+=((fre[i])*(fre[i]-1))/2;
    }
    for(i=1; i<=n; i++)
    {
        ll kola=((fre[a[i]])*(fre[a[i]]-1))/2;
        ll res=sum-kola;
        res+=((fre[a[i]]-1)*(fre[a[i]]-2))/2;
        cout<<res<<"\n";
    }
    return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	string T;
	cin >> T;
	for (auto &c : T) {
		if (c == '?') c = 'D';
	}
	cout << T << endl;

	return 0;
}


Measured memory_bytes: 3744
N,M=map(int, input().split())
mod=1000000000+7
fact=[1]*100001
for i in range(100000):
    fact[i+1]=fact[i]*(i+1)%mod

if N==M:
    print((fact[N]*fact[M]*2)%mod)
elif abs(N-M)==1:
    print((fact[N]*fact[M])%mod)
else:
    print(0)


Measured memory_bytes: 6900
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;

#define INF 987654321
#define ll long long

int N, K;

int main()
{
	scanf("%d %d", &N, &K);
	if (K == 0) return !printf("%lld", (ll)N*N);
	
	ll res = 0;
	for (int i = K + 1; i <= N; i++) // mod
	{
		int val = N / i * (i - K) + max(0, N % i - K + 1);
		res += val;
	}
	printf("%lld", res);
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int aa,bb,m;
    cin>>aa>>bb>>m;
    vector<int> a(aa),b(bb);
    for (int i = 0; i < aa; i++)
    {
        cin>>a[i];
    }
    for (int i = 0; i < bb; i++)
    {
        cin>>b[i];
    }

    int amin=a[0],bmin=b[0];
    for (int i = 0; i < aa; i++)
    {
        amin=min(amin,a[i]);
    }
    for (int i = 0; i < bb; i++)
    {
        bmin=min(bmin,b[i]);
    }
    
    int ans=amin+bmin;
    for (int i = 0; i < m; i++)
    {
        int x,y,c;
        cin>>x>>y>>c;
        x--;
        y--;
        ans=min(ans,a[x]+b[y]-c);
    }
    cout<<ans<<endl;
    
    return 0;
}

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

signed main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

    int ans = 0;

    if(a.at(0) > x){
        ans += a.at(0) - x;
        a.at(0) = x;
    }

    for(int i = 1;i < n;i ++){
        int s = a.at(i-1) + a.at(i);
        if(s > x){
            ans += s - x;
            a.at(i) -= s - x;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

const int maxn = 2e5 + 5;
ll n, a[maxn], ans = 0;

int main() {
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n, greater<int>());
    ans = a[0];
    for (int i = 1; i < n / 2; i++) ans += a[i] * 2;
    if (n % 2) ans += a[n / 2];
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 5332
using System;
using System.Linq;

namespace _5
{
    class Program
    {
        static int n, x;
        static int[] a;
        static bool[,] vis;//solve[depth,sum]????¨??????????????????????????????°
        static bool[,] dp;//solve[depth,sum]??????
        public static bool solve(int depth, int sum)//depth=??±???,sum=???????????§???????¨?
        {
            if (depth == n)
            {
                return (sum == x);
            }
            if (sum > x)
            {
                return false;//sum???x????¶???????????????§?????????
            }
            bool ret = false;
            if (solve(depth + 1, sum + a[depth]) == true)
            {
                ret = true;//a[depth]????????¶??´???
            }
            if (solve(depth + 1, sum) == true)
            {
                ret = true;//a[depth]????????°????????´???
            }
            vis[depth, sum] = true;
            dp[depth, sum] = ret;
            return ret;
        }
        public static void Main()
        {
            n = int.Parse(Console.ReadLine());
            a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int q = int.Parse(Console.ReadLine());
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < q; i++)
            {
                x = b[i];
                vis = new bool[n, x + 1];
                dp = new bool[n, x + 1];
                bool ret = solve(0, 0);
                Console.WriteLine(ret ? "yes" : "no");
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9368
from heapq import heapify
from heapq import heappush as push
from heapq import heappop as pop
def solve():
  n=int(input())
  ans=0
  pos=[[] for _ in range(n)]
  neg=[[] for _ in range(n)]
  for _ in range(n):
    k,l,r=map(int,input().split())
    ans+=min(l,r)
    if l>r:
      pos[k-1].append(l-r)
    elif l<r and k<n:
      neg[k].append(r-l)
  q=[]
  heapify(q)
  for i in range(n):
    for j in pos[i]:
      push(q,j)
    while i+1<len(q):
      pop(q)
  while q:
    ans+=pop(q)
  for i in range(n-1,-1,-1):
    for j in neg[i]:
      push(q,j)
    while n-i<len(q):
      pop(q)
  while q:
    ans+=pop(q)
  print(ans)

def main():
  t=int(input())
  for _ in range(t):
    solve()

if __name__=='__main__':
  main()

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

bool is_prime(int64_t x) {
  for (int64_t i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}

void solve() {
  int x;
  cin >> x;
  while (!is_prime(x)) {
    ++x;
  }
  cout << x << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


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

using namespace std;

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

	if (s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

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

	int n;
	vector<int> w(110);
	cin>>n;
	for(int i =1;i<=n;i++)
		cin >> w[i];
	int t;
	int sum1;
	int sum2;
	int min;
	int j;
	for(int i = 1;i<=1;i++)
			sum1+=w[i];
		for(int j =2;j<=n;j++)
			sum2+=w[j];
		if(sum2>=sum1)
			min = sum2-sum1;
		else
			min = sum1-sum2;
		sum1=0;
		sum2=0;
	for(t = 2;t<=n;t++)
	{
		for(int i = 1;i<=t;i++)
			sum1+=w[i];
		for(int j =t+1;j<=n;j++)
			sum2+=w[j];
		if(sum2>=sum1)
			j = sum2-sum1;
		else
			j = sum1-sum2;
		if(j<min)
			min =j;
		sum1=0;
		sum2=0;
	}
	cout << min<<endl;
	return 0;
}

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

int main(){
  int n,m,count=0;
  cin >> n >> m;
  bool flag=false;
  vector<vector<char>> a(n,vector<char>(n,0));
  vector<vector<char>> b(m,vector<char>(m,0));
  r(i,n){
    r(j,n)cin >> a.at(i).at(j);
  }
  r(i,m){
    r(j,m)cin >> b.at(i).at(j);
  }
  r(i,n-m+1){
    r(j,n-m+1){
      r(k,m){
        r(l,m){
          if(a.at(i+k).at(j+l)==b.at(k).at(l))count++;
        }
      }
      if(count==m*m)flag=true;
      else count=0;
    }
  }
  if(flag)cout << "Yes"<<endl;
  else cout << "No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=5000010;

ll fac[N];

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x;}
    if(n%2==0){
        return power((x*x)%M,n/2);
    }
    if(n%2==1){
        return (power((x*x)%M,n/2)*x)%M;
    }
}

ll ncr(ll n,ll r)
{
    ll num=fac[n];
    ll denum=(fac[r]*fac[n-r])%M;
    ll ans=(num*power(denum,M-2))%M;
    return ans;
}

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

    fac[0]=1;
    for(ll i=1;i<N;++i){
        fac[i]=(i*fac[i-1])%M;
    }

    ll r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    ++r1;++c1;++r2;++c2;
    ll ans=0;
    for(ll i=r1;i<=r2;++i)
    {
        ll ch=( ncr(i+c2-1,i) - ncr(i+c1-2,i) + M)%M;
        ans=(ans+ch)%M;
    }
    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 39296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
  int n,t,mina=1000000000,a,cnt=0,mindiff=0,diff=0;
  cin>>n>>t;
  for(int i=0;i<n;i++){
      cin>>a;
      diff=a-mina;
      if(diff==mindiff){
          cnt++;
      }
      if(diff>mindiff){
        mindiff=diff;
        cnt=1;
      }
      if(mina>a)
        mina=a;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <map>
#include <regex>
#include <sstream>
#include <utility>
#include <list>
#include <unordered_set>
#include <unordered_map>
#define endl   '\n'
#define MOD 1000000

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
int dy[] = { 0,1,-1,0 };
int dx[] = { 1,0,0,-1 };
int dz[] = { 0,0,1,-1 };

int gcd(int a, int b) {
	return (a%b ? gcd(b, a%b) : b);
}
/*
struct tt {
	int to, w;
	bool operator<(const tt &r) const {
		return w > r.w;
	}
};
*/

struct ss {
	int y, x;
};

int n, m;

bool range(int y, int x) {
	return !(y < 0 || y >= n || x < 0 || x >= m);
}

struct tt {
	int to, num;
};

vector<tt> v[100001];
int color[100001];

void sol(int prev_color, int cur) {
	int cur_color = 1;
	for (tt& tmp : v[cur]) {
		if (cur_color == prev_color) cur_color += 1;
		color[tmp.num] = cur_color;
		sol(cur_color, tmp.to);
		cur_color += 1;
	}
	m = max(m, cur_color);
}

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

	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		v[a].push_back({b, i});
	}

	sol(0, 1);

	cout << m - 1 << endl;
	for (int i = 0; i < n - 1; i++) {
		cout << color[i] << endl;
	}


	
}




Measured memory_bytes: 7552
n, m = gets.chop.split.map(&:to_i)
ps, ys = [], []
arr = []
m.times do |i|
    line = gets.chop.split.map(&:to_i)
    arr << {p: line[0], y: line[1], i: i, ans: ''}
    # ps << line[0]
    # ys << line[1]
end
arr.sort! do |a, b|
    a[:y] <=> b[:y]
  end


counts = Array.new(1000000, 1)
m.times do |i|
    arr[i][:ans] = format('%06d', arr[i][:p]) + format('%06d', counts[arr[i][:p]])
    counts[arr[i][:p]] += 1
end
arr.sort! do |a, b|
    a[:i] <=> b[:i]
  end

m.times do |i|
    puts arr[i][:ans]
end

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int x,y; cin>>x>>y;
	bool yes=false;
	for(int i=x;i>=0;--i){
		if(i*2+(x-i)*4==y)yes=true;
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>
 
int main(void){
    int a,b,c,i,ans = 0;
    scanf("%d %d",&a,&b);
    
    if (b == 100){
        c = b + a * 1000;
    }else if (b>9&&b<100){
        c = b + a * 100;
    }else{
        c = b + a * 10;
    }
    
    int j = sqrt(c);
    
    if (j*j == c) ans = 1;
    
    if (ans == 1){
        puts("Yes"); 
    }else{
        puts("No");
    }
    
    return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    int Xor=0;
    for(auto &x:v){
        cin>>x;
        Xor^=x;
    }
    for(auto x:v){
        cout<<(Xor^x)<<" ";
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	if (n == 0)cout << 1 << endl;
	if (n == 1)cout << 2 << endl;
	if (n == 2)cout << 1 << endl;
	if (n >= 3)cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3096
ans (xa1:ya1:xa2:ya2:xb1:yb1:xb2:yb2:_) =
  if (yb1 > ya2 || yb2 < ya1) || (xb2 < xa1 || xb1 > xa2)
  then "NO"
  else "YES"

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Double]]
      o = map ans i
  mapM_ putStrLn o
  

Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int n;
    cin>>n;
    set<string> s;
    for(int i=0;i<n;i++){string S;cin>>S;s.insert(S);}
    cout<<s.size()<<endl;
}


Measured memory_bytes: 19256
#include<iostream>
using namespace std;
int main()
{
	int N;
  	int flag=0;
  	cin>>N;
  	for(int i=0;i<3;i++)
    {
    	int remainder=N%10;
      	if(remainder==7)
        {
        	flag=1;
        }
      	N=N/10;
    }
  	if(flag==1)
    {
    	cout<<"Yes"<<endl;
    }
  	else
    {
    	cout<<"No"<<endl;
    }
	return 0;
}

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

          using namespace std;
          typedef long long ll;
          int n, a[222222];
          ll s;
          map<int, ll> m, p; 
          set<int> q;
          int ar[32332];
          int main()
          {
            cin >> n;
            for(int i = 1; i <= n; i++)
            {
              cin >> a[i];
              m[a[i]]++;
              q.insert(a[i]);
            }
            for(auto it : q)
            {
              ll k = m[it]-1;
              p[it] = ((1+k)*k/2);  
            }
            for(auto id : q)
              s += p[id];
            for(int i = 1; i <= n; i++)
            {
              cout << s - (m[a[i]]-1) << '\n';
            }    
          }

Measured memory_bytes: 24064
MOD = 10**9+7

n = int(input())

def get_primes(n_max):
    count = 0
    ps = [2, 3]

    for n in range(5, n_max+1, 2):
        is_p = True
        for i in range(1, len(ps)):
            count += 1
            if ps[i]**2 > n:
                break
            count += 1
            if n%ps[i] == 0:
                is_p = False
                break
        if is_p:
            ps.append(n)
    return ps
            
primes = get_primes(n)
p_dict = dict(zip(primes, [0]*len(primes)))
ns = [i for i in range(n+1)]
for i in range(2, n+1):
    p = ns[i]
    if p == 1: continue
    p_dict[p] += n//i
    for j in range(i, n+1, i):
        ns[j] = ns[j]//p

# print(p_dict)
ans = 1
for key, item in p_dict.items():
    ans = ans*(item+1)%MOD
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#define llint long long

using namespace std;

struct Node{
	int valid;
	unordered_map<int, int> next;
	Node(){
		valid = 0;
	}
};

int N, Q;
string S[100005];
vector<Node> trie;
int num[400005][26];

void compress(int p)
{
	for(auto it = trie[p].next.begin(); it != trie[p].next.end(); it++){
		int q = it->second;
		while(trie[q].valid == 0 && trie[q].next.size() == 1){
			q = trie[q].next.begin()->second;
		}
		it->second = q;
		compress(it->second);
	}
}

int numdfs(int v)
{
	int ret = 0;
	for(auto it = trie[v].next.begin(); it != trie[v].next.end(); it++){
		num[v][it->first] = numdfs(it->second);
		ret += num[v][it->first];
	}
	if(trie[v].valid) ret++;
	return ret;
}

string tmp;
void modifydfs(int v)
{
	if(trie[v].valid) S[trie[v].valid] = tmp;
	for(auto it = trie[v].next.begin(); it != trie[v].next.end(); it++){
		tmp += it->first + 'a';
		modifydfs(it->second);
		tmp.pop_back();
	}
}

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> S[i];
	
	trie.push_back(Node());
	for(int i = 1; i <= N; i++){
		int p = 0;
		for(int j = 0; j < S[i].size(); j++){
			if(!trie[p].next.count(S[i][j]-'a')){
				trie.push_back(Node());
				trie[p].next[S[i][j]-'a'] = trie.size()-1;
			}
			p = trie[p].next[S[i][j]-'a'];
		}
		trie[p].valid = i;
	}
	
	int q = 0;
	if(trie[0].next.size() == 1){
		q = trie[0].next.begin()->second;
		while(trie[q].valid == 0 && trie[q].next.size() == 1){
			q = trie[q].next.begin()->second;
		}
		trie[0].next.begin()->second = q;
	}
	compress(q);
	
	modifydfs(0);
	numdfs(0);
	
	cin >> Q;
	for(int q = 0; q < Q; q++){
		int k; string s;
		cin >> k >> s;
		
		int order[26];
		for(int i = 0; i < s.size(); i++){
			order[s[i]-'a'] = i;
		}
		
		int p = 0, ans = 0;
		for(int i = 0; i < S[k].size(); i++){
			if(trie[p].valid) ans++;
			for(auto it = trie[p].next.begin(); it != trie[p].next.end(); it++){
				if(order[it->first] < order[S[k][i]-'a']) ans += num[p][it->first];
			}
			p = trie[p].next[S[k][i]-'a'];
		}
		ans++;
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 91876
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,m;
vector<P> ans;

void solve(){
    cin >> n >> m;
    //int l=(m+1)/2;
    for(int i=m;i>=1;i-=1){
        if(m-i>=i) break;
        ans.emplace_back(m-i,i); 
    }
    for(int i=m-1;i>=1;i-=1){
        if(2*m-i>=m+1+i) break;
        ans.emplace_back(2*m-i,m+1+i);
    }
    rep(i,m){
        cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 4188
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	t /= a;
	t *= b;
	cout << t;
	return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;


class Main {
	
	static Scanner scan = new Scanner(System.in);
	static int lim = 1000000007;
	static long[] dp; 
	public static void main(String[] args) {
		int t = 1;
		while(t-->0) {
			int N = scan.nextInt(); long[] arr = new long[N]; dp = new long[N];
			for(int i=0; i<N; i++) {arr[i] = scan.nextLong(); } Arrays.fill(dp,0);
			dp[N-1] = 0; dp[N-2] = Math.abs(arr[N-1]-arr[N-2]);
			for(int i=N-3; i>=0; i--) {
				dp[i] = Math.min(dp[i+1]+Math.abs(arr[i]-arr[i+1]), dp[i+2]+Math.abs(arr[i]-arr[i+2]));
			}
			
			System.out.println(dp[0]);
			
		}
		 
	}
	
	
	

}


Measured memory_bytes: 50804