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

public class P : IComparable
{
    public int to { get; set; }
    public int from { get; set; }
    public string era { get; set; }
    public int CompareTo(object obj)
    {
        var x = (P)obj;
        if (this.from > x.from) return 1;
        else if (this.from == x.from) return 0;
        else return -1;
    }
}


public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var q = int.Parse(line[1]);
            if (n == 0 && q == 0) break;
            var ps = new P[n];
            for (int i = 0; i < n; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var a = int.Parse(line[1]);
                var b = int.Parse(line[2]);
                ps[i] = new P { from = b - a + 1, to = b, era = line[0] };
            }
            ps = ps.OrderBy(x => x.from).ToArray();
            getAns(n, q, ps);
        }
    }
    static void getAns(int n, int q, P[] ps)
    {
        var sb = new StringBuilder();
        var w2 = new P();
        for (int i = 0; i < q; i++)
        {
            var w = int.Parse(Console.ReadLine().Trim());
            w2.from = w;
            var t = LowerBound<P>(ps, w2);
            if (t >= n)
            {
                if (w > ps[n - 1].to) sb.Append("Unknown\n");
                else sb.Append(string.Format(   "{0} {1}\n", ps[n - 1].era, w - ps[n - 1].from + 1));
            }
            else if (t == 0)
            {
                if (w == ps[0].from) sb.Append(string.Format("{0} {1}\n", ps[0].era, w - ps[0].from + 1));
                else sb.Append("Unknown\n");
            }
            else
            {
                if (ps[t].from == w) { sb.Append(string.Format("{0} 1\n", ps[t].era)); }
                else if (ps[t - 1].from < w)
                {
                    if (ps[t - 1].to >= w) { sb.Append(string.Format("{0} {1}\n", ps[t - 1].era, w - ps[t - 1].from + 1)); }
                    else sb.Append("Unknown\n");
                }
            }
        }
        Console.Write(sb);
    }
    public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) < 0)
                low = mid + 1;
            else
                high = mid;
        }
        return low;
    }

    public static int LowerBound<T>(T[] arr, T value) where T : IComparable
    {
        return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    }
}



Measured memory_bytes: 22876
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int a=nextInt();
		int b=nextInt();
		if(a<=0 && 0<=b)
			out.println("Zero");
		else if(a>0)
			out.println("Positive");
		else if((b-a+1)%2==0)
			out.println("Positive");
		else
			out.println("Negative");
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 21204
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab.sort()
#print(ab)

import heapq
h=[]
ans=0
j=0
for i in range(1,m+1):
    while j<n:
        if ab[j][0]>i:
            break
        else:
            heapq.heappush(h,-ab[j][1])
            j+=1
    #print(i,h)
    if h!=[]:
        k=-heapq.heappop(h)
        ans+=k
print(ans)

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

using namespace std;

struct Edge {
	int src;
	int dst;
	int cost;
};

int main()
{
	int N, M, P;
	cin >> N >> M >> P;

	vector<vector<Edge>> g(N);

	for (int i = 0; i < M; ++i) {
		int A, B, C;
		cin >> A >> B >> C;
		--A;
		--B;
		Edge e;
		e.src = A;
		e.dst = B;
		e.cost = P - C;
		g[A].push_back(e);
	}

	const long long INF = 1LL << 60;
	vector<long long> d(N,INF);
	d[0] = 0;

	for (int k = 0; k < N - 1; ++k) {
		for (const auto &edges : g) {
			for (const auto &e : edges) {
				d[e.dst] = min(d[e.dst], d[e.src] + e.cost);
			}
		}
	}

	long long ans1 = -d[N - 1];

	for (int k = 0; k < N - 1; ++k) {
		for (const auto &edges : g) {
			for (const auto &e : edges) {
				d[e.dst] = min(d[e.dst], d[e.src] + e.cost);
			}
		}
	}

	long long ans2 = -d[N - 1];

	if (ans2 > ans1) {
		cout << -1 << endl;
	}
	else if (ans2 < 0) {
		cout << 0 << endl;
	}
	else {
		cout << ans2 << endl;
	}
}


