akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[205];

void solve()
{
    int n;
    scanf("%d", &n);
    vector<ll> a(n);
    int i, j;
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    scanf("%s", str);

    for (i = n-1; i >= 0; i--) {
        if (str[i] == '1') {
            if (a[i]) {
                printf("1\n"); return;
            }
        }
        else {
            for (j = 0; j < i; j++) {
                a[j] = MIN(a[j], a[j] ^ a[i]);
            }
        }
    }
    printf("0\n");
    return;
}


int main(int argc, char* argv[])
{
#if 0
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll red = 0;
    rep(i, 0, n) {
        if(s[i] == 'R') red++;
    }
    ll ans = 0;
    rep(i, 0, red) if(s[i] == 'W') ans++;
    cout << ans << endl;
    return 0;
}

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  string S;
  cin >> S;
  int N = S.size();
  string S1 = S.substr(0,N/2);
  string S2 = S.substr(N/2+1,N/2);
  if(palin(S) && palin(S1) && palin(S2)) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

A, B = map(int, input().split())

if A <= 9 and B <= 9:
    print(A*B)
else:
    print(-1)

Measured memory_bytes: 77536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, N[1000];

void push(int);
int pop(void);

int main(){
  int x,y;
  char n[100];
  top = 0;

  while(scanf("%s", n) != EOF){
    if(n[0] == '+'){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(n[0] == '-'){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if(n[0] == '*'){
      x = pop();
      y = pop();
      push(x * y);
    }
    else{
      push(atoi(n));
    }
  }

  printf("%d\n", pop());

  return 0;
}


void push(int x){
  N[++top] = x;
}

int pop(){
  top--;
  return N[top + 1];
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main() {
  int n;cin>>n;int sum = 0;int l[100];rep(i,n)cin>>l[i];
  rep(i,n){
    sum += l[i];
  }
  rep(i,n){
    if(sum - l[i] <= l[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n;
  cin >> n;
  int sum = 0;
  for (ll i = 1; n / i > 0; i *= 10) {
    sum += (n / i) % 10;
  }
  if (n % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from math import ceil,floor
def tax(a, b):
    mina, maxa = a/0.08, (a+1)/0.08
    minb, maxb = b/0.1, (b+1)/0.1
    if(mina >= maxb or minb >= maxa): return -1

    return max(ceil(mina), ceil(minb))

a, b= map(int, input().strip().split())
print(tax(a, b))

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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

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

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int cys=1000000007;
int n,tot;
int v[10005],nxt[10005],h[5005],siz[5005];
ll d[5005][5005],tmp[5005],f[5005];

ll mod(ll x){return x>=cys?x-cys:x;}

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot;
}

void dfs(int u,int fa){
	d[u][1]=1,siz[u]=1;
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa) continue;
		dfs(v[p],u);
		for(int i=1;i<=siz[u]+siz[v[p]];i++) tmp[i]=0;
		for(int i=1;i<=siz[u];i++){
			for(int j=1;j<=siz[v[p]];j++){
				tmp[i]=mod(tmp[i]+cys-d[u][i]*d[v[p]][j]%cys*f[j]%cys);
				tmp[i+j]=(tmp[i+j]+d[u][i]*d[v[p]][j])%cys;
			}
		}
		siz[u]+=siz[v[p]];
		for(int i=1;i<=siz[u];i++) d[u][i]=tmp[i];
	}
}

int main(){
	n=readint();
	for(int i=1;i<n;i++) addedge(readint(),readint());
	f[2]=1;
	for(int i=4;i<=n;i+=2) f[i]=(i-1)*f[i-2]%cys;
	dfs(1,-1);
	ll ans=0;
	for(int i=1;i<=n;i++) ans=(ans+d[1][i]*f[i])%cys;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 194944
def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    table = list(table)
    return table
N = int(input())
k = 2
res = 0
while k*k<=N:
    n = N
    while not n%k:
        n//=k
    if (n%k==1 or n==1) and n!=N:
        res += 1
    k += 1
a = divisors(N-1)
print(len(a)+res)

Measured memory_bytes: 64548
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int A,P,ans=0; cin >> A >> P;
    ans=A*3+P;
    cout << ans/2 << endl;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

class FordFulkerson
{
public:
    FordFulkerson(int n) : _n(n), _graph(n), _used(n, false) {}

    void add_edge(int from, int to, ll cap)
    {
        _graph[from].emplace_back(to, cap, (int)_graph[to].size());
        _graph[to].emplace_back(from, 0, (int)_graph[from].size() - 1);
    }

    ll operator()(int s, int t)
    {
        ll flow = 0;
        while (true) {
            fill(_used.begin(), _used.end(), false);
            ll f = dfs(s, t, linf);
            if (f == 0) return flow;
            flow += f;
        }
    }

private:
    struct edge
    {
        int to; ll cap; int rev;
        edge(int to, ll cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    int _n;
    vector<vector<edge>> _graph;
    vector<bool> _used;

    ll dfs(int v, int t, ll f)
    {
        if (v == t) return f;
        _used[v] = true;
        for (auto &e: _graph[v]) {
            if (!_used[e.to] && e.cap > 0) {
                ll d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    _graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
};

struct Point { int x, y; };

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

    int n; cin >> n;
    vector<Point> r(n), b(n);
    for (int i = 0; i < n; i++) cin >> r[i].x >> r[i].y;
    for (int i = 0; i < n; i++) cin >> b[i].x >> b[i].y;

    FordFulkerson flow(2 * n + 2);
    int s = 2 * n, t = 2 * n + 1;
    for (int i = 0; i < n; i++) flow.add_edge(s, i, 1);
    for (int i = 0; i < n; i++) flow.add_edge(n + i, t, 1);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (r[i].x < b[j].x && r[i].y < b[j].y) {
                flow.add_edge(i, n + j, 1);
            }
        }
    }

    cout << flow(s, t) << endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

for i in range(n):
    if b[i] >= sum(a[i:i+2]):
        ans += sum(a[i:i+2])
        a[i+1] = 0
    elif a[i] >= b[i]:
        ans += b[i]
    elif a[i] < b[i]:
        ans += b[i]
        a[i+1] -= b[i] - a[i]
print(ans)

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<' '<<b<<' '<<c;
    return 0;
}



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


int main() {
  string N;
  cin >> N;
  
  for(int i; i < N.size(); i++){
    if(N[i]=='1'){
      N.at(i) = 'x';
    }
    if(N[i]=='9'){
      N.at(i) = '1';
    }
    if(N[i]=='x'){
      N.at(i) = '9';
    }
  }
  
  cout << N << endl;
  
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int x[10];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for (int i = 1; i <= 5; i++) cin >> x[i];
    for (int i = 1; i <= 5; i++) {
        if (x[i] == 0) {
            cout << i << E;
            break;
        }
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 3632
import collections

n = int(input())
v = [int(i) for i in input().split()]

odd_number = [i for index, i in enumerate(v) if index % 2 != 0]
even_number = [i for index, i in enumerate(v) if index % 2 == 0]

odd_count = collections.Counter(odd_number).most_common()
even_count = collections.Counter(even_number).most_common()
odd_count.append((10**6, 0))
even_count.append((10**6, 0))

if odd_count[0][0] != even_count[0][0]:
  answer = [odd_count[0][0], even_count[0][0]]
else: 
  answer = [odd_count[1][0], even_count[0][0]] if odd_count[1][1] + even_count[0][1] > odd_count[0][1] + even_count[1][1] else [odd_count[0][0], even_count[1][0]]

print(len([i for i in odd_number if i != answer[0]]) + len([i for i in even_number if i != answer[1]]))

Measured memory_bytes: 21076
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair




int main(){
    ll h,w,n;
    vector<pll> c;
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        c.push_back({a,i+1});
    }
    sort(c.begin(),c.end(),greater<pll>());
    ll W=0;
    ll k=0;
    ll a[1000][1000]={};
    while(W<w){
        if(W%2==0){
            for(int i=0;i<h;i++){
                a[i][W]=c[k].S;
                c[k].F--;
                if(!c[k].F){k++;}
            }
            W++;
        }
        else{
            for(int i=(int)h-1;i>=0;i--){
                a[i][W]=c[k].S;
                c[k].F--;
                if(!c[k].F){k++;}
            }
            W++;
        }
    }
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            cout<<a[i][t];
            if(t!=w-1){cout<<" ";}
        }
        cout<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 8444
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
	long long int N,K,i;
	long long ans=0;
	scanf("%lld%lld",&N,&K);
	long long a=0,b=0;
	a = N/K;
	if(K%2 == 0) b= (N+K/2)/K;
	ans = a*a*a + b*b*b;
	
	printf("%lld",ans);
	return 0;
}

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

namespace ABC163D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            long count = 0;
            long[] ruiseki = new long[N + 1];
            long sum = 0;
            for(int i = 0; i <= N ; i++)
            {
                sum += i;
                ruiseki[i] = sum;
            }
            for(int i = K; i <= N ; i++)
            {
                count += ruiseki[N] - ruiseki[N - i] - ruiseki[i-1] + 1;
                while (count >= 1000000007)
                {
                    count -= 1000000007;
                }
            }
            count += 1;
            while (count >= 1000000007)
            {
                count -= 1000000007;
            }
            Console.WriteLine(count);

        }
    }
}


Measured memory_bytes: 28880
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

ll apply(vector <ll> &g, ll x){
    while(x > 0 && g[__lg(x)] > 0){
        x ^= g[__lg(x)];
    }
    return x;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        vector <ll> a(n);
        for(auto &i : a) cin >> i;
        string s;
        cin >> s;
        vector <ll> g(60);
        char ans = '0';
        for(int i = n - 1 ; i >= 0 ; i--){
            if(s[i] == '0'){
                ll x = apply(g, a[i]);
                if(x > 0) g[__lg(x)] = x;
            }
            else{
                if(apply(g, a[i]) > 0){
                    ans = '1';
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

bool P[8][8];
int N, M;

void init_global() {
	FOR(i, 0, 8) {
		FOR(j, 0, 8) {
			P[i][j] = false;
		}
	}
}

void dfs(int n, int i, vb& v, ll& cnt) {
	if (n == 0) {
		cnt++;
		return;
	}

	v[i] = true;
	FOR(j, 0, N) {
		if (!P[i][j] || v[j]) continue;
		dfs(n - 1, j, v, cnt);
	}
	v[i] = false;
}

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

	cin >> N >> M;
	int a, b;
	FOR(i, 0, M) {
		cin >> a >> b;
		a--; b--;
		P[a][b] = P[b][a] = true;
	}

	ll ans=0;
	vb v(N, false);
	dfs(N-1, 0, v, ans);

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


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 19148
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

//もう一回ワーシャルフロイドして一回でも更新が起きたら正しくない？

int main(){
    int n;cin>>n;
    ll a[n][n];
    rep(i,n)rep(j,n) cin>>a[i][j];
    bool update=false;
    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(a[i][j]>a[i][k]+a[k][j]) update=true;
            }
        }
    }
    if(update){
        cout<<-1<<endl;return 0;
    }
    ll ans=0;

    //最短経路構築
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ll cost=a[i][j];
            //このコストの辺がグラフに要るかどうか
            bool f=false;
            for(int k=0;k<n;k++){
                //kは経由地
                if(k==i) continue;
                if(k==j) continue;
                f=(f||(cost==a[i][k]+a[k][j]));
            }
            if(!f) ans+=cost;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
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; }

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

    ll N, K;
    cin >> N >> K;
    print(min(N % K, K - N % K));

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005


ll N,M;
int min_dist[SIZE],pre_node[SIZE];
vector<int> G[SIZE];

vector<int> bfs(int start){

	vector<int> ret(N+1);

	for(int i = 0; i < N; i++){

		min_dist[i] = BIG_NUM;
		pre_node[i] = -1;
	}
	min_dist[start] = 0;

	queue<int> Q;
	Q.push(start);

	while(!Q.empty()){

		int node_id = Q.front();
		Q.pop();

		for(int i = 0; i < G[node_id].size(); i++){

			int next = G[node_id][i];
			if(min_dist[next] != BIG_NUM)continue;

			min_dist[next] = min_dist[node_id]+1;
			pre_node[next] = node_id;
			Q.push(next);
		}
	}

	int minimum = BIG_NUM,last_node = -1;

	for(int i = 0; i < N; i++){
		if(i == start)continue;

		for(int k = 0; k < G[i].size(); k++){
			if(G[i][k] == start){
				if(minimum > min_dist[i]){
					minimum = min_dist[i];
					last_node = i;
				}
			}
		}
	}

	if(last_node == -1)return ret;

	int tmp = last_node;
	ret.clear();

	while(tmp != -1){
		ret.push_back(tmp);
		tmp = pre_node[tmp];
	}

	return ret;
}


int main(){

	scanf("%lld %lld",&N,&M);


	int from,to;

	for(ll i = 0; i < M; i++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		G[from].push_back(to);
	}

	vector<int> ans(N+1);

	for(ll start = 0; start < N; start++){

		vector<int> work = bfs(start);

		if(work.size() < ans.size()){

			ans = work;
		}
	}

	if(ans.size() == N+1){

		printf("-1\n");
		return 0;

	}else{

		printf("%lld\n",ans.size());
		for(int i = 0; i < ans.size(); i++){

			printf("%d\n",ans[i]+1);
		}
	}

	return 0;
}


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

    class Program
    {
        static int i = 1;
        static int sum = 0;
        static void Main(string[] args)
        {
            int ans;
            int X = int.Parse(Console.ReadLine());
            plus(X);
            ans = i-1;
            Console.WriteLine(ans.ToString());

        }
        static void plus(int a)
        {
            
            while (sum < a)
            {
                sum = sum + i;
                i++;
            }
        }
    }



Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 200005
#define ll long long
#define mod 1000000007
int a[N],p[N],f[N],s[N],n;
int main()
{
	scanf("%d",&n);s[0]=f[0]=1;
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);if(a[i]==a[i-1])n--,i--;}
	for(int i=1;i<=n;i++)
	{
		if(p[a[i]])f[i]=s[p[a[i]]];p[a[i]]=i;
		s[i]=(s[i-1]+f[i])%mod;
	}
	printf("%d\n",s[n]);
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication39
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[8];
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                double[] c = line.Split().Select(double.Parse).ToArray();
                if (c[0] >= 1.1)
                    a[0]++;
                else if (c[0] >= 0.6)
                    a[2]++;
                else if (c[0] >= 0.2)
                    a[4]++;
                else a[6]++;
                if (c[1] >= 1.1)
                    a[1]++;
                else if (c[1] >= 0.6)
                    a[3]++;
                else if (c[1] >= 0.2)
                    a[5]++;
                else a[7]++;
            }
            Console.WriteLine("{0} {1}", a[0], a[1]);
            Console.WriteLine("{0} {1}", a[2], a[3]);
            Console.WriteLine("{0} {1}", a[4], a[5]);
            Console.WriteLine("{0} {1}", a[6], a[7]);
        }
    }
}

Measured memory_bytes: 9596
#include<stdio.h>
int main(){
    char s[100005];
    long i=0,j=0,k=0,rcnt=0,lcnt=0,rnum[50002],lnum[50002],sumnum[50002],res[100005],harf;
    scanf("%s",s);
    while(1){
        if(s[i]=='R'){
            if(lcnt>0){
                lnum[j]=lcnt;
                lcnt=0;
                sumnum[j]=lnum[j]+rnum[j];
                j++;
            }
            rcnt++;
            i++;
        }else if(s[i]=='L'){
            if(rcnt>0){
                rnum[j]=rcnt;
                rcnt=0;
            }
            lcnt++;
            i++;
        }else{
            lnum[j]=lcnt;
            sumnum[j]=lnum[j]+rnum[j];
            j++;
            break;
        }
    }
    
    i=0;
    while(sumnum[i]>0){
        harf=sumnum[i]/2;
        if(sumnum[i]%2==0){
            for(j=0;j<rnum[i]-1;j++){
                res[k]=0;
                k++;
            }
            res[k]=harf;
            k++;
            res[k]=harf;
            k++;
            for(j=0;j<lnum[i]-1;j++){
                res[k]=0;
                k++;
            }
        }else{
            for(j=0;j<rnum[i]-1;j++){
                res[k]=0;
                k++;
            }
            if(rnum[i]%2==0){
                res[k]=harf;
                k++;
                res[k]=harf+1;
                k++;
            }else{
                res[k]=harf+1;
                k++;
                res[k]=harf;
                k++;
            }
            for(j=0;j<lnum[i]-1;j++){
                res[k]=0;
                k++;
            }
        }
        i++;
    }
    for(i=0;i<k;i++){
        printf("%ld ",res[i]);
    }
    printf("\n");
}

Measured memory_bytes: 2432
#include <iostream>
using namespace std;
typedef long long ll;
ll q[410][410], h, w, coux, couy, ans;
string s[410];

void dfs(ll x, ll y, ll z){
    q[x][y] = 1;
    if (z == 0){
        coux++;
        if (x != 0 && q[x - 1][y] == 0 && s[x - 1][y] == '.') dfs(x - 1, y, 1);
        if (x != h - 1 && q[x + 1][y] == 0 && s[x + 1][y] == '.') dfs(x + 1, y, 1);
        if (y != 0 && q[x][y - 1] == 0 && s[x][y - 1] == '.') dfs(x, y - 1, 1);
        if (y != w - 1 && q[x][y + 1] == 0 && s[x][y + 1] == '.') dfs(x, y + 1, 1);
    }
    else{
        couy++;
        if (x != 0 && q[x - 1][y] == 0 && s[x - 1][y] == '#') dfs(x - 1, y, 0);
        if (x != h - 1 && q[x + 1][y] == 0 && s[x + 1][y] == '#') dfs(x + 1, y, 0);
        if (y != 0 && q[x][y - 1] == 0 && s[x][y - 1] == '#') dfs(x, y - 1, 0);
        if (y != w - 1 && q[x][y + 1] == 0 && s[x][y + 1] == '#') dfs(x, y + 1, 0);
    }
}

int main(void){
    // Your code here!
    cin >> h >> w;
    for (ll i = 0; i < h; i++) cin >> s[i];
    for (ll i = 0; i < h; i++){
        for (ll j = 0; j < w; j++){
            if (q[i][j] != 0) continue;
            coux = 0, couy = 0;
            ll y;
            if (s[i][j] == '#') y = 0;
            else y = 1;
            dfs(i, j, y);
            ans += coux * couy;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) cout << exchange(dlm, "\t") << x;
  return os;
}
struct Graph{
  // size_t time;
  vector<vector<size_t>> v;
  // vector<size_t> d,f;
  vector<int32_t> d;
  // Graph(size_t n): time(1), v(n), d(n,0), f(n) {}
  Graph(size_t n): v(n), d(n,-1) {}
  // void dfs(size_t i){
  //   d[i]=time++;
  //   for(const auto& x:v[i]) if(d[x-1]==0) dfs(x-1);
  //   f[i]=time++;
  // }
  void bfs(size_t n){
    d[n]=0;
    deque<size_t> que(1,n);
    while(!que.empty()){
      size_t x=que.front(); que.pop_front();
      for(const auto& y:v[x]){
        if(d[y-1]==-1){
          d[y-1]=d[x]+1;
          que.push_back(y-1);
        }
      }
    }
  }
};
ostream& operator<<(ostream& os, const Graph& x){
  for(size_t i=0; i<x.v.size(); ++i)
    // cout<<(i+1)<<' '<<x.d[i]<<' '<<x.f[i]<<'\n';
    cout<<(i+1)<<' '<<x.d[i]<<'\n';
  return os;
}
int32_t main(){
  size_t n; cin>>n;
  Graph graph(n);
  for(size_t i=0; i<n; ++i){
    size_t id,k; cin>>id>>k;
    graph.v[id-1].resize(k); for(auto&& x:graph.v[id-1]) cin>>x;
  }
  graph.bfs(0);
  cout<<graph;
}


Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n; cin >>n;
    vector<int> p(n+1); REP(i,n) cin >> p[i+1];
    vector<int> q = p;

    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (p[i] == i) {
            if (i < n) {
                swap(p[i], p[i+1]);
                count++;
            } else {
                swap(p[i], p[i-1]);
                count++;
            } 
        } 
    }

    int count2 = 0;
    for (int i = n; i >= 1; i--) {
        if (q[i] == i) {
            if (i > 1) {
                swap(q[i], q[i-1]);
                count2++;
            } else {
                swap(q[i], q[i+1]);
                count2++;
            } 
        } 
    }

    cout << min(count, count2) << endl;
    return 0;
}



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

