akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

typedef int inte;
typedef long long ll;
#define int ll

const int N=4e5+50; 
const ll oo=1e18; 


int tr[N<<1]; 
void build(int v,int l,int r,int x){
	if(l==r)tr[v]=x; 
	else{
		int mid=(l+r)>>1;
		tr[v]=x;
		build(v<<1,l,mid,x); 
		build(v<<1^1,mid+1,r,x); 
	}
}

void update(int v,int l,int r,int s,int t,int x){
	if(r<s||l>t);
	else if(s<=l&&r<=t)cmin(tr[v],x); 
	else{
		int mid=(l+r)>>1;
		update(v<<1,l,mid,s,t,x);
		update(v<<1^1,mid+1,r,s,t,x); 
	}
}
int query(int v,int l,int r,int p){
	if(l==r)return tr[v]; 
	else{
		int mid=(l+r)>>1;
		if(p<=mid)return min(tr[v],query(v<<1,l,mid,p));
		else return min(tr[v],query(v<<1^1,mid+1,r,p)); 
	}
}

int n,m,k,a[N],b[N],disc[N],l[N],r[N];
ll f[N],sum[N];
int dist(int x,int y){ return (x-y+k)%k; }

inte main(inte argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin); 
	//freopen("my.out","w",stdout); 
#endif
	scanf("%lld%lld",&n,&k); 
	rep(i,1,n){
		scanf("%lld%lld",a+i,b+i); 
		if(b[i]==1&&a[i]*2>k){
			puts("-1"); 
			return 0; 
		}
		sum[i]=sum[i-1]-2ll*a[i]; 
		sum[i]=(sum[i]%k+k)%k; 
		//cout<<sum[i]<<endl;
	}
	rep(i,1,n){
		if(b[i]==2){
			l[i]=0,r[i]=k-1; 
		}else{
			l[i]=sum[i-1],r[i]=sum[i]; 
		}
		disc[++m]=l[i]; 
		disc[++m]=r[i]; 
	}
	//for(int i=1;i<=m;++i)printf("F:%lld\n",disc[i]); 
	sort(disc+1,disc+m+1); 
	m=unique(disc+1,disc+m+1)-disc-1; 
	//printf("%lld,%lld\n",disc[1],disc[m]); 
	rep(i,1,n){
		l[i]=lower_bound(disc+1,disc+m+1,l[i])-disc;
		r[i]=lower_bound(disc+1,disc+m+1,r[i])-disc;
		//printf("%lld,%lld\n",l[i],r[i]); 
	}
	build(1,1,m,n+1); 
	dec(i,n,1){
		int p=query(1,1,m,l[i]); 
		if(p!=n+1){
			f[i]=f[p]+dist(disc[l[p]],disc[l[i]]); 
		}
		if(l[i]<=r[i]){
			if(r[i]<m)update(1,1,m,r[i]+1,m,i); 
			if(l[i]>1)update(1,1,m,1,l[i]-1,i);
		}else{
			if(r[i]+1<=l[i]-1)update(1,1,m,r[i]+1,l[i]-1,i); 
		}
		//cout<<f[i]<<endl;
	}
	ll ans=oo; 
	rep(i,1,n){
		int p;
		p=query(1,1,m,l[i]); 
		//cout<<p<<endl;
		if(p==n+1)ans=0; 
		else ans=min(ans,f[p]+dist(disc[l[p]],disc[l[i]])); 
		p=query(1,1,m,r[i]); 
		//cout<<p<<endl;
		if(p==n+1)ans=0; 
		else ans=min(ans,f[p]+dist(disc[l[p]],disc[r[i]])); 
		//cout<<ans<<endl;
	}
	//printf("%lld\n",ans); 
	rep(i,1,n)ans+=a[i]<<1;
	printf("%lld\n", ans);
	return 0; 
}

Measured memory_bytes: 19456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      StringBuilder line  = new StringBuilder();
      StringBuilder wordA = new StringBuilder();
      StringBuilder wordB = new StringBuilder();
      int turn = Integer.parseInt(br.readLine());
      int pointA = 0;
      int pointB = 0;
      int lenA = 0;
      int lenB = 0;
      int len = 0;


      for ( int i = 0; i < turn; i++ ) {

        line.append(br.readLine());
        wordA.append(line.substring(0, line.indexOf(" ")));
        wordB.append(line.substring(line.indexOf(" ")+1, line.length()));

        if( (lenA = wordA.length()) < (lenB = wordB.length()) ) len = wordA.length();
        else if( lenA > lenB ) len = lenB;
        else len = lenA;

        for ( int j = 0; j < len; j++) {

          if ( wordA.charAt(j) > wordB.charAt(j)){
            pointA += 3;
            break;
          } else if ( wordB.charAt(j) > wordA.charAt(j) ) {
            pointB += 3;
            break;
          } else if ( j == (len-1) ) {
            if(lenA == lenB){
              pointA += 1;
              pointB += 1;
              break;
            } else if (lenA > lenB) {
              pointA += 3;
            } else {
              pointB += 3;
            }
          } else {
            continue;
          }
        }

        line.setLength(0);
        wordA.setLength(0);
        wordB.setLength(0);
      }

      System.out.println(pointA + " " + pointB);
    }
  }
}


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

