akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int H, W;
char grid[51][51];

struct Data {
    int id, top, left, down, right;
    Data() {
        id = -1;
        top = left = -1;
        down = right = 100;
    }
};

bool Loop(int dst, int src, const vector<vector<int>> &g,
          vector<bool> &visit)
{
    if (dst == src)
        return true;

    if (visit[src])
        return false;

    visit[src] = true;
    for (unsigned i = 0; i < g[src].size(); ++i) {
        if (Loop(dst, g[src][i], g, visit))
            return true;
    }

    return false;
}

bool Solve()
{
    unordered_map<char, Data> hash;
    int id = 0;

    // 登録
    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j)
            if (grid[i][j] != '.') {
                char c = grid[i][j];

                if (hash.count(c) == 0) {  // 未登録
                    hash[c].id = id++;
                    hash[c].top = hash[c].down = i;
                    hash[c].left = hash[c].right = j;
                }
                else { // 登録済み
                    hash[c].top = min(hash[c].top, i);
                    hash[c].down = max(hash[c].down, i);
                    hash[c].left = min(hash[c].left, j);
                    hash[c].right = max(hash[c].right, j);
                }
            }

    vector<vector<int>> g(id, vector<int>());
    // 長方形の確認
    auto it = hash.begin();
    while (it != hash.end()) {
        for (int y = it->second.top; y <= it->second.down; ++y)
            for (int x = it->second.left; x <= it->second.right; ++x) {
                int src = it->second.id;

                if (grid[y][x] == '.')
                    return false;
                else if (grid[y][x] != it->first &&
                         count(g[src].begin(), g[src].end(),
                               hash[grid[y][x]].id) == 0)
                    g[src].push_back(hash[grid[y][x]].id);
            }
        ++it;
    }

    // ループが存在するかのチェック
    for (unsigned i = 0; i < g.size(); ++i)
        for (unsigned j = 0; j < g[i].size(); ++j) {
            vector<bool> visit(id, false);
            visit[i] = true;

            if (Loop(i, g[i][j], g, visit))
                return false;
        }

    return true;
}

int main()
{
    int T;

    cin >> T;
    while (T--) {
        cin >> H >> W;

        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                cin >> grid[i][j];

        if (Solve())
            cout << "SAFE\n";
        else
            cout << "SUSPICIOUS\n";
    }

    return 0;
}

Measured memory_bytes: 1184
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M_MAX = 100002;

ll n;
int x, m;

int first[M_MAX];

ll sp[M_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> x >> m;
    int a = x;
    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        sp[i] = sp[i - 1] + a;
        if(first[a] != 0)
        {
            ans += (sp[i - 1] - sp[first[a] - 1]) * ((n - i + 1) / (i - first[a]));
            ans += sp[first[a] + (n - i + 1) % (i - first[a]) - 1] - sp[first[a] - 1];
            break;
        }
        ans += a;
        first[a] = i;
        a = 1LL * a * a % m;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 4328
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
c=[0]*n
for i in a:c[i-1]+=1
ind=c.index(2)
x=[]
for i in range(n+1):
    if a[i]==ind+1:x.append(i)
m=n+x[0]-x[1]
f=[1]
for i in range(1,n+2):f.append(f[-1]*i%mod)
def comb(n,r):return f[n]*pow(f[r],mod-2,mod)*pow(f[n-r],mod-2,mod)%mod
for k in range(1,n+2):
    if k==1:print(n);continue
    if k-1>m:print(comb(n+1,k));continue
    ans=comb(n+1,k)-comb(m,k-1)
    print(ans%mod)

Measured memory_bytes: 14008
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>

#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define FOR(i,m,n) for(int (i)=(m);(i)<(n); i++)
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  int N;cin>>N;
  cout<<int(N*1.0/2+0.5);
  return 0;
}


Measured memory_bytes: 256
[n,y]=list(map(int,input().split()))
wa=y-1000*n
ans=0
if wa<0:
    ans=[-1,-1,-1]
else:
    for i in range(n+1):
        for j in range(n-i+1):
            if wa==9000*i+4000*j:
                ans=[i,j,n-i-j]
                break
if ans==0:
    ans=[-1,-1,-1]
