akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,H,W;
    int cnt,x,y;

    cin>>n>>H>>W;

    cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        if(x>=H && y>=W)cnt++;
    }

    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N;
    bool seven = false;

    cin >> N;

    for (int i = 0; i < 3; i++)
    {
        if (N % 10 == 7)
        {
            seven = true;
        }
        N /= 10;
    }
    if (seven)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define mo 998244353
using namespace std;
int n,a[100010],ans=1;
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)ans=1ll*ans*__gcd(i-1,a[i])%mo;
	cout<<ans<<'\n';
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
    public static void main(String[] args){
        char alph[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
        Scanner sc = new Scanner(System.in);
        String str = "";
        while(sc.hasNext()){
            str+=sc.nextLine();
        }
        str=str.toLowerCase();
        int count[] = new int[alph.length];
        for(int i = 0;i < str.length(); i++){
            for(int j = 0; j < alph.length; j++){
                if(str.charAt(i) == alph[j]){
                    count[j]++;
                }
            }
        }
        for(int i = 0; i < alph.length; i++){
            System.out.println(alph[i]+" : "+count[i]);
        }
    }
}


Measured memory_bytes: 26116
n = int(input())
l = [tuple(map(int, input().split())) for _ in range(n)] + [(1<<31, 0)]
mod = 998244353
l.sort()
st = [n]
dp = [0]*n + [1]
for i in range(n-1,-1,-1):
  x,d = l[i]
  v = x + d
  while l[st[-1]][0] < v: st.pop()
  dp[i] = (dp[i+1] + dp[st[-1]]) % mod
  st.append(i)
print(dp[0])

Measured memory_bytes: 42248
#include<iostream>

using namespace std;

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  if(A < B)swap(A,B);
  int res = 0;
  if(A + B >= N){
    res = A - (N - B);
  }
  cout << min(A,B) << " " << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main()
{
	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 && y - r >= 0) {
		if (x + r <= W && y + r <= H)
			std::cout << "Yes" << std::endl;
		else
			std::cout << "No" << std::endl;
	}

	else
		std::cout << "No" << std::endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

