akhauriyash/Code-Regression huggingface dataset:
//ITNOA
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
const long long INF=1e9+10,MAX=2e5+1e4,MOD=1e9+7,MAXL=25;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
void OUT(long double o,int x){
	 cout<<fixed<<setprecision(x)<<o;
	 return;
}
ll a[MAX],b[MAX],t[MAX];
vector<int> v;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=0;i<n;i++){
		if(t[a[i]]==0){
			t[a[i]]=1;
			v.pb(b[a[i]]);
		}
	}
	sort(v.begin(),v.end());
	ll x=0;
	for(int i=0;i<ll(v.size())-k;i++)
		x+=v[i];
	cout<<x;
	return 0;
}

Measured memory_bytes: 6136
import sys
input = sys.stdin.readline
n = int(input())
if n == 1:
  print(2)
  exit()
ab = [list(map(int,input().split())) for i in range(n-1)]
mod = 10**9+7
graph = [[] for i in range(n+1)]
deg = [0 for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  deg[a] += 1
  deg[b] += 1
stack = []
for i in range(2,n+1):
  if deg[i] == 1:
    stack.append(i)
deg[1] += 1
dp = [[] for i in range(n+1)]
cnt = [-1 for i in range(n+1)]
while stack:
  x = stack.pop()
  if dp[x]:
    bl = 1
    wh = 1
    for i in dp[x]:
      ibl = i%mod
      iwh = i//mod
      wh = (wh*(ibl+iwh))%mod
      bl = (bl*iwh)%mod
    cnt[x] = wh*mod+bl
  else:
    cnt[x] = mod+1
  for y in graph[x]:
    if deg[y] > 1:
      dp[y].append(cnt[x])
      deg[y] -= 1
      if deg[y] == 1:
        stack.append(y)
print((cnt[1]%mod+cnt[1]//mod)%mod)

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << c  << " "<< a << " " << b << endl;
}


Measured memory_bytes: 256
"use strict";

const fs = require("fs");

const lines = fs.readFileSync("/dev/stdin", "utf-8").split("\n");
lines.pop();

const k = Number(lines[0].split(" ")[0]);
const n = Number(lines[0].split(" ")[1]);

const aa = lines[1].split(" ").map(x => Number(x));

const ad = [];
let res = 0;
let max = -1;
aa.forEach((a, i) => {
  let dist;

  if (i < n - 1) {
    dist = aa[i + 1] - a;
    ad.push(dist);
  } else {
    dist = k - a + aa[0];
    ad.push(dist);
  }

  if (max < dist) max = dist;
  res += dist;
});

console.log(res - max);


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

int main() 
{
    int m, n, i;
    int x0 = 0; //number of 0
    int x1 = 0; //number of 1
    string str;
    cin >> str;
    m = str.size(); //m=str long
    for (i=0;i<m;i++){
        n = str[i]; // n is ascii
        //cout << n << " ";
        if (n == 48){
            x0 = x0 + 1;
        }
        else if (n == 49){
            x1 = x1 + 1;
        }
    }
    if (x0 >= x1){
        cout << x1*2;
    }
    else {
        cout << x0*2;
    }
    //cout << "\n "<< m;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define cc(a) cout << a << endl;
#define msg(a,b) cout << a << " : " << b << endl;
#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;
#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;



int main(){
    long long int n,m,q,u,v,l,r,sum;
    cin >> n >> m >> q;
    vector<long long int> vec[n+2];
    map<pair<long long int, long long int>,long long int > mp;
    for(int i=0;i<m;i++){
        cin >> u >> v;
        //vec.push_back(make_pair(u,v));
        vec[u].push_back(v);
    }
    //sort(vec.begin(),vec.end());
    for(int i=1;i<=n;i++){
        sort(vec[i].begin(),vec[i].end());
    }
    for(int l=0;l<q;l++){
        cin >> u >> v;
        sum = 0;
        if(mp.find(make_pair(u,v)) != mp.end()  ){
            cout << mp[make_pair(u,v)]  << endl;
            continue;
        }
        for(int i=u;i<=v;i++){
            r = upper_bound(vec[i].begin(),vec[i].end(), v)-vec[i].begin();
            sum += r;
        }
        mp[ make_pair(u,v)] = sum;
        //msg("ANS", sum)
        cout << sum << endl;
    }
   return 0;
}


Measured memory_bytes: 7424
x,y = (int(i) for i in input().split())
groupA = [1,3,5,7,8,10,12]
groupB = [4,6,9,11]
groupC = [2]
if x in groupA and y in groupA:
  print('Yes')
elif x in groupB and y in groupB :
  print('Yes')
else:
  print('No')


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[argc])
{
  char c;
  string query = "AC";
  int index = 0;
  bool result = false;

  while (scanf("%c", &c)) {
    if (c == '\n') break;

    if (query[index] == c) index ++;
    else index = 0;

    if (index == query.size()) {
      result = true;
      break;
    }
  }

  if (result == true) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    int a[6],b[4] = {0,0,0,0};
    string res = "NO";
    rep(i,6) cin >> a[i];
    rep(i,6){
        if(a[i] == 1) b[0]++;
        else if(a[i] == 2) b[1]++;
        else if(a[i] == 3) b[2]++;
        else b[3]++;
    }
    sort(b,b+4);
    if(b[0] == 1 && b[1] == 1 && b[2] == 2 && b[3] == 2) res = "YES";
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
n=map(int,input())
a=list(map(int,input().split()))
b=[[0,0]]*len(a)
#print(b)
for i in range(len(a)):
  b[i]=[a[i],i+1]
#print(b)
b=sorted(b,key= lambda x: x[0])
#print(b)
for i in b:
  print(i[1],end=' ')

print()


Measured memory_bytes: 23040
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	double N, D;
	cin >> N >> D;

	vector<vector<double> > X(N, vector<double>(D));
	rep(i, N) {
		rep(j, D) {
			cin >> X[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N - 1; i++)//i
	{
		for (int j = i+1; j < N; j++)//j
		{
			double distance = 0;
			for (int k = 0; k < D; k++)
			{
				distance += pow(X[i][k] - X[j][k], 2);
			}
			distance = sqrt(distance);

			if (ceil(distance) == floor(distance)) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> A;
bool f() {
	int g = A[0];
	int m = A[0];
	for (int i = 1; i < N; ++ i) {
		g = __gcd(g, A[i]);
		m = max(m, A[i]);
	}
	if (K > m) return false;
	if (K % g) return false;
	return true;
}
int main() {
	cin >> N >> K;
	A.resize(N);
	for (auto& x : A) cin >> x;
	cout << (f() ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int h,n;
    cin>>h>>n;
    vi a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];

    vvi dp(n,vi(h+1,INT_MAX));

    rep(i,n){
        rep(j,h+1){
            if(i)dp[i][j]=dp[i-1][j];
            if(j-a[i]>=0){
                dp[i][j]=cmin(dp[i][j],dp[i][j-a[i]]+b[i]);
            }else{
                dp[i][j]=cmin(dp[i][j],((j+a[i]-1)/a[i])*b[i]);
            }
            // cerr<<"dp["<<i<<""<<"]["<<j<<"] = "<<dp[i][j]<<"\n";
        }
    }

    cout<<dp[n-1][h]<<"\n";

    return 0;
}

Measured memory_bytes: 39424
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    SP =[]
    for i in range(N):
        SP.append([S[i],P[i]])

    t = sorted(SP, key=lambda x:(x[0],-x[1]))

    # print(t)

    ans = []
    for x in t:
        for j in range(N):
            x1,x2 = x
            if(x1 == S[j] and x2 == P[j]):
                ans.append(j+1)


    for i in ans:
        print(i)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]" 
    P = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
#include <complex>
#include <cmath>
#define int long long
using namespace std;
signed main(void)
{
	int n, m;
	cin >> n >> m;
	if (n >= 2 && m >= 2)
		cout << max((long long )0, (n - 2)*(m - 2));
	else if (n == 1 && m == 1)
		cout << 1;
	else cout << n*m-2;
	return 0;
}


Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const long long MOD = 1000000007;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> A) {
  ll p = 0, q = 0, r = 0;
  ll x = 1;

  rep(i, N) {
    int cnt = 0;
    if (p == A.at(i)) cnt++;
    if (q == A.at(i)) cnt++;
    if (r == A.at(i)) cnt++;

    if (p == A.at(i)) {
      p += 1;
    } else if (q == A.at(i)) {
      q += 1;
    } else if (r == A.at(i)) {
      r += 1;
    }

    x *= cnt;
    x %= MOD;
  }

  cout << x % MOD << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    if(s.size()&1){
        cout << "No";
        return 0;
    }
    else {
        for(ll i = 0; i+1 < s.size(); i+=2){
            if(s[i] == 'h' && s[i+1] == 'i')continue;
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxN = 3e3 + 13;
int n, a[maxN], dp[maxN][maxN];
int32_t main () {
    cin >> n;
    for (int i = 0; i < n; i++)
	cin >> a[i];

    for (int dis = 0; dis < n; dis++)
	for (int i = 0; i + dis < n; i++) {
	    int j = i + dis;
	    if  (n % 2 == (j - i + 1) % 2) {
		if (j == i)
		    dp[i][j] = a[i];
		else
		    dp[i][j] = max(dp[i][j - 1] + a[j], dp[i + 1][j] + a[i]);
	    }
	    else {
		if (j == i)
		    dp[i][j] = -a[i];
		else
		    dp[i][j] = min(dp[i][j - 1] - a[j], dp[i + 1][j] - a[i]);
	    }
	}

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


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

typedef struct {
	vector<pair<ll, int>> e;
	ll dis = 1e17, vi = false;
}node_t;
vector<node_t> node;

void dik() {
	priority_queue < pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
	pq.emplace(0, 1);
	node[1].dis = 0;
	while (!pq.empty()) {
		ll x = pq.top().first, y = pq.top().second;
		node[y].vi = true;
		pq.pop();
		//cout << "x=" << x << " y=" << y << endl;
		for (auto ed : node[y].e) {
			ll cost = ed.first, to = ed.second;
			//cout << "cost=" << cost << " to=" << to << endl;
			if (node[to].vi)continue;
			if (node[to].dis > x + cost) {
				node[to].dis = x + cost;			
				pq.emplace(node[to].dis, to);
				//cout << "node[to].dis=" << node[to].dis << " to=" << to << endl;
			}
		}

	}
}

int main() {
	int N, M; cin >> N >> M;
	node = vector<node_t>(N + 1);
	for (int i = 2; i <= N; i++) {
		node[i].e.push_back(make_pair(0, i - 1));
	}

	for (int i = 1; i <= M; i++) {
		ll l, r, c; cin >> l >> r >> c;
		node[l].e.push_back(make_pair(c, r));
	}

	dik();
	cout << (node[N].dis != 1e17 ? node[N].dis : -1) << endl;

}



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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define frep(i,m,n) for(int (i)=(m); (i)<(int)(n); (i)++)
#define rrep(i,n) for(int (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(int (i)=(n)-1; (i)>(int)(m)-1; (i)--)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
const int INF = 1001001001;
const int MOD = 1000000007;

// A:array of pair, N:size of array
void sort_second(vector<pair<ll, ll>> &A, int N);
// a^n
ll a_n(ll a, ll n);
// make vector of (n!)%MOD, (n!)^(-1)%MOD to calculate nCk
void nCk(vector<ll> &n, vector<ll> &ninv);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    int k, x;
    cin >> k >> x;
    if(500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD ;
}

/* calculate a^n with no recursive process (%MOD)
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    int num = 1;
    vector<ll> memory(100);
    memory.at(0) = a;

    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
        memory.at(num) = ret;
        num++;
    }
    if(count == n) return ret;
    else {
        bitset<100> bit = bitset<100>(n-count);
        rep(i, 100) {
            if(bit.test(i)) ret = (ret * memory.at(i)) % MOD;
        }
        return ret;
    }    
}
*/

void nCk(vector<ll> &n, vector<ll> &ninv) {
    n[0] = 1;
    for(int i = 1; i < n.size(); i++) n[i] = (n[i-1] * i) % MOD;
    ninv[n.size()-1] = inv(n[n.size()-1]);
    for(int i = n.size() - 2; i > -1; i--) ninv[i] = (ninv[i+1] * (i+1)) % MOD;
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    n,m,l = map(int,input().split())
    d = [[10**12]*n for _ in [0]*n]
    for i in range(m):
        a,b,c = map(int,input().split())
        if l >= c:
            d[a-1][b-1] = d[b-1][a-1] = c
    for i in range(n):
        d[i][i] = 0

    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])

    edge = [[10**12]*n for _ in [0]*n]
    for i in range(n):
        for j in range(n):
            if d[i][j] <= l:
                edge[i][j] = 1

    for k in range(n):
        for i in range(n):
            for j in range(n):
                edge[i][j] = min(edge[i][j],edge[i][k] + edge[k][j])

    q = int(input())
    for _ in [0]*q:
        s,t = map(int,input().split())
        if edge[s-1][t-1] >= 10**12:
            print(-1)
        else:
            print(edge[s-1][t-1]-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56156
//https://atcoder.jp/contests/dp/tasks/dp_a

#include <bits/stdc++.h>
using namespace std;

int height[100010];
int dp[100010];

int abs(int a,int b)
{
    return (height[a]>=height[b] ? height[a]-height[b] : height[b]-height[a]);
}

int frog(int state)
{
    if(dp[state]!=-1) return dp[state];

    dp[state] = min(frog(state-1) + abs(state-1,state), frog(state-2) + abs(state-2,state));
    return dp[state];
}


int main()
{
    int n;
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &height[i]);
    }
    memset(dp,-1,sizeof(dp));
    dp[1] = 0;
    dp[2] = abs(1,2);
    printf("%d", frog(n));
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n,a;

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

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


int main(){
  string s;cin>>s;
  string t;cin>>t;
  int count = 0;
  for (int i = 0; i < 3; i++)
  {
    if(s.at(i) == t.at(i))count++;
  }
  
  cout << count << endl;
}

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



static int x = []() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  return 0;
}();




int main()
{

    ll t ;
    cin>>t ;

string  s ;
cin>>s ;
ll r= 0  , g = 0 , b = 0 ;
vector<ll> arr , brr , crr ;
unordered_set<ll> ar, br , cr  ;
for(ll i =0 ;i < s.length() ;i++ )
{

    if(s[i]=='R')
    {
        arr.push_back(i+1) ;
        ar.insert(i+1) ;

    }
    if(s[i]=='G')
    {
        brr.push_back(i+1) ;
        br.insert(i+1) ;

    }
    if(s[i]=='B')
    {
        crr.push_back(i+1) ;
        cr.insert(i+1) ;

    }

}

ll count = arr.size() * brr.size() * crr.size() ;

for(auto i : arr )
{

    for(auto j : brr)
    {

        ll k = (i+j) ;
        if(k%2==1)
            continue ;
        else{
            k=k/2 ;



            if(cr.find(k)!=cr.end())
                count-- ;
        }
    }
}






for(auto i : crr )
{

    for(auto j : brr)
    {

        ll k = (i+j) ;
        if(k%2==1)
            continue ;
        else{
            k=k/2 ;



            if(ar.find(k)!=ar.end())
                count-- ;
        }
    }
}




for(auto i : arr )
{

    for(auto j : crr)
    {

        ll k = (i+j) ;
        if(k%2==1)
            continue ;
        else{
            k=k/2 ;



            if(br.find(k)!=br.end())
                count-- ;
        }
    }
}


cout<<count<<endl ;



    return 0 ;
}


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

int main () {
  int64_t S, size, sum=0;
  cin >> S;
  string str=to_string(S);//桁数
  size=str.size();
//  printf("size=%d\n", size);

  if(size>1LL){
      for (int64_t tmp = 0; tmp <(1 << size-1); tmp++) {
        int64_t st=S, p=10LL;
        bitset<10> s(tmp);
        
        for (int i = 0; i < size-1; i++) {
          if(s.test(i)) {
            sum += st%p;
            st/=p;
            if(i==size-2){
              sum+=st%p;
            }
            p=10LL;
//            printf("%d,%d,%10ld,%10ld,%11ld\n", tmp,i,p,st, sum);
          }
          else{
            p*=10LL;
            if(i==size-2){
              sum+=st%p;
            }
//            printf("%d,%d,%10ld,%10ld,%11ld\n", tmp,i,p,st, sum);
          }   
        }
      }
  }
  else{
    sum=S;
  }
  cout << sum << endl;
}

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

int n, m, s;
int dp[2][2001][3001];

int main() {
    while(cin >> n >> m >> s, n){
        for(int i=0;i<2;i++){
            for(int j=0;j<=m;j++){
                fill(dp[i][j], dp[i][j]+s+1, 0);
            }
        }
        dp[0][0][0] = 1;
        for(int i=0;i<n*n;i++){
            for(int j=0;j<m;j++){
                for(int k=0;k<=s;k++){
                    dp[i%2][j+1][k] += dp[i%2][j][k];
                    dp[i%2][j+1][k] %= 100000;
                    if(k+j+1 <= s){
                        dp[(i+1)%2][j+1][k+j+1] += dp[i%2][j][k];
                        dp[(i+1)%2][j+1][k+j+1] %= 100000;
                    }
                }
            }
            for(int j=0;j<=m;j++){
                fill(dp[i%2][j], dp[i%2][j]+s+1, 0);
            }
        }
        int ans = 0;
        for(int i=0;i<=m;i++){
            ans += dp[(n*n)%2][i][s];
            ans %= 100000;
        }
        cout << ans << endl;
    }
    

    return 0;
}



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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x)
{
    bool f = 0;
    x = 0;
    char c = getchar();
    while(c != '-' && (c < '0' || c > '9')) c = getchar();
    if(c == '-') f = 1, c = getchar();
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    if(f) x = -x;
    return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y)
{
    scf(x);
    return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z)
{
    scf(x);
    scf(y);
    return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w)
{
    scf(x);
    scf(y);
    scf(z);
    return scf(w);
}

inline char mygetchar()
{
    char c = getchar();
    while(c == ' ' || c == '\n') c = getchar();
    return c;
}

template <typename T> inline bool chkmax(T &x, const T &y)
{
    return y > x ? x = y, 1 : 0;
}

template <typename T> inline bool chkmin(T &x, const T &y)
{
    return y < x ? x = y, 1 : 0;
}

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

//---------------------------------------------------------head----------------------------------------------------

char s[55];

int main()
{
    scanf("%s", s);
    int n = strlen(s);
    s[n - 8] = 0;
    puts(s);
    return 0;
}


Measured memory_bytes: 256
S = input()
S1 = int(S[:2])
S2 = int(S[2:])

if (1 <= S1 <= 12) and (1 <= S2 <= 12):
	print('AMBIGUOUS')
elif (1 <= S1 <= 12):
	print('MMYY')
elif (1 <= S2 <= 12):
	print('YYMM')
else:
	print('NA')

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>
#include <atcoder/segtree>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;
using namespace atcoder;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;
static const int MAX = 300005;

int ans;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

int main(void) {
    int N, K;
    cin >> N >> K;
    segtree<int, op, e> seg(MAX);
    rep(i, 0, N) {
        int A;
        cin >> A;
        int mx = 0;
        int l = max(0, A-K);
        int r = min(MAX, A+K+1);
        mx = seg.prod(l, r);
        seg.set(A, mx+1);

    }

    ans = seg.all_prod();
    
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 8540
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        string s = to_string(i);
        if(s[0]==s[4]&&s[1]==s[3]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
ss = [input() for _ in range(n)]
count = []
l = [chr(v) for v in range(ord("a"), ord("z")+1)]
d = {c:i for i,c in enumerate(l)}
for s in ss:
    val = [0]*26
    for c in s:
        val[d[c]] += 1
    count.append(tuple(val))
from collections import Counter
c = Counter(count)
ans = sum(v*(v-1)//2 for v in c.values())
print(ans)

Measured memory_bytes: 165360
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
int n;

int solve(int a)
{
    int sum=0;
    while(a>0)
    {
        sum+=a%10;
        a/=10;
    }
    return sum;
}

int main()
{
    int i;
    int ans=0x7fffffff;
    scanf("%d",&n);
    for(i=1;i<=n/2+1;i++)
    {
        int tmp=solve(i)+solve(n-i);
        ans=min(ans,tmp);
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k;
    cin>>n>>k;
    if (n%k) cout<<1;
    else cout<<0;
}


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

using namespace std;
int main(void){
    // Your code here!
    string s,t,u;
    int a,b,c;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
int s[N];
int main(void)
{
    int n;
    cin>>n;
    for (int i = 1;i <= n;++i)
        cin>>s[i];
    reverse(s + 1,s + 1 + n);
    ll l = 2,r = 2;
    for (int i = 1;i <= n;++i)
    {
        l = (l + s[i] - 1) / s[i];
        r /= s[i];
        l *= s[i];
        r *= s[i];
        if (l > r)
            return puts("-1") * 0;
        r += s[i] - 1;
    }
    cout << l << ' ' << r << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cassert>

template<class T>
struct fenwick_tree{
  int n;
  std::vector<T> data;
  fenwick_tree(){}
  fenwick_tree(int _n):n(_n){
    data.resize(n+1);
  }
  fenwick_tree(std::vector<T>const& a):n(a.size()){
    data.resize(n+1);
    for(int i=1;i<=n;++i){
      data[i] += a[i-1];
      if(i+(i&-i)<=n)data[i+(i&-i)] += data[i];
    }
  }
  T prefix_sum(int x){
    T res{0};
    for(int i=x;i>0;i-=i&-i)res+=data[i];
    return res;
  }
  T fold(int l,int r){
    return prefix_sum(r)-prefix_sum(l);
  }
  void add(int x,T v){
    for(int i=x+1;i<=n;i+=i&-i)data[i]+=v;
  }
  void dump(){for(auto x:data)std::cout<<x<<" ";std::cout<<std::endl;}
};

signed main(){

  int n,q;
  std::cin>>n>>q;

  fenwick_tree<int64_t> fen(n);
  std::vector<int64_t> a(n);

  while(q--){
    int com;std::cin>>com;
    if(com==0){
      int64_t i,x;std::cin>>i>>x;i--;
      fen.add(i,x);
      a[i] += x;
    }
    if(com==1){
      int l,r;std::cin>>l>>r;l--,r--;
      std::cout<< fen.fold(l,r+1) <<std::endl;
    }
  }

  fenwick_tree<int64_t> fen2(a);
  assert(fen.data==fen2.data);
  //fenwick_tree<int64_t> fen3(n);
  //for(int i=0;i<n;++i)fen3.add(i,a[i]);
  //assert(fen.data==fen3.data);

}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;
using ll = long long;
using P = pair<ll, ll>;
double PI = acos(-1);



signed main(){
    int n;
    cin >> n;
    vector<int> d(n);
    map<int, int> m;
    int ma = 0;
    rep(i, n) {
        cin >> d[i];
        d[i];
        if(d[i]>=n) {
            cout << 0 << endl;
            return 0;
        }
        m[d[i]]++;
        ma = max(d[i],ma);
        //cout << d[i]<<" "<<m[d[i]] << endl;
    }

    int now = 0;
    ll ans = 1;
    if(d[0] != 0 || m[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    FOR(i, 1, ma+1) {
        //cout << m[i] << endl;
        if(m[i]==0){
            cout << 0 << endl;
            return 0;
        }
        if(i==1) continue;
        rep(j, m[i]) {
            ans *= m[i-1];
            ans %= mod; 
        }
        //cout << ans << endl;
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define fo(i,ini,n) for(int i=ini;i<n;i++)
int const inf=1e9+7;
typedef long long ll;

int main(){
	int t=1;
	while(t--){
		ll n;
		cin>>n;
		vector<ll>dp(3,0);
		fo(a,0,n){
			vector<ll>temp(3,0),store(3);
			cin>>store[0]>>store[1]>>store[2];
			fo(i,0,3){
				fo(j,0,3){
					if(i!=j){
						temp[j]=max(temp[j],dp[i]+store[j]);
					}
				}
			}
			dp=temp;
		}
		ll ans=0;
		fo(i,0,3)
		ans=max(ans,dp[i]);
			cout<<ans<<endl;
		return 0;
	}
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	int x=x2-x1;
	int y=y2-y1;
	cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x<<endl;

	return 0;
}

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

int main()
{
    int n,x;
    while(scanf("%d%d",&n,&x)==2){
        int count = 0;
        if(n == 0 && x == 0) break;
        for(int i = 1;i<=n;i++){
            for(int j = i+1;j<=n;j++){
                for(int k = j+1;k<=n;k++){
                    if(i+j+k == x) count++;
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}



Measured memory_bytes: 3164
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		long[] countA = new long[N+1];
		long[] plus = new long[N+1];
		long[] minus = new long[N+1];
		for( int i=0; i<N; i++ ){
			A[i] = sc.nextInt();
			countA[ A[i] ]++;
		}
		long total = 0;      
		for( int i=1; i<=N; i++ ){
			if( countA[i]>1 ){
				plus[i] = countA[i]*(countA[i]-1)/2;
				minus[i] = (countA[i]-1)*(countA[i]-2)/2;
				total += plus[i];
			}
		}     
		for( int i=0; i<N; i++ ){
			System.out.println( total - plus[A[i]] + minus[A[i]] );
		}    
	}
}


Measured memory_bytes: 106160
#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,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    string s;
    cin>>s;

    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;

    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    vector<int64_t> a(1L << n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<array<int64_t, 2>> m(a.size(), {a.size(), a.size()});
    a.push_back(0);
    for (auto k : irange(0uL, 1uL << n)) {
        bitset<18> bs(k);

        m[k][0] = k;
        for (auto i : irange(0L, n)) {
            if (!bs[i]) {
                continue;
            }

            auto p = (k & ~(1uL << i));
            if (a[m[p][0]] > a[m[k][0]]) {
                m[k][1] = m[k][0];
                m[k][0] = m[p][0];
            } else if (m[p][0] != m[k][0] && a[m[p][0]] > a[m[k][1]]) {
                m[k][1] = m[p][0];
            }

            if (a[m[p][1]] > a[m[k][1]]) {
                m[k][1] = m[p][1];
            }
        }
    }

    int64_t prev = 0;
    for (auto i : irange(1uL, 1uL << n)) {
        int64_t ans = max(prev, a[m[i][0]] + a[m[i][1]]);
        prev = ans;
        cout << ans << "\n";
    }
}

Measured memory_bytes: 10876
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

int n;
ll x, ans;

int main() {
    scanf("%d%lld", &n, &x);
    ll prev = 0, cur;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &cur);
        if (cur > x) {
            ans += cur-x;
            cur = x;
        }
        if (cur + prev > x) {
            ans += cur + prev - x;
            cur -= (cur + prev - x);
        }
        prev = cur;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#define TRUE 0
#define FALSE 1

int main(void) {
	int i;
	int j;
	int max=(int)pow(2.0,15.0);
	int hurui[max];
	
	/////?´???°?±???????/////
	for(i=0;i<max;i++) {
		hurui[i] = TRUE;
	}
	hurui[0] = FALSE;
	hurui[1] = FALSE;
	
	for(i=2;i<max;i++) {
		for(j=2;j<max;j++) {
			if(i*j<max) {
				hurui[i*j] = FALSE;
			}
		}
	}
	/*for(i=0;i<100;i++) {
		if(hurui[i]==TRUE) printf("%d = ?´???°\n",i);
    }*/
	/////////////////////
	
	int input;
	int count;
	
	while(1) {
		scanf("%d",&input);
		if(input==0) break;
		
		count = 0;
		
		for(i=2; i<=input; i++) {
			for(j=2; j<=i; j++) {
				//printf("%d %d\n",i,j);
				if(hurui[i] == FALSE || hurui[j] == FALSE) continue;
				if( (i+j) == input ) {
					count++;
					//printf("%d = %d+%d\n",input,i,j);
				}
			}
		}
		printf("%d\n",count);
	}
	
	exit(0);
}

Measured memory_bytes: 728
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	if n <= 999 {
		fmt.Println("ABC")
	} else {
		fmt.Println("ABD")
	}
}


Measured memory_bytes: 1772
import java.util.Scanner;
import java.util.Random;

public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int a = sc.nextInt();
        int ac=0;
        int wa=0;
        int tle=0;
        int re=0;
        String b ="";
        for(int i=0; i<=a; i++){
            b=sc.nextLine();
            if(b.equals("AC")){
                ac++;
            }else if(b.equals("WA")){
                wa++;
            }else if(b.equals("TLE")){
                tle++;
        }
    }
    re = a-(ac+wa+tle);
    System.out.println("AC x " +ac);
    System.out.println("WA x " + wa);
    System.out.println("TLE x "+ tle);
    System.out.println("RE x "+ re);
}
}

Measured memory_bytes: 61132
#include <iostream>
#include <algorithm>
using namespace std;
int maxv,minv;
int arr[200000];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>arr[i];
	maxv = arr[1] - arr[0];
	minv = arr[0];
	for(int i=1;i<n;i++){
		maxv = max(maxv,arr[i]-minv);
		minv = min(minv,arr[i]);
	}
	cout<<maxv<<endl;
	return 0;
} 


Measured memory_bytes: 3868
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <cfloat>
using namespace std;

int main()
{
    long long int N;
    cin >> N;

    for (long long i = N; i > 0; i--)
    {
        double ans = sqrt((double)i);
        int x = ans;
        if (ans - x < DBL_EPSILON)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string s;
    int sum=0;
    cin>>s;
    if(s[0]=='2')
        sum++;
    if(s[1]=='2')
        sum++;
    if(s[2]=='2')
        sum++;
    if(s[3]=='2')
        sum++;
    cout<<sum<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
//mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;
typedef pair<int,int> pii;

int a[200005];
int main() {
    int n;
    cin>>n;
    ii cin>>a[i];
    ll ans=0,mx=0;
    ii {
        if(a[i]<mx) ans+=mx-a[i];
        else mx=max(mx,(ll)a[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4324
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

unsigned long long K, A, B;
int main(int argc, char const *argv[])
{
    cin >> K >> A >> B;
    K = K + 1;

    if (A+1 < B)
    {
        int k_sub=K-A;
        cout << k_sub/2*(B-A)+A+k_sub%2<<endl;
    }else{
        cout<<K<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
divisor_list = []
for n in a, b:
    divisor_list.append(1)
    for i in range(2, n // 2 + 1):
        if n % i == 0:
            divisor_list.append(i)
    divisor_list.append(n)
l = sorted([x for x in set(divisor_list) if divisor_list.count(x) > 1], key=divisor_list.index)
print(l[-k])

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  vector<vector<pair<int, int>>> city(n);
  for (int i = 0; i < m; i++) {
	cin >> p[i] >> y[i];
	city[p[i] - 1].push_back(make_pair(y[i], i));
  }
  for (int i = 0; i < n; i++) {
	sort(city[i].begin(), city[i].end());
	for (int j = 0; j < city[i].size(); j++) {
	  y[city[i][j].second] = j + 1;
	}
  }
  for (int i = 0; i < m; i++) {
	printf("%06d%06d\n", p[i], y[i]);
  }
  return 0;
}



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

Measured memory_bytes: 256
k = int(input())
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(gcd(a,b), c)

print(ans)


Measured memory_bytes: 80300
#include<bits/stdc++.h>
using namespace std;
int a[15];
struct node{
	int a,b,c,d;
}q[55];
int N,M,Q,res=0;
void dfs(int ans,int id)
{
	if(ans>N)
	{
		int sum=0;
		for(int i=1;i<=Q;i++)
		{
			if(a[q[i].b]-a[q[i].a]==q[i].c)
			sum+=q[i].d;
		}
		res=max(res,sum);
	}
	else
	{
		for(int i=id;i<=M;i++)
		{
			a[ans]=id;
			dfs(ans+1,i);
		}
	}
}
int main()
{
	cin>>N>>M>>Q;
	for(int i = 1;i<=Q;i++){
		cin>>q[i].a >> q[i].b >> q[i].c>>q[i].d;
	}
	dfs(1,1);
	cout<<res<<endl;;
}
 

Measured memory_bytes: 3564
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>


using namespace std;
const long long int MOD=1e9+7;

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=505;

int n,x[N],f[N],a[N*N+N];

bool cmp(int p,int q)
{
    return x[p]<x[q];
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&x[i]),f[i]=i;
    sort(f+1,f+n+1,cmp);
    int now=1;
    for (int i=1;i<=n;i++)
    {
        int w=f[i];a[x[w]]=w;
        for (int j=1;j<w;j++)
        {
            while (a[now]) now++;
            a[now]=w;
        }
        if (now>x[w]) {puts("No");return 0;}
    }
    for (int i=1;i<=n;i++)
    {
        int w=f[i];
        for (int j=1;j<=n-w;j++)
        {
            while (a[now]) now++;
            if (now<x[w]) {puts("No");return 0;}
            a[now]=w;
        }
    }
    puts("Yes");
    for (int i=1;i<=n*n;i++) printf("%d ",a[i]);
    return 0;
}

Measured memory_bytes: 2176
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
to = [False]*N
for i in range(M):
  a,b = map(int, input().split())
  edge[a-1].append(b-1)
  to[b-1] = True

import sys
sys.setrecursionlimit(10**8)

def dfs(v):
  if lis[v]>=0:
    return lis[v]
  if len(edge[v])==0:
    lis[v] = 1
    return 1
  ans = 0
  for u in edge[v]:
    ans = max(ans, dfs(u))
  lis[v] = ans+1
  return ans+1

ans = 0
lis = [-1]*N
for r in range(N):
  if to[r]==False:
    ans = max(ans, dfs(r)-1)
print(ans)

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

int main() {
    int n;
    int v[60];
    int c[60];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    int max = 0;
    for(int i=0;i<n;i++) {
        if(v[i] - c[i] > 0){
            max += v[i] - c[i];
        }
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256