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

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

    int five = 0;
    int seven = 0;

    for (int i = 0; i < 3; i++) {
        int temp;
        cin >> temp;
        if (temp == 5) {
            five++;
        } else if (temp == 7) {
            seven++;
        }
    }
    if (five == 2 && seven == 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  int a,b,c,d;
  IN4(a,b,c,d);
  int takahashi,aoki;
  takahashi = (double)c / (double)b + 0.999999;
  aoki = (double)a / (double)d + 0.999999;
  if (aoki >= takahashi){
    OUT("Yes");
  }
  else
  {
    OUT("No");
  }
  
}

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

int main(void)
{
    int A,B;
    cin >> A >> B;
    int C;
    C = A - B * 2;
    if(C < 0)
        C = 0;

    cout << C;
    return (0);
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	
	int ans[n] = {0};
	for(int i = 0; i < m; i++)
	{
		int a,b;
		cin >> a >> b;
		
		ans[a - 1]++;
		ans[b - 1]++;
	}
	
	for(int i = 0; i < n; i++)
	{
		cout << ans[i] << endl;
	}
}


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


using namespace std;  
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const double eps = 1e-14;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl  
#define DIV 1000000007

int main(){
	map<ll,ll> data;
	ll N,K; cin >> N >> K;
	for(int i = 0; i < N; i++){
		ll a,b; cin >> a >> b;
		data[a] += b;
	}
	for(int i = 1; i < 1000000; i++){
		K -= data[i];
		if(K <= 0){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    char c; cin >> c;
    if(c >= 'a' && c <= 'z'){
        cout << 'a' << endl;
    }
    else{
        cout << 'A' << endl;
    }

}

Measured memory_bytes: 3628
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, k = MAP()
p = LIST()
p.sort()
print(sum(p[:k]))

Measured memory_bytes: 72640
#include <cstdio>
#include <iostream>
 
using namespace std;
 
int main(){
     
    char n[10][10];
     
    for(int i = 0;i < 8;i++){
    cin >> n[i];
    }
     
    cout << "90" << endl;
     
    for(int i = 0;i < 8;i++){
        for(int j = 7;j >= 0;j--){
            cout << n[j][i];
        }
        cout << endl;
    }
     
    cout << "180" << endl;
     
    for(int i = 7;i >= 0;i--){
        for(int j = 7;j >= 0;j--){
        cout << n[i][j];
        }
        cout << endl;
    }
     
    cout << "270" << endl;
     
    for(int i = 7;i >= 0;i--){
        for(int j = 0;j < 8;j++){
        cout << n[j][i];
        }
        cout << endl;
    }
     
    return 0;
     
}


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int N; cin >> N;
    string s; cin >> s;
    int K; cin >> K;

    char c = s[K - 1];
    REP( i, s.size() ){
        if( s[i] != c ) cout << '*';
        else cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
A,B,K = map(int, input().split())
ans = []
for i in range(A, A+K):
  ans.append(i)
for i in range(B-K+1, B+1):
  ans.append(i)
ans = list(set(ans))
ans.sort(reverse=False)
for i in ans:
  if i>=A and i<=B:
    print(i)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> id(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    --p[i];
    id[p[i]] = i;
  }
  vector<int> dp(n, 0);
  for (int i = 0; i < n; i++) {
    dp[p[i]] = 1;
    if (p[i]) dp[p[i]] = dp[p[i] - 1] + 1;
  }
  cout << n - *max_element(dp.begin(), dp.end()) << '\n';
  return 0;
}


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

using namespace std;
const int maxn = 1e5 + 5;
int v[101], n, W, w[101];
long long f[101][maxn];

long long dp(int i, int weight)
{
    if (weight > W) return -1e12;
    if (i > n) {
        if (weight <= W) return 0;
        else return -1e12;
    }
    long long &res = f[i][weight];
    if (res != -1) return res;
    res = dp(i + 1, weight);
    res = max(res, dp(i + 1, weight + w[i]) + v[i]);
    return res;
}

int main()
{
    #ifdef NTMA 
        freopen("abc.inp", "r", stdin);
    #endif
    memset(f, 255, sizeof(f));
    cin >> n >> W;
    for(int i=1; i<=n; ++i) cin >> w[i] >> v[i];
    cout << dp(1, 0) << endl;
}

Measured memory_bytes: 79104
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
const long nPrime = 1000000007;

//素数の逆元
long Inverse(const long &n){
    //nPrime = 1000000007
    if (n % nPrime == 0){
        return 0;
    }
    long a = n, b = nPrime, u = 1, v = 0;
    while (b > 0) {
        long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= nPrime;
    if (u < 0){
        u += nPrime;
    }
    return u;    
}

int main(){
    long n;
    scanf("%ld", &n);
    vector <long> vi(n+1, 0);
    long k;
    for(long i = 1; i <= n+1; i++){
        long a;
        scanf("%ld", &a);
        if(vi[a] != 0){
            k = n + (vi[a] - i);    //aの外側の個数 (a:2個存在するやつ)
        }
        vi[a] = i;
    }
    
    vector <long> vnCombi(n+1,1);  //(n+1)Ci
    vector <long> vkCombi(k+1,1);  //kCi
    vector <long> vnMinusCombi(n,1);  //(n-1)Ci
    vector <long> vnMinusMinusCombi(n-1,1);  //(n-2)Ci
    for(long i = 1; i < n+1; i++){
        vnCombi[i] = vnCombi[i - 1] * (n - i + 1);
        vnCombi[i] %= nPrime;
        vnCombi[i] *= Inverse(i);
        vnCombi[i] %= nPrime;
        if(i < n){
            vnMinusCombi[i] = vnMinusCombi[i - 1] * (n - i);
            vnMinusCombi[i] %= nPrime;
            vnMinusCombi[i] *= Inverse(i);
            vnMinusCombi[i] %= nPrime;
        }
        if(i < n-1){
            vnMinusMinusCombi[i] = vnMinusMinusCombi[i - 1] * (n - i - 1);
            vnMinusMinusCombi[i] %= nPrime;
            vnMinusMinusCombi[i] *= Inverse(i);
            vnMinusMinusCombi[i] %= nPrime;
        }
        if(i < k+1){
            vkCombi[i] = vkCombi[i - 1] * (k - i + 1);
            vkCombi[i] %= nPrime;
            vkCombi[i] *= Inverse(i);
            vkCombi[i] %= nPrime;
        }
    }
    
    for(int i = 1; i <= n; i++){
        long nAns = vnCombi[i];  //n個からi個取る
        nAns += vnMinusCombi[i-1];  //もう一方のaを取って固定して(n-1)個から(i-1)個取る
        if(i <= k+1){
            nAns -= vkCombi[i-1];  //aの取り方によらないやつ(外側k個からi-1個取ったやつ)
        }
        if(i >= 2){
            nAns += vnMinusCombi[i-2];  //a2つ使うやつ
        }
        nAns %= nPrime;
        if(nAns < 0){
            nAns += nPrime;
        }
        printf("%ld\n", nAns);
    }
    printf("1\n");
  
    return 0;
}


Measured memory_bytes: 6644
using System;


public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[n, m];
        var b = new int[m];
        for (int i = 0; i < n; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < m; j++)
                a[i, j] = int.Parse(line2[j]);
        }
        for (int i = 0; i < m; i++)
            b[i] = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var total = 0;
            for (int j = 0; j < m; j++)
                total += a[i, j] * b[j];
            Console.WriteLine(total);
        }
    }
}