for i in range(3):
    print(ans[i],end=" ")
    

            

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int visited[100001]={0};
vector<int> top;
void dfs(vector<vector<int> >& v,int i){
if(visited[i]){
    return ;
}
visited[i]++;
for(int j=0;j<v[i].size();j++){
    dfs(v,v[i][j]);
}
top.pb(i);
}
int main(){
IOS;
int n,m,i,j,x,y;
cin>>n>>m;
vector<vector<int> > v(n);
for(i=0;i<m;i++){
    cin>>x;
    cin>>y;
    v[y-1].pb(x-1);
}
for(i=0;i<n;i++){
    if(!visited[i]){
        dfs(v,i);
    }
}
int dist[n]={0};
for(i=0;i<top.size();i++){
        int maxi=0;
    for(j=0;j<v[top[i]].size();j++){
        maxi=max(maxi,dist[v[top[i]][j]]+1);
    }
    dist[top[i]]=maxi;
}
int *maxi=max_element(dist,dist+n);
cout<<*maxi<<endl;
}


Measured memory_bytes: 11260
list=[]
for x in range(9):
    a,b,c=input().split()
    list.append((a,int(b),int(c)))

i=1
for i in range(i):
    print(list[0][0],list[0][1]+list[0][2],list[0][1]*200+(list[0][2]*300))
    print(list[1][0],list[1][1]+list[1][2],list[1][1]*200+(list[1][2]*300))
    print(list[2][0],list[2][1]+list[2][2],list[2][1]*200+(list[2][2]*300))
    print(list[3][0],list[3][1]+list[3][2],list[3][1]*200+(list[3][2]*300))
    print(list[4][0],list[4][1]+list[4][2],list[4][1]*200+(list[4][2]*300))
    print(list[5][0],list[5][1]+list[5][2],list[5][1]*200+(list[5][2]*300))
    print(list[6][0],list[6][1]+list[6][2],list[6][1]*200+(list[6][2]*300))
    print(list[7][0],list[7][1]+list[7][2],list[7][1]*200+(list[7][2]*300))
    print(list[8][0],list[8][1]+list[8][2],list[8][1]*200+(list[8][2]*300))


Measured memory_bytes: 5616
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>

using namespace std;

int main(){
    cin.tie(0);
    
    int A, B, C; cin >> A >> B >> C;
    cout << min(C, B/A) << endl;
}


Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}

import Data.Bits
import Data.List
import GHC.Int

f :: Int64 -> Int64
f h = maxp 2 (h + 1) where
        maxp m n = if n `mod` m == 0 then m * maxp m (n `div` m) else 1

data Trie = Leaf { check :: Bool } | Branch { check :: Bool, left :: !Trie, right :: !Trie } deriving Show

empty = Leaf { check = False }

