akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mp make_pair

void solve_case()
{
    int n,x,i,j;
    cin >> x >> n;
    set<int> st;
    for(i=0; i<n; i++)
    {
        cin >> j;
        st.insert(j);
    }
    pair<int,int> ans = mp(1e9,1e9);
    for(i=-200; i<205; i++)
    {
        if(st.count(i)) continue;
        if(abs(i-x)<=ans.first)
        {
            ans = min(ans, mp(abs(i-x),i));
        }
    }
    cout << ans.second << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    int T = 1;
    //cin >> T;
    while(T--)
    {
        solve_case();
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int D,G; cin >> D >> G;
    int p[D],c[D]; rep(i,D) cin >> p[i] >> c[i];
    int ans=999999999;
    for(int i=0; i<(1<<D); i++){
        int mr=0,mrn=0; int sum=0;int cnt=0;
        rep(j,D){
            if((i>>j)&1){
                sum+=p[j]*100*(j+1)+c[j]; cnt+=p[j];
            }
            else{mr=100*(j+1); mrn=p[j];}
        }
        if(sum>=G) ans=min(ans,cnt);
        else if(G-sum<=(mrn-1)*mr){
            ans=min(ans,cnt+(G-sum+mr-1)/mr);
        }
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    int N,M;
    cin >> N >> M;
    char A[50][50],B[50][50];
    for(int i=0;i<N;++i){
     for(int j=0;j<N;++j){
     cin >> A[i][j];   
        }   
    }
    
    for(int i=0;i<M;++i){
     for(int j=0;j<M;++j){
     cin >> B[i][j];   
        }   
    }
    bool exist=false;
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(i+M-1>=N || j+M-1>=N) continue;

            bool match=true;
            for(int k=0;k<M;++k){
                for(int l=0;l<M;++l){
                    if(A[i+k][j+l]!=B[k][l]) match=false;
                }
            }
            if(match)exist=true;
        }
    }
    if(exist)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T, Ans;
  int N;
  
  cin >> N >> S >> T;
  
  for(int i = 0; i < N; i++){
    Ans = Ans + S[i] + T[i];
  }
  
  cout << Ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    a--;b--;

    cout << a * b << endl;

}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
vector<vector<int> > g;
vector<int> dp;
int dfs(int root)
{
    if(dp[root] != -1)
        return dp[root];
    for(int i=0;i<g[root].size();i++)
    {
        int u = g[root][i];
        int x = dfs(u);
        if(dp[u] == -1)
            dp[root] = max(dp[root],1+x);
        else
            dp[root] = max(dp[root],1+dp[u]);
    }
    if(dp[root] == -1)
        dp[root] = 0;
    return dp[root];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    g.resize(n+1);
    dp.resize(n+1,-1);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
    }
    for(int i=1;i<=n;i++)
        g[0].pb(i);
    int ans = dfs(0);
    cout<<ans-1;
    
    return 0;
}

Measured memory_bytes: 8696
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int d[n];
  for(int i = 0; i < n; i++){
    scanf("%d", &d[i]);
  }
  int sum = 0;
  int sq = 0;
  for(int i = 0; i < n; i++){
    sum += d[i];
    sq += d[i] * d[i];
  }
  printf("%d\n", (sum * sum - sq) / 2);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  vl A;
  char C;
  cin >> C;
  cout << (char)(C + 1) << endl;
  return 0;
}


Measured memory_bytes: 764
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

s = sr()
t = sr()
n = len(s)
flag = True
for i in range(n):
    flag = True
    for j in range(i,i+n):
        if s[j%n] != t[j-i]:
            flag = False
            break
    if flag:
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 76920
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
		
      	int a = scan.nextInt();
      	int b = scan.nextInt();

      if(b == 1){
       	System.out.println(0);
		return; 
      }
      
      if(a >= b){
        
        System.out.println(1);
		return;
      }
      
      a = a - 1;
      b = b - 1;
      
       double rlt2 = Math.ceil((double)b / a);

            	System.out.println((int)rlt2);
    }
}


Measured memory_bytes: 23252
import sys
X,N=map(int, sys.stdin.readline().split())
P=map(int, sys.stdin.readline().split())

L=[ 0 for _ in range(202) ]

for p in P:
    L[p]=1

