akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
#define yes        cout<<"YES"<<"\n"
#define no         cout<<"NO"<<"\n"
#define modsum(a,b)  ((a%mod)+(b%mod))%mod
#define modpro(a,b)  ((a%mod)*(b%mod))%mod
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
string s;cin>>s;
int su=0;
f(i,s.size())
{
  int x=(s[i]-'0');
  su=(su+x)%9;
}
if(su==0)cout<<"Yes";
else    cout<<"No";
}
  

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int a, b, c, ans, res = (int)1e4; 

int main () {
	cin >> a >> b >> c;
	for (int i = 0; i <= 100; i ++) {
		ans = 0;
		if (i < a || i < b || i < c) continue;
		int cur = (i - a) % 2;
		cur = cur + (i - b) % 2;
		cur = cur + (i - c) % 2;
		if (cur & 1) continue;
		ans = ans + (i - a) / 2;
		ans = ans + (i - b) / 2;
		ans = ans + (i - c) / 2;
		ans = ans + cur / 2;
		res = min(res, ans);
	}
	cout << res;
}                             

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

int solve(unordered_set<int>& s, int x) 
{
	int i;
	for(i=0; i<=100; ++i) {
		if(s.find(x-i) == s.end())
			return x-i;
		else if(s.find(x+i) == s.end())
			return x+i;
	}
	return x-i;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int x, n;	cin >> x >> n;
	unordered_set<int> s;
	for (int i = 0; i < n; ++i) {
		int p;	cin >> p;
		s.insert(p);
	}
	int ans = solve(s, x);
	cout << ans << '\n';
	return 0;
}

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

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;
using t64 = tuple<i64, i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, m, s;
    cin >> n >> m >> s;
    vector<vector<t64>> g(n);
    i64 lim = 0;
    for (i64 i = 0; i < m; i++) {
        i64 u, v, a, b;
        cin >> u >> v >> a >> b, u--, v--;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
        lim += a;
    }
    for (i64 i = 0; i < n; i++) {
        i64 c, d;
        cin >> c >> d;
        g[i].emplace_back(i, -c, d);
    }

    priority_queue<t64, vector<t64>, greater<>> pq;
    pq.emplace(0, 0, s);
    map<p64, i64> t;
    t[{0, s}] = 0;

    vector<i64> ans(n, -1);
    i64 u = n;
    while (!pq.empty()) {
        i64 time, town, coin;
        tie(time, town, coin) = pq.top(); pq.pop();

        if (ans[town] == -1) {
            ans[town] = time;
            u--;
            if (u == 0) break;
        }

        for (auto& e : g[town]) {
            i64 to, cost, wait;
            tie(to, cost, wait) = e;
            i64 ncoin = coin - cost, ntime = time + wait;
            if (ncoin < 0 || (ncoin > coin && ncoin > lim && coin > lim)) continue;
            if (t.find({to, ncoin}) != t.end() && t[{to, ncoin}] <= ntime) continue;
            t[{to, ncoin}] = ntime;
            pq.emplace(ntime, to, ncoin);
        }
    }

    for (i64 i = 1; i < n; i++) cout << ans[i] << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint n;
vector<llint> vec[6], ans;

int main(void)
{
  cin >> n;
  if(n <= 4){
    ans.push_back(2);
    ans.push_back(5);
    ans.push_back(63);
    if(n == 4) ans.push_back(20);
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << " "; cout << endl;
    return 0;
  }

  for(int i = 1; i <= 30000; i++) vec[i%6].push_back(i);

  ans.push_back(vec[2][0]);
  ans.push_back(vec[4][0]);
  ans.push_back(vec[3][0]);
  ans.push_back(vec[3][1]);

  vec[2].erase(vec[2].begin());
  vec[4].erase(vec[4].begin());
  vec[3].erase(vec[3].begin());
  vec[3].erase(vec[3].begin());

  n -= 4;

  for(int i = 0; i < vec[2].size() && n >= 2; i++){
    ans.push_back(vec[2][i]);
    ans.push_back(vec[4][i]);
    n -= 2;
  }
  for(int i = 0; i+1 < vec[3].size() && n >= 2; i+=2){
    ans.push_back(vec[3][i]);
    ans.push_back(vec[3][i+1]);
    n -= 2;
  }
  for(int i = 0; i < vec[0].size() && n > 0; i++){
    ans.push_back(vec[0][i]);
    n--;
  }

  for(int i = 0; i < ans.size(); i++) cout << ans[i] << " "; cout << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 1; i < (n + 1); i++)