int64_t comb(int64_t n, int64_t k) {
    int64_t res = 1;
    for (int64_t i = 1, j = n; i <= k; i++, j--) res = res * j / i;
    return res;
}

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;
    map<double, int64_t, greater<>> v;
    for (int i = 0; i < n; i++) {
        int64_t vv;
        cin >> vv, v[vv]++;
    }

    double ans1 = 0;
    int64_t ans2 = 0;
    if (begin(v)->second >= a) {
        ans1 = begin(v)->first;
        for (int64_t i = a; i <= min(b, begin(v)->second); i++) ans2 += comb(begin(v)->second, i);
    } else {
        int64_t num = 0;
        for (auto& e : v) {
            if (num + e.second < a) {
                num += e.second;
                ans1 += e.first * e.second;
            } else {
                int64_t sel = a - num;
                ans1 += e.first * sel;
                ans1 /= a;
                ans2 = comb(e.second, sel);
                break;
            }
        }
    }

    cout << fixed << setprecision(10) << ans1 << "\n" << ans2 << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int x = Integer.parseInt(in.readLine());

		System.out.println((int)Math.pow(x, 3));
	}
}

Measured memory_bytes: 16860
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k = 1;
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x % 2 == 0){
            if(x % 3 != 0 && x % 5 != 0){
                k = 0;
            }
        }
    }
    if(k == 1){
        cout << "APPROVED";
    }
    else{
        cout << "DENIED";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	
	
	if(N%2==0)
	{
		printf("%d", N/2);
	}	
	if(N%2!=0)
	{
		printf("%d", N/2 + 1);
	}
	return 0;
}


Measured memory_bytes: 3152
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<vector<int> > a(n, vector<int>(n)); REP(i, n) REP(j, n) cin >> a[i][j];
  vector<ll> group(1 << n, 0);
  FOR(i, 1, 1 << n) {
    vector<int> rabbits;
    REP(j, n) {
      if (i >> j & 1) rabbits.emplace_back(j);
    }
    int m = rabbits.size();
    REP(j, m) FOR(k, j + 1, m) group[i] += a[rabbits[j]][rabbits[k]];
  }
  vector<ll> dp(1 << n, -LINF);
  dp[(1 << n) - 1] = 0;
  for (int i = (1 << n) - 1; i >= 0; --i) {
    int sub = i;
    do {
      chmax(dp[sub], dp[i] + group[i ^ sub]);
    } while ((sub = (sub - 1) & i) != i);
  }
  cout << dp[0] << '\n';
  return 0;
}


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

using namespace std;

int main() {
    long long n, d, x, y;
    int cont=0;
    // set<pair<int,int>> points;

    scanf("%lld %lld", &n, &d);

    while (n--) {
        scanf("%lld %lld", &x, &y);

        long long dist = ceil(sqrt(x*x + y*y));

        if (dist <= d) {

            // printf("%d %d %d*\n", x, y, dist);
            ++cont;
            // points.insert({x,y});
        } 
    }

    printf("%d\n", cont);
    
    return 0;
}

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

const int maxn = 1e5;
int n, a[maxn], dp[maxn][2], log[maxn];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		for (log[i] = 0; 1 << log[i] < a[i]; log[i]++) {}
		if (i == 0)
		{
			dp[i][0] = log[i];
			dp[i][1] = log[i];
		}
		else
		{
			if (a[i] == 1 << log[i])
			{
				dp[i][0] = min(dp[i - 1][0] + max(0, log[i] - (log[i - 1] - 1)), dp[i - 1][1] + max(0, log[i] - log[i - 1]));
				dp[i][1] = dp[i][0];
			}
			else
			{
				dp[i][0] = min(dp[i - 1][0] + max(0, log[i] - (log[i - 1] - 1)), dp[i - 1][1] + max(0, log[i] - log[i - 1]));
				dp[i][1] = 1 + min(dp[i - 1][0] + max(0, (log[i] - 1) - (log[i - 1] - 1)), dp[i - 1][1] + max(0, (log[i] - 1) - log[i - 1]));
			}
		}
	}
	cout << min(dp[n - 1][0], dp[n - 1][1]);
}