int main()
{
	ll a, b, x;
	cin >> a >> b >> x;
	ll ans = b / x - a / x;
	if (a % x == 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
struct A{
    string s;
    int p;
    int order;
};
long long c(long long N,long long mod1,long long mod2){
     long long tmp=(N/mod1)+(N/mod2)-(N/((mod1*mod2)/gcd(mod1,mod2)));
 

     return N-tmp;
}
bool compare_by_b(pair<long, long> a, pair<long, long> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    long long N;

    cin >>N;

    long A[N],B[N];
    vector<pair<long,long>> parray;
    FOR(i,N){
        cin >>A[i]>>B[i];
        parray.push_back(make_pair(A[i],B[i]));
    }
    sort(parray.begin(),parray.end(),compare_by_b);
    bool ans=true;
    long long time=0;
    FOR(i,N){
        time+=parray[i].first;
        if(time>parray[i].second){
            ans=false;
            break;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 8816
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b,c,d = na()
e = a+b
f = c+d

print('Left' if e > f else 'Balanced' if e == f else 'Right')

Measured memory_bytes: 3064
# B - Bounding
def b_bounding
    n,x = gets.chomp.split(/\s/).map{|x| x.to_i}
    ln = gets.chomp.split(/\s/).map{|x| x.to_i}

    bouns = 1
    c = 0
    ln.each do |l|
        c += l
        break if c > x
        bouns += 1 if c <= x
    end

    puts bouns
end
# 3 6
# 3 4 5
# 0 3 7 12

#a_rounding
b_bounding

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

int main(){
	int n;
	cin>>n;
	long long a[3*n];
	long long ans=0;
	for(int i=0;i<3*n;i++){
	    cin>>a[i];
	}
	sort(a,a+3*n);
	bool flg=true;
	int cnt=0;
	int l=3*n-2;
	while(flg){
	    ans+=a[l];
	    l-=2;
	    cnt++;
	    if(cnt==n) flg=false;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    for (int i = 0; i < 3; ++i)
        cin >> a[i];
    int k, t = 0;
    cin >> k;
    for (int i = 1; i < 3; ++i) {
        while (a[i] <= a[i - 1]) {
            a[i] *= 2;
            ++t;
        }
    }
    cout << (t <= k ? "Yes\n" : "No\n");
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

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

  ll N, cnt;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    cnt += va[i] % 2 == 1 ? 1 : 0;
  }

  std::string judge = "YES";
  if (cnt % 2 == 1) {
    judge = "NO";
  }

  std::cout << judge << std::endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<int> X(N), Y(N), Z(N);
	for (int i = 0; i < N; ++ i) {
		string u;
		cin >> X[i] >> Y[i] >> u;
		if (u == "R") Z[i] = 0;
		else if (u == "U") Z[i] = 1;
		else if (u == "L") Z[i] = 2;
		else if (u == "D") Z[i] = 3;
	}
	const ll INF = 1LL<<62;
	ll ans = INF;
	for (int tt = 0; ; ++ tt) {
		map<int, map<int,int>> hoge;
		map<int, map<int,int>> piyo;
		for (int i = 0; i < N; ++ i) {
			if (Z[i] <= 1) {
				hoge[X[i]+Y[i]][X[i]] = Z[i];
			}
			if (Z[i]%2 == 0) {
				piyo[Y[i]][X[i]] = Z[i];
			}
		}
		for (auto& x : hoge) {
			ll z = INF;
			for (auto y : x.second) {
				if (y.second == 0) {
					z = y.first;
				} else if (z != INF) {
					ans = min(ans, (y.first - z) * 10);
				}
			}
		}
		for (auto& x : piyo) {
			ll z = INF;
			for (auto y : x.second) {
				if (y.second == 0) {
					z = y.first;
				} else if (z != INF) {
					ans = min(ans, (y.first - z) * 5);
				}
			}
		}
		if (tt == 3) break;
		for (int i = 0; i < N; ++ i) {
			auto x = X[i];
			auto y = Y[i];
			X[i] = -y;
			Y[i] = x;
			Z[i] = (Z[i] + 1) % 4;
		}
	}
	if (ans == INF) {
		cout << "SAFE" << endl;
	} else {
		cout << ans << endl;
	}
}


Measured memory_bytes: 61240
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
template<typename weight_t> using graph = vector<vector<pair<int,weight_t>>>;
template<typename weight_t> vector<weight_t> dijkstra(const graph<weight_t> &g,const int e){
    using node=pair<int,weight_t>; auto cmp=[](node &a,node &b)->bool {return (a.second>b.second);};
    priority_queue<node,vector<node>,decltype(cmp)> pq(cmp);
    vector<weight_t> w(g.size(),numeric_limits<weight_t>::max());
    vector<bool> done(g.size(),false);
    pq.push({e,0}); w[e]=0; done[e]=true;
    while(!pq.empty()){ auto u=pq.top(); pq.pop(); for(auto &v:g[u.first]){
        if(done[v.first])continue;
        if(w[u.first]+v.second<w[v.first]){
            w[v.first]=w[u.first]+v.second; pq.push({v.first,w[v.first]});
        }}
        done[u.first]=true;
    }
    return w;
}
int main(){
    double xs,ys,xt,yt;
    int n;
    cin >> xs >> ys >> xt >> yt >> n;
    vector<double> x(n+2),y(n+2),r(n+2);
    x[0]=xs;
    y[0]=ys;
    x[1]=xt;
    y[1]=yt;
    rep(i,2,n+2){
        cin >> x[i] >> y[i] >> r[i];
    }
    graph<double> g(n+2);
    auto dist = [&](double xi,double yi,double xj,double yj)->double{
        return sqrt((xi-xj)*(xi-xj)+(yi-yj)*(yi-yj));};
    loop(i,n+1)rep(j,i+1,n+2){
        double d=max(0.0,dist(x[i],y[i],x[j],y[j])-r[i]-r[j]);
        g[i].push_back({j,d});
        g[j].push_back({i,d});
    }
    auto ans=dijkstra(g,0);
    cout << setprecision(10) << ans[1] << endl;
    return 0;
}

Measured memory_bytes: 22512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define MOD 1000000007
#define int long long
#define vi vector<long long int>
#define pb push_back
#define rep(i,a,n) for (int i=(a);i<(n);++i)
using namespace __gnu_pbds;
using namespace std;
// its godfather
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int>vec;
long long power(long long a, long long b, long long m)
{
   long long res = 1;
   while (b > 0)
   {
      if (b & 1)
         res = res * a % m;
      a = a * a % m;
      b >>= 1;
   }
   return res;
}
signed main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(0);

#ifndef ONLINE_JUDGE
   if (fopen("INPUT.txt", "r"))
   {
      freopen("INPUT.txt", "r", stdin);
      freopen("OUTPUT.txt", "w", stdout);
   }
#endif
   int t;
   // cin>>t;
   t=1;
   while(t-->0){
      int i;
      int x;
      cin>>x;
      if(x==0) i=1;
      cin>>x;
      if(x==0) i=2;
      cin>>x;
      if(x==0) i=3;
      cin>>x;
      if(x==0) i=4;
      cin>>x;
      if(x==0) i=5;
      cout<<i<<endl;
   }
}

Measured memory_bytes: 3612
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String str=sc.next();
        sc.close();
        for(int i=0;i<str.length();i++){
            System.out.printf("%c",(str.charAt(i)+n-'A')%26+'A');
        }
        System.out.println();
    }
}

Measured memory_bytes: 31060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	vector<int>n(3);
	rep(i,3)cin>>n.at(i);
	sort(all(n));
	cout<<n.at(0)+n.at(1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
  string S;
  int Q;
  cin >> S >> Q;
  int t,f;
  char c;
  bool flag = true;
  vector<char> F,R;
  int i;
  for(i=0;i<Q;i++) {
    cin >> t;
    if(t == 1)flag = !flag;
    else {
      cin >> f >> c;
      if((flag&&(f == 1))||(!flag&&(f == 2)))F.push_back(c);
      else R.push_back(c);
    }
  }
  if(flag) {
    for(i=F.size()-1;i>=0;i--)cout << F[i];
    cout << S;
    for(i=0;i<R.size();i++)cout << R[i];
    cout << endl;
  }
  else {
    for(i=R.size()-1;i>=0;i--)cout << R[i];
    for(i=S.size()-1;i>=0;i--)cout << S[i];
    for(i=0;i<F.size();i++)cout << F[i];
    cout << endl;
  }
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

n, m = map(int, input().split())
x = list(map(int, input().split()))

x = sorted(x)
diff = [0 for _ in range(m-1)]
for i in range(m-1):
    diff[i] = x[i+1] - x[i]

diff = sorted(diff, reverse=True)
ans = sum(diff[n-1:])
print(ans)

Measured memory_bytes: 20504
n = int(input())
lst = list(map(int,input().split()))

cnt = 0
tmp = 1
if 1 not in lst:
    print(-1)
    exit()
else:
    for i in range(n):
        if lst[i] == tmp:
            tmp += 1
        else:
            cnt += 1
    print(cnt)

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

int main()
{
    ll retu[100] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin >> k;



    cout << retu[k - 1] << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n,x,a,b,c,t;
	while(1) {
		scanf("%d %d", &n, &x);
		t = 0;
		if(n == 0 && x == 0) break;
		
		for(a = 1; a <= n-2; a++) {
			for(b = a+1; b <= n-1; b++) {
				for(c = b+1; c <= n; c++) {
					if(a+b+c == x) {
						t++;
					}
				}
			}
		}
		printf("%d\n",t);
	}

	return 0;
}

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

int main() {
  
  int A=0, B=0;
  
  cin >> A >> B;
  
  int sum = A + B;
  int sub = A - B;
  int mul = A * B;
  
  int ans1 = max(max(sum, sub), mul);
  int ans2 = max(max(sum, mul), sub);
  int ans3 = max(max(sub, mul), sum);
  
  cout << max(max(ans1, ans2), ans3) << endl;
  
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

bool dividable[1000001];
bool counted[1000001];

int main(){
    std::ios::sync_with_stdio(false);

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

    sort(a, a+n);
    int ret = 0;
    for(int i=0;i<n;++i)
    {
      if(dividable[a[i]])
      {
        counted[a[i]] = false;
        continue;
      }

      counted[a[i]] = true;
      for(int j=1;a[i]*j < 1000001;++j){
        dividable[a[i]*j] = true;
      }
    }
    cout << accumulate(counted, counted + 1000001, 0) << endl;
}

Measured memory_bytes: 6252
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
        int n;
        cin >>n;
        bool ans = true;
       for(int i = 0; i< n; i++)
       {
               int a;
               cin >> a;
 
               if(a % 2 == 0)
               {
                       if(a % 3 != 0 && a % 5 != 0){
                               ans = false;
                               break;
                       }
               }
 
       }
        if(ans == true)
        {
                cout << "APPROVED" << endl;
        }
        else
        {
                cout << "DENIED" << endl;
        }
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rp(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep(i, x, n) for (int i = (x); i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

#define TRACE(x...)
#define PRINT(x...)
#define WATCH(x) TRACE(cout << #x << " = " << x << endl )

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin >> n >> k;
    vi h(n), dp(n,numeric_limits<int>::max());
    rp(i,n) cin >> h[i];
    dp[0] = 0;
    rep(i,1,n) {
    	rep(j,1,min(k,i)+1) {
    		dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
    	}
    }
    
    cout << dp[n-1] << '\n';
    
    return 0;
}

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

using namespace std;

const int INF = 1e9;
const int N = 1e4;
const int MOD = 998244353;
const double EPS = 1e-6;

const double PI = acos(-1);




int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1];
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    
    int n;

    cin >> n;

    int sum = 0;

    int tmp = n;
    while(tmp >= 10){
        sum = sum + tmp % 10;
        tmp = tmp / 10;
    }
    sum = sum + tmp;

    if(n % sum ==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
    
    
       
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	map<ll,ll>a;
	a[-1]++;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		a[now]++;
		auto itr=a.lower_bound(now);
		itr--;
		if(itr==a.begin()){
			continue;
		}
		else{
			a[itr->first]--;
			if(itr->second==0){
				a.erase(itr);
			}
			//cout << itr->first;
			//cout << itr->second<<endl;
		}
	}
	ll ans=0;
	for(auto itr=a.begin();itr!=a.end();itr++){
		ans+=itr->second;
	//	cout <<itr->second;
	//	cout << itr->first<<endl;
	}
	cout <<ans-1;
	// your code goes here
	return 0;
}

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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    for (ll i = 0; i < n; i++){
        cin >> h[i];
    }
    if (n <= k){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    sort(h.begin(),h.end());
    for (ll i = 0; i < n; i++){
        if (i < n-k){
            ans += h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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;
    int k = (n+1000-1) / 1000;
    cout << k*1000-n << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    map<int, int> vals_and_no;
    for (int i = 0; i < n; i++) {
        int col;
        cin >> col;
        if (vals_and_no.find(col) == vals_and_no.end()) {
            vals_and_no[col] = 1;
        } else {
            vals_and_no[col]++;
        }
    }
    vector<int> no;
    for (map<int, int>::iterator it = vals_and_no.begin(); it != vals_and_no.end(); it++) {
        no.push_back(it -> second);
    }
    sort(no.begin(), no.end());
    int no_rem = 0;
    int rem = 0;
    while (no.size() - rem > k) {
        no_rem += no[rem];
        rem++;
    }
    cout << no_rem;
}

Measured memory_bytes: 13552
#include <iostream>

using namespace std;

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

    int a[100001];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int num = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 1)
            num += 1;
    }

    if (num % 2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 640
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);
    let mut table = vec![vec![0; 10]; 10];

    if n < 10 {
        println!("{}", n);
        return;
    }

    for k in 1..(n+1) {
        let e = (k as f64).log10() as u32;
        let a = if e > 0 { k / 10_u32.pow(e) as usize} else { k };
        let b = k % 10;
        table[a][b] += 1;
    }

    let mut ans = 0;
    for i in 0..10 {
        for j in 0..10 {
            ans += table[i][j] * table[j][i];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
const double PI = acos(-1) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define max 1000000007

using namespace std;
//int n,m,y,x,h,e,l,o,i,j;

int main()
{
	CIN;
	ll l,m;
	cin>>l;
	string s="";
	
	while(l--)
	{
		m=l%26;//m=(m>0?m--:m=m);
		//s+=(char)('a'+(int)(l%26));
		s+=(char)('a'+m);
		l=l/26;


	}
	reverse(s.begin(),s.end());
	cout<<s;

	//cout<<t<<nw;


	
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,k;
	cin>> n >> k;
	
	int arr[n];
	for(int i =0;i<n;i++)
		cin >> arr[i];
		
	
	sort(arr,arr+n);
	int sum = 0;
	for(int i =0;i<k;i++)
		sum += arr[i];

	cout << sum;
}
	


Measured memory_bytes: 3136
N = int(input())
li = [list(map(int, input().split())) for i in range(N)]

s = 0

for index, i in enumerate(li):
  if i[2] > 0:
    s = index
    break
  
for x in range(101):
  for y in range(101):
    h = li[s][2] + abs(x - li[s][0]) + abs(y - li[s][1])
    ok = True

    for i in li:
      if i[2] > 0 and h != i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False
      if i[2] == 0 and h > i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False

    if ok:
      ans = [x, y, h]

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,z,w; cin >>n>>z>>w;
	vector<int> a(n);
	cinf(n,a);
	if(n==1){
		cout << abs(a[0]-w) << endl;
		return 0;
	}
	else{
		cout << max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])) << endl;
		return 0;
	}
}

Measured memory_bytes: 384
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	N := getInt()
	R := getInt()

	if N >= 10 {
		fmt.Println(R)
	} else {
		fmt.Println(R + 100 * (10 - N))
	}
}

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,k; cin>>a>>b>>k;
  vector<int> v;
  for(int i=min(a,b); i>0; i--) if(!(a%i||b%i)) v.push_back(i);
  cout<<v[k-1];
}

