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

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

int main()
{
  int N,K;scanf("%d %d",&N,&K);
  int A[N];for(int i=0;i<N;i++)scanf("%d",&A[i]);
  int g=A[0],mx=A[0];
  for(int i=1;i<N;i++)g=gcd(g,A[i]),mx=max(mx,A[i]);
  if(K<=mx&&K%g==0)printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 4000
#include <iostream>
#include <string>
#include <cstdio>
#include <string.h>
#include <stdlib.h>

using namespace std;

//stackの0番目は空にする
int top = 0, S[10000];

void push(int x) { S[++top] = x; }

int pop() {
    int result = S[top];
    top--;
    return result;
    // return S[--top+1]; 
}

int main() {
    int a, b;
    char s[1000];
    while(cin >> s) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if(s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if(s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else if(s[0] == '/') {
            a = pop();
            b = pop();
            push(a / b);
        } else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}

/*
逆ポーランド記法で与えられた数式の計算
先頭からひとつづつ順番に文字列を読み込む
文字列が数値であればスタックに値を積む（一時的にデータを退避するときに有効なデータ構造
演算子であればスタックから値を二つ取り出して演算子結果をスタックに積む
これらを繰り返す

スタックの操作（最後に入ったものが最初に取り出される）
push(x)　トップにｘを追加
pop()　トップからｘを取り出す

*/


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define  ll      long long 
#define  int     ll 
#define  mod     1000000007
#define  pb      push_back
#define  pob     pop_back
#define  f1      first
#define  s2      second
#define  N       50
#define  K       100005
#define  bol     (int)ceil((say-1)/2.0)
#define  PII     pair<int,int>
#define  PIII    pair<int,PII>
#define  PIIII   pair<PII,PII>
#define  PIIIII  pair<PIII,PII>
#define  PIIIIII pair<PIII,PIII>

using namespace std; 


int n;
int dizi[N][N];
int dp[N][K];

int fun(int crr,int mask,int local,int ans,ll gcrr);
int dpf(int crr,int mask){
    if(crr>=(n+1)){
        return 0;
    }
    if(dp[crr][mask]!=-1)return dp[crr][mask];
    if(mask&(1<<crr))
        return dpf(crr+1,mask);

    dp[crr][mask]=fun(crr,mask,(1<<crr),0,crr);
    return dp[crr][mask];
}
int fun(int crr,int mask,int local,int ans,int gcrr){
    int mx=0,top;
    mx=max(mx,ans+dpf(gcrr+1,mask|local));
    for(int i=(crr+1);i<=(n);i++){
        if(mask&(1<<i))continue;
        top=0;
        for(int j=1;j<=n;j++){
            if(local&(1<<j)){
                top+=dizi[i][j];
            }
        }
        mx=max(mx,fun(i,mask,local|(1<<i),ans+top,gcrr));
    }
    // printf("%lld\n",mx );
    return mx;
}
int32_t main(){
    // freopen("a.gir","r",stdin);      
    // freopen("a.cik","w",stdout);
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            scanf("%lld",&dizi[i][j]);
        }
    }
    memset(dp,-1,sizeof(dp));
    printf("%lld\n", dpf(1,0));
}


Measured memory_bytes: 39296
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[202020];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int h=1;
	for(int i=1;i<=n;i++){
		if(a[i]==h)
			h++;
	}
	if(h==1) printf("-1");
	else
		printf("%d",n-h+1);
	return 0;
}

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

void startup()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
}


int main()
{
startup();

int n,x,t ;
cin>>n>>x>>t;
int ans=t;
int y=x;
while(x<n)
{
    x+=y;
    ans+=t;
}
	cout<<ans;



	return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll; 

string S;

int main() {
    cin >> S;
    if (S.substr(5, 2) == "04" || S.substr(5, 2) == "03" ||
        S.substr(5, 2) == "02" || S.substr(5, 2) == "01") {
        cout << "Heisei" << endl;
    } 
    else {
        cout << "TBD" << endl;
    }
    return 0;    
}

Measured memory_bytes: 888
#include<stdio.h>
int main(){
int n[100],x,i,a;
a=0;
for(i=0;i<100;i++){
n[i]=0;
}
while(scanf("%d",&x)!=EOF){
n[x-1]++;
if(n[x-1]>a) a=n[x-1];
}
for(i=0;i<100;i++){
if(n[i]==a) printf("%d\n",i+1);
}
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n;
    cin >>n;
    ll A[n+1];//1~nを使う
    ll R[n+1];
    A[0]=0;
    R[0]=0,R[1]=0;
    for(int i=1;i<=n;i++){
        cin >>A[i];
        R[1]+=(i%2==0)?(-A[i]):(A[i]);
    }
    cout <<R[1];
    for(int i=2;i<=n;i++){
        R[i]=(A[i-1]-R[i-1]/2)*2;
        cout <<" "<<R[i];
    }
    cout <<endl;

    return 0;

}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    int d=0;
    do{
        if(d==c){
            cout<<"YES"<<endl;
            return 0;
        }
        d=(d+a)%b;
    }while (d);
    cout<<"NO"<<endl;
    return 0;
}

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