Measured memory_bytes: 9328
using System;
using System.Linq;

namespace AtCoderAbc160
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var sSplit = s.Split();
            var k = int.Parse(sSplit[0]);
            var n = int.Parse(sSplit[1]);

            s = Console.ReadLine();
            var a = s.Split().Select(int.Parse).ToArray();

            var p = new Problem3();
            Console.WriteLine(p.GetAnswer(k, n, a));
        }
    }

    public class Problem3
    {
        public int GetAnswer(int k, int n, int[] a)
        {
            Array.Sort(a);

            var maxDistance = 0;
            for (int i = 0; i < a.Length; i++)
            {
                int distance;
                if (i == a.Length - 1)
                {
                    distance = a[0] + k - a[i];
                }
                else
                {
                    distance = a[i + 1] - a[i];
                }
                maxDistance = Math.Max(distance, maxDistance);
            }
            return k - maxDistance;
        }
    }
}


Measured memory_bytes: 36444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
int n,k;
int s = (n+1) * (n + 2) / 2;
const int INF = 1<<29;

int kosu(int x){
    return ((2*n-x+1)*x/2 - x*(x-1) /2 +1); 
}

int main(){
    cin >> n >> k;
    ll ans = 0;
    vector<ll> a(n+2,0);
    for(int i=1;i<=n+1;i++){
        a[i] = ll(i-1)*(ll(i))/2;
    }
    //cout << a.size() << endl;
    /*
    for(auto x:a){
        cout << x << endl;
    }
    */
    
    for(int i=k;i<=n+1;i++){
        ll min = a[i];
        ll max = a[n+1] - a[n-i+1];
        //cout << i << " " << min << " " << max << endl;
        ans += max - min + 1;
        ans = ans%MOD;
    }
    cout << ans%MOD << endl;

}

