akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
 
struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n, m;
int main(){
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

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

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


int n, a[101010], d[101010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		d[a[i]] = i+1;
	}
	
	for(int i = 1; i <= n; i++){
		cout << d[i] << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1664
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

ac = [0]*(N+1)
bc = [0]*(N+1)

ok = True
for i in range(N):
    ac[A[i]] += 1
    bc[B[i]] += 1

d = 0
for i in range(1, N+1):
    if (ac[i]+bc[i]) > N:
        ok = False
        break
    ac[i] += ac[i-1]
    bc[i] += bc[i-1]
    d = max(d, ac[i]-bc[i-1])

if ok:
    print("Yes")
    print(*[B[(i+N-d) % N] for i in range(N)])
else:
    print("No")


Measured memory_bytes: 130332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define end end()
#define vec vector<ll>
#define se set<ll>
#define mults multiset<ll>
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b
#define get(a) cin>>a
#define nextl cout<<endl
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    int a,b;
    cin>>a>>b;
    int x=a-2*b;
    if(x<0) x=0;
    pr(x);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }
ll N, M, X;
vector<vll> A;
vll C;

int main(){
    cin >> N>>M>>X;
    A.resize(N); C.resize(N);
    REP(i, N){
        cin >> C[i];
        ll tmp;
        REP(j, M){
            cin >> tmp;
            A[i].push_back(tmp);
        }
    }
    ll ans = INF;
    REP(msk, 1LL << N){
        vll alg(M, 0);
        ll tmp_cost = 0;
        REP(i, N){
            if(msk >> i & 1){
                REP(j, M){
                    alg[j]+= A[i][j];
                }
                tmp_cost += C[i];
            }
            bool isGood = true;
            REP(j, M){
                if(alg[j] < X) isGood = false;
            }
            if(isGood){
                chmin(ans, tmp_cost);
            }
        }
    }
    if(ans >= INF){
        cout<<-1<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll k;
 cin>>k;
 vector<mp> clas(k);
 for(ll i=0;i<k;i++){
  string s;
  cin>>s;
  int a=0,b=0;
  a = ( (s[0]-'0')*10+(s[1]-'0') )*60 + ( (s[3]-'0')*10+(s[4]-'0') );
  b = ( (s[6]-'0')*10+(s[7]-'0') )*60 + ( (s[9]-'0')*10+(s[10]-'0') );
  clas[i] = mp(a,b);
 }

 vector<ll> cntt(k,0);
 vector<ll> cnts(k,0);
 ll n;
 cin>>n;
 for(ll i=0;i<n;i++){
   ll t;
   cin>>t;
   for(ll j=0;j<t;j++){
    string s;
    cin>>s;
    int a=0,b=0;
    a = ( (s[0]-'0')*10+(s[1]-'0') )*60 + ( (s[3]-'0')*10+(s[4]-'0') );
    b = ( (s[6]-'0')*10+(s[7]-'0') )*60 + ( (s[9]-'0')*10+(s[10]-'0') );
    for(ll l=0;l<k;l++){
     if( a<= clas[l].first && clas[l].second <= b ) cntt[l]++;
    }
   }
 }

  n;
 cin>>n;
 for(ll i=0;i<n;i++){
   ll t;
   cin>>t;
   for(ll j=0;j<t;j++){
    string s;
    cin>>s;
    int a=0,b=0;
    a = ( (s[0]-'0')*10+(s[1]-'0') )*60 + ( (s[3]-'0')*10+(s[4]-'0') );
    b = ( (s[6]-'0')*10+(s[7]-'0') )*60 + ( (s[9]-'0')*10+(s[10]-'0') );
    for(ll l=0;l<k;l++){
     if( a<= clas[l].first && clas[l].second <= b ) cnts[l]++;
    }
   }
 }

 ll sum = 0;
 for(ll i=0;i<k;i++) sum += min( cntt[i] , cnts[i] );

cout<<sum<<endl;
 
 return 0;
}



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

int main() {
	while(1) {
		int res = 0;
		string in;
		cin >> in;

		if (in == "0")
			break;

		for (int i = 0; i < in.size(); i++)
			res += in[i] - '0';

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 3172
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (H, W, K) = Scanner.Scan<int, int, int>();
            var G = new bool[H][].Select(x => Scanner.Scan<string>().Select(x => x == '#').ToArray()).ToArray();

            var answer = 0;
            for (var i = 0; i < 1 << H; i++)
            {
                for (var j = 0; j < 1 << W; j++)
                {
                    var count = 0;
                    for (var h = 0; h < H; h++)
                    {
                        for (var w = 0; w < W; w++)
                        {
                            if (G[h][w] && (i >> h & 1) == 1 && (j >> w & 1) == 1) count++;
                        }
                    }
                    if (count == K) answer++;
                }
            }

            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28380
def main():
	# n,m = map(int,input().split())
	n = int(input())
	l = [str(input()) for i in range(n)]
	
	import collections

	c = collections.Counter(l)
	lc = sorted(list(c.items()), key = lambda x:x[1] , reverse = True)
	# print(lc[0][0])
	ans = []
	checker = 0
	i = 0
	while checker == 0 and i < len(lc):
		if lc[i][1] == lc[0][1]:
			ans.append(lc[i][0])
		else:
			checker += 1
		i += 1

	# keys = [k for k, v in c.items() if v == max(c.values())]
	# print(list(c.items())[0][0])
	# checker = 0
	# while checker == 0:
	# 	if c.items() == max(c.values()):
	ans.sort()
	print('\n'.join(map(str, ans)))

	
	
 
if __name__ == '__main__':
	main()

Measured memory_bytes: 129324
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
      	String s = sc.next();
     	int howlong = s.length();	

      if(K < howlong){
      	s = s.substring(0,K) + "..." ;
      }        
		System.out.println(s);
	}
 
}

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

using namespace std;

typedef long long ll;

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

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

  const int MOD = 998244353;

  vector<vector<ll>> dp(c-a+1, vector<ll>(d-b+1));
  dp[0][0] = 1;
  for (int i = 0; i <= c-a; ++i) {
    for (int j = 0; j <= d-b; ++j) {
      if (i > 0) {
        dp[i][j] = dp[i-1][j]*(b+j)%MOD;
      }
      if (j > 0) {
        dp[i][j] = (dp[i][j]+dp[i][j-1]*(a+i))%MOD;
        if (i > 0) {
          dp[i][j] = (dp[i][j]-dp[i-1][j-1]*(a+i-1)*(b+j-1)%MOD)%MOD;
        }
      }
    }
  }

  cout << (dp[c-a][d-b] < 0 ? dp[c-a][d-b]+MOD : dp[c-a][d-b]) << endl;


  
  return 0;
}




Measured memory_bytes: 73652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define INF 1010101010

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	vector<vector<int>> dp(h, vector<int>(w, INF));
	dp[0][0] = s[0][0] == '#' ? 1 : 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i != 0) {
				if (s[i][j] == s[i - 1][j]) {
					dp[i][j] = dp[i - 1][j];
				} else {
					dp[i][j] = dp[i - 1][j] + 1;
				}
			}
			if (j != 0) {
				if (s[i][j] == s[i][j - 1]) {
					dp[i][j] = min(dp[i][j], dp[i][j - 1]);
				} else {
					dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
				}
			}
		}
	}
	dp[h - 1][w - 1] += s[h - 1][w - 1] == '#' ? 1 : 0;

	cout << dp[h - 1][w - 1] / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] ans = new int[N + 1];
        int[] a = new int[M];
        int[] b = new int[M];

        for(int i=0; i<M; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            ans[a[i]] += 1;
            ans[b[i]] += 1;
        }
        for(int i=1; i<=N; i++){
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 22740
import sys
import math
import bisect
 
def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    ans = 0
    for i in range(1, n + 1):
        if i <= k:
            ans += x
        else:
            ans += y
    print(ans)
 
if __name__ == "__main__":
    main()


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

using namespace std;

int n;
vector<int> a(101);
vector<int> b(101);

int main(){
    a[0] = 0;
    b[0] = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        a[i+1] = a[i] + tmp;
    }
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        b[i+1] = b[i] + tmp;
    }

    int max_val = 0;
    for(int i = 0; i < n; i++){
        max_val = max(max_val, a[i+1] + b[n] - b[i]);
    }

    cout << max_val << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int r, g;
   cin >> r >> g;
   cout << 2*g - r << endl;

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define MAX 10000
int sosu[MAX]={1,1,0};
int main(){
	ll out[100]={0};
	out[99]=1;
	loop(i,2,1500)if(sosu[i]==0){
		for(int j=i;j<MAX;j+=i)sosu[j]=i;
		ll tmp=0;
		for(int j=99;j>=1;j--){
			out[j]=out[j]*i+tmp;
			tmp=out[j]/(int)1e9;
			out[j]%=(int)1e9;
		}
	}
	out[99]+=2;
	bool h=false;	
	rep(i,100)if(out[i]||h){
		if(h)printf("%09d",out[i]);
		else printf("%d",out[i]);
		h=true;
	}
	cout<<endl;
	int n;cin>>n;
	rep(i,n)cout<<sosu[i+2]<<endl;
}

