akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n;
  cin >> n;
  ll x=sqrt(n);
  ll ans=INF;
  FOR(i,1,x+1){
    if(n%i==0){
      ans=min(ans,n/i+i);
    }
  }
  cout << ans-2 << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))


def num_of_two(number):
    ans = 0
    while number % 2 == 0:
        ans += 1
        number /= 2
    return ans

ans = 0
for num in a:
    ans += num_of_two(num)
print(ans)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a>b) swap(a,b);
  if (a>c) swap(a,c);
  if (a>d) swap(a,d);
  if (b<c) swap(b,c);
  if (b<d) swap(b,d);
  if (c<d) swap(c,d);
  if (a==1&&b==9&&c==7&&d==4){
    cout << "YES";
  } else {
    cout << "NO";
  }
}

Measured memory_bytes: 256
/**
*    created: 02.08.2020 21:54:44
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int l = 0, r = 1e9;
    while (r - l > 1) {
        int m = (l + r) / 2;
        auto f = [&] (int i) {
            int cnt = 0;
            rep(i,n) cnt += (a[i] - 1) / m;
            return cnt <= k;
        };
        if (f(m)) r = m; else l = m;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4684
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1000000
 
int n, M[MAX][MAX];
 
void dijkstra(){
  int minv=0, i, u=0, v;
  int d[MAX], color[MAX];
 
  for(i=0; i<n; i++){
    d[i] = INF;
    color[i] = WHITE;
  }
 
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INF;
    u = -1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v]!=BLACK && M[u][v]!=INF){
        if(d[v]>d[u]+M[u][v]){
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
  for(i=0; i<n; i++){
    printf("%d %d\n", i, d[i] == INF ? -1 : d[i]);
  }
}
 
int main(){
  int i, j, k=0, c=0, u=0, v=0;
 
  scanf("%d", &n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      M[i][j] = INF;
    }
  }
  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j<k; j++){
      scanf("%d%d", &v, &c);
      M[u][v] = c;
    }
  }
  dijkstra();
 
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];

    int ans=1;
    int j=-1;
    rep(i,n-1){
        if(j==-1){
            if(a[i]<a[i+1]) j=1;
            else if(a[i]>a[i+1]) j=0;
        }
        else{
            if(j==1 && a[i]>a[i+1]){
                ans++;
                j=-1;  
            }
            else if(j==0 && a[i]<a[i+1]){
                ans++;
                j=-1;
            }
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int wei(int a)
{
	int sum = 0;
	while(a){
	sum++;
	a/=10;}
	return sum;
}
int main()
{
	int s;
	cin>>s;
	int k =wei(s);
	int sum = 0;
	int a = 9;
	if(k == 1)
	{
		cout<<s<<endl;
		return 0;
	}
	for(int i=1;i<=k;i+=2)
	{
		int u = pow(10,i-1);
		if(i < k)
			sum+=a;
		else if(i == k)
			sum+=s-u+1;
		a*=100;
	}
	cout<<sum<<endl;
}

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define vi vector<ll> 
#define pii pair<ll, ll>
#define mii map<ll, ll> 
#define mod 1000000007

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    string s;
    cin>>s;
    int l=s.length();
    int cnt=0;
    loop(i,2,l-1){
        if(s[i]=='C') cnt++;
    }
    bool flag=true;
    int c=0;
    for(int i=1;i<=l-1 && flag==true;i++){
            if((s[i]<'a' || s[i]>'z') && s[i]!='C'){
                flag=false;
            }
        }

    if(s[0]=='A' && cnt==1 && flag==true){
        cout<<"AC"<<endl;
    } else {
        cout<<"WA"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s= scan.next();
		scan.close();
		int cnt=0;
		int max=0;
		int check=0;
		char acgt[] = {'A','C','G','T'};
		for(int i=0;i<s.length();i++) {
			for(int j=0;j<4;j++) {
				if(acgt[j]==s.charAt(i)) {
					cnt++;
					check=1;
					break;
				}
			}
			if(check==0||i==s.length()-1) {
				if(max<cnt)max=cnt;
				cnt=0;

			}
			check=0;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int w, h;
int m[50][50];
int visited[50][50] = {0};

void dfs(int x, int y) {
  visited[x][y] = 1;
  for(int i = -1; i <= 1; i++) {
    for(int j = -1; j <= 1; j++) {
      int nx = x + i;
      int ny = y + j;
      if(0 <= nx && nx < h && 0 <= ny && ny < w && visited[nx][ny] == 0 && m[nx][ny] == 1) {
        dfs(nx, ny);
      }
    }
  }
  
}

int main() {
  while(true) {
    rep(i, h) {
      rep(j, w) {
        visited[i][j] = 0;
      }
    }
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    rep(i, h) {
      rep(j, w) {
        cin >> m[i][j];
      }
    }
    int count = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        if(m[i][j] == 1 && visited[i][j] == 0) {
          count++;
          dfs(i, j);
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 10000000
#define mod 1000000007

int n;
string s[22];
bool cov[22];
int len[22][22];
int dp[1<<15][15];

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,n)cin>>s[i];
    vector<string> ss;
    memset(cov,0,sizeof(cov));
    rep(i,n)rep(j,n){
      if(i==j)continue;
      for(int k=0;k+s[j].size()-1<s[i].size();k++){
        if(s[i].substr(k,s[j].size())==s[j])cov[j]=true;
      }
    }
    rep(i,n)if(!cov[i])ss.push_back(s[i]);
    n=ss.size();
    rep(i,n)rep(j,n)len[i][j]=INF;
    rep(i,n)rep(j,n){
      if(i==j)continue;
      len[i][j]=ss[j].size();
      repl(k,1,min(ss[i].size(),ss[j].size())+1){
        if(ss[i].substr(ss[i].size()-k,k)==ss[j].substr(0,k))minch(len[i][j],ss[j].size()-k);
      }
    }
    rep(S,1<<n)rep(i,n)dp[S][i]=INF;
    rep(i,n)dp[1<<i][i]=ss[i].size();
    rep(S,1<<n)rep(i,n){
      if(dp[S][i]==INF)continue;
      rep(j,n){
        if((S>>j)&1)continue;
        minch(dp[S|(1<<j)][j],dp[S][i]+len[i][j]);
      }
    }
    int res=INF;
    rep(i,n)minch(res,dp[(1<<n)-1][i]);
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 4108
import itertools

while True:
  n, k, s = map(int, input().split())
  if n + k + s == 0:
    break

  a = itertools.combinations(range(1, n + 1), k)

  ans = 0

  for e in a:
    if sum(e) != s:
      continue
    ans += 1

  print(ans)  

Measured memory_bytes: 7508
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int a[3][3];
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	int n, x;
	cin >> n;
	for (int k = 0; k < n; ++k) {
		cin >> x;
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				if (x == a[i][j]) {
					a[i][j] = -1;
				}
			}
		}
	}
	bool ans = false;
	auto ok = [&](int y, int x, int dy, int dx) {
		int cnt = 0;
		for (int i = 0; i < 3; ++i) {
			cnt += a[y + dy * i][x + dx * i] < 0;
		}
		return cnt >= 3;
	};
	for (int i = 0; i < 3; ++i) {
		if (ok(0, i, 1, 0)) ans = true;
		if (ok(i, 0, 0, 1)) ans = true;
	}
	if (ok(0, 0, 1, 1)) ans = true;
	if (ok(2, 0, -1, 1)) ans = true;
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


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

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

  // ここにプログラムを追記
  int A=50;
  for (int i=0; i<N; ++i) {
    int x;
    cin >> x;
    int y=0;
    while (x%2 == 0) {
      ++y;
      x /= 2;
    }
    if (y<A) {
      A = y;
    }
  }
  cout << A << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    string s, t;
    cin >> s;
    cin >> t;
    
    int s_size = (int)s.size();
    int t_size = (int)t.size();
    
    bool ch = false;
    
    for(int i = s_size - t_size; i >= 0; i--){
        string cp_s = s;
        for(int j = 0; j < t_size; j++){
            if(s[i + j] == t[j] || s[i + j] == '?'){
                cp_s[i + j] = t[j];
            }else{
                break;
            }
            if(j == t_size - 1){
                ch = true;
            }
        }
        if(ch){
            for(int j = 0; j < s_size; j++){
                if(cp_s[j] == '?'){
                    cp_s[j] = 'a';
                }
            }
            cout << cp_s;
            exit(0);
        }
    }
    cout << "UNRESTORABLE";
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

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

using ll = long long;

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

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

int main() {
    int h, w, d[50][50];
    string f[50];
    cin >> h >> w;
    rep(i, h) cin >> f[i];
    
    queue<int> q;
    q.push(0);
    fill(d[0], d[h], INF);
    d[0][0] = 0;
    while (!q.empty()) {
        int t = q.front();
        int y = t / w;
        int x = t % w;
        q.pop();
        for (int i = 0; i < 4; ++i) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w || f[ny][nx] == '#')
                continue;
            if (chmin(d[ny][nx], d[y][x] + 1))
                q.push(ny * w + nx);
        }
    }

    int y = h - 1, x = w - 1;
    if (d[y][x] == INF) {
        cout << -1 << endl;
        return 0;
    }
    while (1) {
        f[y][x] = '#';
        if (y == 0 && x == 0)
            break;
        for (int i = 0; i < 4; ++i) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w || f[ny][nx] == '#')
                continue;
            if (d[y][x] == d[ny][nx] + 1) {
                y = ny;
                x = nx;
                break;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        ans += count(f[i].begin(), f[i].end(), '.');
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
from collections import deque

X = input()
n = len(X) # even

stack = deque([])

for char in X:
	if char == 'S':
		stack.append(char)
	elif char == 'T' and len(stack) == 0:
		stack.append('T')
	elif char == 'T' and stack[-1] == 'S':
		stack.pop()
	elif char == 'T' and stack[-1] == 'T':
		stack.append('T')

print(len(stack))

Measured memory_bytes: 44256
#include<bits/stdc++.h>
using namespace std;
#define y1 ___y1
const int N=105;
int ne[N],x1[N],T,y1[N],x2[N],y2[N],n,m,fi[N],tot,zz[N],d[N],Flag,flag[N],flag2[N];
struct Tree{
	int ne[N],tot,fi[N],zz[N],fa[N];
	void jb(int x,int y){
		ne[++tot]=fi[x];
		fi[x]=tot;
		zz[tot]=y;
		swap(x,y);
		ne[++tot]=fi[x];
		fi[x]=tot;
		zz[tot]=y;
	}
	void dfs(int x,int y){
		fa[x]=y;
		for (int i=fi[x];i;i=ne[i])
			if (zz[i]!=y)dfs(zz[i],x);
	}
}T1,T2;
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
void dfs(int x){
	flag[x]=1;
	for (int i=fi[x];i;i=ne[i]){
		if (flag[zz[i]]==1)Flag=1;
		if (!flag[zz[i]])dfs(zz[i]);
	}
	flag[x]=2;
}
int main(){
	scanf("%d",&T);
	while (T--){
		scanf("%d",&n);
		memset(T1.fi,0,sizeof T1.fi);
		memset(T2.fi,0,sizeof T2.fi);
		T1.tot=T2.tot=0;
		memset(d,0,sizeof d);
		for (int i=1;i<n;i++)scanf("%d%d",&x1[i],&y1[i]),d[x1[i]]++,d[y1[i]]++;
		for (int i=1;i<n;i++)scanf("%d%d",&x2[i],&y2[i]);
		for (int i=1;i<n;i++)T1.jb(x1[i],y1[i]),T2.jb(x2[i],y2[i]);
		T1.dfs(1,0);T2.dfs(1,0);
		int fflag=0;
		for (int i=1;i<=n;i++)fflag|=T1.fa[i]!=T2.fa[i];
		if (!fflag){
			puts("0");
			continue;
		}
		int ans=1e9;
		for (int i=1;i<=n;i++)
			if (d[i]==1)for (int j=1;j<=n;j++)
				if (j!=i){
					T1.tot=0;
					memset(T1.fi,0,sizeof T1.fi);
					for (int k=1;k<n;k++)
						if (x1[k]!=i&&y1[k]!=i)T1.jb(x1[k],y1[k]);
					T1.jb(i,j);
					memset(fi,0,sizeof fi);
					tot=0;
					memset(flag,0,sizeof flag);
					T1.dfs(i,0);
					T2.dfs(i,0);
					Flag=0;int cnt=0;
					for (int k=1;k<=n;k++)flag2[k]=T1.fa[k]!=T2.fa[k];
					for (int k=1;k<=n;k++)cnt+=flag2[k];
					for (int k=1;k<=n;k++){
						if (!flag2[k]&&flag2[T1.fa[k]])Flag=1;
						if (!flag2[k]&&flag2[T2.fa[k]])Flag=1;
						if (flag2[k]&&flag2[T1.fa[k]])jb(k,T1.fa[k]);
						if (flag2[k]&&flag2[T2.fa[k]])jb(T2.fa[k],k);
					}
					for (int k=1;k<=n;k++)
						if (!flag[k])dfs(k);
					if (!Flag)ans=min(ans,cnt);
				}
		if (ans==1e9)puts("-1");
		else printf("%d\n",ans+1);
	}
	return 0;
}


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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace abc174_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var c = CIn.Read().ToCharArray();

      var l = 0;
      var r = N - 1;

      var ans = 0;

      while (l < r)
      {
        if (c[l] == 'W' && c[r] == 'R')
        {
          ans++;
          l++; r--;
        }

        if (c[l] == 'R') l++;
        if (c[r] == 'W') r--;
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

using namespace std ;

int a , b , c , k ;

signed main() {
	cin >> a >> b >> c >> k ;
	if( a >= k ) return printf( "%d\n" , k ) , 0 ;
	else {
		if( b >= k - a ) printf( "%d\n" , a ) ;
		else printf( "%d\n" , a - ( k - a - b ) ) ; 
	}
	return 0 ;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <string.h>
int main(){
	char a[15], b[15];
	scanf("%s%s", a, b);
	int n = strlen(b);
	if(strncmp(a, b, n-1) == 0) printf("Yes\n");
	else printf("No\n");
	return 0;
} 

Measured memory_bytes: 1708
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;

long long dp[51][51][2501];

int main(){

	int n,a;
	cin>>n>>a;

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

	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<=n*50;k++){
				if(dp[i][j][k]){
					dp[i+1][j][k]+=dp[i][j][k];
					dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
				}
			}
		}
	}

	long long res=0;
	for(int i=1;i<=n;i++) res+=dp[n][i][i*a];
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 48128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stdio.h>
using namespace std;

int main() {
	long double A, B, X;
	cin >> A >> B >> X;
	X /= A;
	long double a, b, c, triangle, ans, Sin;
	if (X > A * B / 2) {
		a = A;
		triangle = A * B - X;
		b = triangle * 2 / a;
		c = sqrt(pow(a, 2) + pow(b, 2));
		Sin = b / c;
		ans = (asin(Sin) * 180) / 3.14159265358979;
	}
	else {
		a = B;
		b = X * 2 / a;
		c = sqrt(pow(a, 2) + pow(b, 2));
		Sin = a / c;
		ans = (asin(Sin) * 180) / 3.14159265358979;
	}
	printf("%.10Lf\n", ans);
 }

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> f(h);
    rep(i,h) cin >> f[i];
    int dp[h+1][w+1];
    const int INF = 1001001001;
    rep(i,h+1) rep(j,w+1) dp[i][j] = INF;
    rep(i,h) {
        rep(j,w) {
            int from_up;
            int from_left;
            if (i-1 < 0) from_up = INF;
            else from_up = dp[i][j+1] + (f[i-1][j] == '.' && f[i][j] == '#');
            if (j-1 < 0) from_left = INF;
            else from_left = dp[i+1][j] + (f[i][j-1] == '.' && f[i][j] == '#');
            if (i == 0 && j == 0) dp[i+1][j+1] = 0;
            else dp[i+1][j+1] = min(from_up, from_left);
        }
    }
    int ans = dp[h][w] + (f[0][0] == '#');
    cout << ans << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{

  ll a, b;
  cin >> a >> b;

  //cout << gcd(a, b) << endl;
  cout << a * b / gcd(a, b) << endl;

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

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

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007;// 1e9 + 7

ll x[100001] = {};
ll y[100001] = {};
int main() {
	ll n, k; cin >> n >> k;
	string s; cin >> s;

	ll p = 0;
	ll Y = 0;
	bool zero = false;
	bool onlyzero = true;
	rep(i, 0, s.size()) {
		if (s[i] == '0' && !zero) {
			x[p] = i;
			y[p] = Y;
			p++;
			Y = 0;
			zero = true;
		}
		else if (s[i] == '1') {
			Y++;
			zero = false;
			onlyzero = false;
		}
	}

	ll maxV = 0;

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

	rep(i, 0, p) {
		ll m = 0;
		if (i + k >= p) {
			m = n - x[i] + y[i];
		}
		else {
			m = x[i + k] - x[i] + y[i];
		}
		maxV = max(maxV, m);
	}

	cout << maxV << endl;

	return 0;
}

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

#define loop(i,a,b) for(int i = a; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
int func(int a,int b){
  return (int)(a*(100.0+b)/100.0);
}
int main(void){
  int a,b,c;
  while(cin>>a>>b>>c,a||b||c){
    int ans=0;
    loop(i,1,1000){
      loop(j,1,1000){
	if(func(i,a)+func(j,a)==c)ans=max(ans,func(i,b)+func(j,b));
      }
    }
    cout<<ans<<endl;
  }
}


  /*int bf,af,bsum;
  while(cin>>bf>>af>>bsum,bf+af+bsum){
    int res = -1;
    double aper = (100.0+af)/100;
    double bper = 100.0/(100+bf);
    loop(i,1,bsum/2 + 3){
      int x = (i + 0.999) * bper , y = (bsum - i + 0.999) * bper;
      //cout<<" "<<yt-(int)yt<<" "<<xt-(int)xt<<endl;
      //cout<<i<<" "<<bsum-i<<" "<<x<<" "<<y<<" "<<res<<endl;
      res = max(res,(int)(x*aper)+(int)(y*aper));
      cout<<res<<" "<<x<<" "<<y<<endl;
    }
    
    cout<<res<<endl;
  }
  
}
  */

