akhauriyash/Code-Regression huggingface dataset:
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#ifndef ONLINE_JUDGE
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#else
#define DBG(x)
#endif

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;

#define int long long

vector<vector<int>> v;
int r,c,k;

int dp[3005][3005][5];

int solve(int i,int j,int cnt)
{
    if(i==r || j==c)
    {
        if((i==r-1 && j==c) || (i==r && j==c-1))
        {
            if(cnt<=3) return 0;
            return LLONG_MIN;
        }

        return LLONG_MIN;
    }

    int &ret = dp[i][j][cnt];
    if(~ret) return ret;

    ret = 0;

    if(cnt<=2) ret = max(ret, v[i][j] + solve(i,j+1,cnt+1));
    ret = max(ret, solve(i,j+1,cnt));
    if(cnt<=2) ret = max(ret, v[i][j] + solve(i+1,j,0));
    ret = max(ret, solve(i+1,j,0));

    return ret;
}


int32_t main()
{
    optimizeIO();


    cin>>r>>c>>k;

    v = vector<vector<int>>(r,vector<int>(c));

    while(k--)
    {
        int x,y,val;
        cin>>x>>y>>val;

        x-- , y--;
        v[x][y] = val;
    }

    memset(dp,-1,sizeof dp);
    int ans = solve(0,0,0);
    cout<<ans<<endl;
    DBG(ans);

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 426920
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.concat(s);
        String p = sc.next();
        if(s.contains(p))System.out.println("Yes");
        else System.out.println("No");
        sc.close();
    }
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   100005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

