akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    s = input()
    L = ["S", "W"]

    for first in L:
        for second in L:
            res = ["" for _ in range(n)]
            res[0] = first
            res[1] = second
            for i in range(1, n - 1):
                if s[i] == "o":
                    if res[i] == "S" and res[i - 1] == "S":
                        res[i + 1] = "S"
                    elif res[i] == "S" and res[i - 1] == "W":
                        res[i + 1] = "W"
                    elif res[i] == "W" and res[i - 1] == "W":
                        res[i + 1] = "S"
                    else:
                        res[i + 1] = "W"
                else:
                    if res[i] == "S" and res[i - 1] == "S":
                        res[i + 1] = "W"
                    elif res[i] == "S" and res[i - 1] == "W":
                        res[i + 1] = "S"
                    elif res[i] == "W" and res[i - 1] == "W":
                        res[i + 1] = "W"
                    else:
                        res[i + 1] = "S"

            if s[-1] == "o":
                if (res[-1] == "S" and res[-2] != res[0]) or (res[-1] == "W" and res[-2] == res[0]):
                    continue
            else:
                if (res[-1] == "S" and res[-2] == res[0]) or (res[-1] == "W" and res[-2] != res[0]):
                    continue

            if s[0] == "o":
                if (res[0] == "S" and res[-1] != res[1]) or (res[0] == "W" and res[-1] == res[1]):
                    continue
            else:
                if (res[0] == "S" and res[-1] == res[1]) or (res[0] == "W" and res[-1] != res[1]):
                    continue

            print("".join(res))
            break
        else:
            continue
        break
    else:
        print(-1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define al(s) s.begin(),s.end()

typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef pair<int, ppi> pipp;

vector<int> pri;
void era(int n)
{
	vector<int> fl(n+1,0);
	for (int i = 2; i <= n; i++)
	{
		if (fl[i] == 0)
		{
			for (int l = i; l <= n; l += i)
			{
				fl[l] = 1;
			}
			pri.push_back(i);
		}
	}

}

int main()
{
	era(10000);
	int n;
	vector<int> ans;
	for (int i = 0; i < pri.size(); i++)
	{
		if (binary_search(al(pri), pri[i] + 2))
		{
			ans.push_back(pri[i] + 2);
		}
	}

	while (cin >> n&&n)
	{
		if (binary_search(al(ans), n))
		{
			cout << *(lower_bound(al(ans), n))-2 <<" "<< *(lower_bound(al(ans), n)) << endl;
		}
		else
		{
			cout << *(lower_bound(al(ans), n)-1) -2<<" "<< *(lower_bound(al(ans), n) - 1)<< endl;
		}
	}
}

Measured memory_bytes: 1272
# B - Making Triangle

n = int(input())
l = list(map(int, input().split()))
assert n == len(l)

count = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            a, b, c = sorted((l[i], l[j], l[k]))
            if a + b > c:
                count += 1
print(count)


Measured memory_bytes: 9204
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    ll n, x; int m;
    cin >> n >> x >> m;
    int LOG = 40;
    auto to = make_vec<int>({LOG, m});
    auto sum = make_vec<ll>({LOG, m});

    for (ll i = 0; i < m; ++i) {
        to[0][i] = i * i % m;
        sum[0][i] = i;
    }

    rep(i, LOG - 1) {
        rep(j, m) {
            to[i+1][j] = to[i][to[i][j]];
            sum[i+1][j] = sum[i][j] + sum[i][to[i][j]];
        }
    }

    ll ans = 0;
    rep(i, LOG) {
        if (n >> i & 1) {
            ans += sum[i][x];
            x = to[i][x];
        }
    }
    cout << ans << '\n';
}

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

ll A,B,N;
ll v[50];
double maxs[50];
double max_max=0;
ll sum=0;

long dp[51][51];

long nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}