insertT :: Trie -> String -> Trie
insert Leaf { check = _ } ""  = Leaf { check = True } 
insertT Leaf { check = chk } (c:s') = 
    let !t' = insertT Leaf { check = False } s' in
        if c == '0'
        then Branch { check = chk, left = t', right = Leaf {check = False} }
        else Branch { check = chk, left = Leaf { check = False}, right = t'}

insertT b "" = b { check = True }
insertT b (c:s') = if c == '0'
                    then let !t' = insertT (left b) s' in b { left = t' } 
                    else let !t' = insertT (right b) s' in b { right = t' }

compute :: Trie -> Int64 -> Int64
compute t n = go t 0 where
                go Leaf {check = False} h = f $ n - h
                go Leaf {check = True}  h = 0
                go Branch { left = lft, right = rgt } h = (go lft $ h + 1) `xor` (go rgt $ h + 1)

insertMany :: [String] -> Trie -> Trie
insertMany slist t = foldl' insertT t slist 

arrayInput n xs = if n == 0 then return xs
                    else getLine >>= (\x -> arrayInput (n - 1) (x:xs))

main = do
    l <- getLine
    let [n, m] = map read $ words l :: [Int64]
    array <- arrayInput n []
    let t = compute (insertMany array empty) m
        res = if t == 0 then "Bob" else "Alice"

    putStrLn res

Measured memory_bytes: 9596
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s, res;
  cin>>s;
  for(auto c: s){
    if(c=='B') {if(!res.empty())res.erase(res.end()-1);}
    else res += c;
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import qualified Data.Map as M

main = do
  li <- getLine
  let n = read li
  ss <- forM [1..n] (const getLine)
  let ans = compute ss
  putStrLn (unlines ans)

compute :: [String] -> [String]
compute ss = [s | (s,k) <- M.assocs m, k == x]
  where
    m = M.fromListWith (+) [(s,1)|s <- ss]
    x = maximum $ M.elems m


Measured memory_bytes: 165884
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int main(){
    long long X,Y;
    cin>>X>>Y;
    if(X%Y==0){
        cout<<(-1)<<endl;
    }else{
        cout<<X<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	string s;
	int size = 0;
	string ans ="";
	cin >> N;
	cin >> s;
	char last;
	int a = 0,b = 0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='('){
			size++;
			ans = ans + s[i];
		}else{
			if(size>0){
				size--;
				ans = ans + s[i];
			}else{
				ans = "(" + ans + s[i];
			}
		}
	}
		cout << ans;
		for(int i=0;i<size;i++)cout << ")";
			cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vll;
typedef vector<pl> vpl;
constexpr ll MOD = 1e9+7;

vii G[100001];
pl dist[2][100001];

int main() {
	int N, M, S[2];
	cin >> N >> M >> S[0] >> S[1];
	while (M--) {
		int u, v, d;
		cin >> u >> v >> d;
		G[u].emplace_back(v, d);
		G[v].emplace_back(u, d);
	}
	
	for (int i = 0; i < 2; ++i) {
		for (int j = 1; j <= N; ++j) dist[i][j] = pl(1e18, 0);
		dist[i][S[i]] = pl(0, 1);
		priority_queue<pl, vpl, greater<pl>> pq;
		pq.emplace(0, S[i]);
		while (!pq.empty()) {
			ll d = pq.top().f;
			int u = pq.top().s;
			pq.pop();
			if (d > dist[i][u].f) continue;
			for (auto& v : G[u]) {
				if (d + v.s < dist[i][v.f].f) {
					dist[i][v.f] = pl(d + v.s, dist[i][u].s);
					pq.emplace(dist[i][v.f].f, v.f);
				}
				else if (d + v.s == dist[i][v.f].f) {
					dist[i][v.f].s = (dist[i][u].s + dist[i][v.f].s) % MOD;
				}
			}
		}
	}

	vii E;
	ll d = dist[0][S[1]].f;
	for (int u = 1; u <= N; ++u) {
		if (2 * dist[0][u].f == d) E.emplace_back(u, u);
		else if (2 * dist[0][u].f < d) {
			for (auto& v : G[u]) {
				if (2 * dist[1][v.f].f < d && dist[0][u].f + v.s + dist[1][v.f].f == d) E.emplace_back(u, v.f);
			}
		}
	}
	ll sum = 0, ans = 0;
	for (auto& x : E) {
		ll p = (dist[0][x.f].s % MOD) * (dist[1][x.s].s % MOD) % MOD;
		ans = (p * sum + ans) % MOD;
		sum = (p + sum) % MOD;
	}
	cout << 2 * ans % MOD << '\n';
}

Measured memory_bytes: 15060
inf = 10**9
par = [0]*5001
rank = [0]*5001
def init_union_find(V):
    for i in xrange(V):
        par[i] = i
        rank[i] = 0
        
def find(x):
    if par[x] == x: return x
    else:
        par[x] = find(par[x])
        return par[x]
    
def unite(x,y):
    x = find(x)
    y = find(y)
    if (x == y): return
    
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if(rank[x] == rank[y]): rank[x] += 1

def same(x,y):
    return find(x) == find(y)

N = int(raw_input())
init_union_find(N)
cost = [0]*N
dic = {}
for i in xrange(N):
    a,x = raw_input().split()
    dic[a] = i
    cost[i] = int(x)
    
M = int(raw_input())
for loop in xrange(M):
    s,t = raw_input().split()
    unite(dic[s],dic[t])

ans = 0
ncost = [inf]*N
for i,c in sorted(enumerate(cost), key = lambda a:a[1]):
    p = find(i)
    if ncost[p] == inf:
        ncost[p] = c
    ans += ncost[p]
print ans    

Measured memory_bytes: 5596
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    println!("ABC{}", n);
}


Measured memory_bytes: 4352
#include<stdio.h>
 #include<string.h>
 int main(void)
 {
     char N[11];
     int i,n=0,S[11],s=0,m=0;

     scanf("%s",N);
     s=strlen(N);

     for(i=0;i<s;i++){
       S[i]=N[i]-'0';
       m+=N[i]-'0';
     }

     if(s==1) n=S[0];
     if(s==2) n=S[0]*10+S[1];
     if(s==3) n=S[0]*100+S[1]+S[2];
     if(s==4) n=S[0]*1000+S[1]*100+S[2]*10+S[3];
     if(s==5) n=S[0]*10000+S[1]*1000+S[2]*100+S[3]*10+S[4];
     if(s==6) n=S[0]*100000+S[1]*10000+S[2]*1000+S[3]*100+S[4]*10+S[5];
     if(s==7){
      n=S[0]*1000000+S[1]*100000+S[2]*10000+S[3]*1000+S[4]*100+S[5]*10+S[6];
     }
     if(s==8){
      n=S[0]*10000000+S[1]*1000000+S[2]*100000+S[3]*10000+S[4]*1000+S[5]*100+S[6]*10+S[7];
     }
     if(s==9){
      n=S[0]*100000000+S[1]*10000000+S[2]*1000000+S[3]*100000+S[4]*10000+S[5]*1000+S[6]*100+S[7]*10+S[8];
     }
     if(s==10){
      n=S[0]*1000000000+S[1]*100000000+S[2]*10000000+S[3]*1000000+S[4]*100000+S[5]*10000+S[6]*1000+S[7]*100+S[8]*10+S[9];
     }

     if(n%m==0) printf("Yes\n");
     else printf("No\n");
   
     return 0;
 }


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7,mod=1e9+7;
int n,ans,f[N][2];
char s[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	f[0][1]=1;
	for(int i=1;i<=n;i++)
	if(s[i]=='1')f[i][0]=(3ll*f[i-1][0]+f[i-1][1])%mod,f[i][1]=2ll*f[i-1][1]%mod;
	else f[i][0]=3ll*f[i-1][0]%mod,f[i][1]=f[i-1][1];
	ans=(f[n][0]+f[n][1])%mod;
	printf("%d",ans);
}

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

int main() {
    string S;
    cin >> S;
    long long ans = 0;
    for(int p=0; p < (1 << S.size()-1); ++p){
        int power = 0;
        for(int i=0; i<S.size(); ++i) {
            ans += (S[S.size()-1-i] - '0') * (long long)pow(10,power);
            if((p >> i) & 1) power = 0;
            else ++power;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u64 = read();

    let m:u64 = (n as f64).sqrt() as u64;
    //println!("{} {}", n, m);

    let mut ans:u64 = n-1;
    for i in 1..m+1 {
        let p = n / i;
        if n % i != 0 { continue; }
        ans = min(ans, (p-1)+(i-1));
    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
#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(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<k)cout<<n*x<<endl;
    else cout<<k*x+(n-k)*y<<endl;

    return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>
#define N 100
#define INF 1000000

int main(){
  int n,p[N+1],m[N+1][N+1],i,l,j,k,q;

  scanf("%d",&n);
  
  for(i=1;i<=n;i++) scanf("%d%d",&p[i-1],&p[i]);
 
  for(i=1;i<=n;i++) m[i][i]=0;
 
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
        q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
        if(m[i][j]>q) m[i][j]=q;
      }
    }
  }
  
  printf("%d\n",m[1][n]);
  
  return 0;
}


Measured memory_bytes: 2112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> firstRow = Arrays.asList(br.readLine().split(" "));
            List<String> secondRow = Arrays.asList(br.readLine().split(" "));
            String thirdRow = br.readLine();

            List<Integer> ballsCount = new ArrayList<>();
            for (String s : secondRow) {
                ballsCount.add(Integer.parseInt(s));
            }

            Map<String, Integer> ballsCountAndColor = new HashMap<>();

            for (int i = 0; i < firstRow.size(); i++) {
                ballsCountAndColor.put(firstRow.get(i), ballsCount.get(i));
            }

            ballsCountAndColor.put(thirdRow, ballsCountAndColor.get(thirdRow).intValue() - 1);

            System.out.print(ballsCountAndColor.get(firstRow.get(0)).intValue() + " "
                    + ballsCountAndColor.get(firstRow.get(1)).intValue());
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22484
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI cnt(N, 0);
	VI A(N);
	REP(i, N) {
		int a; cin >> a;
		a--;
		cnt[a]++;
		A[i] = a;
	}

	int ans = 0;
	REP(i, N) {
		ans += (cnt[i] * (cnt[i] - 1)) / 2;
	}
	//cout << ans << endl;
	REP(i, N) {
		int res = ans;
		res -= (cnt[A[i]] * (cnt[A[i]] - 1)) / 2;
		//cout << res << " ";
		res += ((cnt[A[i]] - 2) * (cnt[A[i]] - 1)) / 2;
		cout << res << endl;
	}




	return 0;
}



Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll A,B;
  cin >> A >> B;


  cout << ((A<10&&B<10) ? A*B : -1) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define itn int
#define gI gi
#define int long long 

using namespace std;

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

int n, k, m, mx, a[200003], he[200003];
double ans, x[200003], sum[200003];
string ss, t;

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi(), k = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi(), mx = max(mx, a[i]);
	for (int i = 1; i <= mx; i+=1) he[i] = he[i - 1] + i;
	for (int i = 1; i <= n; i+=1)
	{
		x[i] = 1. * he[a[i]] * (1. / a[i]);
	//	printf("%lld %.5lf %.5lf\n", he[a[i]], 1. / a[i], x[i]);
	}
	for (int i = 1; i <= n; i+=1) 
	{
		sum[i] = sum[i - 1] + x[i];
	}
	ans = 0.0;
	for (int i = 1; i + k - 1 <= n; i+=1)
	{
		double kk = sum[i + k - 1] - sum[i - 1];
		//printf("%.5lf %.5lf\n", sum[i + k - 1], sum[i - 1]);
		if (kk > ans) ans = kk;
		//printf("%.5lf %.5lf\n", kk, ans);
	}
	printf("%.10lf\n", ans);
	return 0;
}



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

int main() {
	int a,b;
  	cin>>a>>b;
  	int ai=0;
  	int bi=0;
    int ax=a;
    int bx=b;
  
  	rep(i,b){
        ai+=ax;
      	ax*=10;
    }
  
    rep(j,a){
     bi+=bx;
     bx*=10;
    }
  
 if(a<=b){
  	cout<<ai<<endl;
  }
  
  else{
  	cout<<bi<<endl;
  }
  
  
  
}

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

#define ll long long 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()

int main(){

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
		
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	while(n) {
		if(n % 10 == 7) {
			cout << "Yes\n";
			return 0;
		}
		n /= 10;
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 3656
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
LL r, D, x;
int main(){
	cin >> r >> D >> x;
	for(int i=0; i<10; i++){
		x = r*x - D;
		cout << x << endl;
	}
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i,n) cin >> s[i];
	map<string,int> M;
	rep(i,n){
		M[s[i]] ++;
	}
	cout << M.size() << endl;
}


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

void solve() 
{
    int x,n;cin>>x>>n;bool p[110];REP(i,110)p[i]=0;
    REP(i,n){
        int x;cin>>x;
        p[x]=1;
    }
    REP(i,110){
        if(!p[x-i]){
            cout<<x-i<<endl;return;
        }else if(!p[x+i]){
            cout<<x+i<<endl;return;
        }
    }
}

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

Measured memory_bytes: 3640
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
int main(){
	int n, ans;
	while(cin >> n){
		ans=0;
		rep(i,10) rep(j,10) rep(k,10) rep(l,10) if(i+j+k+l==n) ans++;
		cout << ans << endl;
	}
    return 0;
}

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

int main(){
	string s; int K; cin >> s >> K;
	
	vector<string> v;
	for(int i = 1; i <= 5; i++){
		for(int j = 0; j < s.size(); j++){
			if(j + i <= s.size()){
				//同じ文字列が無ければ追加
				string str = s.substr(j, i);
				auto result = find(v.begin(), v.end(), str);
				if(result == v.end()){
					v.push_back(str);
				}
			}
		}
	}
	
	//昇順ソート
	sort(v.begin(), v.end());

	cout << v[K - 1];
	return 0;
}

Measured memory_bytes: 1024
while True:
    n,x=map(int,input().split())
    if not n: 
        break
    oup=0
    for a in range(1,n+1):
        for b in range(a+1,n+1):
            for c in range(b+1,n+1):
                if a+b+c==x:
                    oup+=1
    print(oup)


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

public class Main {

	public static final long INF = Long.MAX_VALUE;

	public static int[][] itemArray;

	public static long[][] dp;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int itemCount = scan.nextInt();
		int maxWait = scan.nextInt();

		itemArray = new int[itemCount + 1][2];

		for (int i = 1; i < itemCount + 1; i++) {

			// 重さ
			itemArray[i][0] = scan.nextInt();

			// 価値
			itemArray[i][1] = scan.nextInt();
		}

		dp = new long[itemCount + 1][maxWait + 1];

		for (long[] dpArray : dp) {

			Arrays.fill(dpArray, INF);
		}

		long answer = calculateDPValue(itemCount, maxWait);

		System.out.println(answer);
	}

	private static long calculateDPValue(int itemNumber, int waitNumber) {

		if (dp[itemNumber][waitNumber] != INF) {

			return dp[itemNumber][waitNumber];
		}

		if (itemNumber == 0) {

			dp[itemNumber][waitNumber] = 0;
			return 0;
		}

		long value;

		if (itemArray[itemNumber][0] <= waitNumber) {

			value = Math.max(
					calculateDPValue(itemNumber - 1, waitNumber),
					calculateDPValue(itemNumber - 1, waitNumber - itemArray[itemNumber][0]) + itemArray[itemNumber][1]);
		} else {

			value = calculateDPValue(itemNumber - 1, waitNumber);
		}

		dp[itemNumber][waitNumber] = value;
		return value;
	}
}


Measured memory_bytes: 126968
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

const mod = 10^^9+7;
alias mint = FactorRing!mod;

void main()
{
  int n, c; readV(n, c);
  int[] a; readA(n, a);
  int[] b; readA(n, b);

  auto bm = b.reduce!max, s = new mint[][](bm+1, c+1);
  foreach (x; 1..bm+1)
    foreach (k; 0..c+1)
      s[x][k] = s[x-1][k]+mint(x).repeatedSquare(k);

  auto dp = new mint[][](n, c+1);
  foreach (k; 0..c+1)
    dp[0][k] = s[b[0]][k]-s[a[0]-1][k];

  foreach (i; 1..n)
    foreach (j; 0..c+1)
      foreach (k; 0..j+1)
        dp[i][j] += dp[i-1][j-k]*(s[b[i]][k]-s[a[i]-1][k]);

  writeln(dp[n-1][c]);
}

pure T repeatedSquare(alias pred = "a * b", T, U)(T a, U n)
{
  return repeatedSquare!(pred, T, U)(a, n, T(1));
}

pure T repeatedSquare(alias pred = "a * b", T, U)(T a, U n, T init)
{
  import std.functional;
  alias predFun = binaryFun!pred;

  if (n == 0) return init;

  auto r = init;
  while (n > 0) {
    if (n&1) r = predFun(r, a);
    a = predFun(a, a);
    n >>= 1;
  }

  return r;
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; }
  alias FR = FactorRing!(m, pos);
  @property static init() { return FR(0); }
  @property int value() { return vi; }
  @property void value(int v) { vi = mod(v); }
  alias value this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref auto opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; }
  pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); }

  static if (!pos) pure ref auto opUnary(string op: "-")() { return FR(mod(-vi)); }

  static if (m < int.max / 2) {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vi"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; }
  } else {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vl"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; }
  }
  pure ref auto opBinary(string op: "*")(int r) { return FR(mod(vl*r)); }
  ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; }

  pure ref auto opBinary(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); }
  ref auto opOpAssign(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); }
}


