akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long A, long long B, long long C){
  ll ans = 0;
  vector<ll> abc{A,B,C};
  while(1){
    vector<ll> copy(abc);
    if(abc[0]%2 == 1 || abc[1]%2 == 1 || abc[2]%2 == 1)break;
    bool loop = true;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if(i == j)continue;
        abc[j] += copy[i]/2;
      }
    }
    for (int i = 0; i < 3; i++) {
      abc[i] -= copy[i];
      if(abc[i] != copy[i])loop=false;
    }
    if(loop){
      ans = -1;
      break;
    }else ans++;
  }
  cout << ans << endl;
}

int main(){
    long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	long long C;
	scanf("%lld",&C);
    solve(A, B, C);
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<std::string> A, std::vector<std::string> B){
    bool isGood = false;
    for(ll i=0; i<= N-M; i++){
        for(ll j=0; j<= N-M; j++){
            bool subGood = true;
            for(ll k=0; k<M; k++){
                if(A[i+k].substr(j, M) != B[k]) {
                    subGood = false;
                    break;
                }
            }
            if(subGood){
                cout << YES << endl;
                return;
            }
        }
    }
    cout << NO << endl;
    return;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<std::string> A(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> A[i];
    }
    std::vector<std::string> B(M);
    for(int i = 0 ; i < M ; i++){
        std::cin >> B[i];
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 256
S = input()
ans = 0

if S == "keyence":
    ans = 1

else:
    for i in range(len(S)+1):
        for j in range(i+1,len(S)+1):
            S_ = list(S)
            del S_[i:j]
            re = "".join(S_)
            if re != "keyence":
                continue
            else:
                ans = 1
                break

if ans == 0:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3060
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL X,Y;
	cin >> X >> Y;
	LL ans = 0;
	
	if( abs(X) == abs(Y) ){
		if( X!=Y ){
			++ans;
		}
		cout << ans << endl;return;
	}
	if( abs(Y) > abs(X) ){
		if( X < 0 ){
			++ans;
			X *= -1;
		}
		ans += abs(Y)-abs(X);
		X += abs(Y)-abs(X);
		if( X != Y ){
			++ans;
			X *= -1;
		}
		cout << ans << endl;return;
	}else{
		if( X >= 0 ){
			++ans;
			X *= -1;
		}
		ans += abs(X)-abs(Y);
		X += abs(X)-abs(Y);
		if( X != Y ){
			++ans;
			X *= -1;
		}
		cout << ans << endl;return;
	}
	/*
10 5	7
10 10	0
10 15	5
10 -5	6
10 -10	1
10 -15	6

-10 5	6
-10 10	1
-10 15	6
-10 -5	5
-10 -10	0
-10 -15	7

0 5	5
0 0	0
0 -5	6

**これ
10 0	11
-10 0	10

1000000000 999999999
1000000000 1000000000
1000000000 -999999999
1000000000 -1000000000

-1000000000 999999999
-1000000000 1000000000
-1000000000 -999999999
-1000000000 -1000000000
	*/
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

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

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

typedef pair<int, string> P;

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

	int n;
	cin >> n;

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

	const string start = string("12345678").substr(0, n);

	map<string, int> cost;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, start));
	cost[start] = 0;

	while(!que.empty()) {
		const int c_cost = que.top().first;
		const string state = que.top().second;
		que.pop();

		if(cost[state] < c_cost)
			continue;

		for(int i = 0; i < n; ++i) {
			for(int j = i + 1; j < n; ++j) {
				string next = state;
				swap(next[i], next[j]);
				const int n_cost = c_cost + c[i][j];
				if(!cost.count(next) || cost[next] > n_cost) {
					cost[next] = n_cost;
					que.push(P(n_cost, next));
				}
			}
		}
	}

	int ans = 0;
	FOR(it, cost) {
		chmax(ans, it->second);
	}

	cout << ans << endl;
	

	return EXIT_SUCCESS;
}

Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

         string s;
          cin>>s;

           for(int i=0;i<s.length()-1;i++){

                 if(i==0)
                 {
                    if(s[i]=='?')
                    {
                       if(s[i+1]=='D')
                        s[i]='P';

                        else if(s[i+1]=='P')
                         s[i]='D';

                         else if(s[i+1]=='?')
                         s[i]='P';

                         else
                         s[i]='D';
                    }
                 }
                 else{
                     if(s[i]=='?'){
                            if(s[i-1]=='P')
                             s[i]='D';

                             else if(s[i+1]=='D')
                              s[i]='P';

                              else if(s[i+1]=='?')
                              s[i]='P';

                              else
                            s[i]='D';
                  }
                 }
           }
             if(s.length()==1){

                if(s[0]=='?')
                 s[0]='D';
             }
             else{
                if(s[s.length()-1]=='?')
                 {
                     if(s[s.length()-2]=='P')
                      s[s.length()-1]='D';

                      else
                      s[s.length()-1]='D';
                 }
             }
              cout<<s;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int L;
