akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

typedef long long ll;
int mod=1e9+7;
const int maxn=1e5+10;
char  a[maxn];
priority_queue<int>q;
vector<int>v;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    scanf("%s",a+1);
    int cnt1=0;
    int cnt2=0;

    for(int i=1;i<=n;i++)
    {
        if(a[i]=='L'&&a[i-1]!='L')
        {
            cnt1++;
        }
        else if(a[i]=='R'&&a[i-1]!='R')
        {
            cnt2++;
        }
    }
    if(k>=min(cnt1,cnt2))
    {
        printf("%d\n",n-1);
    }
    else
    {
        printf("%d\n",min(2*k+n-cnt1-cnt2,n-1));
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}



signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int n, t;
  cin>>n>>t;
  vector<Int> h(n);
  cin>>h;

  vector<Int> ans(n);
  ans[0] = t / h[0];
  Int sum = h[0];
  Int t2 = t % h[0];
  Int mx = h[0];
  for(Int i=1;i<n;i++){
    if(mx < h[i]){
      ans[i] = (t - sum) / h[i];
      t2 = (t - sum) % h[i];
      mx = h[i];
    }
    else {
      ans[i] = ans[i-1];
      //pr(i, ans[i], t2, h[i]);
      if(t2 < h[i]) ans[i]--, t2 = mx - (h[i] - t2);
      else t2 -= h[i];
    }
    sum += h[i];
  }
    

  for(Int i=0;i<n;i++) cout<<max(1LL, ans[i]+1)<<endl;    
  
  return 0;
}



Measured memory_bytes: 4428
#include <stdio.h>