Measured memory_bytes: 512
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    m,p = [],[]
    
    for x,y in zip(a,b):
        if x > y:
            p.append(x-y)
        elif x < y:
            m.append(y-x)

    ch = sum(m)
    p.sort(reverse=True)
    ans = len(m)
    l = 0
    while ch > 0:
        if l == len(p):
            print(-1)
            exit()
        else:
            ch -= p[l]
            ans += 1
            l += 1
            
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 17048
a,b,c = input().split()
n = int(a)
K = int(b)
Q = int(c)
CAList = []
AllP = []
for i in range(0,Q):
    CAList.append(int(input()))

for j in range(0,n):
    AllP.append(K-Q)

for k in range(0,Q):
    AllP[CAList[k]-1] += 1
    
for m in range(0,n):
    if AllP[m] >= 1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 11784
import collections, itertools, copy


class MaximumFlow:
    def ford_fulkerson(self, G, s, t):
        G_residue = copy.deepcopy(G)

        def dfs(start, used):
            if start == t:
                return [start]
            for end, cap in G_residue[start].items():
                if cap > 0 and end not in used:
                    used.add(end)
                    ret = dfs(end, used)
                    if ret:
                        return ret + [start]
            return []

        flow_value = 0
        while True:
            root = dfs(s, set([s]))
            if root:
                root = root[::-1]
                residue = min(
                    [G_residue[a][b] for a, b in zip(root, root[1:])])
                flow_value += residue
                for a, b in zip(root, root[1:]):
                    G_residue[a][b] -= residue
                    G_residue[b][a] += residue
            else:
                return (flow_value, G_residue)


N = int(input())
AB = [[int(_) for _ in input().split()] for _ in range(N)]
CD = [[int(_) for _ in input().split()] for _ in range(N)]
G = collections.defaultdict(lambda: collections.defaultdict(int))
for a, b in AB:
    G[-1][1000 * a + b] = 1
for c, d in CD:
    G[1000 * c + d][-2] = 1
for ab, cd in itertools.product(AB, CD):
    a, b = ab
    c, d = cd
    if a < c and b < d:
        G[1000 * a + b][1000 * c + d] = 1
flow_value, flow_dict = MaximumFlow().ford_fulkerson(G, -1, -2)
print(flow_value)


