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

using namespace std;

int main(void) {
    string s;
    unsigned int k;
    cin >> s;
    cin >> k;
    vector<string> ss;
    for(int i = 0;i < s.length();i++) {
        ss.push_back(s.substr(i,s.length() - i));
    }
    sort(ss.begin(), ss.end());
    
    set<string> sss;
    while(sss.size() < k) {
        string t = *ss.begin();
        for(int i = 1;i <= t.length() && sss.size() < k;i++) {
            if(sss.find(t.substr(0,i)) == sss.end())
                sss.insert(t.substr(0,i));
        }
        ss.erase(ss.begin());
    }
    auto x = sss.begin();
    for(int i = 1;i < k;i++)
        x++;
    cout << *x << endl;
    return 0;
}


Measured memory_bytes: 16128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 4) {
            System.out.println("No");
            return;
        }
        String y = s.substring(0, 4);
        if (y.equals("YAKI")) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 25172
n, k = map(int, input().split())
# from collections import OrderedDict
# d = OrderedDict()
# a = list(input().split())
# b = list(map(int, input().split()))
# print(r + max(0, 100*(10-n)))
# print("Yes" if 500*n >= k else "No") 
# s = input()
# a = int(input())
# b = int(input())
# c = int(input())
print("Yes" if n == k else "No")

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

int main()
{
    int i, j, k, n, mini, stable=1;
    
    scanf("%d", &n);
    
    char s[n][2], t[n][2], tempA, tempC;
    
    for(i=0; i<n; i++){
        scanf("%s", s[i]);
        for(j=0; j<2; j++)
        	t[i][j] = s[i][j];
    }
    //bubble 
    for (i=0; i<n-1; i++){
        for (j = n-1; j>=i+1; j--){
        	if (s[j][1]<s[j-1][1]){
				tempA = s[j][1];
            	s[j][1] = s[j-1][1];
            	s[j-1][1] = tempA;
            	
            	tempC = s[j][0];
            	s[j][0] = s[j-1][0];
            	s[j-1][0] = tempC;
        	}
    	}
    }
    //selection
    for (i=0; i<n-1; i++){
    	mini = i;
        for (j = i; j<n; j++){
        	if (t[j][1]<t[mini][1]){
				mini = j;
        	}
    	}
    	//swap
    	if (mini!=i){
    		tempA = t[i][1];
        	t[i][1] = t[mini][1];
        	t[mini][1] = tempA;

			tempC = t[i][0];
            t[i][0] = t[mini][0];
            t[mini][0] = tempC;
    	}
    }
    
    for(i=0; i<n; i++){
    	printf("%c%c", s[i][0], s[i][1]);
    	if(i<n-1)
    		printf(" ");
    	else 
    		printf("\n");
    }
    printf("Stable\n");
	
	for(i=0; i<n; i++){
    	printf("%c%c", t[i][0], t[i][1]);
    	if(i<n-1)
    		printf(" ");
    	else 
    		printf("\n");
    }
    
    for (i=0; i<n; i++){
		if (s[i][0]!=t[i][0])
			stable = 0;
    }
    
    if(stable)
    	printf("Stable\n");
    else printf("Not stable\n");
    
    return 0;
}




Measured memory_bytes: 2108
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto N = readln.chomp.to!int;
	auto K = readln.chomp.to!int;
	auto X = readln.chomp.to!int;
	auto Y = readln.chomp.to!int;
	if(N-K <= 0){
		writeln(N*X);
	}else{
		writeln(K*X + (N-K)*Y);
	}
}

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