Measured memory_bytes: 1248
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
    
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        if sum < g:
            use = max(nokori)
            n = min(pc[use-1][0], -(-(g-sum)//(use*100)))
            count += n
            sum += n * use * 100
        if sum >= g:
            ans = min(ans, count)
    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], nokori-{i+1})
ans = float("inf")
dfs(0, 0, 0, set(range(1, d+1)))
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 );
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< std::string, int64_t > origin, std::pair< std::string, int64_t > another )
{
    return origin.second  > another.second;
}
 
int main()
{
    std::string word = "aa";
    int64_t a,b,c,d,e;
    std::cin>> a;
    std::cin>> b;
    c = 0;

    std::priority_queue< int64_t > q;
    
    for( int i = 0; i < a; i++ )
    {
        std::cin>> d;
        q.push( d );
    }

    for( int i = 0; i < b; i++ )
    {
        if( q.empty() )
        {
            break;
        }
        else
        {
            q.pop();
        }
    }

    while( ! q.empty() )
    {
        c += q.top();
        q.pop();
    }

    std::cout<< c;
}


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

using namespace std;
typedef pair<int, int> P;

int table[10][10];

int first(int n) {
  while (n >= 10) {
    n /= 10;
  }
  return n;
}

int last(int n) {
  return (n % 10);
}

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

  for (int i = 11; i <= 99; ++i) {
    int first1 = first(i);
    int last1 = last(i);
    for (int j = 1; j <= N; ++j) {
      int first2 = first(j);
      int last2 = last(j);
      if (first1 == last2 && last1 == first2) {
	table[first1][last1]++;
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int f = first(i);
    int l = last(i);
    ans += table[f][l];
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
    ll N; cin>>N;
    map<string,ll> mp;
    vector<string> w(N);
    for (ll i = 0; i < N; i++){
        cin>>w[i];
        mp[w[i]]++;
    }
    for (ll i = 1; i < N; i++){
        if(mp[w[i]]>=2){ //同じ単語が2回以上出ているか判定
            cout<<"No"<<endl;
            return 0;
        }
        if(w[i-1][w[i-1].size()-1]==w[i][0]){ //しりとり
                continue;
        }else{
                cout<<"No"<<endl;
                return 0;
        }
    }
    cout<<"Yes"<<endl;
    
}


Measured memory_bytes: 3624
n=int(input())
#a,b=map(int,input().split())
a=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
mx=abs(a[0]-a[1])
for i in range(n):
    for j in range(i+1,n):
        mx=max(mx,abs(a[i]-a[j]))

print(mx)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define ld double
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define len length()
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

void solve() {
    int h, cnt = 0, ans = 0; cin >> h;
    while (h > 0) {
        ans += (1ll << cnt);
        ++cnt; h = (h >> 1ll);
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N, M;
    cin >> N >> M;
    
    vec H(N);
    REP(i,0,N) cin >> H[i];
    mat T(N);
    REP(i,0,M) {
        ll a, b;
        cin >> a >> b;
        --a; --b;
        T[a].pb(b);
        T[b].pb(a);
    }

    bool f;
    ll cnt = 0;
    REP(i,0,N) {
        f = true;
        FORR(j,T[i]) {
            if(H[i] <= H[j]) {
                f = false;
                break;
            } 
        }
        if(f) ++cnt; 
    }
    _PR(cnt);

    return 0;
}

/*



*/

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

bool isPrime(int i) {
  if(i==0||i==1) return false;
  for(int j=2;j*j<=i;j++) {
    if(i%j==0) return false;
  }
  return true;
}

int isLike2017(int i) {
  if(isPrime(i)&&isPrime((i+1)/2)) return 1;
  return 0;
}

int main() {
  vector<int> s(100005,0);
  int q;
  cin>>q;
  int l,r;
  for(int i=0;i<100000;i++) {
    s[i+1]=s[i]+isLike2017(i);
  }
  for(int i=0;i<q;i++) {
    cin>>l>>r;
    cout<<s[r+1]-s[l]<<endl;
  }
}


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

int main(void){
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    int x[N+1],y[M+1];

    for(int i=0;i<N;i++)
        cin>>x[i];

    for(int i=0;i<M;i++)
        cin>>y[i];

    x[N]=X;
    y[M]=Y;

    sort(x,x+N+1);
    sort(y,y+M+1);


    if(x[N]<y[0])
        cout<<"No War"<<endl;
    else
        cout<<"War"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned long ul;

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

    int ans = min(a+b, c) + b + ((c-a-b) >= 1);
    cout << ans << endl;

    return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a < b)
    {
        cout << "a < b" << endl;
    }
    else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }
}



Measured memory_bytes: 3096
//
//  main.cpp
//  dp
//
//  Created by 贾皓翔 on 2019/11/26.
//  Copyright © 2019 贾皓翔. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

char buf[1024];
int main(){
    int N;
    cin>>N;
    cin>>buf;
    int cnt=0;
    for(int i=0;i<N-2;i++){
        if (buf[i]=='A'&&(buf[i+1]=='B')&&buf[i+2]=='C') {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    

}




Measured memory_bytes: 256
N = int(input())


def msb(x):
    while x >= 10:
        x //= 10
    return x


n = [[0] * 9 for i in range(9)]

for i in range(1, N + 1):
    l = i % 10
    if l == 0:
        continue
    m = msb(i)
    n[l - 1][m - 1] += 1

ans = 0
for i in range(9):
    for j in range(9):
        ans += n[i][j] * n[j][i]
print(ans)


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

typedef long long ll;

int main(){
    ll N; cin >> N;
    vector<ll> a(N);
    for(ll i=0; i<N; i++){
        cin >> a[i];
    }
    
    
    ll sum=0;

    for(ll j=0; j<a.size(); j++){
        sum += a[j]-1;
    }
    cout << sum << endl;
}


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

int main(){
	int r,c,a[101][101] = {0};
	
	cin >> r >> c;
	
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++) {
			cin >> a[i][j];
			a[r][j] += a[i][j];
			a[i][c] += a[i][j];
			a[r][c] += a[i][j];
		}
	}
	for (int i = 0; i <= r; i++){
		for (int j = 0; j <= c; j++) {
			cout << a[i][j] << " \n"[j==c];
		}
	}
	
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string a,b;
    cin>>a>>b;
    sort(all(a));
    sort(all(b),greater<char>());
    if(a<b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back

//transform(s.begin(), s.end(), s.begin(), ::tolower); //to convert a string entirely to lower case

//toupper(s[i]) or tolower(s[i]) // converting a character to upper or lower case

//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


//vec.insert(v.begin(),value)   -> to insert a value in the vector at the begin

// printf ("%.9f\n",x);
// cout << fixed << setprecision(9);

//covert integer to string :  to_string(integer)

bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        ll n;
        cin >> n;

        ll x,c=0;
        for(ll i = 1; i<=n; i++)
        {
            cin >> x;
            if(i%2 != 0 && x%2 != 0)
            {
                ++c;
            }
        }
        cout << c << endl;
    return 0;
}   

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n,mm=0;
	cin >> n;
	long long ans=0;
	for (int i = 0;i < n;i++) {
		int x;cin >> x;
		mm = max(mm, x);
		ans += mm - x;
	}
	cout << ans << endl;
	return  0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
				Scanner sc = new Scanner(System.in);
				int s = sc.nextInt();
				System.out.print(s/3600+ ":");
				s=s%3600;
				System.out.println(s/60+":"+s%60);
			}
		}