int main() {
    std::cin >> N>>A>>B;
    for (int i = 0; i < N; i++) {
       std::cin >> v[i];
    }
    sort(v,v+N);
    for (int i = A; i <= B; i++) {
        sum=0;
        for (int j = 0; j < i; j++) {
            sum+=v[N-1-j];
        }
        maxs[i]=(double)sum/i;
        max_max=max(maxs[i],max_max);
    }
    ll max_count=0;
    ll max_start=-1;
    for (int i = A; i <= B; i++) {
        if(maxs[i]==max_max){
            max_count++;
            if(max_count==1){
                max_start=i;
            }
        }
    }
    ll result=0;

    if(max_count==1){
        
        ll select = distance(v,upper_bound(v,v+N,v[N-1-(max_start-1)]))-(N-1-max_start)-1;
        ll amount = distance(lower_bound(v,v+N,v[N-1-(max_start-1)]),upper_bound(v,v+N,v[N-1-(max_start-1)]));
        
        result+=nCr(amount,select);
    }else{
        // std::cout << 1 << std::endl;
        ll amount = N-distance(v,lower_bound(v,v+N,v[N-1]));
        for (int i = A; i <= B && i <= amount; i++) {
            result+=nCr(amount,i);
        }
    }
    std::cout << std::fixed;
    std::cout <<setprecision(10)<< max_max << std::endl;
    std::cout << result << std::endl;

}


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

using namespace std;

#define fill(A, val) memset(A,val,sizeof(A))
#define rep(i, a, n) for (int (i)=a;(i)<n;++(i))
#define per(i, n, a) for (long long (i)=n-1;(i)>=a;--(i))
#define all(V) V.begin(),(V).end()
#define sz(V) (int)(V).size()
#define pb push_back
#define fi first
#define se second
#define ret return
#define tr true
#define fl false


typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef pair<ll, ll> pll;                                                                                                                                                        
typedef pair<ld, ld> pdd;
typedef map<int, int> mii;
typedef map<ll, ll> mll;                    
typedef pair<string,int> si;
const double eps = 1e-8;                        
const double Pi = 3.14159265358979323846264338327950288419716939937510;
const long long INF = 1LL << 60;
const long long MAX3 = 1005;
const long long MAX4 = 10005;
const long long MAXN = 100005;
const long long MAX6 = 1000005;
const long long MOD = 1e9 + 7;
const long long N = (int)1e7;
const int Grn = 10000;

ll n,k,a[10],d[11],q;
bool c[11],cc;
vector<int>v;

