akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a >> b;
   if(a == b){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
inline int read()
{
	int k=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) k=k*10+c-'0';return f*k;
}
const int N=100055;
map<int,int> mp;
int n,m,tot,a[N],b[N],c[N],d[N],as,fa[N<<1];
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),a[n+1]^=a[i];
	for(int i=1;i<=n;i++)
		b[i]=read(),b[n+1]^=b[i];
	n++;
	for(int i=1;i<=n;i++)
		c[i]=a[i],d[i]=b[i];
	sort(c+1,c+1+n);sort(d+1,d+1+n);
	for(int i=1;i<=n;i++)
		if(c[i]!=d[i])
			{puts("-1");return 0;}
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i]||i==n)
		{
			if(i<n) as++;
			if(!mp[a[i]]) mp[a[i]]=++tot;
			if(!mp[b[i]]) mp[b[i]]=++tot;
		}
	if(!as) {puts("0");return 0;}
	for(int i=1;i<=tot;i++)
		fa[i]=i;
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i])
			fa[find(mp[a[i]])]=find(mp[b[i]]);
	for(int i=1;i<=tot;i++)
		if(fa[i]==i)
			as++;
	printf("%d\n",as-1);
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int z = __gcd(a, b);
    int count=0;
    for (int i = z; i >=1; --i) {
        if(z%i==0)
        {
            count++;
            if(count==k)
            {
                cout<<i;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

cnt=0
ans=0

for i in range(n):
    if a[i]<0:
        cnt+=1
        a[i]*=-1



if cnt%2==0:
    ans=sum(a)

else:
    ans=sum(a)-2*min(a)

print(ans)


Measured memory_bytes: 19984
#include<stdio.h>
int main()
{
    long long n,sum=0,T,max,min;
    scanf("%lld",&T);
    for(int i=1; i<=T; i++)
    {
        scanf("%lld ",&n);
        if(i==1)
            max=min=n;
        if(max<n)
            max=n;
        else if(min>n)
            min=n;
        sum=sum+n;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2104
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    if 30 <= N:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9916
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if(s < t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,a,b,c,x[8],y[24];
    for(i=0;i<6;i++){
        scanf("%d",&x[i+1]);
    }
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d%d",&b,&c);
        if(b==x[1]){
            if(c==x[2])y[i]=x[3];
            if(c==x[3])y[i]=x[5];
            if(c==x[5])y[i]=x[4];
            if(c==x[4])y[i]=x[2];
        }
        if(b==x[2]){
            if(c==x[3])y[i]=x[1];
            if(c==x[1])y[i]=x[4];
            if(c==x[4])y[i]=x[6];
            if(c==x[6])y[i]=x[3];
        }
        if(b==x[3]){
            if(c==x[2])y[i]=x[6];
            if(c==x[6])y[i]=x[5];
            if(c==x[5])y[i]=x[1];
            if(c==x[1])y[i]=x[2];
        }
        if(b==x[4]){
            if(c==x[2])y[i]=x[1];
            if(c==x[1])y[i]=x[5];
            if(c==x[5])y[i]=x[6];
            if(c==x[6])y[i]=x[2];
        }
        if(b==x[5]){
            if(c==x[1])y[i]=x[3];
            if(c==x[3])y[i]=x[6];
            if(c==x[6])y[i]=x[4];
            if(c==x[4])y[i]=x[1];
        }
        if(b==x[6]){
            if(c==x[5])y[i]=x[3];
            if(c==x[3])y[i]=x[2];
            if(c==x[2])y[i]=x[4];
            if(c==x[4])y[i]=x[5];
        }
    }
    for(i=0;i<a;i++){
        printf("%d\n",y[i]);
    }
    return 0;
}

Measured memory_bytes: 596
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        while (true)
        {
            int n = int.Parse(Console.ReadLine());
            if (n == 0)
            {
                break;
            }
            string[] input = Console.ReadLine().Split(' ');
            int[] income = new int[n];
            double avg = 0;
            for (int i = 0; i < n; i++)
            {
                income[i] = int.Parse(input[i]);
                avg += income[i];
            }
            avg = (double)avg / n;
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                if (income[i] <= avg)
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 16864
#include <cstdio>

int main(){
	int c1,c2,c3;
	bool mem[11];
	while(scanf("%d%d%d",&c1,&c2,&c3) != EOF){
		for(int i = 0; i < 11; i++) mem[i] = false;
		mem[c1] = mem[c2] = mem[c3] = true;
		int ok = 0;
		for(int i = 1; i <= 10; i++){
			if(!mem[i] && c1 + c2 + i <= 20){
				ok++;
			}
		}
		printf("%s\n", ok >= 4 ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 2536
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}
int n,m;
int k;
unordered_map<int,int>mp[N];
int x[N],y[N];
void input()
{
	n=read<int>(),m=read<int>();
	k=read<int>();
	For(i,1,k)
	{
		x[i]=read<int>(),y[i]=read<int>();
		mp[x[i]][y[i]]=1;
	}
}
int ans;
int f[N],g[N];
void work()
{
	ans=n;
	g[1]=1;
	For(i,2,n)
	{
		if(!mp[i][g[i-1]+1])g[i]=g[i-1]+1;
		else g[i]=g[i-1];
	}
	For(i,1,k)if(g[x[i]-1]>=y[i])cmin(ans,x[i]-1);
	
	write(ans,'\n');
}
int main()
{
	input();
	work();
	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> t;
vector<int> kivesz;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    k++;
    t.resize(n);
    for(int i=0; i<n; i++)
    {
        cin>>t[i];
    }
    priority_queue<pair<int, int> > w;
    int sum=0;
    for(int i=0; i<n; i++)
    {
        if(k-t[i]>0)
        {
            w.push({k-t[i], i+1});
            sum+=(k-t[i]);
        }
    }
    if(sum>=k)
    {
        cout<<-1<<endl;
        return 0;
    }
    if(w.size()>0 && w.top().first>k/2)
    {
        cout<<-1<<endl;
        return 0;
    }
    int tilt=-1;

    while(w.size()>0)
    {
        auto akt1=w.top();
        w.pop();
        if(w.size()>0)
        {
            auto akt2=w.top();
            w.pop();
            if(tilt!=akt1.second)
            {
                kivesz.push_back(akt1.second);
                akt1.first--;
                if(akt1.first>0)
                {
                    w.push({akt1});
                }
                w.push(akt2);
                tilt=akt1.second;
            }
            else
            {
                kivesz.push_back(akt2.second);
                akt2.first--;
                if(akt2.first>0)
                {
                    w.push({akt2});
                }
                w.push(akt1);
                tilt=akt2.second;
            }
        }
        else
        {
            if(tilt!=akt1.second)
            {
                kivesz.push_back(akt1.second);
                akt1.first--;
                if(akt1.first>0)
                {
                    w.push({akt1});
                }
                tilt=akt1.second;
            }
            else
            {
                int uj=1;
                if(akt1.second==1) uj=2;
                kivesz.push_back(uj);
                tilt=uj;
                w.push(akt1);
            }
        }
    }
    if(kivesz.size()>k-1)
    {
        cout<<-1<<endl;
        return 0;
    }
    while(kivesz.size()!=k-1)
    {
        if(kivesz.size()==0 || kivesz.back()==1)
        {
            kivesz.push_back(2);
        }
        else
        {
            kivesz.push_back(1);
        }
    }
    int tiltott=-1;
    vector<int> ans;
    for(int i=0; i<kivesz.size(); i++)
    {
        for(int j=1; j<=n; j++)
        {
            if(j!=tiltott && j!=kivesz[i]) ans.push_back(j);
        }
        ans.push_back(kivesz[i]);
        tiltott=kivesz[i];
    }
    for(int i=1; i<=n; i++)
    {
        if(i!=tiltott) ans.push_back(i);
    }
    cout<<ans.size()<<endl;
    for(int i=0; i<ans.size(); i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n;cin>>n;
	cout<<(n*(n+1))/2<<endl;
	return 0;
}

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


int main(){

    int N;
    string s;
    cin >> N;
    cin >> s;


    int si;
    int count_R;
    string target;
    count_R = 0;
    for(si=0;si< N;si++){
        target = s.substr(si,1);
        if(target == "R"){
            count_R = count_R + 1;
        }
    }
    if(count_R > N - count_R){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> a(n);
    int m = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    vector<int> tp;
    tp.push_back(a[0]);
    for(int i = 1; i < n; ++i){
        auto aa = lower_bound(rbegin(tp), rend(tp), a[i]) - tp.rbegin();
        if(lower_bound(rbegin(tp), rend(tp), a[i]) == tp.rbegin() && *rbegin(tp) >= a[i]){
            tp.push_back(a[i]);
        }
        else{
            for(int j = 0; j < tp.size(); ++j)
            {
                if(tp[j] < a[i]){
                    tp[j] = a[i];
                    break;
                }
            }
        }
    }
    cout << tp.size() << "\n";
    return 0;
}

Measured memory_bytes: 1276
import sys

sys.setrecursionlimit(200000)


def f_dfs(i):
    global f_edges, counter
    visited[i] = True
    for edge in f_edges[i]:
        if visited[edge]:
            continue
        f_dfs(edge)
    finish_order[i] = (counter, i)
    counter += 1


def b_dfs(i, group):
    global b_edges, groups
    visited[i] = True
    groups[i] = group
    for edge in b_edges[i]:
        if visited[edge]:
            continue
        b_dfs(edge, group)


n, m = map(int, input().split())

f_edges = [set() for _ in range(n)]
b_edges = [set() for _ in range(n)]

for _ in range(m):
    s, t = map(int, input().split())
    f_edges[s].add(t)
    b_edges[t].add(s)

visited = [False] * n
finish_order = [None] * n
counter = 0

for i in range(n):
    if not visited[i]:
        f_dfs(i)

visited = [False] * n
groups = [None] * n
group = 0

for d, i in sorted(finish_order, reverse=True):
    if not visited[i]:
        b_dfs(i, group)
        group += 1

q = int(input())

while q:
    q -= 1
    u, v = map(int, input().split())
    print(int(groups[u] == groups[v]))

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

int calc(vector<int> d,int N){
    int ans=1;
    for(int i=0;i<N;i++){
        if(d[i]<d[i+1]){
            ans++;
        }
    }
    return ans;
}

int main(){
    int N; cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    sort(d.begin(),d.end());
    int ans=0;
    ans=calc(d,N);
    cout<<ans;
}

Measured memory_bytes: 256
// finish date: 2018/06/16
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000

int cnt_div2(int n) {
    int cnt = 0;
    while (n % 2 == 0) {
        n /= 2;
        cnt++;
    }
    return cnt;
}


int main() {
    int N;
    cin >> N;
    vi a(N);
    int cnt = 0;
    rep(i, N) {
        cin >> a[i];
        cnt += cnt_div2(a[i]);
    }
    cout << cnt << endl;


    return 0;
}






Measured memory_bytes: 256
import numpy as np

N_M = input()
N = int(N_M.split(" ")[0])
M = int(N_M.split(" ")[1])

input_list = []
for i in range(M):
	input_list.append(tuple(input().split(" ")))

AC_list = np.zeros(N, dtype=bool)
WA_list = np.zeros(N, dtype=int)

for data in input_list:

	if data[1] == 'AC':
		AC_list[int(data[0]) - 1] = True
		if WA_list[int(data[0]) - 1] > 0:
			WA_list[int(data[0]) - 1] = -1 * WA_list[int(data[0]) - 1]

	if data[1] == 'WA':
		if not AC_list[int(data[0]) - 1]:
			WA_list[int(data[0]) - 1] += 1

print(np.count_nonzero(AC_list), np.sum((WA_list < 0) * WA_list) * -1)


Measured memory_bytes: 31904
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$n = $sc->nextInt();

//$arr = [];
//for ($i = 0; $i < $n; $i++) {
//    $arr[$i] = $i + 1;
//}
//
//$arr2 = $arr;
//
//$key = 0;
//$cnt_max = 0;
//for ($i = 0; $i < count($arr2); $i++) {
//    $cnt = 0;
//    while ($arr2[$i] % 2 === 0) {
//        $arr2[$i] /= 2;
//        $cnt++;
//    }
//    if ($cnt_max <= $cnt){
//        $cnt_max = $cnt;
//        $key = $i;
//    }
//}
//
//echo $arr[$key];

/* other solution */
$ref = [1,2,4,8,16,32,64];
arsort($ref);
$res = 0;
for ($i = 0; $i < count($ref); $i++) {
    if($n >= $ref[$i]) {
        $res = $ref[$i];
    }
}
    
echo $res;



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

double pow2(double x);

int main(void)
{
    double x1, y1, x2, y2, x3, y3;
    double xx1, yy1, xx2, yy2, xx3, yy3;

    double a1, b1, c1, a2, b2, c2;

    double xp, yp;
    double xxp, yyp;
    double r;

    int n;
    scanf("%d", &n);

    int i;
    for (i = 1; i <= n; i++) {
        scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
        xx1 = pow2(x1);
        yy1 = pow2(y1);
        xx2 = pow2(x2);
        yy2 = pow2(y2);
        xx3 = pow2(x3);
        yy3 = pow2(y3);

        a1 = 2 * (x2 - x1);
        b1 = 2 * (y2 - y1);
        c1 = xx1 - xx2 + yy1 - yy2;
        a2 = 2 * (x3 - x1);
        b2 = 2 * (y3 - y1);
        c2 = xx1 - xx3 + yy1 - yy3;

        xp = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
        yp = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);

        xxp = pow2(xp);
        yyp = pow2(yp);

        r = sqrt(pow2(xp - x1) + pow2(yp - y1));

        printf("%.3f %.3f %.3f\n", xp, yp, r);
    }

    return 0;
}

double pow2(double x)
{
    return x * x;
}

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

int main() {
    int64_t A, B, C, D;
    cin >> A >> B >> C >> D;

    int64_t ans = B - A + 1;
    ans -= (B / C) - (A - 1) / C;
    ans -= (B / D) - (A - 1) / D;
    int64_t lcm = C * D / __gcd(C, D);
    ans += (B / lcm) - (A - 1) / lcm;
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  rep (i, S.size()) {
    cout << 'x';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3608
N, M = map(int, input().split())
A, B = (
    zip(*(map(int, input().split()) for _ in range(M))) if M else
    ((), ())
)

# グラフが二部グラフならば二集合間に辺を張れる
# そうでなければ完全グラフになるように辺を張れる
G = [set() for _ in range(N + 1)]
for x, y in zip(A, B):
    G[x].add(y)
    G[y].add(x)
dp = [0 for _ in range(N + 1)]
q = []
q.append(1)
dp[1] = 1
is_bi = True
while q:
    i = q.pop()
    for j in G[i]:
        if dp[j] == 0:
            dp[j] = -dp[i]
            q.append(j)
        else:
            is_bi &= dp[j] == -dp[i]
ans = (
    sum(x == 1 for x in dp) * sum(x == -1 for x in dp) - M if is_bi else
    N * (N - 1) // 2 - M
)

print(ans)


Measured memory_bytes: 57468
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

let lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
    const x = Number(lines[0]);
    console.log(Math.pow(x, 3))
});


Measured memory_bytes: 20372
import sys
N = input()
TA = input()
T, A = TA.split()
Hinp = input()
H = Hinp.split()
ansnum = None
ans = 0
def getdiff(A, ans):
    return abs(max(ans, A) - min(ans, A))
def chk(A, _ans, ans):
    new_d, old_d = getdiff(A, _ans), getdiff(A, ans)
    if new_d < old_d:
        return True
    return False
def showans(ans):
    print(ans)
    sys.exit()
for i, x in enumerate(H):
    _ans = int(T) - int(x) * 0.006
    if _ans == A:
        showans(i+1)
    if not ansnum or chk(int(A), _ans, ansnum):
        ans = i+1
        ansnum = _ans
showans(ans)

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

from collections import deque

q = deque()

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())

ch -= 1
cw -= 1
dh -= 1
dw -= 1

ban_list = [[-999 for j in range(w)] for i in range(h)]


for i in range(h):
  # 文字列の入力
  s = input()
  for j in range(len(s)):
    ban_list[i][j] = s[j]


ban_list[ch][cw] = 0

cost = 0
ph = ch
pw = cw

q.append([ph, pw])

# 上右下左
ido_h = [-1, 0, 1, 0]
ido_w = [0, 1, 0, -1]

while q:
  ph, pw = q.popleft()
  cost = ban_list[ph][pw]

  for i in range(4):
    nh = ph + ido_h[i]
    nw = pw + ido_w[i]

    if nh < 0 or h -1 < nh or nw < 0 or w -1 < nw:
      continue
    val = ban_list[nh][nw]
    if val == "#" or val == cost:
      continue
    if val == "." or cost < val:
      ban_list[nh][nw] = cost
      q.appendleft([nh, nw])



  # # 上
  # if ph == 0:
  #   pass
  # else:
  #   if ban_list[ph-1][pw] != "#" and ban_list[ph-1][pw] != cost:
  #     if ban_list[ph-1][pw] == "." or cost < ban_list[ph-1][pw]:
  #       ban_list[ph-1][pw] = cost
  #       # appendだとrandom_02.txtがWAになる
  #       q.appendleft([ph-1, pw])
  #   else:
  #     pass

  # # 右
  # if pw == w -1:
  #   pass
  # else:
  #   if ban_list[ph][pw + 1] != "#" and ban_list[ph][pw + 1] != cost:
  #     if ban_list[ph][pw + 1] == "." or cost < ban_list[ph][pw + 1]:
  #       ban_list[ph][pw + 1] = cost
  #       q.appendleft([ph, pw+1])
  #   else:
  #     pass

  # # 下
  # if ph == h -1:
  #   pass
  # else:
  #   if ban_list[ph+1][pw] != "#" and ban_list[ph+1][pw] != cost:
  #     if ban_list[ph+1][pw] == "." or cost < ban_list[ph+1][pw]:
  #       ban_list[ph+1][pw] = cost
  #       q.appendleft([ph+1, pw])
  #   else:
  #     pass

  # # 左
  # if pw == 0:
  #   pass
  # else:
  #   if ban_list[ph][pw - 1] != "#" and ban_list[ph][pw - 1] != cost:
  #     if ban_list[ph][pw - 1] == "." or cost < ban_list[ph][pw - 1]:
  #       ban_list[ph][pw - 1] = cost
  #       q.appendleft([ph, pw-1])
  #   else:
  #     pass


  # ジャンプ--------------
  for i in range(-2, 3):
    if (ph + i < 0) or (h - 1 < ph + i):
      continue

    for j in range(-2, 3):
      if (pw + j < 0) or (w - 1 < pw + j) or (i==0 and j == 0) or (i==0 and j == -1) or (i==0 and j == 1) or (i==-1 and j == 0) or (i==1 and j == 0):
        continue
      if ban_list[ph + i][pw + j] == ".":
        ban_list[ph + i][pw + j] = cost + 1
        q.append([ph + i, pw + j])


result = ban_list[dh][dw]
if result == ".":
  result = -1


print(result)


Measured memory_bytes: 182884
#include<iostream>
using namespace std;
int main (){
    int a,b,c;
int x=0;
int y=0;

cin>>a>>b>>c;
x=b-a;
y=c-b;
 if (x==y){
    cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<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 REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;

	int ans = 0;
	rep(i, n) {
		set<char> s;
		s.insert(a[i]);
		s.insert(b[i]);
		s.insert(c[i]);
		ans += s.size() - 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll a,b,c,i,j,k,m,n;
int main()
{
    scanf("%lld",&a);
    if(a%2==0)
        printf("%lld",a/2-1);
    else
        printf("%lld",a/2);
    return 0;
}


Measured memory_bytes: 256
// ITP1_8_D Ring
import java.io.*;
 
class Main {
 
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
      try {
         String s = br.readLine();
         String p = br.readLine();
         s = s + s;
         if (s.indexOf(p) != -1)
            System.out.println("Yes");
         else
            System.out.println("No");
      }
 
      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 24452
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
const ll inf = 1e18;

void solve(){
	ll n, w, sum = 0, ans = 0; cin>>n>>w;
	ll a[n][2];
	f(i,n) cin>>a[i][0]>>a[i][1], sum += a[i][1];
	vector<ll> v(sum+1,0), tmp(sum+1,0);
	for(int i=1;i<=sum;i++) tmp[i] = inf;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=sum;j++){
			if(j >= a[i-1][1]){
				v[j] = min(tmp[j], a[i-1][0] + tmp[j-a[i-1][1]]);
			}
			else v[j] = tmp[j];
		}
		f(j,sum+1) tmp[j] = v[j];
	}
	for(int i=sum;i>=0;i--){
		if(v[i] <= w){
			ans = i;
			break;
		}
	}
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int s[101]={0};
    
    int ans = 0;
    for(int i=a; i<b; i++) s[i]=1;
    for(int i=c; i<d; i++)
        if(s[i]>0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
(stdin => {
  // Define Function

  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const [w, h, x, y, r] = Array.from(inputs[0].split(' '), Number)

  if ((x - r >= 0 && x + r <= w) && (y - r >= 0 && y + r <= h)) {
    console.log('Yes')
  } else {
    console.log('No')
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'))



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

int main() {
  ll n, m;
  cin >> n >> m;
  if (2 * n <= m) {
    cout << n + (m - 2 * n) / 4 << endl;
  } else {
    cout << m / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
class Dice:
    def __init__(self, init_values = ['1','2','3','4','5','6']):
        self.value = dict(zip(["top", "front","right","left","back","bottom"]\
                             , init_values))

    #north, south, east and west
    def roll(self, direction):
        if direction == 'N':
            self.value["top"], self.value["front"], self.value["bottom"], self.value["back"] = \
            self.value["front"], self.value["bottom"], self.value["back"], self.value["top"]
        elif direction == 'S':
            self.value["top"], self.value["back"], self.value["bottom"], self.value["front"] = \
            self.value["back"], self.value["bottom"], self.value["front"], self.value["top"]
        elif direction == 'E':
            self.value["top"], self.value["left"], self.value["bottom"], self.value["right"] = \
            self.value["left"], self.value["bottom"], self.value["right"], self.value["top"]
        elif direction == 'W':
            self.value["top"], self.value["right"], self.value["bottom"], self.value["left"] = \
            self.value["right"], self.value["bottom"], self.value["left"], self.value["top"]
        else:
            print("Error: illegal format.")

    # clockwise, counterclockwise
    def spin(self, direction):
        if direction == "CW":
            self.value["front"], self.value["right"], self.value["back"], self.value["left"] = \
            self.value["right"], self.value["back"], self.value["left"], self.value["front"]
        elif direction == "CCW":
            self.value["front"], self.value["left"], self.value["back"], self.value["right"] = \
            self.value["left"], self.value["back"], self.value["right"], self.value["front"]
        else:
            print("Error: illegal format.")

    def is_same(self, other_dice):
        for direction in 'SESESE':
            other_dice.roll(direction)
            if self.value["top"] == other_dice.value["top"]:
                for j in range(4):
                    other_dice.spin("CW")
                    if self.value == other_dice.value:
                        return True
        return False

n = int(input())
dice_arr = []
for i in range(n):
    dice_arr.append(Dice(input().split()))

result = "Yes"
for i in range(len(dice_arr)-1):
    for j in range(i+1,len(dice_arr)):
        if dice_arr[i].is_same(dice_arr[j]):
            result = "No"
            break
    if result == "No":
        break

print(result)

Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int x;
    cin >> x;
    int ans = 1;
    for (int i = 2; i < 50; i++)
    {
        int temp = i*i;
        while(temp <=x)
        {
            ans = max(ans,temp);
            temp *= i;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,x,y,ans;
  cin>>a>>b>>c>>x>>y;
  ans=0;
  if(a+b>c*2)
  {
    int m=min(x,y),num,price;
    ans+=m*2*c;
    x-=m,y-=m;
    price=x==0?b:a;
    num=max(x,y);
      
    if(price>c*2)
      ans+=num*2*c,x=0,y=0;
  }
  
  ans+=x*a+y*b;
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,ans,val[100005],ban[100005];
vector<int>g[100005];
int dfs(int x,int p,int dep){
	int got=0;
	for(auto to:g[x])if(to!=p&&!ban[to]&&to!=-1){
		int v=dfs(to,x,dep^1);ans+=abs(v);got+=v;
	}
	if(dep&1)got-=val[x];
	else got+=val[x];
	return got;
}
void solve_tree(){
	if(dfs(1,-1,0)){
		cout<<-1<<endl;
		return;
	}
	cout<<ans<<endl;
}
vector<int>cyc;
bool vis[100005];
int par[100005],col[100005],cnt[2];
void go(int x,int p,int dep){
	par[x]=p;cnt[dep&1]++;col[x]=dep&1;vis[x]=1;
	for(auto to:g[x]){
		if(to!=p){
			if(vis[to]){
				if(cyc.size())continue;
				int cur=x;
				while(cur!=to){
					cyc.push_back(cur);
					cur=par[cur];
				}
				cyc.push_back(cur);
			}else{
				go(to,x,dep+1);
			}
		}
	}
}
signed main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i=1;i<=n;i++)val[i]=1;
	if(m==n-1){
		solve_tree();
		return 0;
	}else{
		go(1,0,0);
		if(cyc.size()%2==0){
			//even circle
			for(auto vv:cyc)ban[vv]=1;
			vector<int>dat;
			for(auto vv:cyc){
				dat.push_back(dfs(vv,0,col[vv]));
			}
			for(int i=1;i<dat.size();i++)dat[i]+=dat[i-1];
			if(dat.back()){
				puts("-1");
				return 0;
			}
			sort(dat.begin(),dat.end());
			for(int i=0;i<dat.size()/2;i++)ans-=dat[i];
			for(int i=dat.size()/2;i<dat.size();i++)ans+=dat[i];
			cout<<ans<<endl;
		}else{
			//odd circle
			int x=cyc[0],y=cyc.back();
			int dif=cnt[col[x]]-cnt[1-col[x]];
			if(dif%2){
				puts("-1");
				return 0;
			}
			val[x]-=dif/2;val[y]-=dif/2;ans+=abs(dif/2);
			for(auto &v:g[x])if(v==y)v=-1;
			for(auto &v:g[y])if(v==x)v=-1;
			if(dfs(1,-1,0)){
				puts("-1");
				return 0;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 19060
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
using namespace std;
struct poi { double x, y; } a, b, c;
double sqr(double x) { return x * x; }
double getdis(poi a, poi b) {
	return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
double calc(double len, double a, double b) {
	double tmp = 1.0 / tan(a / 2) + 1.0 / tan(b / 2) + 2.0;
	return len / tmp;
}
int main() {
	scanf("%lf%lf%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y);
	double A = getdis(b, c), B = getdis(a, c), C = getdis(a, b);
	double p = (A + B + C) / 2, s = sqrt(p * (p - A) * (p - B) * (p - C));
	double ar = asin(2.0 * s / B / C), br = asin(2.0 * s / A / C), cr = asin(2.0 * s / A / B);
	double ans = calc(C, ar, br);
	ans = max(ans, calc(A, br, cr)), ans = max(ans, calc(B, ar, cr));
	printf("%.12lf", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main() {
	int a[100] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1];
}

Measured memory_bytes: 256
mod = 10**9+7
S = input()
l = len(S)
dp = [0,0,1]
ans = 0
for i in range(l):
    if S[i] == 'A':
        dp[0] += dp[2]
        dp[0] %= mod
    if S[i] == 'B':
        dp[1] += dp[0]
        dp[1] %= mod
    if S[i] == 'C':
        ans += dp[1]
        ans %= mod
    if S[i] == '?':
        dp1 = dp[:]
        dp2 = dp[:]
        dp3 = dp[:]
        dp1[0] += dp1[2]
        dp2[1] += dp2[0]
        ans *= 3
        ans += dp3[1]
        ans %= mod
        dp[0] = (dp1[0]+dp2[0]+dp3[0]) % mod
        dp[1] = (dp1[1]+dp2[1]+dp3[1]) % mod
        dp[2]*= 3
        dp[2] %= mod
print(ans)

Measured memory_bytes: 73932
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
long long gcd(long long a, long long b) { /* the greatest common divisor*/
  while (b != 0) {
    long long r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { /*the least common multiple*/
  return (a / gcd(a, b)) * b;
}

int main() {
  LL n,k;
  cin>>n>>k;
  VEC<LL>a(n);
  REP(i,0,n)cin>>a[i];
  LL ma= *max_element(ALL(a));
  LL g=ma;
  REP(i,0,n){
    g=gcd(g,a[i]);
  }
  if(k<=ma && k%g == 0)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;

  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n;
void solve(){
	cin >> n;
	
	if(n >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3604
N = int(input())
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()][::-1]
for i in range(N - 1):
  A1[i + 1] += A1[i]
  A2[i + 1] += A2[i]
A2 = A2[::-1]
A = [A1[i] + A2[i] for i in range(N)]
print(max(A))

Measured memory_bytes: 3064
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Time struct {
	s, t int
}

type ByS []Time

func (a ByS) Len() int           { return len(a) }
func (a ByS) Less(i, j int) bool { return a[i].s < a[j].s }
func (a ByS) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

const MAX = int(1e+5)

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, C := sc.nextInt(), sc.nextInt()
	ch := make([][]Time, C)
	for i := 0; i < N; i++ {
		s, t, c := sc.nextInt(), sc.nextInt(), sc.nextInt()-1
		ch[c] = append(ch[c], Time{s, t})
	}
	ans := make([]int, MAX+1)
	for i := 0; i < C; i++ {
		sort.Sort(ByS(ch[i]))
		before := -1
		for j := 0; j < len(ch[i]); j++ {
			time := ch[i][j]
			if before != time.s {
				ans[time.s-1]++
			} else {
				ans[time.s]++
			}
			ans[time.t]--
			before = time.t
		}
	}
	//fmt.Fprintln(wtr, ans[0:13])
	for i := 0; i < MAX; i++ {
		ans[i+1] += ans[i]
	}
	mx := 0
	for i := 0; i <= MAX; i++ {
		mx = max(mx, ans[i])
	}

	fmt.Fprintln(wtr, mx)
}


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

int n, a, b, c, len[8], ans = 2e9, cost, bamboo;

int main() {
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++)
		cin >> len[i];
	for (int i = 1; i < 1 << n; i++)
		for (int j = 1; j < 1 << n; j++)
			for (int k = 1; k < 1 << n; k++) {
				if (i & j || j & k || k & i)
					continue;
				cost = (__builtin_popcount(i) + __builtin_popcount(j)
						+ __builtin_popcount(k) - 3) * 10;
				bamboo = 0;
				for (int l = 0, bit = i; bit; l++, bit >>= 1)
					if (bit & 1)
						bamboo += len[l];
				cost += abs(bamboo - a);
				bamboo = 0;
				for (int l = 0, bit = j; bit; l++, bit >>= 1)
					if (bit & 1)
						bamboo += len[l];
				cost += abs(bamboo - b);
				bamboo = 0;
				for (int l = 0, bit = k; bit; l++, bit >>= 1)
					if (bit & 1)
						bamboo += len[l];
				cost += abs(bamboo - c);
				ans = min(ans, cost);
			}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int digit_sum = 0;
    for(auto d : to_string(n)) digit_sum += d - '0';
    cout << (n % digit_sum == 0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
 
N, Y = map(int, input().split())
 
if N * 10000 >= Y:
  for a in range(Y // 10000 + 1):
    if a * 10000 + (N - a) * 5000 >= Y:
      for b in range((Y - a * 10000) // 5000 + 1):
        c = (Y - a * 10000 - b * 5000) // 1000
        if a + b + c == N:
          print(a, b, c)
          sys.exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
use std::io::stdin;
use std::io::BufRead;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    loop {
        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        let buf = buf.split_whitespace().collect::<Vec<_>>();

        let m = buf.get(0).unwrap().parse::<isize>().unwrap();
        let f = buf.get(1).unwrap().parse::<isize>().unwrap();
        let r = buf.get(2).unwrap().parse::<isize>().unwrap();

        if m == -1 && f == -1 && r == -1 {
            break;
        }

        println!("{}", if m + f < 30 || m == -1 || f == -1 {
            "F"
        } else if m + f >= 80 {
            "A"
        } else if m + f >= 65 {
            "B"
        } else if m + f >= 50 || r >= 50 {
            "C"
        } else if m + f >= 30 {
            "D"
        } else { unreachable!() });
    }
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  int a = N.size();
  char b = N.at(a - 1);
  if (b == '3'){
    cout << "bon" << endl;
  }
  else if(b == '0'){
    cout << "pon" << endl;
  }
  else if(b == '1'){
    cout << "pon" << endl;
  }
  else if(b == '6'){
    cout << "pon" << endl;
  }
  else if(b == '8'){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<ll> sum(n+1,0);
	for(int i = 1; i <= n; i++){
		sum[i] = sum[i-1] + a[i-1];
	}
	map<ll,ll> m;
	for(int i = 0; i <= n; i++){
		m[sum[i]]++;
	}

	ll ans = 0;
	for(map<ll,ll>::iterator itr = m.begin(); itr != m.end() ; ++itr){
		ans += (itr->second-1)*(itr->second)/2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15872
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		int a[]=new int[n*2];
		for(int i=0;i<n*2;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		for(int i=0;i<n*2;i+=2) ans+=a[i];
System.out.println(ans);
	}
}





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

int main(){
  string s;
  cin >> s;
  char c = s.at(s.size() - 1);
  if(c == '2' || c == '4' || c == '5' || c == '7' || c == '9'){
    cout << "hon" << endl;
  }else if (c == '0' || c == '1' || c == '6' || c == '8'){
    cout << "pon" << endl;
  }else {
   	cout << "bon" << endl;
  } 
}

Measured memory_bytes: 3592
int(input())
n=input()
answer=0
for i in range(10):
    if str(i) in n:
        T=n[n.index(str(i))+1:]
        for j in range(10):
            if str(j) in T:
                U=T[T.index(str(j))+1:]
                for k in range(10):
                    if str(k) in U:
                        answer+=1
print(answer)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
#define sz(x) (ll)x.size()
using namespace std;
 
 
const ll MOD = 998244353 ;
const ll INF = 1e9;
const ll LOG = 29;
#define PI 3.141592653589793238 
 
 
long long binpow(long long a, long long b) {
     a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
 
        
        b >>= 1;
    }
     res%=MOD;
    return res;
}
 
const ll N =(1e5+5);
const ld ep = 1e-9;
vll adj[N];
bool vis[N];
void dfs(ll u){
    vis[u] = true;
    for(auto v:adj[u]){
        if(!vis[v]){
            dfs(v);
        }
    }
}
void solve(){
    ll n,m;
    cin >> n >> m;
    for(int i =1;i<=m;i++){
        ll u,v,z;
        cin >> u >> v >> z;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    ll ans = 0;
    for(int i = 1;i<=n;i++){
        if(!vis[i]){
            ans++;
            dfs(i);
        }
    }
    cout << ans << endl;

}


 
   
 
 
 
 
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
       
 
    ll tt=1;
    while(tt--){
        solve();
    }    
}

Measured memory_bytes: 8960