Measured memory_bytes: 3608
// review
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;

int n;
ll a[MAXN];

void solve() {
  ll sum = 0;
  ll oddSum = 0;
  for (int i=0;i<n;i++) {
    sum += a[i];
    if (i & 1) {
      oddSum += a[i];
    }
  }
  ll prev = sum - 2 * oddSum;
  cout << prev;
  for (int i=0;i<n-1;i++) {
    cout << " " << 2 * a[i] - prev;
    prev = 2 * a[i] - prev;
  }
  cout << endl;
}

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


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

int main(){
  int N,K;
  std::cin >> N >> K;

  std::vector<int> A_arr(N);
  for(int i = 0; i < N; i++) std::cin >> A_arr[i];
  int acc = std::accumulate(A_arr.begin(), A_arr.end(), 0);

  int nd = acc;
  for(; nd > 0; nd--){
    if(acc%nd != 0) continue;
    std::sort(A_arr.begin(), A_arr.end(), [nd](int l, int r){return (l%nd)<(r%nd);});
    int l = -1, r = N;
    int pacc = 0, ppacc = 0;
    while(r-l > 1){
      if(pacc < 0){
        l++;
        pacc += A_arr[l]%nd;
        ppacc += A_arr[l]%nd;
      }else{
        r--;
        pacc += (A_arr[r]%nd)-nd;
      }
      if(ppacc > K) break;
    }
    if(ppacc <= K) break;
  }

  std::cout << nd << std::endl;

  return 0;
}