Measured memory_bytes: 9912
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
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;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    vector<string> s({"AC", "WA", "TLE", "RE"});
    VI cnt(4);
    int n;
    cin >> n;
    REP(i,n){
        string t;
        cin >> t;
        REP(j,4) if (s[j] == t) cnt[j]++;
    }
    REP(i,4){
        cout << s[i] << " x " << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
import math
(n,k),a,f = [list(map(int, s.split())) for s in open(0)]

a.sort()
f.sort(reverse=True)

low = 0
high = 0
for x, y in zip(a,f):
    high = max(high, x*y)

while high != low:
    test = int((high + low) // 2)
    tmp = 0
    for x, y in zip(a,f):
        tmp += max(0, x - math.floor(test / y))
        if tmp > k:
            low = test + 1
            break
    else:
        high = test
print(high)

Measured memory_bytes: 108348
#include<bits/stdc++.h>
using namespace std;
vector<int>v[400000];
int main()
{
    vector<int>::iterator it;
 long long int n,k,a,b,mx=0,sum=0,f=0,d;
    cin>>n>>k;
    for(int i=0;i<k;i++)
    {
      cin>>a>>b;
v[a].push_back(b);

    }
    d=1;
     for(int i=0;i<v[d].size();i++)
        {k=v[d][i];
        it=find(v[k].begin(),v[k].end(),n);
        if(it!=v[k].end())
        {
        f=1;
        mx=*it;
        break;
        }
        }


    if(f==1){cout<<"POSSIBLE"<<endl;}
    else{cout<<"IMPOSSIBLE"<<endl;}

}


Measured memory_bytes: 13184
#include <iostream>
#include <string>
using namespace std;
 
string divide[4] = {"dream", "dreamer", "erase", "eraser"};
bool dp[100010];
 
int main() {
    string S;
    cin >> S;
 
    dp[0] = 1;
    for(int i = 0; i < S.size(); ++i){
        for(string s : divide){
            if(S.substr(i, s.size()) == s){ // うまく切れたら先に進む
                dp[i + s.size()] = dp[i];
            }
        }
    }
    cout << (dp[S.size()] ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int a, b, i;
    char op;
    
    for(i = 1; i > 0; i++){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '+'){
            printf("%d\n", a + b);
        }
        else if(op == '-'){
            printf("%d\n", a - b);
        }
        else if(op == '*'){
            printf("%d\n", a * b);
        }
        else if(op == '/'){
            printf("%d\n", a / b);
        }
        else if(op == '?'){
            break;
        }
    }
    return 0;
}



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

using namespace std;

int main(){

	int N;
	cin >> N;
	int A[N];
	int count=0;	

	for(int i=0;i<N;i++){
		cin >> A[i];
		if((A[i]%2)==1){
			cout << count << endl;
			return 0;
		}
	}


	while(1){
		for(int i=0;i<N;i++){
			if((A[i]%2)==1){
				cout << count << endl;
				return 0;				
			}		
			A[i]=A[i]/2;
		}
		count++;	
	}

	cout << count << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int min = 1000;
        for (int i = 0; i < s.length() - 2; i++) {
            min = Math.min(calc(s.charAt(i), s.charAt(i + 1), s.charAt(i + 2)), min);
        }
        System.out.println(min);
    }
    public static int calc(char x, char y, char z) {
        int a = 100 * Character.getNumericValue(x) + 10 * Character.getNumericValue(y)
            + Character.getNumericValue(z);
        return Math.abs(753 - a);
    }
}


Measured memory_bytes: 22612
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    
print(dp[-1])

Measured memory_bytes: 52208
#include<stdio.h>
int main(){
  int y,m,d;
  scanf("%d/%d%d",&y,&m,&d);
  if(y<2019)goto YES;
  if(y>2019)goto NO;
  if(m<4)goto YES;
  if(m>4)goto NO;
  goto YES;
 NO:;
  printf("TBD\n");
  return 0;
 YES:;
  printf("Heisei\n");
  return 0;
}
  


Measured memory_bytes: 128
/*  (: ///////|||||| BEGINS |||||||\\\\ :) */
/* REMEMBER
Deletes all characters except first one     Deletes 4 characters from index number 1
    str.erase(1);                               str.erase(1,4);
Deletes character at position 4
 str.erase(str.begin() + 4);
bool compare(const pair<int, int>&a, const pair<int, int>&b)
{
   return a.second<b.second;
}
maxn = max_element(mp.begin(), mp.end(), compare)->second;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}
priority_queue <int, vector<int>, greater<int>> gquiz; // to create min heap
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
const int inf=0x3f3f3f3f;
#define mod  1000000007
#define fo(i,n) for(int i=1;i<=n;i++)
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define three_max(n1,n2,n3) (n1 > n2)?(n1>n3?n1:n3):(n2>n3?n2:n3)
#define lb lower_bound
#define ub upper_bound
#define tr(it, a) for(auto it = a.begin();it!=a.end();it++)
#define gcd(a,b) __gcd(a,b)
#define pq priority_queue 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long isprime(long long n)
{
    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return 0;
    }
    return 1;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif


ll n;
double d;
cin>>n>>d;
ll cn=0;
while(n--)
{
double x,y;
cin>>x>>y;
double cal=sqrt(x*x+y*y);
if(cal<=d)cn++;
}
cout<<cn<<endl;
return 0;
}

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

public class BinarySearch
{
    public static void Main()
    {
        Console.ReadLine();
        var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.ReadLine();
        var t = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    
//        "SearchWithHashSet".Measure(() => 
//        {
//            SearchWithHashSet(s, t);
//        });
//        "SearchWithBinarySearch".Measure(() => 
//        {
            SearchWithBinarySearch(s, t);
//        });
    }
    
    private static void SearchWithHashSet(int[] s, int[] t)
    {
//        ThreadPool.SetMinThreads(32, 32);
        var hashSet = new HashSet<int>(s);
        var c = t.Count(x => hashSet.Contains(x));
        Console.WriteLine(c);
    }
    
    private static void SearchWithBinarySearch(int[] s, int[] t)
    {
        var c = t.Count(x => BinarySearchCore(s, x) > 0);
        Console.WriteLine(c);
    }
    
    private static int BinarySearchCore(int[] s, int key)
    {
        var left = 0;
        var right = s.Count();
        
        while (left < right)
        {
            var mid = (left + right) / 2;
            if (s[mid] == key)
                return mid;
            if (key < s[mid])
                right = mid;
            else
                left = mid + 1;
        }
        
        return -1;
    }
    
}
// Define other methods and classes here

Measured memory_bytes: 17904
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

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

	int ans = 1, cur = x;

	while(cur) {
		ans++;
		cur = (cur + x) % 360;
	}

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

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

    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) ans++;
    }
    

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

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n; cin>>n;
        int rem=n%10;
        if(rem==3) cout<<"bon"<<endl;
        else if(rem==0||rem==1||rem==6||rem==8) cout<<"pon"<<endl;
        else cout<<"hon"<<endl;
}


Measured memory_bytes: 3576
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = [-1]*n
c = []
ans = 0
for i in range(k):
    s[ans] = i
    c.append(ans)
    ans = a[ans] - 1
    if s[ans] >= 0:
        t = i - s[ans] + 1
        ans = c[(k-i-1) % t + s[ans]]
        break
print(ans+1)

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int a[5];

int main(){
	REP(i,5){
		cin>>a[i];
	}
	sort(a,a+5);
	REP(i,5){
		if (i) cout<<" ";
		cout<<a[4-i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    int a;
    cin >> a;
    a += pow(a,2) + pow(a,3);
    P(a);
    
    return  0;
}


Measured memory_bytes: 4000
N = int(input())
p_list = list(map(int, input().split()))
sorted_list = sorted(p_list)
count = 0
for p, s in zip(p_list, sorted_list):
    if p != s:
        count += 1
if count == 0 or count == 2:
    print('YES')
else:
    print('NO')

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

typedef pair<int,int> P;
typedef pair<int,P> PP;

int N, M, H, K;

int main() {
    while (cin >> N >> M >> H >> K, N || M || H || K) {
        vector<vector<int>> v(N), c(N), h(N), r(N);
        for (int i = 0; i < M; i++) {
            int x, y, z, w, u;
            cin >> x >> y >> z >> w >> u;
            x--, y--, u--;
            v[x].push_back(y);
            v[y].push_back(x);
            c[x].push_back(z);
            c[y].push_back(z);
            h[x].push_back(w);
            h[y].push_back(w);
            r[x].push_back(u);
            r[y].push_back(u);
        }

        int S, T, Q;
        cin >> S >> T >> Q;
        S--, T--;
        vector<int> price(Q);
        vector<int> cam(Q);

        for (int i = 0; i < Q; i++) {
            int l;
            cin >> l >> price[i];
            for (int j = 0; j < l; j++) {
                int x;
                cin >> x;
                cam[i] |= (1 << (x - 1));
            }
        }

        const int INF = 1 << 27;
        vector<int> dp_p(1 << K, INF);
        dp_p[0] = 0;
        for (int i = 0; i < 1 << K; i++) {
            for (int j = 0; j < Q; j++) {
                if ((i | cam[j]) < (1 << K))
                    dp_p[i|cam[j]] = min(dp_p[i|cam[j]], dp_p[i] + price[j]);
            }
        }

        int ans = INF;
        for (int i = 0; i < 1 << K; i++) {
            if (dp_p[i] == INF) continue;

            vector<vector<int>> dp(N+1, vector<int>(H+1, INF));
            dp[S][0] = 0;

            priority_queue<PP, vector<PP>, greater<PP>> que;
            que.push(PP(0, P(0, S)));

            while (que.size()) {
                PP p = que.top(); que.pop();
                int cost = p.first;
                int now = p.second.second;
                int hour = p.second.first;

                if (dp[now][hour] < cost) continue;

                for (int j = 0; j < v[now].size(); j++) {
                    int next = v[now][j];
                    int ncost = cost;
                    if ((i & (1 << r[now][j])) == 0) ncost += c[now][j];
                    int nhour = hour + h[now][j];

                    if (nhour <= H && dp[next][nhour] > ncost) {
                        dp[next][nhour] = min(dp[next][nhour], ncost);
                        que.push(PP(ncost, P(nhour, next)));
                    }
                }
            }

            for (int j = 0; j <= H; j++) {
                ans = min(ans, dp[T][j] + dp_p[i]);
            }
        }

        if (ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3284
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int in_A;
    int in_B;
    
    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");
      in_A         = Integer.parseInt(in_str_split[0]);
      in_B         = Integer.parseInt(in_str_split[1]);


      /*----------------
       * 計算
       *----------------*/
      if((0 != (in_A % 2)) && (0 != (in_B % 2)))
      {
        System.out.println("Yes");
      }
      else
      {
        System.out.println("No");
      }
      
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin >> n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++){
        cin >> v[i];
        v[i] = v[i]-(i+1);
    }
    ll ans = 0;
    sort(v.begin(),v.end());
    ll s;
    if(n%2!=0){
        s = v[(n)/2];
    }else{
        s = (v[n/2]+v[(n-1)/2])/2;
    }
    for(ll i=0;i<n;i++){
        ans += abs(v[i]-s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }
    vector<int> B(N);
    for (int i=0; i<N; i++){
        B.at(A.at(i)-1) = i+1;
    }
    for (int i=0; i<N; i++){
        cout << B.at(i) << ' ';
    }
   return 0;
}

