akhauriyash/Code-Regression huggingface dataset:
n = int(input())
x = (-1+(1+8*n)**0.5)/2
m = int((-1+(1+8*n)**0.5)//2)
if x != m:
    print('No')
else:
    print('Yes')
    k = 2*n//m
    print(k)
    s = [[] for i in range(k)]
    add = 1
    for i in range(m):
        for j in range(i+1, k):
            s[i].append(add)
            s[j].append(add)
            add += 1
    for i in range(k):
        print(m, ' '.join([str(j) for j in s[i]]))

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
void ts()
{
    cout<<"***我只想过个水题抽奖****"<<endl;
    cout<<"***I JUST WANT PASS A WATER-PROBLEM FOR LUCK DRAW***"<<endl;
}
#define ll long long
int x,y,z,k;
ll a[1005],b[1005],c[1005];
vector<ll>v;
int main()
{
    scanf("%d%d%d%d",&x,&y,&z,&k);
    for(int i=1;i<=x;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=y;i++)
        scanf("%lld",&b[i]);
    for(int i=1;i<=z;i++)
        scanf("%lld",&c[i]);
    sort(a+1,a+1+x);
    sort(b+1,b+1+y);
    sort(c+1,c+1+z);
    reverse(a+1,a+1+x);
    reverse(b+1,b+1+y);
    reverse(c+1,c+1+z);
    for(int i=1;i<=min(200,x);i++)
        for(int j=1;j<=min(200,y);j++)
            for(int k=1;k<=min(200,z);k++)
        v.push_back(a[i]+b[j]+c[k]);
    for(int i=201;i<=x;i++)
        for(int j=1;j<=min(50,y);j++)
            for(int k=1;k<=min(50,z);k++)
            v.push_back(a[i]+b[j]+c[k]);
    for(int i=1;i<=min(50,x);i++)
        for(int j=201;j<=y;j++)
            for(int k=1;k<=min(50,z);k++)
            v.push_back(a[i]+b[j]+c[k]);
    for(int i=1;i<=min(50,x);i++)
        for(int j=1;j<=min(50,y);j++)
            for(int k=201;k<=z;k++)
            v.push_back(a[i]+b[j]+c[k]);
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i=0;i<k;i++)
        printf("%lld\n",v[i]);
}


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


def main():
    h = int(input())
    w = int(input())
    n = int(input())
    max_value = max(h, w)

    for i in range(10000 + 1):
        if max_value * i >= n:
            print(i)
            exit()


if __name__ == '__main__':
    main()


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

int main(){
	int f = 0;
	string s,p;
	cin>>s>>p;
	s = s + s;
	
	for(int i = 0; (int) i < s.size(); i++){
		for(int j = 0;(int) j < p.size(); j++){
			if(s[i + j] != p[j]) break;
			if(j + 1 == (int) p.size()) f = 1;
		}
	}
	
	if(f) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<queue<int>> q(n);
    int T;
    cin >> T;
    while (T--) {
        int x; cin >> x;
        if(x==0) {
            int a,b;
            cin >> a >> b;
            q[a].push(b);
        }
        if (x==1) {
            int t;
            cin >> t;
            if (!q[t].empty()) cout << q[t].front() << endl;
        }
        if (x==2) {
            int t;
            cin >> t;
            if (!q[t].empty()) q[t].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 4212
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, a[200001] = {0};
    cin >> n;

    for (int i = 1; i < n; i++) {
        int v;
        cin >> v;
        a[v]++;
   }
    for (int i = 1; i <= n; i++) {
        cout << a[i] << endl;
   }
}


Measured memory_bytes: 4416
n = int(input())

xl =[]
for i in range(n):
    x,l = map(int,input().split())
    xl.append([x-l,x+l])
xl.sort(key=lambda x: x[1])

arm = xl[0][1] 
cnt = 1
for i in range(1,n):
    x,l = xl[i][0],xl[i][1]

    if arm <= xl[i][0]:
        arm = xl[i][1]
        cnt +=1
        
print(cnt)   

Measured memory_bytes: 21336
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod=1e9+7;
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD; 
 	b /= 2;
 	}
 return x;
}
 
long long dp[5001][5001],n,l;
int main(){
	cin>>n;
	string s;
	cin>>s;	l=s.size();
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=n;j++){
			if(dp[i][j]){
				dp[i+1][j+1]+=2*dp[i][j];
				dp[i+1][j+1]%=mod;
				if(j==0){
					dp[i+1][0]+=dp[i][0];
					dp[i+1][0]%=mod;
				}
				else{
					dp[i+1][j-1]+=dp[i][j];
					dp[i+1][j-1]%=mod;
				}
			}
		}
	}
	cout<<dp[n][l]*pow(pow(2,l,mod),mod-2,mod)%mod;
}