Measured memory_bytes: 1792
#include<stdio.h>
 
   char s[200],p[200];
 
int main(void){
    int sl,pl,i,j;
    scanf("%s",s);
    scanf("%s",p);
 
    i = 0;
    while(s[i] != '\0')
        i++;
     sl = i;
     i = 0;
    while(p[i] != '\0')
        i++;
     pl = i;
 
    for(i = 0;i < sl;i++){
        for(j = 0;j < pl;j++){
            if(s[(i + j) % sl] != p[j])
                break;
        }
        if(j == pl){
            printf("Yes\n");return 0;
        }
    }
    printf("No\n");

    return 0;
}



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

int main() {
	ll n, a, b; cin >> n >> a >> b;
	if (n == 1) {
		if (a != b)cout << 0 << endl;
		else cout << 1 << endl;
	}
	else {
		if (a > b) {
			cout << 0 << endl;
		}
		else {
			ll mi = a * (n - 1) + b;
			ll ma = a + (n - 1)*b;
			cout << ma - mi + 1 << endl;
		}
	}
	return 0;
}


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

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B, C, D;
	
	cin >> A >> B >> C >> D;

	if (A*B > C*D)
	{
		cout << A * B << endl;
	}
	else
	{
		cout << C*D << endl;
	}

	
	return 0;
}


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

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

    int flg = 0;
    if (a == b && a != c) cout << "Yes" <<endl;
    else if (a == c && a != b) cout << "Yes" <<endl;
    else if (c == b && a != c) cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    int q = sqrt(n);
    cout << q * q << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, P=1000000007;
  string S, T="";
  std::cin >> N;
  std::cin >> S;
  string s = S;
  for(int i=0;i<2*N;i++){
    if(i==0) T +='L';
    else if(S[i]!=S[i-1]) T+='L';
    else T+='R', S[i]=(S[i]=='W'?'B':'W');
  }
  bool flag = true;
  std::vector<ll> L(2*N, 0), R(2*N, 0);
  for(int i=0;i<2*N;i++) {
    L[i] = (i==0?0:L[i-1]) + (T[i]=='L'?1:0);
    R[i] = (i==0?0:R[i-1]) + (T[i]=='R'?1:0);
  }
  if(L[2*N-1]!=R[2*N-1]) flag = false;
  if(T[2*N-1]!='R') flag = false;
  if(s[0]=='W' || s[2*N-1]=='W') flag = false;
  ll ans = 1;

  for(int i=0;i<2*N;i++){
    if(T[i]=='R') ans = (ans * (L[i] - R[i] + 1))%P;
    if(ans <0) flag = false;
  }
  //std::cout << T << '\n';
  for(int i=1;i<=N;i++) ans = (ans*i)%P;
  std::cout << (flag?ans:0) << '\n';
  return 0;
}


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

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

using namespace std;
using ll = long long;