Measured memory_bytes: 384
n = int(input())
x = input()

f = [-1] * (n+10)
f[0] = 0

for i in range(1, n+10):
    # python bitcount で見つけたこれを参考に https://ameblo.jp/316228/entry-10518720149.html
    f[i] = f[i % bin(i).count('1')] + 1

init_bitcount = x.count('1')
# Xを init_bitcount+1とinit_bitcount-1で割った余り

x_mod_01 = 0
x_mod_10 = 0
for digit in x:
    x_mod_01 *= 2
    x_mod_10 *= 2
    if digit == '1':
        x_mod_01 += 1
        x_mod_10 += 1
    x_mod_01 %= (init_bitcount+1)
    if init_bitcount != 1:
        x_mod_10 %= (init_bitcount-1)

# print(x_mod_01, x_mod_10, init_bitcount)

power_mod_01 = [-1] * (n+10)
power_mod_01[0] = 1
for i in range(1, n+10):
    power_mod_01[i] = power_mod_01[i-1] * 2 % (init_bitcount + 1)

if init_bitcount != 1:
    power_mod_10 = [-1] * (n+10)
    power_mod_10[0] = 1
    for i in range(1, n+10):
        power_mod_10[i] = power_mod_10[i-1] * 2 % (init_bitcount - 1)


