akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long N;
    cin >> N;
    long long sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 3==0 || i % 5==0||(i % 3==0 && i % 5==0))
        { /* code */
        }
        else
        {
            sum += i;
        }
    }
cout << sum <<endl;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

import os
import sys
import math
import numpy as np


def main():
    a, b, c, k = list(map(int, input().split()))

    ans = a - b

    if k % 2 == 1:
        ans *= -1

    if abs(ans) > 10**18:
        print('Unfair')
    else:
        print(ans)

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

class Combination {
	vector<int64_t> fact, rfact;
	size_t SIZE;
	int64_t MOD;

public:
	Combination(size_t sz, int64_t mod) : SIZE(sz), MOD(mod) {
		fact.assign(SIZE + 1, 0);
		rfact.assign(SIZE + 1, 0);
		fact[0] = 1;
		for (int i = 1; i <= SIZE; ++i) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		rfact[SIZE] = inv(fact[SIZE]);
		for (int i = SIZE - 1; i >= 0; --i) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}
	int64_t inv(int64_t x) const{
		return Pow(x, MOD - 2);
	}
	int64_t Pow(int64_t x, int64_t n) const {
		int64_t ret = 1;
		while (n > 0) {
			if (n & 1) { (ret *= x) %= MOD; }
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	}
	int64_t P(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact[n] * rfact[n - r] % MOD;
	}
	int64_t C(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact[n] * rfact[r] % MOD * rfact[n - r] % MOD;
	}
	int64_t H(int n, int r) const {
		if (n < 0 || r < 0) { return 0; }
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};

int main() {
	const Int MOD = 1e9 + 7;
	Int N, K;
	cin >> N >> K;
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	Combination cb(100000, MOD);

	vector<Int> memo(N, -1);
	memo[0] = cb.P(K, g[0].size() + 1);
	deque<int> que;
	for (auto v : g[0]) { que.push_back(v); }
	while (!que.empty()) {
		int v = que.front();
		que.pop_front();
		memo[v] = cb.P(K - 2, g[v].size() - 1);
		for (auto u : g[v]) {
			if (memo[u] < 0) { que.push_back(u); }
		}
	}
	Int res = 1;
	for (auto v : memo) { (res *= v) %= MOD; }
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 8824
#include<stdio.h>
#include<math.h>
double x[1003], y[1003], r[1003];
double f(int i, int j)
{
	if (r[i] + r[j] > sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2)))
		return 0.0;
	else
		return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2)) - r[i] - r[j];
}
double min[1003];
int h[1000006], l;
int comp_h(int a, int b)
{
	if (min[h[a]] > min[h[b]])
		return 1;
	else
		return -1;
}
void swap_h(int a, int b)
{
	int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
void push(int ne)
{
	h[l] = ne;
	int p = l;
	l++;
	for (; p > 0; p = (p - 1) / 2)
		if (comp_h((p - 1) / 2, p) > 0)
			swap_h((p - 1) / 2, p);
	return;
}
int pop()
{
	l--;
	swap_h(0, l);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2) > 0)
			{
				if (comp_h(p, 2 * p + 2) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[l];
}
int main()
{
	double xs, ys, xt, yt;
	scanf("%lf %lf %lf %lf", &xs, &ys, &xt, &yt);
	int n;
	scanf("%d", &n);
	int i, j;
	for (i = 0; i < n; i++)
		scanf("%lf %lf %lf", &x[i + 1], &y[i + 1], &r[i + 1]);
	x[0] = xs;
	y[0] = ys;
	r[0] = 0;
	x[n + 1] = xt;
	y[n + 1] = yt;
	r[n + 1] = 0;
	for (i = 0; i < n + 2; i++)
		min[i] = 10000000000000;
	int used[1003];
	for (i = 0; i < n + 2; i++)
		used[i] = 0;
	l = 0;
	min[0] = 0;
	push(0);
	while (l > 0)
	{
		i = pop();
		if (used[i] > 0)
			continue;
		used[i]++;
		for (j = 0; j < n + 2; j++)
		{
			if (min[j] > min[i] + f(i, j))
			{
				min[j] = min[i] + f(i, j);
				if (used[j] == 0)
					push(j);
			}
		}
	}
	printf("%.20lf\n", min[n + 1]);
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int M=1000000007;
signed main(){
  int N;
  cin>>N;
  vector<vector<int>> A(N,vector<int>(0));
  for(int i=0;i<N-1;i++){
    int n,m;
    cin>>n>>m;
    A[n-1].push_back(m-1);
    A[m-1].push_back(n-1);
  }
  int ans=0,k=0,l=0;
  vector<int> B(500);
  for(int j=0;j<N;j++){
    k+=j+1;
    for(int n:A[j])
      if(n<j)
        l+=n+1;
    ans+=k-l;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15824
// ABC146B2.cpp
//#include "pch.h"
#include <iostream>
#include <string> // 文字列を使う
using namespace std;
int main()
{
	int N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < S.length(); i++)// 文字列の頭から最後まで
	{
		int num = (int)S.at(i); // 文字のコードを調べる
		if (num+N>90)
		{
			num = num - 26;	// Nを加えたものを出力したいが、
							// Zを超えた場合は、Aからにする
							// アルファベットは26種類だから
							// 26を引いた
		}
		printf("%c", num + N);
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <string>
#define MOD 998244353
#define SIZE 500005

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

ll inv[SIZE],fac[SIZE],finv[SIZE];
void init()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll Ct(int a,int b)
{
	if(a==b) return 1;
	if(a<b) return 0;
	if(b<0) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
char sA[SIZE],sB[SIZE],sC[SIZE],sD[SIZE];
ll left[SIZE],now[SIZE];

ll solve(string A,string B,string C,string D)
{
	int s=0,t=0;
	for(int i=0;i<C.size();i++)
	{
		s+=C[i]-'0';
		t+=D[i]-'0';
	}s--,t--;
	int sum=0;
	for(int i=0;i<A.size();i++)
	{
		left[i]=0;
		if(A[i]=='1')
		{
			left[i]+=Ct(sum+s,s);
			if(left[i]>=MOD) left[i]-=MOD;
		}
		if(B[i]=='1')
		{
			left[i]+=Ct(sum+s,s);
			if(left[i]>=MOD) left[i]-=MOD;
		}
		now[i]=left[i];
		if(i>0)
		{
			if(A[i]=='1'&&B[i]=='1')
			{
				left[i]+=left[i-1]*2LL;
				left[i]%=MOD;
			}
			else
			{
				left[i]+=left[i-1];
				left[i]%=MOD;
			}
		}
		sum+=A[i]-'0';
		sum+=B[i]-'0';
	}
	sum=0;
	ll ret=0;
	for(int i=A.size()-1;i>=0;i--)
	{
		ret+=now[i]*Ct(sum+t,t)%MOD;
		if(ret>=MOD) ret-=MOD;
		if(A[i]=='1'&&i>0)
		{
			ret+=left[i-1]*Ct(sum+t,t)%MOD;
			if(ret>=MOD) ret-=MOD;
		}
		if(B[i]=='1'&&i>0)
		{
			ret+=left[i-1]*Ct(sum+t,t)%MOD;
			if(ret>=MOD) ret-=MOD;
		}
		sum+=A[i]-'0';
		sum+=B[i]-'0';
	}
	return ret;
}
int main()
{
	init();
	int n,m;
	scanf("%d %d",&n,&m);
	scanf("%s",&sA);
	scanf("%s",&sB);
	scanf("%s",&sC);
	scanf("%s",&sD);
	string A=sA;
	string B=sB;
	string C=sC;
	string D=sD;
	bool up=true;
	for(int i=0;i<A.size();i++) if(A[i]=='1') up=false;
	for(int i=0;i<B.size();i++) if(B[i]=='1') up=false;
	for(int i=0;i<C.size();i++) if(C[i]=='1') up=false;
	for(int i=0;i<D.size();i++) if(D[i]=='1') up=false;
	if(up)
	{
		puts("1");
		return 0;
	}
	//printf("%lld %lld\n",solve(A,B,C,D),solve(C,D,A,B));
	ll ret=solve(A,B,C,D)+solve(C,D,A,B);
	if(ret>=MOD) ret-=MOD;
	printf("%lld\n",ret);
	return 0;
}


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


int main(){
   string s;
   cin>>s;
   string a;
   a=s.substr(0,3);
   cout<<a<<endl;
}

Measured memory_bytes: 3600
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        p = 4*h*n - N*h - N*n
        if p <= 0:
            continue
        else:
            if (h*n) % p == 0:
                print(str(h) + " " + str(n) + " " + str((N*h*n)//p))
                exit()

Measured memory_bytes: 40428
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
	ll x;
	cin >> x;
	if (1200 > x)
	{
		cout << "ABC" << endl;
	}
	else
	{
		cout << "ARC" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll n,k;
ll C[1000010],C2[1000010];
ll ksm(ll a,ll b){
    ll res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return res;
}
void init(int n){
    ll ck = 1; C[0] = 1;
    for(ll k = 1;k<=n;k++){
        ck = ck*(n-k+1)%mod*ksm(k,mod-2)%mod;
        C[k] = ck;
    }
    //for(int i = 0;i<=n;i++) cout<<C[i]<<" ";cout<<endl;
    ck = 1,C2[0] = 1;
    n--;
    for(ll k = 1;k<=n;k++){
        ck = ck*(n-k+1)%mod*ksm(k,mod-2)%mod;
        C2[k] = ck;
    }

}
int main(){
    cin>>n>>k;
    init(n);
    ll res = 0;
    for(ll i = 0;i<=min(n-1,k);i++){
        res = (res + C[i] * C2[n-i-1]%mod)%mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 5888
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  ld r1, r2;
  cin >> r1 >> r2;
  cout << 1 / (1 / r1 + 1 / r2) << endl;
  return;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vector<int> vi
#define vector<pii> vpii
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	ll ans=n*(n-1)/2+m*(m-1)/2;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

import datetime
chk = datetime.datetime.strptime("2019/5/1","%Y/%m/%d")
s   = datetime.datetime.strptime(input(),"%Y/%m/%d")
if s<chk:
    print("Heisei")
else:
    print("TBD")

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

using namespace std;

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

  int n, d, x, a;
  cin >> n >> d >> x;
  int res = 0, t;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    t = 1;
    res++;
    while (t*a +1 <= d) {
      res++;
      t++;
    }
  }
  cout << res + x << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

int n, t, tra[26];
char c, con[4] = {'S', 'H', 'C', 'D'};
bool ok[5][20];


int main() {
    tra[7] = 1, tra[2] = 2, tra[3] = 3;
    scanf("%d%c", &n, &c);
    for (int i = 0; i < n; i++) {
        scanf("%c %d", &c, &t);
        ok[tra[c - 65]][t] = 1;
        // printf("%d %d = %d\n", tra['C' - 65], t, ok[tra[c - 65]][t]);
        scanf("%c", &c);
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j <= 13; j++) {
            if (!ok[i][j]) {
                printf("%c %d\n", con[i], j);
            }
        }
    }
}


Measured memory_bytes: 2100
#include <stdio.h>

int main(void){
    int a, b, c;
    int ans = 0;
    
    scanf("%d %d %d",&a, &b, &c);

    if((a==7) && (b==5) && (c==5) || (a==5) && (b==7) && (c==5) ||(a==5) && (b==5) && (c==7)){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main()
{
	long long n,i,j,k,m,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	k=n/(a+b);
	m=n%(a+b);
	if(m>=a)m=a;
	printf("%lld",a*k+m);
}

Measured memory_bytes: 256
import sys,collections; input = lambda : sys.stdin.readline()
exec("try:sys.stdin=pen('input.txt','r')\nexcept:pass")
n = int(input())
ans = [0]*100005
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i**2+j**2+k**2+i*j+j*k+k*i
            if v < 100005:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])


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

int main(void) {
    char taro[101]={'\0'}, hanako[101]={'\0'};
    int i, n, t=0, h=0;

    scanf("%d", &n);
    while (n>0) {
        scanf("%s %s", taro, hanako);
        i=0;
        if (strcmp(taro, hanako)==0) {
            t++, h++;
        } else {
            for (i=0; taro[i]!='\0' || hanako[i]!='\0'; i++) {
                if (taro[i]==hanako[i]) continue;
                if (taro[i]>hanako[i]) {
                    t+=3;
                    break;
                }
                if (taro[i]<hanako[i]) {
                    h+=3;
                    break;
                }
            }
        }
        n--;
    }
    printf("%d %d\n", t, h);
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>

using namespace std;

int main()
{
	int K, N;
	int *A, *D;

	cin >> K >> N;
	A = new int[N];
	D = new int[N];
	for (int i = 0; i < N; i++)
		cin >> A[i];

	for (int i = 0; i < N - 1; i++)
		D[i + 1] = A[i + 1] - A[i];

	if (A[0] > 0)
		D[0] = A[0] + (K - A[N - 1]);
	else if (A[0] == 0)
		D[0] = (K - A[N - 1]);

	int max_index = 0;
	for (int i = 1; i < N; i++)
		if (D[max_index] < D[i])
			max_index = i;

	int sum = 0;
	for (int i = 0; i < N; i++) {
		if (i == max_index)
			continue;
		else
			sum += D[i];
	}

	cout << sum << endl;

	delete A;
	delete D;

	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    map<ll,ll> A;
    map<ll,ll> B;
    REP(i,N){
        ll a;
        cin >> a;
        A[i+a]++;
        B[i-a]++;
    }
    ll ans = 0;
    for(auto x: A){
        ans += x.second * B[x.first];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 37796
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>
#include <queue>

constexpr long long INFLL = 1e18;

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

int main()
{

    int n;
    cin >> n;
    string s;
    cin >> s;

    int count = 0;
    int w = 0;
    int r = 0;
    for (int i = 0; i < n; i++)
    {
        if (s.at(i) == 'W')
        {
            // w++;
        }
        else
        {
            r++;
        }
    }
    count = r;

    for (int i = 1; i <= n; i++)
    {
        if (s.at(i - 1) == 'W')
        {
            w++;
        }
        else
        {
            r--;
        }
        count = min(max(w, r), count);
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3460
H,N=map(int,input().split())
magic=[list(map(int,input().split())) for _ in range(N)]
dp=[float("inf") for _ in range(H+10**4)] #dptableには、魔力の合計値が格納されてるはず
#print(magic)
for i in range(H+10**4):
    for j in range(N):
        if magic[j][0]>i:
            dp[i]=min(dp[i],magic[j][1])
        else:
            dp[i]=min(dp[i],dp[i-magic[j][0]]+magic[j][1])
        #print(dp,dp[i],magic[j][0],i,magic[j][0]<i,magic[j][1])
        #input()
print(dp[H-1])


Measured memory_bytes: 43756
#include<bits/stdc++.h>
#include <boost/lexical_cast.hpp>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n;
    cin>>n;
    lli a[n],i,sum;
    for(i=0;i<n;i++)
    cin>>a[i];
    sum=0;
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            sum=sum+(a[i]-a[i+1]);
            a[i+1]=a[i];
        }
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 5160
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto r = 0;

 loop: foreach (_; 0..n) {
    auto a = readln.chomp.to!int;

    if (a == 2) {
      ++r;
      continue;
    }

    if (a % 2 == 0)
      continue;

    foreach (i; iota(3, a.to!real.sqrt.to!int + 1))
      if (a % i == 0)
        continue loop;

    ++r;
  }


  writeln(r);
}

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

int main(){
	int n;cin>>n;
	vector<int>b(n);
	rep(i,n)cin>>b[i];
	vector<int>v;
	while(!b.empty()){
		bool ok=false;
		for(int i=b.size()-1;i>=0;i--){
			if(b[i]==i+1){
				ok=true;
				v.push_back(b[i]);
				b.erase(b.begin()+i);
				break;
			}
		}
		if(!ok){
			puts("-1");return 0;
		}
	}
	reverse(v.begin(),v.end());
	for(int i:v){
		cout<<i<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		int b =sc.nextInt();
		int c =sc.nextInt();
		if(a==b+c){
		System.out.println("Yes");
		}else if(b==a+c)System.out.println("Yes");
		else if(c==a+b)System.out.println("Yes");
		else System.out.println("No");
	}
}

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

int main() {
    string input;
    int ans = 0;

    cin >> input;

    for (int i = 0; i < input.size(); i++) {
        if (input.at(i) == '0' + 2 ) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()
#define alln(a, n) a, a+n 

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

const vi a = {2, 4, 14, 24, 74}, p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

int c[109], ret, d[109];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	ini(n);
	forn(i, 1, n+1) {
		int t = i;
		while (t != 1) {
			for(auto d : p) {
				if (t % d == 0) {
					c[d]++;
					t /= d;
				}
			}
		}
	}
	forn(i, 0, 109) for(auto j : a) if (c[i] >= j) d[j]++;
	outn(max(0, d[74]) + max(0, d[24]*(d[24]-1)) + max(0, (d[2]-d[24])*d[24]) + max(0, d[14]*(d[14]-1)) + max(0, (d[4]-d[14])*d[14]) + max(0, d[4]*(d[4]-1)*(d[4]-2)/2) + max(0, (d[2]-d[4])*d[4]*(d[4]-1)/2));
	
	return 0;
}


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

using namespace std;
const int LEN = 200005;
char s[LEN];
int a[LEN], cnt[2020];

int main() {
    cin >> s;
    int len = strlen(s);
    int p = 1;
    for (int i = len - 1; i >= 0; i--) {
        a[i] = a[i + 1] + (s[i] - '0') * p;
        a[i] %= 2019;
        p *= 10;
        p %= 2019;
    }
    int ans = 0;
    cnt[0]++;
    for (int i = 0; i < len; i++) {
        ans += cnt[a[i]];
        cnt[a[i]]++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4568
#include<iostream>

using namespace std;

int main()
{
  int h,m,s;
  long S;

  cin>>S;

  h = S/3600;
  S = S-(3600*h);

  m = S/60;
  S = S-(60*m);

  s = S;

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

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define int long long int
using namespace std;
int DP[3001][3001] = {0};
signed main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];

    for(int i=n-1;i>=0;i--)
    {
        for(int j=i;j<n;j++)
        {
            if(i==j)
            {
                DP[i][j] = a[j];
                continue;
            }
            else
            {
                DP[i][j] = max(a[i]-DP[i+1][j],a[j]-DP[i][j-1]);
            }
        }
    }
    cout<<DP[0][n-1];
    return 0;
}

Measured memory_bytes: 70016
# Problem D - Line++

# input
N, X, Y = map(int, input().split())

# initialization
INF = N
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)

# graph search
for i in range(N):
    for j in range(i+1, N):
        # グラフの更新
        kyori_graph[i][j] = min(abs(j-i), abs(X-1-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))

# 個数の数え上げ
for i in range(N):
    for j in range(i+1, N):
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1

# output
for k in kosu_list:
    print(k)


Measured memory_bytes: 79708
N = int(input())
v_str = input()
v_list_str = v_str.split(" ")
v_list_float = [0.0] * N
for i in range(N):
    v_list_float[i] = float(v_list_str[i])
#print(v_list_float)

v_list_float.sort(reverse=True)
#print(v_list_float)

ans = 0.0
for i in range(N-1):
    ans += v_list_float[i] / (2 ** (i+1))
ans += v_list_float[N-1] / (2 ** (N-1))

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define vinn(n,v) int n;cin>>n;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define vinm(n,m,v) int n,m;cin>>n>>m;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define debug(x) cerr<<#x<<" : "<<x<<endl;
mt19937 rd(time(0)); // i = rd%n
bool ch(int n)
{
    int d = n%10;
    while(n>0)
    {
        if(abs(d-n%10)>1)return 0;
        n/=10;
    }
    return 1;
}
struct compare 
{
  bool operator()(const int& l, const int& r) 
  {
      return l > r; //min: > ; max: <
  }
};
 
signed main() 
{
    fastio();
    int k;
    cin>>k;
    vector<int>nx[11];
    priority_queue<int,vector<int>,compare>pq;
    for(int i = 0;i<10;i++)
    {
        if(i-1>=0)nx[i].pb(i-1);
        if(i+1<=9)nx[i].pb(i+1);
        nx[i].pb(i);
        if(i!=0)pq.push(i);
    }

    while(!pq.empty())
    {
        int top = pq.top();
        pq.pop();
        k--;
        if(k==0){cout<<top;return 0;}
        for(auto i:nx[top%10])
        {
            pq.push(top*10+i);
        }
    }


    return 0;
}


Measured memory_bytes: 2420
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();
		final int m = sc.nextInt();

		int[][] adj = new int[n][n];

		for (int i = 0; i < m; i++) {
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			final int c = sc.nextInt();

			adj[a][b] = c;
		}
		
		
		LinkedList<Integer> queue = new LinkedList<Integer>();
		int[] times = new int[n];
		Arrays.fill(times, Integer.MIN_VALUE);
		times[0] = 0;
		
		queue.add(0);
		
		while(!queue.isEmpty()){
			int pos = queue.poll();
			
			for(int to = 0; to < n; to++){
				if(adj[pos][to] > 0){
					if(times[to] < times[pos] + adj[pos][to]){
						times[to] = times[pos] + adj[pos][to];
						queue.add(to);
					}
				}
			}
		}
		
		System.out.println(times[n-1]);

		sc.close();
	}

}

Measured memory_bytes: 25408
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define show(x) cout << x << '\n'
#define showh(x) cout << x << ' '
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
auto t1 = chrono::high_resolution_clock::now();
bool prime[100001];
ll expo(ll a, ll b)
{
    a = a % mod;
    b = b % mod;
    if (b == 0)
        return 1;
    if (b % 2)
        return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
    return expo((a * a) % mod, b >> 1) % mod;
}
ll mul(ll a, ll b)
{
    a = a % mod;
    b = b % mod;
    if (b == 0)
        return 0;
    if (b % 2)
        return ((a % mod) + (mul((a + a) % mod, b / 2) % mod)) % mod;
    return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
    return x && !(x & (x - 1));
}
ll xorcal(ll n)
{
    if (n % 4 == 0)
        return n;
    if (n % 4 == 1)
        return 1;
    if (n % 4 == 2)
        return n + 1;
    if (n % 4 == 3)
        return 0;
}
void sieve(ll n)
{
    memset(prime, true, sizeof(prime));
    prime[0] = false;
    prime[1] = false;
    for (ll i = 2; i * i <= n; i++)
    {
        if (prime[i] == true)
        {
            for (ll j = i * i; j <= n; j += i)
                prime[j] = false;
        }
    }
}
bool isprime(ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 or n % 3 == 0)
        return false;

    for (ll i = 5; i * i <= n; i += 6)
    {
        if (n % i == 0 or n % (i + 2) == 0)
            return false;
    }
    return true;
}

ll modinverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m;
        a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return (b % a, a);
}
bool ispalindrome(string s)
{
    string t = s;
    reverse(t.begin(), t.end());
    if (t == s)
        return true;
    return false;
}
void binary(ll a[], ll n)
{
    gor(i, 0, 64)
    {
        ll k = n >> i;
        a[i] = k & (ll)1;
    }
}
ll countBits(ll n)
{
    if (n == 0)
        return 0;
    return 1 + countBits(n & (n - 1));
}
ld maxvolume(ld s)
{
    // finding length
    ld length = s / 3;

    s -= length;

    // finding breadth
    ld breadth = s / 2;

    // finding height
    ld height = s - breadth;

    return length * breadth * height;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ld l;
    cin >> l;
    cout << fixed << setprecision(20) << maxvolume(l) << endl;
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}

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

using namespace std;

const int mod = 1000000007;

int main() {
  string s; cin >> s;
  // dp[i][x] := i文字までみたとき,
  // dp[i][0]: Aが何個あるか?
  // dp[i][1]: ABが何個あるか?
  // dp[i][2]: ABCが何個あるか?
  vector<vector<long long>> dp(s.length()+10, vector<long long>(3, 0));
  // mul: 現時点で文字列として考えられる種類. "?" が出現するたび3倍される
  long long mul = 1;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'A') {
      dp[i+1][0] = dp[i][0] + mul;
      dp[i+1][1] = dp[i][1];
      dp[i+1][2] = dp[i][2];
    }
    if (s[i] == 'B') {
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1] + dp[i][0];
      dp[i+1][2] = dp[i][2];
    }
    if (s[i] == 'C') {
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1];
      dp[i+1][2] = dp[i][2] + dp[i][1];
    }
    if (s[i] == '?') {
      // ?のときは, 3つの構成可能文字列に分岐するので, 3倍する
      dp[i+1][0] = dp[i][0] * 3 + mul;
      dp[i+1][1] = dp[i][1] * 3 + dp[i][0];
      dp[i+1][2] = dp[i][2] * 3 + dp[i][1];
      mul = (mul * 3) % mod;
    }
    dp[i+1][0] %= mod;
    dp[i+1][1] %= mod;
    dp[i+1][2] %= mod;
  }
  cout << dp[s.length()][2] << endl;
  return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 3624
N, M = map(int, input().split())
k = []
s = []
for i in range(M):
    a = list(map(int, input().split()))
    k.append(a[0])
    s.append(a[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    ri_count = 0
    for j in range(M):
        sw_count = 0
        for l in range(k[j]):
            if i>>(s[j][l]-1) & 1:
                sw_count += 1
        if sw_count%2 == p[j]:
            ri_count += 1
    if ri_count == M:
        ans += 1
print(ans)


Measured memory_bytes: 9164
from fractions import gcd

n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
b=a[0]
for i in range(1,n):
  b=gcd(b,a[i])

if c > a[n-1]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if c % b==0 else "IMPOSSIBLE")
  

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

int main(){
    long long n,k;
    cin>>n>>k;
    long long a,b;
    a=n%k;
    b=k-a;
    cout<<min(a,b)<<endl;
}

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

signed main(void){
    
    long long N;
    string a;
    vector<string> A;
    
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a;
        A.push_back(a);
    }
    
    long long D[60][40]={};
    
    for(int i=0;i<A.size();i++){
        //まずは分子の整数Bと分母の指数kに分けていく
        long long B=0,k=0;
        for(int j=0;j<A[i].size();j++){
            if(A[i][j]=='.')continue;
            B*=10;
            B+=A[i][j]-'0';
        }
        for(int j=0;j<A[i].size();j++){
            if(A[i][j]=='.'){
                k=A[i].size() - j - 1;
            }
        }
        //次にBに2と5がいくつ含まれるかを求める
        long long t=0,f=0;
        long long b=B;
        while(b%2==0){
            t++;
            b/=2;
        }
        b=B;
        while(b%5==0){
            f++;
            b/=5;
        }
        
        //D[t-k][f-k]をインクリメントする
        //…と言いたいところだがマイナスになりうるので+10したものを入れる
        D[t-k+10][f-k+10]++;
        
        
    }
    
    long long Ans=0;
    
    for(int i=0;i<55;i++){
        for(int j=0;j<30;j++){
            for(int k=0;k<55;k++){
                for(int l=0;l<30;l++){
                    if(i+k-20>=0 && j+l-20>=0 && !(i==k && j==l)){
                        //(hoge*2^i*5^j)*(fuga*2^k*5^l)がOKならAnsに足し入れる
                        Ans+=D[i][j]*D[k][l];
                        
                    }
                }
            }
        }
    }
    //D[i][j]*D[k][l]とD[i][l]*D[i][j]で同じものを２回かけているので2で割っておく
    Ans/=2;
    
    //違うA_iでも同じt-k,f-kを持つことはある
    //ので、それを処理する
    for(int i=0;i<55;i++){
        for(int j=0;j<30;j++){
            if(i-10>=0 && j-10>=0){
                Ans += D[i][j]*(D[i][j]-1)/2;
            }
        }
    }
    
    cout << Ans << endl;
    
    return 0;
}


Measured memory_bytes: 11576
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            #define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli i,t,n,m,k;
                string s;
                cin>>s;
                if(s=="Sunny"){
                    cout<<"Cloudy"<<endl;
                }
                else if(s=="Cloudy"){
                    cout<<"Rainy"<<endl;
                }
                else{
                    cout<<"Sunny"<<endl;
                }

                return 0;
            }
















Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

U = 10 ** 6
K,X = map(int,input().split())

L = X - K + 1
R = X + K - 1
L = max(L,-U)
R = min(R,U)

print(*range(L,R+1))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int N,cnt=0,max=-1;
  cin >> N;
  long H,prev = 0;
  for(int i=0;i<N;i++){
    cin >> H;
    if(prev>=H)cnt++;
    else {
      if(cnt > max)max=cnt;
      cnt=0;
    }
    prev = H;
  }
  if(cnt > max)max=cnt;
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        int h,a,k;
        k=0;
        Scanner sc=new Scanner(System.in);
        h=sc.nextInt();
        a=sc.nextInt();
        for(int i=1;h>0;i++){
            h=h-a;
            k=i;
        }
        System.out.println(k);
    }
}

Measured memory_bytes: 35672
#include <stdio.h>
#include <stdlib.h>

int main(){
  int x,n,k,i;
  int p[100];
  int m = scanf("%d %d\n",&x ,&n);
  for(i=1; i <= n; i++){
  	int l = scanf("%d ",&p[i]);
  }
  if (1 <= x <= 100 || 0 <= n <= 100){
    int Answer = x;
    int Answer2 = x;
	for(k=1; k <= n; k++){
      for(i=1; i <= n; i++){
        if((p[i] - x) == ( Answer - x )){
          Answer -= 1;
        }
      }
      for(i=1; i <= n; i++){
         if((p[i] - x) == ( Answer2 - x )){
           Answer2 += 1;
       	 }
       }
     }
    //printf("%d",Answer);
      if(abs( Answer - x ) > abs( Answer2 - x )){
        printf("%d",Answer2);
       }else{
        printf("%d",Answer);
       }   
  }else{
  	printf("error");
  } 
  
return 0;
}

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

int n;
int es[3];

int main() {
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    for (int j=0; j<3; j++) {
      scanf("%d", &es[j]);
    }

    sort(es, es+3);
    if (es[0]*es[0] + es[1]*es[1] == es[2]*es[2]) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
}

Measured memory_bytes: 2500
n = int(input())

if n % 2 == 0:
    print(int(n * (n - 2) / 2))
    for i in range(1, n):
        for j in range(i, n + 1):
            if i + j != n + 1 and i != j:
                print(str(i) + " " + str(j))

else:
    print(int((n - 1) * (n - 1) / 2))
    for i in range(1, n-1):
        for j in range(i, n):
            if i + j != n and i != j:
                print(str(i) + " " + str(j))
    for k in range(1, n):
        print(str(k) + " " + str(n))

Measured memory_bytes: 3336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int d,g;
    cin >> d >> g;
    vector<pair<long long int, long long int>> v(d);
    REP(i,d){
        cin >> v[i].first >> v[i].second;
    }
    long long int hanpa_where=0,score,num,result=linf;

    DEFOR(i,(long long int)pow(2ll,d),0){
        score = 0;
        num = 0;
        REP(j,d){
            if((((long long int)(pow(2,j)))&i)==0){
                hanpa_where = j;
            }else{
                score += (v[j].second) + 100*(j + 1) * v[j].first;
                num += v[j].first;
            }
        }
        if(g-score>0){
            if(((((g-score)+(hanpa_where+1)*100)-1))/((hanpa_where+1)*100)<=v[hanpa_where].first){
                num += ((((g - score) + (hanpa_where + 1) * 100) - 1)) / ((hanpa_where + 1) * 100);
                result = min(result, num);
            }

        }else{
            result = min(result, num);
        }
        

    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PA;
const int MOD = 1000000007;
const ll INF=2e18;

ll N,M;
ll a,b,c;
string s;
int main(){
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));
    return 0;
}


Measured memory_bytes: 764
n, k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()
ans = 0
get_point = {}
get_point["r"] = p
get_point["s"] = r
get_point["p"] = s
string = [[] for i in range(k)]
for i in range(n):
    string[i%k].append(t[i])
for i in range(len(string)):
    dp = [[0 for q in range(3)] for z in range(len(string[i]))]
    if string[i][0] == "r":
        dp[0][2] = get_point[string[i][0]]
    elif string[i][0] == "s":
        dp[0][0] = get_point[string[i][0]]
    else:
        dp[0][1] = get_point[string[i][0]]
    for j in range(1,len(string[i])):
        if string[i][j] == "r":
            dp[j][0] = max(dp[j-1][1], dp[j-1][2])
            dp[j][1] = max(dp[j-1][0], dp[j-1][2]) 
            dp[j][2] = max(dp[j-1][0], dp[j-1][1]) + get_point[string[i][j]]
        elif string[i][j] == "s":
            dp[j][0] = max(dp[j-1][1], dp[j-1][2]) + get_point[string[i][j]]
            dp[j][1] = max(dp[j-1][0], dp[j-1][2]) 
            dp[j][2] = max(dp[j-1][0], dp[j-1][1]) 
        else:
            dp[j][0] = max(dp[j-1][1], dp[j-1][2])
            dp[j][1] = max(dp[j-1][0], dp[j-1][2]) + get_point[string[i][j]]
            dp[j][2] = max(dp[j-1][0], dp[j-1][1])
    ans += max(dp[-1])
print(ans)
        

        






Measured memory_bytes: 18724
import java.util.*;
public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        //String s = sc.next();
        //Long x = sc.nextLong();

        if(a>9 || b>9){
            System.out.println(-1);
            return;
        }

        System.out.println(a*b);
    }
}


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