kyori=float("inf")
ans=None
for i,x in enumerate(L):
    if x==0:
        new_kyori=abs(i-X)
        if new_kyori<kyori:
            ans=i
            kyori=new_kyori
print ans

Measured memory_bytes: 64364
#include<iostream>
using namespace std;
int main()
{
    int arr[21];
    int n,mx=-1,mx2=-1,cnt=1,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(i=1;i<n;i++)
    {
        if(arr[i]>mx2)
            mx2=arr[i];
        if(arr[i]>=arr[0]&& arr[i]>=mx2)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD = 1e9 + 7;
LL mpower(LL a, int n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans *= a;
      ans %= MOD;
    }
    a *= a % MOD;
    a %= MOD;
    n >>= 1;
  }
  return ans % MOD;
}
int main() {
  int n, m;
  cin >> m >> n;
  cout << mpower(m, n) << endl;

  return 0;
}


Measured memory_bytes: 3136
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if n >= m:
  print(0)
else:
  d = [x[i+1]-x[i] for i in range(m-1)]
  d.sort(reverse=True)
  print(x[-1]-x[0]-sum(d[:n-1]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n;
    cin >> n;
    vector<pair<Int, Int>> v(n);
    for (Int i = 0; i < n; i++) {
        Int a, b;
        cin >> a >> b;
        v[i].fi = b;
        v[i].se = a;
    }
    sort(v.begin(), v.end());
    Int time = 0;
    for (Int i = 0; i < n; i++) {
        time += v[i].se;
        if (time > v[i].fi) {
            dump("No");
            return 0;
        }
    }
    dump("Yes");
    return 0;
}

Measured memory_bytes: 3328
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i =0;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long int ll;
int main(){
  int n;cin >>n;vector<ll> x(n),y(n),z(n),w(n);
  rep(i,n) cin >> x[i] >> y[i];
  rep(i,n){
    z[i]=x[i]+y[i];w[i] = x[i]-y[i];
  }sort(ALL(z));sort(ALL(w));
  cout << max(z[n-1]-z[0],w[n-1]-w[0])<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a, 0, sizeof(a))
#define sqr(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int mn = 1e5 + 5;
const int mod = 1e9 + 7;
#define P mod

int n,m;
int a[mn];
struct edge{
    int u,v,w;
    bool operator < (const edge &p) const{
        return w<p.w;
    }
}e[mn];

namespace dsu{
    int f[mn];
    ll sz[mn]; // 点权和
    int esz[mn]; // 边数
    void init(int n){
        for(int i=1;i<=n;i++) f[i]=i,sz[i]=a[i],esz[i]=0;
    }
    int sf(int x){
        if (f[x]==x) return x;
        if (sf(f[x])!=f[x]){
            f[x]=sf(f[x]);
        }
        return f[x];
    }
    void Union(int u,int v){
        u=sf(u),v=sf(v);
        if (u!=v){
            f[u]=v;
            sz[v]+=sz[u];
            esz[v]+=esz[u];
            sz[u]=esz[u]=0;
        }
        esz[v]++;
    }
}
using namespace dsu;

int main() {
#ifdef LOCAL
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
    }
    sort(e+1,e+m+1);
    init(n);
    int ans=m;
    for(int i=1;i<=m;i++){
        Union(e[i].u,e[i].v);
        int u=sf(e[i].u);
        if (sz[u]>=e[i].w) ans-=esz[u],esz[u]=0;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef print
#define print(...)
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
//const int mod=998244353;
const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }
int powm(int a, int b) { int res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }

int a[100007];
const int N = 1e5 + 5;
int seg[200020];
void build() {
	for (int i = 0; i < N; ++i) 
		seg[i + N] = a[i];
	for (int i = N - 1; i > 0; --i)
		seg[i] = seg[2 * i] + seg[2 * i + 1];
}

int query(int l, int r) {
	r++;
	int ans = 0;
	for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
		if (l & 1) ans += seg[l++];
		if (r & 1) ans += seg[--r];
	}
	return ans;
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int m; cin >> m;
	int v; cin >> v; v--;
	int p; cin >> p; p--;
	v -= p;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	int cnt = p + 1;
	build();
	for (int i = p + 1; i < n; ++i) {
		v -= (n - 1 - (i + 1) + 1);
		int vv = max(v, 0LL);
		a[i] += m;
		if (a[i] >= a[p]) {
			int ex = (i - p);
			int su = (ex - 1) * (a[i]) + (a[i] + 1) - query(p, i - 1);
			su -= vv * m;
			cnt += (su > 0);
		} 
		a[i] -= m;
		v += (n - 1 - (i + 1) + 1);
	}
	cout << cnt << '\n';
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n; cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  rep(i,n){cin>>v[i];}
  rep(i,n){cin>>c[i];}
  int ans=0;
  rep(i,n){
    if(v[i]-c[i]>0){ ans += v[i]-c[i]; }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int k,s;
    cin >> k >> s;
    
    int count = 0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z = s - (x+y);
            if(0<=z and z<=k){
                count++;
            }
        }
    }
    
    cout << count;
}


Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) dump(c);
	if (a == c) dump(b);
	if (c == b) dump(a);
}