Measured memory_bytes: 1536
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){

    int N, M, K;
    cin >> N >> M >> K;

    UnionFind uf(N);

    int a, b;
    vector<int> dame(N);
    REP(i, M){
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
        dame[a]++;
        dame[b]++;
    }

    ll c, d;
    REP(i, K){
        cin >> c >> d;
        c--; d--;
        if (uf.issame(c, d)) {
            dame[c]++;
            dame[d]++;
        }
    }

    REP(i, N){
        cout << uf.size(i) - dame[i] - 1;
        if (i < N - 1) cout << " ";
        else cout << endl;
    }


    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>
using namespace std;
int a[101][101][3][3];
int main(){
	int h,w;
	while(1){
		scanf("%d%d",&w,&h);
		if(w==0&&h==0)break;
		memset(a,0,sizeof(a));
		for(int i=1;i<101;i++){
			a[1][i][0][0]=1;
			a[i][1][1][1]=1;
		}
		for(int i=2;i<101;i++){
			for(int j=2;j<101;j++){
				a[i][j][0][0]=(a[i][j-2][0][0]+a[i][j-2][1][0]+a[i][j-2][1][1])%100000;
				a[i][j][1][0]=(a[i-1][j-1][0][1]+a[i-1][j-1][1][1])%100000;
				a[i][j][0][1]=(a[i-1][j-1][0][0]+a[i-1][j-1][1][0])%100000;
				a[i][j][1][1]=(a[i-2][j][0][0]+a[i-2][j][0][1]+a[i-2][j][1][1])%100000;
			}
		}
		
		cout<<(a[w][h][0][0]+a[w][h][0][1]+a[w][h][1][0]+a[w][h][1][1])%100000<<endl;
	}	
}

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

int m, n;
int w[200010], t[200010];
int dp[100010];
int c[20], b[20];

bool isOK(int i, int left, int right){
	return (c[i] >= w[right+1]-w[left]) && (b[i] >= t[right+1]-t[left]);
}

int search(int i, int num){
	int left = num-1;
	int right = m;
	while(right - left > 1){
		int mid = left + (right - left) / 2;
		if(isOK(i, num, mid)) left = mid;
		else right = mid;
	}
	
	return right;
}


int solve(int bit){
	if(bit == ((1 << n)-1)){
		return 0;
	}
	
	if(dp[bit] != -1) return dp[bit];	
	
	int ans = 0;
	for(int i = 0;i < n;i++){
	  if((bit & (1 << i)) == 0){
			int tmp = solve(bit | (1 << i));
			tmp = search(i, tmp);
			ans = max(ans, tmp);
		}
	}
	
	return dp[bit] = ans;
}			

int main(){
	cin >> m >> n;
	
	int wt, tt;
	for(int i = 0;i < m;i++){
		cin >> wt >> tt;
		w[i+1] = w[i] + wt;
		t[i+1] = t[i] + tt;
	}
	
	for(int i = 0;i < n;i++){
		cin >> c[i] >> b[i];
	}
	
	memset(dp,-1,sizeof(dp));
	
	cout << solve(0) << endl;	
}
	



Measured memory_bytes: 5016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	reverse(arr,arr+n);
	ll count=0;
	ll index=0;
	for(ll i=0;i<n-1;i++){
		count+=arr[index];
		if(i%2==0){
			index++;
		}
	}
	cout<<count<<"\n";
	return 0;
}