template <class iterator>
int bubble_sort(iterator *first, iterator *last) {
  int cnt = 0;
  while (last-- > first) {
    for (iterator *iter = first; iter < last; iter++) {
      if (*iter > *(iter + 1)) {
        auto v = *iter;
        *iter = *(iter + 1);
        *(iter + 1) = v;
        cnt++;
      }
    }
  }
  return cnt;
}

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

  int A[n];
  rep(i, n) cin >> A[i];

  int cnt;
  cnt = bubble_sort(A, A + n);

  rep(i, n) {
    cout << A[i];
    if (i < n - 1) cout << " ";
  }
  cout << endl;
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3104
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	ll n,l;
	cin>>n>>l;
	ll first=((n*(n-1))/2)+(l*n);
	ll ans,mi=INT_MAX;
	for(int i=0;i<n;i++){
		if(mi>abs(i+l)){
			mi=abs(i+l);
			ans=first-(i+l);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

int A,B,q;

signed main(){
    int n;
    double ans=0;
    cin>>n;
    while(n--){
        double a;
        string s;
        cin>>a>>s;
        if(s=="JPY")ans+=a;
        else ans+=380000.0*a;
    }
    printf("%.9f\n",ans);
}

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

using namespace std;

int main(){
	long long n, a, b, c, d, ans = 0;
	cin >> n >> a >> b >> c >> d;
	long long e = abs(b - a);
	bool f = false;
	for(int i = 0; i < n && !f; i++){
		long long mi = c * (n - 1 - i) - d * i, ma = d * (n - 1 - i) - c * i;
		if(mi <= e && e <= ma){
			f = true;
		}
	}
	cout << (f? "YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

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

    if(strncmp(&s[0],&t[0],s.size())==0)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}

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

#define int long long

string s, t;
int prefa1[100005], prefa2[100005], q;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> s >> t;
    prefa1[0] = (s[0] == 'A');
    for(int i = 1; i < s.length(); i++) prefa1[i] = (prefa1[i - 1] + (s[i] == 'A'));
    prefa2[0] = (t[0] == 'A');
    for(int i = 1; i < t.length(); i++) prefa2[i] = (prefa2[i - 1] + (t[i] == 'A'));
    cin >> q;
    while(q--){
        int l1, r1, l2, r2;
        cin >> l1 >> r1 >> l2 >> r2;
        int diff1 = 2 * (prefa1[r1 - 1] - ((l1 == 1) ? 0 : prefa1[l1 - 2])) - (r1 - l1 + 1);
        int diff2 = 2 * (prefa2[r2 - 1] - ((l2 == 1) ? 0 : prefa2[l2 - 2])) - (r2 - l2 + 1);
        if(abs(diff1 - diff2) % 3) cout << "NO";
        else cout << "YES";
        cout << "\n";
    }
}

Measured memory_bytes: 2512
#include <cstdio>
#include <algorithm>

int main() {
    int n, m, q;
    scanf("%d %d %d", &n, &m, &q);
    int table[n + 1][n + 1];
    std::fill(table[0], table[n]+n+1, 0);
    for (int i = 0; i < m; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        table[l][r]++;
    }
    for (int i = 0; i < n; i++) {
        table[i + 1][i + 1] += table[i + 1][i] + table[i][i + 1] - table[i][i];
        for (int j = i + 1; j < n; j++) {
            table[j + 1][i + 1] += table[j + 1][i] + table[j][i + 1] - table[j][i];
            table[i + 1][j + 1] += table[i + 1][j] + table[i][j + 1] - table[i][j];
        }
    }
    for (int i = 0; i < q; i++) {
        int p, q;
        scanf("%d %d", &p, &q);
        printf("%d\n", table[q][q] - table[q][p - 1] - table[p - 1][q] + table[p - 1][p - 1]);
    }
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        int dataCount = int.Parse(Console.ReadLine());
        for(int i = 0;i < dataCount;i++)
        {
            int[] triangle = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(triangle);
            var a = triangle[0] * triangle[0];
            var b = triangle[1] * triangle[1];
            var c = a + b;
            var d = triangle[2] * triangle[2];
            if(c == d)
            {
                Console.WriteLine("YES");
            }else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 14248
#include <iostream>

auto main () -> int
{
    int n;
    while (std::cin >> n)
    {
        int res = 0;
        for (auto a = 0; a < 10; ++ a)
        {
            for (auto b = 0; b < 10; ++ b)
            {
                for (auto c = 0; c < 10; ++ c)
                {
                    auto d = n - a - b - c;
                    if (0 <= d && d < 10)
                    {
                        ++ res;
                    }
                }
            }
        }
        std::cout << res << std::endl;
    }
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    long long ans;
    int temp = a % b;

    for(int i = 2; ; i++){
        if((a * i) % b == c){
            cout << "YES" << endl;
            break;
        }else if((a * i) % b == temp){
            cout << "NO" << endl;
            break;
        }
    }

    return 0;
}


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

int main(){
    int k, s;
    ll cnt = 0;
    cin >> k >> s;
    rep(x, k + 1) rep(y, k + 1) if (x + y <= s && s - (x + y) <= k) cnt ++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
let nil = -1

type node = {
  mutable parent : int;
  mutable left : int;
  mutable right : int;
  mutable depth : int;
  mutable height : int;
}

let make () = {
  parent = nil;
  left = nil;
  right = nil;
  depth = nil;
  height = nil
}

let search_root t n =
  let rec doit i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else doit (i + 1)
  in doit 0

let set_depth t n =
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).left <> nil then doit t.(i).left (d + 1);
    if t.(i).right <> nil then doit t.(i).right (d + 1);
  in doit (search_root t n) 0

let set_height t n =
  let rec doit i =
    let hl = ref 0 in
    let hr = ref 0 in
    if t.(i).left <> nil then (doit t.(i).left; hl := t.(t.(i).left).height + 1);
    if t.(i).right <> nil then (doit t.(i).right; hr := t.(t.(i).right).height + 1);
    t.(i).height <- (max !hl !hr)
  in doit (search_root t n)

let print t =
  let sibling i =
    if t.(i).parent = nil then nil
    else if t.(t.(i).parent).left <> i && t.(t.(i).parent).left <> nil then t.(t.(i).parent).left
    else if t.(t.(i).parent).right <> i && t.(t.(i).parent).right <> nil then t.(t.(i).parent).right
    else nil
  in
  let degree i = 0 + (if t.(i).left <> nil then 1 else 0) + (if t.(i).right <> nil then 1 else 0) in
  let print_node i =
    print_string "node "; print_int i;
    print_string ": parent = "; print_int t.(i).parent;
    print_string ", sibling = "; print_int (sibling i);
    print_string ", degree = "; print_int (degree i);
    print_string ", depth = "; print_int t.(i).depth;
    print_string ", height = "; print_int t.(i).height;
    print_string (if t.(i).parent = nil then ", root" else if t.(i).left = nil && t.(i).right = nil then ", leaf" else ", internal node");
    print_string "\n"
  in Array.iteri (fun i _ -> print_node i) t

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> make ()) in
  let rec read i =
    if i < n then begin
      let (id, l, r) = Scanf.scanf "%d %d %d\n" (fun id l r -> (id, l, r)) in
      t.(id).left <- l;
      t.(id).right <- r;
      if l <> nil then t.(l).parent <- id;
      if r <> nil then t.(r).parent <- id;
      read (i + 1)
    end in
  read 0;
  set_depth t n;
  set_height t n;
  print t

Measured memory_bytes: 2368
#include<stdio.h>
#define INFTY 100000
int min_count(void);

int n;
int p[101],m[101][101];

int main(){
    int i;

    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&p[i-1],&p[i]);
    }
    printf("%d\n",min_count());
    
    return 0;
}
int min_count(void){
    int i,j,l,k,q;

    for(i=1;i<=n;i++){
        m[i][i] = 0;
    }
    for(l=2;l<=n;l++){
        for(i=1;i<=n-l +1;i++){
            j = i + l - 1;
            m[i][j] = INFTY;
            for(k=i;k<=j-1;k++){
                if((q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]) < m[i][j]){
                    m[i][j] = q;
                }
            }
        }
    }

    return m[1][n];
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    int ans=0;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        while(a%2==0){
            a/=2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    vector <int> s(m),c(m);
    map<int,int>mp;
    mp[1]=-1;
    mp[2]=-1;
    mp[3]=-1;
    int digit[4];
    REP(i,4){
        digit[i]=-1;
    }
    vector<pair<int,int> >p(m);
    REP(i,m){
        cin >> s[i] >> c[i];
    }
    REP(i,m){
        if(digit[s[i]]!=-1 && digit[s[i]]!=c[i]){
            cout << -1 << endl;
            return 0;
        }
        digit[s[i]]=c[i];
    }
    if(n!=1&&digit[1]==0){
        cout << -1 << endl;
        return 0;
    }
    
    
    int answer  = 0;
    if(n==3){
        if(digit[1]!=-1){
            answer+=digit[1]*100;
        }
        else answer+=100;
        if(digit[2]!=-1){
            answer+=digit[2]*10;
        }
        if(digit[3]!=-1){
            answer+=digit[3];
        }
    }
    if(n==2){
        if(digit[1]!=-1){
            answer+=digit[1]*10;
        }
        else answer+=10;
        if(digit[2]!=-1){
            answer+=digit[2];
        }
    }
    if(n==1){
        if(digit[1]!=-1){
            answer+=digit[1];
        }
    }
    string st = to_string(answer);
    if(st.length()!=n){
        cout << -1 << endl;
        return 0;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N; cin >> N;
    map<string, int> M;
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        sort(begin(s), end(s));
        ans += M[s];
        M[s]++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    class Logger
    {
    private:
        bool isEnable;

    public:
        Logger(bool isEnable = true) : isEnable(isEnable) {}

        template<class T>
        Logger& operator<<(const T& val)
        {
            if(isEnable)
            {
                std::cout << val;
            }
            return *this;
        }

        void set_enable()
        {
            isEnable = true;
        }

        void set_disable()
        {
            isEnable = false;
        }

        void endl()
        {
            if(isEnable)
            {
                std::cout << std::endl;
            }
        }
    };

    Logger logger;

    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

int main()
{
    string s;
    vector<bool> v(26, false);

    cin >> s;

    for(int i = 0; i < s.size(); ++i)
    {
        v[s[i] - 'a'] = true;
    }

    for(int i = 0; i < 26; ++i)
    {
        if(!v[i])
        {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))

S = [0] * N
S[0] = A[0]
for i in range(1, N):
    S[i] = S[i-1] + A[i]

#print(S)

before = 10**9*2
for i in range(N-2, -1, -1):
    left = S[i]
    right = S[N-1] - left
    diff = abs(right - left)
    before = min(before, diff)

print(before)

Measured memory_bytes: 24820
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>

using namespace std;

int main(){
  string s;
  while(cin >> s){
    int a = 0 , b = 0;
    for(int i = 0 ; i < s.size() ; i++ ){
      if(s.substr(i,3) == "JOI") a++;
      else if(s.substr(i,3) == "IOI") b++;
    }
    cout << a << endl << b << endl;
  }
}

Measured memory_bytes: 1212
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N, K;
  invec<int> p(N);

  double r = 0, rmax = 0;
  REP(i, K) {
    r += (double)(p[i] + 1) / 2;
  }
  rmax = r;
  
  for (int i = 0; i < N - K; i++) {
    r -= (double)(p[i] + 1) / 2;
    r += (double)(p[i + K] + 1) / 2;
	rmax = max(r, rmax);
  }

  return rmax;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}




Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  a--;b--;
  bool c[3];
  c[0]=c[1]=c[2]=true;
  c[a]=c[b]=false;
  int ans;
  if(c[0]) ans=1;
  if(c[1]) ans=2;
  if(c[2]) ans=3;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
    if a[i]-a[i-1]<=t:
        ans+=a[i]-a[i-1]
    elif t<a[i]-a[i-1]:
        ans+=t
print(ans+t)



Measured memory_bytes: 25196
/***********************************************************************\
|      _____   ____    _____               _    _   _____   __  __      |
|     |_   _| |  _ \  |  __ \      /\     | |  | | |_   _| |  \/  |     |
|       | |   | |_) | | |__) |    /  \    | |__| |   | |   | \  / |     |
|       | |   |  _ <  |  _  /    / /\ \   |  __  |   | |   | |\/| |     |
|      _| |_  | |_) | | | \ \   / ____ \  | |  | |  _| |_  | |  | |     |
|     |_____| |____/  |_|  \_\ /_/    \_\ |_|  |_| |_____| |_|  |_|     |
|                                                                       |
|                   COMPUTER SCIENCE AND ENGINEERING                    |
|             Noakhali Science and Technology University                |
|                     phn:01751552822                                   |
\***********************************************************************/

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mp             make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))
#define    c1(a)             cin>>a
#define    c2(a,b)            cin>>a>>b
#define    c3 (a,b,c)        cin>>a>>b>>c
#define    mx2(a,b)        max(a,b)
#define    mx3(a,b,c)        max(max(a,b),c)
#define    mn2(a,b)        min(a,b)
#define    mn3(a,b,c)        min(max(a,b),c)
#define    mf           int main()
#define    rt           return


///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));
mf
{
   long double b,c;
    long long int d,a;
    cin>>a>>b;
    c=(a*1.0)*b;
    d=c;
    cout<<d<<endl;


}



Measured memory_bytes: 3728
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		
		int N = 0;
		int tre = 0;
		int count = 0;
		int A[];
		
		Boolean flag = true;
		
		N = Integer.parseInt(as.next());
		
		A = new int[N];
		
		for(int i=0;i<N;i++){
			
			A[i] = Integer.parseInt(as.next());
			
		}
		
		while(flag){
			
			flag = false;
			for(int j=N-1;j>=1;j--){
				
				if(A[j] < A[j-1]){
					
					tre = A[j];
					A[j] = A[j-1];
					A[j-1] = tre;
					flag = true;
					count++;
					
				}
				
			}
			
		}
		
		for(int i=0;i<N;i++){
			
			if(i != N-1){
				
				sb.append(A[i]).append(' ');
			
			}
			else{
				
				sb.append(A[i]);
				
			}
		}
		System.out.println(sb.toString());
		sb.setLength(0);
		sb.append(count);
		System.out.println(sb.toString());

	}

}

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