for i in range(n):
    if x[i] == '0':
        # 0→1
        first_residue = (x_mod_01 + power_mod_01[n - i - 1]) % (init_bitcount+1)
        print(f[first_residue] + 1)
    else:
        if init_bitcount == 1:
            print(0)
            continue
        # 1→0
        first_residue = (x_mod_10 - power_mod_10[n - i - 1]) % (init_bitcount-1)
        print(f[first_residue] + 1)


Measured memory_bytes: 26848
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<assert.h>
#include<stdlib.h>
#include<stack>
using namespace std;
/*********************Contest Template***********************/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<int,int> Cord;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);
struct S{
    int a,b; S(){}S(int _a,int _b){
        a=_a;
        b=_b;
    }
    const bool operator<(const S &o) const{
        return a<o.a;
    }
};
priority_queue<int,vector<int>,greater<int>> mpq;
#define SPACE 0
#define NL 1
inline void showAll(vector<int> &v,int NL_or_space){ 
    //0 is space, 1 is NL
    for(int &here:v){
        printf("%d",here);
        printf("%c",(NL_or_space)?'\n':' ');
    }
}
/*********************Contest Template***********************/
const int SIZE= 100009;

char str[SIZE];

int main(){
	scanf("%s",str+1);

	int cnt1=0,cnt2=0;
	for(int i=1 ; str[i] ; i++){
		if(i&1 && str[i]=='0') cnt1++;
		if(i%2==0 && str[i]=='1') cnt1++;
		if(i&1 && str[i]=='1') cnt2++;
		if(i%2==0 && str[i]=='0') cnt2++;
	}
	printf("%d\n",min(cnt1,cnt2));
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <limits>
#include <type_traits>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  ll n,k;
  cin >> n >> k;
  ll count=(n/k)*(n/k)*(n/k);
  if(k%2 == 0) {
    ll x = n/(k/2) - n/k;
    count += x*x*x;
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  string t;
  for (int i=0; i<s.size(); i++){
    if (s.at(i)=='B') {
      if (!t.empty())
        t.pop_back();
    }
    else
      t.push_back(s.at(i));
  }
  cout << t << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x := intScanner()
	if x == 3 || x == 5 || x == 7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1776
#include<stdio.h>

#define max 100

char array[max][max];

int  main(){
  int u,k,v,i,j,num;

  for(i = 0;i <= max;i++){
    for(j = 0;j <= max;j++){
      array[i][j] = 0;
    }
  }
  scanf("%d",&num);

  for(i = 0;i < num;i++){
    scanf("%d%d",&u,&k);
    while(k--){
      scanf("%d",&v);
      array[u][v] = 1;
    }
  }
  for(i = 1;i <= num;i++){
    for(j = 1;j <= num;j++){
      printf("%d%c",array[i][j],(j == num) ? '\n' : ' ');
    }
  }
  return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    vector<string> vc;
    while( cin >> S ){
        vc.emplace_back( S );
    }
    int tmp{}, tmp2{},  MAX{}, MAXS{}, res{}, res2{};
    REP( i, (int)vc.size() )
    {
        tmp = count( ALL(vc), vc[ i ] );
        tmp2 = vc[ i ].size();
        if( MAX < tmp )
        {
            MAX = tmp;
            res = i;
        }
        if( MAXS < tmp2 )
        {
            MAXS = tmp2;
            res2 = i;
        }
    }
    cout << vc[ res ] << " " << vc[ res2 ] << endl;
    return 0;
}

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

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

    int A, B, C;
    cin >> A >> B >> C;

    cout << ((A * C <= B) ? C : B / A) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t A, B, C;

	scanf("%zu %zu %zu", &A, &B, &C);

	printf("%zu\n", MIN(B/A, C));

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second 
const ll mod=1000000007;
typedef pair<ll,ll> P;
int n;
P a[60];
ll sum=0;
ll qpow(ll x,ll y){
    ll p=1;
    ll ans=0;
    while(y){
        if(y&1){
            ans+=x*p;
            ans%=mod;
        }
        p<<=1;
        y>>=1;
    }
    return ans;
}
int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        ll x;
        cin>>x;
        for(int j=0;j<60;++j){
            if((x>>j)&1) a[j].ff++;
            else a[j].ss++;
        }
    }
    for(int i=0;i<60;i++){
        sum = (sum+1ll*a[i].ff*a[i].ss%mod*((1ll<<i)%mod))%mod;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long n = scanner.nextLong();
        final long a = scanner.nextLong();
        final long b = scanner.nextLong();
        final long c = scanner.nextLong();
        final long d = scanner.nextLong();
        final long e = scanner.nextLong();

        final long min = Math.min(Math.min(Math.min(a, b), Math.min(c, d)), e);
        /*
        if (min == a) {
            System.out.println(split(n, a) + 5);
        } else if (min == b) {
            System.out.println(split(n, b) + 4);
        } else if (min == c) {
            System.out.println(split(n, c) + 3);
        } else if (min == d) {
            System.out.println(split(n, d) + 2);
        } else {
            System.out.println(split(n, e) + 1);
        }
         */
        System.out.println(split(n,min) + 4);
        scanner.close();
    }

    private static long split(final long a, final long b) {
        if (a % b == 0) return a / b;
        else return a / b + 1;
    }
}