Measured memory_bytes: 4348
import math
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c,k=INTM()
    if a>=k:
        print(k)
    elif a<=k<=a+b:
        print(a)
    else:
        print(a-(k-(a+b)))
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 9200
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn dfs(idx: usize, books: &Vec<Vec<u64>>, vals: &Vec<u64>, x: u64) -> u64 {
    if idx == books.len() {
        let mut flag = true;
        for v in vals {
            if *v < x {
                flag = false;
                break;
            }
        }
        if flag {
            return 0;
        } else {
            return 1000000000;
        }
    }    
    let mut new_vals = vals.to_vec();
    let c = books[idx][0];
    for i in 1..books[idx].len() {
        new_vals[i - 1] += books[idx][i];
    }
    return min(dfs(idx + 1, books, vals, x), dfs(idx + 1, books, &new_vals, x) + c);
}

fn main() {
    let (n, m, x) = input_tuple();
    let mut books: Vec<Vec<u64>> = Vec::new();
    for _ in 0..n {
        let book = input_vec();
        books.push(book);
    }
    let vals = vec![0u64; m as usize];
    let ans = dfs(0, &books, &vals, x);
    if ans >= 1000000000 {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" <<endl;
    }
    else cout << "No" << endl;
}


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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rrep(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, k;
    cin >> n >> k;
    n %= k;
    dump(min(n, k - n));
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int card[4][13]={{0}};
    int i,j,k,n,rank;
    char s;
    char moji[4];
    
    scanf("%d",&n);
    
    moji[0]='S';
    moji[1]='H';
    moji[2]='C';
    moji[3]='D';
    
    for(i=0; i<n; i++){
        scanf("%s %d",&s,&rank);
        if(s == 'S') k=0;
        else if(s == 'H') k=1;
        else if(s == 'C') k=2;
        else k=3;
        
        card[k][rank-1] = 1;
    }
    
    for(i=0; i<4; i++){
        for(j=0; j<13; j++){
            if(card[i][j] == 0){
                printf("%c %d\n", moji[i], j+1);
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

string revzzz(char c,int x){
	string ans="";
	for(;x>0;x--){
		ans+=c;
	}

	return ans;
}
int32_t main()
{
	c_p_c();

			int n; cin>>n;

			int arr[n];

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

			int ans=0;
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					for(int k=j+1;k<n;k++){

						if(arr[i]!=arr[j] && arr[j]!=arr[k]&&arr[i]!=arr[k]&&arr[k] < arr[j]+arr[i] && arr[j] < arr[k]+arr[i] && arr[i] < arr[j]+arr[k]){
							ans++;
							// cout<<i+1<<" "<<j+1<<" "<<k+1<<'\n';
						}
					}
				}
			}
			cout<<ans<<'\n';
}	

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

int	main() {
	int N, K;
	cin >>N >>K;
	int S=0;
	for (int i=0; i<N; i++) {
		int h;
		cin >>h;
		if (h>=K)
			S++;
	}
	cout <<S <<endl;
	return 0;
};


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    char c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)cin >> c[i][j];
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}


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

typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    int nel{}, ner{}, nwl{}, nwr{};
    trav(a, s) {
        if (a == 'E') ner++;
        else nwr++;
    }
    int ans = min(nel + ner, nwl + nwr);
    FOR(i, 0, s.size()) {
        if (i > 0) {
            if (s[i - 1] == 'E') nel++;
            else nwl++;
        }
        if (s[i] == 'E') ner--;
        else nwr--;
        ans = min(ans, nwl + ner);
    }
    cout << ans << nl;
}

Measured memory_bytes: 3884
// aaaaaaaaaaaaa
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
long long n,t,q,a[100001],d[100001],x[1001],s[100001],k,f[1001],flg,i,j;
int main(void)
{
	scanf("%lld %lld %lld",&n,&t,&q);
	for(i=1;i<=n;i++){
		scanf("%lld %lld",&a[i],&d[i]);
	}
	for(i=1;i<=q;i++){
		scanf("%lld",&x[i]);
	}
	k=0;
	for(i=1;i<n;i++){
		if(d[i]==1&&d[i+1]==2&&a[i]+t*2>=a[i+1]){
			s[k]=a[i]-(a[i]-a[i+1])/2;
			k++;
		}
	}
	for(j=1;j<=q;j++){
		flg=0;
		for(i=0;i<k;i++){
			if(d[x[j]]==1&&s[i]>=a[x[j]]&&s[i]-t<=a[x[j]]){
				f[j]=s[i];
				flg=1;
//				printf("%lld %lld\n",f[j],s[i]);
				break;
			}
		}
		for(i=k-1;i>=0;i--){
			if(d[x[j]]==2&&s[i]<=a[x[j]]&&s[i]+t>=a[x[j]]){
				f[j]=s[i];
				flg=1;
//				printf("%lld %lld\n",f[j],s[i]);
				break;
			}
		}
		if(flg==0){
			if(d[x[j]]==1) f[j]=a[x[j]]+t;
			else f[j]=a[x[j]]-t;
//			printf("%lld\n",f[j]);
		}
	}
	for(i=1;i<=q;i++){
		printf("%lld\n",f[i]);
	}
	return 0;
}