Measured memory_bytes: 5160
#include<stdio.h>
int minnum(int[], int);

int main(){
  int n, i, j, max, min;
  int R[200000];
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&R[i]);
  }

  min = R[0];
  max = R[1] - R[0];
  for( i = 1 ; i < n ; ++i ){
    if( max < R[i]-min ) max = R[i]- min;
    if( min > R[i] ) min = R[i];
  }

  printf("%d\n",max);
  return 0;
}



Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

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

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

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

	ll t;
	cin >> t;

	cout << t+pow(t,2)+pow(t,3) << endl;
}

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

#define int long long

int memo[110][110][110];

int d, n;
pair<int, pair<int, int> > ono[110];

int dp(int i, int noko, int num){
	
	if(noko <= 0){
		return 0;
	}

	if(i == n){
		return INT_MAX;
	}
	
	int r = ono[i].first;
	int a = ono[i].second.first;
	int e = ono[i].second.second;
	
	if(r > num){
		return INT_MAX;
	}
	
	if(memo[i][noko][num] != -1){
		return memo[i][noko][num];
	}
	if(a == 0 && e == 0){
		return memo[i][noko][num] = dp(i+1, noko, num);
	}
	
	if(num == 100 && a == 0){
		return memo[i][noko][num] = dp(i+1, noko, num);
	}
	
	return memo[i][noko][num] = min(dp(i, noko-a, min(100ll, num+e))+1, dp(i+1, noko, num));
}
	