int main(){
//freopen("search.in","r",stdin);
//freopen("search.out","w",stdout);

cin>>n>>k;
for(int i = 1; i <= k; ++ i){
 cin>>a[i];
c[a[i]] = 1;
}
for(int i = 0; i < 10; ++ i){
 if(c[i] == 0){
d[q] = i;
q++;     
}
}

while(true){
v.clear();
ll cnt = 0;
ll nn = n;
while(nn>0){
v.pb(nn%10);
nn/=10;
}
for(int i = 0; i < sz(v); ++ i){
    for(int j = 0; j < q; ++ j){
     if(v[i]==d[j])cnt++;
  }
}

if(cnt==sz(v))break;
n++;
}
cout<<n;
return 0;
}          

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int a[30] = {};
    for(int i=0; i< s.size();i++){
        a[s[i]- '0' -49]++;
    }
    for(int i=0; i< 26;i++){
        if(a[i]==0) {
            putchar(i + 97);
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const double PI = acos(-1);
int main() {
    int N; cin >> N;
    vector<tuple<double, Int, Int>> A(2*N);
    for (int i = 0; i < N; i++) {
        double angle; Int x, y;
        cin >> x >> y;
        angle = (y == 0 && x == 0 ? 0.0 : atan2(y, x));
        A[i] = make_tuple(angle, x, y);
    }
    sort(begin(A), begin(A) + N);
    for (int i = 0; i < N; i++) {
        double angle; Int x, y;
        tie(angle, x, y) = A[i];
        A[N + i] = make_tuple(angle + 2 * PI, x, y);
    }
    double ans = 0.0;
    for (int i = 0; i < N; i++) {
        double limit = get<0>(A[i]) + PI - 1e-10;
        int j = i;
        Int X = 0, Y = 0;
        while (j < 2 * N && get<0>(A[j]) < limit) {
            X += get<1>(A[j]);
            Y += get<2>(A[j]);
            ans = max(ans, sqrt(X * X + Y * Y));
            j++;
        }
    }
    cout << fixed << setprecision(12) << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        x--;
        a[x]=i;
    }
    vector<int> b(n),c(n-1);
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n-1;i++){
        cin >> c[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        if(i==0) ans+=b[i];
        else{
            if(a[i]-a[i-1]==1){
                ans+=(b[i]+c[i-1]);
            }
            else{
                ans+=b[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'!'||__c>'~') __c=getc();
        while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y);
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
int n,x,y,sg[100005];vector<int>e[100005];void add(int x,int y){e[x].push_back(y);e[y].push_back(x);}
void dfs(int x,int fa){for(int i=0;i<e[x].size();i++) if(e[x][i]!=fa) dfs(e[x][i],x),sg[x]^=(sg[e[x][i]]+1);}
int main(){read(n);for(int i=1;i<n;i++) read(x),read(y),add(x,y);dfs(1,0);puts(sg[1]?"Alice":"Bob");}

Measured memory_bytes: 14336
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
struct bimatch{
	int n;
	vector<vector<int> >G;
	vector<int>match;
	vector<bool>used;
	bimatch(int _n=0):n(_n),G(n),match(n),used(n){}
	void add_edge(int u,int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bool dfs(int v)
	{
		used[v]=true;
		for(int u:G[v])

		{
			int w=match[u];
			if(w<0||!used[w]&&dfs(w))
			{
				match[v]=u;
				match[u]=v;
				return true;
			}
		}
		return false;
	}
	int count()
	{
		int ans=0;
		fill(match.begin(),match.end(),-1);
		for(int v=0;v<n;v++)
		{
			if(match[v]<0)
			{
				fill(used.begin(),used.end(),false);
				if(dfs(v))ans++;
			}
		}
		return ans;
	}
};
bool G[777][777];
int n,m;
int color[777];
bool dfs(int u,int c,vector<vector<int> >&G)
{
	color[u]=c;
	bool ans=true;
	for(int i=0;ans&&i<G[u].size();i++)
	{
		if(color[G[u][i]]==c)return false;
		else if(color[G[u][i]]<0)ans&=dfs(G[u][i],1-c,G);
	}
	return ans;
}
bool bicheck(vector<vector<int> >&G)
{
	for(int i=0;i<n;i++)color[i]=-1;
	bool ans=true;
	for(int i=0;ans&&i<n;i++)if(color[i]<0)ans&=dfs(i,0,G);
	return ans;
}
void ddfs(int u,int c,vector<vector<int> >&G)
{
	color[u]=c;
	for(int i=0;i<G[u].size();i++)
	{
		if(color[G[u][i]]<0)ddfs(G[u][i],c^1,G);
	}
}
void coloring(vector<vector<int> >&G)
{
	for(int i=0;i<n;i++)color[i]=-1;
	int c=-2;
	for(int i=0;i<n;i++)if(color[i]<0)ddfs(i,c+=2,G);
}
pair<int,int>cnt[777];
int dp[777][777];
int f(int a)
{
	return a*(a-1)/2+(n-a)*(n-a-1)/2;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a][b]=G[b][a]=1;
	}
	bimatch M(n);
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)
	{
		if(!G[i][j])M.add_edge(i,j);
	}
	if(!bicheck(M.G))
	{
		cout<<-1<<endl;
		return 0;
	}
	coloring(M.G);
	for(int i=0;i<n;i++)
	{
		if(color[i]%2)cnt[color[i]>>1].second++;
		else cnt[color[i]>>1].first++;
	}
	dp[0][0]=1;int i;
	for(i=0;cnt[i].first>0;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i+1][j+cnt[i].first]|=dp[i][j];
			dp[i+1][j+cnt[i].second]|=dp[i][j];
		}
	}
	int ans=1e9;
	for(int j=0;j<=n;j++)if(dp[i][j])ans=min(ans,f(j));
	cout<<ans<<endl;
}


Measured memory_bytes: 3072
def calc(n, k, x):
    c = 0

    while x <= n:
        a  = (x - 1) // k
        c += 1 + 6 * (1 + a) * a // 2
        x += k

    return c

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

