akhauriyash/Code-Regression huggingface dataset:
// May this submission get accepted
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1, m = inp1;
    vector<ll> a = inp(n);
    
    REP(i, n) a[i] /= 2;

    auto b = a;
    REP(i, n) b[i] = a[i] & ~(a[i] - 1);
    bool okay = true;
    REP(i, n-1) okay &= b[i] == b[n-1];
    if (!okay) {
        cout << 0 << endl;
        return 0;
    }

    ll l = a[0];
    RANGE(i, 1, n-1) {
        l = l / gcd(l, a[i]) * a[i];
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }

    // DUMP(l);
    cout << m / l - m / (l * 2) << endl;
    
}

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

int main(){
    int n,h[100]={0};
    cin>> n;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int ans=1;
    int max=h[0];
    for(int i=1;i<n;i++){
        if(h[i]>=max){
            ans++;
            max=h[i];
        }
    }
    cout<<ans<<"\n";
    return(0);
}

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

#define N 100010

using namespace std;

typedef pair<pair<int, int>, int> Type;

map<string, int> A;

set<Type> Q1, Q2;
set<Type>::iterator it;

int n, cnt, m, val[N], Time[N];
char name[N][30], s[30], opt[30];

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int v, id;
		scanf("%s%d", s, &v);
		if(!A.count((string)s))
		{
			A[(string)s] = ++cnt;
			int l = strlen(s);
			for(int j = 0; j < l ;j++)
				name[cnt][j] = s[j];
			name[cnt][l] = 0;
		}
		id = A[(string)s];
		val[id] = v;
		Time[id] = i;
		Q2.insert(make_pair(make_pair(v, i), id));
	}
	int size = cnt;
	int K = size / 5;
	while(Q1.size() < K)
	{
		it = Q2.end();
		it--;
		Q1.insert(*it);
		Q2.erase(it);
	}
	scanf("%d", &m);
	for(int i = 1; i <= m; i++)
	{
		int v, id;
		scanf("%s", opt);
		if(opt[0] == '+')
		{
			scanf("%s%d", s, &v);
			if(!A.count((string)s))
			{
				A[(string)s] = ++cnt;
				int l = strlen(s);
				for(int j = 0; j < l ;j++)
					name[cnt][j] = s[j];
				name[cnt][l] = 0;
			}
			id = A[(string)s];
			val[id] = v;
			Time[id] = i + n;
			size++;
			K = size / 5;
			Type now = make_pair(make_pair(v, i + n), id);
			it = Q2.end();
			it--;
			if((*it).first.first > v)
			{
				printf("%s is not working now.\n", name[id]);
				Q2.insert(now);
				while(Q1.size() < K)
				{
					Q1.insert(*it);
					printf("%s is working hard now.\n", name[(*it).second]);
					Q2.erase(it);
				}
			}
			else
			{
				Q1.insert(now);
				it = Q1.begin();
				if((*it).second == id && Q1.size() > K)
				{
					printf("%s is not working now.\n", name[id]);
					Q2.insert(*it);
					Q1.erase(it);
				}
				else
				{
					printf("%s is working hard now.\n", name[id]);
					while(Q1.size() > K)
					{
						printf("%s is not working now.\n", name[(*it).second]);
						Q2.insert(*it);
						Q1.erase(it);
					}
				}
			}
		}
		else
		{
			scanf("%s", s);
			size--;
			K = size / 5;
			int id = A[(string)s];
			Type now = make_pair(make_pair(val[id], Time[id]), id);
			it = Q1.find(now);
			if(it == Q1.end())it = Q2.find(now), Q2.erase(it);
			else Q1.erase(it);
			while(Q1.size() > K)
			{
				it = Q1.begin();
				printf("%s is not working now.\n", name[(*it).second]);
				Q2.insert(*it);
				Q1.erase(it);
			}
			while(Q1.size() < K)
			{
				it = Q2.end();
				it--;
				printf("%s is working hard now.\n", name[(*it).second]);
				Q1.insert(*it);
				Q2.erase(it);
			}
		}
	}
}

Measured memory_bytes: 14780
#include <iostream>

using namespace std;

int main() {
    int numberList[102] = {0};
    int X, N, p;

    cin >> X;
    cin >> N;


    for (int i = 0;i < N;i++) {
        cin >> p;
        numberList[p] = 1;
    }

    int min = -1, max = -1;
    int minleng = -1, maxleng = -1;
    for (int i = X;i >= 0;i--) {
        if (numberList[i] == 0 && min == -1) {
            min = i;
            minleng = X - i;
            break;
        }
    }
    for (int i = X;i <= 101;i++) {
        if (numberList[i] == 0 && max == -1) {
            max = i;
            maxleng = i - X;
            break;
        }
    }

    if (minleng <= maxleng) {
        cout << min << endl;
    } else {
        cout << max << endl;
    }

    return 0;

}

