akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace arc086_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] input = new int[200010];
            for (int i = 0; i < x[0]; i++)
            {
                input[a[i]]++;
            }
            Array.Sort(input);
            Array.Reverse(input);
            int ret = 0;
            for (int i = 0; i < x[1]; i++)
            {
                ret += input[i];
            }
            Console.WriteLine(x[0] - ret);
        }
    }
}

Measured memory_bytes: 35676
#include<stdio.h>
   
int main(){
    int S[100001],T[50001],U[100001];
    int i,j,lengh1,lengh2,count=0,count2=0;
      
    scanf("%d",&lengh1);
    for(i=1;i<=lengh1-count2;i++){
        scanf("%d",&S[i]);
    	if(i>1 && S[i]==S[i-1]){
    		i--;
    		count2++;
    
    }}
       
    scanf("%d",&lengh2);
    for(i=1;i<=lengh2;i++){
        scanf("%d",&T[i]);
    }
       
    for(i=1;i<=lengh1-count2;i++){
        for(j=1;j<=lengh2;j++){
        	if(S[i]==T[j]){
        		count++;
    break;}          
              }}
     
 
    printf("%d\n",count);
        
       
    return 0;
}

Measured memory_bytes: 968
using System;
using System.Linq;
using System.Collections.Generic;

namespace abc155
{
    class Program
    {
        static void Main(string[] args)
        {
            //var s = Console.ReadLine();
            var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();

            string ans = a.Select(s => s.ToString()).Distinct().Count() == 2 ? "Yes" : "No";
            Console.WriteLine(ans);
        }
    }
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	pii SP[100], CP[100];

	cin >> N >> M;
	rep(i, 0, N)
	{
		cin >> SP[i].first >> SP[i].second;
	}

	rep(i, 0, M)
	{
		cin >> CP[i].first >> CP[i].second;
	}