main(){
  int i, j, h, w, n;
  double bmi, min, sa, temp;
  int ans;

  while(1){
    scanf("%d", &n);
    if(n==0) break;
    
    ans=1000001;
    min=-1;
    for(j=0;j<n;j++){
      scanf("%d %d %d", &i, &h, &w);
      temp=(double)h/100;
      temp*=temp;
      bmi=w/temp;
      if(22>=bmi) sa=22-bmi;
      else sa=bmi-22;
      if(min>sa || min==-1){
	min=sa;
	ans=i;
      }
      else if(min==sa){
	if(ans>i) ans=i;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  string s;
  long long int n,sum;
  cin>>n>>s;
  vector<int> a;
  vector<long long int> b(3,0);
  rep(i,n){
    (s.at(i)=='R'?a.push_back(0):(s.at(i)=='G'?a.push_back(1):a.push_back(2)));
  }
  rep(i,n)
    b.at(a.at(i))+=1;
  sum=b.at(0)*b.at(1)*b.at(2);
  rep(i,n){
    rep(j,i){
      int k=i+i-j;
      if(k<n){
        if(a.at(i)==a.at(j)) continue;
        if(a.at(i)==a.at(k)) continue;
        if(a.at(j)==a.at(k)) continue;
        sum--;
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r << "\n";
    else {
        cout << r + (100 * (10 - n)) << "\n";
    }
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


int B[16][16];

int main2() {
  CLR(B, -1);

  int N = nextInt();
  REP(i, N) {
    int A = nextInt();
    REP(j, A) {
      int x = nextInt() - 1;
      int y = nextInt();
      B[i][x] = y;
    }
  }
  int ans = 0;
  for (int set = 0; set < (1 << N); set++) {
    bool valid = true;
    REP(i, N) if (set >> i & 1) {
      REP(j, N) if (B[i][j] != -1) {
        if ((set >> j & 1) != B[i][j]) {
          valid = false;
        }
      }
    }
    if (valid) {
      chmax(ans, __builtin_popcount(set));
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
  int A, B, C, D;
  string s;
  cin >> s;
  A = s[0] - '0', B = s[1] - '0', C = s[2] - '0', D = s[3] - '0';
  REP(i, 2) REP(j, 2) REP(k, 2) {
    int num = A;
    if (i == 0)
      num += B;
    else
      num -= B;
    if (j == 0)
      num += C;
    else
      num -= C;
    if (k == 0)
      num += D;
    else
      num -= D;
    if (num == 7) {
      cout << A << (i == 0 ? "+" : "-") << B << (j == 0 ? '+' : '-') << C
           << (k == 0 ? '+' : '-') << D << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3560
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    lint r;
    cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef pair<P,P> PP;

struct state{
	ll cst;
	int v,s,d;
	state(){}
	state(int vv,int ss,int dd,ll cc){
		v=vv;
		s=ss;
		d=dd;
		cst=cc;
	}
	bool operator<(const state &st)const{
		return cst>st.cst;
	}
};

int n;
string s[51];
ll dp[51][2][21];
ll c[51];

bool check(int v,int side,int d){
	if(side==0){
		int l=d,r=s[v].size()-1;
		while(l<=r){
			if(s[v][l]!=s[v][r]){
				return false;
			}
			l++;
			r--;
		}
		return true;
	}else{
		int l=0,r=s[v].size()-1-d;
		while(l<=r){
			if(s[v][l]!=s[v][r]){
				return false;
			}
			l++;
			r--;
		}
		return true;
	}
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin >> s[i] >> c[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<=20;k++){
				dp[i][j][k]=1LL<<60;
			}
		}
	}
	dp[n][0][0]=0;
	priority_queue<state> que;
	que.push(state(n,0,0,0));
	ll ans=1LL<<60;
	while(que.size()){
		state st=que.top();
		que.pop();
		if(dp[st.v][st.s][st.d]<st.cst)continue;
		//printf("%d %d %d %lld\n",st.v,st.s,st.d,st.cst);
		if(st.v==n){
			for(int i=0;i<n;i++){
				dp[i][0][0]=c[i];
				que.push(state(i,0,0,c[i]));
				dp[i][1][0]=c[i];
				que.push(state(i,1,0,c[i]));
			}
			continue;
		}
		if(check(st.v,st.s,st.d)){
			ans=min(ans,st.cst);
			continue;
		}
		for(int i=0;i<n;i++){
			if(st.s==0){
				int posl=st.d;
				int posr=s[i].size()-1;
				int cnt=0;
				bool flag=true;
				while(posl!=s[st.v].size() && posr!=-1){
					if(s[st.v][posl]!=s[i][posr]){
						flag=false;
						break;
					}
					cnt++;
					posl++;
					posr--;
				}
				if(flag){
					if(posl==s[st.v].size() && posr==-1){
						//printf("da %lld\n",st.cst+c[i]);
						ans=min(ans,st.cst+c[i]);
					}else if(posl==s[st.v].size()){
						int nv=i;
						int ns=1;
						int nd=cnt;
						ll nc=st.cst+c[i];
						if(dp[nv][ns][nd]>nc){
							dp[nv][ns][nd]=nc;
							que.push(state(nv,ns,nd,nc));
						}
					}else{
						int nv=st.v;
						int ns=0;
						int nd=st.d+cnt;
						ll nc=st.cst+c[i];
						if(dp[nv][ns][nd]>nc){
							dp[nv][ns][nd]=nc;
							que.push(state(nv,ns,nd,nc));
						}
					}
				}
			}else{
				int posl=0;
				int posr=s[st.v].size()-1-st.d;
				int cnt=0;
				bool flag=true;
				while(posl!=s[i].size() && posr!=-1){
					if(s[i][posl]!=s[st.v][posr]){
						flag=false;
						break;
					}
					cnt++;
					posl++;
					posr--;
				}
				if(flag){
					if(posl==s[i].size() && posr==-1){
						//printf("go %lld\n",st.cst+c[i]);
						ans=min(ans,st.cst+c[i]);
					}else if(posl==s[i].size()){
						int nv=st.v;
						int ns=1;
						int nd=cnt+st.d;
						ll nc=st.cst+c[i];
						if(dp[nv][ns][nd]>nc){
							dp[nv][ns][nd]=nc;
							que.push(state(nv,ns,nd,nc));
						}
					}else{
						int nv=i;
						int ns=0;
						int nd=cnt;
						ll nc=st.cst+c[i];
						if(dp[nv][ns][nd]>nc){
							dp[nv][ns][nd]=nc;
							que.push(state(nv,ns,nd,nc));
						}
					}
				}
			}
		}
	}
	if(ans==(1LL<<60)){
		printf("-1\n");
	}else{
		printf("%lld\n",ans);
	}
	return 0;
}


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

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

	long long int whole = 0; //バームクーヘンの大きさ
	int* A = new int[N];
	for (int i = 0; i < N; i++){
		cin >> A[i];
		whole += (long long int)A[i];
	}

	long long int one_third = whole / 3;

	int i = 0;
	long long int piece1 = 0;
	while (piece1 + (long long int)A[i] <= one_third){
		piece1 += (long long int)A[i];
		i++;
		if (i == N) i -= N; //周期的境界条件
	}
	
	int piece2_begin = i;
	long long int piece2 = 0;
	while (1){
		piece2 += (long long int)A[i];
		i++;
		if (i == N) i -= N; //周期的境界条件
		if (piece2 >= piece1) break;
	}
	
	int piece3_begin = i;
	long long int piece3 = whole - piece1 - piece2;
	long long int ans = min(piece1, piece3);

	for (int i = 1; i < N; i++){
		if (piece1 == 0){
			piece2 -= (long long int)A[piece2_begin];
			piece2_begin++;
		}
		else piece1 -= (long long int)A[i-1];

		while (piece1 + (long long int)A[piece2_begin] <= one_third){
			piece1 += (long long int)A[piece2_begin];
			piece2 -= (long long int)A[piece2_begin];
			piece2_begin++;
			if (piece2_begin == N) piece2_begin -= N; //周期的境界条件
		}

		while (piece2 < piece1){
			piece2 += (long long int)A[piece3_begin];
			piece3_begin++;
			if (piece3_begin == N) piece3_begin -= N; //周期的境界条件
		}

		piece3 = whole - piece1 - piece2;
		ans = max(ans, min(piece1, piece3));
	}

	cout << ans << endl;

	delete[] A;
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
int main(){std::string s;while(1){std::getline(std::cin,s);if(s=="END OF INPUT")break;int t=0;for(int i=0;i<s.length();i++)if(s.at(i)==' ')std::cout<<t,t=0;else t++;std::cout<<t<<"\n";}}

Measured memory_bytes: 0
from collections import deque
from math import ceil

H, W, K = map(int, input().split())
A = [input() for _ in range(H)]

# 2回目以降の移動において、すべての部屋は開いていると考えてよい
si, sj = next(
    (i, j)
    for i in range(H)
    for j in range(W)
    if A[i][j] == 'S'
)
q = deque()
q.append((si, sj, 0))
T = {(si, sj)}
while q:
    i, j, d = q.popleft()
    if d < K:
        for x, y in (
                (u, v)
                for u, v in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1))
                if 0 <= u < H and 0 <= v < W and
                A[u][v] == '.' and (u, v) not in T
        ):
            q.append((x, y, d + 1))
            T.add((x, y))
ans = 1 + ceil(
    min(
        min(i, j, H - 1 - i, W - 1 - j)
        for i, j in T
    ) / K
)

print(ans)


Measured memory_bytes: 125272
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include <cmath>
using namespace std;
int N, A;
int main() {    
    cin >> N >> A;
    if(N%500 <= A) cout << "Yes" << endl;
    else cout << "No" << endl;
            
    return 0;
}

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

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 27 10:00:00 2019

@author: Yamazaki Kenichi
"""

A = list(map(str,input().split()))

q=[]
for i in range(len(A)):
    if str.isdecimal(A[i]):
        q.append(int(A[i]))
    elif A[i] == '+':
        q.append(q.pop()+q.pop())
    elif A[i] == '-':
        q.append(-(q.pop()-q.pop()))
    elif A[i] == '*':
        q.append(q.pop()*q.pop())
print(q.pop())



Measured memory_bytes: 5620
// Marcin Knapik
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
  
const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m, k, q;

int tab[N][3];
int dp[N][3];

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

    cin >> n;
    int gen = 0;
    for(int i = 0; i < n; i++){
    	for(int j = 0; j < 3; j++){
    		cin >> tab[i][j];
    		if(i){
    			int maxi = 0;
    			for(int l = 0; l< 3; l++)
    				if(l!=j)
    					maxi = max(maxi, tab[i-1][l]);
    			tab[i][j] += maxi;
    		}
    		setmax(gen, tab[i][j]);
    	}
    }

    cout << gen << '\n';
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>

static const double PI = 3.14159265359;

int main(void)
{
    double r;
    std::cin >> r;
    double area = r * r * PI;
    double circumference = 2 * r * PI;
    std::cout << std::fixed << std::setprecision(6) << area << " " << circumference << std::endl;
    return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

int main(){
  vector<int> A(3);
  rep(i, 3) cin >> A.at(i);
  
  sort(A.begin(), A.end());
  cout << (A.at(2) - A.at(1)) + (A.at(1) - A.at(0)) << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#define INF 1000000000

using namespace std;

//　ABC057

typedef struct
{
    int a, b;
} POINT;

typedef struct
{
    int c, d;
} CHECK;

int dist(POINT p, CHECK q)
{
    return abs(p.a - q.c) + abs(p.b - q.d);
}


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

    POINT p[n+1];
    CHECK q[m+1];

    for(int i = 1; i <= n; i++)
    {
        cin >> p[i].a >> p[i].b;
    }

    for(int i = 1; i <= m; i++)
    {
        cin >> q[i].c >> q[i].d;
    }

    for(int i = 1; i <= n; i++)
    {
        int index;
        int min = INF;
        for(int j = 1; j <= m; j++)
        {
            int d = dist(p[i], q[j]);    
            if(d < min)
            {
                min = d;
                index = j;
            }
        }
        cout << index << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll d,v,t,x;
    sfl(d),sfl(t),sfl(v);
    x = t*v;
    if(x>=d){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3760
import math

n = int(input())
xy = []
for _ in range(n):
    x, y = map(int, input().split())
    xy.append([x, y])

ans = 0
for x1, y1 in xy:
    for x2, y2 in xy:
        ans += math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(ans/n)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

    	String str1 = scan.next();
    	String str2,str3;

    	int flag = 0;

    	for(int cnt = 0; cnt < str1.length() ; cnt++ ){
    		str2 = String.valueOf(str1.charAt(cnt));
    		for(int cnt2 = cnt + 1; cnt2 < str1.length(); cnt2++){
    			str3 = String.valueOf(str1.charAt(cnt2));
    			if(str3.equals(str2)){
    				flag++;
    			}
    			else{
    			}
    		}
    	}
    	if(flag == 0){
    		System.out.println("yes");
    	}
    	else{
    		System.out.println("no");
    	}
}
}

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

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

	if( ( a > 0 && a < 10 ) && ( b > 0 && b < 10 ) )
		result = a*b;
	else
		result = -1;

	cout << result << endl;
}

Measured memory_bytes: 256
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m
let ( -^ ) x y = x +^ (m - y)

let perm n k =
  Array.fold_left ( *^ ) 1 @@
  Array.init k @@ ( +^ ) (n - k + 1)
let comb n k = power ( *^ ) (perm n k) (perm k k) (m - 2)
let repcomb n k = comb (n + k - 1) k

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort compare as_;
  let combs = Array.make (n + 1) 0 in
  (* combs.(i) = comb i (k - 1) *)
  combs.(k - 1) <- 1;
  for i = k - 1 to n - 1 do
    combs.(i + 1) <- combs.(i) *^ (i + 1) *^ power ( *^ ) 1 (i - k + 2) (m - 2)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( +^ ) 0 @@
  Array.init n @@ fun i ->
    (m +^ as_.(i)) *^ (combs.(i) -^ combs.(n - i - 1))



Measured memory_bytes: 6144
import collections

c=input()
c=input()

tmp=collections.Counter(c)

count_r=0
count_w=0
ans=0
dis_r=0

for i in c:
    if dis_r == tmp["R"]:
        break
        
    elif i == "W":
        if count_r<=tmp["R"]:
            ans+=1
            dis_r+=1
        else:
            ans+=1
    else:
        count_r+=1
        dis_r+=1
print(ans)

Measured memory_bytes: 9592
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int N;
ll dp[100000][3];
ll A[100000], B[100000], C[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i] >> C[i];
	}
	dp[0][0] = A[0], dp[0][1] = B[0], dp[0][2] = C[0];
	
	for (int i = 1; i < N; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i];
	}

	ll ans = 0;
	for (int i = 0; i < 3; i++)ans = max(ans, dp[N - 1][i]);

	cout << ans << endl;

	return 0;
}

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

#define all(n) n.begin(),n.end()
#define ll long long

#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll maxn=5e5+2;
const ll maxx=1e16;
const ll mod=1e9+7;
const ll mod1=998244353;
vector<ll> adj[maxn];
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TEAMS.INP","r"))
    {
        freopen("TEAMS.INP", "r", stdin);
        freopen("TEAMS.OUT", "w", stdout);
    }
    ll dd;
     for (int i=1;i<=5;i++)
     {
         cin>>a[i];
         if (a[i]==0) dd=i;
     }
     cout <<dd;
}


Measured memory_bytes: 15380
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	ll N, M;
	cin>>N>>M;
	vector<ll> s(N, 0);
	REP(i, M) {
		ll a, b;
		cin>>a>>b;
		--a;
		--b;
		++s[a];
		++s[b];
	}
	REP(i, N) {
		cout<<s[i]<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(v) cout << #v << ":\t" << v << "\n"

using namespace std;
using namespace __gnu_pbds;

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	ll x, a;
	cin >> x >> a;
	if (x < a) cout << 0;
	else cout << 10;
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;

int N, M, Q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

vector<int> A;
vector<int> ans;

int score(vector<int> &A) {
	int res = 0;

	for (int i = 0; i < Q; i++) {
		if (A[b[i] - 1] - A[a[i] - 1] == c[i]) res += d[i];
	}
	return res;
}

//引数に渡した数以上の数をAの末尾に追加し、AのサイズがNになれば得点を計算してansに格納するdfs
void dfs(int last) {
	if (A.size() == N) {
		ans.push_back(score(A));
		return;
	}

	for (int i = last; i <= M; i++) {
		A.push_back(i);
		dfs(i);
		A.pop_back();
	}
}

int main() {
	cin >> N >> M >> Q;
	a.resize(Q);
	b.resize(Q);
	c.resize(Q);
	d.resize(Q);
	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	dfs(1);
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());

	cout << ans[0] << endl;

}


Measured memory_bytes: 3856
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

int digit(long long n) {
    int res = 0;
    while (n > 0) {
        n /= 10;
        res++;
    }
    return res;
}

int f(long long a, long long b) {
    return max(digit(a), digit(b));
}

void solve() {
    long long N; cin >> N;
    int ans = 100;
    for (long long i = 1; i*i <= N; i++) {
        long long a, b;
        if (N % i == 0) {
            a = i; b = N / i;
            ans = min(ans, f(a, b));
        }
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

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

ll N, M;

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

    ll ans = 0;
    if (2*N > M) {
        ans += M/2;
        N -= M/2;
        M = M % 2;
    }
    else {
        ans += N;
        M -= 2*N;
        N = 0;
    }

    if (M >= 4) {
        ans += M/4;
        M = M % 4;
    }

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


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


int calc(string pass) {
    stack<char> s;
    for (int i = SZ(pass) - 1; i >= 0; --i) {
        if (pass[i] == ']') continue;
        if (pass[i] == '[') {
            char op = s.top();
            s.pop();
            int a = s.top() - '0';
            s.pop();
            int b = s.top() - '0';
            s.pop();
            if (op == '+') a |= b;
            else if (op == '*') a &= b;
            else a ^= b;
            s.push(a + '0');
        }
        else s.push(pass[i]);
    }
    //out(SZ(s));
    int tmp = s.top() - '0';
    return tmp;
}
string make_pass2(string pass, string num) {
    rep(i, SZ(pass)) {
        if ('a' <= pass[i] && pass[i] <= 'd') {
            pass[i] = num[pass[i] - 'a'];
        }
    }
    return pass;
}
int main() {
    string pass;
    while (cin >> pass && pass != ".") {
        string num; cin >> num;
        string pass2 = make_pass2(pass, num);
        int tmp = calc(pass2);
        int ans = 0;
        
        
        rep(i, 10) rep(j, 10) rep(k, 10) rep(l, 10) {
            num = ""; num += i + '0';
            num += j + '0';
            num += k + '0';
            num += l + '0';
            pass2 = make_pass2(pass, num);
            
            if (calc(pass2) == tmp) {
                ans++;
            }
        }
        out(tmp << " " << ans);
    }
}




Measured memory_bytes: 3232
#include<bits/stdc++.h>
#include<string>
#include<cstring>
using namespace std;
int c=0;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C') c=1;
		if(c==1&&s[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0; 
		} 
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) System.out.println(0);
		else System.out.println(Math.min(A * B, Math.min(B * C, C * A)));
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#define N 2000000

int A[N],B[N],C[10000];
 
void countingsort(int n,int k){
  int i;
  
  for(i=0;i<k;i++)
    C[i] = 0;

  for(i=0;i<n;i++)
    C[A[i]]++;

  for(i=1;i<=k;i++)
    C[i] += C[i-1];

  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
    }

  for(i=0;i<n-1;i++)
    printf("%d ",B[i]);
  printf("%d\n",B[i]);
}

int searchbig(int n){
  int i,max=0;
  for(i=0;i<n;i++){
    if(max < A[i])
      max = A[i];
  }
  return max;
}

int main(){
  int i,n;

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

  countingsort(n,searchbig(n));

  return 0;
}


Measured memory_bytes: 17396
#include <stdio.h>
#include <cmath>
#include <vector>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;

int main(void) {
	vector<int> r;
	while (true)
	{
		int n=0,p=0;
		scanf("%d %d",&n,&p);
		if (n==0 && p==0){
			break;
		}
		int wan=p,candidate[50]={0};
		int i=0;
		while (true)
		{
			if (wan > 0){
				wan--;candidate[i]++;
			} else {
				wan+=candidate[i];candidate[i]=0;
			}
			if (candidate[i]==p){break;}
			i++;
			i=i%n;
		}
		r.push_back(i);
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 872
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
/**
 * Author: AcFunction
 * Date:   2019-09-04 21:48:14
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double 

#define fi first
#define se second
#define MP make_pair
#define pii pair <int, int>
#define pil pair <int, ll> 
#define pli pair <ll, int>
#define pll pair <ll, ll>  

#define All(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

#define ms0(x) memset(x, 0, sizeof(x))
#define ms1(x) memset(x, -1, sizeof(x))

#define oiu cerr << "Yes!" << endl; 
#define O(x) cerr << #x << ": " << x << endl;  

template <typename T> void printarr(T a[], int b, int e) {
  if(b > e) return ; 
  for(int i = b; i < e; i++) cout << a[i] << " "; 
  cout << a[e] << " " << endl; 
} 

template <typename T> int chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0; 
}

template <typename T> int chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0; 
}

const int N = 5001000; 

int n;
int nxt[N], fir[N], pos[N], a[N], ans[N], cnt, len[N];
ll k;  

int main() {
  scanf("%d %lld", &n, &k); k *= n; 
  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]); 
    if(!fir[a[i]]) {
      fir[a[i]] = i;
      pos[a[i]] = i;  
    }
    else {
      nxt[pos[a[i]]] = i; 
      pos[a[i]] = i;  
    }
    nxt[i] = fir[a[i]]; 
  }
  for(int i = 1; i <= n; i++) {
    if(nxt[i] > i) {
      len[i] = nxt[i] - i + 1; 
    }
    else len[i] = n - (i - nxt[i] - 1); 
  }
  int u = 1; ll num = 0; 
  while(1) {
    num += len[u]; 
    u = nxt[u] + 1;
    if(u > n) u -= n;  
    if(u == 1) break ; 
  }
  k = k % num; 
  if(!k) return 0; 
  u = 1; num = 0; 
  // k *= n; 
  while(1) {
    num += len[u];
    if(num >= k) {
      num -= len[u]; 
      for(int j = u; j <= u + k - num - 1; j++) {
        int t = j; if(t > n) t -= n; 
        ans[++cnt] = a[t]; 
      } 
      for(int i = 1; i <= cnt; i++) 
        pos[ans[i]] = fir[ans[i]] = nxt[i] = 0; 
      for(int i = 1; i <= cnt; i++) {
        if(!fir[ans[i]]) {
          fir[ans[i]] = i;
          pos[ans[i]] = i;  
        }
        else {
          nxt[pos[ans[i]]] = i;   
          pos[ans[i]] = i;  
        }
        nxt[i] = fir[ans[i]]; 
      }
      int p = 1; 
      while(p <= cnt) {
        if(nxt[p] > p) {
          p = nxt[p] + 1; 
        }
        else {
          printf("%d ", ans[p]); 
          p++; 
        }
      }
      return 0; 
    }
    u = nxt[u] + 1; 
    if(u > n) u -= n; 
  }
  return 0; 
}

/*
7 999
1 6 3 2 4 3 5
 */

Measured memory_bytes: 14592
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll h[100001] = {};
ll k[100001] = {};

ll n, a, b;
//bool holocost(ll t) {
//	rep(i, 0, n) k[i] = h[i] - b * t;
//
//	ll cnt = 0;
//	rep(i, 0, n) {
//		if (h[i] > 0) {
//			cnt += k[i] / (a - b);
//			if (k[i] % (a - b) != 0)cnt++;
//		}
//	}
//	return cnt <= t;
//}

bool condition(ll x) {
	rep(i, 0, n) {
		k[i] = h[i];
	}
	rep(i, 0, n) k[i] -= x * b;
	ll cnt = 0;
	rep(i, 0, n) {
		if (k[i] > 0) {
			ll d = a - b;
			cnt += k[i] / d;
			if (k[i] % d != 0)cnt++;
		}
	}
	return cnt <= x;
}

int main() {
	cin >> n >> a >> b;
	rep(i, 0, n) cin >> h[i];

	ll l = -1;
	ll r = (ll)1 << 30;
	ll m;
	while (r - l > 1) {
		m = (l + r) / 2;
		if (condition(m)) {
			r = m;
		}
		else {
			l = m;
		}
	}
	cout << r << endl;

	return 0;
}

Measured memory_bytes: 1792
k=int(input())
flag=True
seq=7
"""
これは階乗を含むのでO(klogk)で重い
for i in range(1,k+1):
  if (7*(10**i-1)//9) % k==0:
    print(i)
    flag=False
    break
"""
for i in range(1,k+1):
  if seq%k==0:
    print(i)
    flag=False
    break
  seq=(seq*10+7)%k  # %k(modの考え方)がなければ10**6ではO(k)は重すぎた
  
if flag:
  print(-1)

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

int main()
{
  long long S;
  cin >> S;
  long long x;
  long long y;
  x = (1000000000 - S % 1000000000) % 1000000000;
  y = (S + x) / 1000000000;
  cout << 0 << " " << 0 << " "  << 1000000000 <<" "<<1<< " " << x << " " << y << endl;
}

Measured memory_bytes: 256
<?php
$count = intval(fgets(STDIN));
$numbers = explode(" ", trim(fgets(STDIN)));
$output = array();

for ($i = 0; $i < $count; $i++) {
	$output[$i] = $numbers[$count-1-$i];
}

foreach ($output as $key => $value) {
	if ($value !== end($output))
		echo $value." ";
	else
		echo $value;
}
echo "\n";

Measured memory_bytes: 6632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll n,W;
 cin>>n>>W;
 vector<ll> w(n),v(n);
 for(ll i=0;i<n;i++) cin>>w[i]>>v[i];
 ll V=0;
 for(ll i=0;i<n;i++) V+=v[i];
 const ll INF=1e18;
 vector<vector<ll>> dp(n,vector<ll>(V+1,INF));
 dp[n-1][0]=0;
 dp[n-1][v[n-1]]=w[n-1];
 for(ll i=n-2;i>=0;i--){
  for(ll j=0;j<=V;j++){
   if(j>=v[i]) dp[i][j]=min(dp[i+1][j],dp[i+1][j-v[i]]+w[i]);
   else dp[i][j]=dp[i+1][j];
  }
 }
 for(ll i=V;i>=0;i--){
  if(dp[0][i]<=W) {
   cout<<i<<endl;
   return 0;
  }
 }

 return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef array<int, 2> duo;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, k; cin >> n >> k;
        vector<int> h(n); cin >> h;
        vector<bool> good(n, 1);
        while (k--) {
                int a, b; cin >> a >> b;
                a--, b--;
                if (h[a] >= h[b]) good[b] = 0;
                if (h[b] >= h[a]) good[a] = 0;
        }

        cout << accumulate(all(good), 0);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3736
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vll = vector<ll>;

constexpr ll kMod = 1e9 + 7;

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

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();
  ll W, H, N;
  cin >> W >> H >> N;

  vector<vll> box;
  REP(i, 0, W) {
    vll h;
    REP(j, 0, H) {
      h.emplace_back(0);
    }
    box.emplace_back(h);
  }

  vll X, Y, A;
  REP(i, 0, N) {
    ll x, y, a;
    cin >> x >> y >> a;
    X.emplace_back(x);
    Y.emplace_back(y);
    A.emplace_back(a);

    switch (a) {
      case 1: {
        REP(ii, 0, x) {
          REP(jj, 0, H) {
            box[ii][jj] = 1;
          }
        }
        break;
      }
      case 2: {
        REP(ii, x, W) {
          REP(jj, 0, H) {
            box[ii][jj] = 1;
          }
        }
        break;
      }
      case 3: {
        REP(ii, 0, W) {
          REP(jj, 0, y) {
            box[ii][jj] = 1;
          }
        }
        break;
      }
      default: {
        REP(ii, 0, W) {
          REP(jj, y, H) {
            box[ii][jj] = 1;
          }
        }
        break;
      }
    }
  }

  ll result = 0;
  REP(i, 0, W) {
    REP(j, 0, H) {
      if (box[i][j] == 0) {
        result++;
      }
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <chrono>
#include <random>
#include <stack>
#include <ctime>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

int main() {
    llong a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (2 * c < a + b) {
        vector<llong > Ans;
        if (x < y) {
            Ans.push_back(c * x * 2 + (y - x) * b);
        } else {
            Ans.push_back(c * y * 2 + (x - y) * a);
        }
        Ans.push_back(2 * c * max(x, y));

        sort(Ans.begin(), Ans.end());
        cout << Ans[0] << endl;
    } else {
        cout << a * x + b * y << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *H = map(int, read().split())

    ans = []
    c = 0
    for i in range(N - 1):
        if H[i] >= H[i + 1]:
            c += 1
        else:
            ans.append(c)
            c = 0

    ans.append(c)

    print(max(ans))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20396
/* author   : mpily :-()
title : Competing.cpp
time :Sun Sep 29 15:04:20 2019

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	vector<pair<int,int>>arr(N);
	for(int i = 0; i < N; i++){
		cin>>arr[i].first;
		arr[i].second = i;
	}
	sort(arr.begin(),arr.end());
	for(auto & a : arr){
		cout<<a.second+1<<" ";
	}
	cout<<"\n";
	return 0;
}


Measured memory_bytes: 1536
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;
//--------------------

int main() {

	long res = 0;
	long N, A, B; cin >> N >> A >> B;

	res = min(N * A, B);

	cout << res << endl;
}

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

int main() {
  double a,b,h,m;cin >> a >> b >> h >> m;
  printf("%.12lf\n",sqrt(a*a+b*b-2*a*b*cos(2*M_PI*((h+m/60)/12-m/60))));
}


Measured memory_bytes: 4216
class Integer
  def mod_max(a, d)
    g = self.gcd(d)
    self - g + a % g
  end
end

T = gets.to_i

def f(a, b, c, d)
  return false if a < b
  return false if d < b
  return true if c >= b

  b.mod_max(a, d) <= c
end 

T.times do
  a, b, c, d = gets.split.map(&:to_i)

  if f(a, b, c, d)
    puts 'Yes'
  else
    puts 'No'
  end
end


Measured memory_bytes: 1916
<?php
    $n = trim(fgets(STDIN));

    //??????????????¨?????????????????????
    $trump = array_pad(array(),14,0); 
    $trump[0] = 1;
    $trump = ["S" => $trump, "H" => $trump, "C" => $trump, "D" => $trump];
 
    //??????????????????1????????????
    for($i = 0; $i < $n; $i++){
        list($suit, $number) = explode(" ",trim(fgets(STDIN)));
        $trump[$suit][$number]=1;
    }

    //?????£????????????????????????
    foreach($trump as $key1 => $value1){
        foreach($value1 as $key2 => $value2){
            if($value2 == 0){
                echo "$key1 $key2\n";
            }
        }
    }

Measured memory_bytes: 15484
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N, 0);
	for(int i=0; i<N; ++i) cin >> a[i];
	multiset<int> st;
	for(int i=0; i<N; ++i){
	    auto itr=st.lower_bound(a[i]);
	    if(itr==st.begin()){
	        st.insert(a[i]);
	    }else{
	        --itr;
	        auto del=itr;
	        ++del;
	        st.erase(itr, del);
	        st.insert(a[i]);
	    }
	}
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 5376
N,K=map(int,input().split())
S=input()

#K=1
#S="01100"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0

if(LIST[r][1]=="1"):
    s+=LIST[r][0]
    r+=1
x=0
while(K>0 and len(LIST)>r):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        x=1
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        x=1
        break
    r+=1

MAX=max(s,MAX)

f=0
if(x==0):
    while(r<len(LIST)):
        if(l< len(LIST)-1):
            s-=LIST[l][0]
            l+=1
            f=1
        if(l<len(LIST)-1 and LIST[l][1]=="0"):
            s-=LIST[l][0]
            l+=1

        if(f==0):
            break
        

        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break
        
        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break

print(MAX)


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

int main(){
  int K,S; cin >> K >> S;
  
  int num = 0;
  
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      if(S-i-j >= 0 && S-i-j <= K){
        num++;
      }
    }
  }
  
  cout << num << endl;
  
  return 0;
}
  

Measured memory_bytes: 256
#include <stdio.h>
int main(void){    
	int N,M,i,j,A[1000],c,b[1000],max_count=0,max_game;  
	scanf("%d%d",&N,&M);  
	for(i=0;i<N;i++){  
        scanf("%d",&A[i]);          
	b[i]=0;   
}    
 for(i=0;i<M;i++){   
      scanf("%d",&c);   
      for(j=0;j<N;j++){     
        if(A[j]<=c){
	b[j]++;
	break;
}   
} 
}    
   for(i=0;i<N;i++){        
 if(max_count<b[i]){    
         max_count=b[i];     
        max_game=i+1;      
   }    
 }      
 printf("%d\n",max_game);
	return 0;
} 

Measured memory_bytes: 604
//Love and Freedom.
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define inf 20021225
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
	return f*s;
}
int main()
{
	int x=read();
	for(int i=1;i<=360;i++)	if(x*i%360==0)
	{
		printf("%d\n",i); break;
	}
	return 0;
}

Measured memory_bytes: 1584