Measured memory_bytes: 1160
def mul2():
    n = int(input())
    a = list(map(int, input().split()))
    
    if 0 in a:
        return 0
    ans = 1
    for i in a:
        ans *= i
        if ans > 1000000000000000000:
            return -1
        
    return ans 
print(mul2())

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

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

  for (int i = 0; i < n; i++) {
    for (int j = n-1; j > i; j--) {
      if (A[j] < A[j-1]) {
        int tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        swap++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl << swap << endl;
}



Measured memory_bytes: 3088
n,m=map(int,input().split())
p=10**9+7
n,m=min(n,m),max(n,m)
if m-n>=2:
    print(0)
elif m-n==1:
    ans=1
    for i in range(m):
        ans=ans*(i+1)%p
    for i in range(n):
        ans=ans*(i+1)%p
    print(ans%p)
else:
    ans=1
    for i in range(n):
        ans=ans*(i+1)%p
    print(2*ans*ans%p)



Measured memory_bytes: 63252
#メモ化再帰
N,W = map(int,input().split())
WV = [list(map(int,input().split())) for _ in [0]*N]
memo = [{} for _ in [0]*(N+1)]
def dp(i,j):
    if j<=0 or i<=0: return 0
    if j in memo[i]:return memo[i][j]
    w,v = WV[i-1]
    ret = dp(i-1,j)
    if j-w>=0: ret = max(ret,dp(i-1,j-w)+v)
    memo[i][j] = ret
    return ret
print(dp(N,W))

Measured memory_bytes: 10912
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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



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

ll fac[3*MAX], finv[3*MAX], inv[3*MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 3*MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll path(ll n, ll m) {
	ll ret = 0;
	rep(i, n + 1) {
		ret += COM(m + i + 1, m);
		ret %= MOD;
	}
	return ret;
}


int main() {
	COMinit();

	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	ll ans=(path(r2, c2) - path(r1-1, c2) - path(r2, c1-1) + path(r1-1, c1-1));
	if (ans < 0) { ans += MOD; }
	cout <<ans%MOD;

	


	system("PAUSE");

}


Measured memory_bytes: 70776
def main():
    N, K = map(int, input().split())

    if K&1:
        count = 0
        for i in range(1, N+1):
            if i%K == 0:
                count += 1
        print(pow(count, 3))
    else:
        count = [0, 0]
        k2 = K//2
        for i in range(1, N+1):
            tmp = i%K
            if tmp == 0:
                count[0] += 1
            elif tmp == k2:
                count[1] += 1
        print(pow(count[0], 3) + pow(count[1], 3))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int a, b, i;
	scanf("%d%d", &a, &b);
	if(a<b){
		rep(i,b) printf("%d", a);
	}else if(b<a){
		rep(i,a) printf("%d", b);
	}else{
		rep(i,a) printf("%d", a);
	}
	return 0;
}

Measured memory_bytes: 128
H , W = map(int, raw_input().split())

if H == 1:
    print 1
    exit()
elif W == 1:
    print 1
    exit()


if H%2 == 0:
    print (H/2)*W
elif W%2 == 0:
    print (H/2+1)*(W/2) + (H/2)*(W/2)
else:
    a = (H/2+1)*(W+1)/2
    b = (H/2)*(W/2)
    print  int(a+b)


Measured memory_bytes: 2568
<?php



/**
 * Class fenwickTree
 * Fenwick Tree
 * 長さ NN の配列に対し、
 * 1. 要素の 1 点変更
 * 2. 区間の要素の総和
 * を O(logN) で求めることが出来るデータ構造です。
 */
class FenwickTree
{
    private array $tree;
    private int $max;

    /**
     * fenwickTree constructor.
     * @param int $n <10^8
     */
    function __construct(int $n)
    {
        $this->max = $n;
        $this->tree = array_fill(0,$n,0);
    }

    /**
     * a[p] += x を行う 配列はは"0"スタート
     * @param int $p 挿入位置
     * @param int $x 挿入する数
     */
    public function add(int $p, int $x): void
    {
        assert($p >= 0 && $p < $this->max);
        for($i=$p;$i<$this->max; $i |= ($i + 1)){
            $this->tree[$i] += $x;
        }
    }

    /**
     * a[l] + a[l - 1] + ... + a[r - 1] を返す。
     * @param int $l
     * @param int $r
     * @return int
     */
    public function sum(int $l, int $r): int
    {
        assert($l >= 0 && $l <= $r && $r <= $this->max);
        return $this->sum_from_zero($r) - $this->sum_from_zero($l);
    }

    private function sum_from_zero(int $r): int
    {
//        assert($r >= 0 && $r < $this->max);
        $sum = 0;
        for($i = $r - 1; $i >= 0; $i = ($i & ($i + 1)) -1 ){
            $sum += $this->tree[$i];
        }
        return $sum;
    }

}


//使い方
/*
 * https://atcoder.jp/contests/practice2/tasks/practice2_b
 *
 */
[$N, $Q] = fscanf(STDIN, "%d%d");
$A = fscanf(STDIN, str_repeat("%d", $N));
$ft = new FenwickTree($N);
foreach($A as $key=>$value){
    $ft->add($key, $value);
}
while($Q--){
    $que = fscanf(STDIN, "%d%d%d");
    if($que[0] === 0){
        $ft->add($que[1], $que[2]);
    }else{
        echo $ft->sum($que[1], $que[2]) . PHP_EOL;
    }
}



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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int s, w;
  cin >> s >> w;

  if (w >= s) {
    cout << "unsafe" << endl;

  } else {
    cout << "safe" << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
namespace AOJ {
  public class AOJ {
    public static void Main(string[] args) {
      var n = Console.ReadLine().Split(' ').ToList().Select(int.Parse).ToArray();
      if(0 <= (n[2] - n[4]) && 0 <= (n[3] - n[4]) && n[0] >= (n[2] + n[4]) && n[1] >= (n[3] + n[4]))
        Console.WriteLine("Yes");
      else
        Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 9444
N=int(input())
C=[]
n=[i for i in range(50)]
n[0]=1
for i in range(49):
    n[i+1]+=(n[i]+1)
for i in range(2,int(N**0.5)+1):
    if N%i==0:
        while N%i==0:
            C.append(i)
            N//=i
D=set(C)
E=[]
for d in D:
    E.append(C.count(d))
res=0
for e in E:
    for i in range(50):
            if n[i]<=e<n[i+1]:
                res+=i+1
                break
                
print(res+1 if N>1 else res)

Measured memory_bytes: 9488
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    flg=True
    for k in range(n):
      if k in (i,j):continue
      if a[i][j]>a[i][k]+a[k][j]:
        print(-1)
        exit()
      elif a[i][j]==a[i][k]+a[k][j]:
        flg=False
    if flg:
      ans+=a[i][j]
      #print(i,j)

print(ans)


Measured memory_bytes: 75040
import math


class SegmentTree:
    """
    Segment Tree
    query:
    1. update(i, val): update i-th value to val
    2. query(low, high): find f(value) in [low, high)
    time complexity: O(log n)
    space complexity: O(2n)
    """
    def __init__(self, N, f, default):
        self.N = 1 << math.ceil(math.log(N, 2))
        self.default = default
        self.f = f
        self.segtree = [self.default] * (self.N * 2 - 1)

    def update(self, i, val):
        i += self.N - 1
        self.segtree[i] = val
        while i > 0:
            i = (i - 1) // 2
            self.segtree[i] = self.f(self.segtree[2*i+1], self.segtree[2*i+2])

    def query(self, low, high, k=0, left=0, right=-1):
        if right == -1:
            right = self.N
        if right <= low or high <= left:
            return self.default

        if low <= left and right <= high:
            return self.segtree[k]
        else:
            mid = (left + right) // 2
            return self.f(self.query(low, high, 2*k+1, left, mid),
                          self.query(low, high, 2*k+2, mid, right))


N = int(input())
X = [int(x) for x in input().split()]
dp = SegmentTree(N, lambda x, y: max(x, y), 0)
for x, i in sorted((x, i) for i, x in enumerate(X)):
    dp.update(i, dp.query(0, i) + x)
print(N * (N + 1) // 2 - dp.query(0, N))

Measured memory_bytes: 27952
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
// other libs

signed main(int argc, char* argv[]) {
	int a, b;
	cin >> a >> b;
	if(b==1)cout<<0<<endl;
	else cout << (b - 2) / (a - 1) + 1 << endl;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
ac = [0]*(N+1)
wa = 0
for i in range(M):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        if ac[p] != -1:
            wa += ac[p]
            ac[p] = -1
    else:
        if ac[p] != -1:
            ac[p] += 1
print(ac.count(-1),wa)

Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 	
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }



int n,m,h[N];
vi v[N];
   
 void solve() {
	 cin>>n>>m;
	 rep(i,0,n) cin>>h[i];
	 rep(i,0,m) {
		    int x,y;
		    cin>>x>>y;
		    x--;y--;
		    v[x].pb(y);
		    v[y].pb(x);	 
		 }
		 int ct=0;
	 rep(i,0,n) {
		    if(sz(v[i])==0) {
				   ct++;
				}
			else {
				   int maxi=0;
				   for(auto to:v[i]) {
					     maxi=max(maxi,h[to]);
					   }
					   if(h[i]>maxi) ct++;
				}	
		 }
		 
		 cout<<ct<<endl;
	 	 	 
         
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


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

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long X){
    if(X == 101) {
        cout<<1<<endl; return;
    }
    ll t=1;
    ll money = 100;
    for(; t<4000; t++){
        money = money * 1.01;
        if(money >= X) {
            cout<<t<<endl; return;
        }
    }
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3260
#include <stdio.h>

int main(void)
{

    int i_inputTax8Price;
    int i_inputTax10Price;

    scanf("%d%d", &i_inputTax8Price, &i_inputTax10Price);

    int i_productPriceMinFromA = i_inputTax8Price * 12.5;
    int i_productPriceMaxFromA = (i_inputTax8Price + 1) * 12.5;
    if (i_inputTax8Price % 2 != 0)
    {
        i_productPriceMinFromA++;
    }
    if (i_inputTax8Price % 2 == 0)
    {
        i_productPriceMaxFromA++;
    }
    int i_productPriceMinFromB = i_inputTax10Price * 10;
    int i_productPriceMaxFromB = (i_inputTax10Price + 1) * 10;

    if (i_productPriceMinFromA >= i_productPriceMinFromB && i_productPriceMinFromA < i_productPriceMaxFromB)
    {
        printf("%d", i_productPriceMinFromA);
    }
    else if (i_productPriceMinFromB >= i_productPriceMinFromA && i_productPriceMinFromB < i_productPriceMaxFromA)
    {
        printf("%d", i_productPriceMinFromB);
    }
    else
    {
        printf("-1");
    }

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N;
vector<vector<pair<int,int>>> G;
vector<int> color;
vector<pair<int,int>> ab;
ll maxc;
/*------------------------------------/
for library*/

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

void dfs(int i, int pre, ll pre_c){
    if(pre == -1){
        int cnt = 1;
        for(auto ni: G[i]){
            color[ni.second] = cnt;
            dfs(ni.first, i, cnt);
            cnt++;
        }
    }
    else{
        int cnt = 1;
        for(auto ni: G[i]){
            if(ni.first == pre)continue;
            if(cnt == pre_c){
                cnt++;
            }
            color[ni.second] = cnt;
            //color[ni.second] = (pre_c == maxc) ? pre_c-1:pre_c + 1;
            dfs(ni.first, i, color[ni.second]);
            cnt++;
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin>>N;
    G.resize(N);
    color.resize(N-1);
    rep(i,N-1){
        int a,b; cin>>a>>b;
        a--;b--;
        G[a].push_back({b,i});
        G[b].push_back({a,i});
    }
    maxc = 0;
    int start = 0;
    rep(i,N){
        if(maxc < (ll)G[i].size()){
            chmax(maxc, (ll)G[i].size());
            start = i;
        }
    }
    cout<<maxc<<endl;
    //printpair(ab);
    dfs(start, -1, -1);
    rep(i,N-1){
        cout<<color[i]<<endl;
    }
}

Measured memory_bytes: 7424
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int A,B,C;
int main(){
	scanf("%d%d%d",&A,&B,&C);
	if(A%2!=0||B%2!=0||C%2!=0){
		cout<<"0";
		return 0;
	}
	int t=0;
	while(1){
		t++;
		if(t>100000000){
			printf("-1");
			break;
		}
		int a=(B>>1)+(C>>1),b=(A>>1)+(C>>1),c=(A>>1)+(B>>1);
		if((a&1)||(b&1)||(c&1)){
			printf("%d",t);
			break;
		}
		A=a;B=b;C=c;
	}
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <queue>
#include <cstring>

#define PRINTF(...) 

int r, c;
int senbei[10][10000];

static inline int reverses(int case_bits, int row_idx) {
    return (case_bits >> row_idx) & 1;
}

int solve() {
    int max = 0;
    int end = 2 << r;
    // all row reverse cases; 0 -> 2^r
    for (int p = 0; p < end; p++) {
        // reverse and count
        int count = 0;
        for (int x = 0; x < c; x++) {
            int count_row = 0;
            for (int y = 0; y < r; y++) {
                int color2count = reverses(p, y);
                if (senbei[y][x] == color2count) {
                    count_row++;
                }
            }
            count += (count_row > r - count_row) ? count_row : r - count_row;
        }

        if (count > max) {
            max = count;
        }
    }
    return max;
}

int main() {
    while (true) {
        scanf(" %d %d", &r, &c);
        PRINTF("r: %d c: %d\n", r, c);
        if (r == 0 && c == 0)
            break;
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                if (scanf(" %d", &senbei[i][j]) == EOF) 
                    return 0;
            }
        }
        printf("%d\n", solve());
    }
}

Measured memory_bytes: 3136
#include <stdio.h>

int main(){
    int n, b, f, r, v;
    int i, j;
    
    int info[12][10];
    for(i = 0; i < 12;i++)
        for(j = 0; j < 10;j++)
            info[i][j] = 0;
    
    scanf("%d", &n);
    for(i = 0;i < n;i++){
        scanf("%d%d%d%d", &b, &f, &r, &v);
        info[(b-1)*3+(f-1)][r-1] = info[(b-1)*3+(f-1)][r-1] + v;
    }
    
    for(i = 0;i < 12;i++){
        for(j = 0; j < 10; j++){
            printf(" %d", info[i][j]);
        }
        if((i+1) % 3 == 0 && i != 11) printf("\n####################");
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<iomanip>
#include<math.h>

using namespace std;

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

	c = C * 3.1415926535 / 180 ;
	
	cout << fixed << setprecision(8) << a * b * sin(c) * 0.5 << endl;
	cout << fixed << setprecision(8) << a + b + sqrt(a*a + b*b - 2*a*b*cos(c)) << endl;
	cout << fixed << setprecision(8) << b * sin(c) << endl;
	
	return 0;
}

Measured memory_bytes: 1284
x, n = map(int, input().split())

y = list(map(int, input().split()))
i = 1
if x not in y:
    print(x)
else:
    while(True):
        if x-i not in y:
            print(x-i)
            break
        elif x+i not in y:
            print(x+i)
            break
        i += 1


Measured memory_bytes: 9176
#include <stdio.h>
 #include <algorithm>
 using namespace std;
 int main(){ int H,W;
 while(true){ scanf("%d %d",&H,&W);
 if(H == 0 && W == 0) break;
 for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){
 printf("#");
 } 
printf("\n");
 } 
printf("\n");
 }

 } 


Measured memory_bytes: 2584
import Control.Applicative

func n x = length [ a | a<-[1..n], b<-[a+1..n], c<-[b+1..n], a+b+c==x ]

main = do
	l <- init . map(map(read::String->Int)) . map words . lines <$> getContents
	let l2 = [ func (t!!0) (t!!1) | t<-l ]
	mapM_ print $ l2

Measured memory_bytes: 4224
#include <stdio.h>
int main()
{

    int n,k,x,y;
    scanf("%d %d %d %d",&n,&k,&x,&y);
    if(n>k)
    {
        printf("%d",k*x+(n-k)*y);
    }
    else
        printf("%d",n*x);
    return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      int ng_num = L.end() - lower_bound(L.begin(), L.end(), L[i] + L[j]);
      ans += (N - 1 - j) - ng_num;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256