Measured memory_bytes: 4436
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}

int main() {
	int N = 0, Q = 0;
	string manji;
	int a,b, ac[100009] = { 0 };
	cin >> N >> Q >> manji;
	for (int i = 1; i < manji.size(); i++) {
		if (manji[i] == 'C' && manji[i - 1] == 'A') {
			ac[i] = ac[i - 1] + 1;

		}
		else {
			ac[i] = ac[i - 1];
		}
		//cout << ac[i] << endl;
	}
	for (int i = 0; i < Q; i++) {
		cin >> a >> b;
		cout << ac[b-1] - ac[a-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
#define rep(i, n) for(long i = 0L; i < (n); i++)
using Graph = vector<vector<int>>;
long maxi = 1000000000;

int main()
{
    long n, k, s;
    cin >> n >> k >> s;

    if (k == 0 && s == maxi) {
        rep(i, n) {
            cout << 1 << " ";
        }
        cout << endl;
        return 0;
    }

    if (k == 0 && s < maxi) {
        rep(i, n) {
            cout << s + 1 << " ";
        }
        cout << endl;
        return 0;
    }

    if (s == maxi) {
        rep(i, k) {
            cout << maxi << " ";
        }
        rep(i, n - k) {
            cout << 1 << " ";
        }
        cout << endl;
        return 0;
    }

    if (s < maxi) {
        rep(i, k) {
            cout << s << " ";
        }
        rep(i, n - k) {
            cout << s + 1 << " ";
        }
        cout << endl;
        return 0;
    }
    return 0;
}

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

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

    sort(a,a+n);
    int alice=0,bob=0;
    for(int i=0;i<n;i++){
        if(i%2){
            bob+=a[n-1-i];
        }else{
            alice+=a[n-1-i];
        }
    }
    cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;

int main(){
	int n;
	cin >> n;
	ll w = 1e9 + 7;
	ll power = 1;
	int c = 1;
	rep(i, n){
		power *= c;
		c++;
		power %= w;
	}
	cout << power << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
-- import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function


main :: IO ()
main = do
  n <- read <$> getLine
  ls <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  print $ binSearch 0 n ls

binSearch :: Int -> Int -> VU.Vector Int -> Int
binSearch ng ok ls | ok - ng <= 1 = ok
binSearch ng ok ls =
  if isPossibleWith mid ls then
    binSearch ng mid ls
  else
    binSearch mid ok ls
  where
    mid = (ng + ok) `shiftR` 1


isPossibleWith :: Int -> VU.Vector Int -> Bool
isPossibleWith 1 ls = VU.and $ VU.zipWith (<) ls (VU.tail ls)
isPossibleWith numChars ls
  = VU.foldr loop (const True) ls (DicEntry 0 Nil)
  where
    loop !reqLen cont de@DicEntry{..}
      | reqLen > wordLen = cont $! de{wordLen = reqLen}
      | otherwise = loop1 ((cont $!) . DicEntry reqLen)
                    (cutOff charList reqLen) (reqLen - 1)
    loop1 _ !xs ind | ind < 0 = False
    loop1 cont xs@(Snoc xs' i e) ind = case compare i ind of
      LT -> cont $! Snoc xs ind 1
      EQ | e < numChars - 1 -> cont $! Snoc xs' i (e+1)
         | otherwise        -> loop1 cont xs' (ind-1)
    loop1 cont Nil ind = cont $! Snoc Nil ind 1

data List = Nil | Snoc !List {-# UNPACK #-} !Int {-# UNPACK #-} !Int
 deriving Show

data DicEntry = DicEntry { wordLen :: {-# UNPACK #-} !Int,
                           charList :: !List }

cutOff :: List -> Int -> List
cutOff (Snoc xs i e) till | till <= i = cutOff xs till
cutOff xs !till = xs


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

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  rep(i, n) std::cin >> a[i];
  std::map<int, int> map;

  rep(i, n) {
    map[a[i] - 1]++;
    map[a[i]]++;
    map[a[i] + 1]++;
  }

  int maxv = 0;
  for (int i = -1; i <= 100001; i++) {
    maxv = max(map[i], maxv);
  }

  std::cout << maxv << std::endl;

  return 0;
}


Measured memory_bytes: 8316
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;
vi adj[N+5];
int dp[N+5];
int dfs(int pos)
{
  int x = adj[pos].size();

  vi v;
  for(auto i:adj[pos])
  {
    v.pb(dfs(i));
  }
  sort(v.begin(),v.end());
  int ret = x;

  afor(i,1,x)
  {
    ret = max(ret, i + v[x - i]);
  }
  
  dp[pos] = ret;
  return ret;
}

int main()
{
  finp;
  cin>>n;
  afor(i,2,n)
  {
    int val;
    cin>>val;
    adj[val].pb(i);
  }
dfs(1);
 cout<<dp[1];
  
return 0;
}

Measured memory_bytes: 17024
#include <algorithm>
#include <iostream>
#include <vector>
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(x) begin(x), end(x)
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }

int solve(int n, string const & s) {
    vector<int> dp(n + 1);
    int r = n;
    repeat_reverse (l, n) {
        dp[l] = dp[l + 1];
        if (l + 2 < n and s[l + 2] == '0') {
            r = l + 2;
        }
        if (s[l] == '1') {
            if (s[l + 1] == '0') {
                if (s[r - 1] == '1') {
                    setmax(dp[l], dp[r] + r - l - 2);
                    if (s[r - 2] == '1') {
                        setmax(dp[l], dp[r - 1] + (r - 1) - l - 2);
                    }
                }
            } else {
                if (r + 1 < n and s[r + 1] == '1') {
                    setmax(dp[l], dp[r + 2] + (r + 2) - l - 2);
                }
            }
        }
    }
    return *max_element(whole(dp));
}

int main() {
    int n; string s; cin >> n >> s;
    cout << solve(n, s) << endl;
    return 0;
}


Measured memory_bytes: 2808
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
    double T, X; cin >> T >> X;

    cout << fixed;
    cout << setprecision(10);
    cout << T / X;

    return 0;
}

Measured memory_bytes: 256