int main()
{
    int n, m;
    cin >> n >> m;
    if (n <= m) {
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    string s;
    cin >> s;

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

    char c = 'a';

    for(int i = 0; i < s.size(); ++i){
        if(s.at(i) == c){
            ++c;
        }
    }

    if(c <= 'z')cout << c << endl;
    else cout << "None" << endl;

}

Measured memory_bytes: 512
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
ÍüÎÄ¼þ²Ù×÷£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
signed main(){
	int s=read(),w=read();
	if(w>=s)	puts("unsafe");
	else		puts("safe");
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    string s[4] = {"Christmas","Christmas Eve","Christmas Eve Eve","Christmas Eve Eve Eve"};
    int D;
    cin >> D;
    if(D == 25) cout << s[0];
    else if(D == 24) cout << s[1];
    else if(D == 23) cout << s[2];
    else if(D == 22) cout << s[3];
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int res = (N*(N-1) + M*(M-1)) >> 1;
		System.out.println(res);
	}
}

Measured memory_bytes: 23124
package main

import (
	"fmt"
)

func main() {
	const mod = int64(1000000007)
	n := 0
	var s string
	fmt.Scan(&n, &s)
	m := make(map[rune]int)
	for _, c := range s {
		m[c]++
	}
	ans := int64(1)
	for _, v := range m {
		ans = ans * int64(v+1) % mod
	}
	ans--
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int a, b; cin >> a >> b;
    int ans = 0;
    int num = 1;
    while (num < b) {
        num += a - 1;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long X = nx[1];
        //ちゅーごくじょーよてーり
        //オーダーによってSの終端が決定する
        //まず影響するのは降順のみなことは自明に分かって、
        //で、「次」を選ぶことができる順番は
        //「確率」「期待値」
        //aを取り除いた場合、その後に適用できるのはそれ以前全て。

        List<int> s = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToList();
        ModInt[] dp = new ModInt[X + 1];
        dp[X] = 1;
        int remain = s.Count - 1;
        foreach (var mod in s)
        {
            ModInt[] newDP = new ModInt[X + 1];

            for (int i = 0; i < dp.Length; i++)
            {
                newDP[i % mod] += dp[i];
                newDP[i] += dp[i] * remain;
            }
            remain--;
            dp = newDP;
        }
        ModInt res = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            res += dp[i] * i;
        }
        Console.WriteLine(res);
    }
}


struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ModInt(long data) { Data = data; Eval(); }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private long Eval() => (Data %= MOD) < 0 ? Data += MOD : Data;
    public static implicit operator long(ModInt modInt) => modInt.Eval();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long val) => new ModInt(val);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, ModInt b)
    {
        return new ModInt(a.Data + b.Data);
        //long res = a.Data + b.Data;
        //return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt(a.Data * b.Data);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 32152
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;

signed main() {
	int N;
	cin >> N;
	double num, ans;
	string S;
	ans = 0;
		for (int i = 0; i < N; i++) {
			cin >> num >> S;
			if (S == "JPY") ans += num;
			else ans += num * 380000;
		}
		cout << ans << endl;
}

Measured memory_bytes: 256
n , k = map(int, input().split())
a = list(map(int, input().split()))

dict = {}
for i in range(n):
  if a[i] in dict:
    dict[a[i]] += 1
  else:
    dict[a[i]] = 1
ans = sorted(dict.items(), key=lambda x:x[1])
if len(ans) <= k:
  print(0)
else:
  tmp = 0
  s = 0
  for i in ans:
    tmp += i[1]
    s+=1
    if s == len(dict) - k:
      break
  print(tmp)
    

Measured memory_bytes: 38964
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N,K;
  cin>>N>>K;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  vector<double>E(N+1);
  double tot=0;
  for(int i=0;i<N;i++){
    double sum=0;
    for(int j=1;j<=p[i];j++){
      sum+=j;
    }
    tot+=sum/p[i];
    E[i+1]=tot;
  }
  double ans=0;
  for(int i=1;i<=N-K+1;i++){
     chmax(ans,E[i+K-1]-E[i-1]);
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5584
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<bitset>
#define inf 999999999
using namespace std;
signed main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%lf",(double)n/m);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
	int N,i;
  	int a[10];
  	int max=0,sum=0;
  	scanf("%d",&N);
  	for(i=0;i<N;++i){
      scanf("%d",&a[i]);
      if(a[i]>=max)max=a[i];
    }
  	for(i=0;i<N;++i)sum+=a[i];
  	sum-=max;
  	if(max<sum)printf("Yes\n");
  	else printf("No\n");
  	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MOD (1000000000 + 7)
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string t;
  cin >> t;

  int n = t.length();

  ll dp[4][n + 1];

  dp[0][0] = 1;
  for(int i = 1; i <= n; i++){
    if(t[i - 1] != '?') dp[0][i] = dp[0][i - 1];
    else dp[0][i] = (3l * dp[0][i - 1]) % MOD;
  }

  dp[1][0] = 0;
  for(int i = 1; i <= n; i++){
    dp[1][i] = dp[1][i - 1];
    if(t[i - 1] == '?' || t[i - 1] == 'A'){
      dp[1][i] = (dp[1][i] + dp[0][i - 1]) % MOD;
    }
    if(t[i - 1] == '?'){
      dp[1][i] = (dp[1][i] + dp[1][i - 1]) % MOD;
      dp[1][i] = (dp[1][i] + dp[1][i - 1]) % MOD;
    }
  }

  dp[2][0] = 0;
  for(int i = 1; i <= n; i++){
    dp[2][i] = dp[2][i - 1];
    if(t[i - 1] == '?' || t[i - 1] == 'B'){
      dp[2][i] = (dp[2][i] + dp[1][i - 1]) % MOD;
    }
    if(t[i - 1] == '?'){
      dp[2][i] = (dp[2][i] + dp[2][i - 1]) % MOD;
      dp[2][i] = (dp[2][i] + dp[2][i - 1]) % MOD;
    }
  }

  dp[3][0] = 0;
  for(int i = 1; i <= n; i++){
    dp[3][i] = dp[3][i - 1];
    if(t[i - 1] == '?' || t[i - 1] == 'C'){
      dp[3][i] = (dp[3][i] + dp[2][i - 1]) % MOD;
    }
    if(t[i - 1] == '?'){
      dp[3][i] = (dp[3][i] + dp[3][i - 1]) % MOD;
      dp[3][i] = (dp[3][i] + dp[3][i - 1]) % MOD;
    }
  }

  cout << dp[3][n] << endl;

  return 0;
}


Measured memory_bytes: 3648
N = int(input())
S = input()
top = 0
for i in range(len(S)):
  a = S[:i]
  b = S[i:]
  a = set(a)
  b = set(b)
  a = list(a)
  b = list(b)
  c = len(a) + len(b) - len(set(a+b))
  top =  max(c,top)
print(top)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
 
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

    ll n,k,i,j;
    cin>>n;
    if(n == 2) {cout<<1;return 0;}
    ll q,r,ans=2,tmp;
    for(i=2;i*i<=n;i++)
    {
        if(n%i == 0)
        {
            tmp = n;
            while(tmp%i == 0)
            {
                tmp/=i;
            }
            if(tmp%i == 1) ans++;
            q = n/i;
            if(q!=i)
            {
                tmp = n;
                while(tmp%q == 0)
                {
                    tmp/=q;
                }
                if(tmp%q == 1) ans++;   
            }
        }
    }
    ll m = n-1;
    for(i=2;i*i<=m;i++)
    {
        if(m%i == 0)
        {
            if(i*i == m) ans++;
            else ans+=2;
        }
    }
    cout<<ans;
    // cout<<"\n";
    // vector<ll> a;
    // for(i=2;i<=n;i++)
    // {
    //     if(n%i == 0)
    //     {
    //         ll tmp = n;
    //         while(tmp%i == 0)
    //         {
    //             tmp/=i;
    //         }
    //         if(tmp%i == 1) a.pb(i);
    //     }
    //     else if(n%i==1) a.pb(i);
    // }
    // cout<<sz(a)<<"\n";
    // for(auto h :a) cout<<h<<" ";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int r = W;
    int l = 0;
    int u = H;
    int d = 0;
    for (int i = 0; i < N; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            chmax(l, x);
        } else if (a == 2) {
            chmin(r, x);
        } else if (a == 3) {
            chmax(d, y);
        } else if (a == 4) {
            chmin(u, y);
        }
    }
    if (l < r && d < u) {
        cout << (r - l) * (u - d) << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
    char s1[5], s2[5];
    scanf("%s", s1);
    scanf("%s", s2);
    if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
        printf("YES");
    else
        printf("NO");
    return 0;
}

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

