akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i, M) cin >> B[i];
  int ans = 0;
  rep(i, N) {
    vector<int> A(M);
    rep(j, M) cin >> A[j];
    int sum = C;
    rep(j, M) sum += A[j] * B[j];
    if (sum > 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;

  for(ll i = 0;i < k; i++) {
    if(s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }

  cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int s,s1,s2,s3; cin>>s;
    int ans=0;
    vector <int> a(3);
    a[0]=s%10;
    s=s/10;
    a[1]=s%10;
    s=s/10;
    a[2]=s%10;
    for(int i=0;i<=2;i++){

        if(a[i]==1){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF (4 * 1e18)

int main(){
    cin.sync_with_stdio(false);
    int n, kk;
    cin >> n >> kk;
    P p[n];
    rep(i, n) cin >> p[i].fi >> p[i].se;
    ll ans = INF;
    rep(i, n)repl(j, i, n)repl(k, j, n)repl(l, k, n) {
        ll maxx = max(p[i].fi, max(p[j].fi, max(p[k].fi, p[l].fi)));
        ll minx = min(p[i].fi, min(p[j].fi, min(p[k].fi, p[l].fi)));
        ll maxy = max(p[i].se, max(p[j].se, max(p[k].se, p[l].se)));
        ll miny = min(p[i].se, min(p[j].se, min(p[k].se, p[l].se)));
        int cnt = 0;
        rep(m, n) if (maxx >= p[m].fi && p[m].fi >= minx && maxy >= p[m].se && p[m].se >= miny) cnt++;
        if (cnt >= kk) minch(ans, (maxx - minx) * (maxy - miny));
    }
    cout << ans << endl;
    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;


int N, K;
vector<int> p;


void input() {
    cin >> N >> K;
    p = vector<int>(N);
    rep(i, N) cin >> p[i];
}


int main() {
    input();
    vector<double> w(N);
    rep(i, N) w[i] = double(p[i] * (p[i] + 1)) / (2 * p[i]);
    double ans = 0;
    rep(i, K) ans += w[i];
    double x = ans;
    for (int i = K; i < N; i++) {
        x -= w[i-K];
        x += w[i];
        ans = max(x, ans);        
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		int answer = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			int count = 0;
			int tmp = list.get(i);
			while(tmp % 2 == 0) {
				tmp = tmp / 2;
				count++;
			}
			if(answer >= count) {
				answer = count;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 21332
N, M = map(int, input().split())

if N % 2 == 1:
    for a in range(1, M + 1):
        print(a, N - a + 1)
else:
    for a in range(1, M + 1):
        if a < -(-M // 2) + 1:
            print(a, N - a + 1)
        else:
            print(a, N - a)

Measured memory_bytes: 9216
from collections import deque
 
def solve(h, w, a):
    used = [[True] * (w+2) for _ in range(h+2)]
    que = deque()
    for r in range(h):
        used[r+1][1:-1] = map(lambda _:_=="#", a[r])
        for c in range(w):
            if a[r][c] == "#":
                que.append((r+1, c+1, 0))
    neighbors = [(1,0), (0,1), (-1,0), (0,-1)]
    while que:
        r, c, k = que.popleft()
        for dr, dc in neighbors:
            nr, nc = r+dr, c+dc
            if not used[nr][nc]:
                que.append((nr, nc, k+1))
                used[nr][nc] = True
    return k
 
h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(solve(h, w, a))

Measured memory_bytes: 136960
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <climits>
#include <deque>
#include <map>
#include <deque>
#include <iomanip>
#include <cmath>
#include <functional>
#include <set>
#include <list>
#include <bitset>
#include <stack>
#include <stdio.h>
#define endl '\n'
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
typedef pair<ll,ll> pll;
int main()
{
    /*
for reading from input.txt and writing on output.txt
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
*/
    cin.sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;cin>>n;
    if(n&1)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        n/=2;
        ll ans2=0,ans5=0;
        ll d1=5,d2=2;
        while(n/d1)
        {
            ans5+=n/d1;
            d1=d1*5;
        }
        while(n/d2)
        {
            ans2+=n/d2;
            d2*=2;
        }
        cout<<min(ans2+1,ans5)<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  int a,b,ans=-1;
  cin>>a>>b;
  for(int i=0;i<b*100;i++){
    if(floor(i*0.08)==a and floor(i*0.1)==b){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli a, b, c;
    cin >> a >> b >> c;
    vector<lli> v;
    cout << c << " " << a << " " << b << endl;
}

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

int main(){
  int N; cin >> N;
  long long a[100000];
  for(int i=0; i<N; i++) cin >> a[i];
  
  long long count1=0;
  long long sum1=0;
  for(int i=0; i<N; i++){
    sum1+=a[i];
    if(i%2==0){
      if(sum1<=0){
        count1+=(1-sum1);
        sum1=1;
      }
    }else{
      if(sum1>=0){
        count1+=(sum1+1);
        sum1=-1;
      }
    }
  }
  long long count2=0;
  long long sum2=0;
  for(int i=0; i<N; i++){
    sum2+=a[i];
    if(i%2==1){
      if(sum2<=0){
        count2+=(1-sum2);
        sum2=1;
      }
    }else{
      if(sum2>=0){
        count2+=(sum2+1);
        sum2=-1;
      }
    }
  }
  cout << min(count1,count2) << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ABC045 {
    class Program {
        static void Main(string[] args) {
            int[] steps = new int[3] { 0, 0, 0 };
            string[] str = new string[3];
            for(int i = 0; i < str.Length; i++) {
                str[i] = Console.ReadLine();
            }
            stepUp(str, steps, 0);
        }
        static void stepUp(string[] str,int[] steps,int turn) {
            if (steps[turn] < str[turn].Length) {
                steps[turn]++;
                if (str[turn][steps[turn]-1] == 'a') {
                    stepUp(str, steps, 0);
                }
                else if (str[turn][steps[turn]-1] == 'b') {
                    stepUp(str, steps, 1);
                }
                else {
                    stepUp(str, steps, 2);
                }

            }
            else {
                if (turn == 0) {
                    Console.WriteLine("A");
                }else if (turn == 1) {
                    Console.WriteLine("B");
                }else {
                    Console.WriteLine("C");
                }
            }
        }
        
    
    }
}


Measured memory_bytes: 2648
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

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

int main() {
    int K;
    cin >> K;
    ll sum = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
               sum += gcd(gcd(a, b), c);
            }
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(long i = (long)(init); i < (long)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    long N, K; 
    cin>>N>>K;
    vl A(N), Num(N, __INT_MAX__);
    vector<bool> Town(N, false);
    REP(i, 0, N){
        long to;
        cin >> to;
        to--;
        A[i] = to;
    }
    long cur = 0;
    long count = 0;
    while(!Town[cur]){
        if(count>=K){
            cout << cur+1 << endl;
            return 0;
        }
        Num[cur] = count;
        Town[cur] = true;
        count++;
        cur = A[cur];
    }
    long freq = count - Num[cur];
    long rest = (K - Num[cur]) % freq;
    REP(i, 0, rest){
        cur = A[cur];
    }
    cur++;
    cout << cur << endl;   
}

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

using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
typedef pair< ll, ll > lpair;

void solve()
{
    ll x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    ll t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3644
#include<string>
#include<iostream>

using namespace std;

int main(){
	char *key[]={"","',.!?","abcABC","defDEF","ghiGHI","jklJKL","mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"};
	int len[]={0,5,6,6,6,6,6,8,6,8};

	for(string s;cin>>s;){
		int n=s.length();
		int bef=-1,cons=0;
		for(int i=0;i<n;i++){
			int token=s[i]-'0';
			if(bef==token)	cons++;
			else{
				if(cons>0){
					if(bef!=0)	cout<<key[bef][(cons-1)%len[bef]];
					else		for(int i=1;i<cons;i++)	cout<<' ';
				}
				cons=1;
			}
			bef=token;
		}
		if(cons>0){
			if(bef!=0)	cout<<key[bef][(cons-1)%len[bef]];
			else		for(int i=1;i<cons;i++)	cout<<' ';
		}
		cout<<endl;
	}

	return 0;
}

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

int main(){
    long long n;
    cin >> n;
    long long ans = n;
    for (long long i = 1; i * i <= n; i++){
        if (n % i == 0){
            ans = min(ans, i + n / i - 2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
    int a;
    string b;
    cin >> a >> b;
    int count=0;
    for(int i=0;i<a;i++){
        if(b[i]=='A'){
            if(b[i+1]=='B'){
                if(b[i+2]=='C'){
                    count++; 
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
nm = gets.to_i
print array[nm -1]

Measured memory_bytes: 1788
#include <stdio.h>
main(){
  int s,a=0,b=0,ab=0,o=0;
  char blood[3];
  while(scanf("%d,%s",&s,blood) !=EOF){
    if(blood[0]=='A'&&blood[1]=='B') ab++;
    else if(blood[0]=='B') b++;
    else if(blood[0]=='A') a++;
    else if(blood[0]=='O') o++;
  }

  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0; 
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
  
#define INF 100005
#define NIL -1
  
struct Node{int parent,left,right;};
Node T[INF];
int n,D[INF];
  
void print(int u){
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "depth = " << D[u] << ", ";
  
  if(T[u].parent==NIL) cout << "root, ";
  else if(T[u].left == NIL) cout << "leaf, ";
  else cout << "internal node, ";
  
  cout << "[";
  for(i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}
  
void rec(int u,int p){
  D[u] = p;
  if(T[u].right != NIL) rec(T[u].right,p);
  if(T[u].left != NIL) rec(T[u].left,p+1);  
}
  
int main(void){
  int i,j,d,v,c,left,right;
  
  cin >> n;
  for(i=0;i<n;i++) T[i].parent = T[i].left = T[i].right = NIL;
  
  for(i=0;i<n;i++){
    cin >> v >> d;
    for(j=0;j<d;j++){
      cin >> c;
      if(j==0) T[v].left = c;
      else T[left].right = c;
      left = c;
      T[c].parent = v;
    }
  }
  
  for(i=0;i<n;i++) if(T[i].parent==NIL) right = i;
  rec(right,0);
  
  for(i=0;i<n;i++) print(i);
}

Measured memory_bytes: 7756
n = int(input())
lst = [int(i) for i in input().split()]
dic = {}
for i in range(n):
  if lst[i] not in dic:
    dic[lst[i]] = [1, 0, 0]
  else:
    dic[lst[i]][0] += 1
    dic[lst[i]][1] = dic[lst[i]][0] * (dic[lst[i]][0] - 1) // 2
    dic[lst[i]][2] = (dic[lst[i]][0] - 1) * (dic[lst[i]][0] - 2) // 2
#print(dic)
count = 0
for value in dic.values():
  count += value[1]
for i in range(n):
  m = lst[i]
  count -= dic[m][1]
  count += dic[m][2]
  print(count)
  count += dic[m][1]
  count -= dic[m][2]

Measured memory_bytes: 35624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  double u,s;
  cin>>N;
  if(N%2==0){
    s=N/2;
    cout<<s/N<<endl;
  }
  else {
    u=(N-1)/2;
    cout<<(u+1)/N<<endl;
  }
}

Measured memory_bytes: 3744
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		while(true){
			int n = si();
			if(n==-1) break;

			String ans = "";
			do{
				ans = n%4 + ans;
				n/=4;
			}while(n!=0);
			out.println(ans);
		}
		out.flush();
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
char n;
int a,b;
int main(){
    cin>>a>>b;
    for(int i=0;i<a;i++){
        cin>>n;
        if(n<'0'||n>'9'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cin>>n;
    if(n!='-'){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<b;i++){
        cin>>n;
        if(n<'0'||n>'9'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

ll N, K;

ll solve() {
    vector<ll> A (N + 1, 0);
    ll ans = 0;
    for (size_t i = 1; i < N + 1; i++) A.at(i) = A.at(i - 1) + i;
    for (size_t i = K; i < N + 1; i++) {
        ans += A.at(N) - A.at(N - i) - A.at(i - 1) + 1;
        ans %= MOD;
    }
    ans += 1;
    ans %= MOD;
    return ans;
}

int main(){
    cin >> N >> K;
    cout << solve() << endl;
    return 0;
}


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


int main(){
    ll N;
    cin >> N;
    vector<ll> B(N);
    for(int i=0;i<N;i++){
        cin >> B[i];
        if(B[i]>i+1){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<bool> alreadyUsed(N,false);
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=0;--j){
            if(alreadyUsed[j]){
                continue;
            }
            if(B[j] <= i+1){
                int num=0;
                for(int k=0;k<j;k++){
                    if(alreadyUsed[k]){
                        num++;
                    }
                }
                if(num>=B[j]-1){
                    cout << B[j] << endl;
                alreadyUsed[j] = true;
                break;
                }
                
            }
        }
    }
    
    // Failed to predict input format
    return 0;
}


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

/*typedefs*/
typedef vector<int> vi;
typedef map<string,int> msi;
typedef complex<double> point;
typedef  long long ll;


#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}


unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
ll  OO = 10e12;
const int MAXN = 10e4;
static int arr[MAXN];
int sm = 0;
int x;
int main() {
    IOS();
    int h,n;
    cin>>h>>n;
    REP(i,n)
    {
        cin>>x;
        sm+=x;
    }

    if(sm>=h) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int n,k;
    cin>>n>>k;
    vint p(n);
    for (size_t i = 0; i < n; i++)
    {
        cin>>p[i];
    }
    sort(all(p));
    int ans=0;
    for (size_t i = 0; i < k; i++)
    {
        ans += p[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;

typedef double ld;
const ld eps = 1e-8;

char d[1000];
int a[1000];

int tmp = 0;
bool chked[1000][1000];
int ids[1000][1000];

bool used[3000][1001];
int memo[3000][1001];

int noma[1000][1000];
int chk[1000][1000];
int yemi[1000][1000];

int dfs(int l, int r,int x) {
	if (l > r)return 0;
	if (!chked[l][r]) {
		ids[l][r] = tmp; tmp++;
		chked[l][r] = true;
	}
	int id = ids[l][r];
	if (used[id][x])return memo[id][x];
	used[id][x] = true;
	int res;
	if (noma[l][r] < 0) {
		if (x < yemi[l][r]) {
			res= 0;
		}
		else {
			res= 1;
		}
	}
	else {
		int mid = chk[l][r];
		int vl = dfs(l, mid - 1, x) + dfs(mid + 1, r, x);
		int vr = 1 + dfs(l, mid - 1, noma[l][r]) + dfs(mid + 1, r, noma[l][r]);
		res = min(vl, vr);
	}
	return memo[id][x] = res;
}

void solve() {
	int n; cin >> n;
	rep(i, n) {
		cin >> d[i] >> a[i];
	}
	rep(i, n) {
		int ma = -1;
		int mi = mod; int id = -1;
		Rep(j, i, n) {
			if (d[j] == 'n') {
				if (ma < a[j]) {
					ma = a[j]; id = j;
				}
			}
			else {
				mi = min(mi, a[j]);
			}
			noma[i][j] = ma;
			chk[i][j] = id;
			yemi[i][j] = mi;
		}
	}
	cout << dfs(0, n-1, 1000) << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(1);
	solve();
	//stop
		return 0;
}



Measured memory_bytes: 24704
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int N=0,S=0,E=0,W=0;
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='N') {
      N=1;
    }
    else if(s[i]=='S') {
      S=1;
    }
    else if(s[i]=='E') {
      E=1;
    }
    else {
      W=1;
    }
  }
  if(N==S&&E==W) {
    cout << "Yes" << endl;
  }
  else {
    cout <<"No" << endl;
  }
}

Measured memory_bytes: 256
/*input
ABCACCBABCBCAABCB
*/
#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 int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

string s;
int n;

void solve(){
    cin >> s;
    n = s.size();
    s = "&"+s;
    int bc = 0;
    int ans = 0;
    for(int i = n;i > 0;i--){
      //cout << bc << endl;
      if(s[i] == 'A')ans += bc;
      else{
        if(s[i] == 'C' and s[i-1] == 'B')bc++;
        else if(i < n and s[i] == 'B' and s[i+1] == 'C')continue;
        else bc = 0;
      }
    }
    cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

int main() {
  int A, B; cin >> A >> B;
  for(int i = 0; i <= 100000; i++) {
    if(int(double(i)*0.08) == A && int(double(i)*0.10) == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 2000;
const int L_MAX = 3001;

int main(){
    int N;
    int L[MAX];
    int cntL[L_MAX] = {0};
    int cntR[L_MAX] = {0};
    long long ans = 0;

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

    sort(L,L + N);

    int l = 0;
    int r = N - 1;
    for(int i = 0;i < L_MAX;i++){
        while(l < N && L[l] < i)l++;
        while(r > 0 && L[r] > L_MAX - i - 1)r--;
        cntL[i] = l;
        cntR[L_MAX - i - 1] = N - r - 1;
    }

    for(int i = 0;i < N;i++){
        for(int j = i + 1;j < N;j++){
            int a = min(L[i],L[j]);
            int b = max(L[i],L[j]);
            ans += max(0,N - cntL[b - a + 1] - cntR[a + b - 1] - 1);

            if(a > b - a)ans--;
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int64_t MOD = 1000000007;

// 繰り返し二乗法
int64_t power(int64_t a, int64_t n) {
    int64_t res = 1;
    while (n > 0) {
        if (n % 2 == 1) {
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n >>= 1;
    }

    return res;
}

// 逆元
int64_t inv(int64_t a) {
    return power(a, MOD - 2);
}

// 組み合わせ
int64_t nCr(int64_t n, int64_t r){
    int64_t X = 1, Y = 1;

    for (int i = 0; i < r; i++) {
        X = X * (r - i) % MOD;
        Y = Y * (n - i) % MOD;
    }

    return Y * inv(X) % MOD;
}

int main() {
    int64_t N, A, B;
    cin >> N >> A >> B;

    int64_t ans = power(2, N) - nCr(N, A) - nCr(N, B) - 1;
    while(ans < 0) {
        ans += MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

#define X real()
#define Y imag()
typedef double D;
typedef complex<double>P;
#define EPS (1e-9)

bool iscross(P &p1, P &p2, P &p3, P &p4){
    P d1 = p2 - p1, d2 = p4 - p3;
    D det = d2.X * d1.Y - d1.X * d2.Y;
    if(abs(det) < EPS) return false;
    return true;
}

int main(){
    int n;
    cin >> n;
    REP(i,n){
        double x1, y1, x2, y2, x3, y3, x4, y4;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        P p1(x1,y1), p2(x2,y2), p3(x3,y3), p4(x4,y4);
        if(!iscross(p1,p2,p3,p4)){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = (0 until N).map { readLine()!!.toInt() }

    val set = mutableSetOf<Int>()
    A.forEach { a ->
        if (a in set) set.remove(a)
        else set.add(a)
    }

    println(A.toSet().filter { it in set }.size)
}

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

int main(){
    int n,q;
    cin>>n>>q;
    queue<pair<string,int> > Q;
    string name;
    int time;
    for(int i=0;i<n;i++){
        cin>>name>>time;
        Q.push(make_pair(name,time));
    }
    pair<string,int> u;
    int k,sumtime=0;
    while(!Q.empty()){
        u=Q.front();Q.pop();
        k=min(u.second,q);
        sumtime+=k;
        u.second-=k;
        if(u.second>0)Q.push(u);
        else{
            cout<<u.first<<" "<<sumtime<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6188
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut a: Vec<u32> = (0..n).map(|_| sc.read::<u32>()).collect();
    a.sort();
    let mut ok = false;
    for &x in a.iter() {
        if x % 2 != 0 {
            ok = true;
            break;
        }
    }
    let result = if !ok { "second" } else { "first" };
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int n;
int d[1000];
bool exist[1000001];

int getNum(int l, int r){
	int ret = 0;
	for( int i = l; i <= r; i++ ){
		ret *= 10;
		ret += d[i];
	}
	return ret;
}

int main(){
	int i, j;
	cin >> n;
	for( i = 0; i < n; i++ )
		cin >> d[i];
	
	for( i = 0; i < n; i++ ){
		for( j = i; j < min(n, i + 6); j++ ){
			exist[getNum(i, j)] = true;
		}
	}
	
	for( i = 0; i < n * n; i++ ){
		if( !exist[i] ){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    vector<Pii> v;
    int N, K;

    cin >> N >> K;
    Rep(i, N) {
        v.pb(Pii(0, i));
    }
    Rep(i, N) {
        int a; cin >> a;
        a--;
        v[a].fr++;
    }
    sort(All(v), greater<Pii>());
    int sum = 0;
    int cnt = 0;
    for ( int i = K; i < N; i++ ) {
        sum += v[i].fr;
    }

    cout << sum << endl;
}


Measured memory_bytes: 6384
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        char[] line = sc.next().toCharArray();

        int numOfEOnRightSide = 0;
        int numOfWOnLeftSide = 0;
        int ans = Integer.MAX_VALUE;

        for (int i = 0; i < n; i++) {
            if (line[i] == 'E') {
                numOfEOnRightSide++;
            }
        }

        for (int i = 0; i < n; i++) {
            if (line[i] == 'W'){
                ans = Math.min(numOfWOnLeftSide + numOfEOnRightSide, ans);
                numOfWOnLeftSide++;
            }
            if (line[i] == 'E') {
                numOfEOnRightSide--;
                ans = Math.min(numOfWOnLeftSide + numOfEOnRightSide, ans);
            }

        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 28448
// abc113.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <climits>
#include <iostream>
#include <cstdio>
using namespace std;

double dabs(double a) { return a < 0 ? -a : a; }

int main()
{
	int n,l[11],i,j=0;
	bool f=true;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>l[i];
		j+=l[i];
	}
	for (i=1;i<=n;i++)
	{
		if (l[i]>=j-l[i])
		{
			f=false;
			break;
		}
	}
	if (f)
	{
		cout<<"Yes\n";
	} else {
		cout<<"No\n";
	}
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC"<<endl;
	}else cout<<"ABC"<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int N;
int A[100000];

int res(){
    int K = 0;
    rep(i, N){
        if(A[i]%2 == 0) K++;
    }
    if(K&1) return 1;
    if(K != N-1) return 0;
    int g = A[0]&~1;
    rep(i, N){
        if(A[i] == 1) return 0;
        if(A[i]%2 == 1) A[i]--;
        g = gcd(g, A[i]);
    }
    rep(i, N) A[i] /= g;
    return res()^1;
}

int main(){
    cin >> N;
    rep(i, N) cin >> A[i];
    cout << (res()? "First" : "Second") << endl;
}

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

using namespace std;

#define ll             long long 
#define mod            1000000007
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void initial()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

#define pi   3.14159265358979323846264338327950288419716939937510


int main() 	 	
{
	initial();
	FIO;

	int r;
	cin>>r;

	long double circum = 2*pi*r;

	cout<<fixed<<setprecision(20)<<circum<<endl;
}



Measured memory_bytes: 3804
import heapq
n, m = map(int, input().split())
inf = 10 ** 10
edges = [[] for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    edges[l-1].append((r-1, d))
    edges[r-1].append((l-1, -d))

dist = [inf for _ in range(n)]

def dfs(v):
    stack = [v]
    dist[v] = 0

    while stack:
        v = stack.pop()
        d = dist[v]
        for to, cost in edges[v]:
            if dist[to] != inf:
                if dist[to] != d + cost:
                    return False
            else:
                dist[to] = d + cost
                stack.append(to)

    return True

flg = True
for i in range(n):
    if dist[i] == inf:
        if dfs(i) == False:
            flg = False
            break

print('Yes' if flg else 'No')

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

#define pb push_back
#define pii pair<int,int>
#define f(i,n) for(int i=0;i<n;i++)

using namespace std;


void solve(){
	int n , k;
	 cin >> n >> k;
	 
	 vector<int> v(n);
	 f(i,n){
	 	cin >> v[i];
	 }
	 sort(v.begin(),v.end());
	 
	 int sum=0;
	 int i=0;
	 while(k--){
	 	sum+=v[i];
	 	i++;
	 }
	 cout<<sum;
}

int main() {
	

	    solve();
	    
	return 0;
}


Measured memory_bytes: 3628
n = int(input())
s = input()

left_ws = [0]
for c in s[:-1]:
    plus = 1 if c=='W' else 0
    left_ws.append(left_ws[-1] + plus)

right_es = [sum(1 for c in s[1:] if c=='E')]
for c in s[1:]:
    minus = 1 if c=='E' else 0
    right_es.append(right_es[-1] - minus)

print(min(ws+es for ws, es in zip(left_ws, right_es)))

Measured memory_bytes: 27676
// 参考: https://atcoder.jp/contests/abc166/submissions/12731994
// guitgraphさんありがとうございました。

package main

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

// nextInt でも使用できるように、main関数のスコープ外で定義
var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	// 展望台の数
	n := nextInt()
	// 道の数
	m := nextInt()
	// 標高
	h := make([]int, n)
	// 良い展望台
	good := make([]bool, n)

	// 標高を取得すると共に、とりあえず全部の展望台を「良い展望台」にする
	for i := 0; i < n; i++ {
		h[i] = nextInt()
		good[i] = true
	}

	for i := 0; i < m; i++ {
		ai := nextInt() - 1
		bi := nextInt() - 1
		if h[ai] > h[bi] {
			good[bi] = false
		} else if h[ai] < h[bi] {
			good[ai] = false
		} else {
			good[ai] = false
			good[bi] = false
		}
	}

	var ans int = 0
	// true(良い展望台)の数を数える
	for i := 0; i < n; i++ {
		if good[i] {
			ans++
		}
	}

	fmt.Println(ans)
}

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


Measured memory_bytes: 5512
n,k = [int(x) for x in input().split()]
a = [list(map(int, list(bin(int(x))[2:]))) for x in input().split()]
b = list(map(int, list(bin(k)[2:])))
m = len(b)
for i in a:
    m = max(m,len(i))
for i in range(n):
    for j in range(m-len(a[i])):
        a[i].insert(0,0)
for j in range(m-len(b)):
    b.insert(0,0)
s = [[0,0] for i in range(m)]
for i in a:
    for j in range(m):
        s[j][1-i[j]] += 1
dp = [[0 for i in range(2)] for k in range(m+1)]
dp[0][1] = -float("inf")
f = [1<<(m-i-1) for i in range(m)]
for i in range(m):
    for j in range(2):
        x = 1 if j else b[i]
        for d in range(x+1):
            j_ = j | (d < b[i])
            k = dp[i][j]+f[i]*s[i][d]
            if k > dp[i+1][j_]:
                dp[i+1][j_] = k
print(max(dp[m]))


Measured memory_bytes: 119732
let () = Scanf.scanf "%2d%2d" @@ fun up low ->
  let yymm = 1 <= low && low <= 12 in
  let mmyy = 1 <= up && up <= 12 in
  print_endline @@
  match yymm, mmyy with
  | true, true -> "AMBIGUOUS"
  | false, false -> "NA"
  | true, false -> "YYMM"
  | false, true -> "MMYY"

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <deque>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#define ll              long long
#define PII             pair<int, int>
#define rep(i,a,b)      for(int  i=a;i<=b;i++)
#define dec(i,a,b)      for(int  i=a;i>=b;i--)
using namespace std;
int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846;
const double eps = 1e-6;
const int mod =1e9+7;
const int N = 1e5+5;
//if(x<0 || x>=r || y<0 || y>=c)

inline ll read()
{
	ll x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}
ll gcd(ll m, ll n)
{
	return n == 0 ? m : gcd(n, m % n);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
bool prime(int x) {
    if (x < 2) return false;
    for (int i = 2; i * i <= x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}
ll qpow(ll m, ll k, ll mod)
{
    ll res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % mod;
        t = t * t % mod;
        k >>= 1;
    }
    return res;
}      

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> a(n + 1,vector<int>(3)), dp(n + 1, vector<int>(3));
    rep(i, 1, n)
    { 
        for(int j=0;j<3;j++)
            cin >> a[i][j];
    }
    rep(i, 1, n)
    {
        for (int j = 0; j < 3; j++)
        {
            if (j == 0)
                dp[i][j] = max(dp[i - 1][1] + a[i][j], dp[i - 1][2] + a[i][j]);
            else if(j==1)
                dp[i][j] = max(dp[i - 1][0] + a[i][j], dp[i - 1][2] + a[i][j]);
            else
                dp[i][j] = max(dp[i - 1][0] + a[i][j], dp[i - 1][1] + a[i][j]);
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
    return 0;
}



Measured memory_bytes: 11136
#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_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll a[100010];

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

  cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  ll g=0,sum=0;
  rep(i,n){
    a[i]-=sum;
    sum+=a[i];
    if(a[i]%2==1)g^=n-i;
  }
  if(g==0)cout<<"second"<<endl;
  else cout<<"first"<<endl;

  return 0;
}


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

int main(){

	int H,W ;
	cin >> H >> W;
	
	for(int i = 0;i < (W + 2);i++){
		
		cout << '#';
      
	}
	cout << endl;
	

	for(int i = 0;i < H;i++){
		cout << '#';
		for(int j = 0;j < W;j++){
			char a;
			cin >> a;
			cout << a;
		}
		cout << '#' << endl; 
	}

	for(int i = 0;i <(W + 2);i++){
		cout << '#';
	}
	cout << endl;
}

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

int main() {
  int index;
  cin >> index;
  vector<int> numList = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << numList.at(index - 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MIN(a,b) ((a) < (b) ? (a) : (b))
int main(void){
    char c[1002];
    int fr[2][1000],n,i,j,x,ans,k=0;

    while(scanf("%d",&n)){
        if(n==0)break;
        ans=0;
        for(i=0;i<n;i++){
            scanf("%s",c);
            for(j=0;j<n;j++){
                if(c[j]=='.'){
                    if(i==0 || j==0)fr[!k][j]=1;
                    else {
                        x=MIN(MIN(fr[!k][j-1],fr[k][j]),fr[k][j-1])+1;
                        if(ans<x)ans=x;
                        fr[!k][j]=x;
                    }
                }
                else fr[!k][j]=0;
            }
			k=!k;
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define endl "\n"

#define for0(i, n) for (int i = 0; i < n; i++)
#define loop(i, a, b) for(int i = a;i <= b; i++)
#define forrev(i, n) for(int i = n; i >= 0; i--)
#define test_case(t) int t; cin >> t; while (t--)
#define debug(x) cout<< #x << "=" << x <<"\n";
#define debug(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n";

typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

#define prec(n) fixed<<setprecision(n)
#define inf (int)(1e18)
#define MAX 1000002
#define MOD 1e9 + 7

long long int max(long long int a,long long int b){if(a>b) return a; else return b;}
long long int min(long long int a,long long int b){if(a<b) return a; else return b;}
bool isPrime(int N){
    for(int i=2;i*i<=N;++i){
        if(N%i==0) return false;
    }
    return true;
}

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

    char ch;
    cin>>ch;

    if(isupper(ch))
     cout<<"A"<<endl;

    else 
     cout<<"a"<<endl;
    return 0;
}
//g++ -std=c++17 -Wshadow -Wall -O2 -Wno-unused-result



Measured memory_bytes: 3580