Measured memory_bytes: 193792
#include<stdio.h>

int main(){
  int i, n, m, x, y, goal, data[1000];

  while(1){
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0) break;

    for(i=0; i<n; i++)
      scanf("%d", &data[i]);

    for(i=0, x=0, goal=0; i<m; i++){
      scanf("%d", &y);

      if(goal == 0){
        x += y;
        if(x >= n-1){
          goal = i+1;
        }else{
          x += data[x];
          if(x >= n-1) goal = i+1;
        }
      }
    }

    printf("%d\n", goal);
  }

  return 0;
}

Measured memory_bytes: 0
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_3-D: Areas on the Cross-Section Diagram

#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned int uint;

struct area {
  const uint from_;
  const uint area_;
  area(const uint from, const uint to) : from_(from), area_(to-from) {}
};
                     
static stack<area> prepare_areas(const string str) {
  stack<area> areas;
  stack<uint> s;
  for (auto i = 0u; i < str.size(); ++i) {
    auto c = str[i];
    if (c == '\\') {
      s.push(i);
    } else if (c == '/') {
      if (!s.empty()) {
        areas.push(area(s.top(), i));
        s.pop();
      }
    } else {
      // nop
    }
  }
  return move(areas);
}

static pair<uint, vector<uint>> accumulate_areas(stack<area> areas) {
  uint sum = 0u;
  vector<uint> accs;
  while (!areas.empty()) {
    auto p = areas.top();
    areas.pop();
    auto acc = p.area_;
    while (!areas.empty() && p.from_ < areas.top().from_) {
      acc += areas.top().area_;
      areas.pop();
    }
    sum += acc;
    accs.push_back(acc);
  }
  reverse(accs.begin(), accs.end());
  return move(make_pair(sum, accs));
}

int main(void) {
  string str;
  getline(cin, str);
  auto areas = prepare_areas(move(str));

  auto sum_accs = accumulate_areas(move(areas));
  auto sum = sum_accs.first;
  auto accs = sum_accs.second;

  cout << sum << endl;
  cout << accs.size();
  for (auto acc : accs) {
    cout << " " << acc;
  }
  cout << endl;

  return 0;
}
// end

Measured memory_bytes: 3240
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  int k, a, b;
  cin >> k >> a >> b;
  int sum = 0;
  while (sum < a) {
    sum += k;
  }
  if (sum <= b) cout << "OK" << endl;
  else cout << "NG" << endl;
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 3648
package main

import "fmt"

func main() {

  // 入力
  var n, k, q int
  fmt.Scan(&n, &k, &q)
  // var as [q]int
  as := make([]int, q)
  for count := 0; count < q; count++ {
    var a int
    fmt.Scan(&a)
    as[count] = a
  }

  // 長さn, 初期値k-qの配列を用意
  array := make([]int, n)
  for count := 0; count < n; count++ {
    array[count] = k-q
  }

  // 入力されたAごとに対応するarrayの値をインクリメント
  for count := 0; count < q; count ++ {
    var a int
    a = as[count]
    array[a-1] = array[a-1] + 1
  }

  // 出力
  for count := 0; count < n; count ++ {
    var score int
    score = array[count]
    if 0 < score {
      fmt.Println("Yes")
    } else {
      fmt.Println("No")
    }
  }
}

Measured memory_bytes: 7132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        const long MOD = 1000000007;
        var sc = new Scanner();
        int n = sc.nextInt();
        var s = new Dictionary<string, long>();
        for (int i = 0; i < n; i++)
        {
            char[] cin = sc.next().ToCharArray();
            Array.Sort(cin);
            if (s.ContainsKey(new string(cin))) s[new string(cin)]++;
            else s.Add(new string(cin), 1);
        }

        long ans = 0;
        foreach (var item in s)
        {
            if (item.Value != 1) ans += (item.Value) * (item.Value - 1) / 2;
        }

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Console.WriteLine(ans);
        Console.Out.Flush();
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 31816
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

// for each subset b ⊆ a
template <class F>
void for_each_subset_desc(int a, const F &f){
  for(int t=a; ; t=(t-1)&a){
    f(t);
    if(t==0) break;
  }
}


LLI dp[1<<16];
bool used[1<<16];
LLI score[1<<16];

LLI rec(vector<vector<int>> &a, int p){
  if(used[p]) return dp[p];
  used[p] = true;

  for_each_subset_desc(p,
                       [&](int t){
                         chmax(dp[p], rec(a,t)+score[p^t]);
                       });

  
  
  return dp[p];
}