Measured memory_bytes: 256
use proconio::*;

fn run() {
    input! {
        n: usize,
        a: u64,
        b: u64,
        p: [usize; n],
    }
    let inf = 10u64.pow(9) * 5000 + 1;
    let mut dp = vec![inf; n + 1];
    dp[0] = 0;
    for p in p {
        dp[p] = *dp.iter().take(p).min().unwrap();
        for dp in dp.iter_mut().take(p) {
            *dp += a;
        }
        for dp in dp.iter_mut().skip(p + 1) {
            *dp += b;
        }
    }
    let ans = dp.into_iter().min().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2292
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <ctime>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
 
int n, m, p;
vector<int> et[2500];
vector<int> ec[2500];
vector<int> rEt[2500];
bool visitG[2500];
int dist[2500];
queue<int> que;
 
signed main() {
	int i, j;
	
	cin >> n >> m >> p;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		et[a].push_back(b);
		ec[a].push_back(p - c);
		rEt[b].push_back(a);
	}
	
	que.push(n - 1);
	visitG[n - 1] = true;
	while (!que.empty()) {
		int v = que.front(); que.pop();
		rep(i, rEt[v].size()) {
			int nv = rEt[v][i];
			if (visitG[nv] == false) {
				que.push(nv);
				visitG[nv] = true;
			}
		}
	}
	if (visitG[0] == false) { cout << -1 << endl; return 0; }	//ゲームを終了できない
	
	int INF = 1e+12;
	rep(i, n) dist[i] = INF;
	
	que.push(0);
	dist[0] = 0;
	
	clock_t st = clock();
	int loopCnt = 0;
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		rep(i, et[v].size()) {
			int nv = et[v][i];
			if (visitG[nv] == false) continue;
			if (dist[nv] > dist[v] + ec[v][i]) {
				dist[nv] = dist[v] + ec[v][i];
				que.push(nv);
			}
		}
		
		loopCnt++;
		if (loopCnt % 20000 == 0) {
			clock_t ed = clock();
			if ((double)(ed - st) / CLOCKS_PER_SEC > 1.500) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	
	int ans = max(0LL, -dist[n - 1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 72988
using System;
using System.Collections.Generic;

namespace _0044
{
    class Programｓ
    {
        readonly static int MAX_NUMBER = 50022;

        static void Main(string[] args)
        {
            List<int> primeList = new List<int>();
            for (int i = 1; i < MAX_NUMBER; i++)
            {
                if (IsPrime(i))
                {
                    primeList.Add(i);
                }
            }

            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
                int number = int.Parse(input);
                int previousPrimeNumber = 0;
                int nextPrimeNumber = 0;

                foreach (var primeNumber in primeList)
                {
                    if (primeNumber < number)
                    {
                        previousPrimeNumber = primeNumber;
                    }
                    else if (primeNumber > number)
                    {
                        nextPrimeNumber = primeNumber;
                    }

                    if (nextPrimeNumber != 0)
                    {
                        break;
                    }
                }
                Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber);
            }
        }

        static bool IsPrime(int number)
        {
            if (number <= 1)
            {
                return false;
            }
            else if (number <= 3)
            {
                return true;
            }
            else if ((number % 2) == 0)
            {
                return false;
            }
            else
            {
                for (int i = 3; i <= (int)Math.Sqrt(number); i += 2)
                {
                    if (number % i == 0)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
    }
}



/*
 * 
 * ・最小の素数 2
 * ・最大の素数 50022
 * 
 */

Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 100001;
ll n;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	vector<ll> dp;
	dp.resize(N);
	FILV(dp,INF);
	FOR(i,0,N){
		dp[i]=i;
	}
	FOR(i,0,N){
		ll k=6;
		if(i!=0)dp[i]=min(dp[i],dp[i-1]+1);
		while(i+k<N){
			dp[i+k]=min(dp[i]+1,dp[i+k]);
			k*=6;
		}
		k=9;
		while(i+k<N){
			dp[i+k]=min(dp[i]+1,dp[i+k]);
			k*=9;
		}
	}
	cout<<dp[n]<<endl;

	return 0;
}

Measured memory_bytes: 1024
/*input
1 100000
1000000000
*/
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define T int t;cin>>t;while(t--)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define umi unordered_map<int,int>
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int> >
#define inp(n) for(int i=0;i<n;i++)
#define N 2000005

using namespace std;
using namespace std::chrono;


signed main(){
    int n,m,ans=0;
    cin>>n>>m;
    vi v(n);
    maxheap pq;
    for(int &x:v){
        cin>>x;
        pq.push(x);
    }
    loop(i,0,m){
        int x = pq.top();
        pq.pop();
        pq.push(x/2);
    }
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<"\n";
}


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

using namespace std;

typedef long long ll;
typedef long long int lli;

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

int main(){

	fast_io();
	//code starts here
	
	string s;
	cin >> s;
	
	int n = s.size();
	
	if(s[n-1] == 's'){
		cout << s << "es" << endl;
	} else {
		cout << s << "s" << endl;
	}

	return 0;

}



Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Long l = 1L;
		for(int i = 1; i <= n; i++) {
			l=l*i%1000000007;
		}
		System.out.println(l);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

// Initialize with std::iota(parent, parent+n+1, 0), std::fill(sz, sz+n+1, 1), std::fill(rank, rank+n+1, 0);

const int N = 1e5+1, M = 1e5+1; // Upper bound for n

int parent[N];
int n, m, p[N];
pii s[N];

// Uses path compression
int find(int x) {return parent[x] = (x == parent[x] ? x : find(parent[x]));}

bool disjoint(int x, int y) {return find(x) != find(y);}

void join(int x, int y) {
	if (!disjoint(x, y)) return;
	int newPar = find(x), newChild = find(y);
	parent[newChild] = newPar;
}

int main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n >> m;
    std::iota(parent, parent+n+1, 0);
    FOR(i, 1, n) cin >> p[i];
    REP(i, m) cin >> s[i].first >> s[i].second;
    REP(i, m) join(s[i].first, s[i].second);
    int ans = 0;
    FOR(i, 1, n) if(!disjoint(i, p[i])) ++ans;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
	int mo[10];
	int temp = 0;
	int i;

	for(i = 0;i <= 9;i++){
		scanf("%d", &mo[i]);
	}

	int j;

	for(i = 0;i <= 9;i++){
		for(j = i+1; j <= 9;++j){
			if(mo[i] < mo[j]){
		 		temp = mo[i];
				mo[i] = mo[j];
				mo[j] = temp;
			}
		}
	}

	for(i = 0;i <= 2;i++){
		printf("%d\n", mo[i]);
	}

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a, b, flag(1), i(1), res;
    cin >> a >> b;
    while (flag) {
      if (int(i * 0.08) == a and int(i * 0.1) == b) {
        flag = 0;
        res = i;
        break;
      }
      else if (int(i * 0.08) > a or int(i * 0.1) > b) {
        flag = 0;
        res = -1;
        break;
      }
      i++;
    }
  	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

l = [int(input()) for _ in range(5)]
k = int(input())

for i in range(5):
    for j in range(i + 1, 5):
        if abs(l[i] - l[j]) > k:
            print(":(")
            exit()
print("Yay!")

Measured memory_bytes: 21444
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const double pi = 3.14159265;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int n;
    string s;
    cin >> n >> s;
    int E[300005] = {}, W[300005] = {};
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            if (s[i] == 'E')E[0] = 1;
            else W[0] = 1;
        }
        else {
            if (s[i] == 'E') {
                E[i] = E[i - 1] + 1;
                W[i] = W[i - 1];
            }
            else {
                E[i] = E[i - 1];
                W[i] = W[i - 1] + 1;
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < n; i++) {
        int t = 0;
        if (i == 0) {
            t += E[n - 1] - E[i];
        }
        else if(i == n-1) {
            t += W[n - 2];
        }
        else {
            t += W[i] + E[n - 1] - E[i];
        }
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3076
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
ab = [tuple(map(int, readline().split())) for _ in range(n)]
ab.sort()
for a, b in ab:
    k -= b
    if k <= 0:
        print(a)
        break


Measured memory_bytes: 16980
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main {
 
    private static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
 
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                for(int row = 0; row < H; row++){
                    for(int col = 0; col < W; col++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }
 
                System.out.printf("\n");
 
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 60688
n = gets.to_i
a = gets.split.map(&:to_i)

each_sum = Array.new(n+1, 0)
a.each_with_index do |a_v, index|
  each_sum[index + 1] = a_v + each_sum[index]
end

val = {}
each_sum.each do |x|
  val[x] ||= 0
  val[x] += 1
end

ans = 0
val.each do |_, v|
  ans += (v * (v - 1)) / 2
end

puts ans


Measured memory_bytes: 39036
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;

std::vector<int>dp (100001, -1);
int dpx(
  std::map<int, std::vector<int> >& in,
  int n) {
  if (dp[n] != -1) {
    return dp[n];
  }
  dp[n] = 0;
  for (const auto& i : in[n]) {
    dp[n] = std::max(dp[n], dpx(in, i) + 1);
  }
  return dp[n];
}

void once() {
  int n, m;
  std::cin >> n >> m;
  std::map<int, std::vector<int> > in;
  for (int i = 0; i < m; ++i) {
    int a, b;
    std::cin >> a >> b;
    in[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = std::max(ans, dpx(in, i));
  }

  std::cout << ans << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 20608
import itertools as it
    
n = int(input())
A = sorted(list(map(int, input().split())))
q = int(input())
m = list(map(int, input().split()))

s = set()

for i in range(n):
    li= list(it.combinations(A, i+1))
    for j in range(len(li)):
        s.add(sum(li[j]))

for k in range(q):
    print('yes' if m[k] in s else 'no')

Measured memory_bytes: 58120
n=int(input())
lists=list(map(int,input().split()))
uselist=[]
for i in range(n):
    a=(lists[i],i+1)
    uselist.append(a)
uselist.sort(key=lambda x: x[0])
anslist=[]
for j in range(n):
    anslist.append(uselist[j][1])
print(*anslist)

Measured memory_bytes: 20508
import bisect


def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    B = sorted(map(int, input().split()))
    C = sorted(map(int, input().split()))

    ans = 0
    for i in range(N):
        b = B[i]
        ia = bisect.bisect_left(A, b)
        ic = bisect.bisect_right(C, b)
        # print(b, ia, ic)

        ans += (N-ic)*ia
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 22720
from sys import stdin

h, n = map(int, stdin.readline().split())
attack = [None] * n
cost = [None] * n
for i in range(n):
    a, c = map(int, stdin.readline().split())
    attack[i] = a
    cost[i] = c
dp = [0] + [float('inf')] * h
for i in range(1, h + 1):
    for j in range(n):
        dp[i] = min(dp[i], cost[j] + dp[max(0, i - attack[j])])
print(dp[h])

Measured memory_bytes: 42220
#include <stdio.h>
#include <stdlib.h>

int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main(){
	int N,*arr,*save;
	scanf("%d",&N);
	arr=malloc(sizeof(int)*N);
	save=malloc(sizeof(int)*N);
	for(int i=0;i<N;i++){
		scanf("%d",&arr[i]);
		save[i]=arr[i];
	}
	qsort(arr,N,sizeof(int),cmpfunc);
	for(int i=0;i<N;i++)
	{
		if(save[i]<=arr[N/2-1])	printf("%d\n",arr[N/2]);
		else printf("%d\n",arr[N/2-1]);
	}	
	return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long M){
	if (N == M) cout << "Yes" << endl; else cout << "No" << endl;
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	solve(N, M);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
main()
{
	string s;
	cin>>s;
	if(s=="Sunny")
	{
		cout<<"Cloudy"<<endl;
	}
	else if(s=="Cloudy")
	{
		cout<<"Rainy"<<endl;
	}
	else if(s=="Rainy")
	{
		cout<<"Sunny"<<endl;
	}
}


Measured memory_bytes: 3492
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int M = 2019;

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    string S;
    cin >> S;
    int N = int(S.size());

    vector<int> freq(M, 0);
    freq[0] = 1;

    int value = 0, p10 = 1;
    int64_t total = 0;

    for (int i = N - 1; i >= 0; i--) {
        value = (value + p10 * (S[i] - '0')) % M;
        p10 = 10 * p10 % M;
        total += freq[value];
        freq[value]++;
    }

    cout << total << '\n';
}


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

int main() {
  int input_s, tmp;
  int h, m, s;
  cin >> input_s;

  s = input_s % 60;
  tmp = input_s / 60;
  m = tmp % 60;
  h = tmp / 60;

  cout << h << ':' << m << ':' << s << endl;

  return 0;
}


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

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
 int n,a;
 cin >> n >> a;
 if (n % 500 <= a){
   cout << "Yes\n";
 }
 else{
   cout << "No\n";
 }
  return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)

def inv(x):
    return pow(x, mod - 2, mod)

# 1回だけの場合
def comb(n, b):
    if b > n - b:
        b = n - b
    r = 1
    for k in range(n, n-b, -1):
        r = r * k % mod
    d = 1
    for k in range(1, b+1):
        d = d * k % mod
    return r * inv(d) % mod

def main():
    n,m,k = LI()

    r = comb(n*m,k)
    cc = comb(n*m,2)
    tt = 0
    m2 = m * m
    n2 = n * n
    for i in range(n):
        v = (n-i) * (n-i-1) // 2
        tt += v * m2 % mod
        tt %= mod
    for i in range(m):
        v = (m-i) * (m-i-1) // 2
        tt += v * n2 % mod
        tt %= mod

    rr = r * k * (k-1) // 2 * tt
    rr = rr * inv(cc) % mod

    return rr%mod


print(main())



Measured memory_bytes: 6480
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main() {
	int N, H, W;
	int count = 0;

	cin >> N >> H >> W;

	for (int i = 0; i <= N - W; i++) {
		for (int j = 0; j <= N - H; j++) {
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		c: [[isize; 3]; 3],
	}

	// 1行目でb1を基準としたb2,b3を求める
	let b2 = c[0][1] - c[0][0];
	let b3 = c[0][2] - c[0][0];
	// 2行目、3行目をチェック
	for i in 1..3 {
		if c[i][1] - c[i][0] != b2 || c[i][2] - c[i][0] != b3 {
			println!("No");
			return;
		}
	}

	// 1列目でa1を基準としたa2,a3を求める
	let a2 = c[1][0] - c[0][0];
	let a3 = c[2][0] - c[0][0];
	// 2列目、3列目をチェック
	for j in 1..3 {
		if c[1][j] - c[0][j] != a2 || c[2][j] - c[0][j] != a3 {
			println!("No");
			return;
		}
	}

	println!("Yes");
}



Measured memory_bytes: 2136
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int INF=mod;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<int, int>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,k,n) for(int i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)


//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////



int main(){

  int a, b;cin >> a >> b;
  cout << a*b << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using mpi = boost::multiprecision::int128_t;
using namespace boost::numeric;
using imatrix = ublas::matrix<mpi>;

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};
const ll mod = (int)1e9 + 7;


void modulo(imatrix &mat, mpi mod) {
  for (size_t i = 0; i < mat.size1(); i++) {
    for (size_t j = 0; j < mat.size2(); j++) {
      mat(i, j) %= mod;
    }
  }
}

int main() {
  // use scanf in CodeForces!

  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; ll K; cin >> N >> K;
  imatrix mat(N, N);
  REP(i, N) REP(j, N) cin >> mat(i, j);

  imatrix pow2 = mat, ans(N, N);
  REP(i, N) REP(j, N) ans(i, j) = (ll)(i == j);
  while (K) {
    if (K & 1LL) {
      ans = ublas::prod(ans, pow2);
      modulo(ans, mod);
    }
    pow2 = ublas::prod(pow2, pow2);
    modulo(pow2, mod);
    K >>= 1;
  }

  mpi count = 0;
  REP(i, N) REP(j, N) count = (count + ans(i, j)) % mod;
  cout << count << endl;
  return 0;
}


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

int main()
{
    int a=700;
    string s;cin>>s;
    if(s[0]=='o'){a+=100;}
    if(s[1]=='o'){a+=100;}
    if(s[2]=='o'){a+=100;}
    std::cout << a << std::endl;
    return 0;
}

Measured memory_bytes: 3568