const int mod = 1e9 + 7;
const int maxn = 1e6 + 7;
ll fact[maxn];
ll inv[maxn];

ll binpow(ll a, ll b){
  ll res = 1;
  while(b){
    if(b&1) res = (res*a)%mod;
    a = (a*a)%mod;
    b >>= 1;
  }
  return res;
}


ll binc(int n, int k){
  if(k > n) return 0;
  if(k == 0 || k == n) return 1;
  return (((fact[n] * (inv[k] % mod))%mod) * (inv[n - k] % mod))%mod;
}

int main(){
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  memset(fact,0,sizeof(fact));
  fact[0] = 1;
  for(int i = 1; i < maxn; ++i){
    fact[i] = (fact[i - 1]*i + mod)%mod;
    inv[i] = binpow(fact[i],(ll)mod-2) % mod;
  } 
  ll ans = 0;
  for(int i = b; i < w; ++i){
    ll temp = ((binc(h - a - 1 + i,i)%mod)*(binc(a - 1 + w - i - 1,w - i - 1)%mod))%mod;
    //cout << h - a - 1 + w - i << ' ' << w - i << '\n';
    //cout << (binc(h - a - 1 + i,i)%mod) << ' ' << (binc(a - 1 + w - i - 1,w - i - 1)%mod) << '\n';
    //cout << a - 1 + w - i - 1 << ' ' << w - i - 1 << '\n'; 
    ans = (ans + temp)%mod;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 19172
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int main() {
    int d, g;
    cin >> d >> g;
    g /= 100;
    VI p(d+1), c(d+1);
    FOR(i,1,d){
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    int ans = 1e9;
    REP(mask,1<<d){
        int tmp = 0, s = 0;
        REP(i,d){
            if ((mask >> i) & 1){
                s += (i+1) * p[i+1] + c[i+1];
                tmp += p[i+1];
            }
        }
        FORR(i,d-1,0){
            if (s >= g) break;
            if ((mask >> i) & 1) continue;
            REP(j,p[i+1]){
                s += i+1;
                if (j == p[i+1]) s += c[i+1];
                tmp++;
                if (s >= g) break;
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{ 
    long long dogs;
    scanf("%lld",&dogs);
    int i = 0;
    char str[100];
    while(dogs > 0){
        int temp = dogs % 26;
        if(temp == 0){
            str[i++] = 'z';
            dogs = (dogs/26) - 1;
        }else{
            str[i++] = (temp - 1) + 'a';
            dogs = dogs/26;
        }
    }
    str[i] = '\0';
    for(int j= i-1;j >= 0;j--)
	{
        printf("%c",str[j]);
    }
    return 0;
}

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

struct dice{
	int top;
	int front;
	int left;
	int right;
	int back;
	int bottom;
};

void ClockwiseTop(dice *X){
	int c = X->front;
	X->front  = X->right;
	X->right  = X->back;
	X->back   = X->left;
	X->left   = c;
}

void ClockwiseFront(dice *X){
	int c = X->top;
	X->top    = X->left;
	X->left   = X->bottom;
	X->bottom = X->right;
	X->right  = c;
}

void ClockwiseRight(dice *X){
	int c = X->top;
	X->top    = X->front;
	X->front  = X->bottom;
	X->bottom = X->back;
	X->back   = c;
}

void ClockwiseBottom(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void ClockwiseBack(dice *X){
	ClockwiseFront(X);
	ClockwiseFront(X);
	ClockwiseFront(X);
}

void ClockwiseLeft(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
	ClockwiseRight(X);
}

void TwiceClockwiseTop(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void TwiceClockwiseRight(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
}

dice ArrengeTop(dice A, dice B){
	if(B.front  == A.top) ClockwiseRight(&B);
	if(B.right  == A.top) ClockwiseBack(&B);
	if(B.left   == A.top) ClockwiseFront(&B);
	if(B.back   == A.top) ClockwiseLeft(&B);
	if(B.bottom == A.top) TwiceClockwiseRight(&B);
	return B;
}

dice ArrengeFront(dice A, dice B){
	if(B.right  == A.front) ClockwiseTop(&B);
	if(B.left   == A.front) ClockwiseBottom(&B);
	if(B.back   == A.front) TwiceClockwiseTop(&B);
	return B;
}

char Judge(dice A, dice B){
	B = ArrengeTop(A, B);
	B = ArrengeFront(A, B);	
	if(B.top    != A.top   ) return 'F';
	if(B.front  != A.front ) return 'F';
	if(B.right  != A.right ) return 'F';
	if(B.left   != A.left  ) return 'F';
	if(B.back   != A.back  ) return 'F';
	if(B.bottom != A.bottom) return 'F';
	return 'T';
}

dice Enter(dice X){
	cin >> X.top;
	cin >> X.front;
	cin >> X.right;
	cin >> X.left;
	cin >> X.back;
	cin >> X.bottom;
	return X;
}

int main(){
	//?????????????????????????????¢?????°????????\?????????
	dice A = Enter(A);
	dice B = Enter(B);
	//???????????????????????¨?????????
	if(Judge(A, B) == 'F') cout << "No"  << endl;
	if(Judge(A, B) == 'T') cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll k,a,dp[2<<17],m=1e9+7;
int i,n,j;
main(){
	cin>>n>>k;
	dp[0]=1;
	for(i=0;i<n;i++){
		cin>>a;
		for(j=1;j<=k;j++)dp[j]+=dp[j-1];
		for(j=k;j>=1;j--) 
		{if(j-a-1>=0) dp[j]=(dp[j]-dp[j-a-1])%m;
		else dp[j]%=m;}
	}
	cout<<dp[k];
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a>c || a+b<c) cout << "NO" << endl;
	else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
    long n;
    cin >> n;
    long long ans =0;
    for (int i = 1 ; i <= n ; i ++){
        if ( i % 3 !=0 && i % 5 != 0){
            ans +=i;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
#define ed '\n'
using namespace std;
typedef long long int ll;
#define mod 998244353
double pi=3.14159265358979323846;
void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main(){
	sync();
	ll t;
	t=1;
	for(ll testcase=1;testcase<=t;testcase++){
	ll n,m;
	cin>>n>>m;
	ll sum=0;
	for(ll i=0;i<m;i++)
	{
		ll x;
		cin>>x;
		sum+=x;
	}
	if(sum>n)cout<<-1<<endl;
	else cout<<n-sum<<endl;
	}
}

Measured memory_bytes: 3652
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")



int main() {
	ll M, K, X;
	cin >> M >> K;
	X = 1LL << M;
	if (X <= K) {
		PRI(-1);
		return 0;
	}
	if (M == 0)PRI("0 0");
	else if (M == 1) {
		if (K == 0)PRI("0 0 1 1");
		else PRI(-1);
	}
	else {
		REP(i, 0, X)if (i != K)PRI(i << " ");
		PRI(K << " ");
		for (int i = X-1; i >= 0; --i) if (i != K)PRI(i << " ");
		PRI(K);
	}
	return 0;
}




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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



int main() {
	ll W, H, x, y;
	cin >> W >> H >> x >> y;

	long double sq_ans = static_cast<long double>(W * H) / 2;
	long double cx, cy;
	cx = static_cast<double>(W) / 2;
	cy = static_cast<double>(H) / 2;

	if (x == cx && y == cy) {
		printf("%.9llf %d\n", sq_ans, 1);
	}
	else {
		printf("%.9llf %d\n", sq_ans, 0);
	}
}

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

int main() {
	int A[3], a[3], n1, n2;
	for (int i=0;i<3;i++) {
		cin >> A[i];
	}
	a[0] = A[0] - A[1];
	a[1] = A[1] - A[2];
	a[2] = A[2] - A[0];
	for (int i =0;i<3;i++) {
		if(a[i]<0){
			a[i] = a[i] * -1;
		}
	}
	if(a[0] < a[1]){
		n1 = a[0];
		if (a[1] < a[2]) {
			n2 = a[1];
		}
		else{
			n2 = a[2];
		}
	}else if(a[1] < a[2]){
		n1 = a[1];
		if (a[0] < a[2]) {
			n2 = a[0];
		}
		else {
			n2 = a[2];
		}
	}else{
		n1 = a[2];
		if (a[0] < a[1]) {
			n2 = a[0];
		}
		else {
			n2 = a[1];
		}
	}
	cout << n1 + n2 << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, m;
	cin >> n >> m;
	Vi H(n);
	rep(i, n)  cin >> H[i];
	Vii T(n);
	int a, b;
	rep(i, m) {
		cin >> a >> b;
		a--;  b--;
		T[a].push_back(b);
		T[b].push_back(a);
	}

	int ans = 0;
	rep(i, n) {
		if (T[i].size() == 0) {
			ans++;
			continue;
		}
		bool f = true;
		for (int k : T[i]) {
			if (H[i] <= H[k]) {
				f = false;
				break;
			}
		}
		if (f)  ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 8800
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void){
  int i,ans=753;
  char s[11];
  scanf("%s",s);
  for(i=0;i<strlen(s)-2;i++){
    if(abs((s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48)-753)<ans)
      ans=abs((s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48)-753);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

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

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

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

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

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

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

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            var dic = new Dictionary<string, int>();
            string s1 = cin.next();
            string s2 = cin.next();
            dic.Add(s1, cin.nextInt());
            dic.Add(s2, cin.nextInt());
            string s3 = cin.next();
            dic[s3]--;

            Console.WriteLine(dic[s1] + " " + dic[s2]);
        }

    }
}


Measured memory_bytes: 13152
def dist(a, b):
    v = 0
    for d in range(D):
        v += (a[d]-b[d])**2
    v = v ** 0.5
    return v


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        if dist(X[i], X[j]).is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 3064
#include <cstdio>
int main() {
	int h,m,s,t;
	for(int i=0;i<3;i++) {
		scanf("%d %d %d",&h,&m,&s);
		t=h*3600+m*60+s;
		scanf("%d %d %d",&h,&m,&s);
		t=h*3600+m*60+s-t;
		printf("%d %d %d\n",t/3600,t%3600/60,t%60);
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  for(int i=0;i<n;i++)cin >> x.at(i) >> y.at(i) >> h.at(i);

  for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){

            int ansH; //基準となる高さを格納する変数

            // 一番最初に1以上の数値を見つけた場合はそれで成り立つような高さを基準として設定
            for(int k=0;k<n;k++)if(h.at(k) > 0){
                ansH = h.at(k)+abs(i-x.at(k))+abs(j-y.at(k));
                break; //一つ目を見つけたら強制終了
            }

            bool fin=true;
            //基準の高さで全ての座標で辻褄が合うのか確認
            for(int k=0;k<n;k++){
                if(h.at(k) != max(ansH-abs(i-x.at(k))-abs(j-y.at(k)),0)){
                    fin = false;
                    break;
                }
            }

            //全ての場合は辻褄が合えばその結果を表示して終了
            if(fin){
                cout << i << " " << j << " " << ansH << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
    temp = input()
    count = 0
    min_count = 0
    for j in temp:
        if j == "(":
            count += 1
        else:
            count -= 1
            min_count = min(min_count, count)
    s.append([count, min_count])
sum_count = sum([s[i][0] for i in range(n)])
if sum_count != 0:
    print("No")
else:
    s2 = [s[i] for i in range(n) if s[i][0] >= 0]
    s3 = [s[i] for i in range(n) if s[i][0] < 0]
    s2.sort(key = lambda x: x[1], reverse = True)
    s3.sort(key = lambda x: x[1] - x[0])
    flag = True
    count = 0
    for i in range(len(s2)):
        if count + s2[i][1] < 0:
            flag = False
            break
        else:
            count += s2[i][0]
    for i in range(len(s3)):
        if count + s3[i][1] < 0:
            flag = False
            break
        else:
            count += s3[i][0]
    if flag == True:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 273548
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		boolean start = false;
		int startNum = 0;
		int finishNum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(start == false && s.substring(i, i + 1).equals("A")){
				start = true;
				startNum = i;
			}
			if(start == true && s.substring(i, i + 1).equals("Z")) {
				finishNum = i;
			}
		}
		System.out.println(finishNum - startNum + 1);
		scan.close();

	}

}


Measured memory_bytes: 36572