if k % 2 == 0:
    print(calc(n, k, k) + calc(n, k, k // 2))
else:
    print(calc(n, k, k))


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

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long x = sc.nextLong();

        long a = 0;
        long b = 0;
        while(true){
            long ans = a*a*a*a*a - b*b*b*b*b;
            if(ans == x) break;
            if(b >= 0){
                if(ans > x){
                    b++;
                }else{
                    a++;
                }
                if(a > 10000){
                    a = 1000;
                    b = -1;
                }
            }else{
                if(ans > x){
                    a--;
                }else{
                    b--;
                }
            }

        }

        System.out.println(a + " " + b);
    }

    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: 36656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  int count = s.size();
  // string s1 = s.substr(0,s.size()/2);
  // string s2 = s.substr(s.size()/2,s.size()/2);
  // cout << s1 << endl;
  // cout << s2 << endl;

  while (count > 0) {
    count--;
    string S = s.substr(0,count);
    if (s.size()%2 != 0) continue;
    string s1 = S.substr(0,S.size()/2);
    string s2 = S.substr(S.size()/2,S.size()/2);
    if (s1 == s2) {
      // cout << s1 << endl;
      // cout << s2 << endl;
      cout << s1.size()+s2.size() << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3564
fn main(){
  proconio::input!{s:[String]};
  let mut m=std::collections::HashMap::new();
  for i in s{
    *m.entry(i).or_insert(0)+=1;
  }
  for s in &["AC","WA","TLE","RE"]{
    println!("{} x {}",s,m.get(&s.to_string()).unwrap_or(&0));
  }
}

Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,x,y,i,t;
  while(cin>>n>>a>>b>>c>>x&&n){
    i=t=0;
    for(;i<n;i++,t++){
      cin>>y;
      while(y!=x&&t<=10000){x=(a*x+b)%c;t++;}
      x=(a*x+b)%c;
    }
    if(--t>10000)cout<<-1<<endl;
    else cout<<t<<endl;
  }
}

Measured memory_bytes: 1160
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define chmin(x,y) x = min(x, y)
#define chmax(x,y) x = max(x, y)
#define V vector
vector<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
vector<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n; cin >> n;
    V<char> c(n);
    int r = 0;
    rep(i, n) {
        cin >> c[i];
        if (c[i] == 'R') r++;
    }
    int cnt = 0;
    rep(i, r) {
        if (c[i] == 'R') cnt++;
    }
    int ans = r - cnt;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll N; cin>>N;
  ll a[N];
  umap<ll,ll> mp_count;
  vector<ll> v ={};
  REP(i,N){
    cin >> a[i];
    if(mp_count[a[i]]==0){ v.push_back(a[i]);}
    ++mp_count[a[i]];
  }
  ll s = 0;
  for(ll x:v){
    ll n = mp_count[x];
    s += n*(n-1)/2;
  }
  REP(i,N){
    ll n = mp_count[ a[i] ];
    ll r = s - n*(n-1)/2;
    --n;
    r += n*(n-1)/2;
    cout << r <<"\n";
  }
}

Measured memory_bytes: 10048
n = int(raw_input())
a = map(int, raw_input().split())
ai = zip(a,range(n))
# ai.sort()

# ans = [0] * n
# prev = 0
# for i in range(n):
#     a,a_i = ai[i]
#     ans[a_i] = (a-prev) * (n-i)
#     prev = a

# for i in range(n):
#     print ans[i]

ai.sort()
ai = ai[::-1]
ai.append((0,0)) # dummy

ans = [0] * n
min_a_i = float('inf')
for i in range(n):
    min_a_i = min(min_a_i, ai[i][1])
    ans[min_a_i] += (ai[i][0] - ai[i+1][0]) * (i+1)

for i in range(n):
    print ans[i]

Measured memory_bytes: 23256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

vector<ll> v(55556,1);
vector<ll> ans;

int main(){
    ll N;
    cin>>N;
    set<ll> s;
    v[0]=0;
    v[1]=0;
    for(ll i=2;i<v.size();i++){
        if(v[i]==0) continue;
        else{
            for(ll j=2;i*j<v.size();j++) v[i*j]=0;
        }
    }
    for(ll i=0;i<v.size();i++){
        if(v[i]==1&&i%5==1){
            ans.push_back(i);
        }
    }
    for(ll i=0;i<N;i++){
        cout<<ans[i];
        if(i!=N-1) cout<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        ll n,k;
        cin>>n>>k;
        ll arr[n],dp[n+5];
        for(int i=0;i<n;i++){
            cin>>arr[i];
            dp[i]=INT_MAX;
        }
        dp[0]=0;
        for(int i=1;i<n;i++){
            for(int j=max(0,i-k);j<i;j++){
                dp[i]=min(dp[j]+abs(arr[i]-arr[j]) ,dp[i]);
            }
        }

        cout<<dp[n-1]<<endl;

        

        
    return 0;                               // Reading input fromSTDIN
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}  

bool check(vl &vec,ll mid ,ll k)
{
  ll cuts=0;
  for(ll i:vec)
  {
    cuts+=((i-1)/mid);
  }
 
  if(cuts<=k)
    return true;
  else return false;
} 
     
int main()
{
      
  fast;
  ll n,k;
  cin>>n>>k;
  vl vec(n);
  fr(i,0,n) cin>>vec[i];
  ll l=1,r=1e10;
  ll mid;
  while(l<r)
  {
    mid=(r-l)/2+l;
    if(check(vec,mid,k)) r=mid;
    else l=mid+1;
    mid = (r -l)/2 + l;

  }

  cout<<mid<<endl;
    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 4788
#include <iostream>
#include <queue>
using namespace std;
enum Query
{
    insert = 0,
    getMax = 1,
    deleteMax = 2,
};
std::istream &operator>>(std::istream &is, Query &i)
{
    int tmp;
    if (is >> tmp)
        i = static_cast<Query>(tmp);
    return is;
} //オペレーターオーバーロード
int main()
{
    typedef priority_queue<int> que;
    int n;
    cin >> n;
    vector<que> Q(n);

    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        Query query;
        int t;
        cin >> query >> t;
        que &qt = Q.at(t);

        if (query == insert)
        {
            int x;
            cin >> x;
            qt.push(x);
        }
        if (query == getMax)
        {
            //空ならなにもしない
            if (!qt.empty())
            {
                cout << qt.top() << endl;
            }
        }
        if (query == deleteMax)
        {
            //空の時はなにもしない
            if (!qt.empty())
            {
                qt.pop();
            }
        }
    }
}


Measured memory_bytes: 4032
//============================================================================
// Name        : TopCoderCompetition.cpp
// Author      : taguchi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <bitset>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <numeric>
#include <list>
#include <sstream>
using namespace std;
//#define P pair<int,int>
//#define max 999999
typedef unsigned int uint;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(ull i = 0;i<n;i++)
#define pb(n) push_back(n)
#define clear(n) memset(n,0,sizeof(n))

typedef vector<int> vi;
typedef vector<string> vs;
struct edge{int cost,to;};

vector<string> split(string &in,char delimiter){
	vector<string> re; uint cur = 0,next;
	while((next = in.find_first_of(delimiter,cur)) != string::npos){
		re.pb(string(in,cur,next-cur));
		cur = next + 1;
	}
	re.pb(string(in,cur,in.size()-cur));
	return re;
}
vector<int> split_int(string &in, char delimiter){
	vector<string> str = split(in,delimiter);
	vector<int> re;
	rep(i,str.size()){
		re.pb(strtol(str[i].c_str(),NULL,10));
	}
	return re;
}

class Range{
public:
	int a,b;
	Range(int an,int bn) : a(an),b(bn){}

	bool operator()(int n){
		return a<=n&&n<=b;
	}
	bool isCross(Range x){
		return x(a) || x(b);
	}
	bool contains(Range x){
		return this->a <= x.a && x.b <= this->b;
	}
};


int main(){
	bitset<50020> primes;
	int indexpri[40000];
	memset(indexpri,0,sizeof(indexpri));
	int cnt = 0;
	primes.set();
	for(ul i = 2;i<50020;i++){
		if(primes[i]){
			indexpri[cnt++] = i;
			for(ul j = 2;j*i<50020;j++){
				primes[j*i] = false;
			}
		}
	}
	primes[1] = false;primes[0] = false;
	int results[50020];
	memset(results,0,sizeof(results));
	for(int n = 4;n<=50000;n++){

	}
	while(1){
		int n;
		cin >> n;
		if(n == 0)break;
		if(n % 2 == 1){
			if(binary_search(indexpri,indexpri+cnt,n-2)){
				cout << 1 << endl;
				continue;
			}
		}
		for(int i = 0;i<cnt && n-indexpri[i] > 0;i++){
			if(binary_search(indexpri,indexpri+i+1,n - indexpri[i])) results[n]++;
		}
		cout << results[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;
//--------------------

int main() {
	long res = INT_MAX;
    long myres = 0;
    long all = 0;
	long N, L; cin >> N >> L;
	for (int i = 1; i <= N; i++) all += L + i - 1;//すべて。
    long karires = 0;
    for(int j = 1; j <= N; j++) {for(int i = 1; i <= N; i++) {if(i != j) karires += L + i - 1;} res = min(res , abs(all - karires)); if(res == abs(all - karires)) myres = karires; karires = 0;}
	cout << myres << endl;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())
# print(X)
if X < 0 :
  X = -X

if K * D >= X:
  # print(X % D)
  # print(D - (X % D))
  if ((K - int(X / D)) % 2) == 0:
    print(X % D)
  else:
    print(D - (X % D))
else:
  print(X - (K * D))

Measured memory_bytes: 61728
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    int n, k;
    cin >> n >> k;
    int sol = 0;
    while (n--)
    {
        int temp;
        cin >> temp;
        if(temp >= k)
            sol++;
    }
    cout << sol;
    return 0;
}

/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/

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

int main(int argc, char *argv[])
{
	int i;
	int price;
	char order[8];
	cin >> order;
	price = 700;

	for (i = 0; i < 3; i++) {
		if (order[i] == 'o')
			price += 100;
	}

	cout << price;
	
	return 0;
}


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int a,b,sum,dif,pd;
  cin >> a >> b;
  sum=a+b;
  dif=a-b;
  pd=a*b;
  int max;
  if (dif < sum) max=sum;
  else max=dif;
  if (max < pd) max=pd;
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
L = [0]
R = [0]
import fractions
def GCD(a,b):
    if a*b != 0:
        return fractions.gcd(a,b)
    else:
        return max(a,b)
for i in range(N-1):
    x = A[i]
    y = A[-i-1]
    L.append(GCD(L[i],x))
    R.append(GCD(R[i],y))
ans = 0
for i in range(N):
    x = L[i]
    y = R[-i-1]
    ans = max(GCD(x,y),ans)
print(ans)

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4) {
        if (s[i] == '+') ans++;
        if (s[i] == '-') ans--;
    }
    cout << ans << endl;

    // 処理

    // 出力

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string s;
  while (cin >> s) {
    int v = 0;
    for (char c : s) {
      if (c == '+') ++v;
      if (c == '-') --v;
    }
    cout << v << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = input()
    ans = float('inf')

    for i in range(1, int(n)):
        a = i
        b = int(n) - i
        summed_a = sum(list(map(int, list(str(a)))))
        summed_b = sum(list(map(int, list(str(b)))))
        ans = min(ans, summed_a + summed_b)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#include<queue>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
int ceil(int a,int b){// a以上bの倍数の最小値//
     return (a+b-1)/b*b;
 }
int stoii(string s){//stoi関数の代用 文字列⇒int型//
    return atoi(s.c_str());
}

int R,C;
int sy,sx;
int gy,gx;
string c[51];
void solve(){
	queue<P> qp;
	qp.push({sy,sx});
}
int dp[1010][1010]={0};
int main(){
	int n;
	cin>>n;
	int waru=n;
	int sum=0;
	while(n>0){
		sum+=n%10;
		n=n/10;
	}
	if(waru%sum==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

#define FOR(i, s, e) for (int (i) = (s); (i) < (e); (i)++)

typedef long long ll;
const ll MOD = 1e9 + 7;

ll N;
ll dp[110][4][4][4] = {0};


int main() {
    cin >> N;
    FOR(i, 0, 4) {
        FOR(j, 0, 4) {
            FOR(k, 0, 4) {
                dp[2][i][j][k] = 1;
            }
        }
    }
    dp[2][2][0][1] --;
    dp[2][0][2][1] --;
    dp[2][0][1][2] --;

    FOR(i, 2 , N) {
        FOR(x, 0, 4){
            FOR(y, 0, 4){
                FOR(z, 0, 4) {
                    dp[i + 1][y][z][0] += dp[i][x][y][z];
                    dp[i + 1][y][z][3] += dp[i][x][y][z];
                    if (!(y == 0 && z == 1)) {
                        dp[i + 1][y][z][2] += dp[i][x][y][z];
                    }
                    if (!((y == 2 && z == 0) || (y == 0 && z == 2) || (x == 0 && z == 2) || (x == 0 && y == 2))) {
                        dp[i + 1][y][z][1] += dp[i][x][y][z];
                    }

                    dp[i + 1][x][y][z] %= MOD;
                }
            }
        }
    }

    ll ans = 0;
    FOR(i, 0, 4) {
        FOR(j, 0, 4) {
            FOR(k, 0, 4) {
                ans += dp[N - 1][i][j][k];
                ans %= MOD;
            }
        }
    }

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


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

int main() {
  int N, K, ans;
  cin >> N >> K;
  ans = 0;

  vector<int> h(N);
  rep(i, N) {
    int input; 
    cin >> input;
    if (input >= K) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

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

  if (A >= K) {
    cout << (A-K) << " " << B << endl;
  } else {
    cout << 0 << " " << max(B-(K-A), 0LL) << endl;
  }

  return 0;
}


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

using namespace std;

int dfs (const vector <vector <int>> &graph, int node, vector <int> &length,
         vector <bool> &visited) {
    if (visited[node]) {
        return length[node];
    }

    int len = 0;
    visited[node] = true;

    for (auto &neighbor : graph[node]) {
        len = max(len, 1 + dfs(graph, neighbor, length, visited));
    }
    length[node] = len;
    return length[node];
}

int getLongestPath (const vector <vector <int>> &graph) {
    int n = graph.size();
    vector <int> maxlength(n);
    vector <bool> visited(n);
    
    for (int i = 1; i < n; ++i) {
        if (visited[i]) {
            continue;
        }
        dfs(graph, i, maxlength, visited);
    }
    return *max_element(maxlength.begin(), maxlength.end());
}


int  main () {
    int n, m;
    cin >> n >> m;
    vector <vector <int>> graph(n + 1, vector <int>());

    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        graph[u].emplace_back(v);
    }
    cout << getLongestPath(graph) << "\n";
    return 0;
}

Measured memory_bytes: 9472
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    { 
        int n;
        cin>>n;
        read(a,n);
       // sort(a,a+n);
        int sum=0,m=1e18;
        int maxx=*max_element(a,a+n);
        int minn=*min_element(a,a+n);
        for(int i=minn;i<=maxx;i++)
        {
            for(int j=0;j<n;j++)
            {
                sum+=((a[j]-(i))*(a[j]-(i)));
            }
           // cout<<sum;
            if(sum<m)
            m=sum;
            sum=0;
        }
        // if(sum<m)
        // m=sum;
        cout<<m;
        
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second
 
template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}
 
typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int x=0,y=0;
  FOR(i,1,n+1){
	x+=800;
    if(i%15==0) y+=200;
  }
  cout<<x-y<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  string s;
  cin >> s;
  ll sum = 0;
  for(int bit = 0; bit < (1<<(s.size()-1)); ++bit) {
    ll cur = 0;
    for (int i = 0; i < s.size(); ++i) {
      cur = 10*cur+(s[i]-'0');
      if (bit & (1<<i)) {
        sum += cur;
        cur = 0;
      }
    }
    sum += cur;
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  while(true){
    int n;
    cin>>n;
    if(n==0)return 0;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int sum=0;
    for(auto it:a)sum+=it;
    // sum/n >= a[i]
    //   |
    //   V
    // sum >= a[i]*n
    int ans=0;
    for(auto it:a)if(sum>=it*n)ans++;
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3200
import math
K = int(input())

def saiki(K):
    if K == 1:
        return 1
    sum = 0
    for i in range(K):
        for j in range(K-1):
            sum += math.gcd(math.gcd(i+1,j+1),K)*3
    sum += K
            
    return sum+saiki(K-1)
        
    
sum = saiki(K)
print(sum)

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

int main() {

    string s;
    cin >> s;

    set<char> charset;

    for(int i = 0; i < s.size(); i++){
          charset.insert(s.at(i));
    }

   int count = 0;
   char c;
   for(auto itr = charset.begin(); itr != charset.end(); itr++){
      
      if( *itr != 97+count ){
            c = 97+count;
            cout << c << endl;
            return 0;
      }

      count++;
   }

   if(count == 26)
      cout << "None" << endl;
   else
      cout << (c = 97+count) << endl; 
}



Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<ll> l(n + 2), r(n + 2);
  for (int i = 0; i < n; ++i) {
    l[i + 1] = l[i] + a[i];
  }
  for (int i = n; i >= 1; --i) {
    r[i] = r[i + 1] + a[i - 1];
  }
  ll ans = 1e18;
  for (int i = 1; i < n; ++i) {
    ans = min(ans, abs(l[i] - r[i + 1]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7216
#include <iostream>
#include <cstring>
using namespace std;
int mp[2][20010];

int solve(int goal){
  int x=0,y=0,cost=0,f=1;
  while(x!=goal+1) {
    if(f&&mp[0][x])f=0;
    if(f&&mp[1][x])f=0,cost++;

    if(mp[1][x])y=1,mp[1][x]=0;
    else if(mp[0][x])y=mp[0][x]=0;
    else x++;
    cost++;
  }
  if(y==1)cost++;
  return cost-1;
}

int main(){
  int q;
  cin>> q;
  while(q--){
    int n,pos;
    cin>>n;
    memset(mp,0,sizeof(mp));

    for(int i=0;i<2;i++){
      pos=0;
      for(int j=0,cnt=1;j<2*n;j++){
	char a;
	cin>> a;
	mp[i][pos] |= a/'Y';
	cnt++;
	if(cnt%2==0)pos++;
      }
    }
    cout<<solve(pos)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1324
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

void solve(){
    int N;
    cin >> N;
    lint K[N],L[N],R[N];
    lint ans=0;
    rep(i,N) cin >> K[i] >> L[i] >> R[i];
    rep(i,N) ans+=min(L[i],R[i]);
    rep(i,N) if(L[i]<R[i]) K[i]=N-K[i];
    vector<lint> left[N+1],right[N+1];
    rep(i,N){
        if(L[i]>R[i]) left[K[i]].push_back(L[i]-R[i]);
        else right[K[i]].push_back(R[i]-L[i]);
    }
    priority_queue<lint,vector<lint>,greater<lint>> l,r;
    for(int i=1;i<=N;i++){
        rep(j,left[i].size()) l.push(left[i][j]);
        rep(j,right[i].size()) r.push(right[i][j]);
        while(l.size()>i) l.pop();
        while(r.size()>i) r.pop();
    }
    while(!l.empty()) ans+=l.top(),l.pop();
    while(!r.empty()) ans+=r.top(),r.pop();
    cout << ans << endl;
}

int main(void){
    int T;
    cin >> T;
    while(T--) solve();
}

Measured memory_bytes: 24368
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define MP(a,b) make_pair(a,b)
#define PB push_back

typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;
const int mod = 1e9 + 7;

int dp[410][410];
int N,C,A[410],B[410];
int sum[410][410];

int main(){
	for(int j = 1; j <= 400; ++j) sum[0][j] = 1;
	for(int j = 1; j <= 400; ++j){
		sum[1][j] = j;
		for(int i = 2; i <= 400; ++i){
			sum[i][j] = 1ll * sum[i - 1][j] * j % mod;
		}
	}
	for(int i = 0; i <= 400; ++i){
		for(int j = 1; j <= 400; ++j){
			sum[i][j] = (sum[i][j] + sum[i][j - 1]) % mod;
		}
	}
	scanf("%d%d",&N,&C);
	for(int i = 1; i <= N; ++i){
		scanf("%d",&A[i]);
	}
	for(int i = 1; i <= N; ++i){
		scanf("%d",&B[i]);
	}
	dp[0][0] = 1;
	for(int i = 1; i <= N; ++i){
		for(int j = 0; j <= C; ++j){
			for(int k = 0; k <= j; ++k){
				// dp[i - 1][k] --> dp[i][j]
				dp[i][j] = (dp[i][j] + 1ll * dp[i - 1][k] * (sum[j - k][B[i]] - sum[j - k][A[i] - 1]) % mod) % mod;
				if(dp[i][j] < 0) dp[i][j] += mod;
			}
		}
	}
	printf("%d\n",dp[N][C]);
	return 0;
}

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

using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;

	int min = L;
	int sum = 0;
	for (int i = L; i <= L + N - 1; i++) {
		if (abs(i) < abs(min)) {
			min = i;
		}
		sum += i;
	}

	cout << sum - min << endl;

	return 0;
}


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

using namespace std;

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

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

    return 0;
}


Measured memory_bytes: 3644