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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;

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

int const MAX = 1e5 + 41;

int n;
int a[MAX];

void solve() {
	sort(a + 1, a + n + 1);
	int b = -1;
	int c1 = a[n] / 2;
	int c2 = c1;
	if (a[n] % 2 != 0) {
		c2++;
	}
	fi(1, n - 1) {						
		if (b == -1) {
			b = i;
		} else {
			int v1 = min(abs(c1 - a[i]), abs(c2 - a[i]));
			int v2 = min(abs(c1 - a[b]), abs(c2 - a[b]));
			if (v1 < v2) {
				b = i;
			}
		}
	}
	printf("%d %d\n", a[n], a[b]);
}

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

	scanf("%d", &n);
	fi(1, n) {
		scanf("%d", &a[i]);
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define fid(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pii pair<int,int>
#define TTT "Frog2"
#define maxn 100005
using namespace std;
int n, k, h[maxn];
int f[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen(TTT".inp", "r", stdin);
    freopen(TTT".out", "w", stdout);
    #endif // ONLINE_JUDGE
    cin >> n >> k;
    fi(i, 1, n) cin >> h[i];
    fi(i, 0, n) f[i] = 1e9 + 5;
    f[1] = 0;
    fi(i, 2, n)
    fi(j, max(1, i - k), i - 1)
        f[i] = min(f[i], f[j] + abs(h[i] - h[j]));
    cout << f[n];
}


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

typedef long long int ll;
ll n;
map<ll, ll> ans;

int main() {
    scanf("%lld", &n);
     for(ll x = 1; x <= 101; ++x) {
        for(ll y = 1; y <= 101; ++y) {
            for(ll z = 1; z <= 101; ++z) {
                if(x * x + y * y + z * z + x * y + y * z + x * z <= n) ans[x * x + y * y + z * z + x * y + y * z + x * z]++; 
            }
        }
    }

    for(ll i = 1; i <= n; ++i) printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s[101];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    for(int i = 0; i < H; ++i)
        cin >> s[i];
        
    for(int i = 0; i < H; ++i){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;



public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = 7;
        // a mod k = 0を探索
        for (int i = 0 ; i < k ; i++) {
            if (a % k == 0) {
                System.out.println(i + 1);
                return;
            }
            a %= k;
            a = 10 * a + 7;
        }
        System.out.println(-1);
    }

}


Measured memory_bytes: 35564
N,Y=map(int,input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 9204
W, H, x, y, r = map(int, input().split())

flg = True

if x + r > W:
    flg = False

if y + r > H:
    flg = False

if x - r < 0:
    flg = False

if y - r < 0:
    flg = False

if flg:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5596
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

using namespace std;
void bubblesort(int *a, int n){
    bool flg = true;
    int cnt = 0;
    int k=0;
    while(flg){
        flg = false;
        for(int j=n-1;j>k;j--){
            if(a[j]<a[j-1]){
                swap(a[j], a[j-1]);
                ++cnt;
                flg = true;
            }
        }
        ++k;
    }
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i!=n-1){
            cout << " ";
        } else {
            cout << "\n";
        }
    }
    cout << cnt << "\n";
}

int main(){
    int n;
    cin >> n;
    int *a = (int *)calloc(n, sizeof(int));
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    bubblesort(a, n);

    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rng 200015
queue<int>Q;
vector<int> edge[rng];
int vis[rng],lvl[rng];
void bfs(int n)
{
    for(int x=0;x<200000;x++)
    vis[x]=0;
    vis[n]=1;
    Q.push(n);
    while(!Q.empty())
    {
        n=Q.front();
        Q.pop();
        int len=edge[n].size();
        for(int i=0;i<len;i++)
        {
            int num=edge[n][i];
            if(vis[num]==0)
            {
                vis[num]=1;
                lvl[num]=n;
                Q.push(num);
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    memset(lvl,-1,sizeof(lvl));
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    bfs(1);
    for(int i=2;i<=n;i++)
    {
        if(lvl[i]==-1)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
    {
        cout<<lvl[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 14044
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

public class Prog
{
	static ulong result = 0;

	static public int Main()
	{

		string S = Console.ReadLine();

		for( int i = 0; i < 1 << S.Length - 1; i ++ )
		{
			string curS = S;
			// ビットが立っている所に+を差し込む
			int seek = 0;
			for( int j = 0; j < S.Length - 1; j ++ )
			{
				seek ++;
				if( ( i & ( 1 << j ) ) != 0 )
				{
					curS = curS.Substring( 0, seek ) + "+" + curS.Substring( seek );
					seek ++;
				}
			}
			var parts = curS.Split('+');
			for( int j = 0; j < parts.Length; j ++ )
			{
				result += UInt64.Parse( parts[ j ] );
			}
		}
		Console.WriteLine( result );

		return 0;
	}
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll pot[2][maxN], sma[2];
int n;

int getstp(int x) {
	int ret = 1;
	while(x) {
		x %= __builtin_popcount(x);
		ret++;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	string st;
	cin >> n >> st;
	int cnta = count(st.begin(), st.end(), '1');
	for(int u = 0, cnd = cnta - 1; u < 2; u++, cnd += 2) {
		if(cnd <= 0) continue;
		pot[u][0] = 1;
		for(int i = 1; i <= n; i++)
			pot[u][i] = pot[u][i - 1] * 2 % cnd;
		for(int i = 0; i < n; i++)
			if(st[i] == '1') 
				sma[u] = (sma[u] + pot[u][n - 1 - i]) % cnd;
	}

	for(int i = 0; i < n; i++) {
		int nxt;
		if(st[i] == '0') {
			nxt = (sma[1] + pot[1][n - 1 - i]) % (cnta + 1);
		} else {
			if(cnta - 1 == 0) {
				cout << "0\n"; continue;
			}
			nxt = (sma[0] + (cnta - 1) - pot[0][n - 1 - i]) % (cnta - 1);
		}
		cout << getstp(nxt) << '\n';
	}
}



Measured memory_bytes: 6900
def gcd(a,b)
	a,b = b,a if b>a
	if a % b == 0
		b
	else
		gcd(b,a%b)
	end
end

def lcm(a,b)
	a*b/gcd(a,b)
end

while line = gets
	break if line == "\n"
	a,b = line.split
	puts "#{gcd(a.to_i,b.to_i)} #{lcm(a.to_i,b.to_i)}"
end

Measured memory_bytes: 6096
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
 
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())
 
#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int dict[100005];

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

  for(int i = 0; i <= 100000; ++i) {
    dict[i] = 0;
  }

  int N;
  int t;
  cin >> N;

  for(int i = 1; i <= N; ++i) {
    cin >> t;
    if(i == t) {
      dict[i]++;
    }
  }

  int ans = 0;
  int temp = 0;
  int i = 0;
  while(i <= N) {
    if(dict[i] == 0) {
      i++;
    } else {
      while(dict[i] == 1) {
        temp++;
        i++;
      }

      ans += temp/2 + temp%2;
      temp = 0;
      i++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int nam[100],x,y,i,n;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &nam[i]);
	}
	for (i = 0; i < n; i++){
		if (nam[i] < 0){
			nam[i] = 0 - nam[i];
		}
	}
	x = nam[0];
	y = nam[0];
	for (i = 0; i < n; i++){
		if (nam[i]>x){
			x = nam[i];
		}
		if (nam[i]<y){
			y = nam[i];
		}
	}
	printf("%d", x - y);
	return 0;
}


Measured memory_bytes: 128
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    vector<ll> fr,bc(n);
    fr.push_back(a[0]);
    for(int i=1;i<n;i++){
        fr.push_back(gcd(fr[i-1],a[i]));
    }
    bc[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        bc[i]=gcd(bc[i+1],a[i]);
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(i==0){
            chmax(ans,bc[1]);
        }
        else if(i==n-1){
            chmax(ans, fr[n-2]);
        }
        else{
            chmax(ans,gcd(fr[i-1],bc[i+1]));
        }
    }
    //debug(bc);
    //debug(fr);
    cout << ans << "\n";
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    int res = 0;
    rep(i,n) {
        cin >> a[i];
    }
    rep(i,n) {
        cin >> b[i];
    }
    rep(i,n-1) {
        cin >> c[i];
    }
    int curr;
    int prev = -500;
    for (auto e: a) {
        curr = e - 1;
        res += b[curr];
        if ((curr - prev) == 1) res += c[prev];
        prev = curr;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#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,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a,b;
    cin >> a >> b;
    if(b%a==0){
        put(a+b);
    }else{
        put(b-a);
    }
    return 0;
}


Measured memory_bytes: 256
using System;

namespace JudgeStatusSummary
{
	class Program
	{
		static void Main(string[] args)
		{
			int countAC = 0;
			int countWA = 0;
			int countTLE = 0;
			int countRE = 0;

			int num = int.Parse(Console.ReadLine());
			for (int i = 0; i < num ; i++)
			{
				String str = Console.ReadLine();

				if (str == "AC")
				{
					countAC++;

				} else if (str == "WA")
				{
					countWA++;

				} else if (str == "TLE")
				{
					countTLE++;

				} else if (str == "RE")
				{
					countRE++;
				}
			}

			Console.WriteLine("AC x {0}", countAC);
			Console.WriteLine("WA x {0}", countWA);
			Console.WriteLine("TLE x {0}", countTLE);
			Console.WriteLine("RE x {0}", countRE);
		}
	}
}

Measured memory_bytes: 30404
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;

int main(){
    string s;
    cin>>s;
    int x=0,y=0;
    rep(i,s.size()){
        if(s[i]=='0') x++;
        else y++;
    }
    cout<<min(x,y)*2<<endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; i++)cin >> s[i];
	map<vector<int>, int> a;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		vector<int> d(26, 0);
		for (int j = 0; j < 10; j++) {
			d[s[i][j] - 'a']++;
		}
		ans += a[d];
		a[d]++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 25984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}

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

  int n;
  while(1){
    cin >> n;
    if(n == 0) break;

    int score[n];
    REP(i, n) cin >> score[i];
    MergeSort(score, score+n);

    int min = 1000001;
    REP(i, n-1) if(min > abs(score[i]-score[i+1])) min = abs(score[i]-score[i+1]);

    cout << min << endl;
  }

  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s; int p=0, answer=0;
    for(int i =0; i<s.size(); i++){
        if(p>0){
            if(s[i]=='g') answer++;
            p--;
        }
        else{
            if(s[i]=='p') answer--;
            p++;
        }
    }
    cout<<answer;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i] ++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    ll d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1; y = 0;
    }
    return d; 
}

ll mod_inverse(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

ll comb(ll a, ll b) {
    ll res = 1;
    for(ll i = a; i > a - b; i--) {
        res *= i;
        res %= mod;
    }
    rep1(i, b) {
        res *= mod_inverse(i, mod);
        res %= mod;
    }
    return res;
}

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

  ll N, M; cin >> N >> M;
  map<ll, ll> pf;
  map<ll, ll>::iterator ite;
  pf = prime_factor(M);
  ll ans = 1;
  for(ite = pf.begin(); ite != pf.end(); ite ++) {
      ll k = ite->second;
      ans *= comb(k + N - 1, k);
      ans %= mod;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using ll = long long;
using ull = unsigned long long;
const static unsigned MAX_N = 200000;
ll bucket[MAX_N+1];

int main(){
    unsigned N;
    scanf("%u", &N);
    unsigned A[N];
    for(int i = 0; i < N; ++i){
        scanf("%u", A + i);
        bucket[A[i]]++;
    }
    ull answer = 0;
    for (size_t i = 1; i <= N; i++){
        answer += bucket[i]*(bucket[i] - 1) >> 1;
    }
    for (size_t i = 0; i < N; i++){
        printf("%llu\n", answer + 1 - bucket[A[i]]);
    }
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

template <typename T> istream &operator>>(istream &istr, vector<T> &vec) {
  for(T &x : vec) istr >> x;
  return istr;
}

template <typename T> ostream &operator<<(ostream &ostr, vector<T> &vec) {
  if(!vec.empty()) {
    ostr << vec.front();
    for(auto itr = ++vec.begin(); itr != vec.end(); itr++) ostr << " " << *itr;
  }
  return ostr;
}

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

  auto ans = (b - 1) / (a - 1);
  if((b - 1) % (a - 1) == 0)
    cout << ans << endl;
  else
    cout << ans + 1 << endl;

  return 0;
}


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

 int main() {
   int n;
   cin >> n;
   int res;
   if (n % 2 == 0) {
     res = n / 2;
   }else{
     res = n / 2 + 1;
   }
   cout << res << '\n';
 }


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

int A,B,C=0,N,K;
ll ans = 0;
string S;
vector<pair<ll,ll>> vec(50);
map<pair<ll,ll>,ll> sa;

int main(){
	cin>>N;
	if(N==1){
		cout<<1<<endl;
		return 0;
	}

	for(int i=0;i<N;i++){
		cin>>vec.at(i).first>>vec.at(i).second;
	}
	vec.resize(N);

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i!=j)
				sa[make_pair(vec.at(i).first-vec.at(j).first,vec.at(i).second-vec.at(j).second)]++;
		}
	}
	auto ite = sa.begin();
	while(ite!=sa.end()){
		ans = max(ans,ite->second);
		ite++;
	}
	cout<<N-ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <list>

using namespace std;
int main() {
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

void rec(int d, ll v, vector<ll> &all){

    all.push_back(v);

    if(d == 10) return;

    ll v_shift = v * 10 + v % 10;
    if(v % 10 != 0){
        rec(d + 1, v_shift - 1, all);
    }
    rec(d + 1, v_shift, all);
    if(v % 10 != 9){
        rec(d + 1, v_shift + 1, all);
    }
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll k; cin >> k;

    vector<ll> all;
    rep(i, 9){
        rec(1, i + 1, all);
    }

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

    cout << all[k - 1] << endl;

    return 0;
}

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

int panel[8][8];
int check[8][8][6];
int h,w,c,color,cnt_max;

int change( int mae, int ato, int x ) {
  for( int i = 0; i < h; i++ ) {
    for ( int j = 0; j < w; j++ ) {
      if ( check[j][i][x] == mae ) check[j][i][x] = ato;
    }
  }
  return 0;
}

int changep( int x, int y , int z ) {
  if ( x != 0 ) {
    if ( panel[x-1][y] == color && check[x-1][y][z] != check[x][y][z] ) {
      change( check[x-1][y][z], check[x][y][z] , z );
    }
  }
  if ( x != w-1 ) {
    if ( panel[x+1][y] == color && check[x+1][y][z] != check[x][y][z] ) {
      change( check[x+1][y][z], check[x][y][z] , z );
    }
  }
  if ( y != 0 ) {
    if ( panel[x][y-1] == color && check[x][y-1][z] != check[x][y][z] ) {
      change( check[x][y-1][z], check[x][y][z] , z );
    }
  }
  if ( y != h-1 ) {
    if ( panel[x][y+1] == color && check[x][y+1][z] != check[x][y][z] ) {
      change( check[x][y+1][z], check[x][y][z] , z );
    }
  }
  return 0;
}

int count() {
  int cnt = 0;
  for ( int i = 0; i < h; i++ ) {
    for ( int j = 0; j < w; j++ ) {
      if ( check[j][i][5] == 0 ) cnt++;
    }
  }
  cnt_max = max( cnt_max, cnt );
  
  return 0;
}

int saiki( int color_pre, int cnt ) {
    for ( int k = 1; k < 7; k++ ) {
      color = k;
      if ( cnt == 4 ) color = c;
      for ( int i = 0; i < h; i++ ) {
	for ( int j = 0; j < w; j++ ) {
	  check[j][i][cnt+1] = check[j][i][cnt];
	}
      }
      for ( int i = 0; i < h; i++ ) {
	for ( int j = 0; j < w; j++ ) {
	  if ( check[j][i][cnt+1] == 0 ) changep( j, i , cnt+1 );
	}
      }
      if ( cnt < 4 ) {
	saiki( k, cnt+1 );
      }else {
	count();
      }
    }
  return 0;
}

int main() {

  while(true) {

    cin >> h >> w >> c;
    if ( h == 0 ) break;

    int num = 0;
    for ( int i = 0; i < h; i++ ) {
      for ( int j = 0; j < w; j++ ) {

	cin >> panel[j][i];
	if ( i != 0 && j != 0 ) {
	  if ( panel[j-1][i] == panel[j][i] && panel[j][i-1] == panel[j][i] ) {
	    change( check[j-1][i][0] , check[j][i-1][0], 0 );
	    check[j][i][0] = check[j-1][i][0];
	    continue;
	  }
	}
	if ( i!= 0 ) {
	  if ( panel[j][i-1] == panel[j][i] ) {
	    check[j][i][0] = check[j][i-1][0];
	    continue;
	  }
	}
	if ( j!= 0 ) {
	  if ( panel[j-1][i] == panel[j][i] ) {
	    check[j][i][0] = check[j-1][i][0];
	    continue;
	  }
	}
	check[j][i][0] = num;
	num++;

      }
    }

    cnt_max = 0;
    saiki( panel[0][0], 0 );
    cout << cnt_max/*check[0][0]*/ << endl;
  }
  return 0;
}

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

int main(){
    int m, f, r;
    char grade;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1) grade = 'F';
        else if(m + f >= 80) grade = 'A';
        else if(m + f >= 65) grade = 'B';
        else if(m + f >= 50) grade = 'C';
        else if(m + f >= 30){
            if(r >= 50) grade = 'C';
            else grade = 'D';
            }
        else grade = 'F';
        cout << grade << endl;
    }
    return 0;
}


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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

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

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


  int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    REP(r, 3001)REP(g, 3001){
      int x = N - (r * R) - (g * G);
      if(x >= 0 && x % B == 0) ans++;
    }
  print(ans);
  }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,a[100],sum=0,r1=0,r2=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  sum/=n;
  for(int i=0;i<n;i++) r1+=(a[i]-sum)*(a[i]-sum);
  sum++;
  for(int i=0;i<n;i++) r2+=(a[i]-sum)*(a[i]-sum);
  cout<<min(r1,r2)<<endl;
  return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,ren=0;
  string ans="No";
  cin >> n;
  vector<long> d1(n),d2(n);
  for(long i=0;i<n;i++) {
    cin >> d1[i] >> d2[i];
    if(d1[i]==d2[i]) {
      ren++;
    } else {
      ren=0;
    }
    if(ren>=3) ans="Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int h, w, i, t;
		
while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		if(h == 0 && w == 0){
				break;
			}
		if(1 <= h && h <= 300 && 1 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				
				System.out.print("#");
				
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		}
		}
}	

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

int main() {
  int A, B;
  cin >> A >> B;
  int n = 0;
  
  for (int i = A; i < B + 1; i++) {
    int p, q, r, s, t;
    p = i / 1 % 10;
    q = i / 10 % 10;
    r = i / 100 % 10;
    s = i / 1000 % 10;
    t = i / 10000;
    
    int j = 10000*p + 1000*q + 100*r + 10*s + t;
      
    if (i == j)
      n += 1;
    else if (i != j)
      n += 0;
  }   
      cout << n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N),B(N);
  rep(i,N) {
    cin >> A[i] >> B[i];
  }
  ll tmp = 0;
  drep(i,N) {
    ll m = ((ll)A[i] + tmp) % (ll)B[i];
    if(m == 0) continue;
    tmp += (ll)B[i] - m;
  }
  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 1024
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))
L = [0]*(N+2)
L = np.array(L)

