akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>
//#include <ctime>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 20;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
 	freopen((s+".out").c_str(),"w",stdout);
}



int main() {
    setIO();

    string s; cin >> s;
    int ans = 0;
    int cur =0;
    FOR(i, 0, 2) {
        if (s[i] == 'R') cur++;
        else cur = 0;
        ans = max(ans, cur);
    }
    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3652
import java.util.*;
public class Main{
    public static void main(String sp[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int d = sc.nextInt();
		int val = (2*d)+1;
		int div = n/val;
		int mod = n%val;
		if(mod>0)
			div+=1;
		System.out.println(div);
	}
}

Measured memory_bytes: 23892
n = int(input())
s = input()
ls = [s[k:k+1] for k in range(n)]
#print(ls)

res = 0
for i in range(1,n):
  f = list(set(ls[0:i]))
  b = list(set(ls[i:n]))
  #print(f,b)
  tmp = 0
  for j in range(len(f)):
    if b.count(f[j]) > 0:
      tmp += 1
  if tmp > res:
    res = tmp

print(res)

Measured memory_bytes: 3064
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let t: i64 = input();
    let ts: Vec<i64> = (0..n).map(|_| input()).collect();

    let mut ans = t;
    for i in 1..n {
        if ts[i] > ts[i - 1] + t {
            ans += t;
        } else {
            ans += ts[i] - ts[i - 1];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <stdio.h>

int main(void)
{
	int n,x,min,max,i;
	scanf("%d",&n);
	scanf("%d",&x);
	min=x;
	max=x;
	for(i=1;i<n;i++){
		scanf("%d",&x);
		if(min>x){
			min=x;
		}
		if(max<x){
			max=x;
		}
	}
	printf("%d\n",(max-min+1)/2);
	return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[61];
int cnt[10];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]+2]++;
	}
	if(cnt[0]%2==0){
		printf("%d\n",cnt[4]+cnt[0]);
		for(int i=0;i<n;i++){
			if(a[i]==2 || a[i]==-2){
				printf("%d\n",i+1);
			}
		}
	}else if(cnt[1]>=1){
		printf("%d\n",cnt[4]+cnt[0]+1);
		bool fu=false;
		for(int i=0;i<n;i++){
			if(a[i]==2 || a[i]==-2){
				printf("%d\n",i+1);
			}
			if(a[i]==-1 && !fu){
				fu=true;
				printf("%d\n",i+1);
			}
		}
	}else{
		printf("%d\n",cnt[4]+cnt[0]-1);
		bool fu=false;
		int ca=0;
		for(int i=0;i<n;i++){
			if(a[i]==2 || (a[i]==-2 && (ca+1)!=cnt[0])){
				printf("%d\n",i+1);
				if(a[i]==-2)ca++;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3220
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int X, A, B;

int main()
{
	scanf("%d %d %d", &X, &A, &B);

	int temp = X - A;
	int finalAns = temp % B;

	printf("%d\n", finalAns);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

using namespace std;

int N, hs[1 << 8];

int rec(int l = 0, int r = N)
{
	if (*max_element(hs+l, hs+r)==0) return 0;
	int m = *min_element(hs+l, hs+r);
	if (m)
	{
		for (int i = l; i < r; i++)
		{
			hs[i] -= m;
		}
	}
	int p = 1, nl = l, res = m;
	while(hs[nl] == 0 && nl < r) nl++;
	for (int i = nl; i < r; i++)
	{
		if (p && hs[i] == 0)
		{
			res += rec(nl, i);
			p = 0;
		}
		else if (!p && hs[i])
		{
			p = 1;
			nl = i;
		}
	}
	if (hs[r-1])
	{
		res += rec(nl, r);
	}
	return res;
}

void solve()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> hs[i];
	}
	cout << rec() << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a == b) {
            System.out.println(c);
        } else if (a == c) {
            System.out.println(b);
        } else {
            System.out.println(a);
        }
    }
}


Measured memory_bytes: 21076
s = input()
K = int(input())
# substrings = {}
substrings = []
for i in range(1,6):
    for j in range(0,len(s)):
        if s[j:j+i] not in substrings:
            # substrings[s[j:j+1]] = True
            substrings.append(s[j:j+i])
print(sorted(substrings)[K-1])


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

const long long M=1046527;
string H[1046527];

/*int ti(char ch){
	if(ch=='A')		return 1;
	else if(ch=='C')	return 2;
	else if(ch=='T')	return 3;
	else if(ch=='G')	return 4;
	return 5;
}*/

long long toInt(string str){
	long long p=1, sum=0, i;
	for(i=0; i<str.length(); i++){
		if(str[i]=='A')
			sum+=p*1;
		else if(str[i]=='C')
			sum+=p*2;
		else if(str[i]=='T')
			sum+=p*3;
		else if(str[i]=='G')
			sum+=p*4;
		p*=5;
	}
	/*for(i=0; i<str.length(); i++){
		sum+=p*ti(str[i]);
		p*=5;
	}*/
	return sum;
}

long long h1(long long i){
	return i%1046527;
}
long long h2(long long i){
	return i%1046526;
}

void insert(string str){
	long long key=toInt(str), i, h;
	for(i=0; ; i++){
		h=(h1(key)+i*h2(key))%1046527;
		if(H[h].length()==0){
			H[h]=str;
			return ;
		}
	}
}

string find(string str){
	long long key=toInt(str), i, h;
	for(i=0; ; i++){
		h=(h1(key)+i*h2(key))%1046527;
		if(H[h]==str)
			return "yes";
		else if(H[h].length()==0)
			return "no";
	}
	return "no";
}

int main(){
	int n;
	cin>>n;
	while(n--){
		string command, str;
		cin>>command>>str;
		if(command=="insert")
			insert(str);
		else if(command=="find")
			cout<<find(str)<<endl;
	}
	return 0;
}


Measured memory_bytes: 41600
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
long double x,y,z;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    x=a;
    x=x/3.0;
    x=x*x*x;
    cout<<setprecision(12)<<x;
    return 0;
}

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

int main()
{
	long long  i,j,m;
	cin>>m;

	for(i=-140;i<=140;i++)
	{
	    for(j=-140;j<=140;j++)
	    {
	    	if(i*i*i*i*i-j*j*j*j*j==m)
	    	{
			cout<<i<<" "<<j<<endl;
	    	return 0;
		    }
		}
	}
	
	
	
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    map<pair<int, int>, int> cnt;
    for (int i = 0; i < n - 1; i++) {
        int a = s[i] - '0', b = s[i + 1] - '0';
        cnt[{a, b}]++;
    }

    int nin = 1e9;
    vector<int> best;
    vector<int> pm(9);
    iota(pm.begin(), pm.end(), 1);

    do {
        int tmp = 0;
        pair<int, int> pos[10];
        for (int i = 1; i < 10; i++) {
            pos[pm[i - 1]] = {(i - 1) / 3, (i - 1) % 3};
        }
        for (auto& p : cnt) {
            int dist = abs(pos[p.first.first].first - pos[p.first.second].first) + abs(pos[p.first.first].second - pos[p.first.second].second);
            tmp += dist * p.second;
        }
        if (tmp < nin) {
            nin = tmp;
            best = pm;
        }
    } while (next_permutation(pm.begin(), pm.end()));

    for (int i = 0; i < 9; i++) {
        cout << best[i];
        if (i % 3 == 2) cout << '\n';
    }
}


Measured memory_bytes: 3296
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX-10;
const ll MOD = 1e9+7;

ll dp[310][310][310];

int main() {
  int N,M;cin >> N >> M;
  vector<Pii> rlx[N+1];
  repeat(i,M){
    int l,r,x;
    cin >> l >> r >> x;
    rlx[r].push_back({l,x});
  }
  ll ans=0;
  dp[0][0][0]=1;
  repeat(r,N+1){
    repeat(g,N+1){
      repeat(b,N+1){
        ll color[3]={r,g,b};
        sort(color,color+3);
        ll k = color[2];
        bool isok=true;
        for(auto lx:rlx[k]){
          if(lx.second==1){
            isok &= color[1]<lx.first;
          }else if(lx.second==2){
            isok &= color[0]<lx.first&&lx.first<=color[1];
          }else{
            isok &= lx.first<=color[0];
          }
        }
        if(!isok) dp[r][g][b] = 0;
        dp[k+1][g][b] = (dp[k+1][g][b]+dp[r][g][b])%MOD;
        dp[r][k+1][b] = (dp[r][k+1][b]+dp[r][g][b])%MOD;
        dp[r][g][k+1] = (dp[r][g][k+1]+dp[r][g][b])%MOD;
        if(k==N){
          ans = (ans+dp[r][g][b])%MOD;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 227584
using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif


//point update, range query, 0-indexed
struct bit {
	vector<long long> b;
	void init(int n) { b.resize(n + 1); }
	bit() {}
	bit(int n) { init(n); }
	inline void update(int i, long long v) {
		for (++i; i < (int)b.size(); i += i & -i)
			b[i] += v;
	}
	//sum of the first i values
	long long prefix(int i) const {
		long long a = 0;
		for (; i; i ^= i & -i)
			a += b[i];
		return a;
	}
	inline long long query(int l, int r) const {
		return prefix(r + 1) - prefix(l);
	}
};



int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif
	int n, q;
	cin >> n >> q;

	bit b(n+1);
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		b.update(i, x);
	}
	while (q-- > 0) {
		int x, y, z;
		cin >> x >> y >> z;
		if (x == 0) {
			b.update(y, z);
		}
		else {
			cout << b.query(y, z - 1) << endl;
		}
	}


}


Measured memory_bytes: 8244
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b,ans=0;
	cin >> a >> b;
	if (b == 1)
	{
		cout << 0;
		return 0;
	}
	b -= a;
	if (b <= 0)
		cout << 1;
	else
	{
		ans = b / (a - 1);
		if (b % (a - 1) != 0)
			ans += 1;
		cout << ans + 1;
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1<<30)

idx = 'ABC'
N, *vals = map(int, input().split())
evs = [tuple(map(idx.index, input())) for _ in range(N)]
path = []

def f(i):
	if i == len(evs):
		print('Yes')
		print('\n'.join(path))
		raise SystemExit

	k, j = evs[i]
	for add, sub in ((k, j), (j, k)):
		if vals[sub] == 0: continue
		vals[add] += 1
		vals[sub] -= 1
		path.append(idx[add])

		f(i+1)

		vals[add] -= 1
		vals[sub] += 1
		path.pop()

f(0)

print('No')



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

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

  if (S.size() <= K) {
    cout << S << endl;
  }
  else{
    for(int i=0;i<K;i++){
    cout << S.at(i) ;
    }
    cout << "..." << endl;
  }

}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;

	int k=a+b;
	k/=2;

	if(abs(a-k)==abs(b-k)){
		cout << k << endl;
	}
	else{
		cout << "IMPOSSIBLE\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

class UnionFind{
    public:
        UnionFind(int N) : parent(N), rank(N){
            for(int i = 0; i < N; i++){
                parent[i] = i;
                rank[i] = 1;
            }
        }

        int find(int n){
            if(parent[n] == n){
                return n;
            }
            return parent[n] = find(parent[n]);
        }

        void merge(int m, int n){
            int root_x = find(m);
            int root_y = find(n);
            if(root_x == root_y){
                return;
            }
            if(rank[root_x] < rank[root_y]){
                parent[root_x] = root_y;
            }else if(rank[root_x] > rank[root_y]){
                parent[root_y] = root_x;
            }else{
                parent[root_y] = root_x;
                rank[root_x]++;
            }
        }

        bool equivalent(int x, int y){
            return find(x) == find(y);
        }

    private:
        vector<int> parent;
        vector<int> rank;

};

ll g[100010];

signed main(){
    ll N, M;
    cin >> N >> M;
    UnionFind uf(N);
    ll X, Y, Z;
    REP(i, M){
        cin >> X >> Y >> Z;
        X--; Y--;
        uf.merge(X, Y);
    }
    REP(i, N) g[uf.find(i)] = 1;
    PRINT(accumulate(g, g + N, 0LL));
    return 0;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans;
    ans = 0;
    REP(int,i,0,N-2){
        if ( S.at(i) == 'A' ){
            if ( S.at(i+1) == 'B' ){
                if ( S.at(i+2) == 'C' ) ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i

arr = gets.chomp.split.map(&:to_i)
arr.sort!

distance = arr[-1]
target = 0
half = arr[-1]/2.to_f

arr.each do |i|
  d = (half - i).abs
  if d < distance
    target = i
    distance = d
  end
end

puts "#{arr[-1]} #{target}"


Measured memory_bytes: 11392
#include <cassert>
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
	std::string s;
	std::cin >> s; assert(s.size() == 4);
	const bool pre = (
		s[0] == s[1] &&
		s[0] == s[2]
	);
	const bool post = (
		s[1] == s[3] &&
		s[2] == s[3]
	);
	const bool good = (pre || post);
	const std::string t = (good) ? "Yes" : "No";
	std::cout << t << std::endl;
	return 0;
}

Measured memory_bytes: 256
line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp
    i += 1
end

S = line[0]
T = line[1]

ans = 0
for i in 1..S.length do
  if S[i-1] != T[i-1] then
    ans += 1
  end
end
  
puts ans

Measured memory_bytes: 15176
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
using namespace std;

int dp_H[100003][3];//用dp_H[i][k]表示第i天选择第k项活动的最大快乐值
int Happy[100003][3];//

int BiggestHappy(int N){
    dp_H[1][1]=Happy[1][1];
    dp_H[1][2]=Happy[1][2];
    dp_H[1][3]=Happy[1][3];
    for(int i=2;i<=N;i++){
        dp_H[i][1]=Happy[i][1]+max(dp_H[i-1][2],dp_H[i-1][3]);
        dp_H[i][2]=Happy[i][2]+max(dp_H[i-1][1],dp_H[i-1][3]);
        dp_H[i][3]=Happy[i][3]+max(dp_H[i-1][1],dp_H[i-1][2]);
    }
    int answer=max(dp_H[N][1],max(dp_H[N][2],dp_H[N][3]));
    return answer;
}

int main()
{
    int N;
    while(cin>>N){
        for(int i=1;i<=N;i++){
            cin>>Happy[i][1]>>Happy[i][2]>>Happy[i][3];
        }
        cout<<BiggestHappy(N)<<endl;
    }
    return 0;
}

Measured memory_bytes: 2560
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
//   FI(); /// skip this line for compile
    int n,a=0,b=0,arr[101];
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    reverse(arr,arr+n);
    for(int i=1; i<=n; i++)
    {
        if(i%2==1)
            a+=arr[i-1];
        else
            b+=arr[i-1];
    }
    cout << a-b << endl;
    return 0;
    //code end
}
//okbye



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
vector <int> B(9);
int main() {
    int N;
    cin >> N;
    vector <int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(1 <= A[i] && A[i] < 400){
            B[0]++;
        }
        if(400 <= A[i] && A[i] < 800){
            B[1]++;
        }
        if(800 <= A[i] && A[i] < 1200){
            B[2]++;
        }
        if(1200 <= A[i] && A[i] < 1600){
            B[3]++;
        }
        if(1600 <= A[i] && A[i] < 2000){
            B[4]++;
        }
        if(2000 <= A[i] && A[i] < 2400){
            B[5]++;
        }
        if(2400 <= A[i] && A[i] < 2800){
            B[6]++;
        }
        if(2800 <= A[i] && A[i] < 3200){
            B[7]++;
        }
        if(3200 <= A[i]){
            B[8]++;
        }
    }
    int count = 0;
    for(int i = 0; i < 8; i++){
        if(B[i] != 0){
            count++;
        }
    }
    if(count == 0){
        cout << 1 << ' ' << B[8] << endl;
    }
    else{
        cout << count << ' ' << count + B[8] << endl;
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class rMq {
  public:
  int N;
  vi segtree;
  rMq(int n) {
    N = 1;
    int len = 1;
    while(N < n) {
      N *= 2;
      len += N;
    }
    segtree = vi(len,0);
  }
  void build(int idx,int val) {
    int s = sz(segtree) - (N-idx);
    segtree[s] = val;
    while(1) {
      if(s == 0) break;
      s = (s-1)/2;
      segtree[s] = max(segtree[s*2+1],segtree[s*2+2]);
    }
  }
  int _query(int a,int b,int idx,int l,int r) {
    if(a <= l && r <= b) return segtree[idx];
    if(r <= a || b <= l) return 0;
    int vl = _query(a,b,idx*2+1,l,(l+r)/2);
    int rl = _query(a,b,idx*2+2,(l+r)/2,r);
    return max(vl,rl);
  }
  // max(A[i] | l <= i < r)
  int query(int l,int r) {
    return _query(l,r,0,0,N);
  }
};
  
int main() {
  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
  }
  rMq seg(310000);
  int ans = 0;
  rep(i,n) {
    int r = seg.query(max(0,a[i]-k),min(300000,a[i]+k)+1);
    chmax(ans,r+1);
    seg.build(a[i],r+1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8556
using System;
class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        
        double money = 0.0;
        for (int i = 0; i < n; ++i){
            string[] input = Console.ReadLine().Split(' ');
            double price = double.Parse(input[0]);
            string unit = input[1];
            if(unit.Equals("BTC")){
                money += price * 380000.0;    
            } else {
                money += price;
            }
        }
        
        Console.WriteLine(money);
    }
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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


int main() {
    int N;
    cin >> N;
    vector<vpi> ab(N);
    //vector<vector<bool>> ch(N, vector<bool>(N ,false));
    vi ans(N-1, 0), Vp(N, 0);

    rep(i,N-1) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        ab[a].push_back(make_pair(b, i));
        ab[b].push_back(make_pair(a, i));
    }

    //次数が一番大きい頂点の探索
    int m_d = 0, m_dindex;
    rep(i,N) {
        if((int)ab[i].size() > m_d) {
            m_d = (int)ab[i].size();
            m_dindex = i;
        }
    }

    //根から幅優先探索
    queue<int> que;
    que.push(m_dindex);
    while(!que.empty()) {
        int nr = que.front(); que.pop();

        //色塗り
        int clnum = 0;
        rep(i, ab[nr].size()) {
            if(ans[ab[nr][i].second] != 0) continue;

            //塗られていない辺に塗る色の決定
            clnum++;
            if(clnum == Vp[nr]) clnum++;
            ans[ab[nr][i].second] = clnum;
            que.push(ab[nr][i].first);
            Vp[ab[nr][i].first] = clnum; //親とつながる辺の色を記録
        }
    }

    cout << m_d << "\n";
    rep(i, N-1) cout << ans[i] << "\n";
    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf", ans);
    //cout << ans;
    //cout << "\n";
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()

int main() 
{
	 // #ifndef ONLINE_JUDGE
  //       freopen("input.txt", "r", stdin);
  //       freopen("output.txt", "w", stdout);
  //   #endif
  //   fastio();
	cout<<fixed;
	cout<<setprecision(14);
	double n,k;
	cin>>n>>k;
	double ans=0;
	loop(i,1,n+1)
	{
		ll p = 0;
		if(k>i)
			p = ceil(log(k/i)/log(2));
		//cout<<p<<endl;
		ans+= (1/n) * pow(0.5,p);
	}
	cout<<ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 1e9
using namespace std;
typedef long long ll;

signed main() {
  // std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
  int n;
  cin >> n;

  vector<ll> monsters(n + 1);
  REP(i, n + 1) cin >> monsters.at(i);

  vector<ll> hero(n);
  REP(i, n) cin >> hero.at(i);

  ll cnt = 0;
  REP(i, n){
    ll killed_first = min(monsters.at(i), hero.at(i));
    cnt += killed_first;
    hero.at(i) -= killed_first;

    ll killed_second = min(monsters.at(i + 1), hero.at(i));
    cnt += killed_second;
    monsters.at(i+1) -= killed_second;
  }

  cout << cnt << endl;
}



Measured memory_bytes: 1792
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;

using namespace std;

void solve()
{
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0;i < n;i++)
    {
        int l,r;
        cin >> l >> r;
        sum += (r + 1) - l;
    }
    cout << sum << endl;
    return;
}

int main()
{
    solve();
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int len = (int)s.size();

    int cnt = 0;
    for (int i = 1; i < len; i++) {
        if (s.at(i) == 'g') cnt++;
    }
    int ans = max(0, min(len / 2, cnt) - (len - 1 - cnt));
    cout << ans << endl;
}   

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

const ll mod = 1000000007;
const int INF = 1001001001;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, x, t; cin >> n >> x >> t;
	int ans = n / x * t;
	if(n % x) ans += t;
	cout << ans << endl;
	
} 

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[5];
	for(int i=1;i<=3;i++)
		cin>>a[i];
	sort(a+1,a+4);
	cout<<a[3]-a[1]<<endl;
	return 0;
}

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

int main()
{
    const int cake = 4;
    const int donatu = 7;
    int doller;
    cin >> doller;

    string solve = "No";
    for (int i = 0; i*cake <= doller; i++)
    {
        int cakedoller = (i * cake);
        int donatudoller = doller - cakedoller;
        if (donatudoller % donatu == 0)
        {
            solve = "Yes";
            break;
        }
    }

    cout << solve << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func getNextLine(fp *os.File) string {
	scanner := bufio.NewReader(fp)
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getNextWord(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextWord(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)

	h := getNextInt(scanner)
	w := getNextInt(scanner)
	ss := make([]string, h)
	for i := 0; i < h; i++ {
		ss[i] = getNextWord(scanner)
	}
	left := make([][]int, h)
	for i := 0; i < h; i++ {
		left[i] = make([]int, w+2)
		for x := 0; x < w; x++ {
			if ss[i][x] == '.' {
				left[i][x+1] = left[i][x] + 1
				continue
			}
			left[i][x+1] = 0
		}
		for x := w; x > 0; x-- {
			if left[i][x+1] > 0 && left[i][x] > 0 {
				left[i][x] = left[i][x+1]
			}
		}
	}

	up := make([][]int, w)
	for i := 0; i < w; i++ {
		up[i] = make([]int, h+2)
		for y := 0; y < h; y++ {
			if ss[y][i] == '.' {
				up[i][y+1] = up[i][y] + 1
				continue
			}
			up[i][y+1] = 0
		}
		for y := h; y > 0; y-- {
			if up[i][y+1] > 0 && up[i][y] > 0 {
				up[i][y] = up[i][y+1]
			}
		}
	}

	max := 0
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if ss[y][x] == '#' {
				continue
			}
			sum := left[y][x+1] + up[x][y+1] + -1
			if max < sum {
				max = sum
			}
		}
	}

	fmt.Fprintln(writer, max)

	writer.Flush()
}


Measured memory_bytes: 71424
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <string>

int main() {
	usize n;
	::std::cin >> n;
	double ans = 0;
	while (n--) {
		double x;
		::std::string u;
		::std::cin >> x >> u;
		if (u == "JPY") {
			ans += x;
		}
		else {
			ans += x * 380000;
		}
	}

	::std::cout << ans << ::std::endl;

	return 0;
}


Measured memory_bytes: 256
using System;

class AtCoder
{
    static void Main()
    {
        string[] s;

        s = NextS();
        int n = int.Parse(s[0]);

        s = NextS();
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);

        s = NextS();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) p[i] = int.Parse(s[i]);
        int x = 0; int y = 0; int z = 0;
        for(int i=0; i<n; i++)
        {
            if (p[i] <= a) x++;
            else if (p[i] <= b) y++;
            else z++;
        }
        int ans = z;
        if (y < ans) ans = y;
        if (x < ans) ans = x;
        Console.WriteLine(ans);
    }

    static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<ll> sum(N + 1), possum(N + 1);
    rep(i, N) {
        sum[i + 1] = sum[i] + a[i];
        possum[i + 1] = possum[i] + (a[i] > 0 ? a[i] : 0);
    }

    ll ans = -LINF;
    rep(i, N - K + 1) {
        ll v = sum[i + K] - sum[i] + possum[N] - possum[i + K] + possum[i];
        ans = max(ans, v);
        v = possum[N] - possum[i + K] + possum[i];
        ans = max(ans, v);
    }
    write(ans);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;	

int main() {
	int a, b, c; cin >> a >> b >> c;
	int s = min(a + b, b + c);
	int u = min(s, a + c);
	cout << u << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

ll n,x;
ll res[100];
ll sum[100];

ll func(int m,ll y){
  if(y==sum[m])return res[m];
  else if(m>=y && m>=1) return 0;
  else if(m>=1 && y==res[m]) return res[m-1]+1;
  else if(m>=1 && y<res[m]) return func(m-1,y-1);
  else if(m>=1 && y>res[m]) return res[m]-func(m,sum[m]-y);
  else{
    return 1;
  }
}

    int main(){
      cin >> n >> x;
      rep(i,n+1){
       res[i]=pow(2,i+1)-1;
        sum[i]=pow(2,i+2)-3;
      }
      cout << func(n,x) << endl;
      return 0;}

Measured memory_bytes: 512
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

S = rs()
T = rs()

ans = 0
for i in range(len(S)):
	if S[i] != T[i]:
		ans += 1
print(ans)


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

using namespace std;

vector<int> make_prime_list(int max_num){
    vector<bool> is_prime_list(max_num+1, true);
    for(int i=2; i <= sqrt(max_num); i++){
        if(is_prime_list[i]){
            for(int j=2; i*j <= max_num; j++){
                is_prime_list[i*j] = false;
            }
        }
    }

    int count = 0;
    vector<int> prime_list(max_num+1, 0);
    for(int i=2; i <= max_num; i++){
        if(is_prime_list[i]){
            count++;
        }
        prime_list[i] = count;
    }

    return prime_list;
}

int main(void){
    int input;

    vector<int> prime_list = make_prime_list(999999);

    while(cin >> input){
        cout << prime_list[input] << endl;
    }

    return 0;
}

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";


#define mod 1000000007
#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{IOS
ll  n,i,j,k,sum=0,f=0;
cin>>n>>k>>j;
ll a[n]={0};
if(k*j>=n)
{cout<<"Yes";}
else{cout<<"No";}






return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl a(n);
	cin>>a;
	ll g=a[0];
	rep(i,n-1){
		g=gcd(g,a[i+1]);
	}
	tf(max(a)>=k and (max(a)-k)%g==0,"POSSIBLE","IMPOSSIBLE");
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
	int n,l,p,k=-1;
	scanf("%d%d%d",&n,&l,&p);
	for (int i=1;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		if (p+a>=l)
		k=i;
		p=a;
	}
	if (k==-1)
	printf("Impossible");
	else
	{
		printf("Possible\n");
		for (int i=1;i<k;i++)
		printf("%d\n",i);
		for (int i=n-1;i>=k;i--)
		printf("%d\n",i);
	}
}

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

using namespace std;
int main (){
    int n,m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    for (int i = 0; i < m; i++){
        cin >> l[i] >> r[i];
    }
    int lm,rm;
    lm=*max_element(l.begin(),l.end());
    rm=*min_element(r.begin(),r.end());
//    cout << lm << " " << rm << "\n";
    rm=min(rm,n);
    if(rm<lm) cout << "0" << "\n";
    else      cout << rm-lm+1 << "\n";
}

Measured memory_bytes: 1024
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2], K = ip[3];
	if(K < A) {
		K.writeln;
	}
	else if(A >= K) {
		K.writeln;
	} else if(K <= A + B) {
		A.writeln;
	} else {
		(A - min(C, K - A - B)).writeln;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2724
/* Author: topcoderme123
   Date: 22nd june 2020 
*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define np next_permutation
using namespace std;
using vi=vector<int>;
#define lp(i,n) for(int i=0;i<n;i++)
#define reps(i,j,n) for(int i=j;i<=n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define vs vector<string>
#define us unordered_map<int,int>
#define Mpq priority_queue<int>
#define mpq priority_queue<int,vi,greater<int>> 
#define eb emplace_back
#define prl pair<ll,ll>
#define vp vector<pr>

const int N=(int)5e5+11;

ll n,m;
ll fact[N];

ll invmod(ll x){
  ll y=mod-2,ans=1;
  while(y>0){
     if(y&1) ans=(ans*x)%mod;
     x=(x*x)%mod;
     y>>=1;
  }
  return (ans+mod)%mod;
}

void preprocess(){
  fact[0]=1;
  for(ll i=1;i<N;i++)
    fact[i]=(fact[i-1]*i)%mod;
}

ll comb(ll m,ll n){
  ll x=fact[m],y=invmod(fact[m-n]),z;
  z=invmod(fact[n]);
  ll ans=((x*y)%mod*z)%mod;
  return ans;
}
ll permut(ll m,ll n){
  ll x=fact[m],y=invmod(fact[m-n]);
  ll ans=(x*y)%mod;
  return ans;
}
void solve(){
    cin>>n>>m;
    ll ans=0;
    for(ll i=0;i<=n;i++){
       ll x=comb(n,i),y=permut(m,i),z,temp;
       z=permut(m-i,n-i);
       z=(z*z)%mod;
       temp=((x*y)%mod*z)%mod;
       if(i%2) ans=(ans-temp+mod)%mod;
       else ans=(ans+temp)%mod;
    }
    cout<<ans<<"\n";
}
int main(int argc,char *argv[]){
   ios_base::sync_with_stdio(0);
   cin.tie(nullptr);
   //assert(freopen("input.txt", "r", stdin));
   //assert(freopen("output.txt", "w", stdout));
   preprocess();
   solve();
   return 0;
}


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

#define ll long long

int abc (ll x, ll y) {
  if (x == 0) {
    return y;  
  }  
  if (x > y) {
    return y;  
  }
  return x;
}


int main () {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  int a[n + 1], b[n + 1], c[n + 1];
  a[0] = 0;
  b[0] = 0;
  c[0] = 0;
  int sum_a = 0;
  int sum_b = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1] >> b[i + 1] >> c[i + 1];  
    sum_a = sum_a + a[i + 1];
    sum_b = sum_b + b[i + 1];
  }
  int ans[n + 1][sum_a + 1][sum_b + 1];
  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= sum_a; j++) {
      for (ll l = 0; l <= sum_b; l++) {
        ans[i][j][l] = 0;         
      }  
    }  
  }
  ll min = -1;
  for (ll i = 1; i <= n; i++) {
    ans[i][a[i]][b[i]] = abc(
      ans[i][a[i]][b[i]], c[i]
    ); 
    for (ll j = 0; j <= sum_a; j++) {
      for (ll l = 0; l <= sum_b; l++) {
        if (ans[i - 1][j][l] != 0) {
          ans[i][j + a[i]][l + b[i]] = abc(
            ans[i][j + a[i]][l + b[i]], ans[i - 1][j][l] + c[i]
          );
          ans[i][j][l] = abc(
            ans[i][j][l], ans[i - 1][j][l]
          );
        }    
        if (j % ma == 0 && l % mb == 0) {
          if (j / ma == l / mb && ans[i][j][l] != 0) {
            if (min == -1 || min > ans[i][j][l]) {
              min = ans[i][j][l];  
            }  
          }  
        }
      }  
    } 
  }
  cout << min << endl;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
vector<int> vi;
int arr[150];
int main()
{
    int n,i,j,k,x,y,curr,temp,m;
    int a,b;
    cin >> a >> b >> k;
    for(i=1;i<=a;i++)
    {
        if(a%i==0)
            arr[i]++;
    }
    for(i=1;i<=b;i++)
    {
        if(b%i==0)
            arr[i]++;
    }
    for(i=100;i>0;i--)
    {
        if(arr[i] == 2)
            vi.push_back(i);
    }
    printf("%d\n",vi[k-1]);
    return 0;
}


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

using pii = pair<int, int>;

class union_find {
public:
    union_find(int n) : par(n, -1) {}

    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return;
        if(par[x] < par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

private:
    vector<int> par;
};

int main() {
    int n; cin >> n;
    vector<int> a(n), id(1 << 17, -1);
    union_find uf(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        int tmp = a[i];
        for(int x = 2; x * x <= tmp; ++x) {
            if(tmp % x == 0) {
                while(tmp % x == 0) tmp /= x;
                if(id[x] != -1) {
                    uf.unite(i, id[x]);
                }
                id[x] = i;
            }
        }
        if(tmp > 1) {
            if(id[tmp] != -1) {
                uf.unite(i, id[tmp]);
            }
            id[tmp] = i;
        }
    }

    map<int, vector<int>> vals, idxs;
    for(int i = 0; i < n; ++i) {
        idxs[uf.root(i)].push_back(i);
        vals[uf.root(i)].push_back(a[i]);
    }
    for(auto& p : vals) {
        sort(begin(p.second), end(p.second));
        const auto& ids = idxs[p.first];
        for(int i = 0; i < (int)p.second.size(); ++i) {
            a[ids[i]] = p.second[i];
        }
    }

    cout << is_sorted(begin(a), end(a)) << endl;
}



Measured memory_bytes: 7416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


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

	ll N;
	cin >> N;
	set<string> S;
	rep(i, N) {
		string s;
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << endl;
}


Measured memory_bytes: 19276