akhauriyash/Code-Regression huggingface dataset:
/*
  AOJ 1337
  Title:
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
int n;
int l[50],t[50],r[50],b[50];
int x[101],y[101];
long long flag[101][101];  //max 50bit
int  region[101][101];
int rc,xc,yc;

#define in_rect(x_,y_,l_,t_,r_,b_) (((l_)<=(x_))&&((x_)<(r_))&&((b_)<=(y_))&&((y_)<(t_)))


int compare(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int find_unpaint(int *y,int *x)
{
  int i,j;

  i=*y;j=*x;goto TOCHUU;
  for(i=0;i<xc;i++)
    for(j=0;j<yc;j++)
      {
      TOCHUU:
	if(region[i][j]==0)
	  {
	    *y=i;*x=j;
	    return(1);
	  }
      }
  return(0);
}

void paint(int y,int x,int color)
{
  long long myflag=flag[y][x];
  //printf("p:%d %d [%d]\n",y,x,color);
  region[y][x]=color;
  if(y>0 && flag[y-1][x]==myflag && region[y-1][x]==0)
    paint(y-1,x,color);
  if(y<2*n && flag[y+1][x]==myflag && region[y+1][x]==0)
    paint(y+1,x,color);
  if(x>0 && flag[y][x-1]==myflag && region[y][x-1]==0)
    paint(y,x-1,color);
  if(x<2*n && flag[y][x+1]==myflag && region[y][x+1]==0)
    paint(y,x+1,color);
}
int count_connect()
{
  int i,j,x,y,color;
  memset(region,0,sizeof(region));
  x=y=0;
  color=1;
  while(find_unpaint(&y,&x))
    {
      paint(y,x,color);
      color++;
    }
  return(color);
}
void dump_color()
{
  int i,j;
  for(i=0;i<xc;i++)
    {
      for(j=0;j<yc;j++)
	printf("%-3d|",region[i][j]);
      printf("\n");
    }
}
int shrink(int a[],int n)
{
  int work[101],i,j;
  for(i=j=0;i<n;i++)
    {
      if(i==0 || a[i]!=a[i-1])
	{
	  work[j]=a[i];
	  j++;
	}
    }
  memcpy(a,work,sizeof(int)*j);
  return(j);
}

main()
{
  int i,j,k,in,ret;
  long long mask,res;

  while(scanf("%d",&n) && n)
    {
      x[0]=y[0]=-1;
      for(i=0;i<n;i++)
	{
	  scanf("%d %d %d %d",&l[i],&t[i],&r[i],&b[i]);
	  x[i+1]=l[i];
	  x[n+i+1]=r[i];
	  y[i+1]=t[i];
	  y[i+n+1]=b[i];
	}
      qsort(x,2*n+1,sizeof(int),compare);
      qsort(y,2*n+1,sizeof(int),compare);
      xc=shrink(x,2*n+1);
      yc=shrink(y,2*n+1);

      //xc=yc=2*n+1;

      for(i=0;i<xc;i++)
	for(j=0;j<yc;j++)
	  {
	    for(k=0,res=0L,mask=1LL;k<n;k++,mask<<=1)
	      {
		in=in_rect(x[i],y[j],l[k],t[k],r[k],b[k]);
		//printf("x y=%d %d in rect %d %d %d %d [%d]\n",x[i],y[j],l[k],t[k],r[k],b[k],in);
		if(in)
		  res |= mask;
	      }
	    //printf("x,y,f=%d %d %d\n",x[i],y[j],res);
	    flag[i][j]=res;
	  }
      ret=count_connect();
#ifdef DEBUG
      dump_color();
#endif
      printf("%d\n",ret-1);
    }
  return(0);
}

Measured memory_bytes: 1520
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int P[4100][4100];

int w, h, n;

void Fil(int x, int y){
	if(x < 0 || y < 0 || x >= w || y >= h){
		return;
	}
	if(P[x][y] != 0){
		return;
	}
	P[x][y] = 1;
	Fil(x - 1, y);
	Fil(x + 1, y);
	Fil(x, y - 1);
	Fil(x, y + 1);
}

int main(){
	
	while(true){
		cin >> w >> h;
		if(w == 0 && h == 0){
			break;
		}
		
		cin >> n;
		
		map<int, int> mx, my;
		map<int, int>::iterator ite;
		
		int x1[2000], x2[2000], y1[2000], y2[2000];
		
		for(int i = 0; i < n; i++){
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
			if(x1[i] != 0){
				mx[x1[i]] = 0;
			}
			if(x1[i] != w){
				mx[x1[i] + 1] = 0;
			}
			if(x2[i] != 0){
				mx[x2[i]] = 0;
			}
			if(x2[i] != w){
				mx[x2[i] + 1] = 0;
			}
			if(y1[i] != 0){
				my[y1[i]] = 0;
			}
			if(y1[i] != h){
				my[y1[i] + 1] = 0;
			}
			if(y2[i] != 0){
				my[y2[i]] = 0;
			}
			if(y2[i] != h){
				my[y2[i] + 1] = 0;
			}
		}
		
		int cnt = 0;
		for(ite = mx.begin(); ite != mx.end(); ite++){
			ite->second = cnt;
			cnt++;
		}
		
		cnt = 0;
		for(ite = my.begin(); ite != my.end(); ite++){
			ite->second = cnt;
			cnt++;
		}
		
		w = mx.size();
		h = my.size();
		
		for(int i = 0; i <= mx.size(); i++){
			for(int j = 0; j <= my.size(); j++){
				P[i][j] = 0;
			}
		}
		
		for(int i = 0; i < n; i++){
			x1[i] = mx[x1[i] + 1];
			x2[i] = mx[x2[i]];
			y1[i] = my[y1[i] + 1];
			y2[i] = my[y2[i]];
			for(int j = y1[i]; j <= y2[i]; j++){
				P[x1[i]][j]++;
				P[x2[i] + 1][j]--;
			}
		}
		
		for(int i = 0; i < h; i++){
			cnt = 0;
			for(int j = 0; j < w; j++){
				cnt += P[j][i];
				P[j][i] = cnt;
				//cout << P[j][i];
			}
			//cout << endl;
		}
		
		int ans = 0;
		for(int i = 0; i < mx.size(); i++){
			for(int j = 0; j < my.size(); j++){
				if(P[i][j] == 0){
					Fil(i, j);
					ans++;
				}
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 24048
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	double r;
	cin >> r;
	double pi = acos(-1);
	printf("%f\n", 2*r*pi);
	return 0;
}

Measured memory_bytes: 3788
/*
 * Author : Sadi
 * Tue 14/07/2020
 * 14:03:50.98
 */
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    vector<int> v(n);
    long long ans = 0;
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            ans += (v[i] * v[j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
n=int(input())
w=[input() for _ in range(n)]
f=True
for i in range(1,n):
	if w[i-1][-1] == w[i][0]:
		f=True
	else:
		f=False
		break
if f==False:
	f=False
elif len(list(set(w))) == len(w):
	f=True
else:
	f=False
if f:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
const ll s_max = 2e4+10;
#define int ll
template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
struct state{
    ll w, s, v;
    state(){}
};
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<state> v(n);
    rep(i,n){
        cin >> v[i].w >> v[i].s >> v[i].v;
    }
    sort(all(v), [&](const auto &a, const auto &b){
        return a.s + a.w < b.s + b.w;
    });
    // vector<vector<ll>> dp(n+1, vector<ll>(s_max));
    // rep(i,n){
    //     rep(j,s_max){
    //         chmax(dp[i+1][j], dp[i][j]);
    //         if(j - v[i].w >= 0 && v[i].s >= j - v[i].w){
    //             chmax(dp[i+1][j], dp[i][j - v[i].w] + v[i].v);
    //         }
    //     }
    // }
    vector<ll> dp(s_max);
    rep(i,n){
        state t = v[i];
        rrep(j,s_max){
            if(j - t.w >= 0 && t.s >= j - t.w){
                chmax(dp[j], dp[j-t.w] + t.v);
            }
        }
    }

    ll ans = 0;
    rep(j, s_max)chmax(ans, dp[j]);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <deque>
#include <set>
#include <climits>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)

using namespace std;

typedef long long int lint;

template<typename T> inline bool in(T& x){ return cin >> x; }
template<typename T> inline T in(){T x; cin >> x; return x; }

bool solve(const vector<string>& lots, int n, int m, int h, int d)
{
    m--;
    n--;
    h--;
    rep(i, d){
        if (m != 0 && lots[i][m - 1] == '1'){
            m--;
        }
        else if (m != n && lots[i][m] == '1'){
            m++;
        }
    }
    return m == h;
}
bool is_valid(const vector<string>& lots, int n, int d)
{
    n--;
    rep(i, d){
        rep(j, n - 1){
            if (lots[i][j] == '1' && lots[i][j] == lots[i][j + 1]) return false;
        }
    }
    return true;
}

int main()
{
    int n, m, h, d;
    while (in(n), n){
        vector<string> lots;
        in(m);
        in(h);
        in(d);

        rep(i, d) lots.push_back(in<string>());
        
        if (solve(lots, n, m, h, d)){
            puts("0");
            continue;
        }
        rep(i, d){
            rep(j, n - 1){
                if (lots[i][j] == '0'){
                    lots[i][j] = '1';
                    if (is_valid(lots, n, d) && solve(lots, n, m, h, d)){
                        printf("%d %d\n", i + 1, j + 1);
                        goto end;
                    }
                    lots[i][j] = '0';
                }
            }
        }
        puts("1");
end:;
    }
	return (0);
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <math.h>
int main(){
	int N,A=-1,F,T=-1,X,Y;
	int D[2]={-1,-1},S[2];
	for(scanf("%d",&N);N--;){
		int f,a,t,x,y;
		scanf("%d%d%d%d%d",&f,&a,&t,&x,&y);
		if(t==T&&A!=a){
			int z=(X-x)*(X-x)+(Y-y)*(Y-y);
			if(D[t]<z)D[t]=z,S[t]=f-F;
			if(D[t]==z&&S[t]>f-F)S[t]=f-F;
		}
		F=f,A=a,T=t,X=x,Y=y;
	}
	for(N=0;N<2;N++){
		if(D[N]==-1)puts("-1 -1");
		else printf("%f %f\n",sqrt(D[N]),S[N]/60.0);
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
 
bool isprime[maxn+2];
vector<int>primes;
void sieve(){
        int i,j;
        isprime[0] = isprime[1] = false;
        isprime[2] = true;
        
        for(int i=4;i<=maxn; i+=2) isprime[i] = false;
        for(int i=3;i<=maxn; i+=2) isprime[i] = true;
        
        for(long i=3;i*i<=maxn; i+=2){
            if(isprime[i]){
                for(long j=i*i; j<=maxn;j+=2*i) isprime[j] = false;
            }
        }
 
        primes.push_back(2);
        for(int i = 3; i <= maxn; i+=2) if(isprime[i]) primes.push_back(i);
}
 

int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    */
    
    int T,n;
    sieve();
    while(scanf("%d",&n)==1){
        int idx = lower_bound(all(primes), n) - primes.begin();
        //if(idx > 0 and primes[idx] > n) idx--;
        printf("%d\n", primes[idx]);
    }    
    return 0;
}

Measured memory_bytes: 640
# Your code here!
from sys import stdin
 
#A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
N = int(input())
 
counter = 0
 
for i in range(1,N+1):
    if (i%3 != 0) & (i%5 != 0):
        counter = counter + i
 
print(counter)

Measured memory_bytes: 65116
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def solve(X: int, Y: int):
    ans = 0
    while X <= Y:
        ans += 1
        X *= 2
    print(ans)
    return ans


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int

    solve(X, Y)


if __name__ == '__main__':
    main()


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

int main(){

    string S = "";
    cin >> S;

    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int n,k;
int a[100000];
int b[100000];
int main()
{
	for(;;){
		int ans=0;
	    for(int i=0;i<100000;i++)b[i]=0;
	    cin >> n >> k;
	    if(n==0&&k==0)return 0;
	    for(int i=0;i<k;i++)cin >> a[i];
      	sort(a,a+k);
    	if(a[0]==0){
		    for(int i=1;i<k;i++)a[i]=a[i]-i;
		    for(int i=1;i<k;i++){
                b[a[i]]++;
	        }
		    for(int i=1;i<n-1;i++){
				ans=max(ans,b[i]+b[i+1]+1);
			}
	    }
	    else{
			for(int i=0;i<k;i++)a[i]=a[i]-i;
			for(int i=0;i<k;i++)b[a[i]]++;
			for(int i=0;i<n-1;i++){
				ans=max(ans,b[i]);
			}
	    }
		printf("%d\n",ans);
	}
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

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

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

    double ans = (v[0]+v[1])/2;
    for (ll i = 2; i < N; i++) {
        ans = double(ans+v[i])/2;
    }

    cout << setprecision(15) << ans << endl;
    return 0;
}

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

#define pb push_back
#define ppp pop_back
#define fi first
#define se second
#define pii pair<int,int>

const int N = 1e5 + 5;

int a[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) cin >> a[i];
    int ans = 1e9;
    for (int i=1; i<=n; i++) {
        if (i+k-1 > n) break; 
        int l = a[i], r = a[i+k-1];
        ans = min(ans, r - l + min(abs(l), abs(r)));
    }
    cout << ans;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 9999999999;
ll dx[4]={1,-1,0,0};
ll dy[4]={0,0,1,-1};
ll h , w , k ;
bool inarea(ll x,ll y){
  return x >= 0 && y >= 0 && x < h && y < w ;
}

int main()
{
cin >> h >> w >> k ;
string s[h];
rep(i,h){
  cin >>s[i];
}
vector<pair<ll,ll>> v;
ll dist[h][w]={};
queue<pair<ll,ll>> q;
rep(i,h)rep(j,w){
  if(s[i][j]=='S'){q.push({i,j});
  dist[i][j]=1;
  v.emplace_back(i,j);}
}
while(!q.empty()){
  auto p=q.front();
  q.pop();
  if(p.first==0 || p.first==h-1 || p.second==0 || p.second==w-1){
    cout << 1 << endl;
    return 0;
  }
  rep(i,4){
    ll x=p.first+dx[i];
    ll y=p.second+dy[i];
    if(inarea(x,y) && dist[x][y]==0 && dist[p.first][p.second]<=k && s[x][y]=='.'){
      dist[x][y]=dist[p.first][p.second]+1;
      q.push({x,y});
      v.push_back({x,y});
    }
  }
}
for(auto a:v){
  ans=min(ans,(a.first+k-1)/k);
  ans=min(ans,(h-1-a.first+k-1)/k);
  ans=min(ans,(a.second+k-1)/k);
  ans=min(ans,(w-1-a.second+k-1)/k);
}
cout << ans+1 << endl;
return 0;
}

Measured memory_bytes: 7296
A, B, C = (int(x) for x in input().split())
D = C - (int(C/(7*A+B))*(A*7+B))
#print(D/A)
#print(int(C//(7*A+B)))
if D%A == 0:
    if D < 7*A:
        print(int(C/(7*A+B))*7 + int(D/A))
    else:
        print(int(C/(7*A+B))*7 + 7)
else:
    if D < 7*A:
        print(int(C/(7*A+B))*7 + int(D/A) + 1)
    else:
        print(int(C/(7*A+B))*7 + 7)



Measured memory_bytes: 5608
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int A, B, C, D,ans;
	cin >> A >> B >> C >> D;
	if (A <= C) {
		if (B <= C)ans = 0;
		else if (B > D)ans = D - C;
		else ans = B - C;
	}
	else {
		if (D <= A)ans = 0;
		else if (D > B)ans = B - A;
		else ans = D - A;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
a, b = M.times.map { gets.chomp.split.map(&:to_i) }.transpose # 自身を行列と見立てて、行列の転置(行と列の入れ換え)を行う。転置した配列を生成して返す。

ans = Array.new(N + 1, 0) # 長さ size の配列を生成し、各要素を val で初期化して返す。

M.times do |i|
  ans[a[i]] += 1
  ans[b[i]] += 1 
end

puts ans[1..N] # ans だけだと要素1 番目も見る

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, a;
	cin >> n;
	bool me = false;
	rep(i, 1, n){
		cin >> a;
		if(a%2 != 0){
			me = true;
		}
	}
	if(me){print("first")}
	else{print("second")}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int N; cin >> N;
    if(N==1){
        cout << "Hello World" << endl;
    }else{
        int a,b; cin >> a >> b;
        cout << a+b << endl;
    }
}

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

int main(){
  int m,nmax,nmin,p[200],n,maxn;
  while(1){
    cin>> m>>nmin>>nmax;
    if(m==0&&nmax==0&&nmin==0)
      break;
    for(int i=0;i<m;i++)
      cin>>p[i];
    maxn=0;
    for(int i=nmin;i<=nmax;i++)
      if(maxn<=p[i-1]-p[i]){
        maxn=p[i-1]-p[i];
        n=i;
      }
    cout<<n<<endl;
  }
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;
int n, l, q, x, y, k, s, a[N], b[N][20];
int main() {
	int i, j;
	scanf("%d", &n);
	for(i=1; i<=n; i++) scanf("%d", &a[i]);
	scanf("%d%d", &l, &q);
	for(i=j=1; i<n; i++) {
		for(; j<n && a[j+1]-a[i]<=l; j++);
		b[i][0] = j;
	}
	for(j=1; b[1][j-1]; j++) for(i=1; i<n; i++) {
		b[i][j] = b[b[i][j-1]][j-1];
	}
	k = j-2;
	while(q--) {
		scanf("%d%d", &x, &y);
		if(x>y) swap(x, y);
		for(j=k, s=0; j>=0; j--) {
			if(!b[x][j]) continue;
			if(b[x][j] < y) {
				s += 1<<j;
				x = b[x][j];
			}
		}
		printf("%d\n", s+1);
	}
	return 0;
}

Measured memory_bytes: 9088
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int  a, b;
    cin >> a >> b;
    int tap = (b - a) / (a - 1) + 1;
    if (b == 1) {
        cout << "0" << endl;
    } else if (b < a) {
         cout << "1" << endl;
    } else if (b >= a) {
        if ((b - a) % (a - 1) != 0){
            ++tap;
            cout << tap << endl;
        } else {
            cout << tap << endl;
        }
    }

    return 0;
}

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int K;
    int A, B;
    ist >> K >> A >> B;

    /* ------- 計算 ------- */

    for(int i = A; i <= B; i++) {
        if(i%K == 0) {
            ost << "OK" << endl;
            return;
        }
    }

    ost << "NG" << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


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

using namespace std;

#define ll long long 
#define pi 3.14159265358979323
#define mod 1000000007

void solve(){
    int k;
    cin>>k;
    ll sum = 0;
    for(int a = 1;a<=k;a++){
        for(int b = 1;b<=k;b++){
            for(int c = 1;c<=k;c++){
                sum += __gcd(a,__gcd(b,c));
            }
        }
    }
    cout<<sum;
}

int main() {
    int t = 1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3624
N,K=map(int,input().split())
l=list(map(int,input().split()))

for i in range(N):
    l[i]=abs(l[i]-K)
    
def ins(num):
    l=[]
    for i in range(1,int(num**0.5//1)+1):
        if num%i==0:
            l.append(i)
            l.append(num//i)
    return l

cand=(ins(min(l)))

cand.sort()
#print(cand)

count=0

for item in cand:
    temp=0
    for target in l:
        if target%item==0:
            temp+=1
    count=max(count,temp)
    if count==temp:
        ans=item
print(ans)

#遅いかも

Measured memory_bytes: 14252
h, w = map(int, input().split())

a = []

for i in range(h):
    a.append(input())

#print(a)

ans = []

for i in range(h + 2):
    if i == 0 or i == h + 1:
        s = ""
        for j in range(w + 2):
            s = s + "#"

        ans.append(s)

    else:
        s = "#" + a[i - 1] + "#"
        ans.append(s)

#print(ans)

print('\n'.join(ans))


Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int A, B, M, x, y, c, ans = INT_MAX;
	cin >> A >> B >> M;
	vector<int> a(A), b(B);
	for (int& i : a) cin >> i;
	for (int& i : b) cin >> i;
	for (int i = 0; i < M; i++) {
		cin >> x >> y >> c;
		ans = min(ans, a[x - 1] + b[y - 1] - c);
	}
	cout << min(ans, *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end()));
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xmod (int)(1e9+7)
using namespace std;

ll x,y,fac[1000005],sum;
ll fpow(ll a,ll b){
	ll ans=1,base=a;
	while (b > 0){
		if ((b&1) == 1) ans=ans*base%xmod;
		base=base*base%xmod;
		b/=2;
	}
	return ans;
}
int main(){
	scanf("%lld%lld",&x,&y);
	fac[0]=1;
	for (int i=1;i<=1000000;i++){
		fac[i]=fac[i-1]*i;
		fac[i]%=xmod;
	}
	for (int i=0;i<=1000000;i++){
		if (y >= i*2 && (y-i*2)*2+i == x){
			sum=(((fac[i+y-i*2]%xmod)*(fpow(fac[i],xmod-2)%xmod)%xmod)*(fpow(fac[y-i*2],xmod-2)%xmod))%xmod;
			sum%=xmod;
		//	printf("%lld %lld %lld\n",fac[i],fac[y-i*2],fac[i+y-i*2]);
		}
	}
	printf("%lld\n",sum);
	return 0;
}

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

bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false; 
  }
  return true;
}

int DP[101][76];
int main() {
  int n;
  cin >> n;
  
  vector<int> v;
  for (int i = 2; i <= n; ++i) {
    if (!is_prime(i)) continue;
    int sum = 0;
    for (int k = 1; k <= n; ++k) {
      int p = k;
      while (p % i == 0) {
        ++sum;
        p /= i;
      }
    }
    v.push_back(sum + 1);
  }
  
  DP[0][1] = 1;
  for (int i = 0; i < v.size(); ++i) {
    for (int k = 0; k <= 75; ++k) {
      for (int dk = 1; dk <= v[i]; ++dk) {
        if (k * dk > 75) continue;
        DP[i + 1][k * dk] += DP[i][k];
      }
    }
  }
  
  cout << DP[v.size()][75] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
#define V vector<int>
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;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)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;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))





signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	if (n>=m) {
		cout << 0 << endl; return 0;
	}
	vector<int>x(m); rep(i, m)cin >> x[i];
	sort(x.begin(), x.end());
	vector<int>sa(m - 1);
	rep(i, m - 1) {
		sa[i] = x[i + 1] - x[i];
	}
	sort(sa.begin(), sa.end());
	int ans = 0;
	rep(i, m - n) {
		ans += sa[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() 
{
	int a;
	int b;
	cin >> a;
	cin >> b;
	if( a>b ){
		cout << "a > b";
	}else if( a<b ){
		cout << "a < b";
	}else if( a==b ){
		cout << "a == b";
	}
	cout << endl;
}


Measured memory_bytes: 3080
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

a, b = input().split()
a = int(a)
p, q = map(int, b.split('.'))
res = a * p + a * q // 100
print(res)


Measured memory_bytes: 9200
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int sum = 7;
		int count = -1;
		for(int i = 0; i < 1000000; i ++){
			if(sum % K == 0){
				count = i + 1;
				break;
			}
			sum %= K;
			sum *= 10;
			sum += 7;
	}
	
	System.out.println(count);
}
}

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

int main(void) {

	int x, h, m, s, k;
	cin >> x;
	h = x / 3600;
	k = x / 60;
	m = k % 60;
	s = x % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  int d1[n], d2[n];
  for (int i = 0; i < n; ++i){
    cin >> d1[i] >> d2[i];
  }
  int yes = 0;
  for (int i = 2; i < n; ++i){
    if(d1[i]==d2[i] and d1[i-1]==d2[i-1] and d1[i-2]==d2[i-2])  yes = 1;
  }
  if(yes) cout << "Yes\n";
  else  cout << "No\n";
  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main()
{
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  for(;;)
  {
	C=C-B;
    if(C<=0)
    {
      printf("Yes");
      break;
    }
    A=A-D;
    if(A<=0)
    {
      printf("No");
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

class RMQ_segment_tree
{
    using data_type = int;

public:

    vector<data_type> dat;
    int N;
    data_type infinity;

    RMQ_segment_tree(int n, data_type inf){
        N = 1;
        while(n > N) N = N << 1;
        dat = vector<data_type>(2 * N - 1, inf);
        infinity = inf;
    }

    //k番目の値をaに更新
    void update(int k, data_type a){
        k += N - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    //[a, b)の最小値
    data_type minval(int a, int b){
        return query(a, b, 0, 0, N);
    }

    data_type query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return infinity;
        if(a <= l && r <= b) return dat[k];
        else{
            data_type vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            data_type vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

signed main(){

    int N, x; cin >> N >> x;
    vec a(N); readvec(a);

    RMQ_segment_tree sgt(2 * N, INF);
    REP(i, N) sgt.update(i, a[i]);
    REP(i, N) sgt.update(i + N, a[i]);
    
    int ans = INF;
    REP(m, N){
        int tmp = x * m;
        REP(i, N) tmp += sgt.minval(i + N - m, i + N + 1);
        ans = min(ans, tmp);
    }

    cout << ans;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100010];
int main(){
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	cout<<a[n/2+1]-a[n/2]<<'\n';
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

typedef double weight_t;
const weight_t INF=1<<29;

struct edge{
  int v;
  weight_t w;
};

vector<int> minimum_spanning_arborescence(const vector<vector<edge> > &G,int root){
  const int N=G.size();
  vector<int> prev(N,-1);
  vector<weight_t> weight(N,INF);
  for(int i=0;i<N;i++){
    for(auto e:G[i]){
      if(e.v!=root&&e.w<weight[e.v]){
	weight[e.v]=e.w;
	prev[e.v]=i;
      }
    }
  }
  vector<int> check(N,N);
  int cycle_len=0;
  vector<char> in_cycle(N);
  for(int i=0;i<N;i++){
    for(int j=i;j>=0;){
      if(check[j]<i)break;
      if(check[j]==i){
	for(int k=j;;){
	  cycle_len++;
	  in_cycle[k]=true;
	  k=prev[k];
	  if(k==j)goto found;
	}
      }
      check[j]=i;
      j=prev[j];
    }
  }
  return prev;
 found:
  int nN=N-cycle_len+1;
  vector<int> newv(N),oldv(N);
  for(int i=0,idx=0;i<N;i++){
    if(!in_cycle[i]){
      oldv[idx]=i;
      newv[i]=idx++;
    }else{
      newv[i]=nN-1;
    }
  }
  vector<vector<edge> > nG(nN);
  vector<int> in(N,-1),out(N,-1);
  vector<weight_t> in_val(N,INF),out_val(N,INF);
  for(int i=0;i<N;i++){
    for(auto e:G[i]){
      weight_t nc=e.w-weight[e.v];
      if(!in_cycle[i]){
	if(!in_cycle[e.v]){
	  nG[newv[i]].push_back({newv[e.v],nc});
	}else{
	  if(nc<in_val[i]){
	    in_val[i]=nc;
	    in[i]=e.v;
	  }
	}
      }else{
	if(!in_cycle[e.v]){
	  if(nc<out_val[e.v]){
	    out_val[e.v]=nc;
	    out[e.v]=i;
	  }
	}
      }
    }
  }
  for(int i=0;i<N;i++){
    if(in_val[i]<INF){
      nG[newv[i]].push_back({nN-1,in_val[i]});
    }
    if(out_val[i]<INF){
      nG[nN-1].push_back({newv[i],out_val[i]});
    }
  }
  auto r=minimum_spanning_arborescence(nG,newv[root]);
  vector<int> rv(N);
  for(int i=0;i<nN-1;i++){
    if(r[i]<0){
      rv[oldv[i]]=r[i];
    }else if(r[i]<nN-1){
      rv[oldv[i]]=oldv[r[i]];
    }else{
      rv[oldv[i]]=out[oldv[i]];
    }
  }
  int v_into_cycle=oldv[r[nN-1]];
  int v_in_cycle=in[v_into_cycle];
  rv[v_in_cycle]=v_into_cycle;
  int x=prev[v_in_cycle];
  for(int i=0;i<cycle_len-1;i++){
    rv[x]=prev[x];
    x=prev[x];
  }
  return rv;
}

double sqr(double d){
  return d*d;
}

int main(){
  int N,M;
  cin>>M>>N;
  double v[123][123];
  double d[123][123]={};
  vector<vector<edge> > G(N+1);
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>v[i][j];
      d[N][i]+=sqr(v[i][j]);
    }
    G[N].push_back({i,d[N][i]});
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j)continue;
      double num=0,den=0;
      for(int k=0;k<M;k++){
	num+=v[j][k]*v[i][k];
	den+=sqr(v[i][k]);
      }
      if(den==0){
	d[i][j]=d[N][j];
      }else{
	for(int k=0;k<M;k++){
	  d[i][j]+=sqr(v[j][k]-num/den*v[i][k]);
	}
      }
      G[i].push_back({j,d[i][j]});
    }
  }
  auto r=minimum_spanning_arborescence(G,N);
  double ans=0;
  for(int i=0;i<N;i++){
    ans+=d[r[i]][i];
  }
  cout<<fixed<<ans<<endl;
}

Measured memory_bytes: 8604
#include<stdio.h>
int main(){
  int a,b,c,d,i;
  while(scanf("%d%d",&a,&b) != EOF) {
    c=a+b;
    d=1;
    while(c>9){
      c=c/10;
      d++;
    }
    printf("%d\n",d);
  }
  return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;
int main() {
   int cnt = 1;
   while (1) {
      int x;
      cin >> x;
      if (x == 0)
         break;
      printf("Case %d: %d\n", cnt, x);
      cnt++;
   }
   return 0;
}


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

int a [100000];

int main()

{
	
	int h,n,z=0;
	cin >> h>> n;
	for (int i=0;i<n;i++)
	{
		cin >> a[i];
		z=z+a[i];
	}
	if (z>=h)
			cout << "Yes";
	else 
		cout << "No";
}


Measured memory_bytes: 640
n, m = map(int, input().split())
V = n + m
par = [i for i in range(0, V)]
sizes = [1] * V


def find(x):
    if x == par[x]:
        return x
    par[x] = find(par[x])
    return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if sizes[x] < sizes[y]:
        x, y = y, x
    par[y] = x
    sizes[x] += sizes[y]


for i in range(0, n):
    for l in [int(k)for k in input().split()][1:]:
        unite(i, l - 1 + n)
print("NO" if len([i for i in range(0, n)if find(i) != find(0)]) > 0 else "YES")


Measured memory_bytes: 12592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(){
  int a,b; cin>>a>>b;
  for(int i=0; i<1002; i++){
    int x=i*0.08, y=i*0.1;
    if(x==a && y==b) {
      cout<<i;
      return 0;
    }
  }
  cout<<-1;
}

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

digits = [str(x) for x in range(10)]
for i in range(A):
  if S[i] in digits:
    pass
  else:
    print("No")
    exit()

if S[A] != '-':
  print("No")
  exit()

for i in range(A+1, A+B+1):
  if S[i] in digits:
    pass
  else:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

//a,b両方に入ってる文字種の数を返す
int cnt(string a,string b){
    set<char> lt;
    rep(i,a.size()){
        rep(j,b.size()){
            if(a.at(i)==b.at(j)){
                lt.insert(a.at(i));
            }
        }
    }
    return lt.size();
}

int main(){
    string S;
    int N;
    cin>>N>>S;
    int ans=0;
    rep2(i,1,N-1){
        ans=max(ans,cnt(S.substr(0,i),S.substr(i,N)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,d,e,f,s;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	s=a+(b*5)+(c*10)+(d*50)+(e*100)+(f*500);
	
	if(s<1000){
		printf("0\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}


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

long a, b, c, d;
long gcd(long a, long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

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

long sub(long n) {
  return n - n / c - n / d + n / lcm(c, d);
}

int main() {
  cin >> a >> b >> c >> d;
  cout << sub(b) - sub(a - 1) << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	// N
	scanner.Scan()
	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	for i := 0; i < N; i++ {
		scanner.Scan()
		target, err := strconv.Atoi(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}

		// 偶数判定
		if target%2 == 0 {
			// 3, 5 倍数判定
			if target%3 != 0 && target%5 != 0 {
				fmt.Println("DENIED")
				os.Exit(0)
			}
		}
	}
	fmt.Println("APPROVED")
}


Measured memory_bytes: 1832
import java.util.*

fun main(args: Array<String>) {
    val xx = mutableListOf<Int>()
    
    Scanner(System.`in`).use {
        val n = it.nextInt()
        val x = it.nextInt()
        for (i in 0 until n) {
            xx.add(Math.abs(it.nextInt() - x))
        }
    }

    while (1 < xx.size) {
        if (xx[1] < xx[0]) {
            val tmp = xx[0]
            xx[0] = xx[1]
            xx[1] = tmp
        }

        val r = xx[1] % xx[0]

        if (r == 0) {
            xx.removeAt(1)
        } else {
            xx[1] = r
        }
    }

    println(xx[0])
}


Measured memory_bytes: 52044
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;






int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(c - a- b <= 0) {
        cout<<"No"<<endl;
        return 0;
    }

    ll n = c-a-b;

    if(4*a*b < n * n) 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 int long long
using ll = long long;

int N, M, s, g1, g2;
ll dist[101][101];
void init() {
    REP(i, N) {
        REP(j, N) { dist[i][j] = 1e9; }
    }
    REP(i, N) dist[i][i] = 0;
}

bool solve() {
    cin >> N >> M >> s >> g1 >> g2;
    if (N == 0) return false;
    init();
    REP(i, M) {
        int u, v, c;
        cin >> u >> v >> c;
        u--, v--;
        dist[u][v] = c;
    }
    s--, g1--, g2--;
    REP(k, N) REP(i, N) REP(j, N) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); }
    int ans = 1e9;
    REP(m, N) { ans = min(ans, dist[s][m] + dist[m][g1] + dist[m][g2]); }
    cout << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    fr(i,k){
        if(a>=b) b*=2;
        else if(b>=c) c*=2;
    }
    puts(a<b&&b<c?"Yes":"No");
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t{1};
    //cin>>t;
    fr(i,t) solve();
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,n,s) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define rall(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void printpair(vector<pair<ll, ll>> vp)
{
  cout<<'['<<endl;
  rep(i,0,vp.size())
  {
    pair<ll, ll> p=vp[i];
    cout<<'{'<<p.first<<','<<p.second<<'}'<<endl;
  }
  cout<<'}'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
const long long INF = 1e12;
//------------------------------------------------------------
ll N,M;

void solve()
{
    cin >> N >> M;

    vector<vector<ll>> V(N);
    rep(i,0,M)
    {
      ll A,B; cin >> A >> B;
      --A; --B;
      V[A].push_back(B);
      V[B].push_back(A);
    }

    queue<ll> Q; // 次の場所を随時格納
    Q.push(0);

    vector<ll> ans(N, -1); // 次の場所を格納していく
    ans[0]=0;

    while (!Q.empty())
    {
      ll p = Q.front(); Q.pop();
      for(ll NP:V[p])
      {
        if(ans[NP]>-1) continue;
        ans[NP] = p;
        Q.push(NP);
      }
    }
    
    print("Yes");
    rep(i,1,N) print(ans[i]+1);

    return;
}



Measured memory_bytes: 12940
while True:
	m,f,r=map(int,input().split())
	if m==(-1) and f==(-1) and r==(-1):
		break
	if m==-1 or f==-1:
		print('F')
	elif m+f>=80:
		print('A')
	elif 65<=m+f and m+f<80:
		print('B')
	elif 50<=m+f and m+f<65:
		print('C')
	elif 30<=m+f and m+f<50:
		if r>=50:
			print('C')
		else:
			print('D')
	else:
		print('F')


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

constexpr int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        int aa;
        cin >> aa, a[aa]++;
    }

    int ans = 1;
    for (int i = 0; i < n; i++) {
        if ((i == 0 && n%2 == 1 && a[i] != 1)
            || (i != 0 && i%2 != n%2 && a[i] != 2)
            || (i%2 == n%2 && a[i] != 0)) {
            ans = 0;
        }
    }

    if (ans) {
        for (int i = 0; i < n / 2; i++) ans = ans * 2 % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a;
    
    cin>>a;
    
    int b[4];
    
    
    b[3]=a/1000;
    b[2]=(a%1000)/100;    
    b[1]=(a%1000%100)/10;
    b[0]=a%1000%100%10;
    if(b[3]==b[2]&& b[2]==b[1] ||b[2]==b[1]&& b[1]==b[0]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
    }
    let mut ans = 0;
    for i in 1..(n + 1) {
        let mut t = i;
        let mut c = 0;
        while t > 0 {
            t /= 10;
            c += 1;
        }
        ans += c & 1;
    }
    write!(out, "{}\n", ans).unwrap();
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i] >> B[i];
	}
 
	//pair<int, int> は int2つの型
	vector<pair<int, int>> AB(N);
	for (int i = 0; i < N; i++)
	{
		AB[i] = make_pair(A[i], B[i]);
	}
	sort(AB.begin(), AB.end());
 
	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		//このお店で購入する数を決める
		int buy = min(M, AB[i].second);
 
		//買った金額を加算する
		ans += (long long)buy * AB[i].first;
		//残り本数を減らす
		M -= buy;
	}
 
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int N;
vector<ll> a;

int main() {

    cin >> N;
    a.resize(N);
    REP(i,N) cin >> a[i];

    int cnt4 = 0;
    int cnt2 = 0;

    REP(i,N) {
        if (a[i] % 4 == 0) cnt4++;
        else if (a[i] % 2 == 0) cnt2++;
    }

    N -= cnt2;

    if (cnt2 == 0) {
        if (cnt4 * 2 + 1 >= N) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }

    if (N <= cnt4 * 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

signed main(){
  int ans=0;
  long long n,d;cin>>n>>d;
  while(n--){
    long long x,y;cin>>x>>y;
    ans+=(x*x+y*y<=d*d);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
num = int(input())
    
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    alist = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

    while X_dumy>0:
        X_dumy-=1
        out = alist[(X_dumy%n)]+out
        X_dumy = int(X_dumy/n)
    return out
    
print(Base_10_to_n(num, 26))

Measured memory_bytes: 9208