akhauriyash/Code-Regression huggingface dataset:
def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
            A[j+g] = v
    return cnt
    
def shellsort(A,n):
    cnt = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    G.reverse()
    m = len(G)
    print(m)

    print(" ".join(map(str,G)))
    for i in range(m):
        cnt += insertionSort(A,n,G[i])
    print(cnt)
    for i in A:
        print(i)
        
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
shellsort(A,n)




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

int main(){

    bitset<18> subset, T;
    
    int n, k, b;
    cin >> n >> k;
    while (k--){
        cin >> b;
        T[b] = 1;
    }

    for(int i = 0; i < (1 << n); i++){
        subset = i;
        if((subset | T) == subset){
            cout << i << ":";            
            for (int j = 0; j < n; j++){
                if (subset[j]){
                    cout << ' ' <<  j;
                }
            }
            cout << endl;            
        }

    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4+7;
int dp[maxn] = {1};
int Wight[10] = {0,2,5,5,4,5,6,3,7,6},A[10];
int n,m;
signed main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)scanf("%d",&A[i]);
    for(int i=1;i<=m;i++)
        for(int j=Wight[A[i]];j<=n;j++)
            dp[j] = max(dp[j],dp[j-Wight[A[i]]]+1);
    sort(A+1,A+1+m);
    while(n){
        if(dp[n] == dp[n-Wight[A[m]]]+1)
            printf("%d",A[m]),n -= Wight[A[m]];
        else m--;
    }
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] h = new long[n];
        for (int i = 0; i < h.length; i++) {
            h[i] = sc.nextLong();
        }

        if( n <= k){
            System.out.println(0);
        }else{
            long ans = 0;
            Arrays.sort(h);
            for (int i = 0; i < n-k; i++) {
                ans += h[i];
            }
            System.out.println(ans);
        }


    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 24796
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    ll ans = 0;
    char now;

    rep(j, k){
        for(int i = j; i < n; i += k){
            if (i == j) {
                if (t[i] == 'r'){
                    now = 'p';
                    ans += p;
                }
                if (t[i] == 's'){
                    now = 'r';
                    ans += r;
                }
                if (t[i] == 'p'){
                    now = 's';
                    ans += s;
                }
            }
            else {
                if (t[i] == 'r' && now == 'p'){
                    if (i + k < n && t[i+k] == 'r') now = 's';
                    if (i + k < n && t[i+k] == 's') now = 's';
                    if (i + k < n && t[i+k] == 'p') now = 'r';
                }
                else if(t[i] == 'r'){
                    now = 'p';
                    ans += p;
                }
                if (t[i] == 's' && now == 'r'){
                    if (i + k < n && t[i+k] == 'r') now = 's';
                    if (i + k < n && t[i+k] == 's') now = 'p';
                    if (i + k < n && t[i+k] == 'p') now = 'p';
                }
                else if(t[i] == 's'){
                    now = 'r';
                    ans += r;
                }
                if (t[i] == 'p' && now == 's'){
                    if (i + k < n && t[i+k] == 'r') now = 'r';
                    if (i + k < n && t[i+k] == 's') now = 'p';
                    if (i + k < n && t[i+k] == 'p') now = 'r';
                }
                else if(t[i] == 'p'){
                    now = 's';
                    ans += s;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


const ll MOD=1000000000+7;



ll mod_pow(ll x, ll n, ll m)
{
	ll ret = 1LL;
	for(;n>0;n>>=1)
	{
		if(n&1) ret=(ret*x)%m;
		x=(x*x)%m;
	}
	return ret;
}


ll mod_inv(ll x, ll m)
{
	return mod_pow(x, m-2, m)%m;
}


ll nCr(int n, int r)
{
	ll bunbo=1, bunsi=1;

	if(r*2>n) r=n-r;
	for(int i=0;i<r;i++)
	{
		bunbo=bunbo*(n-i)%MOD;
		bunsi=bunsi*(i+1)%MOD;
	}
	return bunbo*mod_inv(bunsi, MOD)%MOD;
}


ll calc(int n, int d)
{
	if(n<=0) return 0LL;
	if(d<=0) return 0LL;
	if(n<d) return 0LL;
	return nCr(n-1, d-1);
}


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		for(int i=1;i<=k;i++)
		{
			ll ans=0;
			if(i==1 && n==k) ans=1;
			ans+=calc(k, i)*calc(n-k, i-1)  %MOD;
			ans+=calc(k, i)*calc(n-k, i  )*2%MOD;
			ans+=calc(k, i)*calc(n-k, i+1)  %MOD;
			ans%=MOD;
			printf("%lld\n", ans);
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

int main(){
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	REP(i,n) cin >> a[i] >> b[i];
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	
	if(n%2){
		cout << b[n/2]-a[n/2]+1 << endl;
	}else{
		cout << b[n/2-1]+b[n/2]-(a[n/2-1]+a[n/2])+1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4764
n = int(input())
a = list(map(int,input().split()))

now = 1
ok = False

a.sort()

for i in range(len(a)):
	now *= a[i]
	if now > 1000000000000000000 :
			print(-1)
			ok = True
			break

if ok == False:
	print(now)




Measured memory_bytes: 21644
import bisect
import math
import sys
 
jd = []
for i in range(1,50) :
  jd.append((1+i)*i//2)
  
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

n = int(input())

if n == 1 :
  print(0)
  sys.exit()

p = factorization(n)

ans = 0
for i in p :
  c = i[1]
  ans += bisect.bisect_right(jd, c)
  
print(ans)

Measured memory_bytes: 9452
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int A,B,C; scanf("%d %d %d", &A, &B, &C);
	int v = B/A;

	int ans = min(v,C);
	printf("%d\n", ans);


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl; 
	return 0;
}

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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    int A[N+1];
    FOR(i,0,N) cin >> A[i];

    if (N == 0 && A[0] == 0) { cout << -1; return 0; }

    long long D[N+1] = {0};
    RFOR(i,N-1,0){
        D[i] = D[i+1] + A[i+1];
    }

    D[0] = min(D[0],1LL-A[0]);
    if (D[0] < 0) { cout << -1; return 0; }
    FOR(i,1,N){
        D[i] = min(D[i],D[i-1]*2-A[i]);
        if (D[i] < 0) { cout << -1; return 0; }
    }

    long long t = D[0] + A[0];
    FOR(i,1,N){
        if (D[i-1] > D[i]+A[i] || D[i-1]*2 < D[i]+A[i]) {
            cout << -1;
            return 0;
        }
        t += D[i] + A[i];
    }
    cout << t;
}



Measured memory_bytes: 4824
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n;
string S;

ll ans;
map<pair<string, string>, ll> mp;

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

	string s1 = S.substr(0, n);
	string s2 = S.substr(n);
	reverse(s2.begin(), s2.end());

	for (int i = 0; i < 1 << n; i++) {
		string r, b;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) r += s1[j];
			else b += s1[j];
		}
		mp[make_pair(r, b)]++;
	}

	for (int i = 0; i < 1 << n; i++) {
		string r, b;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) r += s2[j];
			else b += s2[j];
		}
		ans += mp[make_pair(r, b)];
	}

	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 91904
#include <iostream>
#include <vector>
#include <utility>
#include <string>
using namespace std;

int main() {

	//数字
	int X,Y,A,B;
	cin >> X >> Y;
  	cin >> A >> B;
	if(X!=A){
    cout << 1 << endl;
    }else{
    cout << 0 << endl;
    }


	
}


Measured memory_bytes: 256
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
  ll X,K,D,res;
  cin >> X >> K >> D;
  if(X<0) X = -X;
  ll div = X/D;
  if(div >= K){
    res = X-K*D;
  } else if((K-div)%2==0){
    res = X-div*D;
  }else{
    res = X-(div+1)*D;
  }
  
  cout << abs(res);
}

Measured memory_bytes: 3632
use num_integer::gcd;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut ans = 0;
    for i in a.iter() {
        ans = gcd(*i, ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

const int MAX_V = 100005;

struct edge { int to; long w; };
vector<edge> G[MAX_V];
long loc[MAX_V];
bool seen[MAX_V];

bool dfs(int s){
    seen[s] = true;
    for(auto& e : G[s]){
        if(seen[e.to]){
            if(loc[e.to] != loc[s] + e.w) return false;
        }
        else{
            loc[e.to] = loc[s] + e.w;
            if(!dfs(e.to)) return false;
        }
    }
    return true;
}

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

    rep(i, m){
        int l, r; long d; cin >> l >> r >> d; l--; r--;
        G[l].push_back(edge{r, d});
        G[r].push_back(edge{l, -d});
    }

    rep(i, n){
        if(!seen[i]){
            bool ok = dfs(i);
            if(!ok){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int K; cin >> K;
	string s; cin >> s;
	if (K >= s.size()) {
		cout << s << "\n";
	}
	else cout << s.substr(0, K) << "..." << "\n";

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()%
#define int long long

signed main(){
    int n, l;
    cin >> n >> l;
    int minimum = INT_MAX, taste = 0;
    reps(i,l,l+n-1){
        if(abs(minimum) > abs(i)){
            minimum = i;
        }
        taste += i;
    }
    cout << taste - minimum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
const int INF=0x3f3f3f3f;
int a[1000],n,m;
int main()
{
	int i,j,k,ans=0,mind=999999;
	cin>>n>>m;
	memset(a,0,sizeof(a));
	for(i=0;i<m;i++)
	{
		int x;
		cin>>x;
		a[x+100]=1;
	}
	for(i=0;i<=101;i++)
	{
		if(a[i+100]==0 && abs(i-n)<mind)
		{
			ans=i;
			mind=abs(i-n);
		}
	}
	for(i=0;i>=-100;i--)
	{
		if(a[i+100]==0 && abs(i-n)<mind)
		{
			ans=i;
			mind=abs(i-n);
		}
	}
	if(m==0)
	{
		cout<<n<<endl;
	}
	else
		cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3196
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		char[] moji = S.toCharArray();
		for(int i = 0; i < moji.length; i ++){
			System.out.print((char)(mojiAdd(moji[i], N)));
		}
		System.out.println();
	}

	public static int mojiAdd(char moji, int N){
		if((int)(moji) + N > 90){
			return (int)(moji) + N - 26;
		}else{
			return (int)(moji) + N;
		}
	}
}


Measured memory_bytes: 26452
#include <stdio.h>

  int main(){
  int i,j,k,v,N;
  int A[100];

  scanf("%d",&N);

   for(i=0;i<N;i++){
     scanf("%d",&A[i]);
  }

  for(i=0;i<N;i++){
if(i==N-1){
printf("%d\n",A[i]);
}
else  printf("%d ",A[i]);
  }

  for(i=1;i<N;i++){
  v=A[i];
  j=i-1;

  while(j>=0&&A[j]>v){
  A[j+1]=A[j];
  j--;
  A[j+1]=v;
}
  for(k=0;k<N;k++){
    if(k==N-1){
      printf("%d\n",A[k]);
    }
    else    printf("%d ",A[k]);
    }
  }
    return 0;
  }



Measured memory_bytes: 2080
#include<stdio.h>


int main(){

  int n, p, cup, c[60];
  int i;

  while(scanf("%d %d", &n ,&p), n){
    cup=p;
    for(i=0;i<n;i++) c[i]=0;

    while(1){
      
      for(i=0;i<n;i++){
	if(cup!=0){
	  c[i]++;
	  cup--;
	  if(c[i]==p) break;
	}else if(c[i]!=0){
	  cup=c[i];
	  c[i]=0;
	}
      }
      if(i<n&&c[i]==p) break; 
    }
    printf("%d\n", i);
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
  int count=0,n;
  string s;
  cin>>n>>s;
  for(int i=0;i<n-2;i++)
  {
    while((s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'))
       {
         count++;
         i=i+2;
       }
       }
       cout<<count;
       return 0;
       }

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

const int MAX_N = int(1e5);
int n;
int times_odd[MAX_N + 1];
int times_even[MAX_N + 1];

void solve() {
    int max_odd = 0, second_odd = 0, max_odd_num = 0, second_odd_num = 0;
    int max_even = 0, second_even = 0, max_even_num = 0, second_even_num = 0;
    REP(i, MAX_N + 1) {
        if (max_even <= times_even[i]) {
            second_even_num = max_even_num, max_even_num = i;
            second_even = max_even, max_even = times_even[i];
        } else if (second_even < times_even[i]) {
            second_even_num = i;
            second_even = times_even[i];
        }
        if (max_odd <= times_odd[i]) {
            second_odd_num = max_odd_num, max_odd_num = i;
            second_odd = max_odd, max_odd = times_odd[i];
        } else if (second_odd < times_odd[i]) {
            second_odd_num = i;
            second_odd = times_odd[i];
        }
    }


    if (max_odd_num == max_even_num) {
        if (second_odd > second_even) {
            cout << n / 2 - second_odd + n / 2 - max_even << endl;
        } else {
            cout << n / 2 - second_even + n / 2 - max_odd << endl;
        }
    } else {
        cout << n / 2 - max_odd + n / 2 - max_even << endl;
    }
}

int main() {
    cin >> n;
    int temp;
    REP(i, n) {
        cin >> temp;
        if (i % 2 == 0) times_even[temp]++;
        else times_odd[temp]++;
    }
    solve();
    return 0;
}

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

using namespace std;

const int NMAX = 2e5 + 5;

int N, A[NMAX];

long long fr[NMAX], ans;

static inline void Read ()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N;

    for(int i = 1; i <= N; ++i)
        cin >> A[i], ++fr[A[i]];

    return;
}

int main ()
{
    Read();

    for(int i = 1; i <= N; ++i)
        if(fr[i] > 1)
            ans += 1LL * (1LL * fr[i] * (fr[i] - 1LL)) / 2LL;

    for(int i = 1; i <= N; ++i)
    {
        long long Now = ans;

        if(fr[A[i]] > 1)
        {
            Now -= 1LL * (1LL * fr[A[i]] * (fr[A[i]] - 1LL)) / 2LL;

            --fr[A[i]];

            Now += 1LL * (1LL * fr[A[i]] * (fr[A[i]] - 1LL)) / 2LL;

            ++fr[A[i]];
        }

        cout << Now << '\n';
    }

    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);
	ll n, d, x, y, ans = 0;
	cin >> n >> d;
	d*= d;
	for(int i = 0; i < n && cin >> x >> y; i++){
		ans += d >= (x*x + y*y);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3648
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		
		int min_cost = 1001;
		int c = 0;
		int t = 0;
		
		for(int i=0; i<N; i++){
			c = sc.nextInt();
			t = sc.nextInt();
			if(t <= T){
				if(c < min_cost){
					min_cost = c;
				}
			}
		}
		if(min_cost == 1001){
			System.out.println("TLE");
		}
		else{
			System.out.println(min_cost);
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n,b=0,c;
    cin>>n;
    long long int a[n];
    for(int j=0;j<n;j++){
       cin>>a[j];
    }
    for(int i=0;i<n;i++){
        c=a[i];
        while(c%2==0){
            c=c/2;
            b++;
        }
    }
    cout<<b<<endl;
    return 0;
}


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

int main () {
  string n;
cin >> n;
if (n[0] == '9') {
  cout << "Yes" << endl;
return 0;
}
  if (n[1] == '9') {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3588
//#include "bits/stdc++.h"

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

const int none = 0;
const int open = 1;
const int close = -1;

int n;
int w;
int h;

inline void hit(vector<int>& vec, int pos, int range) {
	int start = max(0, pos - range);
	int end = min((int) vec.size() - 1, pos + range);
	vec[start] += open;
	vec[end] += close;
}

inline bool check(vector<int>& vec) {
	int state = 0;
	for (size_t i = 0; i < vec.size() - 1; i++) {
		state += vec[i];
		// std::cout << "debug state " << state << std::endl; // debug
		if (state <= 0) {
			return false;
		}
	}
	return true;
}

void print(const vector<int>& vec) {
}

int main() {

	cin >> n >> w >> h;
	w++;
	h++;
	vector<int> vec_w(w, none);
	vector<int> vec_h(h, none);
	for (int i = 0; i < n; i++) {
		int x;
		int y;
		int range;
		cin >> x >> y >> range;
		hit(vec_w, x, range);
		hit(vec_h, y, range);
		//print(vec_w);
		//print(vec_h);
		//cout << endl;
	}
	if (check(vec_w) or check(vec_h)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    map<string, int> mp;
    vector<pair<string, int>> v;
    for (int i = 0; i < n; i++) {
        char s[11];
        scanf("%s", s);
        mp[s] = mp[s] + 1;
    }

    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        v.push_back(make_pair(itr->first, itr->second));
    }

    sort(v.begin(), v.end(), [](const pair<string, int> x, const pair<string, int> &y) {
        return x.second != y.second ? x.second > y.second : x.first.compare(y.first) < 0;
    });
    
    int max = v[0].second;
    for (auto itr = v.begin(); itr != v.end() && itr->second == max; ++itr) {
        printf("%s\n", itr->first.c_str());
    }
    return 0;
}

Measured memory_bytes: 28144
n,k = gets.split.map(&:to_i)
if (n-1)*(n-2)/2 < k
    puts "-1"
    exit
end
if n == 2 && k == 0
    puts 1,"1 2"
    exit
end
if k < n-2
    ans = []
    (n-k-2).times do |i|
        (n-i-1).times do |j|
            ans << [i+1,i+j+2]
        end
    end
    (k+1).times do |i|
        ans << [n-i,n-i-1]
    end
else
    sum = (n-1)*(n-2)/2
    m = n-1
    # while (1)
    100.times do
        if (sum-(m-2) <= k)
            break
        else
            sum -= m-2
            m -= 1
        end
    end
    ans = []
    m.times do |i|
        ans << [1,i+2]
    end
    ((m+2)..n).each do |i|
        ans << [i-1,i]
    end
    (sum-k).times do |i|
        ans << [2,i+3]
    end
end
s = ans.size
puts s
s.times do |i|
    puts ans[i].join(" ")
end

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

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

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

  string result = "No";
  map<char, int> mp;
  for (char c:s) {
    mp[c]++;
  }
  if (mp.size() == 2) {
    for (auto v:mp) {
      if (v.second == 2) {
        result = "Yes";
      }
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[]

  for i in range(n):
    l.append([i,I()])

  l2=copy.deepcopy(l)

  l2=sorted(l2,key=lambda x:x[1])

  ans=0
  for i,x in enumerate(l2):
    if i%2!=x[0]%2:
      ans+=1
  return ans//2

# main()
print(main())


Measured memory_bytes: 46284
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5,MOD = 998244353;
#define int long long
int n,s;
int a[N],f[N];
int ans;
signed main() {
	scanf("%lld%lld",&n,&s);
	for(int i = 1;i <= n;++i)
		scanf("%lld",a+i);
	f[a[1]] = 1;
	for(int i = 2;i <= n;++i) {
		for(int j = s;j > a[i];--j)
			(f[j] += f[j-a[i]]) %= MOD;
		(f[a[i]] += i) %= MOD;
		(ans += f[s] % MOD) %= MOD;
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 256
s=input()
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
elif s=='SAT':
    print(1)

Measured memory_bytes: 3060
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

const int MAX = 100005;

struct Node
{
    int key;
    Node *parent, *left, *right;
};

int n;
Node *root, *NIL;

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL)
    {
        root = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
}

void insert()
{
}
void Preorder(Node *u)
{
    cout << " " << u->key;
    if (u->left != NIL)
        Preorder(u->left);

    if (u->right != NIL)
        Preorder(u->right);
}

void Inorder(Node *u)
{

    if (u->left != NIL)
        Inorder(u->left);
    cout << " " << u->key;
    if (u->right != NIL)
        Inorder(u->right);
}

void Postorder(Node *u)
{

    if (u->left != NIL)
        Postorder(u->left);

    if (u->right != NIL)
        Postorder(u->right);
    cout << " " << u->key;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        if (s == "insert")
        {
            int v;
            cin >> v;
            insert(v);
        }
        else if (s == "print")
        {
            Inorder(root);
            cout << endl;
            Preorder(root);
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 26544
#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()
using ll = long long;
using P = pair<int, int>;

int Q, l[100005], r[100005];
bool isPrime[100005];
int sum[100005] = {0};

int main() {
    cin >> Q;
    rep(i, Q) cin >> l[i] >> r[i];

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

    for (int i=3; i<=100000; i++) {
        if (i%2==1) {
            sum[i] = sum[i-1] + (isPrime[i]&&isPrime[(i+1) / 2]);
        } else {
            sum[i] = sum[i-1];
        }
    }

    rep(i, Q) {
        cout << sum[r[i]] - sum[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
    ll n;
    cin >> n;
    vector<ll> a;
    a.resize(n + 1);
    for (ll i = 0; i < n; i++) cin >> a[i];

    ll sum = 0;
    ll ans = 0;
    ll r = 0;
    for (ll l = 0; l < n; l++) {
        while ((sum ^ a[r]) == sum + a[r] && r < n) {
            sum += a[r];
            r++;
        }
        ans += r - l;
        sum ^= a[l];
    }
    cout << ans;
    return 0;
}

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

int main() {
  int a,b;
  cin >> a>>b;
  int ans=0;
  rep2(i,a,b+1){
    if(i/10000==i%10&&(i-i/10000*10000)/1000==(i-1%10)/10%10){
      ans++;
    }
  }
 
  cout<<ans<<endl;
 
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,j;
	
	scanf("%d %d",&i,&j);
	
	if(i % 3 == 0 || j % 3 == 0 || (j+i) % 3 == 0){
		printf("Possible\n");
	}
	else {
		printf("Impossible\n");
	}
	
	return(0);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String... args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int rooms[][][] = new int[4][3][10];
        for(int i = 0;i < 4;i++){
            for(int j = 0;j < 3;j++){
                for(int k = 0;k < 10;k++){
                    rooms[i][j][k] = 0;
                }
            }
        }

        for(int i = 0;i < n;i++){
            int b = scan.nextInt();
            int f = scan.nextInt();
            int r = scan.nextInt();
            int v = scan.nextInt();
            rooms[b-1][f-1][r-1] += v;
        }

        for(int i = 0;i < 4;i++){
            for(int j = 0;j < 3;j++){
                for(int k = 0;k < 10;k++){
                    System.out.print(" ");
                    System.out.print(rooms[i][j][k]);
                }
                System.out.println();
            }
            if(i != 3)System.out.println("####################");
        }

        scan.close();
    }
    

}


Measured memory_bytes: 28960
function Main(input){
  var N = input.split("\n")[0];
  N = parseInt(N,10);
  var V = input.split("\n")[1].split(" ");
  var C = input.split("\n")[2].split(" ");
  var A = [];
  for(i=0;i<=(N-1);i++){
    V[i] = parseInt(V[i],10);
    C[i] = parseInt(C[i],10);
  }
  for(i=0;i<=(N-1);i++){
    A[i] = V[i] - C[i];
  }
  var sum = 0;
  for(i=0;i<=(N-1);i++){
    var max = Math.max(...A);
    var Mnum = A.indexOf(max);
    if(max>=0){
      sum += max;
      A.splice(Mnum,1);
    }else{
      break;
    }
    
  }
  console.log(sum);

  
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));



Measured memory_bytes: 7500
import numpy as np
N, K = map(int, input().split())
s = input()
S = []
S.append(1)
for c in s:
    S.append(int(c))
S.append(1)
#print(S)

Blocks = 2 * K + 1
l = len(S)
count = 0
Zone = []
for i in range(l-1):
    count += 1 
    if S[i] != S[i+1]:
        Zone.append(count)
        count = 0
        
if S[l-2] != S[l-1]:
    Zone.append(1)
else:
    Zone.append(count+1)

#print(Zone)
Persons = []
if Blocks >= len(Zone):
    print(N)
else:
    Persons.append(sum(Zone[0:Blocks]))
    j = 0
    while Blocks + j < len(Zone):
        Persons.append(Persons[int(j/2)]+Zone[Blocks+j]+Zone[Blocks+j+1]-Zone[j]-Zone[j+1])
        j += 2
    Persons[0] -= 1
    Persons[len(Persons)-1] -= 1
    #print(Persons)
    print(max(Persons))
        
    

        

Measured memory_bytes: 15732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

struct segtree{
	int N; vector<int> dat;
	segtree(int N_):dat(N_*4){
		int x=1;
		while(N_>x){x*=2;}
		N=x;
	}
	void update(int i, int x){
		i+=N-1;
		dat[i]=x;
		while(i>0){
			i=(i-1)/2;
			dat[i]=dat[i*2+1]|dat[i*2+2];//演算
		}
	}
	int query(int a, int b){
		return query_sub(a,b,0,0,N);
	}
	int query_sub(int a, int b, int k, int l, int r){
		if(r<=a||b<=l)
			return 0;//モノイド
		else if(a<=l&&r<=b)
			return dat[k];
		else{
			int vl=query_sub(a,b,k*2+1,l,(l+r)/2);
			int vr=query_sub(a,b,k*2+2,(l+r)/2,r);
			return vl|vr;//演算
		}
	}
};

int main(){
	int n; cin >> n;
	string s; cin >> s;
	segtree tr(n);
	REP(i,n){
		tr.update(i,1<<(s[i]-'a'));
	}
	int q; cin >> q;
	while(q--){
		int a; cin >> a;
		if(a==1){
			int b; char c;
			cin >> b >> c;
			tr.update(b-1,1<<(c-'a'));
		}
		else{
			int l, r;
			cin >> l >> r;
			int k=tr.query(l-1,r);
			int ans=0;
			REP(i,26) ans+=(k>>i)&1;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 11680
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int r;
int main()
{
	cin>>r;
	cout<<r*r<<endl;
	return 0;
}

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

using namespace std;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (a+b==c+d){
        cout<<"Balanced"<<endl;
    }
    else if (a+b>c+d){
        cout<<"Left"<<endl;
    }
    else{
        cout<<"Right"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,mod=1000000007,i,j,k,pas,n;
long long f(long long q){
	if(q<=1) return 0;
	q--;
	return (q*(q+1)/2);
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>k;
	for(i=k; i<=n+1; i++){
		pas+=f(n+1)-f(n+1-i)-f(i)+1;
		pas%=mod;
	}
	cout<<pas;
	return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

long find(long x, vector<long> &vec) {
  if (vec[x] == 0) return x;
  long root = find(vec[x], vec);
  vec[x] = root;
  return root;
}

void uf_union(long x, long y, vector<long> &vec) {
  long a = find(x, vec);
  long b = find(y, vec);
  // cout << "a: " << a << ", b: " << b << endl;
  if (a == b) return;
  vec[a] = b;
}

void solve() {
  long N, M;
  cin >> N >> M;
  vector<long> p(N+1, 0);
  rep (i, N) cin >> p[i+1];
  vector<long> uf(N+1, 0);
  rep (i, M) {
    long x, y;
    cin >> x >> y;
    uf_union(x, y, uf);
  }
  // for (auto it: uf) cout << it << " ";
  // cout << endl;
  unordered_map<long, long> mp;
  for (long i = 1; i <= N; i++) {
    mp[p[i]] = find(i, uf);
    // cout << "i: " << i << ", p[i]: " << p[i] << ", group: " << find(i, uf) << endl;
  }
  long ret = 0;
  for (long i = 1; i <= N; i++) {
    if (mp[p[i]] == mp[i]) ret++;
  }
  cout << ret << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 5924
n, k = map(int, input().split())
L, R = [], []
for x in map(int, input().split()):
    if x < 0:
        L.append(-x)
    else:
        R.append(x)
L.reverse()
INF = 10**18
ans = INF
if len(L) == 0:
    ans = R[k-1]
elif len(R) == 0:
    ans = L[k-1]
else:
    for i in range(1, k):
        l, r = k-i-1, i-1
        if not(l < len(L)) or not(r < len(R)):
            continue
        a, b = L[l], R[r]
        ans = min(ans, min(a, b)+a+b)
print(ans)


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

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main()
{
	lli N, M;
	cin >> N >> M;
	string s,t;
	cin >> s >> t;
	lli gcd_val = __gcd(N, M);
	lli lcm_val = N / gcd_val * M;
	if (N == 1 || M == 1) {
		if (s[0] == t[0]) {
			cout << max(N, M) << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	if (gcd_val == 1) {
		if (s[0] == t[0]) {
			cout << lcm_val << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	lli n_mod = N / gcd_val;
	lli m_mod = M / gcd_val;
	for (int i = 0; i < gcd_val; i++) {
		if (s[i*n_mod] != t[i*m_mod]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << lcm_val << endl;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int num = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] num = new int[3];
		
		for(int i=0;i<3;i++) {
			num[i]=sc.nextInt();
		}
		
		Arrays.sort(num);

		System.out.println(num[1]-num[0]+num[2]-num[1]);

	}

}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void){

    int n, i, r1, r2, r, flag, a[1000];

    scanf(" %d\n", &n);

    for(i = 0; i < n ; i++){
        scanf(" %d", &a[i]);
        
        r = a[i]%2;
        r1 = a[i]%3;
        r2 = a[i]%5;

        if(r == 0){
            if(r1 == 0 || r2 == 0){
                flag = 1;
            }else {
                printf("DENIED\n");
                return 0;
            }
        
        }
    }

    if(flag == 1){
        printf("APPROVED\n");
    }else {
        printf("DENIED\n");
    }

    return 0;


}

Measured memory_bytes: 128
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */


// [abc052_b.cpp] => [27-07-2020 @ 22:03:27] 
// Author & Template by : Udit "luctivud" Gupta
// https://www.linkedin.com/in/udit-gupta-1b7863135/


#include <bits/stdc++.h>
// #include <iostream>
// #include <string>
// #include <vector>
// #include <algorithm>
// #include <sstream>
// #include <queue>
// #include <deque>
// #include <bitset>
// #include <iterator>
// #include <list>
// #include <stack>
// #include <map>
// #include <set>
// #include <functional>
// #include <numeric>
// #include <utility>
// #include <limits>
// #include <time.h>
// #include <math.h>
// #include <stdio.h>
// #include <string.h>
// #include <stdlib.h>
// #include <assert.h>

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;
typedef vector<int> v_int;
typedef vector<lld> v_lld;
typedef vector<llu> v_llu;
typedef pair<int, int> p_int;
typedef pair<lld, lld> p_lld;


#define   INDEPENDENT_CASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define          _input(V3C0)  for(auto &V3C0_IT7 : (V3C0)) cin >> (V3C0_IT7)
#define     mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define   CH3K(IT7, EN4, S7P)  (((S7P)<0) ? (IT7)>(EN4) : (IT7)<(EN4))
#define for4(IT7,ST4,EN4,S7P)  for(auto IT7=(ST4); CH3K(IT7,EN4,S7P); (IT7)+=(S7P))
#define    FORE4CH(IT7, V3C0)  for(auto IT7=(V3C0).begin(); IT7!=(V3C0).end(); IT7++)


// template<typename T> void _SC4N(T &x) { 
//     x = 0; bool neg = 0; 
//     register T c = getchar();
//     if (c == '-') neg = 1, c = getchar();
//     while ((c < 48) || (c > 57)) c = getchar();
//     for ( ; c < 48||c > 57 ; c = getchar());
//     for ( ; c > 47 && c < 58; c = getchar() ) x= (x << 3) + ( x << 1 ) + ( c & 15 );
//     if (neg) x *= -1;
// }





void solveEachTest(lld T35TC453N = 1) {
    // auto S34t = chrono:: high_resolution_clock::now(); 
    lld n; cin >> n;
    lld x = 0LL;
    lld ans = 0LL;
    for4(i, 0LL, n, 1LL) {
        char c; cin >> c;
        if (c == 'I') x++;
        else x--;
        ans = max(ans, x);
    }

    cout << ans;
    

    cout << "\n"; 

    // auto S34p = chrono::high_resolution_clock::now(); 
    // auto D34n = chrono::duration_cast<chrono::microseconds>(S34p - S34t);
    // cout << "Time Elapsed: " << D34n.count() / (long double) 1e6 << " seconds" << endl; 
    return;
}


signed main() {

    // ios_base::sync_with_stdio(false); cin.tie(0);

    lld T3X0 = 0, T353 = 1;

    // INDEPENDENT_CASES()
        solveEachTest(T353 - T3X0);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    sort(p, p+n, greater<int>());
    p[0] = p[0]/2;
    int ans = 0;
    for(int i=0;i<n;i++){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

	int s = A + B;
	int d = A - B;
	int k = A * B;

	cout << max(k, max(s, d)) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int x,m;
	double ans=0,ave=0,ss=0;
	char a;
	while(cin>>x>>a>>m){
		ss++;
		ave+=m;
		ans+=x*m;
	}
	cout<<ans<<endl;
	double q=ave/ss-(int)(ave/ss);
	if(q>=0.50000000) cout<<(int)(ave/ss)+1<<endl;
	else cout<<(int)(ave/ss)<<endl;
}

Measured memory_bytes: 1236
#include <stdio.h>

int a[110][110];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int t,k;
		scanf("%d%d",&t,&k);
		while(k--){
			int s;
			scanf("%d",&s);
			a[t][s]=1;
		}
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)printf("%d%c",a[i][j],j==n?10:32);
}


Measured memory_bytes: 2056
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        String list1[] = s1.split("");
        String list2[] = s2.split("");
        String ans = "";
        if(list1[0].equals(list2[2]) && list1[1].equals(list2[1]) && list1[2].equals(list2[0])){
            ans = "YES";
            System.out.println(ans);
        }else{
            ans = "NO";
            System.out.println(ans);
        }
        
    }
}


Measured memory_bytes: 35512
#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
typedef vector<int> VI;

int main() {
  ios_base::sync_with_stdio(false);
  string S; cin >> S;
  int ans = 0, st = 0, en = S.length() - 1;
  for(;;) {
    while(S[st] != S[en]) {
      if(S[st] == 'x') { st++; }
      else if(S[en] == 'x') { en--; }
      else {
        cout << -1 << endl;
        return 0;
      }
      ans++;
    }
    st++;
    en--;
    if(st >= en) { break; }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
import scipy as sp
n, k = list(map(int, (input().split())))

k_list = sp.arange(k, n+2, dtype="int64")

k_list = n*k_list - k_list**2 + k_list + 1

ans = 0
for i in k_list:
    ans += i % (10**9 + 7)
    ans = ans % (10**9 + 7)
#print(sum(k_list))
print(ans)

Measured memory_bytes: 35088
function Main(input) {
	input = input.split("\n");
	line0 = input[0].split(" ");
	line1 = input[1].split(" ");
	var a = Number(line0[0]);
	var b = Number(line0[1]);
	var c = Number(line1[0]);
  	var d = Number(line1[1]);
	if(b > d){
      	console.log(1);
       }else{
       	console.log(0);
       }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) {
		cin >> a[i];
	}
	int num = 1;
	int brk = 0;
	bool is_sat = true;
	rep(i,n) {
		if (a[i] != num) {
			brk++;
		}
		else {
			num++;
		}
	}
	if (num == 1) {
		cout << -1 << endl;
	}
	else {
		cout << brk << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     long n = sc.nextLong();
     long k = sc.nextLong();
     long i = n%k;
     long ans = Math.min(i,k-i);
     System.out.println(ans);
   }
}


Measured memory_bytes: 21844