Measured memory_bytes: 3616
#include <stdio.h>

int N;
char S[271828];

int asumi[271828], iguti[271828];

int main(void) {
	int i;
	int hayamisaori;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%271826s", S + 1) != 1) return 1;
	for (i = 1; i <= N; i++) {
		asumi[i] = asumi[i - 1] + (S[i] == '#');
	}
	for (i = N; i >= 1; i--) {
		iguti[i] = iguti[i + 1] + (S[i] == '.');
	}
	hayamisaori = N;
	for (i = 0; i <= N; i++) {
		int hanazawakana = asumi[i] + iguti[i + 1];
		if (hanazawakana < hayamisaori) hayamisaori = hanazawakana;
	}
	printf("%d\n", hayamisaori);
	return 0;
}

/* 白(0個以上) → 黒(0個以上) にする */


Measured memory_bytes: 3496
from collections import Counter

H, W = map(int, input().split())
a = ""

for _ in range(H):
    a = a + input()

c = Counter(a)

s_4 = 0
s_2 = 0
s_1 = 0

for _, x in c.most_common():
    s_4 += x//4
    s_2 += (x%4)//2
    s_1 += x%2
    
a_4 = (H//2)*(W//2)
a_2 = (H//2)*(W%2)+(W//2)*(H%2)
a_1 = (H%2)*(W%2)

if s_4 - a_4 < 0:
    print("No")
elif (s_2+(s_4 - a_4)*2) - a_2 < 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3444
N, K = map(int, input().split())
L = 10**9+7

parts = []
i = 1
while i<=N:
    a = N // i
    j = N // a
    parts.append(j-i+1)
    i = j+1

C = parts
for _ in range(K-1):
    C_new = []
    c = 0
    for i,p in enumerate(parts[::-1]):
        num_dual = i
        c += C[i]
        C_new.append(p * c % L)
    C = C_new[::-1]
print(sum(C) % L)


Measured memory_bytes: 132556
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	StringBuilder out;

	void run() {
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextInt();
		}
		out = new StringBuilder();
		print(A);
		for (int i = 1; i < N; i++) {
			int v = A[i];
			int j = i - 1;
			while (j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			print(A);
		}
		System.out.print(out);
	}

	void print(int[] A) {
		for (int i = 0; i < A.length; i++) {
			out.append((i == 0 ? "" : " ") + A[i]);
		}
		out.append("\n");
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 23316
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

struct Pro {
  int v;
  int w;
};

int capa;
int ans = 0;
V<Pro> p;

int main() {
  int n, capa;
  cin >> n >> capa;
  V<int> v(n), w(n);

  rep(i, n) {
    cin >> v[i] >> w[i];
  }

  // dp[品物][重さ] = 価値
  V<V<int>> dp(n + 1, V<int>(capa + 1));
  rep(i ,capa + 1) {
    dp[0][i] = 0;
  }

  rep(i, n) {
    rep(j, capa + 1) {
      if(j - w[i] >= 0) {
        dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  cout << dp[n][capa] << endl;
}



Measured memory_bytes: 6776
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se seoncd
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

char s[105];
int n;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(n%2==1){
		puts("No");
		return 0;
	}
	for(int i=1;i<=n;i+=2)
		if(s[i]!='h'){
			puts("No");
			return 0;
		}
	for(int i=2;i<=n;i+=2)
		if(s[i]!='i'){
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

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

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    int arr1[101] = {0}, arr2[101] = {0}, cnt = 0;
    for(int i=a; i<b; i++)
        arr1[i] = 1;
    for(int i=c; i<d; i++)
        arr2[i] = 1;
    for(int i=0; i<=100; i++){
        //if(i <= 60)cout<<i<<" "<<arr2[i]<<endl;
        if(arr1[i] == 1 && arr2[i] == 1) cnt++;}
    cout<<cnt<<endl;
    return 0;
}

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

typedef long long ll;

int main()
{
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int ans=0;
    if(h1>h2)ans=(h1-h2)*60+(m1-m2);
    else ans=(h2-h1)*60+(m2-m1);
    cout<<(max(0,ans-k))<<endl;
    return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A,B;
    cin>>A>>B;
    int counter=0;
    for(int i=A; i<=B; i++) {
        int a=i/10000;
        int b=(i-a*10000)/1000;
        int c=(i-a*10000-b*1000)/100;
        int d=(i-a*10000-b*1000-c*100)/10;
        int e=i%10;
        if(a==e&&b==d) counter++;
    }
    cout<<counter<<endl;
}

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

int W, H;
char tile[25][25];
int cnt;

void dfs(int y, int x){
	cnt++;
	tile[y][x] = '#';
	int dy[4] = { 0, 1, 0, -1 };
	int dx[4] = { 1, 0, -1, 0 };
	for (int i = 0; i < 4; i++){
		int Y = y + dy[i];
		int X = x + dx[i];
		if (0 <= Y&&Y < H && 0 <= X&&X < W&&tile[Y][X] != '#')dfs(Y, X);
	}
}

int main(){
	
	
	while (cin >> W >> H,W != 0 && H != 0){
		cnt = 0;

		int y, x;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> tile[i][j];
				if (tile[i][j] == '@'){
					y = i;
					x = j;
				}
			}
		}
		dfs(y, x);

		cout << cnt << endl;

	}
return 0;
}




Measured memory_bytes: 3032
#include <cstdio>
#include <algorithm>
#include <queue> 
#define il inline
#define N 200001
using namespace std;

int T,n,a[N],b[N],pos[N];
int t[2][4*N];
struct node
{
	int a,b,x,y,l,r;
};
il bool operator < (node i,node j){return i.a>j.a;}
priority_queue<node> h;

il char gc()
{
    static char now[1<<20],*S,*T;
    if (T==S)
    {
        T=(S=now)+fread(now,1,1<<20,stdin);
        if (T==S) return EOF;
    }
    return *S++;
}

il int read()
{
	int res=0;
	char c;
	while ((c=gc())<'0'||c>'9');
	res=(c^48);
	while ((c=gc())>='0'&&c<='9') res=(res<<3)+(res<<1)+(c^48);
	return res;
}

il void build(int k,int l,int r)
{
	if (l==r){t[0][k]=b[l],t[1][k]=a[l];return;}
	int mid=(l+r)>>1;
	build(k<<1,l,mid),build(k<<1|1,mid+1,r);
	t[0][k]=min(t[0][k<<1],t[0][k<<1|1]),t[1][k]=min(t[1][k<<1],t[1][k<<1|1]);
}

il int query(int id,int k,int l,int r,int x,int y)
{
	if (l>=x&&r<=y) return t[id][k];
	int mid=(l+r)>>1,res=2e8;
	if (x<=mid) res=min(res,query(id,k<<1,l,mid,x,y));
	if (y>mid) res=min(res,query(id,k<<1|1,mid+1,r,x,y));
	return res;
}

il void work(int l,int r)
{
	if (l>r) return;
	int x=query(l&1,1,1,n,l,r),X=pos[x],y=query(l&1^1,1,1,n,X,r),Y=pos[y];
	node res=(node){x,y,X,Y,l,r};
	h.push(res);
} 

int main()
{
	n=read();
	int i,x,y,l,r,X,Y;
	node now;
	for (i=1; i<=n; i++)
	{
		if (i&1) pos[a[i]=read()]=i,b[i]=1e8;
		else pos[b[i]=read()]=i,a[i]=1e8;
	}
	build(1,1,n),work(1,n);
	
	while (!h.empty())
	{
		node now=h.top(); h.pop();
		printf("%d %d ",now.a,now.b);
		work(now.l,now.x-1),work(now.x+1,now.y-1),work(now.y+1,now.r);
	}
	
	return 0;
}

Measured memory_bytes: 12148
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  
  unsigned long long int ans;
  if (X / D >= K){
    ans = X;
    for (int i = 0; i < K; i++){
      ans -= D;
    }
    cout << ans << endl;
  }
  else{
    if ((K - (X / D)) % 2 == 1){
      ans = abs(X - D * ((X / D) + 1));
    }
    else{
      ans = X - D * (X / D);
    }
    cout << ans << endl;
  }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

int draw(int cur, vector<int> &color, const Graph &G, int col) {
    color[cur] = col;
    for (int nx : G[cur]) {
        if (color[nx] == -1) {
            int ret = draw(nx, color, G, 1-col);
            if (ret < 0) return -1;
        } else if (color[nx] == col) {
            return -1;
        }
    }
    return 0;
}

void solve() {
    ll N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    vector<int> color(N, -1);
    int ret = draw(0, color, G, 0);
    if (ret < 0) {
        cout << N * (N-1) / 2 - M << '\n';
    } else {
        ll b = count(color.begin(), color.end(), 0);
        ll w = count(color.begin(), color.end(), 1);
        cout << b * w - M << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int count = 0;
	for(int i=0; i<a; i++)
	{
		int temp;
		cin >> temp;
		while(temp % 2 == 0)
		{
			count ++;
			temp /= 2;
		}
	}
	printf("%d\n",count);
	return 0;
}

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

int n;
int a, k;
int res;

int Solve(int a, int k)
{
	while (a % k)
		if (k <= a / k) {
			int sub = a / k + 1;
			a -= sub;
		} else {
			int sub = a / k + 1;
			int lim = a / k * k;
			int tk = (a - lim) / sub;
			if (tk * sub != a - lim) tk++;
			a -= tk * sub;
		}
	return a / k;
}

int main()
{
	scanf("%d", &n);
	while (n--) {
		scanf("%d %d", &a, &k);
		res ^= Solve(a, k);
	}
	printf("%s\n", res? "Takahashi": "Aoki");
	return 0;
}

Measured memory_bytes: 256
// Base -2 Number

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;

int n;

void to_base2() {
    string ans = "";
    while (n > 0) {
        if (n % 2 == 0) {
            ans = "0" + ans;
        } else {
            ans = "1" + ans;
        }
        n >>= 1;
    }
    cout << ans << endl;
}

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

int main() {
    cin >> n;

    to_base_minus2();
    return 0;
}


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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);
    
    string s; cin >> s;
    reverse(s.begin(), s.end());
    int n = s.size();
    vector<vector<int>> dp(n+1, vector<int>(13, 0));
    dp[0][0] = 1;
    int tmp = 1;
    for(int i=0;i<n;++i) {
      if(s[i] == '?') {
        for(int j=0;j<13;++j) {
          for(int k=0;k<10;++k) {
            dp[i+1][(j+k*tmp)%13] += dp[i][j];
            dp[i+1][(j+k*tmp)%13] %= MOD;
          }
        }
      } else {
        for(int j=0;j<13;++j) {
          dp[i+1][(j+(s[i]-'0')*tmp)%13] += dp[i][j];
          dp[i+1][(j+(s[i]-'0')*tmp)%13] %= MOD;
        }
      }
      tmp = (tmp * 10) % 13;
    }

/*     for(int i=0;i<=n;++i) {
      printv(dp[i]);
    } */
    cout << dp[n][5] << endl;

}

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

int main(int argc, char const *argv[])
{
    int H,W;
    while(1) {
        cin >> H >> W;
        if(H==0 && W ==0) break;
        for (int i = 0; i < H; ++i)
        {
            for (int j = 0; j < W; ++j)
            {
                if((i+j)%2==0) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll n,k;
    cin >> n >> k;
    ll sum=0;
    for(ll i=k;i<=n+1;i++){
        sum+=i*(n-i+1)+1;
      	sum%=mod;
    }
    cout << sum;
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
char c;int a,b,l,i;
int main(){
	scanf("%d%d",&a,&b);
	l=a+b+1;
	for(i=0;i<l;i++){
		cin>>c;
		if(i==a&&c!='-'||i!=a&&(c<'0'||c>'9')){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[10001];
bool f=false;
int main(){
	cin>>a;
	int l=strlen(a);
	for(int i=0;i<=l-1;i++){
		if(a[i]=='C'){
			for(int j=i;j<=l-1;j++){
				if(a[j]=='F')f=true;
			}
		}
	}
	if(f==true)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i;
	char S[5];
	scanf("%s",S);
	for(i=0;i<4;i++){
		if(S[i]=='A'&&S[i+1]=='C'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
int h,w;
char a[101][101];

void dfs(int c, int b, char sign){
	int y = c-1;
	int x = b;
	if(y>=0 && x>=0 && y<h && x<w && a[y][x] == sign){
		a[y][x] = '!';
		dfs(y, x, sign);
	}
	y = c+1;
	x = b;
	if(y>=0 && x>=0 && y<h && x<w && a[y][x] == sign){
		a[y][x] = '!';
		dfs(y, x, sign);
	}
	y = c;
	x = b - 1;
	if(y>=0 && x>=0 && y<h && x<w && a[y][x] == sign){
		a[y][x] = '!';
		dfs(y, x, sign);
	}
	y = c;
	x = b + 1;
	if(y>=0 && x>=0 && y<h && x<w && a[y][x] == sign){
		a[y][x] = '!';
		dfs(y, x, sign);
	}
	
	
}



int main()
{	
	//freopen("in.txt", "r", stdin);
	while(cin >> h >> w){
		if(h == 0 && w == 0){
			break;
		}
		memset(a,127,sizeof(a));
		for(int i = 0; i<h; i++){
			for(int j = 0; j<w; j++){
				cin >> a[i][j];
			}
		}
		int count = 0;
		for(int i = 0; i<h; i++){
			for(int j = 0; j<w; j++){
				if(a[i][j] != '!'){
					dfs(i, j, a[i][j]);
					count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
} 


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

ll n,a,dp[51][51][2501];
ll ans=0;
vector<ll> x(51);

int main(){
    cin >> n >> a;
    for(int i = 0;i < n;i ++){
        cin >> x[i+1];
    }
    dp[0][0][0] = 1;
    for(int j = 0;j < n+1;j ++){
        for(int k = 0;k < n+1;k ++){
            for(int s = 0;s < n*a+1;s ++){
                if(j>=1&&s<x[j]) dp[j][k][s] = dp[j-1][k][s];
                else if(j*k>=1&&s>=x[j]) dp[j][k][s] = dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];
            }
        }
    }
    for(int k = 1;k < n+1;k ++){
        ans += dp[n][k][k*a];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N=1e9+7;
int32_t main()
{
    IOS;
    string s;
    string t;
    cin>>s;
    cin>>t;
    int i=0;
    int j=t.size()-1;
    int ans = INT_MAX;
    int corr=0;
    while(j<=s.size()-1)
    {
        corr=0;
        for(int k=i;k<=j;k++)
        {
            if(s[k]!=t[k-i])
            {
                corr++;
            }
        }
        ans = min(ans,corr);
        i++;
        j++;
    }
    if(ans==INT_MAX)
        ans=0;
    cout<<ans;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define F first
#define S second
#define s(x) #x<<" "<<x<<" | "<<
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define all(A)  A.begin(),A.end()  
#define has(m,x)   (m.find(x)!=m.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define endl "\n"
const int MSIZE = 2e5+5;
const int MOD = 1e9+7 ;


int arr[MSIZE];
ll brr[MSIZE];


int main(){

    FIO
    int n,m,k; cin>>n>>m>>k;
    f(i,0,n-1)    cin>>arr[i];
    brr[0] = 0;
    f(i,1,m) {
        cin>>brr[i]; brr[i] += brr[i-1];
        // cout<<brr[i]<<" ";
    }
    // cout<<endl;
    int ans = upper_bound(brr,brr+m+1,k) - brr - 1;
    f(i,0,n-1) {
        if(k<arr[i])    break;    k-=arr[i];
        int len = i + upper_bound(brr,brr+m+1,k) - brr;
        ans = max(ans,len);
        // cout<< s(i) s(len) s(ans) s(k) endl;
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}
    


Measured memory_bytes: 5996
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    string s;
    scan(s);
    writeln(s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ? "Bad" : "Good");
}














void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int count = 0;
    for(int i=a; i<=b; i++) {
      StringBuffer sb = new StringBuffer(String.valueOf(i));
      if(String.valueOf(i).equals(sb.reverse().toString()))
        count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 50064
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
/* contest template */
int n;
int c[500];
int s[500];
int f[500];
int a[500];

int time(int n, int i, int t) {
	if (i == n - 1) {
		return t;
	}
	else if (t <= s[i]) {
		return time(n, i + 1, s[i] + c[i]);
	}
	else {
		return time(n, i + 1, f[i] * (ceil((double)t / (double)f[i]))+c[i]);
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 0; i <= n - 1; i++) {
		a[i] = time(n, i, 0);
	}
	for (int i = 0; i < n; i++) {
		cout << a[i]<<endl;
	}

	return 0;
}



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

int main()
{
    vector<vector<ll>> A(3, vector<ll>(3, 0));
    rep(i,3) {
        rep(j,3) {
            ll tmp; cin >> tmp;
            A[i][j] = tmp;
        }
    }
    ll N; cin >> N;
    rep(k, N) {
        ll tmp; cin >> tmp;
        rep(i,3) {
        rep(j,3) {
            if (A[i][j] == tmp) {
                A[i][j] = -1;
            }
        }
        }
    }
    rep(i,3) {
        if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1) {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    rep(i,3) {
        if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1) {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) {
        cout << "Yes" << endl;
        exit(0);
    }
    if (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1) {
        cout << "Yes" << endl;
        exit(0);
    }
    cout << "No" << endl;
}


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



int main() {
  string s,t;
  cin >> s >> t;
  
  int count = 0;
  rep(i,s.size()){
    if(t.at(i) == s.at(i)){
      count++;
    }
  }
  if(count == s.size()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}


Measured memory_bytes: 3584
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    (1..N).filter { judge(it) && it % 2 != 0 }.count().let(::println)
}

fun judge(n: Int): Boolean {
    return (1..n).filter { n % it == 0 }.count() == 8
}


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

int main() {
  int wsum=0,ksum=0,w[10],k[10];
  for(int i=0;i<10;i++) {
    cin >> w[i];
  }
  for(int i=0;i<10;i++) {
    cin >> k[i];
  }
  sort(w,w+10,greater<int>() );
  sort(k,k+10,greater<int>() );
  for(int i=0;i<3;i++) {
    wsum += w[i];
    ksum += k[i];
  }
  cout << wsum << " " << ksum << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000002


int main(){

	long long N,L,T;
	cin>>N>>L>>T;
	L*=2;
	T*=2;
	vector<long long> ans(N);
	
	vector<long long> X(N),W(N);
	for(int i=0;i<N;i++){
		cin>>X[i]>>W[i];
		X[i]*=2;
		ans[i] = (X[i]+(W[i]==1?T:-T))%L;
		if(ans[i]<0)ans[i]+=L;
	}
	
	sort(ans.begin(),ans.end());
	
	long long cnt = 0LL;
	for(int i=0;i<N;i++){
		if(W[0]==W[i])continue;
		long long x;
		if(W[0]==1){
			x = X[i]-X[0];
		}
		else{
			x = X[0]-X[i];
		}
		if(x<0)x+=L;
		x/=2;
		if(x>=T)continue;
		cnt++;
		cnt += (T-x-1)/(L/2);
	}
	cnt = (N-cnt%N)%N;
	int f = -1;
	long long temp = (X[0]+(W[0]==1?T:-T))%L;
	if(temp<0)temp+=L;
	for(int i=0;i<N;i++){
		if(ans[i]==temp){
			if(W[0]==2)f=i;
			else if(f==-1)f=i;
		}
	}
	if(W[0]==1){
		f += cnt;
		f%=N;
	}
	else{
		f -= cnt;
		if(f<N)f += N;
	}

	
	for(int i=0;i<N;i++){
		cout<<ans[(f+i)%N]/2<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5560
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, long long K, std::vector<long long> H){
  H.insert(H.begin(), 0LL);
  vvl dp(N-K+1, vl(N+1, LINF));
  dp[0][0] = 0;
  rep(k,N-K) rep(i,N+1){
    rep(j,i){
      chmin(dp[k+1][i], dp[k][j]+max(0LL, H[i]-H[j]));
    }
  }
  cout << *min_element(ALL(dp[N-K])) << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
  solve(N, K, std::move(H));
  return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define PTR2(a,j,N,k,L) for(int i = (j); i <= (N);i++) see(a[i],k,L);

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}
template<typename T> void see(T a[],int from,int to){ _rep(i,from,to) cout << a[i]<<" ";cout << endl;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


int main()
{
    int a,b;
    cin >> a >> b;
    string k1,k2;
    _for(i,0,a){
        k1.PB('0'+b);
    }
    _for(i,0,b){
        k2.PB('0' + a);
    }

    cout << min(k1,k2) <<endl;

    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
s = input()
ct = 0
for p in range(1000):
    step = 0
    p = str(p).zfill(3)
    for i in range(n):
        if s[i] == p[0]:
            step += 1
            idx = i
            break
    if step == 1:
        for i in range(idx+1, n):
            if s[i] == p[1]:
                step += 1
                idx = i
                break
    if step == 2:
        for i in range(idx+1, n):
            if s[i] == p[2]:
                #print(p)
                ct += 1
                break
print(ct)

Measured memory_bytes: 42972
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
signed main(){
    fast;
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    int q1 = a/k;
    int q2 = b/k;
    if(q1!=q2)
        cout<<"OK";
    else{
        if(a%k == 0){
            cout<<"OK";
        }
        else cout<<"NG";
    }
}


Measured memory_bytes: 3640
S = input()
T = input()
n = len(S)
m = len(T)

if S.islower() and 0 <= n and n <= 10:
    if T[:-1] == S and m - n == 1 and T[-1].islower():
        print('Yes')
    else:
        print('No')    
else:
    print('No')


Measured memory_bytes: 9108
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using ll = long long;

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;


int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    

    int n;
    cin >> n;
    
    map<int,int> cnt;
    
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        cnt[t]++;
    }
    
    int ret = 0;
    
    for (auto e : cnt)
    {
        if (e.first > e.second) //a > cnt a
        {
            ret += e.second;
        }
        else if (e.first < e.second) //a < cnt a
        {
            ret += e.second-e.first;
        }
    }
    
    cout << ret << endl;
    
    return 0;
    
}




Measured memory_bytes: 4736
h,w =(map(int,input().split()))
if h%2==0:
    if w%2 ==0:
        ans = h*w//2
    else:
        ans = (h*(w-1))//2 + h//2
else:
    if w%2 ==0:
        ans = (w*(h-1))//2 + w//2

    else:
        ans = (h-1)*(w-1)//2 + (w-1)//2+(h-1)//2 +1
if h==1 or w==1:
    ans=1
print(ans)

Measured memory_bytes: 3060
fun main() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    var r = 0
    var g = 0
    var b = 0

    var result = 0L
    var sub = 0L
    for(i in 0 until n){
        when{
            s[i] == 'R' -> r++
            s[i] == 'G' -> g++
            s[i] == 'B' -> b++
        }
    }
    result = r * g * b.toLong()

    for(i in 0 until n){
        for(j in i + 1 until n){
            if(s[i] != s[j] && 2 * j - i < n){
                if(s[i] != s[2 * j - i] && s[j] != s[2 * j - i]) sub++;
            }
        }
    }

    println(result - sub)
}


Measured memory_bytes: 36044
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n,m;
    long long h[100000];
    cin>>n>>m;
    fori(n){
        cin>>h[i];
    }
    bool r[100000];
    fori(n){
        r[i]=true;
    }

    
    fori(m){
        int a,b;
        int hoge,huga;
        cin>>hoge>>huga;
        a=min(hoge,huga)-1;
        b=max(hoge,huga)-1;
        if(h[a]>=h[b]){
            r[b]=false;
        }
        if(h[b]>=h[a]){
            r[a]=false;
        }
    }

    int answer=0;
    fori(n){
        if(r[i]){
            ++answer;
        }
    }
    cout<<answer;
}

Measured memory_bytes: 4512
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  string S;
  cin>>S;
  string ans="";
  string d = "dream";
  string dr = "dreamer";
  string e = "erase";
  string er = "eraser";
  
  int L=S.length()-1;
  
  urep(i,L,-1){
    if(i>8){
   //   cout<<S[i]<<" "; 
      if(S[i]=='m'){
        i=i-5;
        ans=d+ans;
      }else if(S[i]=='e'){
        i=i-5;
        ans=e+ans;
      }else if(S[i-2]=='m'){
        i=i-7;
        ans=dr+ans;
      }else{
        i=i-6;
        ans=er+ans;
      }
    }else{
 //     cout<<" "<<i<<" ";
      if(i==4&&S[0]=='d'){
        ans=d+ans;
      }else if(i==4&&S[0]=='e'){
        ans=e+ans;
      }else if(i==5){
        ans=er+ans;
      }else{
        ans=dr+ans;
      }
      i=-1;
    }
    if(S==ans||i==-1){
      break;
    }
    i++;
  }
  if(S==ans){
    cout<<"YES";
  }else{
    cout<<"NO";
  }

//  cout<<ans;

}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("03")
#pragma GCC optimize ("unroll-loops")
#define ll long long
#define ms(a,b) memset(a,b,sizeof(a))
#define endl '\n'
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mpp(a,b,c) make_pair(a,make_pair(b,c))
#define fi first
#define se second
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repp(a,b,c) for(int a=b;a>=c;a--)

int main(){
/////////////////////////////////////////////
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
/////////////////////////////////////////////
	ll a,b;
	cin >> a >> b;
	if(a <10 && b<10)cout << a*b << endl;
	else cout << "-1" << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define M 1000000007
using namespace std;
int main(){
    
    ll n,m,x;
    cin>>n>>m;
    ll a[n+1]={0};
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
//    for(int i:dp) cout<<i<<" ";
    for(int i=0;i<m;i++){
        cin>>x;a[x]=1;
    }
    if(a[1]!=1) dp[1]=1;
    if(a[2]==0) dp[2]=1+dp[1];
    //for(int i:dp) cout<<i<<" ";
    for(int i=3;i<=n;i++){
        if(!a[i]) dp[i]=(dp[i-1]+dp[i-2])%M;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S;
  while (cin >> N >> S) {
    string res = "";
    for (char c : S) {
      int i = c - 'A';
      int j = (i + N) % 26;
      res += char('A' + j);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.array, std.conv, std.numeric, std.stdio, std.string;

void main()
{
    auto m = readln.chomp.split[1].to!int;
    auto a = readln.chomp.split.to!(ulong[]);
    while (a.all!(e => e % 4 == 0))
    {
        a[] /= 2;
        m /= 2;
    }
    stderr.writeln(a);
    assert (a.any!(e => e % 4));
    if (a.any!(e => e % 4 == 0))
    {
        return "0".writeln;
    }
    auto l = reduce!lcm(1UL, a);
    ((m + l/2) / l).writeln;
}
ulong lcm(ulong a, ulong b)
{
    return a / gcd(a, b) * b;
}

Measured memory_bytes: 4420
a = int(input())
l = list(map(int,input().split()))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a


def lcm(a,b):
    return a*b//gcd(a,b)

MOD = 10**9+7
ans = 0
t = 1
for i in l:
    t = lcm(t,i)

for i in l:
    ans +=t//i
print(ans%MOD)


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

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
  int c[3][3];
  int x[3] = {0}, y[3] = {0};
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> c[i][j];
      x[i] += c[i][j];
      y[j] += c[i][j];
    }
  }

  bool correct = true;
  for(int i = 0; i < 3; i++) {
    if((x[i]-x[(i+1)%3])%3 != 0) correct = false;
    if((y[i]-y[(i+1)%3])%3 != 0) correct = false;
  }

  if(correct) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}  


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;


int main(){
	int n;
	float centor, check;
	cin >> n;
	vector<int> x(n), copy_x(n);

	for (int i = 0; i < n; i++) {
		cin >> x[i];
		copy_x[i] = x[i];
	}
	sort(x.begin(),x.end());
	centor = (x[n / 2 - 1] + x[n / 2]) / 2.0;
	for (int i = 0; i < n; i++) {
		check = (float)copy_x[i];
		if (centor > check) {
			cout << x[n / 2] << endl;
		}
		else {
			cout << x[n / 2 - 1] << endl;
		}

	}
	return 0;
}

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

int main(){
  ll N;cin >> N;
  ll sum = 0;
  for(ll i=1;i<=N;i++){
    ll j = N / i;
    sum += j*(j+1)/2*i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
from bisect import bisect_right as bisect


def inpl():
    return list(map(int, input().split()))


N = int(input())
A = inpl()
B = inpl()
C = inpl()
A.sort()
B.sort()
C.sort()

BtoC = [0 for i in range(N + 1)]
ci = N - 1
for bi in range(N - 1, -1, -1):
    while ci >= 0 and B[bi] < C[ci]:
        ci -= 1
    # print(bi)
    BtoC[bi] = N - ci - 1 + BtoC[bi + 1]

ans = 0
for ai in range(N):
    while bi < N and B[bi] <= A[ai]:
        bi += 1
    ans += BtoC[bi]

print(ans)


Measured memory_bytes: 24052
import sys
import math
import heapq
from collections import defaultdict, deque
from decimal import *
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''D Anything Goes to zero'''
twoPowM1=[0]*(300000)
twoPowM2=[0]*(300000)
stepsSmall=[0]*(300000)

n=r()
s=input()
bitcount=0
for i in range(n):
    if s[i]=='1':
        bitcount+=1

mod=bitcount-1
if mod>0:
    twoPowM1[0]=1
    for i in range(1,len(twoPowM1)):
        twoPowM1[i]=(twoPowM1[i-1]+twoPowM1[i-1])%mod

mod=bitcount+1
twoPowM2[0]=1
for i in range(1,len(twoPowM2)):
    twoPowM2[i]=(twoPowM2[i-1]+twoPowM2[i-1])%mod

for i in range(1,len(stepsSmall)):
    stepsSmall[i]=1+stepsSmall[i%bin(i).count('1')]

valM1=0;valM2=0
for i in range(n):
    mod=bitcount-1
    if mod>0:
        valM1=((valM1*2)%mod+int(s[i]))%mod
    mod=bitcount+1
    valM2=((valM2*2)%mod+int(s[i]))%mod

for i in range(n):
    pow=n-1-i
    if s[i]=='0':
        mod=bitcount+1
        newVal=(valM2+twoPowM2[pow])%mod
        print(stepsSmall[newVal]+1)
    else:
        mod=bitcount-1
        if mod==0:
            print(0)
        else:
            newVal=(valM1-twoPowM1[pow])%mod
            print(stepsSmall[newVal]+1)

Measured memory_bytes: 103920