int main(){
  int N;
  while(cin >> N){
    vector<vector<int>> a(N, vector<int>(N)); cin >> a;

    fill_array(dp, 0);
    fill_array(used, false);
    fill_array(score, 0);

    REP(i,1<<N){
      if(__builtin_popcount(i) == 0) continue;
    
      REP(j,N){
        if((i>>j) & 1) continue;
        LLI t = score[i];
        REP(k,N) if(((i>>k) & 1) && j!=k) t += a[j][k];
        score[i | (1<<j)] = t;
      }
    }

    int p = 0;
    REP(i,N) p |= (1<<i);

    cout << rec(a, p) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////




int main() {
	int N; cin >> N;
	vector<int> A(N);
	rep(i,N){cin >> A.at(i);}
	sort(ALL(A));
	int ans = A.at(N/2)-A.at(N/2-1);
	cout << ans << endl;
}

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

int main(void)
{
  int t,h,m,s;
  cin >> t;
  h = t/3600;
  m = (t-h*3600)/60;
  s = t%60;
  cout << h << ':' << m << ':' << s << endl;
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int inf = 1e9;

vi DX = {-1, 1, 0, 0};
vi DY = {0, 0, -1, 1};

int opp(int d) {
	if (d == 0) return 1;
	if (d == 1) return 0;
	if (d == 2) return 3;
	if (d == 3) return 2;
}

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

	int H, W, K; cin >> H >> W >> K;
	int X1, Y1, X2, Y2; cin >> X1 >> Y1 >> X2 >> Y2; --X1; --Y1; --X2; --Y2;
	swap(X1, Y1);
	swap(X2, Y2);

	vector<vector<bool>> grid (H, vector<bool> (W));
	F0R(i, H) {
		F0R(j, W) {
			char c; cin >> c;
			grid[i][j] = c == '@';
		}
	}

	vector<vector<int>> dist (H, vector<int> (W, inf));
	using state = tuple<int, int, int>;
	deque<state> q;
	dist[Y1][X1] = 0;	
	q.push_back(make_tuple(X1, Y1, 0));

	while (!q.empty()) {
		state p = q.front();
		q.pop_front();

		int x = get<0>(p);
		int y = get<1>(p);
		int s = get<2>(p);

		F0R(d, 4) if ((s & (1 << d)) == 0) {
			for (int l = 0; l <= K; ++l) {
				int nx = x + DX[d] * l;
				int ny = y + DY[d] * l;
				if (0 > nx || nx >= W || 0 > ny || ny >= H || grid[ny][nx]) break;
				if (dist[y][x] + 1 < dist[ny][nx]) {
					dist[ny][nx] = dist[y][x] + 1;
					
					int skip = 0;
					if (l != K) {
						skip |= (1 << d);
						skip |= (1 << opp(d));
					} else {
						skip |= (1 << opp(d));
					}
					q.push_back(make_tuple(nx, ny, skip));
				}
			}
		}
	}

	print((dist[Y2][X2] < inf) ? dist[Y2][X2] : -1);
}

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

using namespace std;

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

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

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

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



string s;
string t[3] = {"Sunny", "Cloudy", "Rainy"};
void solve(){
	cin >> s;
	for(int i = 0; i < 3; i++){
		if(t[i] == s) cout << t[(i+1)%3] << endl;
	}
}

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


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

from collections import deque

def solve():
    MOD = 10**9 + 7

    N = int(readline())

    dp0 = [[[0]*(N+1) for i in range(N+1)] for j in range(N+1)]
    dp0[0][0][0] = 1
    for c in range(1, N+1):
        for a in range(N+1):
            for b in range(N+1):
                r = 0
                if a:
                    r += dp0[c-1][a-1][b]
                if b:
                    r += dp0[c-1][a][b-1]
                if a and b:
                    r += dp0[c-1][a-1][b-1]
                dp0[c][a][b] = r % MOD

    G = [[] for i in range(N)]
    deg = [0]*N
    for i in range(N-1):
        a, b = map(int, readline().split())
        G[a].append(b)
        deg[b] += 1
    r = 0
    for i in range(N):
        if deg[i] == 0:
            r = i
            break
    que = deque([r])
    vs = []
    while que:
        v = que.popleft()
        vs.append(v)
        for w in G[v]:
            que.append(w)
    vs.reverse()
    hs = [0]*N
    for v in vs:
        e = 0
        for w in G[v]:
            e = max(e, hs[w] + 1)
        hs[v] = e

    def dfs(v):
        res = [1]
        hv = 0
        for w in G[v]:
            r = dfs(w)
            hw = len(r)-1
            r0 = [0]*(hv+hw+1)
            for i in range(hv+1):
                for j in range(hw+1):
                    for k in range(max(i, j), i+j+1):
                        r0[k] += res[i] * r[j] * dp0[k][i][j] % MOD
            res = r0
            hv += hw
        return [0] + res
    write("%d\n" % (sum(dfs(r)) % MOD))
solve()



Measured memory_bytes: 116156
# -*- coding: utf-8 -*-
N = int(input())
Sn = []
for _ in range(N):
    Sn.append(list(input()))

Sn_ccnt = [{} for _ in range(N)]

for i,Si in enumerate(Sn):
    for c in Si:
        if c in Sn_ccnt[i]:
            Sn_ccnt[i][c] += 1
        else:
            Sn_ccnt[i][c] = 1

char_cnt = {}
for c in 'abcdefghijklmnopqrstuvwxyz':
    for ccnt in Sn_ccnt:
        if c in ccnt:
            if c in char_cnt:
                if ccnt[c] < char_cnt[c]:
                    char_cnt[c] = ccnt[c]
            else:
                char_cnt[c] = ccnt[c]
        else:
            char_cnt[c] = 0

ans = ""
for k, v in sorted(char_cnt.items(), key=lambda x: x[0]):
    ans += k*v

# print(char_cnt)
print(ans)


Measured memory_bytes: 3188
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
        ll a,b;
        cin >> a >> b;
        cout << a*b << endl;



    }
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <cmath>
#include <list>
#include <map>
#include <vector>

using namespace std;

int checkIntersection(double xa,double ya,double ra,double xb,double yb, double rb){
    double d = (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb);
    double sr = (ra+rb)*(ra+rb);
    double dr = (ra-rb)*(ra-rb);
    
    if (d > sr){
        return 0;
    }else if(d<sr && d<d){
        return 1;
    }else if(dr>d){
        return (ra>rb)?2:-2;
    }else return 1;
    
    
    
}

int main (int argc, char const* argv[]){
    double xa, ya,ra, xb,yb,rb;
    int i, n, result;
    
    cin >> n;
    while(cin >> xa>> ya>>ra>> xb>> yb>> rb){
        result = checkIntersection(xa, ya,ra, xb,yb,rb);
        
        cout << result << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
int main(void){
  int inum[13],num[14];
  int tmp,i,j,k,l=0,flag=1,flag1=0,flag3=0;
  int ko[9],koc[9];
  

  while(1){
  aaa:
    if(scanf("%1d",&inum[0])==EOF){
      break;
    }
    scanf("%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d",&inum[1],&inum[2],&inum[3],&inum[4],&inum[5],&inum[6],&inum[7],&inum[8],&inum[9],&inum[10],&inum[11],&inum[12]);
    for(k=1;k<10;k++){
    lp:
      flag=1;
          
      for(i=0;i<9;i++){
	ko[i]=0;
	koc[i]=0;
      }
      for(i=0;i<13;i++){
	num[i]=inum[i];
      }
      num[13]=k;
      for(i=0;i<13;i++){
	for(j=13;j>i;j--){
	  if(num[j]<num[j-1]){
	    tmp=num[j];
	    num[j]=num[j-1];
	    num[j-1]=tmp;
	  }
	}
      }

     
     
      for(i=0;i<14;i++){
	for(j=1;j<10;j++){
	  if(j==num[i]){
	    ko[j-1]=ko[j-1]+1;
	    if(ko[j-1]>5){
	      printf("0\n");
	      goto aaa;
	    }
	  }
	}
      }
   
      for(i=0;i<9;i++){
	koc[i]=ko[i];
	if(koc[i]>4){
	  k++;
	  goto lp;
	}
      }

     
      //hanntei

      for(j=0;j<9;j++){
	for(l=0;l<9;l++){
	  koc[l]=ko[l];
	}

	if(flag==1){
	  
	  if(koc[j]>=2){
	    flag=0;
	    flag1=0;
	    koc[j]=koc[j]-2;
	    
	    
	    for(l=0;l<9;l++){
	      if(koc[l]==1&&koc[l+1]>=1&&koc[l+2]>=1){
		koc[l]--;
		koc[l+1]--;
		koc[l+2]--;
	      }else if(koc[l]==4&&koc[l+1]>=1&&koc[l+2]>=1){
		koc[l]--;
		koc[l+1]--;
		koc[l+2]--;
	      }else if(koc[l]==2&&koc[l+1]>=2&&koc[l+2]>=2){
		koc[l]=koc[l]-2;
		koc[l+1]=koc[l+1]-2;
		koc[l+2]=koc[l+2]-2;
	      }
	    }
	  
	    for(l=0;l<9;l++){
	      if(koc[l]>=3){
		koc[l]=koc[l]-3;
	      }
	    }
	   
	   
	    for(l=0;l<9;l++){
	      if(koc[l]==1&&koc[l+1]>=1&&koc[l+2]>=1){
		koc[l]--;
		koc[l+1]--;
		koc[l+2]--;
	      }
	      }
	    for(l=0;l<9;l++){
	      if(koc[l]!=0){
		flag=1;
		flag1=1;
	      }
	    }
	    if(flag1==0){
	      if(flag3>0){
		printf(" ");
	      }
	      printf("%d",k);
	      flag3++;
	    }
	  }
	}
      }
    }
    if(flag3==0){
      printf("0");
    }
    printf("\n");
    flag3=0;
  }
  return 0;
}

Measured memory_bytes: 1848
n=int(input())
tmp=list(map(int,input().split()))
a=[]
ave=0
for i in range(n):
    ave+=tmp[i]
    a.append([i,tmp[i]])

ave=ave/n
a.sort(key=lambda x:(abs(ave-x[1]),x[0]))
# print(ave,a)
print(a[0][0])

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int llint;
llint n,k,arr[105],dp[105][100005],FWT[105][100005];
llint sum(llint a,llint b) {
	return ((a%1000000007)+(b%1000000007))%1000000007;
}
llint diff(llint a,llint b) {
	return ((a%1000000007)-(b%1000000007)+1000000007)%1000000007;
}
void update(llint ind,llint x,llint v) {
	x+=1;
	for(x;x<=100002;x+=x&-x) {
		FWT[ind][x]=sum(FWT[ind][x],v);
	}
}
llint query(llint ind,llint x) {
	x+=1;
	llint ret=0;
	for(x;x>0;x-=x&-x) ret=sum(ret,FWT[ind][x]);
	return ret;
}
int main()
{
	cin >> n >> k;
	for(llint i=0;i<n;i++) {
		cin >> arr[i];
	}
	//memset(dp,-1,sizeof(dp));
	for(llint i=0;i<=arr[0];i++) {
		dp[0][i]=1;
		update(0,i,1);
	}
	for(llint i=1;i<n;i++) {
		for(llint j=0;j<=k;j++) {
			dp[i][j]=diff(query(i-1,j),query(i-1,max(-1LL,j-arr[i]-1)));
			update(i,j,dp[i][j]);
		}
	}
	/*for(int i=0;i<n;i++) {
		for(int j=0;j<=k;j++) {
			cout <<dp[i][j]<<" ";
		}
		cout <<endl;
	}*/
	cout <<dp[n-1][k]%1000000007;
	return 0;
}


Measured memory_bytes: 160000
#include <bits/stdc++.h>
using namespace std;
char STR[200001];
void DEL(int i);
void INSERT(char ch, int i);
int main()
{
    char ch, pre;
    int cnt = 0, str_i = 0;

    while ((ch = getchar())!='\n')
    {
        if (pre == 'S' && ch == 'T')
        {
                DEL(str_i-1);
                pre = STR[str_i-2];
                str_i--;

        }
        else
        {
            INSERT(ch, str_i);
            pre = ch;
            str_i++;
        }
    }

    //printf("%s", STR);
    int l = strlen(STR);
    for (int i=0; i<l; i++)
    {
        if (STR[i] == '.')
            cnt++;
    }
    printf("%d", l - cnt);

    return 0;
}
void DEL(int i)
{
        STR[i] = '.';
}
void INSERT(char ch, int i)
{
    STR[i] = ch;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;

  if (s[2] == s[3] && s[4] == s[5]){
    Out("Yes");
    return 0;
  }
  Out("No");
  
}


Measured memory_bytes: 256
h,w = gets.split.map(&:to_i)
c = 10.times.map{gets.split.map(&:to_i)}

for i in 0..9
  for j in 0..9
    for k in 0..9
      c[j][k] = c[j][i]+c[i][k] if c[j][k] > c[j][i]+c[i][k]
    end
  end
end

ans = 0
h.times do
  a = gets.split.map(&:to_i)
  w.times do |i|
    ans += a[i] == -1 ? 0 : c[a[i]][1]
  end
end

puts ans

Measured memory_bytes: 2300
#include <cstdio> 
#define abs(x) ((x>0)?x:(-(x))) 
int H,W,D,A; 
int Q,L,R; 
int px[90001],py[90001]; 
int d[90001]; 
int main() { 
  scanf("%d%d%d",&H,&W,&D); 
  for(int i=0;i<H;i++) { 
    for(int j=0;j<W;j++) { 
      scanf("%d",&A); px[A]=i,py[A]=j; 
    } 
  } 
  for(int i=D+1;i<=H*W;i++) d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]); 
  scanf("%d",&Q); 
  while(Q--) { 
    scanf("%d%d",&L,&R); 
    printf("%d\n",d[R]-d[L]); 
  } 
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n%2!=0){cout<<0;return 0;}
    vector<int> d(n,0);
    for(int i=0;i<n;i++)cin>>d[i];
    sort(d.begin(),d.end());
    cout<<d[n/2]-d[(n/2)-1];//654
    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	Di := make(map[int]int)
	for i := 0; i < N; i++ {
		Di[nextInt()]++
	}
	M := nextInt()
	// Ti := make(map[int]int)
	// for i := 0; i < M; i++ {
	// 	Ti[nextInt()]++
	// }
	for i := 0; i < M; i++ {
		D := nextInt()
		Di[D]--
		if Di[D] < 0 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 28672
x, a, b = gets.split.map(&:to_i)
n = gets.to_i
n.times do
  case gets
  when /^n/ then x = [x + a, 0].max
  when /^t/ then x = [x + b, 0].max
  when /^k/ then x = 0
  end
end
p x


Measured memory_bytes: 8880
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int t, k, x, y;
	cin >> x >> y;
	bool yes = false;
	for (t = 0; t <= x; t++) {
		k = x - t;
		if (2 * t + 4 * k == y)
			yes = true;
	}
	cout << (yes ? "Yes" : "No") << endl;
	return 0;
}

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

int main(void){
    int n;
    int reminder = 0;
    cin >> n;
    reminder = n % 10;

    if(reminder == 3){
	cout << "bon" << endl;
    }else if(reminder == 0 || reminder == 1 || reminder == 6 || reminder == 8){
	cout << "pon" << endl;
    }else{
	cout << "hon" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<int, int>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;

int main(){
    int n;cin>>n;
    double b=n;
    cout<<(b-n/2)/b<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%s', $s);
if ($n % 2 == 1) {
    echo 'No';
    exit;
}
echo (substr($s, 0, $n / 2) === substr($s, $n / 2, $n / 2)) ? 'Yes' : 'No';


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

int main(){
    string s;
    cin >> s;
    
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        for(int j=i; j<s.size(); j++){
            bool flag = true;
            string sub = s.substr(i, j-i+1);
            for(auto c:sub){
                if(c != 'A' && c != 'C' && c != 'G' && c != 'T') flag = false;
            }
            if(flag) ans = max(ans, (int)sub.size());
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>V(M-1);
	vector<int>A(M);
	for (int i = 0; i < M; ++i)cin >> A[i];
	sort(A.begin(), A.end());
	for (int i = 0; i < M - 1; ++i) {
		V[i] = A[i + 1] - A[i];
	}
	if (N >= M) {
		cout << 0 << endl;
	}
	else {
		sort(V.begin(), V.end());
		int sum = 0;
		for (int i = 0; i < M - N; ++i) {
			sum += V[i];
		}
		cout << sum << endl;
	}
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,a=1,b=1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a *= 3;
        if(x%2 == 0) b *= 2;
    }
    cout << a-b << endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int h,a;
	cin >> h >> a;
	cout << (h-1)/a+1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int max(int p,int q){
    if(p>q) return p;
    else return q;
}
int main(void){
    int k,n,i;
    scanf("%d%d",&k,&n);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    int ans = k+a[0]-a[n-1];
    for(i=0;i<n-1;i++) ans = max(ans,a[i+1]-a[i]);
    printf("%d",k-ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    ll x, y;
    cin >> x >> y;
    if(x * y > 0 && y < x){
        cout << abs(y - x) + 2 << endl;
    }else if(x * y > 0){
        cout << abs(y - x) << endl;
    }else if(x * y < 0){
        cout << abs(abs(y) - abs(x)) + 1 << endl;
    }else if(x == 0 && y >= 0){
        cout << y << endl;
    }else if(x == 0){
        cout << abs(y) + 1 << endl;
   }else if(y == 0 && x <= 0){
       cout << abs(x) << endl;
   }else if(y == 0){
       cout << x + 1 << endl;
   }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
	int A,B,C;	
	cin >> A;
	cin >> B;
	cin >> C;
	if (min(A,B)<C && max(A,B)>C)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N;
    int j, a=0;

    cin >> N;

    string S;
    map<string, int> memo;

    rep(i, N) {
        cin >> S;
        memo[S]++;
    }

    int mx = 0;

    for(auto& x: memo) {
        int v = x.second;
        mx = max(mx, v);
    }

    for(auto i=memo.begin(); i!=memo.end(); i++) {
        if(i->second == mx) {
            cout << i->first << endl;
        }
    }

    return 0;
    
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const int INF = (int)1e9;
const int maxN = (int)1e5 + 10;

void solve() {
  int n, m, u, v;
  cin >> n >> m;
  vector<int> h(n + 1);
  for (int i = 1 ; i <= n ; i++) {
    cin >> h[i];
  }
  vector<int> g[maxN];
  for (int i = 0 ; i < m ; i++) {
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  int ans = 0;
  for (int i = 1 ; i <= n ; i++) {
    int hh = -1;
    for (int x : g[i]) {
      hh = max(hh, h[x]);
    }
    if (h[i] > hh) ans++;
  }
  cout << ans;
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

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

int main(){
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if(x <= 3) ans += 100000 * (4 - x);
    if(y <= 3) ans += 100000 * (4 - y);
    if(x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int k, n;
int arr[300100];

int main() {
    int i, j;

    scanf("%d%d",&k,&n);
    if (k%2==0) {
        printf("%d ",k/2);
        for (i=1;i<n;i++) printf("%d ",k);
        printf("\n");
        return 0;
    }
    if (k==1) {
        for (i=0;i<(n+1)/2;i++) printf("1 ");
        printf("\n");
        return 0;
    }
    for (i=0;i<n;i++) arr[i] = (k+1)/2;
    for (i=0;i<n/2;i++) {
        for (j=n-1;!arr[j];j--);
        arr[j]--;
        if (arr[j]) for (j++;j<n;j++) arr[j]=k;
    }
    for (i=0;i<n;i++) {
        if (arr[i]) printf("%d ",arr[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 3456
//Number 1153

#include <stdio.h>
#define MAX 100

int main(void)
{
  int n, m, i, j, sum1, sum2, out1, out2, min;
  int taro[MAX] = {0};
  int hanako[MAX] = {0};

  while(1)
    {
      scanf("%d %d", &n, &m);
      if(n==0&&m==0)
	break;

      sum1 = 0;
      sum2 = 0;
      
      for(i=0; i<n; i++)
	{
	  scanf("%d", &taro[i]);
	  sum1 += taro[i];
	}
      
      for(i=0; i<m; i++)
	{
	  scanf("%d", &hanako[i]);
	  sum2 += hanako[i];
	}

      out1 = -1;
      out2 = -1;
      min = 200;
      for(i=0; i<n; i++)
	{
	  for(j=0; j<m; j++)
	    {
	      if(sum1-taro[i]+hanako[j]==sum2+taro[i]-hanako[j])
		{
		  if(min>=taro[i]+hanako[j])
		    {
		      out1 = taro[i];
		      out2 = hanako[j];
		      min = out1 + out2;
		    }
		  //break;
		}
	    }
	}

      //printf("%d\n", out1);
      //printf("%d\n", out2);
      
      if(out1==-1&&out2==-1)
	printf("-1\n");
      else
	printf("%d %d\n", out1, out2);
      
    }
  return 0;
}

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

int main(void){
    int i,n;
    cin >> n;
    long int R[n], tmp[2];
    cin >> R[0];
    cin >> R[1];
    tmp[0]=min(R[0],R[1]);
    tmp[1]=R[1]-R[0];
    for(i=2; i<n; i++){
        cin >> R[i];
        tmp[1] = max(R[i]-tmp[0],tmp[1]);
        tmp[0] = min(R[i], tmp[0]);
    }
    cout << tmp[1] << endl;
    return 0;
}

Measured memory_bytes: 4648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  int A,B;
  cin>>a>>b>>c>>d;
  A=a;
  if(a>b){
    A=b;
  }
  B=c;
  if(c>d){
    B=d;
  }

  cout<<A+B<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define H 501
#define W 101
#define K 101

using namespace std;
int h,n,p,m,k;
double mem[H][W][K];
bool used[H][W][K];
int bar[H];

double dfs(int y,int x,int cnt){
  if(y == 0) return (x == p)*(cnt == 0);
  if(used[y][x][cnt]) return mem[y][x][cnt];
  used[y][x][cnt] = 1;
  double res = 0;

  if(bar[y]!=-1){
    if(bar[y] == x) res += dfs(y-1,x+1,cnt);
    else if(bar[y] == x-1) res += dfs(y-1,x-1,cnt);
    else res += dfs(y-1,x,cnt);
  }

  else if(bar[y] == -1){
    double numh = h - m  - (k - cnt);
    double div = (n-1) * numh/cnt;
    int c = 0;
    if(x < n-1 && cnt) res += dfs(y-1,x+1,cnt-1)/div,c++;
    if(x > 0 && cnt) res += dfs(y-1,x-1,cnt-1)/div,c++;
    if(cnt) res += (dfs(y-1,x,cnt-1) * (n-1-c))/div;
    res += dfs(y-1,x,cnt);
  }
  return mem[y][x][cnt] = res;
}

signed main(){
  cin>>h>>n>>p>>m>>k;
  p--;
  memset(bar,-1,sizeof(bar));
  for(int i=0,a,b;i<m;i++)cin>>a>>b,bar[h-a+1] = b-1;

  double ans = 0;
  for(int i=0;i<n;i++){
    double res = dfs(h,i,k);
    ans = max(ans,res);
  }
  printf("%.10lf\n",ans);

  return 0;
}

Measured memory_bytes: 48084
#include "bits/stdc++.h"
using namespace std ;

int b[105];
int a[105] ;
int main(){
	int n ;
	cin >> n ;
	for( int i = 1 ; i <= n-1 ; i++ ){
		cin >> b[i] ;
	}
	a[0] = b[1];
	for( int i = 1 ; i < n-1  ; i++  ){
		a[i] = min(b[i],b[i+1]);
	}
	a[n-1] = b[n-1] ;
	int ans = 0 ;
	for( int i = 0 ; i < n ; i++ ){
		ans += a[i] ;
	}
	cout << ans << endl ;



	return 0 ;
}

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

ll calc(ll x){

  ll ans = 1;
  
  for(ll i=1; i*i<=x; i++){
    if(x%i==0){
      ans = max(ans, i);
    }
  }

  return ans;
}



int main(){
  ll N;
  cin >> N;  
  
  int res = calc(N);
  
  cout << (res-1)+(N/res)-1 << endl;
  
  
  return 0;
}

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

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

  if(n==0){
    cout << 0 << endl;
    return 0;
  }

  string ans = "";
  while(n!=0){
    if(n%2==0) ans = "0"+ans;
    else{
      ans = "1"+ans;
      n-=1;
    }
    n/=-2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include <functional>
#include<algorithm>
#include <iterator>

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

int main()
{
	int N;
	vector<int>rr;
	cin>>N;
	vector<int>A(N+1),B(N+1);
	vector<bool>f(N+1,false);
	for(int i=1;i<=N;i++)
	{
		int a;
		cin>>a;
		A[i]=a;
	}
	for(int i=N;i>=1;i--)
	{
		if(A[i]!=B[i]%2)
		{
			rr.push_back(i);
			for(int j=1;j*j<=i;j++)
			{
				int pp=i/j;
				if(i%j==0)
				{
					B[pp]++;
					if(i!=j*j)
						B[j]++;
				}
			}
		}
	}
	if(B[1]%2==A[1])
	{
		sort(rr.begin(),rr.end());
		cout<<rr.size()<<endl;
		for(int i=0;i<rr.size();i++)
		{
			cout<<rr[i]<<(i==rr.size()-1?"\n":" ");
		}

	}
	else
	{
		cout<<"-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3196
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
BC = []
for _ in range(M):
    B, C = map(int, input().split())
    BC.append([B, C])
BC = sorted(BC, key=lambda x: x[1], reverse=True)
# print("A: {}".format(A))
# print("BC: {}".format(BC))

A_dash = []
for ij in BC:
    i, j = ij
    A_dash.extend([j]*i)
    if len(A_dash) >= N:
        break
A_dash = A_dash[:N]

A_dash.extend(A)
A_dash = sorted(A_dash, reverse=True)[:N]

print(sum(A_dash))


Measured memory_bytes: 29500
#include<bits/stdc++.h>
#define int long long
#define MAXN 200010
using namespace std;
int n,m,A[30][MAXN];
char S[MAXN],T[MAXN];
long long ans;
bool vis[30];
signed main(){
	scanf("%s",S+1);
	n=strlen(S+1);
	scanf("%s",T+1);
	m=strlen(T+1);
	for(int i=1;i<=n;i++){
		int num=S[i]-'a'+1;
		A[num][++A[num][0]]=i;
		vis[num]=true;
	}
	int la=0;
	for(int i=1;i<=m;i++){
		int num=T[i]-'a'+1;
		if(vis[num]==false){
			puts("-1");
			return 0;
		}
		int p=upper_bound(A[num]+1,A[num]+1+A[num][0],la)-A[num];
		if(p==A[num][0]+1){
			ans=((ans/n)+1)*1LL*n;
			la=A[num][1];
		}
		else la=A[num][p];
	}
	ans+=la;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 41472
S = list(input())
N = len(S)
dp = [[0] * 13 for _ in range(N+1)]
MOD = 10**9 + 7
s = S[0]
if s=='?':
    for k in range(10):
        dp[0][k] = 1
else:
    dp[0][int(s)] = 1
 

for i in range(1,N):
    s = S[i]
    if s=='?':
        for j in range(13):
            for k in range(10):
                tmp = (j*10 + k)%13
                dp[i][tmp] += dp[i-1][j]
                dp[i][tmp] %= MOD
    else:
        for j in range(13):
            tmp = (j*10 + int(s))%13
            dp[i][tmp] += dp[i-1][j]
            dp[i][tmp] %= MOD
            
print(dp[N-1][5])

Measured memory_bytes: 64888
#include<iostream>
#include<cstdio>
using namespace std;
int n[1001];
int main()
{
	int a,b,c,d,ans=0;
	cin>>a>>b>>c>>d;
	for(int i=a;i<=b;i++)
		n[i]++;
	for(int i=c;i<=d;i++)
		n[i]++;
	for(int i=0;i<=100;i++)
		if(n[i]==2) ans++;
	if(ans==0) cout<<"0";
	else cout<<ans-1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define booga cout << "booga" << endl
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


int main(int argc, char** argv){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	cout << n * (n-1) / 2 << "\n";
	return 0;
}



Measured memory_bytes: 256