using namespace std;

int main() {
int a[3];
for (int i = 0; i < 3; ++i) {
cin >> a[i];
}

int s1 = 0;
int s2=  0;

for (int i = 0; i < 3; ++i) {
if (a[i] == 5) s1++;
else if (a[i] == 7) s2++;
}

if (s1 == 2 && s2 == 1) {
cout << "YES\n";
} else {
cout << "NO\n";
}

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define MX 1000000007

int main()
{
	
	ll n,d;
	cin>>n>>d;
	ll x,y;
	ll i,ans=0;
	FOR(i,n)
	{
		cin>>x>>y;
		if((d*d)>= x*x + y*y)
			ans++;

	}
	cout<<ans;

}

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

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
using pll = pair<ll, ll>;

const ll MAXN = 1000001;
bool P[MAXN];

map<ll, ll> makePrimeFactorMap(ll n)
{
    map<ll, ll> res;

    for (ll i=2;i*i<=n;++i)
    {
        while ((n % i) == 0) { n /= i; ++res[i]; }
    }

    if (n != 1) { ++res[n]; }

    return res;
}

template<typename T> T gcdraw(T a, T b) { return a ? gcdraw(b%a, a) : b; }
template<typename T> T gcd(T a, T b)
{
    const auto aa = abs(a), bb = abs(b);
    return aa > bb ? gcdraw(aa, bb) : gcdraw(bb, aa);
}

int main()
{
    ll N;
    cin >> N;

    vector<ll> A(N);
    for (auto& a: A) { cin >> a; }

    bool isPairwise = true;
    ll setwise = A[0];

    for (ll i=0;i<N;++i)
    {
        if (isPairwise) for (const auto& kv : makePrimeFactorMap(A[i]))
        {
            isPairwise &= !P[kv.first];
            P[kv.first] = true;
        }

        setwise = gcd(setwise, A[i]);
    }

    if (isPairwise)        { cout << "pairwise coprime" << endl; }
    else if (setwise == 1) { cout << "setwise coprime" << endl; }
    else                   { cout << "not coprime" << endl; }

    return 0;
}


Measured memory_bytes: 11120
#include <stdio.h>
int main(void){
    int n;
    scanf("%d\n",&n);
    
    int fib[45];
    fib[0]=1;
    fib[1]=1;
    
    for(int i=2;i<=n;i++){
        fib[i]=fib[i-1]+fib[i-2];
    }
    
    printf("%d\n",fib[n]);
    
    return 0;
}



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

int a[100];
int main() {
	int n;
	while (cin >> n, n) {
		rep(i, n)scanf("%d", &a[i]);
		int cnt = 0;
		bool flag = true;
		for (int i = 0; flag; i++) {
			flag = false;
			for (int j = n - 1; j >= i + 1; j--) {
				if (a[j] < a[j - 1]) {
					swap(a[j], a[j - 1]);
					flag = true;
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3112
from collections import Counter

N = int(input())
A = list(map(int, input().split()))


def comb(x):
    if x == 0:
        return 0
    if x == 1:
        return 0
    return x * (x - 1) // 2


d = Counter(A)
# print(d)
k = d.keys()

# print(k)
total = 0

for kk in k:
    total += comb(d[kk])

# print(total)

for a in A:
    res = total
    res -= comb(d[a])
    res += comb(d[a] - 1)
    print(res)

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

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < n.size(); i++) {
    if (n.at(i) == '1') n.at(i) = '9';
    else if (n.at(i) == '9') n.at(i) = '1';
  }
  cout << n << endl;
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if( abs( a-c ) <= d || (abs( a-b ) <= d && abs( b-c ) <= d) ) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 256
from math import atan, degrees
a, b, x = map(int, input().split())

if x * 2 >= a ** 2 * b:
    print('{:.8}'.format(degrees(atan(2 * b / a - 2 * x / a ** 3))))
else:
    print('{:.8}'.format(degrees(atan(a * b ** 2 / 2 / x))))

Measured memory_bytes: 2940
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[10010][110][2];

signed main() {
    string s; cin >> s;
    int D; cin >> D;

    int N = s.length();
    dp[0][0][0] = 1;
    for(int i=0; i<N; i++) {
        for(int k=0; k<D; k++) {
            for(int f=0; f<2; f++) {
                int lim = f ? 9 : s[i] - '0';
                for(int x=0; x<=lim; x++) {
                    int nk = (k + x) % D;
                    int nf = f || (x < lim);
                    (dp[i+1][nk][nf] += dp[i][k][f]) %= MOD;
                }
            }
        }
    }

    cout << (dp[N][0][0] + dp[N][0][1] - 1 + MOD) % MOD << endl;
    return 0;
}


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

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

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

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

    vector<int> G[100005];

    for (int i = 0;i < M;i++){
        int a,b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 1;i <= N;i++){
        cout << G[i].size() << endl;
    }

    return 0;

}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};

int main() {
	string s;
	cin >> s;
	ll n = 0;
	int ans = 0;
	for (int i= 0;i < s.size();i++) {
		n += (s[i] - '0') * pow(10,s.size() - i - 1);
	}
	int p = pow(4,s.size());
	for (int i = 0;i < p;i++) {
		int x = i;
		ll seisei = 0;
		int cnt = 0;
		while (x != 0) {
			if (x % 4 == 0) {
				seisei += pow(10,cnt) * 0;
			} else if (x % 4 == 1) {
				seisei += pow(10,cnt) * 3;
			} else if (x % 4 == 2) {
				seisei += pow(10,cnt) * 5;
			} else {
				seisei += pow(10,cnt) * 7;
			}
			cnt++;
			x /= 4;
		}
		if (seisei != 0 && seisei <= n) {
			string nn = to_string(seisei);
			bool aa = false,bb = false,cc = false,xx = false;
			for (int j = 0;j < nn.size();j++) {
				if (nn[j] - '0' == 0) {xx = true;}
				if (nn[j] - '0' == 3) {aa = true;}
				if (nn[j] - '0' == 5) {bb = true;}
				if (nn[j] - '0' == 7) {cc = true;}
			}
			if (aa && bb && cc && !xx) {ans++;}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<pair<int, int>>> parent(h, vector<pair<int, int>>(w, make_pair(-1, -1)));
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    parent[0][0] = make_pair(-2, -2);
    while(!q.empty()){
        pair<int, int> v = q.front(); q.pop();
        for(int i = 0; i < 4; i++){
            int x = v.first + dx[i];
            int y = v.second + dy[i];
            if (x < 0 || x >= w || y < 0 || y >= h) continue;
            if (s[y][x] == '#' || parent[y][x] != make_pair(-1, -1)) continue;
            q.push(make_pair(x, y));
            parent[y][x] = v;
        }
    }

    if (parent[h-1][w-1] == make_pair(-1, -1)){
        cout << -1 << endl;
        return 0;
    }

    pair<int, int> pre = parent[h-1][w-1];
    set<pair<int, int>> st;
    while(pre != make_pair(-2, -2)){
        st.insert(pre);
        int x = pre.first;
        int y = pre.second;
        pre = parent[y][x];
    }
    st.insert(make_pair(w-1, h-1));

    int ans = 0;
    rep(row, h) rep(col, w){
        if (s[row][col] == '#') continue;
        auto itr = st.find(make_pair(col, row));
        if (itr != st.end()) continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
let partition (a : int array) p r =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let rec doit i j =
    if j = r then (swap i r; i)
    else if a.(j) <= a.(r) then (swap i j; doit (i + 1) (j + 1))
    else doit i (j + 1) in
  doit p p

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let k = partition a 0 (n - 1) in
  Array.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else if i = k then " [%d]" else " %d") e) a;
  print_newline ()

Measured memory_bytes: 5264
#include <stdio.h>

int main(void)
{
    int a,b,c,d;
    scanf("%d %d",&a,&b);
    if (b%a==0){
    c=a+b;
    printf("%d\n",c);
    }   
    else{
    d=b-a;
    printf("%d\n",d);
    }   
    return 0;
}



Measured memory_bytes: 128
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  ll n; cin >> n;
  ll s = 100;
  int y=0;
  while (s < n) {
    s += (s/100);
    y++;
  }
  cout << y << endl;
  return 0;
}


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

#define int long long int

const int INF=1e9+5;

#undef int
int main()
{
	
	int n,k;
	scanf("%d",&n);
	vector<int> dp(3,0);
	vector<int> arr(3,0);
	dp[0]=0;
	
	
	for(int i=0;i<n;i++)
	{
		vector<int> new_dp(3,0);
		for(int j=0;j<3;j++)
			scanf("%d",&arr[j]);
	
		
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j!=k)
				{
					new_dp[j]=max(new_dp[j],dp[k]+arr[j]);
				}
			}
		}

		dp=new_dp;

	}
	
	
	printf("%d",max(max(dp[0],dp[1]),dp[2]));


	
}

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

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

using namespace std;

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

	int ans=0,now=0;
	rep(i,n){
		int t; cin>>t;
		if(now+T<t) ans+=T;
		else        ans+=t-now;
		now=t;
	}
	ans+=T;
	cout<<ans<<endl;

	return 0;
}


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

