akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int n; cin >> n;
    vector<int> num(n+1); //数iがn!の素因数に含まれる個数を調べる
    for (int i=2; i<=n; i++) {
        bool prime = isPrime(i);
        if (!prime) continue;
        int tmp = n;
        int cnt = 0;
        while (tmp/i > 0) {
            tmp /= i;
            cnt += tmp;
        }
        num[i] = cnt;
    }
    int n74 = 0, n24 = 0, n14 = 0, n4 = 0, n2 = 0;
    for (int i=2; i<=n; i++) {
        if (num[i] >= 74) n74++;
        if (num[i] >= 24) n24++;
        if (num[i] >= 14) n14++;
        if (num[i] >= 4) n4++;
        if (num[i] >= 2) n2++;
    }
    int ans = 0;
    ans = n74 + n24*(n2-1) + n14*(n4-1) + n4*(n4-1)/2*(n2-2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(){
  char s[200010];
  scanf("%s",s);
  int cont1,cont2;
  for(int i=0;i<strlen(s);i++){
    if(s[i]==65){
      cont1=i;
      break;
    }
  }
  for(int i=strlen(s);i>=0;i--){
    if(s[i]==90){
      cont2=i+1;
      break;
    }
  }
  printf("%d\n",cont2-cont1);
  return 0;
}

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

#define N 100000

int dist[N];

int main()
{
	int ans = 0;
	int k;

	cin >> k;

	for( int i = 0; i < N; i++ ) {
		dist[i] = INT32_MAX;
	}
	typedef pair< int, int> P;
	priority_queue<P> p;
	p.push( make_pair(-1, 1) );
	while( !p.empty() ) {
		int c = -p.top().first;
		int n = p.top().second;
		p.pop();
		if( dist[n] <= c ) {
			continue;
		}
		dist[n] = c;
		if( dist[(n + 1) % k] > c + 1) {
			p.push( make_pair(-(c + 1), (n + 1) % k) );
		}
		if( dist[(n * 10) % k] > c + 1) {
			p.push( make_pair(-c, (n * 10) % k) );
		}
	}
	ans = dist[0];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
    ll N,X;
    cin >> N >> X;
    vector<ll> L(N),R(N);
    map<ll,ll> m,cmp;
    for(int i=0;i<N;i++){
        cin >> L[i] >> R[i];
        cmp[L[i]] = 1;
        cmp[R[i]] = 1;
    }
    ll id = 1;
    for(auto& x:cmp){
        x.second = id;
        m[id] = x.first;
        id++;
    }
    vector<ll> imos(id+2);
    for(int i=0;i<N;i++){
        imos[cmp[L[i]]]++;
        imos[cmp[R[i]]+1]--;
    }
    ll ma = -1,l_id = -1,r_id = -1;
    for(int i=1;i<=id;i++){
        imos[i] += imos[i-1];
        if(ma<imos[i]){
            ma = imos[i];
            l_id = i;
            r_id = i;
        }else if(ma==imos[i]) r_id = i;
    }
    cout << (ma%2? X*(ma-1)+m[r_id]:X*ma-m[l_id])<<endl;
}



Measured memory_bytes: 58996
import java.util.Scanner;

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

        System.out.println(a + b >= c ? "Yes" : "No" );
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
vector<int> to[N];
int main(){
    int n,u,v;
    cin>>n>>u>>v;
    u--;v--;
    REP(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> m(n,-1);
    vector<int> c(n,-1);
    m[u]=0;
    c[v]=0;
    queue<int> q;
    q.push(u);
    while(SZ(q)){
        int a=q.front();
        q.pop();
        for(auto s:to[a]){
            if(m[s]==-1){
                q.push(s);
                m[s]=m[a]+1;
            }
        }
    }
    q.push(v);
    while(SZ(q)){
        int a=q.front();
        q.pop();
        for(auto s:to[a]){
            if(c[s]==-1){
                q.push(s);
                c[s]=c[a]+1;
            }
        }
    }
    int ans=0;
    if(n!=2){
        REP(i,n){
            if(m[i]<=c[i]){
                int tmp=c[i]-1;
                ans=max(ans,tmp);
            }
        }
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 6656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{

    public static void Main(string[] args)
    {
        var split = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = split[0];
        int K = split[1];
        string S = Console.ReadLine();

        List<int> list = new List<int>();
        string first = S[0].ToString();
        string looking = first;
        int counter = 0;

        for (int i = 0; i < N; i++)
        {

            if (looking == S[i].ToString()) counter++;
            else
            {
                looking = S[i].ToString();
                list.Add(counter);
                counter = 1;
            }

        }
        list.Add(counter);
        int answer = 0;

        int n_look_array = K * 2 + 1;
        if (first == "0")
        {
            list.Insert(0, 0);

        }
        if (looking == "0")
        {
            list.Add(0);
        }

        n_look_array = K * 2 + 1;


        if (list.Count < n_look_array)
        {
            answer = list.Sum();
        }
        else
        {
            Queue<int> queue = new Queue<int>();
            int sum = 0;
                            queue.Enqueue(list[0]);
                sum += list[0];
                list.RemoveAt(0);
            while (list.Count > 0)
            {
                queue.Enqueue(list[0]);
                sum += list[0];
                list.RemoveAt(0);
                queue.Enqueue(list[0]);
                sum += list[0];
                list.RemoveAt(0);
                if (queue.Count == n_look_array) answer = sum;
                if (queue.Count > n_look_array)
                {
                    sum -= queue.Dequeue();
                    sum -= queue.Dequeue();
                    if (answer < sum) answer = sum;

                }


            }
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 19292
def main():
    A, B, C = (int(x) for x in input().split())
    K = int(input())

    while not A < B < C and K > 0:
        if A >= B: B *= 2
        else: C *= 2
        K -= 1
        # print(A, B, C, K)
    if A < B < C: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()

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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0); cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  int dp[n + 1][m + 1];
  memset(dp, 0, sizeof dp);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i - 1] == t[j - 1]) 
        dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1]); 
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  } 
  int cur = dp[n][m];
  string res;
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (s[i - 1] == t[j - 1] && dp[i][j] == cur) {
        res += s[i - 1];
        --cur;
        break;
      }
    }
  }
  reverse(all(res));
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 38812
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ll A, B;
    ll result = max(A, B);
    cin >> A >> B;
    for (int i = 1; i <= B; i++) {
        if ((A * i) % B == 0) {
            result = A * i;
            break;
        }
    }
    cout << result << endl;
    return 0;
}

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