Measured memory_bytes: 26284
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

int main(void) {
    int i;
    int a[7];
    REP (i,7) cin >> a[i];
    ll ans = 0;
    if (a[0] && a[3] && a[4] && a[0] % 2 + a[3] % 2 + a[4] % 2 >= 2) {
        ans += 3;
        a[0]--;
        a[3]--;
        a[4]--;
    }
    ans += a[0] / 2 * 2;
    ans += a[1];
    ans += a[3] / 2 * 2;
    ans += a[4] / 2 * 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define for(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N;cin >> N;
cout << N + N*N + N*N*N << endl;
}

Measured memory_bytes: 3636
N = gets.to_i
A = gets.split.map(&:to_i)
even, odd = A.partition.with_index{|v,i| i.even?}

ce = even.size
co = odd.size
we = even.each_with_object(Hash.new(0)){|v, o| o[v] += 1 }.sort_by{|k,v| v}.reverse.take(2)
wo = odd.each_with_object(Hash.new(0)){|v, o| o[v] += 1 }.sort_by{|k,v| v}.reverse.take(2)

if we.size == 1 && wo.size == 1 && we.first[0] == wo.first[0]
  puts [we.first[1], wo.first[1]].min
else
  puts [ 
      we.first[0] == wo.first[0] ? N : ce - we.first[1] + co - wo.first[1], 
      we.first[0] == wo.last[0]  ? N : ce - we.first[1] + co - wo.last[1] ,
      we.last[0]  == wo.first[0] ? N : ce - we.last[1]  + co - wo.first[1],
      we.last[0]  == wo.last[0]  ? N : ce - we.last[1]  + co - wo.last[1] 
    ].min
end


Measured memory_bytes: 19360
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//.splitで文字列を区切る
		String[] line = sc.nextLine().split(" ");

		//int型にして格納していく
		int a1 = Integer.parseInt(line[0]);
		int a2 = Integer.parseInt(line[1]);
		int a3 = Integer.parseInt(line[2]);
		int a4 = Integer.parseInt(line[3]);
		int a5 = Integer.parseInt(line[4]);
		int a6 = Integer.parseInt(line[5]);

		int b = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < b; i++) {

			int ue = sc.nextInt();
			int mae = sc.nextInt();
			int ans = 0;

			if (ue == a1 || ue == a6) {
				if (mae == a2) {
					ans = 3;
				} else if (mae == a3) {
					ans = 5;
				} else if (mae == a4) {
					ans = 2;
				} else {
					ans = 4;
				}
			}

			if (ue == a2 || ue == a5) {
				if (mae == a1) {
					ans = 4;
				} else if (mae == a3) {
					ans = 1;
				} else if (mae == a4) {
					ans = 6;
				} else {
					ans = 3;
				}
			}

			if (ue == a3 || ue == a4) {
				if (mae == a1) {
					ans = 2;
				} else if (mae == a2) {
					ans = 6;
				} else if (mae == a5) {
					ans = 1;
				} else {
					ans = 5;
				}
			}

			if (ue == a4 || ue == a5 || ue == a6) {
				ans = 7 - ans;
			}
			System.out.println(line[ans - 1]);
		}
	}
}