class Program{
  static void Main(){
    int N = int.Parse(Console.ReadLine());
    int[] D = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
    
    long sum = 0;
    for (int i = 0; i < N-1; i++){
      for (int j = i + 1; j < N; j++){
        sum += D[i] * D[j];
      }
    }
    
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N,K;
    cin >> N >> K;
    ll ans = K;
    rep(i,N-1){
        ans*=(K-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>

const int MOD = 1000000007;


ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}


int main(int argc, char *argv[])
{
	ll a,b,n;
	cin>>a>>b>>n;
	ll x=n/b;
	ll y=n%b;
	if (x>0) y=b-1;
	cout<<(a*y)/b<<endl;

	return 0;
}



Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>

#define I 1
#define V 5
#define X 10
#define L 50
#define C 100
#define D 500
#define M 1000

int main(void)
{
	char num_roma[101];
	int i;
	int len;
	int num_arabia = 0;
	while (scanf("%s", num_roma) != EOF){
		
		len = strlen(num_roma) - 1;
		
		if (num_roma[len] == 'I'){
			num_arabia += I;
		}
		else if (num_roma[len] == 'V'){
			num_arabia += V;
		}
		else if (num_roma[len] == 'X'){
			num_arabia += X;
		}
		else if (num_roma[len] == 'L'){
			num_arabia += L;
		}
		else if (num_roma[len] == 'C'){
			num_arabia += C;
		}
		else if (num_roma[len] == 'D'){
			num_arabia += D;
		}
		else if (num_roma[len] == 'M'){
			num_arabia += M;
		}
		
		len--;
		
		while (len >= 0){
			if (num_roma[len] == 'I'){
				if (num_roma[len + 1] != 'I'){
					num_arabia -= I;
				}
				else {
					num_arabia += I;
				}
			}
			
			else if (num_roma[len] == 'V'){
				if (num_roma[len + 1] != 'I' && num_roma[len + 1] != 'V'){
					num_arabia -= V;
				}
				else {
					num_arabia += V;
				}
			}
			else if (num_roma[len] == 'X'){
				if (num_roma[len + 1] != 'I' && num_roma[len + 1] != 'V' && num_roma[len + 1] != 'X'){
					num_arabia -= X;
				}
				else {
					num_arabia += X;
				}
			}
			
			else if (num_roma[len] == 'L'){
				if (num_roma[len + 1] != 'I' && num_roma[len + 1] != 'V' && num_roma[len + 1] != 'X' && num_roma[len + 1] != 'L'){
					num_arabia -= L;
				}
				else {
					num_arabia += L;
				}
			}
			
			else if (num_roma[len] =='C'){
				if (num_roma[len + 1] != 'D' && num_roma[len + 1] != 'M'){
					num_arabia += C;
				}
				else {
					num_arabia -= C;
				}
			}
			
			else if (num_roma[len] == 'D'){
				if (num_roma[len + 1] != 'M'){
					num_arabia += D;
				}
				else {
					num_arabia -= D;
				}
			}
			else if (num_roma[len] == 'M'){
				num_arabia += M;
			}
			len--;
		}
		printf("%d\n", num_arabia);
		num_arabia = 0;
	}
	return 0;
}

Measured memory_bytes: 540
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;
 
	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;
 
	    	return this.s-p.s;
	    }
 	}
 	class Sort implements Comparator<Integer> 
	{ 
	    public int compare(Integer a, Integer b) 
	    { 
	    	if(a < 0)
	    		a *= -1;
	    	if(b < 0)
	    		b *= -1;
	    	return a.compareTo(b);
	    } 
	}
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	int upperBound(long a[],long key)
	{
		int l=0,r=a.length-1;
		int i=-1;
 
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid]<key)
				l=mid+1;
 
			else{
				i=mid;	
				r=mid-1;
			}
			
		}
		return i;
	}
	int lowerBound(Pair[] a , long key)
	{
		int l = 0, r = a.length- 1;
		int i = -1;
 	
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid].f<key)
			{
				i=mid;
				l=mid+1;	
			}
 
			else
				r=mid-1;
			
		}
		return i;
	}
 
	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}
	
 
	int mod= 1000000007;
	long gcd(long x ,long y)
	{
		if(y==0)
			return x;
		return gcd(y,x%y);
	}
 
	// ArrayList a[];
	// int vis[],cnt=0;
	// void dfs(int ver)
	// {
	// 	ArrayList<Integer> l=a[ver];
	// 	if(l.size()==1)
	// 		cnt++;
	// 	for(int v:l)
	// 	{
	// 		if(vis[v]==0){
	// 			vis[v]=vis[ver]+1;
	// 			dfs(v);
	// 		}
	// 	}
	// }
 
 	int countSetBits(long n) 
    { 
        int count = 0; 
        while (n > 0) { 
            n &= (n - 1); 
            count++; 
        } 
        return count; 
    }

	void solve() throws IOException{
		int l = nextInt();
		int r = nextInt();
		int d = nextInt();
		int cnt = 0;
		
		for(int i = l; i <= r; i++)
		{
			if(i % d == 0)
				cnt++;
		}
		out.println(cnt);
	}
 	
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
 
		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Main().run();
	}		
}
 