int main(){
    int n,count = 0;
    cin>>n;
    int m = INT_MAX;
    for (int i=0;i<n;++i){
        int x;
        cin>>x;
        m = min(m,x);
        if (x<=m){
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	string s; ll K;
	cin >> s >> K;
	ll n = s.size();

	ll ans = -1;
	// dp[現在の位置（左）（変更可）][現在の位置（右）][変更回数]
	vector<vvl> dp(n + 1, vvl(n + 1, vl(K + 1, -1)));
	dp[0][0][0] = 0;
	REP(i, n) REP(j, n) REP(k, K + 1) {
		if (dp[i][j][k] < 0) continue;
		if (i + j + 1 == n) { // 同じ場所になったとき
			ans = max(ans, dp[i][j][k] * 2 + 1);
		} else if (i + j == n) { // すれ違ったとき
			ans = max(ans, dp[i][j][k] * 2);
		} else {
			if (s[i] == s[n - j - 1]) MAXC(dp[i + 1][j + 1][k], dp[i][j][k] + 1);
			if (k < K) MAXC(dp[i + 1][j + 1][k + 1], dp[i][j][k] + 1);
			MAXC(dp[i + 1][j][k], dp[i][j][k]);
			MAXC(dp[i][j + 1][k], dp[i][j][k]);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 216832
#!python3

# input
N, M, Q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(Q)]


def point(A):
    ret = 0
    for a, b, c, d in abcd:
        if A[b] - A[a] == c:
            ret += d
    return ret


def solve(A):
    n = len(A) - 1
    if n == N:
        return point(A)
    m = A[n]
    ans = 0
    for i in range(m, M + 1):
        ans = max(ans, solve(A + [i]))
    return ans


def main():
    ans = solve([1])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9216
n,x,y = map(int,input().split())
ans = [0]*(n-1)

for i in range(1,n):
    for j in range(i+1,n+1):
        dist = min(j-i,abs(x-i)+1+abs(j-y))
        ans[dist-1] += 1
print(*ans,sep="\n")

Measured memory_bytes: 3444
D, G = map(int, input().split())
scores = []

for i in range(D) :
    p, c = map(int, input().split())
    scores.append((p, c))
    
# if n is perfect -> combination
def calc_for(mask) :
    score, cnt = 0, 0
    for i in range(len(mask)) :
        if mask[i] == "1" :
            score += (i + 1) * 100 * scores[i][0] + scores[i][1]
            cnt += scores[i][0]
            
    min_cnt = 10**20
    
    if score >= G :
        return cnt
    else :    
        for i in range(len(mask)) :
            if mask[i] != "1" :
                cnt_tmp = 0 # 中途半端分
                score_tmp = score # 中途半端分
                achieve_flg = False


                for j in range(scores[i][0] - 1) :
                    score_tmp += (i + 1) * 100
                    cnt_tmp += 1
                    
                    if score_tmp >= G :
                        achieve_flg = True
                        break

                if achieve_flg == True : 
                    min_cnt = min(min_cnt, cnt + cnt_tmp)

        return min_cnt
            
# generate permutations 
perms = []

def permsgen(S) :
    global perms
    if len(S) >= D :
        perms.append(S)
    else :
        permsgen(S + "0")
        permsgen(S + "1")

permsgen("")

# do calc 
min_cnt = 10**20
for p in perms :
    min_cnt = min(min_cnt, calc_for(p))
    
print(min_cnt)

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll s = 0;
    int c = 0, m = 1 << 30;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (a <= 0) {
            c++;
        }
        m = min(m, abs(a));
        s += abs(a);
    }

    if (c % 2) {
        s -= m * 2;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 26596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
int h[100005];
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>h[i];
    sort(h,h+n);
    int min=1000000000,m;
    for(int i=k-1;i<n;i++)
    {
        m=h[i]-h[i-k+1];
        if(m<min) min=m;
    }
    cout<<min<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextDouble()) {
				double x = sc.nextDouble();

				 double n = Math.ceil(((((x/9.8)*(x/9.8)*4.9)+5)/5));
				System.out.println((int)n);
			}
		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 19156
from itertools import  product

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

ks=[ list(map(int,input().split())) for _ in range(m) ]

p=list(map(int,input().split()))
ans=0

for z in product((0, 1), repeat=n):
    for i in range(m):    
        k=ks[i][0]
        on_count=0
        for j in range(1,k+1):
            if z[ks[i][j]-1]==1:
                on_count+=1
        if  on_count%2!=p[i]:
            break
    else:
        ans+=1
print(ans)   
#print(z)

Measured memory_bytes: 3064
import itertools

N, M, Q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for i in range(Q)]
# print(N, M, Q)
# print(abcd)

def calculate(A, abcd):
    total = 0
    for abcdi in abcd:
        a = abcdi[0] - 1
        b = abcdi[1] - 1
        c = abcdi[2]
        d = abcdi[3]
        if A[b] - A[a] == c:
            total += d
    # print(A, total)

    return total

A = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# print(A)

maximum = max([calculate(Ai, abcd) for Ai in A])

print(maximum)


Measured memory_bytes: 25260
#include<stdio.h>
 
int Linear(int a[], int n, int key){
  int i = 0;
  a[n]  = key;
  while (a[i] != key)
    i++;
  if (i==n){
    return 0;
  } else {
    return 1;
  }
}
 
int main(){
  int i, n, a[10001], q, k;
  int sum = 0;
  scanf("%d", &n);
  for (i=0; i<n; i++)
  scanf("%d", &a[i]);
  scanf("%d", &q);
  for (i=0; i<q; i++) {
  scanf("%d", &k);
  if (Linear(a, n, k)==1)
  sum++;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 2728
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for A in range(a+1):
    for B in range(b+1):
        for C in range(c+1):
            if x == 500*A + 100*B + 50*C:
                cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
  string s1, s2;
  cin >> s1 >> s2;
  int i, k=0;
  for(i=0; i<s1.length(); i++){
    if(s1[i]==s2[i])continue;
    else k++;
  }
  cout << k << endl;
}


Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

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

    for(int i = 1; i <= 3500; i++) {
        for(int j = 1; j <= 3500; j++) {
            int k = 4 * i * j - n * (i + j);
            int l = n * i * j;
            if(k > 0 && l % k == 0) {
                cout << i << " " << j << " " << l / k << endl;
                return 0; 
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> vec(M,vector<int>(2));
  for(int i=0; i<M; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
  }
  vector<int> ball(N,1);
  vector<bool> exist(N,false);
  exist.at(0) = true;
  
  for(int i=0; i<M; i++){
    int x = vec.at(i).at(0)-1;
    int y = vec.at(i).at(1)-1;
    if(exist.at(x) == true){
      exist.at(y) = true;
    }
    ball.at(x)--;
    ball.at(y)++;
    if(ball.at(x) == 0){
      exist.at(x) = false;
    }
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    if(exist.at(i) == true){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

const int MOD = (int) 1e9 + 7;

int dp[5005][5005][5], dps[5005][5];
int answer[5005][5], step[5005];

int main()
{
 	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
 	ios_base::sync_with_stdio(0); cin.tie(0);
 	int n, A, B;
 	cin >> n >> A >> B;
 	if (A > B) swap(A, B);

 	step[0] = 1;
 	for (int i = 1; i <= n; i++) step[i] = 2 * step[i - 1] % MOD;
 	if (A == 1) cout << step[n] << '\n', exit(0);

 	dp[1][1][0] = 1, dp[1][1][3] = 1;
 	for (int i = 1; i < B; i++)
 		for (int j = 1; j <= i; j++)
 		{
 		 	dp[i + 1][j + 1][0] = (dp[i + 1][j + 1][0] + dp[i][j][0]) % MOD;
 		 	if (j >= A) dp[i + 1][1][1] = (dp[i + 1][1][1] + dp[i][j][0]) % MOD;
 		 	dp[i + 1][1][0] = (dp[i + 1][1][0] + dp[i][j][1]) % MOD;
 		 	dp[i + 1][j + 1][1] = (dp[i + 1][j + 1][1] + dp[i][j][1]) % MOD;
 		 	dp[i + 1][j + 1][2] = (dp[i + 1][j + 1][2] + dp[i][j][2]) % MOD;
 		 	if (j >= A) dp[i + 1][1][3] = (dp[i + 1][1][3] + dp[i][j][2]) % MOD;
 		 	dp[i + 1][1][2] = (dp[i + 1][1][2] + dp[i][j][3]) % MOD;
 		 	dp[i + 1][j + 1][3] = (dp[i + 1][j + 1][3] + dp[i][j][3]) % MOD;
 		}
 	for (int i = 1; i < B; i++)
 		for (int j = 1; j <= i; j++)
 		{
 		 	if (j >= A) answer[i][0] = (answer[i][0] + dp[i][j][0]) % MOD;
 		 	answer[i][1] = (answer[i][1] + dp[i][j][1]) % MOD;
 		 	if (j >= A) answer[i][2] = (answer[i][2] + dp[i][j][2]) % MOD;
 		 	answer[i][3] = (answer[i][3] + dp[i][j][3]) % MOD;
 		}

 	for (int i = 1; i < A; i++) dps[i][0] = 1;
 	for (int i = 1; i < B; i++) dps[i][1] = (answer[i][1] + answer[i][3]) % MOD;

 	for (int i = 1; i <= n; i++)
 	{
 	 	for (int j = 1; j < min(B, n - i + 1); j++)
 	 	{
 	 	 	int c = answer[j][3];
 	 	 	if (j == n - i) c = (c + answer[j][2]) % MOD;
 	 	 	dps[i + j][1] = ((ll) dps[i + j][1] + (ll) dps[i][0] * (ll) c) % (ll) MOD;
 	 	}
 	 	for (int j = 1; j < min(A, n - i + 1); j++)
 	 		dps[i + j][0] = (dps[i + j][0] + dps[i][1]) % MOD;
 	}
 	int ans = ((ll) step[n] - (ll) dps[n][0] - (ll) dps[n][1] + (ll) 2 * MOD) % (ll) MOD;
 	cout << ans << '\n';
 	return 0;
}

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

int SumOfDigit(int n) {
	int k = n % 10;
	while (n >= 10) {
		n /= 10;
		k += n % 10;
	}
	return k;
}

int main() {
	int N;
	cin >> N;
	int min = 9999 * 2;
	for (int i = 1; i <= N/2; i++) {
		int sum = SumOfDigit(i) + SumOfDigit(N - i);
		if (sum < min) min = sum;
	}
	cout << min;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    string s, t, u; cin >> s >> t >> u;
    out((char)toupper(s[0]) << (char)toupper(t[0]) << (char)toupper(u[0]));
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int UP=0;
const int FLONT=1;
const int RIGHT=2;
const int LEFT=3;
const int BACK=4;
const int DOWN=5;
class Dice{
 public:
  Dice();~Dice();
  int num[6];
  void set_num(int n,int i);
  void spin(char c);
  int get_num(int n);
};
Dice::Dice(){}
Dice::~Dice(){}
void Dice::set_num(int n,int i){num[i]=n;}
int Dice::get_num(int n){return num[n];}
void Dice::spin(char c){
  int temp;
  if(c=='S'){
    temp=num[0];
    num[0]=num[4];
    num[4]=num[5];
    num[5]=num[1];
    num[1]=temp;
  }if(c=='N'){
temp=num[0];
    num[0]=num[1];
    num[1]=num[5];
    num[5]=num[4];
    num[4]=temp;
  }if(c=='W'){
    temp=num[0];
    num[0]=num[2];
    num[2]=num[5];
    num[5]=num[3];
    num[3]=temp;
  }if(c=='E'){
temp=num[0];
    num[0]=num[3];
    num[3]=num[5];
    num[5]=num[2];
    num[2]=temp;
  }if(c=='X'){
    temp=num[1];
    num[1]=num[2];
    num[2]=num[4];
    num[4]=num[3];
    num[3]=temp;
  }
}
int main(){
  //char c[102];                                                                
  int q,a,b;
  Dice *m_Dice;
  m_Dice=new Dice;
  for(int i=0; i<6; i++){
    int n;
    cin>>n;
    m_Dice->set_num(n,i);
  }
  cin>>q;
  for(int i=0; i<q; i++){
    cin>>a; cin>>b;
    for(int j=0; j<3; j++){
      if(a==m_Dice->get_num(UP))break;
      else m_Dice->spin('S');
    }
    for(int j=0; j<3; j++){
      if(a==m_Dice->get_num(UP))break;
      else m_Dice->spin('E');
}
    for(int j=0; j<3; j++){
      if(b==m_Dice->get_num(FLONT))break;
      else m_Dice->spin('X');
    }
    cout<<m_Dice->get_num(RIGHT)<<endl;
  }
  //for(int i=0; i<6; i++)cout<<m_Dice->get_num(i)<<endl;                       
  delete m_Dice;
  return 0;
}

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

using namespace std;

int b[2][105], sum[2][105];

int main() { 
    int n;
    while (cin >> n) {
        for (int j = 0; j < 2; ++j)
            for (int i = 1; i <= n; ++i) 
                cin >> b[j][i];
        memset(sum, 0, sizeof(sum));
        for (int i = 1; i <= n; ++i)
            sum[0][i] = sum[0][i-1] + b[0][i];
        for (int i = n; i; --i)
            sum[1][i] = sum[1][i+1] + b[1][i];
        int mx = 0;
        for (int i = 1; i <= n; ++i) 
            mx = max(sum[0][i] + sum[1][i], mx);
        cout << mx << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int q = scan.nextInt();
        int[] a = new int[q];
        for(int i = 0; i < q; i++) a[i] = scan.nextInt();
        int[] p = new int[n];
        Arrays.fill(p, k - q);
        for(int i = 0; i < q; i++){
            p[a[i] - 1]++;
        }
        for(int i = 0; i < n; i++){
            System.out.println(p[i] <= 0 ? "No" : "Yes");
        }
        scan.close();
    }
}

Measured memory_bytes: 55416
#include <iostream>
#include <iomanip>
#include <functional>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> A;
    for (int i=0; i<N; i++) {
        int temp;
        cin >> temp;
        A.push_back(make_pair(temp, i+1));
    }
    
    sort(A.begin(), A.end());

    for (int i=0; i<N; i++) {
        cout << A[i].second << " ";
    }

    return 0;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


int main() {
    string S; cin >> S;
    int n = S.size();
    vvi dp(n + 1, vi(4, 0));
    dp[n][3] = 1;

    for (int i = n - 1; i >= 0; i--) {
        ll x = (S[i] == '?' ? 3LL : 1LL) ;
        dp[i][3] = x * dp[i + 1][3] % MOD;
        rep(j, 3) {
            dp[i][j] = x * dp[i + 1][j] % MOD;
            if (S[i] == '?' || S[i] == 'A' + j) {
                dp[i][j] = (dp[i][j] + dp[i + 1][j + 1]) % MOD;
            }
        }
    }

    cout << dp[0][0] << endl;

}



Measured memory_bytes: 5840
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#define ll long long
using namespace std;
int main() {
	ll n, d, x,sum=0;
	cin >> n >> d >> x;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		if (d%a[i]!=0) {
			sum += (d / a[i] + 1);
		}
		else {
			sum += d / a[i];
		}
	}
	sum += x;
	cout << sum << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	br := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
		br[i] = ar[i]
	}
	sort.Ints(br)
	for i := 0; i < n; i++ {
		if ar[i] <= br[n/2-1] {
			fmt.Println(br[n/2])
		} else {
			fmt.Println(br[n/2-1])
		}
	}
}


Measured memory_bytes: 9728
def soin(N):
    res = [1]
    i = 2
    while i < round(N**(1/2)) + 3:
        if N%i == 0:
            res.append(i)
            N = N//i
            i = 2
        else:
            i += 1
    res.append(N)
    return set(res)

A, B =(int(i) for i in input().split())
print(len(soin(A)&soin(B)))

Measured memory_bytes: 41580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for (int i=0; i<k; ++i) {
        if (a >= b) b *= 2;
        else c *= 2;
    }
    y_n(a < b && b < c);
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>  
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <list>
#include <cmath>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <functional>
#include <cassert>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<char, char> pcc;
const int inf = 0x3f3f3f3f;
const LL lnf = 0x3f3f3f3f3f3f3f3fLL;
const double pi = 3.14159265358979323846;
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int maxn = 0 + 10;

char str[maxn];

int main() {
	int CAS = 0;
	//std::ios::sync_with_stdio(0);  
	//std::cin.tie(0);  
#ifdef NIGHT_13  
	freopen("in.txt", "r", stdin);
	//freopen("out2.txt", "w", stdout);
	int time_night_13 = clock();
#endif // NIGHT_13  

	while (scanf("%s", str) != EOF) {
		if (strstr(str, "AC") != NULL) {
			puts("Yes");
		}
		else {
			puts("No");
		}
	}


#ifdef NIGHT_13  
	fprintf(stderr, "\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
	fprintf(stderr, "\t   Time: %d ms", (int)clock() - time_night_13);
	fprintf(stderr, "\n...........................................\n\n");
#endif // NIGHT_13  
	return 0;
}

Measured memory_bytes: 384
while 1:
    N = input()
    if N=='0000':break
    if N[0] ==N[1] == N[2] == N[3]:
        print('NA')
        continue
    cnt = 0
    while N != '6174':
        x = int(''.join(reversed(sorted(list(N))))) - int(''.join(sorted(list(N))))
        N = str(x).zfill(4) 
        cnt += 1

    print(cnt)

Measured memory_bytes: 6724
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(a == b && c == d){
        cout << "yes" << endl;
    }
    else if(a == c && b == d){
        cout << "yes" << endl;
    }
    else if(a == d && b == c){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }
}


Measured memory_bytes: 3124
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>

using namespace std;

int main() {
	int ans;
	int n;
	int tmp;
	int* num;
	int s, w;
	cin >> s>>w;


	if (s <= w) {
		cout << "unsafe";
	}
	else {
		cout << "safe";
	}


	return 0;
}

Measured memory_bytes: 3040
# 問題文
# 今日の曜日を表す文字列Sが与えられます。

# Sは SUN,MON,TUE,WED,THU,FRI,SAT のいずれかであり、
# それぞれ日曜日、月曜日、火曜日、水曜日、木曜日、金曜日、土曜日を表します。

# 次の日曜日 (あす以降) が何日後か求めてください。

# 制約
# Sは SUN,MON,TUE,WED,THU,FRI,SAT のいずれか

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# 次の日曜日が何日後か出力せよ。

l  = ['SUN','MON','TUE','WED','THU','FRI','SAT']
ll = [ 7,    6,    5,    4,    3,    2,    1   ]

S = input()

print(ll[l.index(S)])

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    string S; cin >> S;
    int N = S.size();
    set<string> st;
    int ans = 0;
    int tmp = 1;

    for(int left = 0; left < N;){
        int width_l = tmp;
        int width_r = 1;
        while(true){
            string l = S.substr(left, width_l);
            string r = S.substr(left + width_l, width_r);
            if(l != r) {
                left += width_l;
                tmp = width_r;
                ++ans;
                break;
            }
            else{
                if(left + width_l + width_r >= N){
                    ++ans;
                    left = N;
                    break;
                }
                ++width_r;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    bool neg = false, pos = false;
    rep(i, n) {
        cin >> a[i];
        if(a[i] < 0) neg = true;
        else if(a[i] > 0) pos = true;
    }
    sort(a.begin(), a.end());

    if(pos and !neg){
        ll m = -a.front();
        for(int i = n-1; i >= 1; --i){
            m += a[i];
        }
        ppp(m);

        int b = a[0];
        rep(i, n-2){
            cout << b << sp << a[i+1] << endl;
            b -= a[i+1];
        }
        cout << a[n-1] << sp << b << endl;
    }
    else if(!pos and neg){
        ll m = a.back();
        for(int i = 0; i < n-1; ++i){
            m -= a[i];
        }
        ppp(m);

        int b = a[n-1];
        for(int i = 0; i < n-1; ++i){
            cout << b << sp << a[i] << endl;
            b -= a[i];
        }
    }
    else if(pos and neg){
        ll m = 0ll;
        for(int i = 0; i < n; ++i){
            m += abs(a[i]);
        }
        ppp(m);

        int p = lower_bound(a.begin(), a.end(), 0) - a.begin();

        // cerr << a << endl;
        ll b = a[0];
        for(int i = p; i < n-1; ++i){
            cout << b << sp << a[i] << endl;
            b -= a[i];
        }
        a[0] = b;
        b = a[n-1];
        for(int i = 0; i < p; ++i){
            cout << b << sp << a[i] << endl;
            b -= a[i];
        }

    }
    else{
        ppp(0);
        rep(i, n-1){
            cout << "0 0" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
#include<sstream>
#include<vector>
#include<algorithm>
 
using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define pii pair<int,int>
#define INF 0x3f3f3f3f
#define ll long long
#define mod  998244353
const int N = 1e5 + 10;
const int M = 2e6 + 1005;
int main()
{
    int n;
    cin>>n;
    ll Sum = 0,num = 0;
    for(int i = 1;i <= n;++i){
        ll a,b;
        cin>>a>>b;
        Sum += a*b;
        num += b;
 
    }
    num = num - 1 + (Sum - 1) /9;
    cout<<num<<endl;
}

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

using namespace std;

int main() {
  	int n;
  	cin >> n;
  	int a[n];
  	for (int& x : a)
        cin >> x;
  	int str = 0;
  	int mx = 0;
  	for (int i = 0; i < n - 1; i++) {
    	if (a[i + 1] <= a[i])
        	str++;
      	else {
          	mx = max(mx, str);
            str = 0;
        }
    }
  	mx = max(mx, str);
  	cout << mx;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll mod=1e9+7;

ll ara[2000];

void factorise(int n)
{
	for(int i=2;i*i<=n;i++)
	{
		while(n%i==0)
		{
			n/=i;
			ara[i]++;
		}
	}
	
	if(n!=1) ara[n]++;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		factorise(i);
	}
	
	ll tot=1;
	
	for(int i=1;i<=1000;i++)
	{
		tot*=(ara[i]+1);
		tot%=mod;
	}
	
	
	cout<<tot;
	
					                                				
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void){
	ios::sync_with_stdio(false);
	int N, X, i, j, k,length;
	cin >> N >> X ;
	int L[N];
	k = 1;
	rep0(i, N) {
		cin >> L[i];
	}
	length = 0;
	for (i = 0; i < N;i++) {
		length += L[i];
		if (X >= length) {
			k += 1;
		}
	}

	cout << k;
	return 0;
}

//sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順

////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}


Measured memory_bytes: 256
#include <stdio.h>
#define swap(a, b) a^=b^=a^=b

int gcd(int, int);

int main(void){

  int x, y, i;

  scanf("%d%d",&x, &y);

  if(x < y) swap(x, y);

  printf("%d\n",gcd(x, y));

  return 0;
}

int gcd(x, y){
  int i;

  while(y > 0){
  i = x % y;
  x = y;
  y = i;
  }

  return x;
}

Measured memory_bytes: 592
//### In The Name Of GOD ###

// %% Remember; (((He))) is The (((Accepter))) %%

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2 * 1000 * 1000 + 200;
const int MAXN = 100 * 1000 + 1;
const int MLOG = 18;
const int NMAX = 1 * 1000;

signed main(){
  IO;
  string s, z[] = {"dream", "dreamer", "erase", "eraser"};
  cin >> s;
  while(s != ""){
    string ss;
    while(s[sz(s) - 1] != 'd' && (s[sz(s) - 1] != 'e' || (ss == "amer" || ss == "am" || ss == "r" || ss == "")) && sz(s)){
      ss = s[sz(s) - 1] + ss;
      s.erase(s.begin() + sz(s) - 1);
      // cout << s << ' ' << ss << endl;
    }
    if(sz(s)){
      ss = s[sz(s) - 1] + ss;
      s.erase(s.begin() + sz(s) - 1);
      // cout << s << ' ' << ss << endl;
    }
    bool p = false;
    for(int i = 0; i < 4; i++){
      if(z[i] == ss) p = true;
    }
    if(!p) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
int main(){
	scanf("%d",&k);
	k--;
	printf("%d\n",a[k]);
return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;

ll misum =0;
ll func(ll i,const v<> &c){
    if(i<=0||misum>=0)return 0;
    misum+=c[i];
    return func(i-1,c)+1;
}

int main(){
    
    ll n; cin  >>  n;
    auto a = v<>(n,0);
    auto b = v<>(n,0);
    auto c = v<>(n,0);
    
    ll sum=0;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) {
        c[i] = a[i]-b[i];
        sum+=c[i];
    }

    sort(c.begin(),c.end());
    
    ll ans =count_if(c.begin(),c.end(),[](ll i)mutable{
            if(i<0) {
                misum+=i;
                return true;
            }
            return false;
        });
    
    if(sum<0){
        cout << -1 << endl;
        return 0;
    }

    cout << ans+func(n-1,c);
    
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
const int MOD = 1e9+7;

int main() {
    int N, M;
    cin >> N >> M;
    vi H(N);
    vi A(M);
    vi B(M);
    vi ans(N,1);
    int count = 0;
    rep(i, N) cin >> H[i];
    rep(i, M) {
        cin >> A[i];
        cin >> B[i];
    }
    rep(i, M) {
        if (H[A[i]-1] > H[B[i]-1]) ans[B[i]-1] = 0;
        else if (H[A[i]-1] < H[B[i]-1]) ans[A[i]-1] = 0;
        else if (H[A[i]-1] == H[B[i]-1]) {
            ans[A[i]-1] = 0;
            ans[B[i]-1] = 0;
        }
    }
    for (int x : ans) count = count + x;
    cout << count << endl;
}

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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n, m;
    cin >> n >> m;
    map<int, int> f;
    rep(i, n) {
        int x;
        cin >> x;
        f[x]++;
    }
    
    while (m--) {
        f.rbegin()->se--;
        f[f.rbegin()->fi / 2]++;
        if (f.rbegin()->se == 0) f.erase(f.rbegin()->fi);
    }

    ll sum = 0;
    for (auto& i : f) sum += 1ll * i.fi * i.se;
    cout << sum;

    return 0;
}


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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

using ll = long long;
const ll inf = 1e15;

int main() {
    int V, E; cin >> V >> E;
    int n = V;
    vector<vector<ll>> v(V, vector<ll>(V, inf));
	rep(i, n) v[i][i] = 0;
    rep(i, E) {
        int a, b, c; cin >> a >> b >> c;
        v[a][b] = c;
    }
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
				if (max(v[i][k], v[k][j]) == inf) continue;
                v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
            }
        }
    }
    rep(i, n) {
        if (v[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    rep(i, n) {
        rep(j, n) {
            if (j) cout << " ";
            if (v[i][j] == inf) cout << "INF";
            else cout << v[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3224
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdio>

using namespace std;
char Kachi(char a);

int main()
{
    int N , K, R, S, P;
    string T;
    cin >> N;
    cin >> K;
    cin >> R;
    cin >> S;
    cin >> P;
    cin >> T;
    string dashita = "";
    long point = 0;

    for(int i = 0; i < N; i++)
    {
        char dasenai = 'a';
        if(i >= K)
        {
            dasenai = dashita[i -K];
        }

        char dashitai = Kachi(T[i]);
        if(dashitai == dasenai)
        {
            dashita += "a";
        }
        else
        {   
            switch (dashitai)
            {
            case 'r':
                point += R;
                break;
            case 's':
                point += S;
                break;
            case 'p':
                point += P;
                break;
            default:
        cout << dashitai << endl;
                throw new exception;
            }
            dashita += dashitai;
        }
    }
    cout << point << endl;
}

char Kachi(char a)
{
    switch (a)
    {
    case 'r':
        return 'p';
    case 's':
        return 'r';
    case 'p':
        return 's';
    default:
        cout << a << endl;
        throw new exception;
    }
}


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

int main(){
	
	int a,b;
	char op;
	while(1){
		cin>>a>>op>>b;
		if(op=='?')break;
		
		if(op=='+')cout<<a+b<<endl;
		else if(op=='-')cout<<a-b<<endl;
		else if(op=='*')cout<<a*b<<endl;
		else if(op=='/')cout<<a/b<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 200100;

int n;
ll arr[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
	int ans = 0;
	for(int tmps = 1, i = 1; i <= n; i++){
		if(arr[i] == tmps) tmps++, ans--;
		ans++;
	}
	printf("%d\n", ans == n ? -1 : ans);
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }

    vector<pair<ll, ll>> op;

    ll maxi = max_element(a.begin(), a.end()) - a.begin();
    ll mini = min_element(a.begin(), a.end()) - a.begin();
    if(a.at(mini) < 0 && a.at(maxi) > 0){
        if(abs(a.at(mini)) > a.at(maxi)){
            for(int i = 0; i < n; ++i){
                if(a.at(i) > 0){
                    op.push_back(make_pair(mini, i));
                    a.at(i) += a.at(mini);
                }
            }
        }else{
            for(int i = 0; i < n; ++i){
                if(a.at(i) < 0){
                    op.push_back(make_pair(maxi, i));
                    a.at(i) += a.at(maxi);
                }
            }
        }
    }

    ll mina = *min_element(a.begin(), a.end());
    if(mina >= 0){
        for(int i = 1; i < n; ++i){
            if(a.at(i - 1) > a.at(i)){
                op.push_back(make_pair(i - 1, i));
                a.at(i) += a.at(i - 1);
            }
        }
    }else{
        for(int i = n - 2; i >= 0; --i){
            if(a.at(i) > a.at(i + 1)){
                op.push_back(make_pair(i + 1, i));
                a.at(i) += a.at(i + 1);
            }
        }
    }

    cout << op.size() << endl;
    for(auto p : op){
        cout << p.first + 1 << ' ' << p.second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x, y;
	char op;
	while (1){
		scanf("%d %c %d\n", &x ,&op, &y);
		if (op == '?') break;
		else if (op == '+') cout << x + y << endl;
		else if (op == '-') cout << x - y << endl;
		else if (op == '*') cout << x * y << endl;
		else cout << x/y << endl;
	}
}


Measured memory_bytes: 3208
#include <algorithm>
#include <climits>
#include <iostream>
using namespace std;

int main() {
	int n, R, ans = INT_MIN, tmp;
	cin >> n >> tmp;
	for (int i = 1; i < n; ++i) {
		cin >> R;
		ans = max(ans, R - tmp);
		tmp = min(R, tmp);
	}
	cout << ans << endl;
}


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

int main() {
  long long N, W;
  cin >> N >> W;
  vector<long long> w(N), v(N);
  for (int i = 0; i < N; i++) cin >> w.at(i) >> v.at(i);
  long long INF = 1LL << 60;
  vector<vector<long long>> dp(N+1, vector<long long>(100001, INF));
  dp.at(0).at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int sum_v = 0; sum_v < 100001; sum_v++) {
      if (sum_v - v.at(i) >= 0) {
        dp.at(i+1).at(sum_v) = min(dp.at(i+1).at(sum_v), dp.at(i).at(sum_v - v.at(i)) + w.at(i));
      }
      dp.at(i+1).at(sum_v) = min(dp.at(i+1).at(sum_v), dp.at(i).at(sum_v));
    }
  }
  long long ans = 0;
  for (int sum_v = 0; sum_v < 100001; sum_v++) {
    if (dp.at(N).at(sum_v) <= W) ans = sum_v;
  }
  cout << ans << endl;
}

Measured memory_bytes: 80256