signed main(){
	while(cin >> d >> n, d != 0){
		int a, e, r;
		for(int i = 0;i < n;i++){
			cin >> a >> e >> r;
			ono[i] = {r, {a, e}};
		}
		
		sort(ono, ono+n);
		
		memset(memo, -1, sizeof(memo));
		
		int ans = dp(0, d, 0);
		
		if(ans < INT_MAX){
			cout << ans << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	
	return 0;
}
		
		


Measured memory_bytes: 13516
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;





int main(void){

    

    long n,k;
    cin >>n>>k;
    string ans;

    int *arr = new int[n];

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

    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            if(arr[i]>arr[j]) swap(arr[i],arr[j]);
        }
    }

    long sum = 0;
    for(int i = 0; i < k; i++) {
        sum+= arr[i];
    }


    cout<<sum;


    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    cout << fixed << setprecision(10) << (double)((n+1)/2)/n << endl;
    return 0;
}

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

using namespace std;

int main(){

    int N,K;cin>>N>>K;
    bool canuse[10];
    fill_n(canuse,10,true);
    REP(i,K){
        int d;cin>>d;
        canuse[d]=false;
    }
    bool canPay=false;
    while(!canPay){
        int n=N;
        canPay=true;
        while(n>0){
            if(!canuse[n%10])canPay=false;
            n/=10;
        }
        N++;
    }
    cout<<N-1<<endl;

    return 0;
}

Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    ll n;
                    cin>>n;
                    // vector<vector<int>> tree(n+1);
                    vector<pair<int, int>> edges;
                    for(int i = 0; i < n-1; i++){
                        ll f, s;
                        cin>>f>>s;
                        edges.push_back({min(f, s), max(f, s)});
                        // tree[f].push_back(s);
                        // tree[s].push_back(f);
                    }

                    ll ans = 0;
                    for(int i = 0; i < n-1; i++){
                        ans -= (n-edges[i].second+1)*(edges[i].first);
                    }
                    // cout<<ans;
                    for(int i = 1; i <= n; i++)
                        ans += i*(n-i+1);
                    cout<<ans;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 5340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