int n,m;
int mp;
struct Edge{
	int x,y,w;
}ed[66];
int main()
{
	scanf("%d",&L);
	while((1<<(mp+1))<=L)
	{
		ed[++m]=(Edge){mp,mp+1,0};
		ed[++m]=(Edge){mp,mp+1,1<<mp};
		mp++;
	}
	for(int i=0;i<mp;++i)
		if((L>>i)&1)
			ed[++m]=(Edge){i,mp,((L>>(i+1))<<(i+1))};
	printf("%d %d\n",mp+1,m);
	for(int i=1;i<=m;++i)
		printf("%d %d %d\n",ed[i].x+1,ed[i].y+1,ed[i].w);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i,j;
    int x,n;
    cin>>x>>n;
    set<int> se;
    for(i=0;i<n;i++){
        int p;
        cin>>p;
        se.insert(p);
    }
    for(i=0;i<200;i++){
        if(se.count(x-i)==0){
            cout<<x-i<<endl;
            return 0;
        }
        if(se.count(x+i)==0){
            cout<<x+i<<endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3660
N, H = map(int, input().split())
a = []
b = []
for i in range(N):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)

shake = max(a)
throw = 0
for i in b:
    if i > shake:
        throw += i

b.sort(reverse=True)

ans = 0
if throw < H:
    ans += (H-throw+shake-1)//shake
    H -= ans * shake

i=0
while H>0:
    ans += 1
    H -= b[i]
    i += 1


print(ans)

Measured memory_bytes: 11300
#include <iostream>
using namespace std;
const int maxn = 505;
int a[maxn][maxn],cnt[3][1005];
int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	for(int i = 1;i <= m; ++i)
	{
		for(int j = 1;j <= m; ++j)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i = 1;i <= n; ++i)
	{
		for(int j = 1;j <= n; ++j)
		{
			int x;
			cin>>x;
			cnt[(i + j) % 3][x]++;
		}
	}
	long long ans = 1e18;
	for(int f1 = 1;f1 <= m; ++f1)
	{
		for(int f2 = 1;f2 <= m; ++f2)
		{
			for(int f3 = 1;f3 <= m; ++f3)
			{
				if(f1 == f2 || f2 == f3 || f1 == f3)
				{
					continue;
				}
				long long now = 0;
				for(int i = 1;i <= m; ++i)
				{
					now += cnt[1][i] * a[i][f1] + cnt[2][i] * a[i][f2] + cnt[0][i] * a[i][f3];
				}
				ans = min(ans,now);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<bool> sunuke(n,false);
  for (int i=0;i<k;i++) {
    int d;
    cin>>d;
    for (int j=0;j<d;j++) {
      int a;
      cin>>a;
      sunuke.at(a-1)=true;
    }
  }
  int ans=0;
  for (int i=0;i<n;i++) {
    if (sunuke.at(i)==false) ans++;
  }
  cout<<ans<<endl;
}

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

int main(void){
    int n;
    cin >> n;
    vector<ll> l(n);
    for (int i=0; i<n; i++) cin >> l[i];
    int cnt = 0;
    for (int i=0; i<n-2; i++){
        for (int j=i+1; j<n-1; j++){
            for (int k=j+1; k<n; k++){
                if (l[i]!=l[j] && l[j]!=l[k] && l[i]!=l[k] && l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){

  int r = 0;
  double sum = 0;

  cin >> r;

  if(r>=1 && r<=100){
    sum = r*2*(M_PI);
  }

cout << sum << endl;
//cout << (sum - 458.67252742410977361942)*100 << endl;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

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

   pair <ll,ll> a[n];

   rep(i,n){
      ll p,q;
      cin>>p>>q;
      a[i]=make_pair(p,q);
   }

   sort(a,a+n);
   ll ans=0;
   rep(i,n){
      ll b=min(a[i].second,m);
      ans+=a[i].first*b;
      m-=b;

      if(m==0) break;
   }
   cout<<ans;
   
  
return 0;
}



Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define int long long
#define x first 
#define y second
#define dbg(x) cout << #x << " = " << x << endl;

void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();
    return 0;
}
 
const int MOD = 998244353, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;
int f[50][10][10];

void solve() {
    int k;
    cin >> k;

    if (k <= 9) {
        cout << k << endl;
        return;
    }

    k -= 9;

    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (abs(i - j) <= 1) {
                f[2][i][j]++;
            }
        }
    }

    for (int i = 3; i < 50; ++i) {
        for (int d1 = 0; d1 < 10; ++d1) {
            for (int d2 = 0; d2 < 10; ++d2) {
                if (abs(d1 - d2) <= 1) {
                    for (int k = 0; k < 10; ++k) {
                        if (abs(d2 - k) <= 1) {
                            f[i][d1][d2] += f[i - 1][d2][k];
                        }
                    }
                }
            }
        }
    }

    int id = -1;

    for (int i = 2; i < 50; ++i) {
        int sum = 0;
        for (int d1 = 1; d1 < 10; ++d1) {
            for (int d2 = 0; d2 < 10; ++d2) {
                if (abs(d1 - d2) <= 1) {
                    sum += f[i][d1][d2];
                }
            }
        }

        if (sum >= k) {
            id = i; 
            break;
        }
        else {
            k -= sum;
        }
    }

    int last = 0;
    int cur = 0;
    bool flag = true;

    for (int d1 = 1; d1 < 10; ++d1) {
        for (int d2 = 0; d2 < 10; ++d2) {
            if (abs(d1 - d2) <= 1) {
                cur += f[id][d1][d2];
                if (cur >= k && flag) {
                    flag = false;
                    last = d1;
                    break;
                }
            }
        }
    }

    // dbg(last)
    

    for (int i = 1; i < last; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (abs(i - j) <= 1) {
                k -= f[id][i][j];
            }
        }
    }

    // dbg(k << " " << id)

    int T = last;
    vector<int> ans;
    for (int i = id; i >= 2; --i) {
        int nw;

        for (int d = 0; d < 10; ++d) {
            if (abs(last - d) <= 1) {
                if (k - f[i][last][d] <= 0) {
                    nw = d;
                    break;
                }
                else {
                    k -= f[i][last][d];
                }
            }
        }

        ans.push_back(nw);
        last = nw;
    }

    ans.insert(ans.begin(), T);

    for (auto it : ans) { 
        cout << it;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

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


// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	cin >> h >> w;
	P c, d;
	cin >> c.first >> c.second >> d.first >> d.second;
	c.first --;
	c.second --;
	d.first --;
	d.second --;
	vector<string> field(h);
	REP(i, h){
		cin >> field[i];
	}

	vector<vector<ll>> seen(h, vector<ll>(w, INF));
	seen[c.first][c.second] = 0;
	
	priority_queue<pair<ll, P>, vector<pair<ll, P>>, greater<pair<ll, P>>> que;
	que.emplace(0, c);

	while(!que.empty()){
		pair<ll, P> hoge = que.top();
		que.pop();
		ll x = hoge.second.first, y = hoge.second.second;
		ll level = hoge.first;

		if(x == d.first && y == d.second){
			cout << level << endl;
			return 0;
		}
		REP(i, 4){
			ll nx = x + dx[i], ny = y + dy[i];
			if(nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
			if(seen[nx][ny] <= level) continue;
			if(field[nx][ny] != '.') continue;
			seen[nx][ny] = level;
			que.emplace(level, make_pair(nx, ny));
		}

		for(ll i = x-2; i <= x+2; i ++){
			for(ll j = y-2; j <= y+2; j++){
				if(i < 0 || j<0||i >= h||j >= w) continue;
				if(seen[i][j] <= level+1) continue;
				if(field[i][j] != '.') continue;
				seen[i][j] = level+1;
				que.emplace(level+1, make_pair(i, j));
			}
		}

	}

	// REP(i, h){
	// 	REP(j, w){
	// 		cout << seen[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << endl;

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

Measured memory_bytes: 13668
x, n = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort()
if n == 0:
    print(x)
else:
    for i in range(lis[n-1]+2):
        
        if i < x and i not in lis:
            a = i
        if i >= x and i not in lis:
            b = i
            if abs(a-x) <= abs(b-x):
                print(a)
            else:
                print(b)
            break



Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;
int arr[26];

void solve(){
    int k,n;
    cin>>k>>n;
    int arr[n];
    rep(i,n) cin>>arr[i];
    int ans=0;
    rep(i,n-1) ans=max(ans, arr[i+1]-arr[i]);
    if(arr[n-1]-arr[0]<=k/2) cout<<arr[n-1]-arr[0];
    else cout<<min(k-ans,arr[n-1]-arr[0]);
    
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 1152
n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
for i in range(1, n):
  if l[i] + l[i-1] > x:
    diff = (l[i] + l[i-1]) - x
    ans += diff
    if l[i] >= diff:
      l[i] -= diff
    else:
      l[i-1] -= diff - l[i]
      l[i] = 0
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int MAXN=1e5+1;

struct node{
    int degree;
    int cnt;
    node(int _degree=0, int _cnt=0){
        degree=_degree;
        cnt=_cnt;
    }
};

int n, m, ai, bi;
vector<int> h(MAXN);
vector<node> graph(MAXN,node(0,0));

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        cin>>ai>>bi;
        graph[ai].degree++;
        graph[bi].degree++;
        if(h[ai]>h[bi]){
            graph[ai].cnt++;
        }
        if(h[ai]<h[bi]){
            graph[bi].cnt++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(graph[i].cnt==graph[i].degree)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4452
N = int(input())
data_v = list(map(int, input().split()))
data_c = list(map(int, input().split()))

data = [0] * N
ans = 0
for i in range(N):
    data[i] = data_v[i] - data_c[i]
    if data[i] >= 0:
        ans += data[i] 

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
string S[55];
int T[55];
string X;
char buf[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) {
	scanf("%s%d", buf, T+i);
	S[i] = buf;
    }
    scanf("%s", buf);
    X = buf;

    bool f = false;
    int ans = 0;
    REP (i, N) {
	if (f) ans += T[i];
	if (S[i] == X) f = true;
    }
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;



int main(){
    int N,K;cin >> N >> K;
    set<pair<int,int>> Edge;
    function<void(int,int)> calc = [&](int i,int j){
        if(j == 0)return ;
        Edge.insert({i,(j-1)/2});
        calc(i,(j-1)/2);
    };
    for(int a = N-1;a >= 1;a--){
        calc(a,a);
    }
    cout<<Edge.size()<<endl;
    for(auto e :Edge){
        cout<<e.first+1<<" "<<e.second+1<<endl;
    }
    for(int index = 0;index < K;index++){
        int i = 0;
        int result = -1;
        while(i < N){
            cout<<i+1<<endl;
            string s;cin >> s;
            if(s == "Yes"){
                result = -1;
                break;
            }
            if(s == "Near"){
                i *= 2;
                i++;
            }else{
                i++;
                result = i;
                i *= 2;
                i++;
            }
        }
        if(result != -1){
            cout<<result+1<<endl;
            string s;cin >> s;
            continue;
        }
    }
    cout<<flush;
    return 0;
}



Measured memory_bytes: 3312
import sys
sdin = sys.stdin.readline

n,k = map(int, sdin().split())

ab = []
for i in range(n):
    a,b = map(int, sdin().split())
    ab.append(tuple([a,b]))

ab.sort(key=lambda x:x[0])
res = k
for a, b in ab:
    res -= b
    
    if res <= 0:
        print(a)
        
        break


Measured memory_bytes: 18220
a,b,C,x,y = gets.split.map(&:to_i)
if a > b
  a,b = b,a
  x,y = y,x
end
ans = 0
if a+b <= 2*C
  p a*x + b*y  
elsif b <= 2*C # < a+b
  d = [x,y].min
  p 2*C*d + a*(x-d) + b*(y-d)
elsif a <= 2*C # < b
  p 2*C*y + a*[x-y,0].max
else           # C < a
  p 2*C*[x,y].max
end


Measured memory_bytes: 1788
/*

साहिल पे पहुंचने से इनकार किसे है लेकिन,
तूफ़ानो से लड़ने का मज़ा ही कुछ और है,
कहते है, कि किस्मत खुदा लिखता है लेकिन,
उसे मिटा के खुद गढ़ने का मजा ही कुछ और है।

*/


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
using namespace std;
 
#define int                 long long int
#define ull					unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define RS(arr)              sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define si                  set <int>
#define vi                  vector <int>
#define vvi                 vector <vector <int>>
#define vs                  vector <string>
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vpp                 vector <pair<int, pii>>
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define spi                 set <pii>
#define speed               ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl                "\n"
#define all(p)              p.begin(), p.end()
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)             priority_queue <t>
#define que_min(t)             priority_queue <t, vector<t>, greater<t>>
#define debuga(a, l, r)     for(auto x:a)cout<<x<<" ";cout<<endl;
#define debug1(x)           cout << #x " = " << x << endl;
#define debug2(x,y)         cout << #x " = " << x << " " << #y " = " << y << endl;
#define debug3(x,y,z)       cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define debug4(x,y,z,w)     cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define debug5(x,y,z,w,v)   cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define debug6(x,y,z,w,v,a) debug3(a, y, x)debug3(w, v, a)
#define p2d(v)     	    for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      	    for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)	for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    #ifndef ONLINE_JUDGE
         freopen("input.txt",  "r",  stdin);
         freopen("output.txt", "w", stdout);
    #endif
}

int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005

int coount(int n){
	int res = n/10 ;
	n/=10;
	int curr = 5;
	while(n>=curr){
		res += n/curr;
		curr*=5;
	}
	return res;
}

int32_t main(){
//	read();
	int n;
	cin>>n;
	if(n&1){
		cout<<0<<endl;
	}else{
		cout<<coount(n)<<endl;
	}
} 

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)


def is_in_map(x, y, w, h):
	return 0 <= x < w and 0 <= y < h


def dfs(x, y, lct):
	lct[y][x] = 0
	w = len(lct[0])
	h = len(lct)

	for i in range(-1, 2):
		for j in range(-1, 2):
			nx = x + i
			ny = y + j
			if not is_in_map(nx, ny, w, h):
				continue
			if lct[ny][nx] == 0:
				continue
			dfs(nx, ny, lct)

def resolve():
	while True:
		w, h = map(int, input().split())

		if w == 0 and h == 0:
			break

		ans = 0
		lct = []

		for _ in range(h):
			lct.append(list(map(int, input().split())))
		for i in range(h):
			for j in range(w):
				if lct[i][j] == 0:
					continue
				dfs(j, i, lct)
				ans += 1
		print(ans)

resolve()



Measured memory_bytes: 8108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  map<string, int>  gacha;
  rep(i, N)
  {
    string S;
    cin >> S;
    gacha[S]++;
  }
  int ans = gacha.size();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, i;
    int x = 0;
    int max = 0;
    string  S;
    cin >> N >> S;

    for (i = 0; i < N; ++i){
      if (S[i] == 'I') {
        x += 1;
        if (max < x){
          max = x;
        }
      } else {
        x -= 1;
      }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
x = int(input())						# 5


#nの素数判定
def is_prime(n):
	if n == 1:
		return False
	for i in range(2,int(n**0.5)+1):
		if n % i == 0: return False
	return True


ans = x

while is_prime(ans)==False:
	ans+=1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>

using namespace std;


int main(int argc, const char * argv[]) {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> dp(n+1, 0);
  int l, r;
  for(int i = 1; i <= n; i++){
    dp[i] = dp[i-1];
    if(s[i-1] == 'A' && s[i] == 'C'){
      dp[i]++;
    }
  }
  for(int i = 0; i < q; i++){
    cin >> l >> r;
    cout << dp[r-1] - dp[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N, A, B;
	//long long N, M;
	//double d, e;
	//string s, t;
	//vector<int> v;
	//vector<pair<int, int>> pl;

	//while() {}
	//for(int i=0; i<N; i++) {}
	
	cin >> N >> A >> B;
	int _max = min(A, B);
	int _min = max(0, (A+B)-N);
	// >> 
	cout << _max << ' ' << _min;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
int main(){
  ll a; cin >>a; string b;
  for(int i=0; i<4; i++){
    char c; cin >>c;
    if(i-1) b+=c;
  }
  int c=stoi(b);
  cout <<a*c/100;
return 0;}

Measured memory_bytes: 3508
mm, dd = gets.split.map(&:to_i)

cnt = 0

4.upto(mm) do |m|
  22.upto(dd) do |d|
    d10 = d/10
    d1 = d%10
    if d10>=2 && d1>=2 && m == d10*d1
      cnt+=1
    end
  end
end
puts cnt


Measured memory_bytes: 1788
def dfs(s,x):
    if len(s) == n:
        print(s)
    else:
        for c in range(ord('a'), ord(x) + 1):
            dfs(s + chr(c), chr(ord(x) + 1) if chr(c) == x else x)

n = int(input())
dfs('', 'a')

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans += min(x, k - x) * 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
ll mod=1000000007;
int main()
{
	/*
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
	#endif
	*/
fast;
ll n;cin>>n;
ll a[n];
ll sum[n];
fr(i,0,n)
{
	cin>>a[i];
	if(i==0) sum[i]=a[i];
	else sum[i]=sum[i-1]+a[i];
}
ll ans=0,k=n-1,j=0;
fr(i,0,n-1)
{
	ans=(ans+(a[i]*((sum[k]-sum[j])%mod)%mod))%mod;
	j++;
}
cout<<ans;
return 0;
}
 
  

Measured memory_bytes: 6752
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;cin>>n;
  bool f=0;
  for(long long i=1;i<=3500;i++){
for(long long j=1;j<=3500;j++){
long long s=4*i*j-n*i-n*j;
  if(s>0&&(n*i*j)%s==0){
cout<<i<<' '<<j<<' '<<(n*i*j)/s<<endl;
    
    f=1;
    break;
  }
}
    if(f)break;
  }
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
  int submitted[30];
  for(int i=0; i < 30; i++){
    submitted[i] = 0;
  }
  for(int i=0; i < 28; i++){
    int ind;
    std::cin >> ind;
    submitted[ind - 1] = 1;
  }
  for(int i=0; i < 30; i++){
    if(submitted[i] == 0){
      std::cout << i+1 << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  string a;int flag=0;
  cin>>a;
  for(int i=0;i<a.size();i++)
    if(a[i]=='C') flag=1;
    else if(a[i]=='F'&&flag==1)
      {cout<<"Yes";flag=8;}
  if(flag!=8) cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <chrono>
using namespace std;
#pragma GCC optimize("-O3")
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10) //cin.tie(0); cout.tie(0);
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FWD(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()
#define what(x) cerr << #x << " is " << x << endl;
#define int long long

const int MAXN = 2e5 + 1e4;
int kapitan[MAXN];
int wynik = 0;

int fiind(int x)
{
    if (kapitan[x] != x)
        kapitan[x] = fiind(kapitan[x]);
    return kapitan[x];
}
void unia(pair<int, pii> P)
{
    // cerr << P.st << " " << P.nd.st << " " << P.nd.nd << endl;
    int x = fiind(P.nd.st);
    int y = fiind(P.nd.nd);
    if (x > y)
        swap(x, y);
    if (x == 0 && y == 0)
        return;
    wynik += P.st;
    if (x == 0 || x == y)
        kapitan[y] = 0;
    else
        kapitan[y] = x;
}

vector<pair<int, pii>> A;
main()
{
    _upgrade;
    iota(kapitan, kapitan + MAXN, 0);
    int n, w, h;
    cin >> n >> w >> h;
    rep(i, n)
    {
        int b, c, a;
        cin >> b >> c >> a;
        b += max(w, h) + 2;
        A.pb(mp(a, mp(b, c)));
    }
    sort(all(A), greater<pair<int, pii>>());
    for (auto a : A)
        unia(a);
    cout << wynik << endl;
}

Measured memory_bytes: 6644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
    string s;
    long long int sum = 0;

    cin >> s;

    for (int bit = 0; bit < (1<<(s.size()-1)); bit++) {
        string t(s);
        long long int cnt = 1, tmp = 0;
        
        for (int i = 0; i < s.size()-1; i++) {
            if (bit & (1<<i)) {
                t.insert(t.begin()+i+cnt, '+');
                cnt++;
            }
        }
        for (int i = 0; i < t.size(); i++) {
            if (t[i] != '+') {
                tmp = tmp * 10 + t[i] - '0';
            }
            else {
                sum += tmp;
                tmp = 0;
            }
        }
        sum += tmp;
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>
 
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)

int main() {
  int N;
  cin >> N;
 
  int black_count[N+1];
  black_count[0] = 0;
  REP(i, N) {
    char c;
    cin >> c;
    black_count[i+1] = black_count[i];
    if (c == '#')
      ++black_count[i+1];
  }
 
  int min_count = N + 1;
  REP(i, N+1) {
    int left_white = i - black_count[i]; 
    int right_black = black_count[N] - black_count[i];
    min_count = min(min_count, (i - left_white) + (N - i - right_black));
  }
  cout << min_count << endl;
 
  return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (a,b,k) = readLine()!!.split(" ").map { it.toLong() }
    val ansA = Math.max(a-k, 0)
    val ansK = Math.max(k-a,0)
    val ansB = Math.max(b-ansK,0)
    println("$ansA $ansB")
}

Measured memory_bytes: 37916
#include<bits/stdc++.h>
using namespace std;
#define int long long
main()
{
    int x,y;
    cin>>x>>y;
    for(int i=0; i<=100; i++)
    {
        for(int j=0; j<=100; j++)
        {
            int v=i*2+j*4;
            if(v==y&&i+j==x)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main() {
	//入力;
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	map<string,int> mp;
	rep(i,N){
		string s; cin >> s;
		sort(all(s));
		mp[s]++;
	}
	ll ans = 0;
	for(auto it: mp){
		ll n = it.sc;
		ans += n*(n-1)/2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		WriteLine(GetInts(3).Distinct().Count() == 2 ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int a,b;
    cin>>a>>b;
    int c=a*b;
    if(c%2!=0) cout<<"Odd"<<endl;
    else cout<<"Even"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int C[102][102];
 
void meiro(int W,int H,int c){
  if(C[W][H]!=c){
    return;
  }
 
  C[W][H] = -1;
 
  meiro(W-1,H  ,c);
  meiro(W  ,H+1,c);
  meiro(W+1,H  ,c);
  meiro(W  ,H-1,c);
}
 
int main(){
  while(1){
    int w,h;
    cin >> w >> h;
    if(w==0 && h==0){
      break;
    }
 
    for(int i=0;i<102;i++){
      for(int j=0;j<102;j++){
        C[i][j] = 1919810;
      }
    }
 
    int xs,ys,xg,yg;
    cin >> xs >> ys >> xg >> yg;
 
    int n;
    cin >> n;
 
    int c,d,x,y;
    for(int i=0;i<n;i++){
      cin >> c >> d >> x >> y;
 
      if(d==0){
        for(int j=x;j<x+4;j++){
          for(int k=y;k<y+2;k++){
            C[j][k]=c;
          }
        }
      }else{
        for(int j=x;j<x+2;j++){
          for(int k=y;k<y+4;k++){
            C[j][k]=c;
          }
        }
      }
    }
 
    meiro(xs,ys,C[xs][ys]);
 
    if(C[xg][yg] == -1){
      cout << "OK" << endl;
    }else{
      cout << "NG" << endl;
    }
  }
 
  return 0;
}


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

int main() {
 int n,l; cin>>n>>l;
  
  if(l<0){
    if(l+n-1<0) cout<<(n-1)*l+(n-1)*(n-2)/2<<endl;
    else cout<<n*l+n*(n-1)/2<<endl;
  }
  else cout<<(n-1)*l+(n-1)*n/2<<endl;
     
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    map<string,int>memo;
    REP(i,N){
        string d;cin>>d;
        memo[d]++;
    }
    int M;cin>>M;
    REP(i,M){
        string d;cin>>d;
        memo[d]--;
    }
    int ans=0;
    for(auto it=memo.begin();it!=memo.end();it++){
        ans=max(ans,it->second);
    }
  	cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

string s;

int main() {
	cin >> s;
	REP(i, s.size()) {
		if (s[0] != s[i])break;
		if (i == s.size() - 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = INF;
	REP(i, 27) {
		ll cnt = 1;
		string t = s;
		while (t.size() > 1) {
			string buf = "";
			REP(j, t.size() - 1) {
				if (t[j] == 'a' + i || t[j + 1] == 'a' + i) {
					buf += (char)('a' + i);
				}
				else buf += t[j];
			}
			bool f = 0;
			REP(j, buf.size()) {
				if (buf[j] != 'a' + i)break;
				if (j == buf.size() - 1)f = 1;
			}
			if (f) {
				ans = min(ans, cnt);
				break;
			}
			t = buf;
			//cout << buf << endl;
			cnt++;
		}
	}
	cout << ans << endl;
}

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

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

    auto f = [](long long x) {
        return x * x * x;
    };

    long long N, K; cin >> N >> K;
    if (K & 1)
        cout << f(N/K) << "\n";
    else
        cout << f(N/K) + f((N/(K/2)) - (N/K)) << "\n";
}

Measured memory_bytes: 256
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

const int maxn = 2e5 + 7;

int a[maxn];

int main() {
    int n;
    while(cin >> n) {
        for(int i = 1 ; i <= n ; i++) {
            cin >> a[i];
        }
        int sum = 0;
        int cnt = 1;
        for(int i = 1 ; i <= n ; i++) {
            if(a[i] == cnt) {
                cnt++;
            } else {
                sum++;
            }
        }
        if(sum == n) cout << -1 << endl;
        else cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  vector<ll>vec(5);
  ll b=10;
  for(ll i=0;i<5;i++){
    ll c;
    cin>>c;
    vec.at(i)=((c-1)/10+1)*10;
    if(c%10!=0){
    b=min(b,c%10);
    }
  }
  ll s=0;
  for(ll i=0;i<5;i++){
    s+=vec.at(i);
  }
  s-=10-b;
  cout<<s<<endl;
  return 0;
}
    
  


 


Measured memory_bytes: 3596