int main(){
int a[6];
int i;
for(i=0;i<5;i++){
cin>>a[i];
}
sort(a,a+5);
cout << a[4];
for(i=3;i>=0;i--){
cout << " " << a[i];
}
cout << endl;
return 0;
}

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

int main(){
  int N, M;
  cin >> N;
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin >> s[i];
  }
  cin >> M;
  vector<string> t(M);
  for(int i=0; i<M; i++){
    cin >> t[i];
  }
  int cnt=0, cnt_max=0;
  for(int i=0; i<N; i++){
    cnt = 0;//初期化
    for(int j=i; j<N; j++){
      if(s[i] == s[j]){
        cnt++;
      }
    }
    for(int k=0; k<M; k++){
      if(s[i] == t[k]){
        cnt--;
      }
    }
    if(cnt > cnt_max){
      cnt_max = cnt;
    }
  }
  cout << cnt_max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    set<int> s;
    s.insert(1);
    s.insert(2);
    s.insert(3);
    int a,b; cin >> a >> b;
    s.erase(a); s.erase(b);
    cout << *s.begin() << endl;
    return 0;
}


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 k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int tmp = n - k;

        if(tmp < 0){
            System.out.println(n*x);
        } else {
            System.out.println(k*x + tmp*y);
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int x, y, z;
    cin >> x >> y >> z;
    int n = x + y + z;
    ll res = 0;
    vector <int> f(n), s(n);
    for (int i = 0; i < x + y + z; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        res += c;
        a -= c;
        b -= c;
        f[i] = a;
        s[i] = b;
    }
    vector <int> id(n);
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), [&] (int i, int j) {
        return f[i] - s[i] > f[j] - s[j];
    });
    vector <ll> pref(n), suf(n);
    multiset <int> bst;
    ll sm = 0;
    for (int i = 0; i < n; ++i) {
        sm += f[id[i]];
        bst.insert(f[id[i]]);
        if (bst.size() > x) {
            sm -= *bst.begin();
            bst.erase(bst.begin());
        }
        pref[i] = sm;
    }
    sm = 0;
    bst.clear();
    for (int i = n - 1; i >= 0; --i) {
        sm += s[id[i]];
        bst.insert(s[id[i]]);
        if (bst.size() > y) {
            sm -= *bst.begin();
            bst.erase(bst.begin());
        }
        suf[i] = sm;
    }
    ll delta = -1e18;
    for (int i = 0; i + 1 < n; ++i) {
        if (i + 1 >= x && n - i - 1 >= y) delta = max(delta, pref[i] + suf[i + 1]);
    }
    cout << res + delta << '\n';
}