int a[1000];

int main(void)
{
  while (1) {
    string s1, s2;
    vector<string> s1double;
    vector<string> s2double;
    vector<string> s1word;
    vector<string> s2word;
    cin >> s1 >> s2;
    if (s1[0] == '.') {
      break;
    }
    string tmp = "\0", tmpp = "\0";
    for (int i = 0; i < s1.size(); ++i) {
      if (s1[i] == '"') {
	if (tmpp != "\0")
	s1word.push_back(tmpp);
	tmpp = "\0";
        int j = i + 1;
	for (; s1[j] != '"'; ++j) {
	  tmp += s1[j];
	}
	i = j;
	s1double.push_back(tmp);
	tmp = "\0";
      } else {
	tmpp += s1[i];
      }
    }
    if (tmpp != "\0")
    s1word.push_back(tmpp);
    tmp = "\0", tmpp = "\0";
    for (int i = 0; i < s2.size(); ++i) {
      if (s2[i] == '"') {
	if (tmpp != "\0")
	s2word.push_back(tmpp);
	tmpp = "\0";
        int j = i + 1;
	for (; s2[j] != '"'; ++j) {
	  tmp += s2[j];
	}
	i = j;
	s2double.push_back(tmp);
	tmp = "\0";
      } else {
	tmpp += s2[i];
      }
    }
    if (tmpp != "\0")
    s2word.push_back(tmpp);
    int flag = 0;
    if (s1word.size() != s2word.size() || s1double.size() != s2double.size()) {
      flag = 2;
    } else {
      for (int i = 0; i < s1word.size(); ++i) {
	if (s1word[i] != s2word[i]) {
	  flag = 2;
	}
      }
      for (int i = 0; i < s1double.size(); ++i) {
	if (s1double[i] != s2double[i]) {
	  ++flag;
	}
      }
    }
    if (flag == 0) {
      cout << "IDENTICAL" << endl;
    } else if (flag == 1) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl; 
    }
  }
  return 0;
}



Measured memory_bytes: 3244
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,min1,min2;
	cin>>a>>b>>c;
	min1=min(a,min(b,c));
	if(min1==a)
	{
		min2=min(b,c);
	}
	if(min1==b)
	{
		min2=min(a,c);
	}
	if(min1==c)
	{
		min2=min(b,a);
	}
	cout<<min1+min2<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main()
{
	string s;
	cin>>s;
	if(s=="SUN")
	{
		cout<<7<<endl;
	}
	if(s=="MON")
	{
		cout<<6<<endl;
	}
	if(s=="TUE")
	{
		cout<<5<<endl;
	}
	if(s=="WED")
	{
		cout<<4<<endl;
	}
	if(s=="THU")
	{
		cout<<3<<endl;
	}
	if(s=="FRI")
	{
		cout<<2<<endl;
	}
	if(s=="SAT")
	{
		cout<<1<<endl;
	}
}


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

static const int MAX = 500;
int mat[MAX][MAX];
int h, w;

pair<int, int> next(int i, int j){
    int ni, nj;
    if(i % 2 == 0){
        if(j < w-1){
            ni = i, nj = j+1;
        } else {
            ni = i+1, nj = j;
        }
    } else {
        if(j > 0){
            ni = i, nj = j-1;
        } else {
            ni = i+1, nj = j;
        }
    }
    if(ni < 0 || h <= ni || nj < 0 || w <= nj){
        return make_pair(-1, -1);
    } else {
        return make_pair(ni, nj);
    }
}