for i in A:
    L[i] +=1

LL  = np.multiply(L,L-1)/2

gros = int(sum(LL))

for k in A:
    print(gros +1 - L[k])


Measured memory_bytes: 34152
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

from math import factorial
from itertools import permutations

def main():
  n = ni()
  xy = [na() for _ in range(n)]

  ff = lambda a, b, c, d: ((a - b) ** 2 + (c - d) ** 2) ** 0.5

  res = []
  for per in permutations(range(n)):
    tmp = 0
    for i, pp in enumerate(per[:-1]):
      tmp += ff(xy[pp][0], xy[per[i+1]][0], xy[pp][1], xy[per[i+1]][1])
    res.append(tmp)
  print(sum(res) / factorial(n))


if __name__ == '__main__':
  main()
 


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

int main(){
  int n;
  cin>>n;
  ll a[n],large0,small0,ans=0;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(n%2==0){
    large0=0;
    small0=0;
    for(int i=0;i<n/2-1;i++){
      large0+=a[n-i-1]-a[i];
      large0+=a[n-i-1]-a[i+1];
    }
    large0+=a[n/2]-a[0];
    ans=max(ans,large0);
    for(int i=0;i<n/2-1;i++){
      small0+=a[n-i-1]-a[i];
      small0+=a[n-i-2]-a[i];
    }
    small0+=a[n-1]-a[n/2-1];
    ans=max(ans,small0);
  }
  else{
    large0=0;
    small0=0;
    for(int i=0;i<n/2-1;i++){
      large0+=a[n-i-1]-a[i];
      large0+=a[n-i-1]-a[i+1];
    }
    large0+=a[n/2+1]-a[n/2-1];
    large0+=a[n/2]-a[0];
    ans=max(ans,large0);
    for(int i=0;i<n/2-1;i++){
      small0+=a[n-i-1]-a[i];
      small0+=a[n-i-2]-a[i];
    }
    small0+=a[n/2+1]-a[n/2-1];
    small0+=a[n-1]-a[n/2];
    ans=max(ans,small0);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4364
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    int x, y;
    cin >> x >> y;

    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
      if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
        cout << "Yes";
      }else{
        cout << "No";
      }
    }else if(x == 4 || x == 6 || x == 9 || x == 11){
      if(y == 4 || y == 6 || y == 9 || y == 11){
        cout << "Yes";
      }else{
        cout << "No";
      }
    }else if(x == 2){
      if(y == 2){
        cout << "Yes";
      }else{
        cout << "No";
      }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		in.close();
		if(k==0) {
			System.out.println((long)n*n);
		}else {
			long ans = 0;
			for(int b=1;b<=n;b++) {
				if(b<k+1) continue;
				ans += (n/b)*(b-k);
				int remain = n-(n/b)*b;
				ans += remain>=k ? remain-k+1 : 0;
			}
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll a, b;
    cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout <<"Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3596
/**
 *    author:  whohet
 *    created: 11-07-2020 17:00:37
**/

#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

signed main()
{
	fasterthanlight;
	int n;
	cin >> n; int a, b;
	cin >> a >> b;
	int arr[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	sort(arr, arr + n);

	int x = 0, y = 0, z = 0;
	for (int i = 0; i < n; i++)
	{
		if (arr[i] <= a)
			x++;
		else if (arr[i] <= b)
			y++;
		else
			z++;
	}
	y = min(y, z);
	cout << min(x, y);



	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, x, y, dist[2005], ans[2005];
vector<int> adj[2005];

int main() {
	fastio; cin >> n >> x >> y;
	FOR(i, 1, n-1) {
		adj[i].pb(i+1);
		adj[i+1].pb(i);
	}
	adj[x].pb(y); adj[y].pb(x);
	FOR(i, 1, n) {
		memset(dist, -1, sizeof dist); dist[i] = 0;
		queue <pi> q; while (!q.empty()) q.pop();
		q.push(pi(i, 0));
		while (!q.empty()) {
			pi cur = q.front(); q.pop();
			for (auto it:adj[cur.f]) {
				if (dist[it] == -1 or dist[it] > cur.s + 1) {
					dist[it] = cur.s + 1;
					q.push(pi(it, dist[it]));
				}
			}
		}
		FOR(i, 1, n) ans[dist[i]]++;
	}
	FOR(i, 1, n-1) cout << ans[i]/2 << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

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

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n, m;
  cin >> n;
  
  map<string, int> mp;
  rep(i, 0, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  
  cin >> m;
  
  rep(i, 0, m) {
    string s;
    cin >> s;
    mp[s]--;
  }
  
  int ans = -1e9;
  map<string, int>::iterator p;
    for(p = mp.begin(); p != mp.end(); p++)
      ans = max(p->second, ans);
  
  cout << max(0, ans) << "\n";

}


Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1

typedef struct{
  int parent;
  int l;
  int r;
}Node;

Node T[10000];
int n,D[10000+32];
int H[10000+67];
void Depth(int ,int);
int Height(int);
int sibling(int);
void print(int);


int main(){
  int i,v;
  int l,r,root = 0;
  scanf("%d",&n);
  i=0;
  while(i<n){
    T[i].parent = NIL;
    ++i;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }
  for(i=0;i<n;i++)
  if(T[i].parent == NIL)root = i;
  Depth(root,0);
  Height(root);
  i=0;
  while(i<n){
  
  print(i);
  i++;
}
  return 0;
}
void Depth(int u,int q){
  if(u == NIL)
  return;
  D[u]=q;
  Depth(T[u].l,q+1);
  Depth(T[u].r,q+1);
}
int Height(int u){
  int h1=0;
  int h2=0;
  if(T[u].l!=NIL)
    h1 = Height(T[u].l) + 1;
  if(T[u].r!=NIL)
    h2 = Height(T[u].r) + 1;
  if(h1>h2)
  return H[u]=h1;
  else 
  return H[u]=h2;
}
int Sibling(int u){
  if(T[u].parent == NIL)return NIL;
  if(T[T[u].parent].l != u && T[T[u].parent].l != NIL)
return T[T[u].parent].l;
  if(T[T[u].parent].r != u && T[T[u].parent].r != NIL)
return T[T[u].parent].r;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",Sibling(u));
  int deg = 0;
  if(T[u].l != NIL)deg++;
  if(T[u].r != NIL)deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
  if(T[u].parent==NIL){
    printf("root\n");
  }
    else if(T[u].l == NIL && T[u].r == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}


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

int main(){
	char a[4],flag='1';
	int c;
	int i;
	cin>>a;
	for(i=0;i<3;i++){
		if(a[i] == flag){
			cout<<9;
		}else{
			cout<<1;
		}
	}	
}


Measured memory_bytes: 256
num = int(input())
list = list(map(int, input().split()))

for i in range(num):
    v = list[i]
    if i == 0:
        list[0] = v
    else:
        j = i - 1
        while j >= 0 and list[j] > v:
            list[j+1] = list[j]
            j -= 1
        list[j+1] = v

    result = ''
    for i in range(num):
        result += str(list[i]) + ' '

    print(result[:-1])


Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	int n;
	cin >> n;
	
	int ans = 180 * (n-2);	

	cout << ans << endl;
}

Measured memory_bytes: 256
#ABC069C
N=int(input())
a=list(map(int,input().split()))
#奇数、4の倍数の数を数える。2の倍数だが4の倍数でないものの数は数えなくてよい。
odd=0
four=0
for i in range(N):
    if a[i]%2==1:
        odd+=1
    elif a[i]%4==0:
        four+=1
#4の倍数の個数が奇数の個数以上であればOK
if four>=odd:
    print('Yes')
#4の倍数の個数が奇数の個数-1の時は、他に数が無ければOK
elif four+1==odd and four+odd==N:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14224
#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int S = 1000 , maxn = 5e5+5;
struct box{
	int l,r,i;
	bool operator <(const box other){
		if( l/S != other.l/S )return l/S < other.l/S;
		return  r < other.r;
	}
};
vector<int>a(maxn),ans(maxn),cnt(maxn);
vector<box>q(maxn);
vector<int>mp;
int n,m,tot=0;
void insert(int x){
	if( !cnt[x] )tot++;
	cnt[x]++;
}
void remove(int x){
	cnt[x]--;
	if( !cnt[x]  ){
		tot--;
	}
}
int32_t main(){
	IOS
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];mp.push_back(a[i]);
	}
	for(int i=1;i<=m;i++){
		cin>>q[i].l>>q[i].r;q[i].i=i;
	}
	sort(q.begin()+1,q.begin()+m+1);
	sort(mp.begin(),mp.end());
	mp.erase(unique(mp.begin(),mp.end()),mp.end());
	for(int i=1;i<=n;i++){
		a[i]=lower_bound(mp.begin(),mp.end(),a[i])-mp.begin()+1;
	}
	int l = 1 , r = 1;
	for(int i=1;i<=m;i++){
		while( r <= q[i].r ){
			insert(a[r++]);
		}
		while( l < q[i].l ){
			remove(a[l++]);
		}
		while( l > q[i].l ){
			insert(a[--l]);
		}
		while( r > q[i].r + 1){
			remove(a[--r]);
		}
		ans[q[i].i]=tot;
	}
	for(int i=1;i<=m;i++){
		cout<<ans[i]<<endl;
	}
}


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

int main() {
    int S;
    cin >> S;
    ll mod = 1e9+7;
    vector<ll> dp(S+1, 0);
    dp[0] = 1;
    for (int i = 1; i <= S; i++) {
        for (int j = 0; j <= i-3; j++) {
            dp[i] += dp[j];
            dp[i] %= mod;
        }
    }
    cout << dp[S] << endl;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int  MaxN = 1e5;
int a[MaxN + 5], b[MaxN + 5];
int c[MaxN + 5];

int main()
{
	int n;
	memset(a, 0, sizeof(a));
	while(~scanf("%d", &n)){
		for (int i = 1; i <= n; i++)	scanf("%d", &a[i]);
		sort(a + 1, a + 1 + n);
		int t = 0;
		int num = 1;
		if (n == 1)	printf("1\n");
		else{
			for(int i = 2; i <= n + 1; i++){
				if (a[i] != a[i-1]){
					b[++t] = a[i - 1];
					c[t] = num;
					num = 1;
				}
				else num++;
			}
			int ans = 0;
			for (int i = 1; i <= t; i++){
				if (c[i] % 2 == 1)	ans++;
			}
			printf("%d\n", ans);
		}
	}
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(void) {
	int n,m;
	char trans[100][2];
	char c;

	while (scanf("%d", &n), n) {
		for (int i = 0; i < n; i++) {
			scanf(" %c %c", &trans[i][0], &trans[i][1]);
		}
		scanf("%d", &m);
		for (int i = 0; i < m; i++) {
			scanf(" %c", &c);
			for (int j = 0; j < n; j++) {
				if (trans[j][0] == c) {
					c = trans[j][1];
					break;
				}
			}
			printf("%c", c);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 996
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;



int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextInt();
        double b = scanner.nextInt();

        // === ans1 ===
        System.out.println((int) Math.ceil((a + b) / 2));

    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
struct NODE{
	int x,y,d;
	NODE(int a,int b,int c){x=a , y=b, d=c;}
};

int main(){
	int W,H;
	while(cin >> W >> H , H){
		bool data[62][62] = {0};
		rep(i,62)rep(j,62)data[i][j] = 1;
		rep(i,H*2-1)rep(j,W*2-1)data[i+1][j+1] = 0;
		rep(i,2*H-1){
			if(i%2==0){
				rep(j,W-1){
					bool a;cin >> a;
					data[i+0][j*2+2] |= a;
					data[i+1][j*2+2] |= a;
					data[i+2][j*2+2] |= a;
				}	
			}else{
				rep(j,W){
					bool a;cin >> a;
					data[i+1][j*2+0] |= a;
					data[i+1][j*2+1] |= a;
					data[i+1][j*2+2] |= a;
				}
			}
		}
		int dx[] = {-1,0,1,0},dy[] = {0,-1,0,1};
		queue<NODE> Q;
		bool done[62][62] = {0};
		Q.push(NODE(1,1,0));
		while(Q.size()){
			NODE q = Q.front(); Q.pop();
			
			if(done[q.y][q.x])continue;
			else done[q.y][q.x] = true;
			
			if(q.x == W*2-1 && q.y == H*2-1){
				cout << (q.d+2)/2 << endl;
				goto end;
			}
			rep(i,4){
				int tx = dx[i] + q.x , ty = dy[i] + q.y;
				if(data[ty][tx] == true)continue;
				Q.push(NODE(tx,ty,q.d+1));
			}
		}
		cout << 0 << endl;
		end:;
	}
}

Measured memory_bytes: 920
def main():
  N, K = list(map(int, input().split()))
  A = list(map(int, input().split()))

  d = 60
  to = [[0] * N for _ in range(d)]

  for i in range(N):
    #テレポート距離が2^0のデータを入れる
    #これは入力A1〜ANと同じ
    to[0][i] = A[i] - 1 #0-indexedにする

  for i in range(1, d):
    for j in range(N):
      to[i][j] = to[i-1][to[i-1][j]]

  v = 0
  for i in range(d-1, -1, -1):
    l = 1 << i

    if(K >= l):
      v = to[i][v]
      K -= l

  print(v + 1)

if __name__ == "__main__":
  main()

Measured memory_bytes: 175716
n = 10**5
a = [0 for i in range(n+1)]

is_prime = [1 for i in range(n+1)]
is_prime[0], is_prime[1] = 0, 0

#エラトステネスの篩
for i in range(2, n+1):
    if (not is_prime[i]):
        continue
    for j in range(i*2, n+1, i):
        is_prime[j] = 0

for i in range(2, n+1):
    if i % 2 == 0:
        continue
    if is_prime[i] and is_prime[int((i+1)/2)]:
        a[i] = 1

s = [0 for i in range(n+1)]
for i in range(n):
    s[i+1] = s[i] + a[i]

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(s[r+1]-s[l])

Measured memory_bytes: 8056
h,w=gets.chomp.split(" ").map(&:to_i)
fir = 0;
w % 2 == 1 ?fir=((w+1)/2):fir=(w/2)
ans = 0
if h % 2 == 1
	ans = ((h -1)/2 * w ) + fir
else
	ans = h/2 * w
end
if w == 1|| h == 1 #対策忘れだとぉ！？
  ans = 1
end
puts ans


Measured memory_bytes: 1916