ll a[maxn],b[maxn];
int  n;
ll cnt;
int main()
{
	cin>>n;
	cnt=0;
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
		cnt=cnt^a[i];
	}
	for(int i=0;i<n;++i)
	{
		b[i]=cnt^a[i];
		if(i!=n-1) printf("%d ",b[i]);
		else printf("%d\n",b[i]); 
	}
	return 0;
}

Measured memory_bytes: 6692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N;

struct Station {
  int dist, start, T;
};
vector<Station> s;

int main () {
  cin >> N;
  s.resize(N-1);

  rep(i,N-1) cin >> s[i].dist >> s[i].start >> s[i].T;

  rep(i,N-1) {
    int t = 0;
    for(int j = i; j < N - 1; j++) {
      t = max(((t + s[j].T - 1) / s[j].T) * s[j].T, s[j].start) + s[j].dist;
    }
    cout << t << endl;
  }
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
def is_tri(a, b, c):
    if a == b or b == c or a == c:  return 0
    ma = max(a, b, c)
    rest = a + b + c - ma
    if rest > ma:  return 1
    return 0

N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            ans += is_tri(L[i], L[j], L[k])
print(ans)

Measured memory_bytes: 68940
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? ((x) : -(x)))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
int P[MAXN];
int sz[MAXN];
int unode[MAXN], vnode[MAXN];
ll ANS[MAXN];

int myfind(int x) {
	return x == P[x] ? x : P[x] = myfind(P[x]);
}

void myunion(int x, int y) {
	P[y] = x;
	sz[x] += sz[y];
}

int main()
{
	int i, j;
	scanf("%d%d", &N, &M);
	for (i = 1; i <= M; ++i) {
		scanf("%d%d", &unode[i], &vnode[i]);
	}
	for (i = 1; i <= N; ++i) {
		P[i] = i;
		sz[i] = 1;
	}
	for (i = M; i >= 1; --i) {
		int u = myfind(unode[i]);
		int v = myfind(vnode[i]);
		if (u != v) {
			ANS[i] = (ll)sz[u] * (ll)sz[v];
			myunion(u, v);
		}
	}
	for (i = 1; i <= M; ++i) {
		ANS[i] += ANS[i - 1];
		printf("%lld\n", ANS[i]);
	}
	return 0;
}

Measured memory_bytes: 3712
#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 argc, char const *argv[]) {
	int AB, BC, CA; cin >> AB >> BC >> CA;
	cout << AB * BC / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
candidate=[0]*4
if h*w%3==0:
	print(0)
	exit()