using namespace std;
struct UnionFind {
    vector<int> data;
    int size;
    UnionFind(int N) : 
        data(N, -1), size(N) {}
    int root(int x){
        if(data[x] < 0) return x;
        return data[x] = root(data[x]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        size--;
        data[x] += data[y];
        data[y] = x;
    }
};

const int MOD = 1000000007;

int main(){
    int N, M;
    while(cin >> N >> M && N > 0){
        UnionFind uf(N);
        REP(i, M){
            int a, b;
            cin >> a >> b;
            a--; b--;
            uf.unite(a, b);
        }
        int s = uf.size;
        int ans = 1;
        REP(i, s) ans = (2LL * ans) % MOD;
        if(s < N) {
            ans = (ans + 1) % MOD;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1584
#include<algorithm>
#include<iostream>
#include<map>

#define MAX 1100


using namespace std;

struct Data
{
	int n1 , n2 , n3 , n4;
};


int main()
{
	Data data1 , data2;

	cin >> data1.n1 >> data1.n2 >> data1.n3 >> data1.n4;
	cin >> data2.n1 >> data2.n2 >> data2.n3 >> data2.n4;

	cout << max((data1.n1 + data1.n2 + data1.n3 + data1.n4) , (data2.n1 + data2.n2 + data2.n3 + data2.n4)) << endl;

	return 0;
}

Measured memory_bytes: 1160
# edges[src][dst] = cost
def bellman(start, n, edges)
    dist = Array.new(n+1, Float::INFINITY)
    prev = Array.new(n+1)
    dist[start] = 0
    n.times do |i|
        update = false
        edges.length.times do |src|
            edges[src].each do |dst, cost|
                if dist[dst] > dist[src] + cost
                    update = true
                    prev[dst] = src
                    if i == n - 1
                        dist[dst] = -Float::INFINITY
                    else
                        dist[dst] = dist[src] + cost
                    end
                end
            end
        end
        break unless update
    end
    return dist, prev
end

N, M = gets.split.map(&:to_i)
edges = Array.new(N+1){Hash.new}
M.times do |i|
    a, b, c = gets.split.map(&:to_i)
    edges[a][b] = -c
end

dist, _ = bellman(1, N, edges)
if dist[N] == -Float::INFINITY
    puts 'inf'
else
    puts -dist[N]
end

Measured memory_bytes: 2300
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return a*b // gcd(a,b)

n = int(input())
a = list(map(int,input().split()))
b = a[::-1]
l = [0]
r = [0]
for i in range(n):
    l.append(gcd(a[i],l[-1]))
    r.append(gcd(b[i],r[-1]))
r = r[::-1]
ans = 0
for i in range(n):
    ans = max(ans,gcd(l[i],r[i+1]))
print(ans)

Measured memory_bytes: 20760
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    P = [int(i) for i in input().strip().split()]

    ans = 0
    for i in range(len(P) - 1):
        if P[i] == i + 1:
            P[i + 1] = i + 1
            ans += 1
    if P[-1] == N:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19908
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, t;
    cin >> n >> t;
    double a;
    cin >> a;
    double mn = INF;
    int idx;
    for(int i = 1; i <= n; i++){
        int h;
        cin >> h;
        double s = (double)t - (double)h*0.006;
        s = abs(a-s);
        if(mn > s){
            mn = s;
            idx = i;
        }
    }
    cout << idx;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int r, c, n, x1, y1, x2, y2;
    vector<pii> a;
    vector<int> b = {0};
    cin >> r >> c >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        int z1 = -1, z2 = -1;
        if (!y1) z1 = x1;
        else if (x1 == r) z1 = r + y1;
        else if (y1 == c) z1 = r + c + r - x1;
        else if (!x1) z1 = r + c + r + c - y1;
        if (!y2) z2 = x2;
        else if (x2 == r) z2 = r + y2;
        else if (y2 == c) z2 = r + c + r - x2;
        else if (!x2) z2 = r + c + r + c - y2;
        if (z1 != -1 && z2 != -1) a.push_back({z1, i}), a.push_back({z2, i});
    }
    sort(a.begin(), a.end());
    for (pii i : a) {
        if (b.back() == i.second) b.pop_back();
        else b.push_back(i.second);
    }
    if (b.size() == 1) cout << "YES";
    else cout << "NO";
}


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

bool present[101];

int main(void)
{
    int x, n;
    cin >> x >> n;
    unordered_set<int> seq;

    for (int i = 0, x; i < n; i++)
    {
        cin >> x;
        seq.insert(x);
    }

    int ans = 0;
    int i = 0;
    while (true)
    {
        if (!seq.count(x - i))
        {
            ans = x - i;
            break;
        }
        if (!seq.count(x + i))
        {
            ans = x + i;
            break;
        }
        i++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
long pow(int k, int n)
{
  long ans = 1;
  while(n--) ans *= k;
  return ans;
}
int main(void)
{
  long ans = 0, tmp, len;
  char s[11];
  cin >> s;
  len = strlen(s);
  for(int i = 0; i < len; i++){
    for(int j = 0; j < len; j++){
      if(j < i)
        tmp = 0;
      else if(j == i)
        tmp = pow(2, i);
      else
        tmp = pow(2, j - 1);
      ans += tmp * pow(10, len - j - 1) * (int)(s[i] - '0');
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n, a, b;

i32 main()
{
	cin >> n >> a >> b;
	cout << max(0ll, (b*(n-1)+a)-(a*(n-1)+b)+1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  long double ans=0;
  for(long long int i=0; i<n; i++){
    long double x;
    string s;
    cin>>x>>s;
    if(s=="BTC"){
      ans+=x*380000.0;
    }else{
      ans+=x;
    }
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

struct LR{
    int l, r;

    LR() : l(-1), r(-1){}
    LR(int ll, int rr) : l(ll), r(rr){}
};

int main(){
    queue<LR> q;
    int n;      cin >> n;
    int h[101], ans = 0;

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

    int l[101], r[101];
    bool con = true;
    while(true){
        bool s = false;
        LR x;
        con = false;
        for(int i=0; i<n; ++i){
            //not found
            if(!s){
                if(h[i] > 0){
                    x.l = i;
                    s = !s;
                    con = true;
                }
            }
            else{
                if(h[i] == 0){
                    x.r = i;
                    q.emplace(x.l, x.r);
                    s = !s;
                }
            }
        }
        if(!con) break;
        if(s) q.emplace(x.l, n);

        int l2, r2, max = 0;
        while(!q.empty()){
            if(q.front().r - q.front().l > max){
                l2 = q.front().l; r2 = q.front().r;
                max = r2-l2;
            }
            q.pop();
        }
        
        for(int i=l2; i<r2; ++i){
            --h[i];
        }
        ++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

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

    b += a * 60;
    d += c * 60;
    d -= b;

    cout << max(0, d - e) << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

#define int ll
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    vint a(n); vin(a);
    vint l(n + 1, 0), r(n + 1, 0);
    rep(i, n) {
        l[i + 1] = l[i] + a[i];
    }
    for(int i = n - 1; i >= 0; -- i) {
        r[i] = r[i + 1] + a[i];
    }
    int ans = LLONG_MAX;
    repi(i, 1, n) {
        chmin(ans, (int)abs(l[i] - r[i]));
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
string a,b,c;
vector<char> v;
int dp[3001][3001];
int trace(int n,int m)
{
    if(n==0 || m==0){
        return 0;
    }
    if(a[n-1]==b[m-1]){
        c+=a[n-1];
        trace(n-1,m-1);
    }
    else if(dp[n-1][m]==dp[n][m]) trace(n-1,m);
    else trace(n,m-1);
}
int func(int i,int j)
{
    if(i==0 || j==0){
        return 0;
    }
    if(dp[i][j]!=0) return dp[i][j];
    if(a[i-1]==b[j-1]){
         return dp[i][j]= 1+func(i-1,j-1);
    }

    return dp[i][j]=max(func(i-1,j),func(i,j-1));
}
int main()
{
    cin>>a>>b;
    memset(dp,0,sizeof dp);
    int n=a.size();
    int m=b.size();
   // int ans = func(n,m);
   // cout<<ans;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i-1]==b[j-1]) dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }

    trace(n,m);
    for(int i=c.size()-1;i>=0;i--)
        cout<<c[i];
}


Measured memory_bytes: 35456
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdlib>
#include<stack>
#include<climits>
#include<vector>
#include<string>
#include<map>
using namespace std;
const int maxn = 1e5 + 10;
char s[maxn];
int main(){
    while(~scanf("%s", s)){
        int len=strlen(s);
        bool flag=false;
        for(int i=0; i<len-2&&!flag; i++){
            if(s[i]==s[i+1]){
                printf("%d %d\n",i+1,i+2);
                flag=true;
            }
            else if(s[i]==s[i+2]){
                printf("%d %d\n", i+1, i+3);
                flag=true;
            }
        }
        if(s[len-2]==s[len-1]&&!flag){
            printf("%d %d\n", len-1, len);
            flag=true;
        }
        if(!flag) printf("-1 -1\n");
    }
    return 0;
}


Measured memory_bytes: 384
A=int(input())
B=int(input())
C=int(input())
X=int(input())
n=0
for x in range(A+1):
    for y in range(B+1):
        for z in range(C+1):
            if 500*x+100*y+50*z==X:
                n+=1
print(n)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int data[4][13] = {};
	int i, j;
	char c, mark[4] = {'S', 'H', 'C', 'D'};
	int n, num;
	
	scanf("%d", &n);
	
	while (n--) {
		scanf(" %c %d", &c, &num);
		num--;
		
		switch(c) {
			case 'S': data[0][num] = 1; break;
			case 'H': data[1][num] = 1; break;
			case 'C': data[2][num] = 1; break;
			case 'D': data[3][num] = 1; break;
		}
	}
	
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 13; j++) {
			if (!data[i][j]) {
				printf("%c %d\n", mark[i], j + 1);
			}
		}
	}
	
	return 0;
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;

int main() {
	int N, answer = 0;
	scanf("%d", &N);
	if (N <= 9) {
		answer = N;
	}
	else if (N <= 99) {
		answer = 9;
	}
	else if (N <= 999) {
		answer = N - 90;
	}
	else if (N <= 9999) {
		answer = 909;
	}
	else if (N <= 99999) {
		answer = N - 9090;
	}
	else if (N == 100000) {
		answer = 90909;
	}
	printf("%d", answer);
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<long long> v(n+1), ans(n+1, 0);
    int u = 0;
    for (int i = 0; i < n; i++) cin >> v[i+1];
    for (int i = n; i > 0; i--) {
        long long sum = 0;
        for (int j = i; j <= n; j += i) {
            sum += ans[j];
        }
        if ((sum % 2) != v[i]) ans[i] = 1, u++;
    }
    cout << u << endl;
    int r = 0;
    for (int i = 1; i <= n; i++) {
        if (ans[i]) {
            if (r) cout << " ";
            cout << i;
            r++;
        }
    }
    assert(r == u);
    return 0;
}

Measured memory_bytes: 3968
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n, a, b = inl()
    if (b - a) % 2 == 0:
        return (b - a) // 2

    k = min(a - 1, n - b)
    return k + 1 + (b - a) // 2


print(solve())


Measured memory_bytes: 9144
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;


int main(){
    // input
    int H, A;
    cin >> H >> A;

    // calc
    int ans = H/A;
    if( H%A != 0 ) ans++;

    // out
    cout << ans << endl;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        // long K = sc.nextLong();
        int[] A = new int[N];
        boolean[] bool = new boolean[N];
        boolean res = true;
        for(int i=0; i<N; i++){
            A[i] = Integer.parseInt(sc.next());
            if(A[i] % 2 != 0){
                System.out.println(0);
                System.exit(0);
            }
        }
        int count = 0;
        boolean t = true;
        
        while(t){
            for(int i=0; i<N; i++){
                if(i == 0){
                    count += 1;
                }
                A[i] = A[i] / 2;
                if(A[i] % 2 != 0 ){
                    res = false;
                    break;
                }
            } 
            if(!res){
                break;
            }
        }
        System.out.println(count);
        sc.close();
    }
}      

Measured memory_bytes: 23636
def four_card?(cards)
  cards[0] == cards[3] || cards[1] == cards[4]
end

def full_house?(cards)
  (cards[0] == cards[1] && cards[2] == cards[4]) ||
  (cards[0] == cards[2] && cards[3] == cards[4])
end

def straight?(cards)
  cards[0] != cards[1] && cards[1] != cards[2] && cards[2] != cards[3] &&
  cards[3] != cards[4] &&
  (cards[4] - cards[0] == 4 || cards[0] == 1 && cards[1] == 10)
end

def three_card?(cards)
  cards[0] == cards[2] || cards[1] == cards[3] || cards[2] == cards[4]
end

def two_pair?(cards)
  (cards[0] == cards[1] && (cards[2] == cards[3] || cards[3] == cards[4])) ||
  (cards[1] == cards[2] && cards[3] == cards[4])
end

def one_pair?(cards)
  (cards[0] == cards[1]) || (cards[1] == cards[2]) ||
  (cards[2] == cards[3]) || (cards[3] == cards[4])
end

def hand(cards)
  return 'four card'  if four_card?(cards)
  return 'full house' if full_house?(cards)
  return 'straight'   if straight?(cards)
  return 'three card' if three_card?(cards)
  return 'two pair'   if two_pair?(cards)
  return 'one pair'   if one_pair?(cards)
  return 'null'
end

gets(nil).split.each do |line|
  cards = line.split(',').map(&:to_i).sort
  puts hand(cards)
end

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

int main() {
	int n;
	scanf("%d", &n);
	map <int, int> f;
	for(int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		f[x] += 1;
	}
	long long ans = 0;
	vector <int> good;
	for(auto i : f) {
		if(i.second >= 4) {
			ans = max(ans, 1LL * i.first * i.first);
		}
		if(i.second >= 2) {
			good.push_back(i.first);
		}
	}
	if(good.size() >= 2) {
		ans = max(ans, 1LL * good[good.size() - 2] * good[good.size() - 1]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define NIL NULL

struct node {
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;

Node root;

Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node, int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);


int main() {
  int n, i, j, x, count=0, *state;
  char com[20];
  Node t;
  
  scanf( "%d" , &n );
  state = malloc(n * sizeof(int));

  for ( i=0; i<n; i++ ) {
    scanf( "%s" , com );
    
    if ( com[0] == 'f' ) {
      scanf( "%d" , &x );
      t = treeSearch(root, x);
      if ( t != NIL ) state[count] = 1;
      else state[count] = 0;
      count++;
    }
    
    else if ( com[0] == 'i' ) {
      scanf( "%d" , &x );
      insert(x);
    }
    
    else if ( com[0] == 'p' ) {
      for ( j=0; j<count; j++ ) {
	if ( state[j] == 1 ) printf( "yes\n" );
	else printf( "no\n" );
      }
      count = 0;
      inorder(root);
      printf( "\n" );
      preorder(root);
      printf( "\n" );
    }
    
    else if ( com[0] == 'd' ) {
      scanf( "%d" , &x );
      treeDelete(treeSearch(root, x));
    }
  }
  for ( j=0; j<count; j++ ) {
    if ( state[j] == 1 ) printf( "yes\n" );
    else printf( "no\n" );
  }
  
  return 0;
}


Node treeMinimum(Node x){
  while ( x->left != NIL ) x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while ( x->right != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if ( (u == NIL) || (k == u->key) ) return u;
  if ( k < u->key ) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  
  if ( x->right != NIL ) return treeMinimum(x->right); // case 1
  y = x->parent;
  while ( (y != NIL) && (x == y->right) ) {
    x = y;
    y = y->parent;
  }
  return y; // case 2
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if ( (z->left == NIL) || (z->right == NIL) ) y = z;
  else y = treeSuccessor(z);

  if ( y->left != NIL ) x = y->left;
  else x = y->right;

  if ( x != NIL ) x->parent = y->parent;
  
  if ( y->parent == NIL ) root = x;
  else if ( y == y->parent->left ) y->parent->left = x;
  else y->parent->right = x;
  
  if ( y != z ) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key ) x = x->left;
    else x = x->right;
    z->parent = y;
  }
  if ( y == NIL ) root = z; // Tree is empty
  else if ( z->key < y->key ) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if ( u != NIL ) {
    inorder(u->left);
    printf( " %d" , u->key );
    inorder(u->right);
  }
}

void preorder(Node u){
  if ( u != NIL ) {
    printf( " %d" , u->key );
    preorder(u->left);
    preorder(u->right);
  }
}



Measured memory_bytes: 20832
import sys
input = sys.stdin.readline

roads = [tuple(map(int, input().split())) for _ in range(3)]

road_cnt = [0] * 4

for road in roads:
    a = road[0] - 1
    b = road[1] - 1
    road_cnt[a] += 1
    road_cnt[b] += 1

if max(road_cnt) == 3:
    print("NO")
else:
    print("YES")

    

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

int pri(int n)
{
  if (n % 2 == 0){
    cout << " " << 2;
    return n / 2;
  }
  for (int i = 3; i <= n / i; i += 2){
    if (n % i == 0){
      cout << " " << i;
      return n / i;
    }
  }

  cout << " " << n;
  return 1;
}

int main()
{
  int n;

  cin >> n;
  cout << n << ":";

  while(n != 1){
    n = pri(n);
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 1168
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
#define qwq
const int mod=1e9+7;
int dp[50][(1<<17)+7];
int n,x,y,z;
ll all_ans=1;
int main(){
	scanf("%d%d%d%d",&n,&x,&y,&z);
	int gdans=(1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));
	int limit=(1<<(x+y+z))-1;
	dp[0][0]=1;
	for(int i=1;i<=n;++i){
		all_ans*=10;
		all_ans%=mod;
		for(int s=0;s<=limit;++s){
			if((s&gdans)==gdans)continue;
			for(int c=1;c<=10;++c){
				int k=((s<<c)|(1<<(c-1)))&limit;
				if((k&gdans)==gdans)continue;
				dp[i][k]+=dp[i-1][s];
				dp[i][k]%=mod;
			}
		}
	}
	ll ans=0;
	for(int s=0;s<=limit;++s){
		ans+=dp[n][s];ans%=mod;
	}
	printf("%lld\n",(all_ans-ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 22212
using System;
using System.Collections.Generic;
using System.Linq;
 
class MainClass
{
    public static void Main()
    {
        var str = Console.ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .ToArray();
        var d = str[0];
        var n = str[1];
        if (d == 0)
        {
            if (n != 100)
            Console.WriteLine(n);
            else
            {
                Console.WriteLine(101);
            }
        }
        else if (d == 1)
        {
            if (n!= 100)
            Console.WriteLine(n * 100);
            else
            {
                Console.WriteLine(10100);
            }
        }
        else
        {
            if (n != 100)
            Console.WriteLine(n * 10000);
            else
            {
                Console.WriteLine(1010000);
            }
        }
        Console.ReadLine();
    }
}   

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int ans = 1;
  for (int i = 0; i < N - 1; i++) {
      if (vec.at(i) != vec.at(i + 1)) {
        ans++;
      }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 9600
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
 
    int ans = 0;
    for (int i = 0; i < 3; i++) {
      if (S.charAt(i) == T.charAt(i)) {
        ans++;
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int n;
	cin >> n;
	int a[n+1];
	LOOP(i,n){
		cin >> a[i+1];
	}
	int res[n+1];
	int resc = 0;
	for(int i=n; i>=1; i--){
		int cnt = 0;
		int j = i*2;
		while(j<=n){
			if(res[j])cnt++;
			j+=i;
		}
		if(cnt%2==a[i]){
			res[i]=0;
		}else{
			res[i]=1;
			resc++;
		}
	}
	cout << resc << endl;
	LOOP(i,n){
		if(res[i+1]==1)cout << i+1 << endl;
	}
}


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

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;

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

    ll ans = 1;
    if(abs(n-m) >= 2){
        cout << 0 << endl;
    }else{
        for(int i = 2; i <= n; i++){
            ans *= i;
            ans %= mod;
        }
        for(int i = 2; i <= m; i++){
            ans *= i;
            ans %= mod;
        }
        cout << (n == m ? ans * 2 % mod : ans) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

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

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

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BCardGameForTwo {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi A(n);
        in >> A;
        sort(A.rbegin(), A.rend());
        int res = 0;
        FOR(i, 0, n) {
            res += (i % 2 ? -1 : 1) * A[i];
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BCardGameForTwo solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
	int a[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	qsort(a,3,sizeof(int),compare_int);
	int ans = 0;
	ans += abs(a[0] - a[1]);
	ans += abs(a[1] - a[2]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    abc108c()
}

fun abc108c() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }

    val restZero = (1..n).count() { it % k == 0 }.toDouble()
    val restHalvedK = (if (k % 2 == 0) (1..n).count { it % k == k / 2 } else 0).toDouble()

    println(Math.pow(restZero, 3.0).toLong() + Math.pow(restHalvedK, 3.0).toLong())
}


Measured memory_bytes: 38652
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;


int main() {
    int x;
    cin>>x;
    vector<bool>a(100010,false);
    a[100]=true;
    a[101]=true;
    a[102]=true;
    a[103]=true;
    a[104]=true;
    a[105]=true;
    vector<int>b={100,101,102,103,104,105};
    for(int i=106;i<100009;i++){
        for(int j=0;j<6;j++){
            if(a.at(i-b.at(j))==true){
                a.at(i)=true;
            }
        }
    }
    if(a.at(x)==true){
        cout<<"1"<<endl;
    }
    else{
        cout<<"0"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
/*
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
*/

int main() {
	string S; cin >> S;
	int c0 = 0, c1 = 0;
	for (char c : S) {
		if (c == '0') c0++;
		else c1++;
	}
	cout << 2 * min(c0, c1) << endl;		
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define inf 9999999999999999
#define F first
#define S second
#define eb emplace_back
#define mpp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 50000
#define mod 1000000007
using namespace std;

int main(){//read(x);
//fast;
ll r,g,h,i,j,x,t,y,z=0,e,f,a,b,c,d,n,m,l,k;
string s;
cin>>s;
n=s.size();
cout<<s;
if(s[n-1]=='s')cout<<"es\n";
else cout<<"s\n";
}





















Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, max_a = 0, min_a = 1000000000, A;
    cin >> N;
    REP(i, N) {
        cin >> A;
        max_a = max(max_a, A);
        min_a = min(min_a, A);
    }
    cout << max_a - min_a << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    total = 0
    for i_a in a:
        total ^= i_a

    ans = []
    for i_a in a:
        now_ans = 0
        for i_bin in range(49):
            if i_a & (1 << i_bin) == 0:
                if total & (1 << i_bin) != 0:
                    now_ans += (1 << i_bin)
            else:
                if total & (1 << i_bin) == 0:
                    now_ans += (1 << i_bin)

        ans.append(str(now_ans))

    print(' '.join(ans))
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 109616
X,Y=map(int,input().split())
if (X+Y)%3!=0:
    print(0)
    exit()
mod=10**9+7
N=(X+Y)//3
'''
k*(1,2)+(n-k)*(2,1)=(x,y)
(k+2n-2k,2k+n-k)=(x,y)
(2n-k,n+k)=(x,y)
2y=2n+2k
x=2n-k
2y-x=3k
'''
K=(2*Y-X)//3
if not(0<=K<=N):
    print(0)
    exit()
ans=1
for i in range(1,K+1):
    ans*=(N+1-i)*pow(i,mod-2,mod)
    ans%=mod
print(ans)


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


//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%.15lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = 1e18;
const ll SIZE = 1e5+5;
const ll mod = 1e9+7;


ll pow2[40];
//map <ll, bool> is_pow;
void cal_pow2() {
    ll i, x = 1, y;
    for0(i, 35) {
//        y = x - 1; ///TO CALCULATE 2^N - 1
        y = x; ///TO CALCULATE 2^N
        pow2[i] = y;
//        is_pow[y] = 1;
        x *= 2;
    }
}

int main() {
    cal_pow2();
    ll t = 0, n, x, y, z, i, j, k, g, p, q, sum = 0, c = 0;
    string s, s1, s2;

    scl2(n, k);
    double ans = 0.0;

    for1(x, n) {
        c = 0;
        y = x;

        while(y < k) {
            c++;
            y *= 2;
        }

        double prob = (double) (1.0 / (n * pow2[c]));
        ans += prob;
    }

    printd(ans);

    return 0;
}



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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B;
	string s;
	
	cin>>A>>B;
	
	cin>>s;
	
	if(s.size() != A + B + 1){
		 cout<<"No"<<endl;
	} else if(s[A] != '-'){
		cout<<"No"<<endl;
	} else {
		for(int i = 0; i < A; i++){
			if(!('0' <= s[i] && s[i] <= '9')){
				cout<<"No"<<endl;
				return 0;
			}
		}
		for(int i = 0; i < B; i++){
			if(!('0' <= s[A+1+i] && s[A+1+i] <= '9')){
				cout<<"No"<<endl;
				return 0;
			}
		}
		
		cout<<"Yes"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPLL(i, n) for(ll i = 0;i < (n);++i)

#define endl "\n"
#define pb push_back
#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int N, C, s[100000], t[100000], c[100000];
	cin >> N >> C;
	int sum[200002], cnt[200002] = {0};
	REP(i, N) cin >> s[i] >> t[i] >> c[i];
	REP(i, C){
		REP(j, 200002) sum[j] = 0;
		REP(j, N){
			if(c[j]==i+1){
				sum[s[j]*2-1]++; sum[t[j]*2]--;
			}
		}
		for (int j = 1; j < 200002; j++) {
			sum[j] += sum[j-1];
		}
		REP(j, 200002) if(sum[j] > 0) cnt[j]++;
	}
	int ans = -1;
	REP(i, 200002) ans = max(ans, cnt[i]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    x = int(n**0.5)

    a = 0
    for i in range(x, 0, -1):
        if n % i == 0:
            a = i
            break
    b = int(n / a)
    print(a + b - 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
import sys
input = sys.stdin.readline

def make_divisors(n):
    div_num = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div_num += 1
            if i != n // i:
                div_num += 1
    return div_num

ans = [1166714, 2472071, 3829761, 5221424, 6638407, 8075420, 9529244, 10997400, 12478098]

n = int(input())
keta = 0
for j in range(1, 10+1):
  if n <= j*100000:
    keta = j-1
    break
if keta == 0:
  count = 0
else:
  count = ans[keta-1]
for i in range(max(keta*100000,1), n):
  count += make_divisors(i)
print(count)

Measured memory_bytes: 68716
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
  auto dp = new bool[](3000001);
  dp[1] = 1;
  foreach (i; 1..500001) {
    if (dp[i]) {
      dp[i*2] = dp[i*3] = dp[i*5] = 1;
    }
  }
  foreach (line; stdin.byLine) {
    auto x = line.chomp.split.map!(to!int);
    if (x.length == 1) break;
    int cnt;
    foreach (i; x[0]..x[1]+1) {
      if (dp[i]) cnt++;
    }
    cnt.writeln;
  }
}

Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
#define min(a,b) ((a>b)?b:a)
int main()
{
  int n;
  cin>>n;
  vector<int> dp;
  dp.push_back(0);
  for(int i=1;i<=n;i++){
    int a=dp[i-1]+1;
    if(i>=6) {
      int b=dp[i-6]+1;
      a=min(b,a);
    }
    if(i>=36) {
      int b=dp[i-36]+1;
      a=min(b,a);
      
    }
    if(i>=216) {
      int b=dp[i-216]+1;
      a=min(b,a);
    }
    if(i>=1296) {
      int b=dp[i-1296]+1;
      a=min(b,a);
    }
    if(i>=7776) {
      int b=dp[i-7776]+1;
      a=min(b,a);
    }
    if(i>=46656) {
      int b=dp[i-46656]+1;
      a=min(b,a);
    }
    if(i>=9) {
      int b=dp[i-9]+1;
      a=min(b,a);
    }
    if(i>=81) {
      int b=dp[i-81]+1;
      a=min(b,a);
      
    }
    if(i>=729) {
      int b=dp[i-729]+1;
      a=min(b,a);
    }
    if(i>=6561) {
      int b=dp[i-6561]+1;
      a=min(b,a);
    }
    if(i>=59049) {
      int b=dp[i-59049]+1;
      a=min(b,a);
    }
    dp.push_back(a);
  }
  cout<<dp[n];
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    string s, t;
    cin >> s >> t;

    rep(i,n)cout << s[i] << t[i];
    cout << 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);
    long n = sc.nextLong();
    long[] a = new long[6];
    int index = 0;
    long min = Long.MAX_VALUE;
    for(int i = 1; i <= 5; i++){
      a[i] = sc.nextLong();
      if(min > a[i]){
        min = a[i];
        index = i;
      }
    }
    System.out.println((long)(Math.ceil(n / (double)min)) + 4);
  }
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
#include<vector>


int main(){
    int N;
    std::cin >> N;
    std::vector<int> P(N), Q(N);
    for(int i = 0; i < N; i++){
        std::cin >> P[i];
        P[i]--; // to 0 origin
    }
    for(int i = 0; i < N; i++){
        std::cin >> Q[i];
        Q[i]--; // to 0 origin
    }

    std::vector<int> order(N);
    int a, b;
    int cnt = 0;
    for(int i = 0; i < N; i++) order[i] = i;
    do{
        cnt++;
        bool a_flag = true;
        bool b_flag = true;
        for(int i = 0; i < N; i++){
            if(order[i] != P[i]) a_flag = false;
            if(order[i] != Q[i]) b_flag = false;
        }
        
        if(a_flag) a = cnt;
        if(b_flag) b = cnt;
    }while(std::next_permutation(order.begin(), order.end()));

    std::cout << std::abs(a - b) << std::endl;
    return 0;
}

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



//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}

//最小公倍数
template<class T> T lcm(T a, T b)
{
  // cout << gcd(a, b) << endl;
	return a / gcd(a, b)*b;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = lcm(a,b);
  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = Long.parseLong(sc.next());
    
    long min = N-1;
    long sqrt = (long)Math.sqrt(N);
    for(long i=2;i<=sqrt;i++){
      if(N%i==0){
        if(i-1+N/i-1<min){
          min = i-1+N/i-1;
        }
      }
    }
    System.out.print(min);
    System.out.flush();
  }
}

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

int main(){
  int n,d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i,n){
    rep(j,d) cin >> x[i][j];
  }
  int ans = 0;
  rep(i,n) rep(j,i){
      int sq=0;
      rep(k,d){
        int s = x[i][k]-x[j][k];//差
        sq+=s*s;
      }
      int s=sqrt(sq)+0.5;//intのcast(型変換)は切り捨てなので、四捨五入のための+0.5。ex)1.9999は切り捨てされると1になる
      if (s*s==sq) ans++;
  }
    cout << ans << endl;
}


Measured memory_bytes: 256