Measured memory_bytes: 7424
#include <stdio.h>
#include <math.h>

#define SQ(x) ((x) * (x))

int main(void)
{
    int s;
    int i;
    double x1, x2, x3;
    double y1, y2, y3;
    double a, b, c, d, e, f;
    double l, m, n;
    
    scanf("%d", &s);
    for (i = 0; i < s; i++){
        scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
        
        a = (x1 - x2);
        b = (y1 - y2);
        c = -1 * (SQ(x1) - SQ(x2) + SQ(y1) - SQ(y2));
        d = (x1 - x3);
        e = (y1 - y3);
        f = -1 * (SQ(x1) - SQ(x3) + SQ(y1) - SQ(y3));
        
        l = (c * e - b * f) / (e * a - b * d);
        m = (d * c - a * f) / (d * b - e * a);
        
        n = -1 * (SQ(x1) + SQ(y1) + l * x1 + m * y1);
        
        printf("%.3f %.3f %.3f\n", l / -2.0, m / -2.0, sqrt(SQ(l) + SQ(m) - 4 * n) / 2.0);
    }
    
    return (0);
}

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


int main(){
  int N, M;
  vector<pair<int64_t, int64_t>> AB(100010);

  cin >> N >> M;
  for(int i=0; i<N; i++){
    cin >> AB[i].first >> AB[i].second;
  }

  sort(AB.begin(), AB.begin()+N);

  int cur = 0; int64_t ans = 0;
  while(M > 0){
    if(AB[cur].second > 0){
      ans += AB[cur].first;
      AB[cur].second--; M--;
    } else {
      cur++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    getLine
    as <- fmap read . words <$> getLine :: IO [Int]
    let nd = filter odd $ as
    let (n4, n2) = partition ((== 0) . (`mod` 4)) (filter even as)
    let (sd, s2, s4) = (length nd, length n2, length n4)

    let p1 = sd <= s4
    let p2 = and [sd - 1 == s4, s2 == 0]
    let p3 = and [sd == 0, even s2]

    let ans = case () of
            _ | p1        -> True
              | p2        -> True
              | p3        -> True
              | otherwise -> False

    if ans then putStrLn "Yes" else putStrLn "No"

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

long long gcd(long long a, long long b) {
    if (a % b) return gcd(b, a % b);
    else return b;
}

int main() {
    long long a, b; cin >> a >> b;
    long long g = gcd(a, b);
    int cnt = 1;
    for (long long i = 2; i * i <= g; i++) {
        if (g % i == 0) {
            cnt++;
            while (g % i == 0) g /= i;
        }
    }
    if (g != 1) cnt++;
    cout << cnt << endl; 
    return 0;
}

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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BITS(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)

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

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll Q;
  cin >> Q;
  vl L(Q), R(Q);
  REP(i, Q) cin >> L[i] >> R[i];
  vector<bool> prime(1e5 + 1, true);
  vl po(1e5 + 1, 0);
  prime[1] = false;
  FOR(i, 2, (ll)pow(1e5, 0.5) + 1) {
    if (!prime[i])
      continue;
    for (ll j = 2; j * i < 1e5 + 1; j++) {
      prime[i * j] = false;
    }
  }
  FOR(i, 1, 1e5 + 1) {
    po[i] = po[i - 1];
    if (prime[i] && prime[(i + 1) / 2]) {
      po[i]++;
    }
  }
  REP(i, Q) { cout << po[R[i]] - po[L[i] - 1] << endl; }

  return 0;
}


Measured memory_bytes: 3576
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long K;
        K = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(N, K);
    }
}