def solve(a,b,k):
	candidate[k]=a
	cnd=float('inf')
	for i in range(a+1):
		c1=b*i
		c2=(a-i)*(b//2)
		c3=(a-i)*(b-b//2)
		cnd=min(cnd,max(c1,c2,c3)-min(c1,c2,c3))
	candidate[k+1]=cnd

solve(h,w,0)
solve(w,h,2)
print(min(candidate))





Measured memory_bytes: 3064
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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


signed main() {
    int n,m;cin >>n>>m;
    vector<int> hi(n),est(n,-1);
    rep(i,n)cin>>hi[i];
    vector<vector<int>> a(n);


    rep(i,m){
        int a_,b;cin >>a_>>b;
        a_--;b--;
        est[a_]=max(est[a_],hi[b]);
        est[b]=max(est[b],hi[a_]);
    }
    int ans=0;
    rep(i,n){
        if(hi[i]>est[i]||est[i]==-1)ans++;
    }

    cout <<ans<<endl;
}

















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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

signed main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H+1, vector<int>(W+1));
    vector<vector<int>> B(H+1, vector<int>(W+1));
    REP(i,1,H+1) REP(j,1,W+1) cin >> A[i][j];
    REP(i,1,H+1) REP(j,1,W+1) cin >> B[i][j];

    const int DIFF_MAX = (80 + 80) * 80;
    vector<vector<bool>> dp(W+1, vector<bool>(DIFF_MAX,false)), dpPrev(W+1, vector<bool>(DIFF_MAX,false)); // red is (n-80) larger than blue.
    dpPrev[1][DIFF_MAX / 2] = true;

    REP(i,1,H+1) {
        REP(j,1,W+1) {
            REP(k,0,DIFF_MAX) {
                if (!dp[j-1][k] && !dpPrev[j][k]) continue;
                const int diff = abs(A[i][j] - B[i][j]);
                if (k + diff <= DIFF_MAX) dp[j][k+diff] = true;
                if (k - diff >= 0) dp[j][k-diff] = true;
            }
        }
        swap(dp, dpPrev);

        // clear
        REP(i,1,W+1) {
            dp[i].clear();
        }
        dp.clear();
        dp = vector<vector<bool>>(W+1, vector<bool>(DIFF_MAX,false));
    }
    int answer = INT_MAX;
    REP(k,0,DIFF_MAX) {
        if (!dpPrev[W][k]) continue;
        answer = min(answer, abs(k - DIFF_MAX / 2));
    }

    cout << answer << "\n";

    return 0;
}


Measured memory_bytes: 512
a = list(map(int,[input() for i in range(5)]))
b = 10
c = 0
for i in a:
	if i % 10 > 0:
		c += i + 10 - i % 10
		if b > i % 10:
			b = i % 10
	else:
		c += i
print(c-10+b)


Measured memory_bytes: 2940
while True:
  H,W = map(int,input().split())
  H1 = H-1
  W1 = W-1
  if H == 0 and W == 0:
    break
  for i in range(H):
    for s in range(W):
      if i ==0 or i ==H1:
        print('#',end='')
      else:
        
        if s == 0 or s==W1:
          print('#',end='')
        else:
          print('.',end='')
    print()
  print()


Measured memory_bytes: 7008
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    if (len == 1) {
        cout << "YES" << endl;
        return 0;
    }
    int cnt[3] = {};
    rep(i, S.length()) {
        cnt[S[i] - 'a']++;
    }
    sort(cnt, cnt + 3, greater<int>());
    if (cnt[1] == 0) {
        cout << "NO" << endl;
    } else if (cnt[2] == 0) {
        if(len == 2) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    } else if (cnt[0] - cnt[2] < 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }

    vector<int>adj[200005];
    bool vis[200005];
    int maxi=0;
    int dfs(int u){
        int ans=0;
        if(!vis[u]){
            vis[u]=true;
            ans++;
            for(auto v : adj[u]){
                ans+=dfs(v);
            }
        }
        return ans;
    }

    void solve(){  
        int n,m;
        cin>>n>>m;
        memset(vis,false,sizeof(vis));
        for(int i=0;i<m;i++){
            int a,b;
            cin>>a>>b;
            a--;
            b--;
            adj[a].push_back(b);
            adj[b].push_back(a);
        }
        for(int i=0;i<n;i++){
            if(!vis[i]){
                maxi=max(maxi,dfs(i));
            }
        }
        cout<<maxi;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


Measured memory_bytes: 21024