int main()
{
    ll k=0,a,b,c;
    cin>>a>>b>>c;
    if(a==b && b!=c)
        k=1;
    else if(b==c && c!=a)
        k=1;
    else if(c==a && b!=a)
        k=1;


        if(k==1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    return 0;
}
































Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e5+5;
int n,i,fa[N],dg[N],a[N],h,t,q[N];
int et,he[N],cnt,hv[N];
struct edge{int l,v;}e[N];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
int get(int x){
	cnt++;int i;
	for (i=he[x];i;i=e[i].l) hv[e[i].v]=cnt;
	for (i=0;hv[i]==cnt;i++);return i;
}
int main(){
	for (n=read(),i=1;i<=n;i++)
		dg[fa[i]=read()]++;
	for (i=1;i<=n;i++) if (!dg[i]) q[++t]=i;
	while (h!=t){
		int x=q[++h],y=fa[x];a[x]=get(x);
		e[++et].l=he[y];he[y]=et;e[et].v=a[x];
		if (!(--dg[y])) q[++t]=y;
	}
	if (!((n-t)&1)){puts("POSSIBLE");return 0;}
	int k=-1;
	for (i=1;i<=n;i++) if (dg[i]){
		int v=get(i);if (k==-1) k=v;
		if (k!=v) break;
	}
	puts(i<=n?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 5760
// i hope i get better                                                           
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e2+9;
int k;
ll ans;

int gcd(int a,int b){
	if(a<b) swap(a,b);
	if(!b) return a;
	return gcd(b,a%b);
}

int main(){
	cin>>k;
	for(int i=1;i<=k;++i){
		for(int j=1;j<=k;++j){
			int g=gcd(i,j);
			for(int l=1;l<=k;++l){
				ans+=gcd(g,l);
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	
    int n,k ;    
    cin >> n >> k ;
    double ans ;

    for(int i=1;i<=n;i++){
        double prob = 1.0/n ;
        int tmp = i ;
       // int point = i ;
        while(tmp<k){
           prob = prob*0.5 ;
           tmp*=2 ;
        }
      ans += prob ;
    }
    
    cout << fixed << setprecision(10) << ans << endl ;
  	return 0;
}


Measured memory_bytes: 256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

int N;
double s_x, s_y, t_x, t_y;
double x[1002], y[1002], r[1002];
double mat[1002][1002];

void input() {
	cin >> s_x >> s_y >> t_x >> t_y >> N;
	REP(i, 1, N + 1) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[0] = s_x;
	y[0] = s_y;
	x[N + 1] = t_x;
	y[N + 1] = t_y;
}
void make_mat() {
	REP(i, 0, N + 2) {
		REP(j, 0, N + 2) {
			mat[i][j] = (i == j) ? INFD :
				max(0.0, sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i])) - (r[i] + r[j]));
		}
	}
}

bool ffixed[1002];
double dist[1002];
void dij() {
	REP(i, 0, N + 2) {
		dist[i] = INFD;
	}

	int curr = 0;
	dist[0] = 0;
	while(curr != N + 1){
		ffixed[curr] = true;
		REP(i, 0, N + 2) {
			if (ffixed[i] == false) {
				dist[i] = min(dist[i], dist[curr] + mat[curr][i]);
			}
		}

		int next = 0;
		double min = INFD;
		REP(i, 0, N + 2) {
			if (ffixed[i] == false && dist[i] < min) {
				next = i;
				min = dist[i];
			}
		}
		curr = next;
	}
	return;
}

int main() {
	input();
	make_mat();
	dij();
	printf("%.12f", dist[N + 1]);
	return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cstring>

char S[55], T[55];
char res[55];
int SL, TL;
int ok;

void solve()
{
	int i, j;
	SL = strlen(S);
	TL = strlen(T);
	char s[55];
	ok = 0;
	for(i=0; i<SL&&SL-i>=TL; i++){
		for(j=0; j<TL; j++){
			if(S[i+j]!=T[j] && S[i+j]!='?')
				break;
		}
		if(j==TL){
			for(j=0; j<SL; j++)
				s[j] = S[j];
			for(j=0; j<TL; j++)
				s[i+j] = T[j];
			for(j=0; j<SL; j++){
				if(s[j]=='?')
					s[j] = 'a';
			}
			s[SL] = 0;
			if(ok==0){
				strcpy(res, s);
				ok = 1;
			}
			else{
				if(strcmp(s, res) < 0)
					strcpy(res, s);
			}
		}
	}
	if(ok)
		printf("%s\n", res);
	else
		printf("UNRESTORABLE\n");
}

int main()
{
	scanf("%s", S);
	scanf("%s", T);
	solve();
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    a.push_back(97987493);
    each(i, a)--i;
    int ans = 0;
    FOR(i, 0, n) {
        if (a[a[i]] == i) {
            a[a[i]] = n;
            ++ans;
        }
    }
    cout << ans << "\n";
}

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

#define MAX_N 100

typedef long long ll;

using namespace std;

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

int main() {
  int N;
  cin >> N;
  ll res;
  cin >> res;
  for (int i = 1; i < N; ++i) {
    ll t;
    cin >> t;
    res = res * (t / gcd(res, t));
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 3184
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;

int main() {
    ll a, b;
    string u, s, t;
    cin >> s >> t >> a >> b >> u;
    cout << (u == s ? a - 1 : a) << " " << (u == t ? b - 1 : b) << endl;

}


Measured memory_bytes: 256
//g++でビルド

#include "bits/stdc++.h"

using namespace std;

int main(){
    int n;
    cin >> n;
    double result = 0;
    for(int i = 0; i < n; i++){
        double a;
        string b;
        cin >> a >> b;
        if(b == "BTC"){
            a = 380000.0 * a;
        }
        result += a;
    }
        

    cout << result << endl;
    return 0;
}

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

int main ()
{
	int a[105], c = 0, n; 
	cin >> n; 
	for (int i = 0; i < n; ++i)cin >> a[i]; 
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			for (int k = j + 1; k < n; ++k)
			{
				if (a[i] == a[j] || a[i] == a[k] || a[j] == a[k])continue; 
				else if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i])c++; 
			}
		}
	}
	cout << c << endl; 
}

Measured memory_bytes: 3488
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
ans = []
for i in range(n)[::-1]:
    tmp = i+1
    pl = a[i]
    tmp += i+1
    while tmp <= n:
        pl += b[tmp-1]
        tmp += i+1
    b[i] = pl % 2
for i in range(n):
    if b[i] == 1:
        ans.append(i+1)
print(len(ans))
print(*ans)


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

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

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

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

    bitset<200000> bs;
    cin >> bs;

    int64_t k = bs.count();
    int64_t k0 = max(1L, k - 1), k1 = k + 1;
    int64_t r0 = 0, r1 = 0, d0 = 1, d1 = 1;
    vector g(n, 0L);
    for (auto i : irange(0L, n)) {
        r0 += d0 * bs[i];
        r0 %= k0;
        r1 += d1 * bs[i];
        r1 %= k1;

        if (bs[i]) {
            g[i] = (k0 - d0 % k0) % k0;
        } else {
            g[i] = d1 % k1;
        }

        d0 = 2 * d0 % k0;
        d1 = 2 * d1 % k1;
    }

    for (auto i : irange(0L, n) | reversed) {
        bitset<20> m;
        if (bs[i]) {
            if (k == 1) {
                cout << 0 << "\n";
                continue;
            } else {
                m = (r0 + g[i]) % k0;
            }
        } else {
            m = (r1 + g[i]) % k1;
        }

        int64_t ans = 1;
        while (m.any()) {
            m = m.to_ullong() % m.count();
            ++ans;
        }

        cout << ans << "\n";
    }
}

Measured memory_bytes: 4696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
	static int n;
	static rep d[];
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		n = sc.nextInt();
		double a[] =new double[n];
		d = new rep[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextDouble();
			d[i] = convert(a[i]);
		}
		int numInt = 0;
		int maxX = -20;
		int minX = 1000;
		int maxY = -20;
		int minY = 1000;
		for(int i=0;i<n;i++) {
			if(d[i].x>=0 && d[i].y>=0) {
				numInt++;
				
			}
			maxX = Math.max(maxX, d[i].x);
			minX = Math.min(minX, d[i].x);
			maxY = Math.max(maxY, d[i].y);
			minY = Math.min(minY, d[i].y);
		}
		long lookUp[][] = new long[maxX-minX+1][maxY-minY+1];
		for(int i=minX;i<=maxX;i++) {
			for(int j=minY;j<=maxY;j++) {
				long temp = solve(i,j);
				lookUp[i-minX][j-minY] = temp;
			}
			
		}
		long res = 0;
		for(int i=0;i<n;i++) {
			res+=lookUp[d[i].x-minX][d[i].y-minY];
		}
		res-=numInt;
		res/=2;
		System.out.println(res);

	}
	static long solve(int a,int b) {
		long cnt = 0;
		for(int i=0;i<n;i++) {
			if(d[i].x>=-a && d[i].y>=-b) {
				cnt++;
			}
		}
		return cnt;
	}
	static rep convert(double k) {
		BigDecimal d = BigDecimal.valueOf(k);
		BigDecimal mult = BigDecimal.valueOf(1000000000);
		d = d.multiply(mult);
		BigInteger x = d.toBigInteger();
		int a =0;
		BigInteger two = BigInteger.valueOf(2);
		BigInteger five = BigInteger.valueOf(5);
		while(x.remainder(two).compareTo(BigInteger.ZERO)==0){
			a++;
			x = x.divide(two);
		}
		int b =0;
		while(x.remainder(five).compareTo(BigInteger.ZERO)==0) {
			b++;
			x = x.divide(five);
		}
		rep ret = new rep();
		a-=9;
		b-=9;
		ret.c = x;
		ret.x = a;
		ret.y = b;
		
		return ret;
	}
	public static class rep{
		
		BigInteger c;
		int x,y;
		
	}
	public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
 
 
    }
}


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