class Solver {
    public void solve(long N, long K) {
        long ans = 0;
        while (N > 0) {
            N /= K;
            ans++;
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int N;
long A[1<<17],B[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<=N;i++)cin>>A[i];
	if(N==0)
	{
		if(A[0]==1)cout<<1<<endl;
		else cout<<-1<<endl;
		return 0;
	}
	else if(A[0]>0)
	{
		cout<<-1<<endl;
		return 0;
	}
	B[N]=A[N];
	for(int i=N;i--;)B[i]=B[i+1]+A[i];
	long ans=0,pre=1;
	for(int i=0;i<=N;i++)
	{
		if(pre>B[i])pre=B[i];
		ans+=pre;
		pre-=A[i];
		if(pre<0)
		{
			cout<<-1<<endl;
			return 0;
		}
		pre*=2;
	}
	cout<<ans<<endl;
}


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> cant(10);
  for (int i = 0; i < k; ++i) {
    int d;
    cin >> d;
    cant[d] = 1;
  }
  vector<int> v;
  while (n > 0) {
    v.push_back(n % 10);
    n /= 10;
  }
  int smallest = -1;
  for (int i = 0; i < 10; ++i) {
    if (!cant[i]) {
      smallest = i;
      break;
    }
  }
  assert(smallest != -1);
  int dig = (int) v.size();
  for (int i = dig - 1; i >= 0; --i) {
    if (cant[v[i]]) {
      int j = i, need = 1;
      while (j < dig && need) {
        for (int c = v[j] + 1; c <= 9; ++c) {
          if (!cant[c]) {
            v[j] = c;
            need = 0;
            break;
          }
        }
        if (need) {
          ++j;
        } else {
          break;
        }
      }
      if (j == dig && need) {
        int largest = smallest;
        if (largest == 0) {
          for (int k = smallest + 1; k < 10; ++k) {
            if (!cant[k]) {
              largest = k;
              break;
            }
          }
        }
        assert(largest != 0);
        v.push_back(largest);
      }
      for (int k = 0; k < j; ++k) {
        v[k] = smallest;
      }
      break;
    }
  }
  for (int i = (int) v.size() - 1; i >= 0; --i) {
    cout << v[i];
  }
  cout << '\n';
  return 0;
}


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


int dfs(vector<int> graph[], int node, vector<int>& dp) {
    if (dp[node] != -1) {
        return dp[node];
    }

    int ans = 0;

    for (int next : graph[node]) {
        ans = max(ans, 1 + dfs(graph, next, dp));
    }

    dp[node] = ans;
    return ans;
}

int main() {
    int N, M;
    scanf("%d%d", &N, &M);
    vector<int> graph[N + 1];
    vector<int> dp(N + 1, -1);

    for (int i = 0; i < M; i++) {
        int x, y;

        scanf("%d%d", &x, &y);
        graph[x].push_back(y);
    }

    int res = 0;

    for (int i = 1; i <= N; i++) {
        res = max(res, dfs(graph, i, dp));
    }

    cout << res << endl;
}

Measured memory_bytes: 8832
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
  //   String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu[3]);


//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(nyu){
case "H H":
System.out.println("H") ;
break;

case "D D":
System.out.println("H") ;
break;

case "H D":
System.out.println("D") ;
break;

case "D H":
System.out.println("D") ;
break;


default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



//if(D<1200){
//double res=Math.ceil((AB)/2);

//System.out.println("ABC");
//}else if(B<A){
//System.out.println("Alice");

//}else{
System.out.println(nyu.replaceAll(","," "));

//}




	}
}

Measured memory_bytes: 21460