	rep(i, 0, N)
	{
		int md = INF;
		int mi = -1;
		rep(j, 0, M)
		{
			if (chmin(md, abs(SP[i].first - CP[j].first) + abs(SP[i].second - CP[j].second)))
			{
				mi = j;
			}
		}
		cout << mi + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[15];
int n;
char pre;
long long hash1(char *s,int num)
{
	long long ret=0;
	for(int i=0;s[i];i++)
	{
		ret=ret*num+s[i];
	}
	return ret;
}
set<pair<long long,long long>> set1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(i!=1&&s[0]!=pre)
		{
			cout<<"No"<<endl;
			return 0;
		}
		pre=s[strlen(s)-1];
		pair<long long,long long> temp=make_pair(hash1(s,133),hash1(s,1333));
		if(set1.find(temp)!=set1.end())
		{
			cout<<"No"<<endl;
			return 0;
		}
		set1.insert(temp);
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main()
{
    int N;
    vector<int> D;

    cin >> N;
    while(N--) {
        int n;
        cin >> n;
        D.push_back(n);
    }

    int ct = 0;
    if(D.size() % 2 == 0) {
        sort(D.begin(), D.end());
        int mid = D.size() / 2;
        for (int i=D[mid-1]+1; i<=D[mid]; i++) ct++;
    }

    cout << ct << endl;

    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>
#define N 200000000
#define INF 2000000001
   
int size;
int h[N];
   
void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
   
void maxHeapify(i){
  int l = 2*i;
  int r = 2*i+1;
  int valM;
  if(l <= size && h[l] > h[i]) valM = l;
  else valM = i;
  if(r <= size && h[r] > h[valM]) valM = r;
  if(valM != i){
    swap(&h[i], &h[valM]);
    maxHeapify(valM);
  }
}
   
void hIncreaseKey(int i, int key){
  if(key < h[i]) return;
  h[i] = key;
  while(i>1 && h[i/2]<h[i]){
    swap(&h[i], &h[i/2]);
    i = i/2;
  }
}
   
void maxHeapInsert(int key){
  size++;
  h[size] = -INF;
  hIncreaseKey(size, key);
}
   
int heapExtractMax(){
  int valM;
  if(size < 1) return 0;
  valM = h[1];
  h[1] = h[size--];
  maxHeapify(1);
  return valM;
}
   
int main(){
  char input[20];
  size = 0;
  while(scanf("%s", input)){
    if(!strcmp(input, "end")) break;
    if(!strcmp(input, "extract")) printf("%d\n", heapExtractMax());
    else{
      char val[20];
      scanf("%s", val);
      maxHeapInsert(atoi(val));
    }
  }
  return 0;
}

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

int main(){
    string S;
    cin >> S;
    if(S=="Sunny"){
        puts("Cloudy");
    }else if(S=="Cloudy"){
        puts("Rainy");
    }else if(S=="Rainy"){
        puts("Sunny");
    }else{
        puts("-1");
    }
    return 0;
}

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

int main() {
    int N ;
    cin >> N ;
    
    for ( int i = 0 ; i < N ; i ++){
        string S ;
        cin >> S ;
            
            if ( S == "Y"){
            cout << "Four" << endl;
                break;
        }
            else if ( i == N - 1){
                cout << "Three" << endl;
            }
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
int myf(int x){
    int ret;
    x==0 ? ret=0:
    x<=6 ? ret=1:
  	ret=2;
    return ret;
}

signed main(){
    int N;
    cin >>N;
    cout<<(N/11)*2+myf(N%11)<<endl;
}

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

int main(int argc, const char * argv[]) {
    
    int N;
    cin >> N;
    bool flag = false;
    for (int i = 0; i <= 25; i++) {
        for (int j = 0; j <= 14; j++) {
            if (4 * i + 7 * j == N) {
                flag = true;
                break;
            }
        }
        if (flag) break;
    }
    if (flag) cout << "Yes" << endl; else cout << "No" << endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    map<string, int> ma;
    ma["SUN"] = 7;
    ma["MON"] = 6;
    ma["TUE"] = 5;
    ma["WED"] = 4;
    ma["THU"] = 3;
    ma["FRI"] = 2;
    ma["SAT"] = 1;

    string s; cin >> s;

    cout << ma[s] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1000000000
using namespace std;
int main()
{
    int n,b[200],ans=0,a[200];
    scanf("%d",&n);
    for(int i=1; i<=n-1; i++)
        scanf("%d",&a[i]);
    a[0]=inf;
    for(int i=1; i<=n-1; i++)
        b[i]=min(a[i-1],a[i]);
    b[n]=a[n-1];
    for(int i=1;i<=n;i++)
        ans+=b[i];
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	int n;
	int max = 0;
	string *s;
	map<string,int> counter;
	cin >> n;
	s = new string[n];
	for(int i = 0;i < n;i++){
		cin >> s[i];
		auto itr = counter.find(s[i]);
		if(itr == counter.end()){
			counter[s[i]] = 1;
		}else{
			counter[s[i]] += 1;
		}
	}
	for(auto itr = counter.begin();itr != counter.end();itr++){
		if(itr -> second > max){
			max = itr->second;
		}
	}
	for(auto itr = counter.begin();itr != counter.end();itr++){
		if(itr -> second == max){
			cout << itr -> first << '\n';
		}
	}


	return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
const long long mod=1000000007;

// Basically Fibonacch sequence
int main() {
  int N, M; cin >> N >> M;
  vector<long long> dp(N+10, 0);
  vector<bool> ok(N+1, true);
  for(int i = 0; i < M; ++i) {
    int a; cin >> a;
    ok[a] = false;
  }
  for(int i = 1; i <= N; ++i) {
    if(ok[i]) {
      if(i == 1) dp[i] = 1;
      else if(i == 2) dp[i] = dp[i-1] + 1;
      else dp[i] = (dp[i-1] + dp[i-2]) % mod;
    } else {
      dp[i] = 0;
    }
  }
  cout << dp[N] << endl;

  return 0;
}


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		StringBuilder a=new StringBuilder(s);
		StringBuilder b=new StringBuilder("");
		int T=sc.nextInt();
		int m=0;
		for(int i=0;i<T;i++){
			int n=sc.nextInt();
			if(n==2){
				int d=sc.nextInt();
				String c=sc.next();
				
				if(m==0){
					if(d==1){
						b=b.append(c);
					}else{
						a=a.append(c);
					}
				}else{
					if(d==1){
						a=a.append(c);
					}else{
						b=b.append(c);
					}
				}
			}else if(n==1){
				if(m==0){
					m=1;
				}else{
					m=0;
				}
			}
		}
		
		if(m==0){
			System.out.println(b.reverse()+""+a);
		}else if(m==1){
			System.out.println(a.reverse()+""+b);
		}
	}

}


Measured memory_bytes: 120972
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int K;
	cin >> s;
	cin >> K;
	vector<string> v;

	rep(i, 0, s.size()) {
		rep(j, 1, K + 1) {
			v.push_back(s.substr(i, j));
		}
	}

	vsort(v);
	vunique(v);
	cout << v[K - 1] << endl;


}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    string S;
    cin >> S;

    map<char, ll> m;
    for (ll i = 0; i < N; i++) {
        m[S[i]]++;
    }

    ll ans = 1;
    for (map<char, ll>::iterator it = m.begin(), end = m.end(); it != end; it++) {
        ans *= (it->second + 1);
        ans %= MOD;
    }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=505,DIR[4][2]={1,0,0,1,0,-1,-1,0};

int n;
bool notp[MAXN*MAXN];
int prm[MAXN*MAXN],pn;
void euler(int n)
{
	notp[1]=1;
	for(int i=2;i<=n;++i)
	{
		if(!notp[i])prm[++pn]=i;
		for(int j=1;j<=pn && i*prm[j]<=n;++j)
		{
			notp[i*prm[j]]=1;
			if(!(i%prm[j]))break;
		}
	}
}
ll a[MAXN][MAXN];
inline ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
inline ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
unordered_set<ll> s;

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n);
	euler(n*500);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			if(!((i+j)&1))
			{
				a[i][j]=prm[(i+j)/2]*prm[(i-j+n+1)/2+n];
				s.insert(a[i][j]);
			}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
		{
			if(!((i+j)&1))continue;
			a[i][j]=1;
			for(int t=0;t<4;++t)
			{
				int x=i+DIR[t][0],y=j+DIR[t][1];
				if(!x || !y || x>n || y>n)continue;
				a[i][j]=lcm(a[i][j],a[x][y]);
			}
			ll x=a[i][j];
			++a[i][j];
			while(s.count(a[i][j]))a[i][j]+=x;
			s.insert(a[i][j]);
		}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
			printf("%lld ",a[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 15304
#include<iostream>
#include <algorithm>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main() {
    int N, M;
    int Sum = 0;

    // input
    cin >> N >> M;
    int array[N], A[N];
    for(int i=0; i<= N-1; i++){
        cin >> array[i];
    }

    // 配列の和の計算
    for(int i=0; i<= N-1; i++){
        Sum = Sum + array[i];
    }

    // 降順ソート
    sort(array, array + SIZE_OF_ARRAY(array), greater<>());

    // 出力
    if(array[M-1] * 4 * M >= Sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

#define ll long long int
#define MOD 1000000007
#define sc(a) scanf("%lld",&a)
#define f0(n) for(ll i=0;i<n;i++)
#define f1(n) for(ll i=1;i<=n;i++)
#define pb(v,a) v.push_back(a)
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end());


int main()
{
	ll s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe"<<endl;
	else
		cout<<"safe"<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	ll N,K;
	cin>>N>>K;
	
	if(K%2==1){
		cout<<(N/K)*(N/K)*(N/K)<<endl;
	}
	else{
		ll ans =0;
		ans+=(N/K)*(N/K)*(N/K);
		ans+=((N+(K/2))/K)*((N+(K/2))/K)*((N+(K/2))/K);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n=0,i=0,min=10000000000,max=0;
  int a[1000];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
  	scanf("%d",&a[i]);
    if(a[i]<min){
      min=a[i];
    }
    if(max<a[i]){
      max=a[i];
    }
  }
  printf("%d",max-min);
  
  
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


//////////////////////////////////////////////////////////////////////////////////////b,cl
int main(){
    int a,b,c;
    cin >> a >> b >> c;

    swap(a,b);
    swap(a,c);

    cout << a << " "  << b << " " << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*ncr mod m
const int mod=1000000009;
int c[r+1];
void ncr(int n,int r){c[0]=1;repre(i,1,n)for(int j=min(i,r);j>0;j--)c[j]=((c[j-1]%mod)+(c[j]%mod))%mod;return c[r];}*/
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int a,b,c,d;
  cin>>a;
  string s;
  cin>>s;
  if(a<3200)cout<<"red\n";
  else cout<<s<<endl;
  return 0;
}


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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	int a, b;
	char op;

	cin >> a >> op >> b;
	if (op == '+') {
		cout << a+b << '\n';
	}
	else {
		cout << a-b << '\n';
	}
 
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int x,y,tmp;
  while(1){ 
    scanf("%d%d",&x,&y);
    if(x == 0 && y == 0){
      break;
    } else if(x > y){
      tmp = x; x = y; y = tmp;
    }
    printf("%d %d\n", x,y);
  }
  return 0;
}


Measured memory_bytes: 1924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A; int B; int C;
  cin>>A>>B>>C;
  int N=0;
  if(A==B)
    N++;
  if(A==C)
    N++;
  if(B==C)
    N++;
  
  if(N==1)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int euclid(int b, int c){
	int a;
	while (c != 0){
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}

int main(){
	int a, b, g, l;
	while (scanf("%d %d", &a, &b) != EOF){
		g = euclid(a, b);
		l = a / g * b;
		printf("%d %d\n", g, l);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++) 
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
//#define x first
//#define y second

using namespace std;
int n;
map<string,bool>usd;
char k;
string junk;
int main()
{
	cin>>n;
	cin>>junk;
	usd[junk]=1;
	k=junk[junk.size()-1];
	rep2(i,1,n)
	{
		cin>>junk;
		if(junk[0]!=k||usd.count(junk))
		{
			cout<<"No"<<endl;
			return 0;
		}
		usd[junk]=1;
		k=junk[junk.size()-1];
	}
	cout<<"Yes"<<endl;
	return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  set<int> S;
  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    S.insert(a);
  };
  cout << S.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
// 	cin>>test;	
	while(test--)
	{
	long a,b=0,c,k,i,n,temp;
		cin>>n>>k;
		long d[11]={0};
		for(i=0;i<k;i++)
		{
		    cin>>temp;
		    d[temp]++;
		}
		for(i=n;i<999999;i++)
		{
		    stringstream ss;
		    string s1;
		    ss<<i;
		    ss>>s1;
		    bool flag=true;
		    for(int j=0;j<s1.length();j++)
		    {
		        if(d[int(s1[j])-int('0')])
		        {
		            flag=false;
		            break;
		        }
		    }
		        if(flag)
		        {
		            cout<<i;
		            break;
		        }
		    }
		}
		
 }
    


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

using namespace std;
using ll = long long;

int main()
{
  string X; cin >> X;
  int N = X.size();

  stack<char> st;
  for (int i = 0; i < N; ++i) {
    if (X[i] == 'S') st.push(X[i]);
    else if (X[i] == 'T' && (st.size() == 0 || st.top() == 'T')) {
      st.push(X[i]);
    } else if (X[i] == 'T' && (st.top() == 'S')) {
      st.pop();
    }
  }

  cout << st.size() << endl;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;
bool sortbysecdesc(const pair<string,ll> &a, 
				const pair<string,ll> &b) 
{ 
	return a.second>b.second; 
} 
void solve()
{ll t=1,n,m,k;  
 while(t--){ cin>>n; vector<pair<string,ll>> a(n),v(n); for(ll i=0;i<n;i++){cin>>a[i].first>>a[i].second;} v=a; vector<ll> b(n); ll start=0,end=0;
 sort(v.begin(),v.end());
 
 for(ll i=0;i<n;)
 {start=i; end=i;for(ll j=i+1;j<n;j++){
 if(v[j].first==v[i].first)
 end=j;
 if(j==n-1) sort(v.begin()+i, v.begin()+end+1, sortbysecdesc);
  }i=end+1;
 }
 for(ll i=0;i<n;i++)
  {for(ll j=0;j<n;j++)
   {if(v[i]==a[j]) b[i]=j+1;
   }
  }for(ll i=0;i<n;i++) cout<<b[i]<<endl;
 }
}
int main()
{
fast
ll t=1;
while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

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

if __name__ == "__main__":
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())

    count = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                val = i*500 + j*100 + k*50
                if val == x:
                    count += 1

    print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <queue>
#include <set>
using namespace std;
int wmap[30][30];
int hmap[30][30];
int main()
{
  for(;;){
    int w,h;
    cin >> w >> h;
    if(w==0 || h==0) break;
    memset(wmap,0,sizeof(wmap));
    memset(hmap,0,sizeof(hmap));
    for(int i=0; i<h; i++){
      for(int j=0; j<w-1; j++){
        cin >> wmap[i][j];
      }
      if(i == h-1) break;
      for(int j=0; j<w; j++){
        cin >> hmap[i][j];
      }
    }
    queue< pair<int,pair<int,int> > > q;
    q.push( make_pair<int,pair<int,int> >(0,make_pair(0,0)));
    set< pair<int,int> > s;
    s.insert( make_pair<int,int>(0,0));
    bool bfind = false;
    while(!q.empty()){
      pair<int,pair<int,int> > node = q.front(); q.pop();
      int len = node.first;
      pair<int,int> pos = node.second;
      if(pos.first == w-1 && pos.second == h-1){
        bfind = true;
        cout << len+1 << endl;
        break;
      }
      if(pos.first > 0 && wmap[pos.second][pos.first-1] == 0){
        pair<int,int> pn = make_pair(pos.first-1,pos.second);
        if(s.insert(pn).second){
          q.push(make_pair<int,pair<int,int> >(len+1,pn));
        }
      }
      if(pos.first < w-1 && wmap[pos.second][pos.first] == 0){
        pair<int,int> pn = make_pair(pos.first+1,pos.second);
        if(s.insert(pn).second){
          q.push(make_pair<int,pair<int,int> >(len+1,pn));
        }
      }
      if(pos.second > 0 && hmap[pos.second-1][pos.first] == 0){
        pair<int,int> pn = make_pair(pos.first,pos.second-1);
        if(s.insert(pn).second){
          q.push(make_pair<int,pair<int,int> >(len+1,pn));
        }
      }
      if(pos.second < h-1 && hmap[pos.second][pos.first] == 0){
        pair<int,int> pn = make_pair(pos.first,pos.second+1);
        if(s.insert(pn).second){
          q.push(make_pair<int,pair<int,int> >(len+1,pn));
        }
      }
    }
    if(!bfind){
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
ll p[100]={1ll},b[100],l[100]={1ll},n,k;///p[i]-->s[i]中有几个p,b[i]-->s[i]中有几个b,l[i]-->s[i]中有几个字母
void init(){
    for(int i=1;i<55;i++){
        p[i] = 2*p[i-1]+1,b[i] = 2*b[i-1]+2;
        l[i] = p[i]+b[i];
    }
}
ll dfs(ll cur,ll len){
    if(!cur)return 1ll;///s[0]='p'
    if(len<=1)return 0ll;///'b'或者空
    if(len == 1+l[cur-1])///'b'+s[i-1]
        return p[cur-1];
    if(len == 2+l[cur-1])///'b'+s[i-1]+'p'
        return p[cur-1]+1;
    if(len == l[cur] || len == l[cur]-1)///'b'+s[i-1]+'p'+s[i-1]或者'b'+s[i-1]+'p'+s[i-1]+'p'
        return p[cur];
    if(len<1+l[cur-1])///'b'+****
        return dfs(cur-1,len-1);
    return p[cur-1]+1+dfs(cur-1,len-l[cur-1]-2);///'b'+s[i-1]+'p'+***
}
int main(){
    init();
    cin>>n>>k;
    cout<<dfs(n,k)<<endl;
    return 0;
}


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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  
  for(int i = 0; i<N-2; i++){
    if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,p,s=0,m;cin>>N;
  cin>>s;m=s;
  for(int i=1;i<N;i++){
    cin>>p;s+=p;m=max(m,p);
  }
  cout<<s-m/2<<endl;
}

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


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

    std::vector<int> a;

    int t=0;
    for(int i=0; i<N; i++) {
        std::cin >> t;
        a.push_back(t);
    }

    long long ans=0;
    for(int i=0; i<a.size()-1; i++) {
        if(a[i]>a[i+1]) {
            ans += a[i]-a[i+1];
            a[i+1] = a[i+1] + (a[i]-a[i+1]);
        }
    }

/*
    for(int i=0; i<a.size(); i++) {
        std::cout << a[i] << " ";
    }
    std::cout << std::endl;
    */
    std::cout << ans << std::endl;


    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, k;

    cin >> n >> m >> k;

    bool isYes = false;
    bool breaker = false;

    int i, j;

    for (i = 0; i <= n; i++) {
        if (i * m == k) {
            isYes = true;

            break;
        }

        for (j = 0; j <= m; j++) {
            if ((i * m + j * n - i * j * 2) == k) {
                isYes = true;
                breaker = true;

                break;
            }
        }

        if (breaker) break;
    }

    if (isYes) cout << "Yes" << '\n';
    else cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);

    rep(i, n)
    {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int sum = 0;
    for (int i = n - 1; i >= n - k; i--)
    {
        sum += l[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main() {
  int A,B,C;
  cin>>A>>B>>C;
  for(int i=1;i<B;i++){
  if(A*i%B==C){cout<<"YES"<<endl;return 0;}
  }
  cout<<"NO"<<endl;
 return 0;}

Measured memory_bytes: 256
N, W = map(int, input().split())
v = [0] * N
w = [0] * N
for i in range(N):
    v[i], w[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
    for j in range(W + 1):
        if j < w[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])

print(dp[N][W])



Measured memory_bytes: 25492
from itertools import product

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

L = []
for i in range(N) :
    L.append([V[i],C[i]])
L = sorted(L, key=lambda x: x[0])

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

Measured memory_bytes: 3064
#include <stdio.h>

int w, h, n;
int x1,y1,x2,y2;

int main(void) {

    scanf("%d %d %d", &w, &h, &n);
    x1=y1=0;
    x2=w;
    y2=h;
    
    for(int i=0; i<n; i++) {
        int x, y, a;
        scanf("%d %d %d", &x, &y, &a);
        
        if(a==1 && x>x1) {
            x1=x;
        }
        else if(a==2 && x<x2) {
            x2=x;
        }
        else if(a==3 && y>y1) {
            y1=y;
        }
        else if(a==4 && y<y2) {
            y2=y;
        }
    }
    
    if(x2<x1 || y2<y1) printf("0");
    else printf("%d", (x2-x1)*(y2-y1));
    
    return 0;
}

Measured memory_bytes: 128
import heapq
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ABList = [[] for _ in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a-1>m-1:
        continue
    ABList[a-1].append(-b) # because of min heap

ans = 0
heap = []
for i in range(m):
    for j in ABList[i]:
        heapq.heappush(heap, j)
    if len(heap)>0:
        B = heapq.heappop(heap)
        ans += -B       

print(ans)


Measured memory_bytes: 17860
# include <bits/stdc++.h>
# define rr register
# define int long long
const int N=100010,INF=0x3f3f3f3f,MOD=1e9+7;
int n,k;
int ans;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
signed main(void){
	n=read(),k=read();
	for(rr int i=k;i<=n;++i){
		int d=(1+(i-1))*(i-1)/2,h=((n-i+1)+n)*i/2;
		ans=(ans+(h-d+1))%MOD;
	}
	printf("%lld",ans+1);
	return 0;
}


Measured memory_bytes: 3764
def solve():
    N = int(input())
    A = [int(input())-1 for i in range(N)]

    cnt = 0
    idx = 0
    ans = -1
    while cnt < N:
        idx = A[idx]
        cnt += 1
        if idx == 1:
            ans = cnt
            break
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 49624
#include<iostream>

using namespace std;

int n, in[4], tmp[4], out[4];

int money_count(int m, int i, int j, int k, int l){
  tmp[0] = m/500 + in[0]-i;
  m %= 500;
  tmp[1] = m/100 + in[1]-j;
  m %= 100;
  tmp[2] = m/50 + in[2]-k;
  m %= 50;
  tmp[3] = m/10 + in[3]-l;
  return tmp[0] + tmp[1] + tmp[2] + tmp[3];
}

void solve(){
  int min_ = 100;
  for(int i=0; i<=in[0]; ++i){
    for(int j=0; j<=in[1]; ++j){
      for(int k=0; k<=in[2]; ++k){
        for(int l=0; l<=in[3]; ++l){
          int m = 500*i + 100*j + 50*k + 10*l - n;
          if(m < 0) continue;
          int sum = money_count(m, i, j, k, l);
          if(min_ > sum){
	    out[0]=i; out[1]=j; out[2]=k; out[3]=l; min_ = sum;
          }
        }
      }
    }
  }
}

int main(){
  bool is=false;
  while(1){
    cin >> n;
    if(!n) break;
    for(int i=3; i>=0; --i) cin >> in[i];
    solve();
    if(is) cout << endl;
    if(out[3] != 0) cout << "10 " << out[3] << endl;
    if(out[2] != 0) cout << "50 " << out[2] << endl;
    if(out[1] != 0) cout << "100 " << out[1] << endl;
    if(out[0] != 0) cout << "500 " << out[0] << endl;
    is=true;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    long ans = 1;
    for (int i = 0; i < n; i++) {
      ans = lcm(ans, a[i]);
    }
    System.out.println(ans);
  }

  public static long gcd(long a, long b) {
    if (b == 0) {
      return a;
    }
    return gcd(b, a % b);
  }

  public static long lcm(long a, long b) {
    return (a / gcd(a, b)) * b;
  }
}


Measured memory_bytes: 26368
n=int(input())
lst=[]
for i in range(n):
    a,b=map(int,input().split())
    lst.append([a-b,a+b])
lst=sorted(lst,key=lambda x:x[1])
ans=0
end=-float("inf")
for i in lst:
    if i[0]>=end:
        ans+=1
        end=i[1]
print(ans)

Measured memory_bytes: 93260
module Sort_Module
    implicit none
    public
    contains
    recursive subroutine mergesort(a, p, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r
        integer(8) q
        if (p < r) then
            q = (p+r)/2
            call mergesort(a, p, q, b)
            call mergesort(a, q+1, r, b)
            call merge(a, p, q, r, b)
        end if
    end subroutine mergesort
    subroutine merge(a, p, q, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r, q, i, j, k
        integer(8) t
        k = p;   i = p;   j = q+1
        do
            if (.not. (k <= r)) exit
            if (j > r) then
                t = a(i);   i = i+1
            else if (i > q) then
                t = a(j);   j = j+1
            else if (a(i) <= a(j)) then
                t = a(i);   i = i+1
            else
                t = a(j);   j = j+1
            end if
            b(k) = t;   k = k+1
        end do
        do i = p, r
            a(i) = b(i)  
        end do
    end subroutine merge
    subroutine sort(a)
      integer(8) a(:),b(ubound(a,1)-size(a)+1:ubound(a,1)),n,k
      n = ubound(a,1)
      k = ubound(a,1)-size(a)+1
      call mergesort(a,k,n,b)
    end subroutine sort
    function POSL(a,v) result(r)!find first i:a(i)>=v
        implicit none
        integer(8) :: a(:),l,r,idx,v
        r = ubound(a,1) + 1
        l = ubound(a,1)-size(a)
        do while(r-l>1)
            idx = l + (r-l)/2
            if(a(idx) >= v)then
                r = idx
            else
                l = idx
            endif
        enddo
    end function
    function POSU(a,v) result(r)!find first i:a(i)>v
        implicit none
        integer(8) :: a(:),l,r,idx,v
        r = ubound(a,1) + 1
        l = ubound(a,1)-size(a)
        do while(r-l>1)
            idx = l + (r-l)/2
            if(a(idx) > v)then
                r = idx
            else
                l = idx
            endif
        enddo
    end function
    function NUM(a,v) result(n)
        implicit none
        integer(8) :: a(:),v,n
        n = POSU(a,v) - POSL(a,v)
    end function
  end module Sort_Module
  
  
  program atcoder
    use Sort_Module
    implicit none
    integer(8) :: N,M,i,ans=0,j,x,y
    integer(8),allocatable,dimension(:) :: A
    read*,N,M
    allocate(A(N))
    do i=1,N
        read*,x,y
        A(i) = x*10_8**6_8+y;
    enddo
    call sort(A)

    do i = 1_8,N
        x = mod( A(i) , 10_8**6_8 )
        if(M/=0 .and. M<=x)then
            ans = ans + (A(i)/10_8**6_8)*M
            M = 0
        else if(M/=0 .and. M>x)then
            M = M - x
            ans = ans + (A(i)/10_8**6_8)*x
        endif
    enddo
    write(*,'(I0)')ans
    stop 
  contains
  end program atcoder

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

int a[3][3];
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>a[i][j];
  int n;cin>>n;
  for(int i=0;i<n;i++){
    int k;cin>>k;
    for(int j=0;j<3;j++){
      for(int l=0;l<3;l++){
        if(a[j][l]==k)a[j][l]=-1;
      }
    }
  }
  for(int i=0;i<3;i++){
    int c=0;
    for(int j=0;j<3;j++){
      c+=a[i][j];
    }
    if(c==-3)fin("Yes");
  }
  for(int i=0;i<3;i++){
    int c=0;
    for(int j=0;j<3;j++){
      c+=a[j][i];
    }
    if(c==-3)fin("Yes");
  }
  for(int i=0;i<1;i++){
    int c=0;
    for(int j=0;j<3;j++){
      c+=a[j][i+j];
    }
    if(c==-3)fin("Yes");
  }
  for(int i=0;i<1;i++){
    int c=0;
    for(int j=0;j<3;j++){
      c+=a[j][2-j];
    }
    if(c==-3)fin("Yes");
  }
  fin("No");
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

void solve (int n)
{
    vi a(n);
    forn (i, n) cin >> a[i];
    sort(all(a));

    ll pref = 0;
    int border = 0;
    forn (i, n - 1)
    {
        pref += a[i];
        if (2 * pref < a[i + 1])
            border = i + 1;
    }

    cout << n - border << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


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

int main(void) {
	double n,max,min,ans;
	char str[100],s[100];

	fgets(s,sizeof(str),stdin);
	sscanf(s,"%lf",&n);
	max=n; min=n;
	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%lf",&n);
		if(n>max)
			max=n;
		else if(min>n)
			min=n;
	}
	printf("%.1f\n",ans=max-min);
	return 0;
}

Measured memory_bytes: 660
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int in[100005];
int out[100005];
int dp[100005];
using graph = VVI;

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	graph g(n);
	REP(i, m) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--, y--;
		g[y].PB(x);
		out[y]++;
		in[x]++;
	}
	stack<int> st;
	VI nodes;
	REP(i, n) {
		if (!in[i]) {
			st.push(i);
		}
	}
	while (!st.empty()) {
		auto i = st.top();
		nodes.PB(i);
		st.pop();
		for (auto j : g[i]) {
			in[j]--;
			if (!in[j])st.push(j);
		}
	}
	int ret = 0;
	for (auto i : nodes) {
		for (auto j : g[i]) {
			dp[j] = max(dp[j], dp[i] + 1);
		}
		if (g[i].size() == 0)ret = max(ret, dp[i]);
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 7416
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int N,X;
	cin>>N>>X;
	int mini=INF,sum=0;
	for(int i=0;i<N;i++){
		int m;
		cin>>m;
		mini=min(mini,m);
		sum+=m;
	}
	cout<<N+(X-sum)/mini<<endl;
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> P(n);
    for (int i = 0; i < n; i++) {
        cin >> P[i];
    }

    int out = 0;
    for (int i = 1; i < n - 1; i++) {
        if (max({P[i-1], P[i], P[i+1]}) != P[i])
            if (min({P[i-1], P[i], P[i+1]}) != P[i]) out++;
    }

    cout << out << endl;
}


Measured memory_bytes: 256
import numpy as np

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

ans = 1
var = X
while True:
  X *= 2
  if X <= Y:
    ans += 1
  else:
    break

print(ans)


"""
## なんで以下のプログラムが誤りなのかわからん
# 入力n以下の最大の2のべきを出力
# 2**(out) <= (in) < 2**(out+1)
# power2_smaller(8) = 3
# power2_smaller(9) = 3
def power2_smaller(num):
    return len(str(bin(num))[2:])-1

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

ans = power2_smaller(int(Y/X)) + 1
print(ans)
"""

Measured memory_bytes: 12484
N,M = map(int,input().split())
A,B,C,D,Ans = [],[],[],[],[]
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
for _ in range(M):
    c,d = map(int,input().split())
    C.append(c)
    D.append(d)
for i in range(N):
    d,t = 10**10,-1
    for j in range(M):
        if d > abs(A[i]-C[j])+abs(B[i]-D[j]):
            d = abs(A[i]-C[j])+abs(B[i]-D[j])
            t = j
    Ans.append(t)
for i in range(N):
    print(Ans[i]+1)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	int G[N][N],tmp[N][N];
	for(int i = 0;i < N;i++){
		for(int j = 0;j < N;j++){
			G[i][j] = 0;
			tmp[i][j] = 0;
		}
	}
	for(int i = 0;i < M;i++){
		int a,b;
		cin >> a >> b;
		G[a-1][b-1] = 1;
		G[b-1][a-1] = 1;
		tmp[a-1][b-1] = 1;
		tmp[b-1][a-1] = 1;
	}

	int count = 0;
	int reached[N];

	for(int i = 0;i < N;i++) reached[i] = 0;
	for(int i = 0;i < N-1;i++){
		for(int j = i+1;j < N;j++){
			if(G[i][j] == 1){
				tmp[i][j] = 0;
				tmp[j][i] = 0;
				stack<int> s;
				s.push(i);
				int x = i;
				int y = 0;
				reached[x] = 1;
				while(1){
					if(x >= N or y >= N){
						x = s.top();
						s.pop();
						y = 0;
					}
					if(tmp[x][y] == 1 and reached[y] == 0){
						s.push(y);
						reached[y] = 1;
						tmp[x][y] = 0;
						tmp[y][x] = 0;
					}

					if(s.empty())break;
					y++;
				}
				for(int k = 0;k < N;k++){
					if(reached[k] == 0){
						count++;
						break;
					}
				}
				for(int k = 0;k < N;k++){
					for(int l = 0;l < N;l++){
						tmp[k][l] = G[k][l];
					}
					reached[k] = 0;
				}
			}
		}

	}
	cout << count << endl;

}

Measured memory_bytes: 256
// "include" {{{
    #include <deque>
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <deque>
    #include <list>
    #include <map>
    #include <queue>
    #include <set>
    #include <stack>
    #include <cstring>
    // }}}
    using namespace std;
    #define rep(i,n) for(int i=0;i<(n);++i)
    #define reps(i,n) for(int i=1;i<=(n);++i)
    #define all(x) (x).begin(),(x).end()
    #define pii pair<int,int>
    #define int long long
    const int INF = 0x3f3f3f3f;
    const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
    const long long mod = 1000000007;
     
     
    signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[0] * a[1] / 2<< '\n';
    return 0;
    }

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

ll fact(ll n){
    if(n<=1)
        return 1;
    else
        return n*fact(n-1)%1000000007;
}

int main(){
    ll N, M;
    cin >> N >> M;
    if(N == M){ //2*N!*M!
        cout << 2*fact(N)*fact(M)%1000000007 << endl;
    }else if(abs(N - M) == 1){  //N!*M!
        cout << fact(N)*fact(M)%1000000007 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)

using namespace std;

int main(){
    cs
    int a;
    cin>>a;
    repp(i,1,9){
        if(a%i==0&&a/i<=9) {cout<<"Yes";return 0;}
    }
    cout<<"No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[2][100010],d[100010],INF=1<<29;
vector<ll> v[100010];
ll n,m,s,t;
 
void bfs(ll s,ll k) {
  fill(d,d+n+1,INF);
  d[s]=0;
  c[k][0]++;
  queue<ll> que;
  que.push(s);
  while(!que.empty()) {
    ll x=que.front();que.pop();
    for(int i=0; i<v[x].size(); i++) {
      ll y=v[x][i];
      if(d[y]<=d[x]+1) continue;
      d[y]=d[x]+1;
      c[k][d[y]]++;
      que.push(y);
    }
  }
}
   
 
int main() {
  cin >> n >> m >> s >> t;
  for(ll i=0; i<m; i++) {
    ll x,y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  memset(c,0,sizeof(c));
  bfs(s,0);
  bfs(t,1);
  ll z=d[s],ans=0;
  for(ll i=0; i<z-1; i++) ans+=c[0][i]*c[1][z-i-2];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11232
n = int(input())
a, b = 0, 0
for i in range(n):
    s1, s2 = input().split()
    if s1 > s2:
        a += 3
    elif s1 == s2:
        a += 1
        b += 1
    else:
        b += 3
print('{0} {1}'.format(a, b))

Measured memory_bytes: 7648
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var ans = true
    var preT = 0
    var preX = 0
    var preY = 0
    repeat(n) {
        val (t, x, y) = readInts()
        val dt = t - preT
        val dr = Math.abs(x - preX) + Math.abs(y - preY)
        ans = ans && dr <= dt && (dt - dr) % 2 == 0
        preT = t
        preX = x
        preY = y
    }
    println(if (ans) "Yes" else "No")
}


Measured memory_bytes: 57768
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

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

	vector<long long> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

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

	int cntDead = 0;
	while(N-cntDead != 1){
		for(int i=cntDead+1, index=cntDead; i<N; i++){
			A[i] %= A[index];
			if(A[i] == 0)
				cntDead++;
		}

		sort(A.begin(), A.end());
	}

	cout << A[N-1] << endl;

	return 0;
}


Measured memory_bytes: 1024