Measured memory_bytes: 4784
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define repst(p) for(int i=begin[p],q;i;i=next[i])if((q=to[i])!=h)
inline void check_min(int a,int &b){if(a<b)b=a;}
namespace BoDaJingShen
{
	int abs(int x){return x<0?-x:x;}
	const int N=100100,M=N*2;
	struct disjoint_set_union
	{
		int q[N];
		void init(int n){for(int i=1;i<=n;i++)q[i]=i;}
		int ask(int p){return p==q[p]?p:q[p]=ask(q[p]);}
		inline void link(int u,int v){q[ask(u)]=ask(v);}
		inline bool uni(int u,int v){return ask(u)==ask(v);}
	}d;
	int begin[N],next[M],to[M];
	int dep[N],fa[N],s[N];
	bool fob[N];
	int n,m,e,ans,sx,sy;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	void predfs(int p,int h=0)
	{
		repst(p)fa[q]=p,dep[q]=dep[p]+1,predfs(q,p);
	}
	int dfs(int p,int h=0)
	{
		if(fob[p])return 0;
		int ret=s[p];
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
				ret+=dfs(q,p);
		ans+=abs(ret);
		return ret;
	}
	void initialize()
	{
		scanf("%d%d",&n,&m);
		d.init(n);
		for(int i=1,u,v;i<=m;i++)
		{
			scanf("%d%d",&u,&v);
			if(d.uni(u,v))sx=u,sy=v;
			else add(u,v),d.link(u,v);
		}
		if(!sx)sx=1;
		predfs(sx);
		for(int i=1;i<=n;i++)s[i]=(dep[i]&1)?1:-1;
	}
	int t0[N*8],*c=t0+N*4;
	int stk[N],f[N*2],tot;
	inline void push(int &p){fob[p]=1,stk[++tot]=p,p=fa[p];}
	void work0()
	{
//		while(1)printf("?\n");
//		printf("%d\n",dfs(1));
		if(dfs(1)){printf("-1\n");return;}

		tot=0;
		while(sx!=sy)push(sy);
		push(sx);
		
		ans=0;
		for(int i=1;i<=tot;i++)
		{
			fob[stk[i]]=0;
			ans-=abs(f[i+tot]=f[i]=dfs(stk[i]));
			fob[stk[i]]=1;

//			printf("%d ",f[i]);
		}
//		printf("\n");

//		printf("ans=%d\n",ans);

		for(int i=1;i<=tot;i++)
			ans+=abs(f[i]+=f[i-1]),c[f[i]]++;

//		printf("ans = %d\n",ans);

		int ret=ans,cnt=0;
		for(int i=1;i<=n;i++)cnt+=c[i];

//		f[tot]=0;
		for(int i=tot+1;i<2*tot;i++)
		{

//			printf("cnt = %d\n",cnt);

			int x=-f[i];
			if(x>0)
			{
				while(x--)
				{
					ret+=cnt+c[0]-(tot-cnt-c[0]);
					cnt+=c[0];
					c=c-1;
				}
				c[0]--;
			}
			else
			{
				x=-x;
				while(x--)
				{
					ret+=(tot-cnt)-cnt;
					c=c+1;
					cnt-=c[0];
				}
				c[0]--;
			}
			f[i]+=f[i-1];

			int y=f[i]-f[i-tot];
			ret+=abs(y);

//			printf("fn = %d\n",f[i]);

			c[y]++;
			if(y>0)cnt++;

//			printf("%d : %d\n",i-tot,ret);
			check_min(ret,ans);
		}
		printf("%d\n",ans);
	}
	void work1()
	{
		int tmp=0,k;
		for(int i=1;i<=n;i++)tmp+=s[i];
		if(tmp&1){printf("-1\n");return;}
		ans=abs(tmp/2);
		k=tmp>0?-1:1;
		s[sx]+=k*ans;
		s[sy]+=k*ans;
		if(dfs(sx))printf("fuck\n");
		printf("%d\n",ans);
	}
	void solve()
	{
		initialize();
		if(m==n-1)
		{
			ans=0;
			if(dfs(sx)==0)printf("%d\n",ans);
			else printf("-1\n");
		}
		else 
		{
			if((dep[sx]&1)==(dep[sy]&1))work1();
			else work0();
		}
	}
}
int main()
{
	BoDaJingShen::solve();
	return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));
  reverse(ALLOF(v));

  ll ret = 0;
  int cnt = 0;
  rep(i,N){
    if(i==0){
      ret += v[i];
      cnt++;
    }else{
      int x = max(0, min(2, N-1-cnt));
      ret += v[i] * x;
      cnt += x;
    }
  }

  cout << ret << endl;
  
  return 0;
}


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