#define ll long long

int main(){
    ll N,ans = 0;
    cin >> N;
    for(ll i = 1;i < N/i - 1;i++){
        if(N%i == 0)ans += N/i - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


void solve(){
    string str;
    cin>>str;
    
    int one=0,two=0;
    for(char ch:str){
        if(ch=='1'){
            one++;
        }
        else{
            two++;
        }
    }
    cout<<2*min(one,two)<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

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

int main() {
  int n,y;
  cin>>n>>y;
  int u_a=y/10000;
  int u_b=y/5000;
  int l=-1;
  int m=-1;
  int p=-1;
  for(int a=0;a<=u_a;a++){
    for(int b=0;b<=u_b;b++){
      int c=y-10000*a-5000*b;
      if(c<0) break;
      c/=1000;
      if(a+b+c==n){
        l=a;
        m=b;
        p=c;
        break;
      }
    }
  }
  cout<<l<<" "<<m<<" "<<p<<endl;
}

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

int main()
{
    int X;
    int b;
    int p;
    int max;
    int ans;

    scanf("%d", &X);

    max = 1;
    for(b = 2; b <= X; b++) {
        for(p = 2; ; p++) {
            ans = pow(b, p);
            if(ans > X) {
                break;
            }
            if(ans > max) {
                max = ans;
            }
        }
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 512
int main() {
    
    int m, f, r; 
     
    
    while (1) {
        scanf("%d %d %d", &m, &f, &r);
         
        if (m == -1 && f == -1 && r == -1) { 
            break;
        }
         
        if (m == -1 || f == -1) {
            printf("F\n");
        }else if (m+f >= 80) {
            printf("A\n");
        }else if (m+f >= 65) {
                printf("B\n");
        }else if (m+f >= 50) {
                printf("C\n");
        }else if (m+f >= 30) {
            if (r >= 50) {
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n");
        }
    }
     
     
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

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

    vector<int> left(N+1, 0), right(N+1, 0);
    for(int i=0; i<N; i++) left[i+1] = gcd(left[i], a[i]);
    for(int i=N-1; i >= 0; i--) right[i] = gcd(right[i+1], a[i]);

    int ans = 0;
    for(int i=0; i < N; i++) {
        int l = left[i];
        int r = right[i+1];
        ans = max(ans, gcd(l, r));
    }

    cout << ans << endl;
}



Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	a := intScanner()
	b := intScanner()
	fmt.Println(larger((b*(n-1)+a)-(a*(n-1)+b)+1, 0))
}
func larger(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    long long ans = 0;
    for (int i = n-1; i >= 0; i--) {
        a[i] += ans;
        if (a[i] % b[i] != 0) {
            int x = b[i] - (a[i] % b[i]);
            ans += x;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int N,j=0;
  float total;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N-1;i++){
    j++;
    if(i == 0){
      total = (vec.at(0) + vec.at(1)) / 2.0;
    }else{
      total = (total + vec.at(j)) / 2.0;
    }
  }
  cout << total << endl;
}


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

int main() {
	int N;
	int A[200001] = { 0 };
	int memo[200001] = { 0 };
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		cin >> A[i];
		memo[A[i]]++;
	}

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

}

Measured memory_bytes: 5196
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main(){
    int x;
    std::cin >> x;
    
    int b, p, val;
    std::vector<int> vec;
    if(1 == x){
        std::cout << 1 << std::endl;
    }else{
        for(b = 2;; ++b){
            p = 2;
            val = std::pow(b, p);
            if(val > x){
                break;
            }else{
                while(val <= x){
                    vec.push_back(val);
                    ++p;
                    val = std::pow(b, p);
                }
            }
        }

        std::cout << *max_element(vec.begin(), vec.end()) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){ cin >> a.at(i); }

    vector<vector<bool>> dp(n, vector<bool>(2001, false));
    for(ll i = n - 1; i >= 0; i--){
        dp.at(i).at(0) = true;
        for(ll j = 1; j < dp.at(i).size(); ++j){
            bool tmp = false;
            if(i + 1 < n){
                tmp = tmp || dp.at(i + 1).at(j);
                if(j >= a.at(i)){
                    tmp = tmp || dp.at(i + 1).at(j - a.at(i));
                }
            }else{
                tmp = tmp || (j == a.at(i));
            }
            dp.at(i).at(j) = tmp;
        }
    }

    ll q;
    cin >> q;
    REP(i, q){
        ll m;
        cin >> m;
        if(dp.at(0).at(m)){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    int64_t A, B, C;

    scanf("%"PRId64"%"PRId64"%"PRId64, &A, &B, &C);

    if (A == B && B == C) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 128