akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main (void){
    int N, A;
    cin >> N >> A;

    vector<int> x(N);

    for (int i = 0; i < N; i++){
        cin >> x.at(i);
        x[i] -= A;
    }

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

    int X = 2 * N * max(A, x[N-1]-A);

    long long dp[N][X];

    for (int j = 0; j < X; j++){
        if (j == x[0] + X/2){
            dp[0][j] = 1;
        }
        else{
            dp[0][j] = 0;
        }
    }

    dp[0][X/2] += 1;

    for (int i = 1; i < N; i++){
        for (int j = 0; j < X; j++){
                dp[i][j] = dp[i-1][j];
            }
        for (int j = 0; j < X; j++){
            for (int k = 0; k < X; k++){
                if (k + x[i] == j){
                    dp[i][j] += dp[i-1][k];
                }
            }
        }
    }

    cout << dp[N-1][X/2] - 1 << endl;

	return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
    string S;
    cin >> S;
    int result=0;
    for (int i = 0;i<4;i++){
        if (S[i] == '+'){
            result++;
        } else {
            result--;
        }
    }

    cout << result << endl;

}

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

int main(){
  int N, D, X;
  cin >> N >> D >> X;
  int ans=X;
  for(int i=0; i<N; i++){
    int A;
    cin >> A;
    ans+= (D+A-1)/A;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    int n, y; cin >> n >> y;

    bool isvalid = false;
    reps(i, 0, n+1){
        reps(j, i, n+1){
            int n1 = i, n2 = j-i, n3 = n-j;

            int sum = 10000*n1 + 5000*n2 + 1000*n3;
            if(sum == y){
                isvalid = true;
                cout << n1 << " " << n2 << " " << n3 << endl;
                break;
            }
        }
        if(isvalid) break;
    }

    if(!isvalid){
        cout << -1 << " " << -1 << " " << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 384
MOD = 10**9 + 7

H, W, K = map(int, input().split())

fibs = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
def getFib(i):
    return fibs[i+2]

numLs, numCs, numRs = [0]*W, [0]*W, [0]*W
for j in range(W):
    numCs[j] = getFib(j-1) * getFib(W-1-j-1)
    numLs[j] = getFib(j-2) * getFib(W-1-j-1)
    numRs[j] = getFib(j-1) * getFib(W-1-j-2)

dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        dp[i+1][j] += dp[i][j] * numCs[j]
        if j > 0:
            dp[i+1][j-1] += dp[i][j] * numLs[j]
        if j < W-1:
            dp[i+1][j+1] += dp[i][j] * numRs[j]
    for j in range(W):
        dp[i+1][j] %= MOD

print(dp[H][K-1])


Measured memory_bytes: 3064
import collections
from collections import deque
def tree(s):

    INF=-10**9
    dis = [INF for i in range(n)]
    ans = [INF for i in range(n)]
    dis[s]=0
    def bfs():
        d = deque()
        d.append(s)

        while len(d):
            x = d.popleft()
            cnt=1

            for i in range(len(b[x])):
                y=b[x][i]
                if dis[y] == INF:
                    d.append(y)
                    dis[y]=dis[x]+1
                    if ans[x]!=cnt:
                        ans[y]=cnt
                        cnt+=1
                    else:
                        cnt+=1
                        ans[y]=cnt
                        cnt+=1

        return ans
    return bfs()

n=int(input())
a = [list(map(int, input().split())) for i in range(n-1)]
b = [[] for i in range(n)]

for i in range(n-1):
    b[a[i][0]-1].append(a[i][1]-1)

x=tree(0)
print(max(x))
for i in range(n-1):
    print(x[a[i][1]-1])

Measured memory_bytes: 82520
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define debug(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define debug(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;
using Graph = vector<vector<int>>;

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

#define P (1'000'000'007)

class UnionFind {
public:
    UnionFind(int n) {
        for (int i = 0; i < n; i++) {
            _parent.push_back(i);
            _size.push_back(1);
        }
    }

    int find(int index) {
        if (is_root(index)) return index;
        return _parent[index] = find(_parent[index]);
    }

    bool is_root(int index) {
        return _parent[index] == index;
    }

    bool has_same_root(int lhs, int rhs) {
        return find(lhs) == find(rhs);
    }

    void unite(int lhs, int rhs) {
        int l = find(lhs);
        int r = find(rhs);
        if (has_same_root(l, r)) return;
        _size[l] += _size[r];
        _parent[r] = l;
    }

    int size(int index) {
        return _size[find(index)];
    }

private:
    vector<int> _parent;
    vector<int> _size;
};

signed main() {
    int n, m;
    cin >> n >> m;

    UnionFind uf(n);

    int ans = 1;

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;

        uf.unite(a, b);
        chmax(ans, uf.size(a));
    }

    cout << ans;
    
    return 0;
}


Measured memory_bytes: 6324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int a,int b){
	if(a<b) return gcd(b,a);
	int r;
	while(r=a%b){
		a=b;
		b=r;
	}
	return b;
}
int main(){
	ll n,m;cin>>n>>m;
	string s,t;cin>>s>>t;
	ll l=n*m/gcd(n,m);

	ll a=l/n,b=l/m;//aはlの中のsの間隔、bはtの間隔。l[i+a]==s[j+1],l[i]==s[j]
	ll lt=a*b/gcd(a,b);//a,bのlcm,aとbが同じl[i]のiを指すところ.l[lt*i]==s[aa*o]==t[bb*o]
	int cnt=l/lt;
	ll aa=lt/a,bb=lt/b;

	//cout<<a<<" "<<b<<" "<<lt<<" "<<cnt<<"\n";
	for(ll i=0;i<cnt;i++){
		if(s[i*aa]!=t[i*bb]) {
			cout<<-1<<"\n";
			return 0;
		}
	}
	cout<<l<<"\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int long long
signed main() {
	ll ans=999999999999999, h, w;
	cin >> h >> w;
	for (ll i = 1; i < h; i++) {
		ans = min(ans, max(i*w, (h-i)*(ll)ceil(w / 2.0)) - min(i*w, (ll)floor(w / 2.0)*(h-i)));
		ans = min(ans, max(i*w, (ll)ceil((h - i) / 2.0)*w) - min(i*w, (ll)floor((h - i) / 2.0)*w));
	}
	for (int i = 1; i < w; i++) {
		ans = min(ans, max(i*h, (w - i)*(ll)ceil(h / 2.0)) - min(i*h, (ll)floor(h / 2.0)*(w - i)));
		ans = min(ans, max(i*h, (ll)ceil((w - i) / 2.0)*h) - min(i*h, (ll)floor((w - i) / 2.0)*h));
	}
	cout << ans << endl;
	getchar(); getchar();
}

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

using namespace std;

using l = long;
using ll = long long;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using pii = vector<pair<int, int>>;

int main()
{
	ll tmp, a, b, c; cin >> a >> b >> c;
	if ((tmp = c - a - b) <= 0) {
		cout << "No";
		return 0;
	}
	tmp * tmp > a * b * 4 ? cout << "Yes" : cout << "No";
	return 0;
}

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

constexpr int factorial(int n) {
	return n > 1 ? n * factorial(n - 1) : 1;
}

constexpr int NUMBER_OF_CARDS = 9;
constexpr int denominator = factorial(NUMBER_OF_CARDS);

void solve() {
	vector<int> gates(NUMBER_OF_CARDS), jackie(NUMBER_OF_CARDS);
	for(auto &e : gates) cin >> e;
	for(auto &e : jackie) cin >> e;

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

	int gates_win = 0, jackie_win = 0;
	do {
		int gates_score = 0, jackie_score = 0;
		for(int i = 0; i < NUMBER_OF_CARDS; ++i) {
			(gates[i] > jackie[i] ? gates_score : jackie_score) += gates[i] + jackie[i];
		}
		if(gates_score > jackie_score) ++gates_win;
		else if(gates_score < jackie_score) ++jackie_win;
	} while(next_permutation(jackie.begin(), jackie.end()));

	cout << (double)gates_win / denominator << " " << (double)jackie_win / denominator << endl;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.flags(ios::fixed);
	cout.precision(5);

	int t;
	cin >> t;
	while(t--) solve();

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAXN=8155;
bool vis[MAXN];
queue<int> q,qq;
double best;
int best_a,best_b;
int A,B,C,D,E,F;

void solve(){
    q.push(0);
    while(!q.empty()){
        int cur_sugar=q.front(); q.pop();
        if(cur_sugar>F||vis[cur_sugar]) continue;
        vis[cur_sugar]=1;
        while(!qq.empty()) qq.pop();
        qq.push(0);
        bool ok=0;
        while(!qq.empty()){
            int cur_water=qq.front(); qq.pop();
            if(A+cur_water+cur_sugar<=F){
                int nx_water=cur_water+A;
                if(nx_water/100*E>=cur_sugar){
                    ok=1;
                    if(best<cur_sugar*100.0/(nx_water+cur_sugar)){
                        best=cur_sugar*100.0/(nx_water+cur_sugar);
                        best_a=nx_water+cur_sugar,best_b=cur_sugar;
                    }
                }
                else qq.push(A+cur_water);
            }
            if(B+cur_water+cur_sugar<=F){
                int nx_water=cur_water+B;
                if(nx_water/100*E>=cur_sugar){
                    ok=1;
                    if(best<cur_sugar*100.0/(nx_water+cur_sugar)){
                        best=cur_sugar*100.0/(nx_water+cur_sugar);
                        best_a=nx_water+cur_sugar,best_b=cur_sugar;
                    }
                }
                else qq.push(B+cur_water);
            }
        }
        if(ok) { q.push(cur_sugar+C),q.push(cur_sugar+D); }
    }
    if(best_a==0){ best_a=A; }
    cout<<best_a<<' '<<best_b<<endl;
}

int main(){
    cin>>A>>B>>C>>D>>E>>F;
    A*=100,B*=100;
    solve();
}


Measured memory_bytes: 256
import math
import itertools
import statistics
# = int(input())
A, B, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
y = []
c = []
for i in range(M):
    X, Y, Z = [int(j) for j in input().split()]
    x.append(X)
    y.append(Y)
    c.append(Z)

m = min(a)+min(b)
for i in range(M):
    price = a[x[i]-1]+b[y[i]-1]-c[i]
    if price < m:
        m = price 

print(m)



Measured memory_bytes: 27216
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{

  int n,sum(0);
  cin>>n;
  int A[n-1];
  for(int i=0 ;i<n-1&& cin>>A[i]; i++);
rep(i,n)
{
    if(i==0)
    {
        sum+=A[i];
    }else if(i==n-1)
    {
        sum+=A[n-2];
    }else
    {
        sum+=min(A[i-1],A[i]);
    }
}
cout<<sum;
go;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin>>s;
    cin>>t;
    int m=s.length(), n=t.length();
    vector<int> idx;
    int dp[m+1][n+1];
    dp[0][0]=0;
    for(int i=1;i<=m;i++) dp[i][0]=0;
    for(int j=1;j<=n;j++) dp[0][j]=0;
    for(int i=1;i<=m;i++) for(int j=1;j<=n;j++)
    {
        if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
        else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    }
    int i=m, j=n;
    while(i>=1 && j>=1)
    {
        if(s[i-1]==t[j-1])
        {
            idx.push_back(i);
            i--;
            j--;
        }
        else
        {
            if(dp[i][j-1]>dp[i-1][j]) j--;
            else i--;
        }
    }
    reverse(idx.begin(),idx.end());
    for(int i: idx) cout<<s[i-1];
}

Measured memory_bytes: 38804
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int a,b; cin>>a>>b;
  string s; cin>>s;
  int n=s.length();
  string ans="Yes";
  for(int i=0;i<n;i++){
	if(s[i]=='-'){
      if(i!=a) ans="No";
    }
    else{
      if(i==a) ans="No";
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    D, G, *PC = map(int, read().split())
    P = PC[::2]
    C = PC[1::2]

    ans = INF
    for mask in range(1 << D):
        problems = score = 0
        available = [False] * D
        for i in range(D):
            if mask & (1 << i):
                problems += P[i]
                score += 100 * (i + 1) * P[i] + C[i]
            else:
                available[i] = True

        if score >= G:
            if ans > problems:
                ans = problems
            continue

        for i in range(D - 1, -1, -1):
            if not available[i]:
                continue
            if score + 100 * (i + 1) * P[i] + C[i] < G:
                problems += P[i]
                score += 100 * (i + 1) * P[i] + C[i]
            else:
                n = (G - score + 100 * (i + 1) - 1) // (100 * (i + 1))
                problems += n
                score += 100 * (i + 1) * n
                break

        if score >= G and ans > problems:
            ans = problems

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9024
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

A,B,C,D,E,F = MI()

density = 0
ans = (100*A,0)
for i in range(30):  # 操作1の行う回数
    for j in range(30):  # 操作2の行う回数
        if i == 0 and j == 0:
            continue
        elif 100*(A*i+B*j) >= F:
            continue
        else:
            r = min(F-100*(A*i+B*j),E*(A*i+B*j))  # 溶かせる砂糖の上限
            a = r
            for k in range(C):
                s = r-D*k
                if s < 0:
                    break
                else:
                    a = min(a,s % C)
            if density < (r-a)/((r-a)+100*(A*i+B*j)):
                density = (r-a)/((r-a)+100*(A*i+B*j))
                ans = ((r-a)+100*(A*i+B*j),(r-a))

print(*ans)

Measured memory_bytes: 62140
#include <stdio.h>

int main(){
    int a,b,c,i,j,count;
    scanf("%d %d %d",&a,&b,&c);
    for(i = a;i <= b; i++){
        for(j = 1; j * i <= c; j++){
            j * i;
            if(j * i == c){
                count++;
            }
        }
    } 
    printf("%d\n",count);
}

Measured memory_bytes: 1848
// Problem : D - Caracal vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_d
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n);n=(n*n);x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
cin>>n;
int i=log2(n);
cout<<2*Pow(2,i)-1;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<math.h>
#include<stdio.h>


int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) {
		std::cin >> a[i];
	}std::cout << a[2] <<"\t"<< a[0] << "\t" << a[1] << std::endl;
	
	
}

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

using namespace std;

string t="CODEFESTIVAL2016";

int main(){
 string s;
  cin >> s;
  
  int res=0;
  
  for(int i=0;i<s.length();i++){
   if(s[i]!=t[i]) res++;
 
  }

  
 cout << res << endl; 
  
  
  
} 


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        string[] n = Console.ReadLine().Split();
        Dictionary<string, int> a = new Dictionary<string, int> { };
        for (int i = 0;i< n.Length; i++)
        {
            if (!a.ContainsKey(n[i].ToLower()))
            {
                a.Add(n[i].ToLower(), 1);
            }
            else { a[n[i].ToLower()]++; }
        }
        Console.WriteLine( a.OrderBy(p => p.Value).Last().Key+" "+ a.OrderBy(p => p.Key.Length).Last().Key);


   //     Console.WriteLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static string Reverse(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}


Measured memory_bytes: 10000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	int a, b, x;
	cin >> a >> b >> x;

	if (a <= x && (a + b) >= x) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

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

typedef long long ll;
ll ans=0;
ll h,n;
int a;
int main(){
	cin>>h>>n;
	
	for(ll i=0; i<n; i++){
		cin>>a;
		ans+=a;
	}
	
	if(h<=ans)
		puts("Yes");
	else
		puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  int n, p, max = 0, ans = 0;
  cin >> n;
  rep(i, n){
    cin >> p;
    if(p >= max){
      ans += max;
      max = p;
    }else{
      ans += p;
    }
  }
  cout << ans + max / 2 << endl;
}

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

int main() {
  string a,b,c;
  string chk = "NO";
  
  cin >> a >> b >> c;

  if(a.at(a.size()-1) == b.at(0)){
    if(b.at(b.size()-1) == c.at(0)){
      chk = "YES";
    }
  }
  
  cout << chk;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define H 500000
int A[H+1],n;

void maxHeapify(int i){
    int l = i*2;
    int r = i*2+1;
    int maxi;
    if( l <= n && A[l] > A[i] ){
        maxi = l;
    } else maxi = i;
    if( r <= n && A[r] > A[maxi] ){
        maxi = r;
    }
    if( maxi != i ){
        int temp = A[i];
        A[i] = A[maxi];
        A[maxi] = temp;
        maxHeapify(maxi);
    }
}

int main(){
    int i,j,k;
    cin >> n;
    for( i = 1; i <= n; i++ ){
        cin >> A[i];
    }
    for( i = n/2; i >=1 ; i-- ){
        maxHeapify(i);
    }
    for( i = 1; i <=n; i++ ){
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 4972
import math
import sys
def II(): return int(sys.stdin.readline())

n = II()
sum = 0
# for n in range(1, n+1):
    # print('++++++n = '+str(n))
    # for m in range(1, n+1):
        # if n//m == n%m:
            # print('m = '+str(m)+":sho"+str(n // m)+"amari:"+str(n % m))

# for x in range(n):
for x in range(1,int(math.sqrt(n+1))):
    if n % x == 0:
        # print((n//x)-1)
        sum += ((n//x)-1)
print(sum)


Measured memory_bytes: 40172
N = int(input())
H = list(map(int,input().split()))

ans = 0
prev = -1
cnt = 0
for h in H:
  if h <= prev:
    cnt += 1
  else:
    ans = max(ans,cnt)
    cnt = 0
    
  prev = h
  
ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  unordered_map<string,int> three;
  unordered_map<string,int> memo;

  rep(i,S.size()){
    unordered_map<string,int> tmp;
    memo[""] = 1;
    FOR(it,memo){
      tmp[(it->first)] = 1;
      string t = (it->first);
      t += S[i];
      if(t.size() == 3){
        three[t] = 1;
        tmp[t.substr(1)] = 1;
      }else{
        tmp[t] = 1;
      }
    }
    swap(memo, tmp);
  }

  cout << three.size() << endl;
  
  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define ll long long
using namespace std;

int main(){
//  cout<<123<<endl;
  string s;
  cin>>s;
  s[5]=' ';s[13]=' ';
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func isPrime(a int) bool {
	for j := 2; j*j <= a; j++ {
		if a%j == 0 {
			return false
		}
	}
	return true
}

func main() {
	n, x := nextInt(), nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	sort.Ints(a)

	s, res := 0, 0
	for i := 0; i < n-1; i++ {
		s += a[i]
		if s <= x {
			res++
		}
	}
	if s+a[n-1] == x {
		res++
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
ans = 0
for i in range(N):
    A.append(list(map(int, input().split())))

for i in range(N):
    test = 0
    for j in range(M):
        test += A[i][j]*B[j]

    if test + C > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}

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

using namespace std;

double dp[3010][3010];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N;
	cin >> N;
	vector<double> p(N);
	for (int i = 0 ; i < N ; i++) cin >> p[i];
	dp[0][0] = 1.0;
	for (int i = 1 ; i <= N ; i++)
	{
		for (int j = 0 ; j <= i ; j++)
		{
			if (j == 0)
			{
				dp[i][0] = dp[i-1][0] * (1.0 - p[i-1]);
			}
			else
				dp[i][j] = dp[i-1][j] * (1.0 - p[i-1]) + dp[i-1][j-1] * p[i-1];	
		}
	}
	double ans = 0;
	for (int i = 0 ; i <= N ; i++)
	{
		int tails = N - i;
		if (i > tails)
			ans += dp[N][i];
	} 
	cout << fixed << setprecision(10) << ans << "\n";  
	return 0;
}

/*
	Define dp[i][j]: getting j heads from first i tosses

	Base Case:
	dp[0][0] = 1
	Recursive Case:
		+ There are 2 case:
			1.	This toss doesn't contains head: dp[i-1][j] * (1 - p[i]) (0 heads => j-0)
			2. 	This toss contains head: dp[i-1][j-1] * p[i]             (1 heads => j-1)
		The answer will be: dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * p[i]
 */

Measured memory_bytes: 69120
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
// #define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 1000000007;
// const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;


const int MAX_h = 100;
const int MAX_w = 100;
int h, w;
char a[MAX_h][MAX_w];

int alpa[26];
int eN, oN, tN, fN, oI;

signed main(){
    ios::sync_with_stdio(0);

    cin >> h>>w;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cin >> a[i][j];
            alpa[int(a[i][j]-'a')]++;
        }
    }

    for(int i = 0;i < 26;i++){
        if(alpa[i]%2 != 0){
            if(oN!=0){
                cout<< "No\n";
                return 0;
            }
            oN++;
            oI = i;
        }else{
            eN++;
        }

        if(alpa[i]%4 == 0){
            fN++;
        }else if(alpa[i]%2 == 0){
            tN++;
        }
    }


    if(h%2   ==   0 && w%2 == 0){
        if(tN  == 0 &&oN == 0){
            cout<< "Yes\n";
            return 0;
        }
        cout<< "No\n";
        return 0;
    }else if(h%2 != 0 && w%2 == 0){
        if(oN!=0){
            cout<< "No\n";
            return 0;
        }
        if(tN>w/2){
            cout<< "No\n";
            return 0;
        }

        if((w/2-tN)%2 == 0){
            cout<< "Yes\n";
            return 0;
        }else{
            cout<< "No\n";
            return 0;
        }
    }else if(h%2 == 0 && w%2 != 0){
        if(oN!=0){
            cout<< "No\n";
            return 0;
        }
        if(tN>h/2){
            cout<< "No\n";
            return 0;
        }

        if((h/2-tN)%2 == 0){
            cout<< "Yes\n";
            return 0;
        }else{
            cout<< "No\n";
            return 0;
        }
    }else if(h%2 != 0 && w%2 != 0){
        if(oN!=1){
            cout<< "No\n";
            return 0;
        }
        alpa[oI]--;
        if(alpa[oI]%4 == 0){
            fN++;
        }else if(alpa[oI]%2 == 0){
            tN++;
        }

        if(tN>(w+h-2)/2){
            cout<< "No\n";
            return 0;
        }

        if(((w+h-2)/2-tN)%2 == 0){
            cout<< "Yes\n";
            return 0;
        }else{
            cout<< "No\n";
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)

using namespace std;


int main() {
    //cin.tie(0);
   	//ios::sync_with_stdio(false);
       
    int i,j,k,m;
    int n,tmp;
    int ia;
    int sum=0;
    vector<int> a(0);//初期の配列のサイズを0にセット
    cin>>n;
    rep(i,n)    {
        cin >> ia;
        

        a.push_back(ia);
    }
    int f=0;
    sort(a.begin(),a.end());
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            for(k=j+1;k<n;k++){
                if(a[i]<a[j]+a[k]){
                    if(a[j]<a[i]+a[k]){
                        if(a[k]<a[i]+a[j]) sum++;
                    }
                }
            }
        }
    }
    cout<<sum<<endl;
    

    return 0;
}

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

using namespace std;

int main()
{
    int n,k;
    int ball[105];
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin >> ball[i];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans=ans+2*min(k-ball[i],ball[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	int a[]=new int[1000],i,j,n,sum,k,m;
    Scanner b =new Scanner(System.in);
    n= b.nextInt();
    for(i=0;i<n-1;i++)
    {
    	a[i]=b.nextInt();
    }
    sum=a[0];
    for(i=0;i<n-2;i++)
    {
    	if(a[i]>=a[i+1])
    	{
    		sum=sum+a[i+1];
    	}
    	else if(a[i+1]>a[i])
    	{
    		sum=sum+a[i];
    	}
    }
    sum=sum+a[n-2];
    System.out.println(""+sum);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

int atoz(){
    int frnt,bck,nibo,present,i;string s;
        frnt = abs(s[i]-present);
        bck = 26-frnt;
        nibo = min(frnt,bck);
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    //int a,b,c;
    ll n,k;
    cin>>n>>k;
    ll dif = abs(n-k);
    if(dif%k==0){
        cout<<0<<endl;
    }
    else
    {
        cout<<min(dif, k-dif%k);
    }
    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  cout << (*max_element(v.begin(), v.end()) - *min_element(v.begin(), v.end())) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n;
    cin>>n;
    if(n%10==3)
    {
        cout<<"bon"<<endl;
    }
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"hon"<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (a > b){
    for (int i = 0; i < a; i++) cout << b;
  } else if (a < b){
    for (int i = 0; i < b; i++) cout << a;
  } else {
    for (int i = 0; i < a; i++) cout << a;
  }
}

Measured memory_bytes: 256
def examA():
    Alpha = [chr(i) for i in range(97, 97+26)]
    S = SI(); N = len(S)
    ans = -1
    for i in range(N):
        for s in Alpha:
            cur = [s for s in S]
            for l in range(i):
                for k in range(N-1):
                    if cur[k+1]==s:
                        cur[k]=s
 #           print(cur)
            if len(Counter(cur[:N-i]))==1:
                ans = i
                break
        if ans>=0:
            break
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


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

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

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

	ll ans = 1;
	if (N == 1) {
		ans = 1;
	}

	ll pre2 = 2; 
	ll pre1 = 1;

	for (int i = 2; i <= N; ++i) {
		ll L = pre1 + pre2;
		pre2 = pre1;
		pre1 = L;
	}
	ans = pre1;
	
	cout << ans << endl;
	return 0;
}

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    int ans=a[n-1];
    int i;
    for(i=n-2;i>(n-2)-n/2+1;i--)
        ans+=2*a[i];
    if(n%2)ans+=a[i];
    cout << ans;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
int dp[1000001];
int ways(int arr[],int i,int n)
{
  if(dp[i]!=-1)
    return dp[i];
 if(i>=n)
   return 0;
 return dp[i]=min(abs(arr[i]-arr[i+1])+ways(arr,i+1,n),abs(arr[i]-arr[i+2])+ways(arr,i+2,n));
}
int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  memset(dp,-1,sizeof(dp));
  cout<<ways(arr,0,n-1)<<endl;
  return 0;
}


Measured memory_bytes: 8448
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
A.sort()

def gcd(n,m):
	if m > n:
		n,m = m,n
	a,b = n,m
	while b > 0:
		a,b = b, a%b
	return a

def isPrime(n):
	if n <= 1:
		return False
	if n == 2:
		return True
	if n % 2 == 0:
		return False
	i = 3
	while i * i <= n:
		if n % i == 0:
			return False
		i += 2
	return True

P = [n for n in range(10**3 + 1) if isPrime(n)]
used = [False for _ in range(10**6 + 1)]

isPC = True
s = A[0]

n = A[0]
for p in P:
	if p > n:
		break
	while n % p == 0:
		used[p] = True
		n = n // p
if n > 1:
	used[n] = True

for n in A[1:]:
	if isPC:
		a = n
		for p in P:
			if p > a:
				break
			if a % p == 0 and used[p]:
				isPC = False
				break
			while a % p == 0:
				a = a // p
		if a > 1 and used[a]:
			isPC = False
		else:
			used[a] = True

	if s > 1:
		s = gcd(s, n)

if isPC:
	print("pairwise coprime")
elif s == 1:
	print("setwise coprime")
else:
	print("not coprime")

Measured memory_bytes: 207984
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,sum=3;
	cin>>a>>b>>c;
	if(a==b) sum--;
	if(a==c) sum--;
	if(b==c) sum--;
	if(a==b&&a==c&&b==c) sum=1;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=(int) 1e5;
static const int MOD=(int) 1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
string s;

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

    int n = s.size();
    int ans = n;
    for(int i=1;i<n;i++){
        if(s[i-1] != s[i]){
            int res = max(i,n-i);
            ans = min(ans,res);
        }
    }
    cout << ans <<"\n";
    return 0;
}


Measured memory_bytes: 512
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
const int MAX=1e5+5;

#define int long long

using namespace std;

const int inf=0x3f3f3f3f;
typedef long long ll;

int n;
int a1,b1,c1,a2,b2,c2;
vector<pair<int,int> >A_to_B,B_to_A;
int dp1[5005],dp2[5005*5005];

signed main(){
	cin>>n>>a1>>b1>>c1>>a2>>b2>>c2;
	if(a1!=a2){
		if(a1<a2){
			A_to_B.push_back(make_pair(a1,a2));
		}else{
			B_to_A.push_back(make_pair(a2,a1));
		}
	}
	if(b1!=b2){
		if(b1<b2){
			A_to_B.push_back(make_pair(b1,b2));
		}else{
			B_to_A.push_back(make_pair(b2,b1));
		}
	}
	if(c1!=c2){
		if(c1<c2){
			A_to_B.push_back(make_pair(c1,c2));
		}else{
			B_to_A.push_back(make_pair(c2,c1));
		}
	}
	dp1[0]=0;
	for(auto p:A_to_B){
		for(int j=0;j+p.first<=n;j++){
			dp1[j+p.first]=max(dp1[j+p.first],dp1[j]+p.second);
		}
	}
	int now=0;
	for(int i=0;i<=n;i++)now=max(now,n-i+dp1[i]);
	dp2[0]=0;
	for(auto p:B_to_A){
		for(int j=0;j+p.first<=now;j++){
			dp2[j+p.first]=max(dp2[j+p.first],dp2[j]+p.second);
		}
	}
	int ans=0;
	for(int i=0;i<=now;i++)ans=max(ans,now-i+dp2[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 195584
/*  -*- coding: utf-8 -*-
 *
 * 2923.cc: Ravage
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = MAX_N * 2;

/* typedef */

/* global variables */

/* subroutines */

int as[MAX_N], bs[MAX_N];
int us[MAX_M], cs[MAX_M + 1];

/* main */

int main() {
  int n, m = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d%d", as + i, bs + i);
    us[m++] = as[i];
    us[m++] = bs[i];
  }
  sort(us, us + m);
  m = unique(us, us + m) - us;
  //printf("m=%d\n", m);

  for (int i = 0; i < n; i++) {
    int i0 = lower_bound(us, us + m, as[i]) - us;
    int i1 = lower_bound(us, us + m, bs[i]) - us;
    cs[i0]++;
    cs[i1 + 1]--;
  }

  int maxc = cs[0];
  for (int i = 1; i <= m; i++) {
    cs[i] += cs[i - 1];
    if (maxc < cs[i]) maxc = cs[i];
  }
  printf("%d\n", maxc);
  return 0;
}



Measured memory_bytes: 5636
#include<stdio.h>
int main(void){
    int i;
    char s[4];
    char t[4];
    int count = 0;
    scanf("%s",s);
    scanf("%s",t);
    for ( i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
        {
            count++;
        }
        
    }
    printf("%d\n",count);
    return 0;
}

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

int main(){

    int n,x; cin>>n>>x;

    int len[n];

    for(int i=0; i<n; i++) cin>>len[i];

    int count =1,i=0,sum=0;

    while( ( sum = len[i] + sum ) <= x && i <= n+1){   
        
        count++; i++;
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	nextReader = newScanner()

	x := nextInt()
	fmt.Printf("%d\n", x*x*x)
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}



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

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

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

    cout << min(a, b) + min(c, d) << endl;
}

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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, b * d, a * d, b * c});
    return 0;
}

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

using namespace std;

int main() {
    int l,contor=0;
    char pass[4];
    char str[30001]; 
    cin>>l;
    cin>>str;
    int  I,II;
 
    for(int i=0; i<=9; ++i)
    {
        pass[0] = char(57-i);
        
        for(int j=0; j<=9; ++j)
        {     
            pass[1] = char(57-j);
            for(int k=0; k<=9; ++k)
            {      I=0,II=0;
                pass[2] = char(57-k);
               for(int q=0;q<l; ++q)
               {
                   if(pass[0] == str[q] && I==0)
                       I=1;
                       else
                     if(pass[1]==str[q] && I && II==0)
                         II=1;
                         else
                        if(pass[2] == str[q] && I && II)
                        {
                            contor ++;
                            
                            break;
                        }
                         
                     
                   
               }
                
            }
        }
    }
    cout<<contor;
  
    return 0;
}

Measured memory_bytes: 256