Measured memory_bytes: 22612
from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))
rui = [0] * (N + 1)
for i in range(N):
    rui[i + 1] = rui[i] + a[i]

d = defaultdict(int)
for key in rui:
    d[key] += 1

sortd = sorted(d.items(), key=lambda x: x[1], reverse=True)

cnt = 0
for i, j in sortd:
    if j >= 2:
        cnt += (j * (j - 1) // 2)
print(cnt)

Measured memory_bytes: 48660
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	ll n, k, q;
	cin>>n>>k>>q;
	vll a(n, 0);
	rep(i, q){
		ll an;
		cin>>an;
		a[an-1]++;
		
	}
	rep(i, n){
		if(k-(q-a[i])>0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}


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


int main(){
    ll N,M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M)
    {
        cin >> A[i];
    }

    int tmp = N;
    rep(i,M)
    {
        tmp -= A[i];
    }

    if(tmp >= 0)
    {
        cout <<tmp;
    }else
    {
        cout<< -1;
    }
    

    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>
#include <functional>

using namespace std;
using ll = long long;

#define all(x) (x).begin(),(x).end()
#define PRI(n) cout << n << " "<<endl;
#define PRI2(n, m) cout << n << " " << m << " "<<endl;

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

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

struct edge;
struct UnionFind;

bool isPrime(ll x);

ll GCD(ll a, ll b);

ll LCM(ll a, ll b);

ll nCr(int n, int r);


struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int N) {
        for (int i = 0; i < N; ++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

ll M, N;
int F[100][10];
int P[100][10];
int A[2][100];

int main() {
    cin >> N >> M;
    if (N == 1 && M == 1)PRI(1)
    else if (N == 1 && M > 1)PRI(M - 2)
    else if (N > 1 && M == 1)PRI(N - 2)
    else
        PRI((N - 2) * (M - 2))
    return 0;
}

struct edge {
    int to, cost;
    bool flag = false;
};

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) for (int j = min(i, r); j < 1; --j)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
int main(void){
 int a,i,n;
 long long min,max,sum;
    scanf("%d",&n);
    scanf("%d",&a);
   min=a;
   sum=a;
   max=a;

    for(i=0;1;i++){
        scanf("%d",&a);
        if(i==n-1)break;
        if(a<=min)
        {min=a;}
        if(a>=max)
        {max=a;}
        sum=sum+a;}
printf("%d %d %ld\n",min,max,sum);
}



Measured memory_bytes: 2760
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(ll i=a;i<=(ll)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
 
int main() {
    cs
    int n,ans=0;cin>>n;
    vector<int> v(n);
    vector<int> vv(n);
    vector<int> vvv(n-1);
    for(auto &i:v) cin>>i;
    for(auto &i:vv) cin>>i;
    for(auto &i:vvv) cin>>i;
    rep(i,n) {
        ans+=vv[v[i]-1];
        if(i&&v[i]-v[i-1]==1) ans+=vvv[v[i]-2];
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int n, m;
struct Node {
	//int id;
	list<int> next;
};
Node graph[100005];
int prenum[100005];
int parent[100005];
int lowest[100005];
set<int> answer;
int rootCount;
void dfs(int curNodeId,int step) {
	int low = prenum[curNodeId];
	list<int>::iterator it = graph[curNodeId].next.begin();
	list<int>::iterator end = graph[curNodeId].next.end();
	for (it; it != end; it++) {
		int id = *it;
		if (prenum[id] == 0) {
			parent[id] = curNodeId;
			prenum[id] = step + 1;
			dfs(id, step + 1);
			low = min(low, lowest[id]);
			if (step == 1) {
				rootCount++;
			}
		}
		else {
			low = min(low, prenum[id]);
		}
	}
	lowest[curNodeId] = low;
}
void findArticulationPoint() {
	if (rootCount >= 2) {
		answer.insert(0);
	}
	int p;
	for (int i = 1; i < n; i++) {
		p = parent[i];
		if (p == 0) {
			continue;
		}
		if (prenum[p] <= lowest[i]) {
			answer.insert(p);
		}
	}
	vector<int> ans;
	for (set<int>::iterator it = answer.begin(); it != answer.end(); it++) {
		ans.push_back(*it);
	}

	sort(ans.begin(), ans.end());

	for (vector<int>::iterator it = ans.begin(); it != ans.end(); it++) {
		printf("%d\n", *it);
	}
}
int main() {
	scanf("%d %d", &n,&m);
	int a, b;
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a,&b);
		graph[a].next.push_back(b);
		graph[b].next.push_back(a);
	}

	prenum[0] = 1;
	dfs(0,1);

	findArticulationPoint();

	/*for (int i = 0; i < n; i++) {
		cout << i << " " << prenum[i] << " " << parent[i] << " " << lowest[i] << endl;
	}*/
}



Measured memory_bytes: 8500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int MOD = 1e9+7;
const int MAXN = 1e5+5;
vector<int> graph[MAXN];
ll dp[MAXN][2]; 
int n;
 
void DFS(int curr, int par)
{
    dp[curr][0] = dp[curr][1] = 1;
 
    for(auto& neighbor : graph[curr])
    {
        if(neighbor == par) continue;
        DFS(neighbor, curr);
        (dp[curr][0] *= dp[neighbor][1]) %= MOD;
        (dp[curr][1] *= (dp[neighbor][0] + dp[neighbor][1]) % MOD) %= MOD;
    }
}
int CeilIndex(std::vector<ll>& v, int l, int r, int key) 
{ 
    while (r - l > 1) { 
        int m = l + (r - l) / 2; 
        if (v[m] >= key) 
            r = m; 
        else
            l = m; 
    } 
  
    return r; 
}
ll LongestIncreasingSubsequenceLength(std::vector<ll>& v,std::vector<ll>& b) 
{ 
    if (v.size() == 0) 
        return 0; 
  
    std::vector<ll> tail(v.size(), 0); 
  	std::vector<ll> sum(v.size(), 0); 
    int length = 1; 
  
    tail[0] = v[0]; 
  	sum[0]=b[0];
  	ll isum=0;
    for (size_t i = 1; i < v.size(); i++) { 
        if (v[i] < tail[0]) {
            tail[0] = v[i]; 
          	sum[0]=max(sum[0],b[i]);
        }
  
        else if (v[i] >= tail[length - 1]){ 
            tail[length] = v[i]; 
          	sum[length]=sum[length-1]+b[i];
          	length++;
        }
  
        else{
          	int ind=CeilIndex(tail, -1, length - 1, v[i]);
            tail[ind] = v[i];
            sum[ind] = max(sum[ind],sum[ind-1]+b[i]); 
        }
      
    } 
    return *max_element(sum.begin(),sum.end()); 
} 
 
vector<vector<ll>> MatMul(vector<vector<ll>> a, vector<vector<ll>> b)
{
    vector<vector<ll>> ans(n, vector<ll>(n));
    int k;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            for(ans[i][j] = k = 0; k < n; ++k)
            {
                ll temp = (a[i][k] * b[k][j]) % MOD;
                ans[i][j] = (ans[i][j] + temp) % MOD;
            }
        }
    }
    return ans;
}
 
vector<vector<ll>> MatPow(vector<vector<ll>> base, ll p)
{
    vector<vector<ll>> ans(n, vector<ll>(n));
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            ans[i][j] = (i==j);
        }
    }
 
    while(p)
    {
        if(p&1) ans = MatMul(ans, base);
        base = MatMul(base, base);
        p /= 2;
    }
 
    return ans;
}
 
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    ll k;
    cin >> n >> k;
    vector<vector<ll>> adjMat(n, vector<ll>(n));
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            cin >> adjMat[i][j];
        }
    }
    vector<vector<ll>> res = MatPow(adjMat, k);
    ll ans = 0;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            ans += res[i][j];
            if(ans >= MOD) ans -= MOD;
        }
    }
    cout << ans << "\n";
    return 0; 
}

Measured memory_bytes: 2688
integer(8) N
integer(8),allocatable,dimension(:)::work,dead
integer(8) timeline
read*,N
allocate(work(N),dead(N))
do i=1,N
  read*,work(i),dead(i)
end do

call heapsort(n,dead,work)

timeline=0
!$omp parallel
do i=1,N
  timeline=timeline+work(i)
  if(timeline>dead(i))then
    print"(A)","No"
    Stop
  end if
end do
!$omp end parallel

print"(A)","Yes"

contains

subroutine heapsort(n,array,b)
  implicit none
  integer(8),intent(in) :: n
  integer(8),intent(inout) :: array(1:n),b(1:n)
  integer(8)::i,k,j,l
  integer(8):: t,tb

  l=n/2+1
  k=n
  !$omp parallel
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
        tb=b(L)
     else
        t=array(k)
        tb=b(k)
        array(k)=array(1)
        b(k)=b(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           b(1)=tb
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           b(i)=b(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     b(i)=tb
  enddo
  !$omp end parallel
  return
end subroutine heapsort
end


Measured memory_bytes: 3328