Measured memory_bytes: 26148
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint h, w, k;

const int FACT_MAX = 400005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint calc(llint h, llint w)
{
  llint ret = 0;
  for(llint i = 1; i <= w-1; i++){
    ret += 2 * i * (w-i) % mod, ret %= mod;
  }
  //cout << ret << endl;
  ret *= h*h%mod, ret %= mod;
  ret *= k*(k-1)/2%mod, ret %= mod;

  //cout << ret << endl;
  for(int i = 0; i < k-2; i++){
    ret *= (h*w-2-i) % mod, ret %= mod;
  }
  //cout << ret << endl;

  ret *= fact_inv[k], ret %= mod;
  return ret;
}

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

  cin >> h >> w >> k;

  llint ans = calc(h, w) + calc(w, h);
  ans %= mod;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



int main() {
  int n;

  cin >> n;

  if (n == 1 || n == 2) {
    cout << 0 << endl;
  } else if (n % 2 == 0) {
    cout << n / 2 - 1 << endl;
  } else {
    cout << n / 2 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	ll n;
	cin >> n;
	ll now = -1,ans=0;
	priority_queue<P> q;
	FOR(i,0,n){
		ll a,b;
		cin >> a >> b;
		q.push({-b,a});
	}
	while(!q.empty()){
		P next = q.top();
		q.pop();
		if(next.second<=now)continue;
		now = -next.first;
		ans++;
	}
	cout << ans << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 064 D / Link: http://abc064.contest.atcoder.jp/tasks/abc064_d  ----- */


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

	LL N; cin >> N;
	string s; cin >> s;
	int R = 0, L = 0;
	FOR(i, 0, N) {
		if (s[i] == '(') {
			L++;
		}
		else { // )
			if (L > 0)L--;
			else R++;
		}
	}
	string ans = string(R, '(') + s + string(L, ')');
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

#define int long long

const int MAX = LLONG_MAX/10;
/* 現在地 コスト 残り時間 */
typedef tuple<int,int,int> tp;

/* first: 移動先   second: 移動コスト */
typedef pair<int,int> P;

vector<P > G[110];

void solve(int n,int m,int l,int k,int a,int h){
  /* 最短経路を格納する dist[町][残りの時間] */
  int dist[110][110];
  for(int i=0;i<110;i++){
    for(int j=0;j<110;j++){
      dist[i][j]=MAX;
    }
  }

  /* 冷凍施設のある都市かどうか */
  vector<bool> freeze(110,false);
  for(int i=0;i<l;i++){
    int town;cin>>town;
    freeze[town]=true;
  }

  /* 経路情報の初期化 */
  for(int i=0;i<110;i++){
    G[i].clear();
  }
  /* 経路情報を格納 */
  for(int i=0;i<k;i++){
    int x,y,t;
      cin>>x>>y>>t;
      G[x].push_back(mp(y,t));
      G[y].push_back(mp(x,t));
  }

  /* 拡張ダイクストラパート */
  priority_queue<tp,vector<tp>,greater<tp> > que;
  que.push(make_tuple(a,0,m));
  while(que.size()){
    /* 現在地 コスト 残り時間 */
    int now,cost,time;
    tie(now,cost,time)=que.top();que.pop();
    if(dist[now][time]<cost)continue; /* すでにコストがも止まっていた時 */

    for(auto x : G[now]){
      if(freeze[now]){/* 休憩所があったら休憩したいね */
	for(int i=0;i<=m;i++){
	  if(m<time+i)break; /* これ以上休憩しても時間の無駄無駄無駄ァ!!! */
	  if(time+i-x.second<0)continue; /* 移動中に溶けてしまうので */

	  /* 最短経路を計算する */
	  if(cost+i+x.second<dist[x.first][time+i-x.second]){
	    dist[x.first][time+i-x.second]=cost+i+x.second;
	    que.push(make_tuple(x.first,dist[x.first][time+i-x.second],time+i-x.second));
	  }
	}
      }else{ /* 休憩所がないので進むしかないね */
	/* 氷が溶けちゃうね */
	if(time-x.second<0)continue;
	/* 最短経路を計算する  */
	if(cost+x.second<dist[x.first][time-x.second]){
	  dist[x.first][time-x.second]=cost+x.second;
	  que.push(make_tuple(x.first,dist[x.first][time-x.second],time-x.second));
	}
      }
    }
  }

  int maxi=MAX;
  for(int i=0;i<110;i++){
    maxi=min(maxi,dist[h][i]);
  }
  if(maxi==MAX)cout<<"Help!"<<endl;
  else cout<<maxi<<endl;
}

signed main(){
  int n,m,l,k,a,h;
  while(cin>>n>>m>>l>>k>>a>>h,n|m|l|k|a|h){
    solve(n,m,l,k,a,h);
  }
}



Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
string S;
cin >> S;
int c = 1;
for(int i  =1 ;i<S.size();i++){
if(S[i] == S[i-1]){
    i+=2;
    c+=2;
    if(i+1 - S.size() == 1) c--;
    if(i+1 -S.size() == 2 ) c -= 2;
}
else if(S[i] != S[i-1]){
    c++;
}
}
cout << c << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define LL long long
using namespace std;

const string YES = "Yes";
const string NO = "No";

pair<int, LL> find(vector<pair<int, LL>> &tab, int a){
    if(tab[a].first==-1)return make_pair(a, 0);
    auto d = tab[a].second;
    auto p = find(tab, tab[a].first);
    tab[a] = make_pair(p.first, p.second+d);
    return tab[a];
}

void merge(vector<pair<int, LL>> &tab, int l, int r, LL d){
    auto pl=find(tab, l);
    auto pr=find(tab, r);
    if(pl.first!=pr.first){
        tab[pl.first]=make_pair(pr.first, (pr.second+d)-pl.second);
    }
}

void solve(long long N, long long M, std::vector<long long> L, std::vector<long long> R, std::vector<long long> D){
    vector<pair<int, LL>> tab(N+1, make_pair(-1, 0));
    for(LL i=0; i<M; i++){
        auto l=L[i], r=R[i], d=D[i];
        if(find(tab, l).first != find(tab, r).first)
            merge(tab, l, r, d);
        else if(find(tab, l).second - find(tab, r).second != d){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    std::vector<long long> D(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
        scanf("%lld",&D[i]);
    }
    solve(N, M, std::move(L), std::move(R), std::move(D));
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  string s;
  cin >> s;
  string f = "FESTIVAL";
  cout << s.substr(0, s.size() - f.size()) << endl;
  return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  int ans = 700;
  rep(i,s.size())
    if(s[i] == 'o') ans+=100;

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


Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int a,b,n;
    bool ok=true;
    cin>>a>>b>>n;
    lol(i,n){
	int x,y;cin>>x>>y;
	if(a<=x&&x<b)ok=false;
	if(a<y&&y<=b)ok=false;
	if(x<=a&&b<=y)ok=false;
    }
    cout<<1-ok<<endl;
    return 0;
}



Measured memory_bytes: 3100
if __name__ == '__main__':
    w, h, n = [int(x) for x in input().split()]
    dots = []
    x_start = 0
    y_start = 0
    x_finish = w
    y_finish = h
    zero_flag = False
    for _ in range(n):
        dots.append([int(x) for x in input().split()])
    for dot in dots:
        if dot[2] == 1:
            if dot[0] > x_start:
                x_start = dot[0]
        if dot[2] == 2:
            if dot[0] < x_finish:
                x_finish = dot[0]
        if dot[2] == 3:
            if dot[1] > y_start:
                y_start = dot[1]
        if dot[2] == 4:
            if dot[1] < y_finish:
                y_finish = dot[1]
        if x_finish <= x_start or y_finish <= y_start:
            zero_flag = True
            break

    if zero_flag:
        ans = 0
    else:
        ans = (x_finish - x_start) * (y_finish - y_start)
    print(ans)

Measured memory_bytes: 3064
<?php
  	fscanf(STDIN,"%d %d",$n,$m);
	$h_li = array();
	$h_li = explode(" ",trim(fgets(STDIN)));
	$tenbou = array();
	for($i=0;$i<$m;$i++){
     	 $ab = explode(" ",trim(fgets(STDIN)));
      	 $tenbou[$ab[0]][] = $h_li[$ab[1]-1];
      	$tenbou[$ab[1]][] = $h_li[$ab[0]-1];
    }

//print_r($tenbou);

$count=0;


for($i=1;$i<=$n;$i++){
   // echo $i." ".$h_li[$i-1]."\n";

  if(empty($tenbou[$i])){
    $count++;
    continue;
  }
  
  rsort($tenbou[$i]);
   // print_r($tenbou[$i]);

  if($tenbou[$i][0]<$h_li[$i-1]){
    $count++;
  }
}
echo $count."\n";
   

Measured memory_bytes: 61172
N = int(input())
L = list(map(int, input().split()))

count = 0
for i in range(N-2):
    for j in range(i+1, N-1, 1):
        for k in range(j+1, N, 1):
            if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                if max(L[i], L[j], L[k]) < (L[i]+L[j]+L[k])-max(L[i], L[j], L[k]):
                    count += 1

print(count)

Measured memory_bytes: 9156
#include<iostream>
#include<string>
#include<cctype>
#include<cstring>

using namespace std;

string toUpper(string s){
  string t = s;
  for ( int i = 0; i < s.size(); i++){
    t[i] = toupper(s[i]);
  }
  return t;
}

int main(){
  string target,source;
  int count = 0;
  cin >> target;
  target = toUpper(target);

  for (;;){
    cin >> source;
    if ( source == "END_OF_TEXT" ) break;
    source = toUpper(source);

    if ( target == source ) count++;
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

int main(int argc, char **argv)
{
  uint64_t A, B, T;
  std::cin >> A >> B >> T;
  
  uint64_t N = T / A;
  std::cout << (B * N) << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
import numpy as np
import itertools

def main():
    N = int(input())
    P = np.array([int(x) for x in input().split()])
    
    Q = np.array(list(itertools.accumulate(P, min)))

    print(np.count_nonzero(P <= Q))

if __name__ == '__main__':
    main()


Measured memory_bytes: 34048