Measured memory_bytes: 32924
import math

N, D = map(int, input().split())
xList = []
zahyoList = []
for x in range(N):
    xList.append(list(map(int, input().split())))

count = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        r = 0
        for n in range(D):
            r += (xList[i][n] - xList[j][n]) ** 2
        if (math.sqrt(r) % 1 == 0):
            count += 1

print(count)


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

int main(){
	int n , m , l;
	int i , j , k;
	int a[100][100]={0,0}; // m x n
	int b[100][100]={0,0}; // l x m
	long long int c[100][100]={0,0}; // l x n
	cin >> n >> m >> l;
	for(i=0 ; i<n ; i++){
		for(j=0 ; j<m ; j++){
			cin >> a[j][i];
		}
	}
	for(i=0 ; i<m ; i++){
		for(j=0 ; j<l ; j++){
			cin >> b[j][i];
		}
	}
	for(i=0 ; i<n ; i++){
		for(j=0 ; j<l ; j++){
			for(k=0 ; k<m ; k++){
				c[j][i]+=a[k][i]*b[j][k];
			}
		}
	}
	for (i=0 ; i<n ; i++){
		for(j=0 ; j<l-1 ; j++){
			cout << c[j][i] << " ";
		}
		cout << c[l-1][i] << endl;
	}
	return 0;
}

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