int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
        }
    }

    int i = 0, j = 0;
    vector<vector<int>> arr;
    while(1){
        int ni, nj;
        tie(ni, nj) = next(i, j);
        if(ni == -1 || j == -1) break;

        if(mat[i][j] % 2){
            mat[i][j]--;
            mat[ni][nj]++;
            arr.push_back({i, j, ni, nj});
        }

        i = ni, j = nj;
    }

    cout << arr.size() << endl;
    for(auto a : arr){
        for(int i = 0; i < 4; i++){
            if(i) cout << " ";
            cout << a[i]+1;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 9904
import sys
input = sys.stdin.readline

N = int(input())
ans = 0
ans = [[0] * (N+1) for _ in range(N+1)]
depth = 1

def dfs(l, r, d):
    global depth
    if l == r:
        return
    depth = max(depth, d)
    m = (l + r) // 2
    for i in range(l, m+1):
        for j in range(m, r+1):
            ans[i][j] = ans[i][j] = d
    dfs(l, m, d+1)
    dfs(m+1, r, d+1)

dfs(1, N, 1)
for i in range(1, N):
    print(*ans[i][i+1:])

Measured memory_bytes: 48092
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif

static void A_task();

int main()
{
	A_task();
	
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int N, K;
	scanf(" %d %d", &N, &K);

	int ans = N - K;
	if (K == 1) {
		ans = 0;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#define N 300000
using namespace std;
int main(){
  int n,i,j,sosu[N];
  set<int> s;
  for(i=2;i<=N;i++){
    if(i%7==1||i%7==6) sosu[i]=1;
    else sosu[i]=0;
  }
  for(i=2;i<=N;i++){
    if(sosu[i]==1){
      for(j=i*2;j<=N;j+=i){
    sosu[j]=0;
      }
    }
  }
  while(1){
    cin >> n;
    if(n==1) break;
    for(i=0;i<=n;i++){
      if(sosu[i]==1&&n%i==0){
    s.insert(i);
      }
    }
    cout << n << ':';
    for(set<int>::iterator it=s.begin();it!=s.end();it++){
      cout << ' ' << (*it);
    }
    cout << endl;
    s.clear();
  }
  return 0;
}

Measured memory_bytes: 2364
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        u,v,w = map(int, input().split())
        u,v = u-1,v-1
        G[u].append((v,w))
        G[v].append((u,w))

    ans = [-1] * N
    ans[0] = 0
    stack = [(0,0)]
    while stack:
        v, w = stack.pop()
        for to, to_w in G[v]:
            if ans[to] >= 0: continue
            ans[to] = 1 if (w + to_w) & 1 else 0
            stack.append((to, w + to_w))
    
    for a in ans: print(a)

if __name__ == '__main__':
    main()

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

using namespace std;

char s[300005];
int sum[300005];
int main(){
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    for(int i = 0; i < n; i++){
        if(i == 0) sum[i] = (s[i] == 'W');
        else sum[i] = sum[i - 1] + (s[i] == 'W');
    }
    int mx = 300001;
    for(int i = 0; i < n; i++){
        if(i == 0) mx = min(mx, n - 1 - (sum[n - 1] - sum[0]));
        else mx = min(mx, sum[i - 1] + n - 1 - i - (sum[n - 1] - sum[i]));
    }
    printf("%d\n", mx);
}


Measured memory_bytes: 1664
(n,m,k),*A,=[list(map(int,i.split())) for i in open(0)]
a=A[0]
b=A[1]

aa=[0]
bb=[0]
for i in range(n):
    aa.append(aa[i]+a[i])
for i in range(m):
    bb.append(bb[i]+b[i])

ans=0

for i in range(n+1):
    if aa[i]>k:
        break
    while bb[m]>k-aa[i]:
        m-=1
    ans=max(ans,m+i)
        
print(ans)

Measured memory_bytes: 47120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define fastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define ao(a)        \
    for (auto i : a) \
        cout << i << " ";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main()
{
    ll n, k;
    cin >> n >> k;
    ll a[n], b[n];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    sort(a, a + n, greater<ll>());
    sort(b, b + n);
    ll l = -1, r = a[0] * b[n-1], p = k, mid;
    while (r - l > 1)
    {
        p = k;
        mid = (l + r) >> 1;
        rep(i, n)
        {
            p -= max(0LL, a[i] - (mid / b[i]));
            if (p < 0)
                break;
        }
        if (p >= 0)
            r = mid;
        else
            l = mid;
    }
   c(r)
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll h,w,k;
ll x1,y_1,x2,y2;
v2 c;
v3 vis;
priority_queue<tuple<ll,ll,ll,ll>, vector<tuple<ll,ll,ll,ll>>, greater<tuple<ll,ll,ll,ll>>> pq;
ll dx[] = {0, 1, 0, -1};
ll dy[] = {1, 0, -1, 0};
ll ans = -1;


int main(){
    cin >> h >> w >> k;
    cin >> x1 >> y_1 >> x2 >> y2;
    c = v2(h+2, v1(w+2, 1));
    for(ll i = 1;i <= h;i++){
        string s;
        cin >> s;
        for(ll j = 1;j <= w;j++){
            c[i][j] = (s[j-1] == '@');
        }
    }
    vis = v3(4, v2(h+2, v1(w+2, 0)));
    pq.push(make_tuple(0ll, 0ll, x1, y_1));
    while(!pq.empty()){
        ll cost, d, x, y;
        tie(cost, d, x, y) = pq.top();
        pq.pop();
        if(vis[d][x][y]) continue;
        vis[d][x][y] = 1;
        if(x == x2 && y == y2){
            ans = (cost + k - 1) / k;
            break;
        }
        ll next_x = x + dx[d];
        ll next_y = y + dy[d];
        if(c[next_x][next_y] == 0 && vis[d][next_x][next_y] == 0){

            pq.push(make_tuple(cost+1, d, next_x, next_y));
        }
        for(ll i = 0;i < 4;i++){
            ll next_cost = ((cost + k - 1) / k) * k;
            if(vis[i][x][y] == 0){
                pq.push(make_tuple(next_cost, i, x, y));
            }
        }


    }
    cout << ans << endl;

}


Measured memory_bytes: 151668
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A.at(i);
	int ans = 0;
	rep(i, N) {
		int B;
		cin >> B;
		ans += B;
	}
	vector<int> C(N - 1);
	rep(i, N - 1) cin >> C.at(i);
	rep(i, N - 1) {
		if (A.at(i) + 1 == A.at(i + 1)) ans += C.at(A.at(i) - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring> 
#include <iostream>
#include <queue> 
using namespace std;
int n,m,k; 
int main(){
	scanf("%d%d%d",&n,&m,&k);
	if(n%m==0) printf("%d\n",n/m*k);
	else printf("%d\n",(n/m+1)*k);
	return 0;
} 

Measured memory_bytes: 3780
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<vector<int>> G(N);

  F0R(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> rs(N, -1);
  rs[0] = 0;

  queue<int> qu;
  qu.push(0);

  while (qu.size()) {
    int x = qu.front();
    qu.pop();

    for (auto c : G[x]) {
      if (rs[c] >= 0) continue;
      rs[c] = x;
      qu.push(c);
    }
  }

  cout << "Yes" << newl;
  FOR(i, 1, N) {
    cout << (rs[i] + 1) << newl;
  }
}
#endif


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

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


int main(){
	int n;
	string match,list[100];
	
	cin>>match;
	cin>>n;
	
	int m = match.size()-1;
	int ret = 0;
	rep(i,n){
		cin>>list[i];
		list[i] += list[i].substr(0,m);
		//cout << list[i] << endl;
		if( list[i].find(match,0) != string::npos )ret++;
		//puts("--------");
	}
	printf("%d\n",ret);

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

/** 累積和 */
template<typename T>
vector<T> calc_csum(vector<T> &val) {
	vector<T> sum(val.size() + 1);
	partial_sum(val.begin(), val.end(), sum.begin() + 1);
	return sum;
}

template<typename T>
T sum_csum(vector<T> &sum, int begin, int end) {
	return sum[end] - sum[begin];
}

template<typename T>
vector< vector<T> > calc_csum2(vector< vector<T> > &val) {
	int H = val.size();
	int W = val[0].size();
	vector< vector<T> > sum(H + 1, vector<T>(W + 1));

	for (int y = 0; y < H; y++) {
		partial_sum(val[y].begin(), val[y].end(), sum[y + 1].begin() + 1);
	}

	for (int y = 0; y < H; y++) {
		for (int x = 0; x <= W; x++) {
			sum[y + 1][x] += sum[y][x];
		}
	}

	return sum;
}

template<typename T>
T sum_csum2(vector< vector<T> > &sum, int y1, int y2, int x1, int x2) {
	return sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1];
}

/** /累積和 */


typedef tuple<int, int, int, int> Kukei;

int H, W, S;
int total_power;
VVI tile;
VVI c_tile;
vector< vector< vector< vector<PII> > > > memo;

bool can_group(int x1, int x2, int y1, int y2) {
	return total_power - S <= sum_csum2<int>(c_tile, y1, y2, x1, x2);
}

PII dfs(int x1, int x2, int y1, int y2) {
	PII tmp = memo[y1][x1][y2][x2];
	if (tmp.first != -1) {
		return tmp;
	}
	
	PII res(-1, -1);

	if (!can_group(x1, x2, y1, y2)) {
		return memo[y1][x1][y2][x2] = res;
	}

	for (int v = x1 + 1; v < x2; v++) {
		PII a = dfs(x1, v, y1, y2);

		if (a.first == -1) {
			continue;
		}

		PII b = dfs(v, x2, y1, y2);

		if (b.first == -1) {
			continue;
		}

		res = max(res, make_pair(a.first + b.first, min(a.second, b.second)));
	}

	for (int h = y1 + 1; h < y2; h++) {
		PII a = dfs(x1, x2, y1, h);

		if (a.first == -1) {
			continue;
		}

		PII b = dfs(x1, x2, h, y2);

		if (b.first == -1) {
			continue;
		}

		res = max(res, make_pair(a.first + b.first, min(a.second, b.second)));
	}

	if (res.first == -1) {
		res = make_pair(1, sum_csum2<int>(c_tile, y1, y2, x1, x2));
	}

	return memo[y1][x1][y2][x2] = res;
}

int main(void) {
	while(cin >> H >> W >> S, H) {
		tile = VVI(H, VI(W, 0));
		total_power = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				cin >> tile[i][j];
				total_power += tile[i][j];
			}
		}

		memo = vector< vector< vector< vector<PII> > > >(H + 1,
				vector< vector< vector<PII> > >(W + 1,
				vector< vector<PII> >(H + 1,
				vector<PII>(W + 1,
				make_pair(-1, -1)))));

		c_tile = calc_csum2<int>(tile);

		PII ans = dfs(0, W, 0, H);

		cout << ans.first << " " << (S - total_power + ans.second) << endl;
	}

	return 0;
}

Measured memory_bytes: 19592
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    c = input()
    r = c.count("R")
    ans = 0
    for i in range(r, n):
        if c[i] == "R":
            ans += 1
    print(ans)

if __name__=="__main__":
    main()


Measured memory_bytes: 68696
#include "bits/stdc++.h"
using namespace std;
struct aa {
	int id;
	int score;
	int num;
	aa() {
		id = 0;
		score = 0;
		num = 0;
	};
};
bool operator<(const aa&l, const aa&r) {
	return l.num == r.num ? l.score == r.score ? l.id<r.id : l.score<r.score : l.num >r.num;
}
int main() {
	while (1) {
		int T, P, R; cin >> T >> P >> R;
		if (!T)break;
		int miss[100][100];
		memset(miss, 0, sizeof(miss));
		int score[100][100];
		memset(score, 0, sizeof(score));
		for (int i = 0; i < R; ++i) {
			int a, b, c; cin >> a >> b >> c;
			a--; b--;
			string st; cin >> st;
			if (st == "WRONG") {
				miss[a][b]++;
			}
			else {
				score[a][b] += miss[a][b] * 1200 + c;
			}
		}
		vector<aa>scores(T);
		for (int i = 0; i < T; ++i) {
			scores[i].id = i;
			for (int j = 0; j < P; ++j) {
				scores[i].score += score[i][j];
				if (score[i][j])scores[i].num++;
			}
		}
		sort(scores.begin(), scores.end());
		for (auto s : scores) {
			cout << s.id+1 << " " << s.num << " " << s.score << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3228
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N,A;
        cin >> N>>A;
        if (N % 500 <=A)
        {
                puts("Yes");
        }
        else
        {
                puts("No");
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

string S,T; cin >> S >> T;

if (T.substr(0, S.size()) == S) cout << "Yes\n";
else cout << "No\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 3640
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n, m]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const a: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    let sum = 0;
    for (let i = 0; i < m; i++) {
      sum += a[i];
    }
    return `${sum > n ? -1 : n - sum}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

main()
{
	int flag=0;
	set<char> s;
	char input[2000];
	int i,j,len;
	
	scanf("%s",input);
	len=strlen(input);
	
	for(i=0;i<len;i++)
	{
		if(s.count(input[i])==0)
		{
			s.insert(input[i]);
		}
		else
		{
			flag=1;
			break;
		}
	}
	if(flag==0)
	{
		printf("yes");
	}
	else if(flag==1)
	{
		printf("no");
	}
	
}

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

int main() {
  int A, B, C, D;
  string op;
  cin >> A >> B >> C >> D;
  if(A+B > C+D){
    cout << "Left" << endl;
  }
  else if(A+B == C+D){
    cout << "Balanced" << endl;
  }
  else if(A+B < C+D){
    cout << "Right" << endl;
  }
}

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

int calc(int x) {
  char buf[128];
  sprintf(buf, "%08d", x*x);
  buf[6] = '\0';
  return atoi(buf+2);
}

int main() {
  int n;
  cin >> n;
  for(int tc = 0; tc < n; ++tc) {
    int x;
    cin >> x;
    cout << "Case " << tc+1 << ":" << endl;
    for(int i = 0; i < 10; ++i) {
      cout << (x = calc(x)) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    
    int k = n / 200;
    cout << 10 - k << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    for(int i = 0; i < N; i++){
        cin >> x.at(i);
    }
    for(int i = 0; i < M; i++){
        cin >> y.at(i);
    }
    x.push_back(X);
    y.push_back(Y);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if(x.at(N) < y.at(0)){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    umap<char,ll> Map;
    uset<ll> kind;
    ll x;
    INT(n);
    string s;
    cin>>s;
    rep(i,n){
        if(kind.count(s[i])){
            Map[s[i]]++;
        }else{
            kind.insert(s[i]);
            Map[s[i]]=1;
        }
    }
    ll ans=1;
    for(auto key:kind){
        //選ばないという選択肢もあるためプラス1
        ans*=(Map[key]+1);
        ans%=MOD;
    }
    //すべて選ばなかった場合は文字列ができないのでマイナス1
    ans--;
    if(ans<0)ans+=MOD;
    out(ans);
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A, B, C, D;
  	
  	cin >> A >> B >> C >> D;
  	if ( (A+B) > (C+D) ) {
      cout << "Left" << endl;
    } else if ( (A+B) < (C+D) ) {
      cout << "Right" << endl;
    } else if ( (A+B) == (C+D) ) {
      cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W,N;
int sx, sy;
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    if(A<=B*2) cout << 0 << endl;
    else cout << A-2*B << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
ll a[N];
int d[42];

void f(ll x)
{
    int p=0;
    while(x)
    {
        p++;
        if(x&1)
            d[p]++;
        x/=2;
    }
}
int main()
{
    int n;
    ll k,sum=0;
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]),f(a[i]);


    for(int i=41;i>=1;i--)
    {
        ll h=(1ll<<(i-1));

        if(d[i]>=n-d[i])
            sum+=d[i]*h;
        else
        {
            if(k<h) sum+=d[i]*h;
            else
            {
                sum+=(n-d[i])*h;
                k-=h;
            }
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x=sc.nextLong(),cost=100;
		for(int i=1;;i++) {
			cost*=1.01;
			if(cost>=x) {
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 35784