const ll INF = 5e15;
ll N, M;
vector<vector<ll>> edges(1e5);
vector<vector<ll>> reve(1e5);

vector<ll> top_sort(const vector<vector<ll>> &edges){
	vector<ll> ret;
	vector<bool> road(N);
	vector<bool> used(N);
	function<bool(ll)> dfs = [&](ll now){
		used[now] = true;
		road[now] = true;
		for(ll nxt : edges[now]){
			if(road[nxt]) return false;
			if(used[nxt]) continue;
			if(!dfs(nxt)) return false;
		}
		ret.push_back(now);
		road[now] = false;
		return true;
	};
	for(ll i = 0; i < edges.size(); i++){
		if(used[i]) continue;
		if(!dfs(i)) return vector<ll>(0);
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

int main(){
    cin >> N >> M;
    edges.resize(N);
    reve.resize(N);
    for(ll i = 0; i < N + M - 1; i++){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        reve[b].push_back(a);
    }
    auto ts = top_sort(edges);
    vector<ll> pos(N);
    for(ll i = 0; i < N; i++) pos[ts[i]] = i;
    vector<ll> ans(N);
    for(ll i = 0; i < N; i++){
        if(reve[i].size() == 0){
            ans[i] = 0;
            continue;
        }
        ll look = reve[i][0];
        for(ll e : reve[i]){
            if(pos[look] < pos[e]) look = e;
        }
        ans[i] = look + 1;
    }
    for(ll e : ans) cout << e << '\n';
    return 0;
}


Measured memory_bytes: 17396
N, k=map(int, input().split())
flag=0
if N>=k:
    NN=N-k+1
    M=k-1
    flag=1
else:
    M=N
if M==0:
    print(1/1)
    exit(0)
lls=[]
l=1
while True:
    if 2**l >=k:
        break
    else:
        l+=1
lls.append(l)
if M>=2:
    for s in range(2,M+1):
        for i in range(l,-1,-1):
            if 2**i <k/s:
                lls.append(i+1)
                break
s=0
for i in range(len(lls)):
    s+=0.5**lls[i]
print(s/N if flag==0 else (s+NN)/N)


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var l = readLine()!!.split(' ').map(String::toInt).sorted()
    var sum = 0
    for (i in l.indices) {
        if (i % 2 == 0) sum += l[i]
    }
    println(sum)
}

Measured memory_bytes: 22584
#include<iostream>

using namespace std;

int main(void) {
	int q;
	int l, r;
	bool prime[100001] = {};
	int c[100001] = {};

	for (int i = 2; i <= 100000; i++) {
		if (!prime[i]) {
			for (int j = i+i; j <= 100000; j+=i) {
				prime[j] = true;
			}
		}
	}

	for (int i = 3; i <= 100000; i+=2) {
		if (prime[i] == false && prime[(i + 1) / 2] == false) {
			c[i]++;
		}
	}

	for (int i = 3; i <= 100000; i++) {
		c[i] += c[i - 1];
	}

	cin >> q;

	for (int i = 1; i <= q; i++) {
		cin >> l >> r;

		cout << c[r] - c[l - 1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
 
int keta(int n){
  if(n / 10 == 0){
    return(n);
  }
  else{
    return(n % 10 + keta(n / 10));
  }
}
 
int main()
{
  int n;
  cin >> n;
  if(n % keta(n) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(){
  int h, w;
    cin >> h >> w;
  char g[h][w];
  string ans = "Yes";

    for(int i=0; i<h; i++)
      for(int j=0; j<w; j++) cin >> g[i][j];

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        if(g[i][j]=='#'){
          if(g[i+dx[0]][j+dy[0]] == '#' || g[i+dx[1]][j+dy[1]] == '#' || g[i+dx[2]][j+dy[2]] == '#' || g[i+dx[3]][j+dy[3]] == '#')
            continue;
          ans = "No";
          break;
        }
      }
    }
    cout << ans << endl;


}

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

int const MAX = 200002;
long long const MAX_A = 1000000000000000002;
long long a[MAX];
long long l[MAX / 2 + 2], r[MAX / 2 + 2];

long long Merge(long long a[], int left, int mid, int right) {
	int i, j;
	long long cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++) {
		l[i] = a[left + i];
	}
	for (i = 0; i < n2; i++) {
		r[i] = a[mid + i];
	}
	l[n1] = MAX_A; r[n2] = MAX_A;
	i = 0; j = 0;
	for (int k = left; k < right; k++) {
		if (l[i] <= r[j]) {
			a[k] = l[i];
			i++;
		}
		else {
			a[k] = r[j];
			j++;
			cnt += n1 - i;
		}
	}
	return cnt;
}
long long MergeSort(long long A[], int left, int right) {
	int mid;
	long long v1, v2, v3;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		v1 = MergeSort(A, left, mid);
		v2 = MergeSort(A, mid, right);
		v3 = Merge(A, left, mid, right);
		return v1 + v2 + v3;
	}
	else { return 0; }
}

int main() {
	long long n;
	long long k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= k;
	}
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
		a[i] += a[i - 1];
	}
	long long inv;
	inv = MergeSort(a, 0, n+1);
	cout << n * (n + 1) / 2 - inv << endl;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> b(N);
	for(int i=0;i<N;i++)	cin >> b.at(i);

	vector<int> ans;
	for(int i=N-1;i>=0;i--){
		int max=-1;
		for(int j=i;j>=0;j--){
			if(b.at(j)==j+1){
				max=j+1;
				break;
			}
		}
		//cout << max << ",";
		if(max==-1){
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(max);
		b.erase(b.begin()+max-1);
	}

	for(int i=N-1;i>=0;i--)	cout << ans.at(i) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


typedef unsigned long long ull;
ull B = 1e8 + 7;
const int maxn = 300001;
vector<ull> v(maxn);

void build(string a) {
    int al = (int)a.length();
    
    vector<ull> t(maxn);
    t[0] = 1;
    rep(i, al - 1) t[i + 1] = t[i] * B;
    
    rep(i, al) {
        v[i + 1] += v[i] + t[al - 1 - i] * a[i];
    }
}


int main() {
    int n, m;
    cin >> n >> m;
    
    string str;
    cin >> str;
    
    set<ull> s;
    build(str);
    
    int l = 1, r = 1;
    rep(i, m) {
        string t;
        cin >> t;
        
        if (t == "L++") {
            l++;
        } else if (t == "L--") {
            l--;
        } else if (t == "R++") {
            r++;
        } else {
            r--;
        }
        
        // cout << l << " " << r << " " << v[r] << " " << v[l - 1] << endl;
        s.insert((v[r] - v[l - 1]) * pow(B, l - 1));
    }
    cout << sz(s) << endl;
    
    // cout << endl; rep(i, sz(str) + 1) cout << v[i] << endl;
    // cout << endl; for (auto e : s) cout << e << endl;
}



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

int main() {
	int hosuu;
	int kakudo;
	double x, y = 0;
	double degree = M_PI/2;
	char comma;
	while(1) {
		cin >> hosuu >> comma >>  kakudo;
		if(hosuu == 0 && kakudo ==0) break;
		else {
			x += cos(degree) * hosuu;
			y += sin(degree) * hosuu;
			degree -= (double)kakudo / 180 * M_PI;
		}
	}
	cout << int(x) << endl;
	cout << int(y) << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

string s;
int k, l;
int n[101];
int dp[2][101][4];

int main(){
    cin >> s >> k;
    l = s.size();
    for (int i = 0; i < l; ++i) n[i] = s[i] - '0';
    memset(dp, sizeof(dp), 0);
    dp[0][0][0] = 1;   // For sure
    dp[0][0][1] = n[0]-1;
    dp[1][0][1] = 1;   // Not for sure
    for (int i = 1; i < l; ++i){
        dp[0][i][0] = dp[0][i-1][0];
        if (n[i] == 0) dp[1][i][0] = dp[1][i-1][0];
        else dp[0][i][0] += dp[1][i-1][0];
        for (int j = 1; j <= k; ++j){
            dp[0][i][j] = dp[0][i-1][j] + dp[0][i-1][j-1]*9;
            if (n[i] == 0){
                dp[1][i][j] = dp[1][i-1][j];
            }
            else{
                dp[0][i][j] += dp[1][i-1][j] + dp[1][i-1][j-1]*(n[i] - 1);
                dp[1][i][j] = dp[1][i-1][j-1];
            }
        }
    }
    cout << (dp[0][l-1][k] + dp[1][l-1][k]);
}

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

int main(){
  long N;
  cin >> N;
  vector<pair<long,long>> BA(N);
  for(int i=0; i<N; i++){
    cin >> BA[i].second >> BA[i].first;
  }
  sort(BA.begin(),BA.end());
  
  long time=0;
  bool T=1;
  for(int i=0; i<N; i++){
    time+=BA[i].second;
    if(time>BA[i].first){
      T=0;
    }
  }
  if(T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; ++i)
        cin >> s[i];

    int ans = 0;
    int aCnt = 0;
    int bCnt = 0;
    bool isBoth = true;
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<s[i].size()-1; ++j){
            if(s[i].substr(j, 2) == "AB")
                ++ ans;
        }
        if(s[i].back() == 'A')
            ++ aCnt;
        if(s[i].front() == 'B')
            ++ bCnt;
        if((s[i].back() == 'A') ^ (s[i].front() == 'B'))
            isBoth = false;
    }

    if(aCnt > 0 && aCnt == bCnt){
        if(isBoth)
            ans += aCnt - 1;
        else
            ans += aCnt;
    }
    else{
        ans += min(aCnt, bCnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, const char *argv[])
{
  int n; char s[100001];
  scanf("%d", &n);
  scanf("%s", s);

  for (int i = 0; i < (1 << 2); i++) {
    bool t[100010];
    t[0] = i & 1;
    t[1] = i & (1 << 1);
    int k = 2;
    while (k <= n + 1) {
      if (!t[k - 1] && s[(k - 1) % n] == 'o') t[k] = t[k - 2];
      if (!t[k - 1] && s[(k - 1) % n] == 'x') t[k] = !t[k - 2];
      if (t[k - 1] && s[(k - 1) % n] == 'o') t[k] = !t[k - 2];
      if (t[k - 1] && s[(k - 1) % n] == 'x') t[k] = t[k - 2];
      k++;
    }

    if (t[n] == t[0] && t[n + 1] == t[1]) {
      for (int j = 0; j < n; j++) {
	if (!t[j]) printf("S");
	else printf("W");
      } endl;
      return 0;
    }
  }
  printf("-1\n");

  return 0;
}
    
    
    


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

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

    int H1,M1,H2,M2,K; cin >> H1 >> M1 >> H2 >> M2 >> K;
    int t=(H2-H1)*60+M2-M1;
    cout << t-K << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
ifstream fin("date.in");
using ll = long long;
string s;
int k;
int main() {
	cin >> s;
	for (int i = 0; i < s.length(); i++)
		k = (k + s[i] - '0') % 9;
	if (k == 0)
		cout << "Yes";
	else
		cout << "No";
    return 0;
}


Measured memory_bytes: 3744
n = gets.to_i

x = []
y = []

n.times { |i|
  items = gets.chomp.split(/ /).map { |e| e.to_i }
  x << items[0]
  y << items[1]
}

patterns = (1..n).to_a.permutation(n).to_a
length = 0

patterns.each { |pattern|
  (pattern.size - 1).times { |i|
    length += Math.sqrt((x[pattern[i]-1]-x[pattern[i+1]-1]) ** 2 + (y[pattern[i]-1]-y[pattern[i+1]-1]) ** 2)
  }
}

puts length / patterns.size



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

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r > 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans = (a * b) / gcd(a,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import namedtuple


class Card(namedtuple('Card', ('suit', 'value'))):
    __slots__ = ()

    def __str__(self):
        return self.suit + str(self.value)


def bubble_sort(cards):
    n = len(cards)
    for i in range(n):
        for j in range(n - 1, i, -1):
            if cards[j - 1].value > cards[j].value:
                cards[j - 1], cards[j] = cards[j], cards[j - 1]


def selection_sort(cards):
    n = len(cards)
    for i in range(n):
        minj = min(range(i, n), key=lambda j: cards[j].value)
        if i != minj:
            cards[i], cards[minj] = cards[minj], cards[i]


cards = [Card(suit, value) for suit, value in sys.stdin.readlines()[1].strip().split()]

bubbled = cards[:]
bubble_sort(bubbled)
print(' '.join([str(c) for c in bubbled]))
print('Stable')

selected = cards[:]
selection_sort(selected)
print(' '.join([str(c) for c in selected]))
print('Stable' if selected == bubbled else 'Not stable')



Measured memory_bytes: 6044
import java.util.*;
public class Main {
        public static void main(String[] args){
                 Scanner sc = new Scanner(System.in);
                 int S = sc.nextInt();
                 int W = sc.nextInt();
                 if(W>=S){
                   System.out.println("unsafe");
                 }else{
                  System.out.println("safe");
                  } 
        }
  
  
}

Measured memory_bytes: 35848
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<vector<int> > grid(n, vector<int>(m));
    vector<int> a(k);
    forn(i, k) cin >> a[i];
    forn(i, n)
    {
        if (i % 2 == 0)
        {
            for (int j = 0; j < m; j++)
            {
                for (int x = 0; x < k; x++) if (a[x] > 0) {a[x]--, grid[i][j] = x + 1; break;}
            }
        }
        else
        {
            for (int j = m - 1; j >= 0; j--)
            {
                for (int x = 0; x < k; x++) if (a[x] > 0) {a[x]--, grid[i][j] = x + 1; break;}
            }
        }
    }
    forn(i, n)
    {
        forn(j, m)
        {
            cout << grid[i][j] << " ";
        }
        cout << "\n";
    }
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 384
MOD = 10**9 + 7

def MOD_perm(n, r):
    rtn = 1
    for _ in range(r):
        rtn *= n
        rtn %= MOD
        n -= 1
    return rtn

def MOD_inv(a):
    b = MOD
    u = 1
    v = 0
    while b > 0:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u = u % MOD
    if u < 0:
        u += MOD
    return u

def main():
    n = int(input())
    x = list(map(int, input().split()))
    ans = 0
    inv = 0
    perm = MOD_perm(n-1, n-1)
    for i in range(1, n):
        dif = x[i] - x[i-1]
        inv += MOD_inv(i)
        inv %= MOD
        ans += dif * perm * inv
        ans %= MOD
    print(ans % MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20300
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

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

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int n, k;

vector<vector<int>> graph;

int dfs(int pre, int v, int &cnt) {
    int height = 0;
    for (int to: graph[v]) chmax(height, dfs(v, to, cnt) + 1);
    if (pre != 0 && k - 1 <= height) {
        cnt++;
        height = -1;
    }
    return height;
}

int main() {
    cin >> n >> k;
    graph.resize(n);
    vector<int> a(n);
    cin >> a;
    rep(i, n) a[i]--;
    repr(i, 1, n) graph[a[i]].push_back(i);
    
    int cnt = 0;
    dfs(0, 0, cnt);
    if (a[0] != 0) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100000000
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

ll power(int a,int n){
	ll ans=1;
	while(n){
		if(n%2==0){
			a*=a;
			n/=2;
		}
		else{
			ans*=a;
			n--;
		}
	}
	return ans;
}

int main(){
	fast;
	int x;
	cin>>x;
	if(x==1){
		cout<<1<<' '<<0;
		return 0;
	}
	ll a,b;
	bool flag=1;
	int i,j;
	for( i=-2500;i<=2500;i++){
		a=power(i,5);
		for( j=-2500;j<=2500;j++){
			b=power(j,5);
			if(a-b==x){
				flag=0;
				break;
			}
		}
		if(!flag)	break;
	}
	cout<<i<<' '<<j;
}

Measured memory_bytes: 3608
from functools import partial
from itertools import islice


def take(n, iterable):
    return list(islice(iterable, n))


def chunked(iterable, n):
    return iter(partial(take, n, iter(iterable)), [])


def solve(string):
    n, m, *ab = map(int, string.split())
    ab = sorted([tuple(_ab) for _ab in chunked(ab, 2)])
    cl = cr = None
    ans = 0
    for a, b in ab:
        if cr is None or cr <= a:
            cl, cr = a, b
            ans += 1
            continue
        cl, cr = max(cl, a), min(cr, b)
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


Measured memory_bytes: 27396
N = int(input())
P = list(map(int,input().split()))
color = [0] * 9

for i in range(N):
    if P[i] >= 3200:
        color[8] += 1
    elif 3200 > P[i] >= 2800:
        color[7] += 1
    elif 2800 > P[i] >= 2400:
        color[6] += 1
    elif 2400 > P[i] >= 2000:
        color[5] += 1
    elif 2000 > P[i] >= 1600:
        color[4] += 1
    elif 1600 > P[i] >= 1200:
        color[3] += 1
    elif 1200 > P[i] >= 800:
        color[2] += 1
    elif 800 > P[i] >= 400:
        color[1] += 1
    elif 400 > P[i]:
        color[0] += 1

if color[8] != 0 and color.count(0) == 8:
    ans1 = 1
    ans2 = color[8]
elif color[8] == 0:
    ans1 = 9 - color.count(0)
    ans2 = ans1 + color[8]
else:
    ans1 = 9 - color.count(0) - 1
    ans2 = ans1 + color[8]

print(ans1, ans2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
ll a[maxn];
ll s[maxn];
int main(){
   ll n,time;
   scanf("%lld%lld",&n,&time);
  // ll sum=0;
   ll maxx=0;
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&a[i]);
   }
   for(int i=1;i<=n;i++)
   {
       s[i]=s[i-1]+a[i];
       if(a[i]>maxx)
       {
           maxx=a[i];
       }
       if(time>=s[i])
       {
         printf("%lld\n",(time-s[i])/maxx+2);
       }
       else
       {
           printf("1\n");
       }
   }
  return 0;
}


Measured memory_bytes: 4776
N = int(input())

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

lis = [i for i in A if i%2 == 0 ]

lis2 = [i for i in lis if i%3 != 0]

lis3 = [i for i in lis2 if i%5 != 0]

if len(lis3) > 0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include<stdio.h>
int main()

{
    int a,b,c,d=0,i;
    scanf("%d%d%d",&a,&b,&c);
    if(1<=a&&a<=10000&&1<=b&&b<=10000&&1<=c&&c<=10000)
    {
        for(i=a;i<=b;i++)
        {
            if(c%i==0)
                d++;
        }
        printf("%d\n",d);
    }

}



Measured memory_bytes: 2104
use proconio::input;

// use std::f64::consts::PI;
// use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;
use proconio::marker::Usize1;

const MOD: u64 = 1000000007;

fn main() {
    input! {
        w: usize,
        h: usize,
        n: u32,
        K:[(usize,usize,u32);n]
    }
    let mut x = vec![0; w];
    let mut y = vec![0; h];
    for k in K {
        if k.2 == 1 {
            for i in 0..k.0 as usize {
                x[i] = 1;
            }
        }
        if k.2 == 2 {
            for i in k.0..w as usize {
                x[i] = 1;
            }
        }
        if k.2 == 3 {
            for i in 0..k.1 as usize {
                y[i] = 1;
            }
        }
        if k.2 == 4 {
            for i in k.1..h as usize {
                y[i] = 1;
            }
        }
    }
    let mut xc = 0;
    let mut yc = 0;
    for v in x{
        if v==0{xc+=1;}
    }
    for v in y{
        if v==0{yc+=1;}
    }
    println!("{}", xc*yc);

}


Measured memory_bytes: 2076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n =sc.nextInt();
		for (int i = 0;; i++) {
			long p = (long)Math.pow(3, i);
			if(n <= p){
				System.out.println(i);
				break;
			}
		}
	}

}

Measured memory_bytes: 17372
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

ll a,b,k;

int main(){
	scanf("%lld%lld%*lld%lld",&a,&b,&k);
	printf("%lld\n",(k&1)?b-a:a-b);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int a,b,c;cin>>a>>b>>c;
    if(a==b && a==c){
        if(a%2||b%2||c%2)cout<<0<<endl;
        else cout<<-1<<endl;
    }else{
        int cnt=0;
        int u,v,w;
        while(1){
            if(a%2||b%2||c%2)break;
            else{
                cnt++;
                u=(b+c)/2;
                v=(c+a)/2;
                w=(a+b)/2;
                a=u;
                b=v;
                c=w;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define int long long
signed main() {
	int a, b;
	cin >> a >> b;
	int ans = a - 1;
	if (a <= b) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Mon struct {
	x, h int
}

type Mons []Mon

func (a Mons) Len() int           { return len(a) }
func (a Mons) Less(i, j int) bool { return a[i].x < a[j].x }
func (a Mons) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, D, A := sc.nextInt(), sc.nextInt(), sc.nextInt()
	M := make([]Mon, N)
	for i := 0; i < N; i++ {
		M[i] = Mon{sc.nextInt(), sc.nextInt()}
	}
	sort.Sort(Mons(M))
	Mx := []int{}
	Sum := []int{}
	Sum = append(Sum, 0)
	ans := 0
	for i := 0; i < N; i++ {
		mon := M[i]
		ok := len(Mx)
		ng := -1
		for abs(ok-ng) > 1 {
			mid := (ok + ng) / 2
			if mon.x <= Mx[mid] {
				ok = mid
			} else {
				ng = mid
			}
		}
		sum := 0
		if ok != len(Mx) {
			sum = Sum[len(Sum)-1] - Sum[ok]
		}
		if sum < mon.h {
			diff := mon.h - sum
			count := ceil(diff, A)
			ans += count
			Mx = append(Mx, mon.x+2*D)
			Sum = append(Sum, Sum[len(Sum)-1]+count*A)
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  string s;
  cin>>s;
  if(s=="SUN") cout<<7<<endl;
  if(s=="MON") cout<<6<<endl;
  if(s=="TUE") cout<<5<<endl;
  if(s=="WED") cout<<4<<endl;
  if(s=="THU") cout<<3<<endl;
  if(s=="FRI") cout<<2<<endl;
  if(s=="SAT") cout<<1<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int count=0;
    while(true){
        if(n%111==0){
            cout << n << endl;
            return 0;
        }
        else if(n>111){
            n-=111;
            count++;
        }
        else{
            cout << (count+1)*111 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256