struct UnionFind{
    vector<int>parent;//親の番号
    UnionFind(int N):parent(N){
        rep(i,N){
            parent[i]=i;
        }
    }//全て根であるとして初期化
    int root(int x){
        if(parent[x]==x){
            return x;
        }
        return parent[x]=root(parent[x]);
    }//根を探す
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry){
            return;
        }
        parent[rx]=ry;
    }//xの根をyの根にくっつける
    bool same(int x,int y){
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }//x,yの属する木が同じならtrue
};

int main(){
    int N,M;cin>>N>>M;
    vector<int>p(N);
    rep(i,N){
        int a;cin>>a;a--;
        p.at(i)=a;
    }
    UnionFind tree(N);
    rep(i,M){
        int x,y;cin>>x>>y;
        x--;y--;
        tree.unite(x,y);
    }
    int count=0;
    rep(i,N){
        if(tree.same(i,p.at(i))){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1024
N,Q=map(int,input().split())
S=input()
A=[0]*N
# 累積和
for i in range(1,N):
	if S[i-1:i+1]=="AC":
		A[i]+=1
	A[i]=A[i]+A[i-1]
# [l:r)区間の総和を求める
for i in range(Q):
	l,r=map(int,input().split())
	print(A[r-1]-A[l-1])

Measured memory_bytes: 7748
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int i;
    string s;
    cin >> s;
    int count = 0;
    for(i=0;i<s.size();i++){
        count += s[i] - '0';
        count %= 9;
    }

    if(count == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3724
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let n: i32 = scan.next();
    println!("{}", (1000 - n % 1000) % 1000);
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 2172
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define mod 1000000007;
#define my_mod 2019;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string s,t;
    cin >> s >> t;
    t.pop_back();
    s == t ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
const int INF = 1e9;
const int MOD = INF+7;
using P = pair<int,int>;


int main(){
    int N,M,C;
    cin >> N >> M >> C;
    vector<int>B(M);
    rep(i,M) cin >> B[i];

    int ans = 0;

    rep(i,N){
        int A = 0;
        rep(j,M){
            int a;
            cin >> a;
            A += a*B[j];
        }
        if(A+C > 0) ans++;
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] splitS = S.split("", 0);
        int change = 0;
        
        for(int i = 0; i < splitS.length/2; i++){
            if(!splitS[i].equals(splitS[splitS.length-1-i])){
                change++;
            }
        }
        System.out.println(change);
        
    }
}

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

typedef long long ll;
#define pii pair<int, int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

string s , a , b , c , d , x , y;

int main()
{
    _FastIO;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < ((n - 1) / 2); i++){
        x += s[i];
    }
    for(int i = n - 1; i > (n - 1) / 2; i--){
        y += s[i];
    }

    for(int i = 0; i < (x.size() - 1) / 2; i++){
        a += x[i];
    }
    for(int i = x.size() - 1; i > (x.size() - 1) / 2; i--){
        b += x[i];
    }
    for(int i = 0; i < (y.size() - 1) / 2; i++){
        c += y[i];
    }
    for(int i = y.size() - 1; i > (y.size() - 1) / 2; i--){
        d += y[i];
    }
    if((n - 1) % 4 == 0){
        a += x[(x.size() - 1) / 2];
        c += y[(y.size() - 1) / 2];
    }
    if(x == y && a == b && c == d){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int N;
	int a = -1,an = -1, b = -1;
	cin >> N;

	for(int i = 0; i < N; i++) {
		int r;
		cin >> r;
		if(r > a) b = a, a = r, an = i;
		else if(r > b) b = r;
	}

	for(int i = 0; i < N; i++) {
		if(i == an) cout << b << endl;
		else cout << a << endl;
	}
}


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

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

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

const long long int INF = 1LL << 50;
const int nmax = 1001;
const int mmax = 2001;

struct edge {
    int from,to;
    long long int cost;
};

edge es[2010];

int a[mmax],b[mmax];
long long int c[mmax];

long long int d[nmax];
int n,m;

int main(){

    int s,t;
    long long int dd;

    cin >> n >> m;

    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }

    for(int i=0; i<=n; i++){
        d[i] = INF;
    }

    d[1] = 0;

    for(int loop=0; loop<n-1; loop++){
        for(int i=0; i<m; i++){
            if(d[a[i]] == INF){
                continue;
            }
            if(d[b[i]] > d[a[i]] + c[i]){
                d[b[i]] = d[a[i]] + c[i];
            }
        }
    }

    long long int ans = d[n];

    bool negative[nmax];

    for (int i = 0; i <= n; ++i) {
        negative[i] = false;
    }

    for (int loop = 0; loop < n ; ++ loop) {
        for (int i = 0; i < m; ++i) {
            if (d[a[i]] == INF) continue;
            if (d[b[i]] > d[a[i]] + c[i]) {
                d[b[i]] = d[a[i]] + c[i];
                negative[b[i] ] = true;
            }

            if (negative[a[i]] == true) {
                negative[b[i]] = true;
            }
        }
    }

    if(negative[n]){
        cout << "inf" << endl;
    }
    else{
        cout << -ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

ll n, m, k, a[202020], b[202020], c[404040];

int main(){
    cin >> n >> m >> k;
    for(int i=1; i<=n; i++) cin >> a[i], a[i] += a[i-1];
    for(int i=1; i<=m; i++) cin >> b[i], b[i] += b[i-1];
    
    int j = m, mx = 0;
    for(int i=0; i<=n; i++){
        if(a[i] > k) break;
        while(a[i]+b[j] > k) j--;
        mx = max(mx, i+j);
    }
    cout << mx;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a==b) {
    cout << c;
  }
  if (b==c) {
    cout << a;
  }
  if (a==c) {
    cout << b;
  }
  
  return 0;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long



int N;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  if(N % 2 == 0){
  	cout << N/2 << endl;
  }
  else{
  	cout << N/2 + 1 << endl;
  }
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

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

#define MAX_ 17
#define IF 16000000

#define lengthof(x) (sizeof(x) / sizeof(*(x)))

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	unsigned int data[MAX_][MAX_];
	unsigned int dp[1<<(MAX_-1)];
	unsigned int min_;

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

		fill((unsigned int*)data,(unsigned int*)(data+lengthof(data)),0);
		fill((unsigned int*)dp,(unsigned int*)(dp+lengthof(dp)),IF);


		for(int i1=0;i1<n;i1++){
			for(int i2=0;i2<n+1;i2++){
				cin>>data[i1][i2];
			}
		}


		for(int i1=0;i1<n;i1++){
			dp[1<<i1]=data[i1][0];
		}


		//for(int i1=0;i1<n-1;i1++){
			for(int i2=0;i2<(1<<n);i2++){
				//if(dp[i2]!=IF) {
					for(int i3=0;i3<n;i3++){
						int i4=i2|(1<<i3);
						if(i2!=i4){
							
							min_=data[i3][0];
							for(int i5=0;i5<n;i5++){
								
								if((i2&(1<<i5))!=0) {
									min_=min(min_,data[i3][i5+1]);
									//cout<<"min_ "<<min_<<" "<<data[i3][i5+1]<<endl;
								}
							}
							dp[i4]=min(dp[i4],dp[i2]+min_);
							//dp[i2]=IF;
							//i3のステージをi2の武器でこす
						}
					}
				//}
			}
		//}

		/*for(int i1=0;i1<(1<<n);i1++){
			for(int i2=0;i2<n;i2++){
				cout<<dp[i1][i2]<<"  ";
			}
			cout<<endl;
		}*/

		cout<<dp[(1<<n)-1]<<endl;




	}
	return 0;
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
#include<tr1/unordered_map>
using namespace std;
typedef long long ll;
#define pb push_back
const ll INF=1e18;
const int inf=0x3f3f3f3f;
void py(){
    cout<<"Yes"<<'\n';
}
void pn(){
    cout<<"No"<<'\n';
}
const int M=1e6+6;
const int mod=1e9+7;
ll f[M];
ll ksm(ll a,ll b){
    ll t=1;
    while(b){
        if(b&1){
            t=(t*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return t;
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    ll ans=0;
    for(int i=k;i>=1;i--){
        f[i]=ksm(k/i,n);
        for(int j=2*i;j<=k;j+=i)
            f[i]=(f[i]-f[j]+mod)%mod;
    }
    for(ll i=1;i<=k;i++)
        ans+=i*f[i],ans%=mod;
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 4500
import bisect
X = int(input())
n = 10**5+3
sosu = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    sosu.difference_update(range(i*2, n+1, i))
sosu = list(sosu)
sosu.sort()
ind = bisect.bisect_right(sosu, X)
if sosu[ind-1] == X:
    print(X)
else:
    print(sosu[ind])


Measured memory_bytes: 20604
#include <iostream>
#include "stdio.h"
#include "math.h"
#include "ctype.h"
#include "memory.h"
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	while(cin>>n)
	{
		int k = n;
		for(int i = 1;i<n;i++)
		{
			int a = i;
			int b = n - i;
			int tempa = 0;
			while(a/10)
			{
				tempa += a%10;
				a= a/10;
			}
			tempa += a%10;
			
			while(b/10)
			{
				tempa += b%10;
				b= b/10;
			}
			tempa += b%10;

			if (tempa  < k)
			{
				k = tempa;
			}
		}
	
		cout<<k<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
ll cnt[maxn];
ll k;
int main()
{
    int n;
    memset(cnt,0,sizeof(cnt));
    scanf("%d%lld",&n,&k);
    while(n--)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        cnt[u]+=v;
    }
    ll sum=0;
    for(int i=1;i<=maxn;i++)
    {
        sum+=cnt[i];
        if(sum>=k)
        {
            printf("%d\n",i);
            break;
        }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    long a = 0;
    for(int i = 0; i < m; i++){
        long ai;
        cin >> ai;
        a += ai;
    }
    if(n<a){
        cout << -1 << endl;
    }else{
        cout << n-a << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long int ll;
int main() {
    
    ll k;
    cin>>k;
    if(k%7==0)
    k/=7;
    
    if((k%2==0)||((k%5)==0))
    printf("-1");
    else
    {
        ll i=1, power=10;
        if(k==1)
        printf("1");
        
        else if(k%9==0)
        {
            while(power!=1)
            {
                i++;
                power*=10;
                power%=(9*k);
            }
            printf("%lld", i);
        }
        else if(k%3==0)
        {
            while(power!=1)
            {
                i++;
                power*=10;
                power%=(9*k);
            }
            printf("%lld", i);
        }
        else
        {
            while(power!=1)
            {
                i++;
                power*=10;
                power%=(9*k);
            }
            printf("%lld", i);
        }
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 3760
// 171

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int x, n;
    cin >> x >> n;
    
    if(n == 0){
        cout << x << endl;
        return 0;
    }

    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p.at(i);
    }
    
    for(int i=0; i<=n; i++){
        int min_buf = x-i, max_buf = x + i;
        bool c = true;
        for(int n: p){
            if(min_buf == n){
                c = false;
                break;
            }
        }
        if(c){
            cout << min_buf << endl;
            return 0;
        }

        c = true;
        for(int n: p){
            if(max_buf == n){
                c = false;
                break;
            }
        }
        if(c){
            cout << max_buf << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,k;cin >> n >>k;
    vl a(n);rep(i,n)cin >> a[i];
    vl dp(k+1);
    rep(i,k+1){
        set<ll> st;
        rep(j,n){
            if(i-a[j]>=0)st.ins(dp[i-a[j]]);
        }
        rep(j,110)if(!st.count(j)){
            dp[i]=j;break;
        }
    }
    if(dp[k])cout << "First" <<endl;
    else cout << "Second" <<endl;
}

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

int main() {
  int N , A ;
  cin >> N >> A ;
  
	// N = 500 * P + A のようなPのとき支払うことができる Pは整数
  	// N - A を500で割った余りが0
  	// 余分に払い切れる場合も可
  
  if ( ( N % 500 ) <= A ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
n , y = map(int, input().split())

ans = '-1 -1 -1'
for a in range(n + 1):
    for b in range(n + 1):
        if 10000 * a + 5000 * b + (n - a - b) * 1000 == y and (n-a-b) >= 0:
            ans = '{} {} {}'.format(a, b, (n-a-b))
            break
    if ans != '-1 -1 -1':
        break

print(ans)

Measured memory_bytes: 3060
A, B = map(int, input().split())

res = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            cand = int(''.join([str(i), str(j), str(k), str(j), str(i)]))
            if A <= cand <= B:
                res += 1

print(res)

Measured memory_bytes: 3060
#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;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<ll> ans(10000010,1);
void solve(){
    for(int i = 2; i < 10000010; i++){
        for(int j = i;j < 10000010; j += i){
            ans[j]++;
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    ll res = 0;
    solve();
    for(int i=1;i <= n;i++){
        res += i*ans[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 81260
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = (0 until n).map { sc.next().toInt() }
    println(problem063c(n, s))
}

fun problem063c(n: Int, s: List<Int>): Int {
    val dp = (0 until n).map { IntArray(n + 1) { 0 } }
    for (i in 1 until n + 1) {
        dp[0][i] = s[0]
    }
    for (i in 1 until n) {
        for (j in 0 until n + 1) {
            if (i == j) {
                dp[i][j] = dp[i - 1][j]
            } else {
                dp[i][j] = dp[i - 1][j] + s[i]
            }
        }
    }
    var max = 0
    dp[n - 1].forEach {
        if (it % 10 != 0) max = Math.max(max, it)
    }
    return max
}

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

typedef long long ll;

int n;
ll res;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        if (i % 3 != 0 && i % 5 != 0)
            res += i;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		if(n < 1000) {
			System.out.println("ABC");
		}else {
			System.out.println("ABD");
		}
		
	}
}

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

int main() {
	for( ;; ) {
		int H, W;
		cin >> H >> W;

		if( H == 0 && W == 0 ) {
			break;
		}

		for( int y = 0; y < H; ++y ) {
			cout << '#';

			for( int x = 1; x < W-1; ++x ) {
				cout << (y == 0 || y == H-1 ? '#' : '.');
			}

			cout << '#' << endl;
		}

		cout << endl;
	}
}



Measured memory_bytes: 3120
from collections import deque
N, M = map(int, input().split())
Clear = [-1]*N
T = [[] for _ in range(N)]
ans = 0
for i in range(M):
    X, Y, Z = map(int, input().split())
    X -= 1
    Y -= 1
    T[X].append(Y)
    T[Y].append(X)

for i in range(N):
    if Clear[i] == -1:
        ans += 1
        Clear[i] = 1
        P = deque([i])
        while(len(P) > 0):
            t = P.popleft()
            for j in T[t]:
                if Clear[j] == -1:
                    Clear[j] = 1
                    P.append(j)
print(ans)

Measured memory_bytes: 66848
/**/
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	ios::sync_with_stdio(false);
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++){
		if(a*i%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int x,a,b,n, u[200000], v[200000], w[200000];
	
	string str, str2;
	cin >> x>>a>>b;
	if (x >= b - a&&b-a>0) {
		cout << "safe" << endl;
	}
	else if (b - a <= 0) {
		cout << "delicious" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
}


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

using namespace std;

int main(){
    int a,b,c,d,total,min,sec;
    cin >> a >> b >> c >> d;
    total = a + b + c + d;
    min = total / 60;
    sec = total % 60;
    cout << min << endl << sec << endl;
    return 0;
}

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

#define ll long long
#define inf 100000000000000000
#define rep(i,a) for(ll i=0; i<a; ++i)
#define pb push_back

ll n;
ll a[100005];
ll b[100005];

ll mod = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  rep(i,n) {
    cin>>a[i];
  }
  rep(i,n) {
    cin>>b[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  ll ia=0;
  ll ib=0;
  ll x=0, y=0;
  ll ans=1;
  while(ia<n && ib<n) {
    if (a[ia]<b[ib]) {
      if (y==0) {
        x++;
      } else {
        ans*=y;
        ans = ans%mod;
        y--;
      }
      ia++;
    } else {
      if (x==0) {
        y++;
      } else {
        ans*=x;
        ans = ans%mod;
        x--;
      }
      ib++;
    }
  }
  while(ia<n) {
    if (y==0) {
      x++;
    } else {
      ans*=y;
      ans = ans%mod;
      y--;
    }
    ia++;
  }
  while(ib<n) {
    if (x==0) {
      y++;
    } else {
      ans*=x;
      ans = ans%mod;
      x--;
    }
    ib++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vecl A(N),B(N),C(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N) cin >> C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    /*
    for(int a : A) cout << a << " ";
    cout << endl;
    for(int a : B) cout << a << " ";
    cout << endl;
    for(int a : C) cout << a << " ";
    cout << endl;
    */
    ll ans = 0;
    REP(i,N) {
        ll b = B[i];
        ll l1 = -1;
        ll r1 = N;
        while(r1-l1 > 1) {
            ll mid = (l1+r1)/2;
            if(A[mid] >= b) r1 = mid;
            else l1 = mid;
        } 
        ll l2 = -1;
        ll r2 = N;
        while(r2-l2 > 1) {
            ll mid = (l2+r2)/2;
            if(C[mid] > b) r2 = mid;
            else l2 = mid;
        } 
        /*
        cout << l1 << " " << r1 << endl;
        cout << l2 << " " << r2 << endl;
        cout << endl;
        */
        ans += (l1+1)*(N-r2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

using Graph = vector<vector<int>>;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;


int main()
{
    int H,N;
    cin >> H >> N;
    vector <int> a(N);
    ll sum_a = 0;
    REP(i, N)
    {
        cin >> a[i];
        sum_a += a[i];
    }

    string res = "No";

    if(sum_a >= H)res = "Yes";


    cout << res << endl;


    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc167_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] read = Console.ReadLine().Split(' ');

            long A = int.Parse(read[0]);
            long B = int.Parse(read[1]);
            long C = int.Parse(read[2]);
            long K = int.Parse(read[3]);

            if (K <= A)
            {
                Console.Write(K);
            }

            else if (K <= A + B)
            {
                Console.Write(A);
            }

            else
            {
                Console.Write(A - (K - (A + B)));
            }

            Console.Read();

        }
    }
}


Measured memory_bytes: 27524
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

vector<vector<int>> adj;
vector<int> parent;
vector<long long> black, white;
#define MOD 1000000007

int n;

long long mul_inv(long long a, long long b)
{
	long long b0 = b, t, q;
	long long x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

long long division(long long a, long long b, long long p) {		// (a / b) mod p = ((a mod p) * (b^(-1) mod p)) mod p
	long long ans, inv;
	inv = mul_inv(b, p);
	ans = ((a % p) * inv) % p;
	return ans;
}



long long solve(int id, bool canblack) {
	bool hasson = false;
	long long vwhite = 1, vall = 1, ans, v;

	if (canblack && (black[id] != -1)) return black[id];
	if (!canblack && (white[id] != -1)) return white[id];

	for (auto p : adj[id]) {
		if ((parent[p] == -1) || (parent[p] == id)) {
			parent[p] = id;
			hasson = true;

			black[p] = solve(p, true);
			white[p] = solve(p, false);

			vwhite = (vwhite * white[p]) % MOD;
			vall = (vall * black[p]) % MOD;
		}
	}

	if (!hasson) {
		if (canblack) return 2;
		else return 1;
	}
	else {
		ans = 0;
		if (canblack) {
			ans = (vwhite + vall) % MOD;
		}
		else {
			ans = vall;
		}
		return ans;
	}
}

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

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

	parent.assign(n + 1, -1);
	parent[1] = 0;
	black.assign(n + 1, -1);
	white.assign(n + 1, -1);

	long long ans = solve(1, true);

	cout << ans << "\n";

	return 0;
}





Measured memory_bytes: 14592
#include <cstdio>
int N ,T ,A , X ;
int main ()
{
scanf ("%d %d %d " ,&N ,& T ,& A );
int res =0;
int cc =1 <<30;
for ( int i =1; i <= N ; i++)
{
scanf ("%d " ,& X );
int d =( T *1000 - X *6) - A *1000;
if (d <0) d = - d ;
if ( cc > d ) cc =d , res = i ;
}
printf ("% d\n " , res );
}

Measured memory_bytes: 128