int main()
{
    std::size_t N;
    std::cin >> N;

    std::size_t n_AC  = 0;
    std::size_t n_WA  = 0;
    std::size_t n_TLE = 0;
    std::size_t n_RE  = 0;

    for(std::size_t i=0; i<N; ++i)
    {
        std::string result;
        std::cin >> result;
        if(result == "AC")
        {
            n_AC += 1;
        }
        else if(result == "WA")
        {
            n_WA += 1;
        }
        else if(result == "TLE")
        {
            n_TLE += 1;
        }
        else if(result == "RE")
        {
            n_RE += 1;
        }
        else
        {
            assert(false);
        }
    }

    std::cout << "AC x "  << n_AC << std::endl;
    std::cout << "WA x "  << n_WA << std::endl;
    std::cout << "TLE x " << n_TLE << std::endl;
    std::cout << "RE x "  << n_RE << std::endl;



    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<cmath>

using namespace std;

int main(){

    double x1, y1, x2, y2;

    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

    printf("%.8lf\n", sqrt( (x2-x1) * (x2-x1) + (y2-y1) * (y2-y1) ) );

    return 0;

}


Measured memory_bytes: 2724
from collections import defaultdict

N,M = map(int,input().split())
X = sorted(map(int,input().split()))
d = defaultdict(list)
for x in X:
    d[x%M].append(x)

res = 0
for i in range(M//2+1):
    j = (-i)%M

    if i == j:
        res += len(d[i])//2
    else:
        l, r = d[i], d[j]
        if len(l) < len(r):
            l,r = r,l

        t = 0
        last = None
        for v in l:
            if last is None:
                last = v
            elif last == v:
                t += 1
                last = None
            else:
                last = v

        res += len(r) + min((len(l)-len(r))//2, t)

print(res)

Measured memory_bytes: 32932
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=2e5+5;
const ll inf=1e17;



int main()
{
    idfc;

    ll a,b,c,d;

    cin>>a>>b>>c>>d;



    ll ans=b*d;
    ans=max(ans,b*c);
    ans=max(ans,a*d);
    ans=max(ans,a*c);
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3664
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

x=int(input())
while True:
    if is_prime(x):
        print(x)
        break
    else:
        x+=1

Measured memory_bytes: 2940
N,M,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))

if X >= Y:
    print('War')
else:
    for Z in range(X+1,Y+1):
        if max(x) < Z and Z <= min(y):
            print('No War')
            exit()
    else:
        print('War')



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <tuple>
#include <numeric>
#include <utility>
#include <climits>
#include <float.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#pragma GCC target ("avx2")

using namespace std;

typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
  	return vector<T>(a);
}
 
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  	cin.tie(0);
  	cout.tie(0);
  	ios::sync_with_stdio(false);
	
	long long n, c, ans = 0;
	cin >> n >> c;
	vector<ll> x(n), v(n);
	for(int i = 0; i < n; i++){
		cin >> x[i] >> v[i];		
	}
	vector<ll> ruiseki_tokei(n), ruiseki_hantokei(n);
	vector<ll> rev_tokei(n, 0), rev_hantokei(n, 0);
	ruiseki_tokei[0] = v[0] - x[0];
	for(int i = 1; i < n; i++){
		ruiseki_tokei[i] = ruiseki_tokei[i-1] + v[i] - (x[i] - x[i-1]);
		rev_tokei[i] = max(rev_tokei[i-1], ruiseki_tokei[i-1] - x[i-1]);
	}
	ruiseki_hantokei[n-1] = v[n-1] - (c - x[n-1]); 
	for(int i = n - 2; i >= 0; i--){
		ruiseki_hantokei[i] = ruiseki_hantokei[i+1] + v[i] - (x[i+1] - x[i]);
		rev_hantokei[i] = max(rev_hantokei[i+1], ruiseki_hantokei[i+1] - (c - x[i+1]));
	}
	for(int i = 0; i < n; i++){
		ans = max({ ans, ruiseki_tokei[i] + max(rev_hantokei[i], 0ll), ruiseki_hantokei[i] + max(rev_tokei[i], 0ll) });
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<pair<ll, ll>> arr(n);
  for(int i = 0; i < n; i++){
    cin >> arr[i].second >> arr[i].first;
  }
  sort(arr.begin(), arr.end());
  ll pr = 0;
  bool pos = true;
  for(int i = 0; i < n; i++){
    pr += arr[i].second;
    if( pr > arr[i].first )
      pos = false;
  }
  if( pos )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3328
/*input
6 5
1 2
3 2
4 2
1 6
5 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
bool vis[maxn];
vector<int> edge[maxn];

int dfs(int u,int d){
	vis[u]=1;
	int ret=1;
	if(d==0) return ret;
	for(int v:edge[u]) if(!vis[v]) ret+=dfs(v,d-1);
	return ret;
}

int main(){
	IOS;
	int n,k;
	cin>>n>>k;
	REP(i,n-1){
		int u,v;
		cin>>u>>v;
		u--;v--;
		edge[u].pb(v);
		edge[v].pb(u);
	}

	int ans=0;

	if(k%2==0){
		REP(i,n){
			fill(vis,vis+n,0);
			ans=max(ans,dfs(i,k/2));
		}
	}
	else{
		REP(i,n) for(int j:edge[i]) if(i<j){
			// cout<<i<<' '<<j<<'\n';
			fill(vis,vis+n,0);
			vis[i]=1;
			int cur=dfs(j,k/2);
			// cout<<cur<<'\n';
			vis[i]=0;
			cur+=dfs(i,k/2);
			// cout<<cur<<'\n';
			ans=max(ans,cur);
		}
	}
	cout<<n-ans<<'\n';
	return 0;
}


Measured memory_bytes: 7424
from collections import Counter
n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a = Counter(prime_factorize(n))
ans = 0
for i in a.values():
  for j in range(1,1000):
    di = j*(j+1)/2
    if di > i:
      ans += j-1
      break
print(ans)

Measured memory_bytes: 9464
#include <iostream>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define max(a, b) a > b ? a : b

int H[100000];

int main()
{
	int N;
	int count = 0;
	int max_count = 0;

	cin >> N;
	rep(i, N) cin >> H[i];

	rep(i, N - 1) {
		if (H[i] >= H[i + 1]) count++;
		else count = 0;
		max_count = max(max_count, count);
	}

	cout << max_count << endl;

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    const int mod=1000000007;
    long long int t=1;
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        t=t*i%mod;
    }
    printf("%d\n",t);
    return 0;
}


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

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

  int q = x / 100;
  int r = x % 100;

  if(5 * q >= r) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main(){
	var a, b int
	fmt.Scan(&a,&b)
	if a == b {
		fmt.Println(a+b)
	} else if a > b {
		fmt.Println(2*a-1)
	} else {
		fmt.Println(2*b-1)
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, k; cin >> n >> k;
  vector<ll> h(n); for(int i = 0; i < n; i++) cin >> h[i];
  ll ans = 1000000000;
  ll minn, maxn;
  sort(h.begin(), h.end());
  for(int i = 0; i+k-1 < n; i++) {
    minn = h[i];
    maxn = h[i+k-1];
    ans = min(ans, maxn-minn);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solvea()
{
    string s;
    cin>>s;
    if(s[s.length()-1]=='s'){
        s.append("es");
    } else{
        s.push_back('s');
    }
    cout<<s;
}
void solveb(){

}
void solvec(){

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

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solvea();
    }

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 100000000000009;
ll i;



int main(){
    ll N;
    cin>>N;
    V v(N);
    rep(0,N)cin>>v.at(i);
    ll cnt=0;
    ll sum=0;
    rep(0,N){
        if(v.at(i)<0){
            cnt++;
            v.at(i)*=-1;
        }
        sum+=v.at(i);
    }
    sort(v.begin(),v.end());
    if(cnt%2==1)sum=sum-2*v.at(0);
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
int A,B,K;
  cin >> K >> A  >> B;
  rep2(i,A, B+1 ){
  if(i%K==0){
  cout << "OK" << endl;
    return 0;
  }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3636
from collections import defaultdict
s = input()
k = int(input())
dd = {}
if len(s) == 1:
    print(s)
    exit()
for i in range(len(s)):
    dd[s[i]] = 1
for i in range(len(s)-1):
    for j in range(i+1, len(s)):
        if j-i+1 <= k:
            dd[s[i:j+1]] = 1
li = []
for key in dd:
    li.append(key)
li.sort()
print(li[k-1])

Measured memory_bytes: 76876
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program {
    internal static void Main(string[] args) {
        int N = int.Parse(ReadLine());

        var dp = new int[100010];
        dp[0] = 0;

        for (int i = 1; i <= 100000; i++) {
            dp[i] = 100000;
            int power = 1;
            while (power <= i) {
                dp[i] = Math.Min(dp[i], dp[i - power] + 1);
                power *= 6;
            }

            power = 1;
            while (power <= i)
            {
                dp[i] = Math.Min(dp[i], dp[i - power] + 1);
                power *= 9;
            }
        }

        WriteLine(dp[N]);
    }
}



Measured memory_bytes: 11232
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;

void input() {
  cin >> n;
}

void solve() {
  vector<int> a;

  for (int i = 0; i <= 9; ++i) {
    a.push_back(stoi(string(3, i + '0').c_str()));
  }

  cout << *lower_bound(a.cbegin(), a.cend(), n);
}

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

  preambule();
  input();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
 
void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}
ll sosuu[110];
void keisan(ll n){
    for (ll i=2;i<=n;i++){
        if (n%i==0){
            while(n%i==0){
                sosuu[i]=sosuu[i]+1;
                n/=i;
            }
        }
    }
}
int main(){
    fill(x,x+110,0);
    ll n;
    cin >> n;
    for (ll i=1;i<=n;i++){
        keisan(i);
    }
    ll ans=1;
    for (ll i=2;i<=n;i++){
        ans*=sosuu[i]+1;
        ans%=1000000007;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
long long n,i,x;
vector<long long> v;
int main() {
  /*  cin >> n;
    s = "";
    while(n > 1) {
        if(n%26 == 0) s += 'z';
        else s += (char)('a'+n%26-1);
        n /= 26;
    }
    
    if(n == 1) s = "a" + s;
    cout << s;*/
    cin >> n;
    v.resize(n);
    x = 0;
    for(i = 0; i < n; i++) {
        cin >> v[i];
        x ^= v[i];
    }
    for(i = 0; i < n; i++) {
        cout << (x^v[i]) << " ";
    }
    cout << endl;
    return 0;
}

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

int main(){
  int a;
  cin>>a;
  if(a%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  string s;
  cin>>s;
  for(int i=0;i<a/2;i++){
    if(s.at(i)!=s.at(a/2+i)){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

Measured memory_bytes: 3548
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
     
    count = 0
    for a in range(1, x // 3):
        for b in range(a + 1, x):
            c = x - a - b
            if b < c <= n:
                count += 1
    print(count)
    



Measured memory_bytes: 5596
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64
    }
    println!("ABC{}", n);
}

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

int main()
{
	int H, W;
	while (cin >> H >> W, H || W) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << (((i + j) & 1) ? '.' : '#');
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inf 99999999
using namespace std;

int e,m;

int main(){
  int i,j,k,max;
  bool ch=0;
  while(1){
    cin >> e;
    if(e==0)break;
    m = inf;
    ch=0;
    max = sqrt(e);
    for(i=max;i>=0;i--)for(j=max;j>=0;j--)if(!ch){
	  int x = i*i*i+j*j;
	  if(x<=e){
	    if(i+j+e-x<m)m = i+j+e-x;
	  }
	}
    cout << m << endl;
  }
  return 0;
}



Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long x = Long.parseLong(sc.next());
		long k = Long.parseLong(sc.next());
		long d = Long.parseLong(sc.next());
		
		if(x < 0) {
			x *= -1;
		}
		long p = x/d;
		if(p == 0) {
			long m = d-x;
			k--;
			if(k % 2 ==0) {
				System.out.println(m);
			}
			else {
				System.out.println(d-m);
			}
			return;
		}
		
		if(p >= k) {
			System.out.println(x-d*k);
			return ;
		}
		
		long l;
		
		if(Math.abs(x - d*(p+1)) <= x-d*p) {
			k -= p+1;
			l = Math.abs(x-d*(p+1));
		}
		else {
			k -= p;
			l = x-d*p;
		}
		
		if(k % 2 == 0) {
			System.out.println(l);
		}
		else {
			System.out.println(d-l);
		}
		
		}
			
}

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

using namespace std;

int main(){
    int n, sum;
    double avg,a2,a;
    while(cin >> n) {
        if(n == 0) break;
        
        sum = 0;
        avg = 0.0;
        a2 = 0.0;
        
        int s[n];
        int sum = 0;
        rep(i,n) {
            cin >> s[i];
            sum += s[i];
        }
        
        avg = (double)sum / n;
        
        rep(i,n) {
            a2 += ((s[i]-avg) * (s[i]-avg)) / n;
        }
        
        cout << fixed << setprecision(8) << sqrt(a2) << endl;
    }
}


Measured memory_bytes: 3224
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

ll freq[2019];
char s[200010];
ll m[200010];

int main() {
    ios_base::sync_with_stdio(false);
    scanf("%s", s);
    int n = strlen(s);
    m[0] = 1;
    for(int i = 1; i <= 200000; i++) {
        m[i] = (m[i-1] * 10) % 2019;
    }
    ll ans = 0;
    ll acum = s[n-1] - '0';
    freq[acum]++;
    freq[0]++;
    for(int i = n-2; i >= 0; i--) {
        acum = ((s[i] - '0') * m[n-i-1] + acum) % 2019;
        if(i < n-3)
            ans += freq[acum];
        freq[acum]++;
        //cout << "acum: " << acum << endl;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 5512
// AOJ 0181
#include <iostream>

const int kMaxWidth = 1500000;
const int kMaxBooks = 100;

int thickness[kMaxBooks];
int m, n;

bool canPlace(int width) {
	int k = 0;
	int filled = 0;
	for (int i = 0; i < n; i++) {
		if (thickness[i] > width) return false;
		if (filled + thickness[i] > width) {
			if (++k >= m) return false;
			filled = 0;
		}
		filled += thickness[i];
	}
	return true;
}

int solve() {
	int left = 0, right = kMaxWidth;
	while (right - left > 1) {
		int mid = (left + right) / 2;
		if (canPlace(mid)) right = mid;
		else left = mid;
	}
	return right;
}

int main() {
	while (1) {
		std::cin >> m >> n;
		if (m == 0) break;
		for (int i = 0; i < n; i++)
			std::cin >> thickness[i];
		std::cout << solve() << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160