akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
bool index(int s,int k){
  if(s>k) return true;
  else return false;
}
int main(){
  int d,n,m;
  while(cin>>d,d){
    cin >> n >> m;
    int s[n+1],k,ans = 0;
    for(int i=1;i<n;i++) cin >> s[i];
    s[0] = 0;
    s[n] = d;
    sort(s,s+n+1);
    for(int i=0;i<m;i++){
      cin >> k;
      int max = n;
      int mins = 0;
      while(max-mins>1){
	int a = (max+mins) / 2;
	if(index(s[a],k)) max = a;
	else mins = a;
      }
      ans += min(abs(k-s[max]),abs(k-s[mins]));
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1568
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 2005
#define INF 10000000000005LL
#define MOD 1000000007

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

int n;

P A[SIZE];

ll dp[SIZE][SIZE];

int main(){

  cin >> n;
  rep(i,0,n){
    cin >> A[i+1].first;
    A[i+1].second = (ll)i+1LL;
  }
  sort(A+1,A+n+1,greater<P>());

 dp[0][0] = 0;
 rep(i,0,n+1) rep(j,0,n+1) if(i+j != 0) if(i+j <= n) {
   ll p1 = (ll)i;
   ll p2 = (ll)(n-j+1);
   ll m1,m2;m1=m2=-INF;
   if(i-1>=0) m1 = A[i+j].first*(A[i+j].second-p1) + dp[i-1][j];
   if(j-1>=0) m2 = A[i+j].first*(p2-A[i+j].second) + dp[i][j-1];

   dp[i][j] = max(m1,m2);
 }

 /*
 rep(i,0,n+1) {
   rep(j,0,n+1) cout << dp[i][j] << " ";
   cout << endl;
 }
 */

 ll ans = 0;
 rep(i,0,n+1){
   ans = max(ans,dp[i][n-i]);
 }
 cout << ans << endl;

  return 0;
}


Measured memory_bytes: 26256
S = input()
ans = True

if S[0] != 'A':
    ans = False
elif S[2:-1].count('C') != 1:
    ans = False
elif not (S[1] + S[2:-1].replace('C', '') + S[-1]).islower():
    ans = False
print('AC' if ans else 'WA')


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

using namespace std;

typedef long long i64;

i64 f(i64 x) {
    i64 fx = 0;
    for (; x; fx += x % 10, x /= 10);
    return fx;
}

int main() {
    i64 K, x = 1, fx = 1, nx, fnx;
    scanf("%lld", &K);
    while (K --) {
        printf("%lld\n", x);
        nx = x + 1;
        fnx = f(nx);
        for (i64 dx = 1; dx <= x + 1; dx *= 10) {
            i64 tx = x + dx;
            i64 ftx = f(tx);
            if (nx * ftx > tx * fnx) {
                nx = tx;
                fnx = ftx;
            }
        }
        x = nx;
        fx = fnx;
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s; cin >> s;
    string tmp = "";
    REP(i, s.size()) {
        if (s[i] == '0') {
            tmp += '0';
        } else if (s[i] == '1') {
            tmp += '1';
        } else if (tmp.size() > 0) {
            tmp = tmp.substr(0, tmp.size()-1);
        }
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 3492
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d", &a,&b);
	if((a==1)&&(b==2))
	printf("3\n");
		if((a==2)&&(b==1))
	printf("3\n");
		if((a==3)&&(b==1))
	printf("2\n");
		if((a==1)&&(b==3))
	printf("2\n");
		if((a==2)&&(b==3))
	printf("1\n");
		if((a==3)&&(b==2))
	printf("1\n");
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                var x = new StringBuilder();
                for (int j = 0; j < s.Length; j++)
                {
                    x.Append(s[(i + j) % s.Length]);
                }
                if (x.ToString() == t)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<string>> snake(h, vector<string>(w));
  int row = -1;
  int column = -1;
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      cin >> snake[i][j];
      if(snake[i][j] == "snuke") {
        row = i + 1;
        column = j;
      }
    }
  }

  char c = 'A' + column;

  cout << c << row << endl;
}

Measured memory_bytes: 256
#include <stdio.h> 
#include <stdlib.h> 
#include <vector> 
#include <memory.h> 
using namespace std; 
const int N=100; 
int n,m,cnt; 
bool b[N]; 
vector <int> a[N]; 
  
void DFS(int u){ 
    b[u]=true; 
  
    bool ok=true; 
    for (int i=1;i<=n;i++) 
        if (b[i]==false) ok=false; 
    if (ok) cnt++; 
  
    for (int i=0;int v=a[u][i];i++) 
        if (b[v]==false) DFS(v); 
    b[u]=false; 
} 
  
int main(){ 
    scanf("%d%d",&n,&m); 
    int x,y; 
    for (int i=1;i<=m;i++){ 
        scanf("%d%d",&x,&y); 
        a[x].push_back(y); 
        a[y].push_back(x); 
    } 
  
    for (int i=1;i<=n;i++){ 
        a[i].push_back(0); 
        b[i]=false; 
    } 
  
    cnt=0; 
    DFS(1); 
  
    printf("%d",cnt); 
} 

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

class prog{
  static void Main(){
    int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
    
    int ans;
    if (input[1] < input[2]||input[0] > input[3]) ans = 0;
    else if ((input[0] <= input[2]&&input[1] >= input[3])||(input[0] >= input[2]&&input[1] <=input[3])) ans = Math.Min(input[1] - input[0], input[3] - input[2]);
    else ans = Math.Min(input[1] - input[2], input[3] - input[0]);
    
    Console.WriteLine(ans);
    
  }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int a, b;
  cin >> a >> b;

  int cnt = 0;
  int now = 1;
  while (now < b) {
    cnt++;
    now--;
    now += a;
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3596
from itertools import permutations

C = [list(map(int, input().split())) for _ in range(3)]
A = [0, 1, 2]

ans = []

for x in permutations(A, 3):
  temp = 0
  for j in range(3):
    temp += C[j][x[j]]
  ans.append(temp)
    
if len(set(ans)) == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 8860
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    set<int> st;
    bool ans = true;
    REP(i,n) {
        int a; cin >> a;
        auto ret = st.insert(a);
        if (ret.second == false) ans = false;
    }

    CFYN(ans)

    return 0;
}

Measured memory_bytes: 9600
n, m, *x = map(int, open(0).read().split())
if n >= m:
  print(0)
  quit()
x = sorted(set(x))
lst = [j - i for i, j in zip(x, x[1:])]
lst.sort(reverse=1)
s = sum(lst[n - 1:])
print(s)


Measured memory_bytes: 14972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		char op = sc.next().charAt(0);
		int b = sc.nextInt();

		int ans = op == '+' ? a + b : a - b;

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {
    int a, b, c;
    int i;
    int count = 0;

    scanf("%d %d %d", &a, &b, &c);

    for(i = a; i <= b; i++){
       if(c % i == 0) count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, d;
  cin >> n >> d;
  int ans = 0;
  while (n--)
  {
    int x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      ans++;
  }
  cout << ans;

}


Measured memory_bytes: 3668
from collections import deque

N = int(input())

edge = [[] for _ in range(N)]
check = [False] * N
dist = [0] * N

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1].append((v-1,w))
    edge[v-1].append((u-1,w))

q = deque([0])

while q :
    current = q.popleft()
    if check[current] :
        continue

    check[current] = True
    for ad , w in edge[current] :
        if not check[ad] :
            q.append(ad)
            dist[ad] = dist[current] + w

for w in dist :
    print(w % 2)

Measured memory_bytes: 43892
n, m, x = map(int, input().split())
inn = [ list( map(int, input().split() ) ) for _ in range(n) ]
c = [inn[_][0] for _ in range(n) ]
ara = [ inn[_][1:] for _ in range(n)]

ans = 1e9

for mask in range(2**15):
	cost = 0
	cnt = [0 for _ in range(m)]
	for i in range(n):
		if ( (1 << i) & mask ) == 0:
			continue
		cost += c[i]
		for j in range(m):
			cnt[j] += ara[i][j]
	ok = 1
	for i in range(m):
		if cnt[i] < x:
			ok = 0
	if ok:
		ans = min(ans, cost)

if ans == 1e9:
	ans = -1

print(ans)





Measured memory_bytes: 9068
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;

#define MAX_N 500000
#define INF 1145141919

vector<int>G[MAX_N];
list<int> out;
bool V[MAX_N];
int N, M, b, c[MAX_N], d;
int indeg[MAX_N];
queue<int>Q;

void bfs(int s) {
	Q.push(s);
	V[s] = true;
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		out.push_back(u);
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			indeg[v]--;
			if (indeg[v] == 0 && V[v] == false) { V[v] = true; Q.push(v); }
		}
	}
}

void Tsort() {
	for (int i = 0; i < N; i++) {
		indeg[i] = 0;
	}
	for (int u = 0; u < N; u++) {
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			indeg[v]++;
		}
	}
	for (int u = 0; u < N; u++) {
		if (indeg[u] == 0 && V[u] == false) {
			bfs(u);
		}
	}
	b = 0; d = 0;
	for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
		cout << *it << endl;
		c[b] = *it;
		if (b >= 1) {
			for (int i = 0; i < G[c[b - 1]].size(); i++) {
				if (G[c[b - 1]][i] == c[b]) {
					goto F;
				}
				d = 1;
			F:;
			}
		}
		b++;
	}
	//cout << d << endl;
}

int main() {
	int s, t;
	for (int i = 0; i < MAX_N; i++) { G[i].clear(); }
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> s >> t;
		G[s].push_back(t);
	}
	Tsort();
	return 0;
}

Measured memory_bytes: 16080
/*Lucky_Glass*/
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=10000;
typedef pair<int,int> pii;
#define fir first
#define sec second

int n;
vector<int> lnk[N+3];
priority_queue< pii > que;
int du[N+3],num[N+3],ans[N+3];
long long tot;
bool del[N+3];

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		lnk[u].push_back(v);
		lnk[v].push_back(u);
	}
	for(int i=1;i<=n;i++) scanf("%d",&num[i]);
	sort(num+1,num+1+n);
	for(int i=1;i<=n;i++)
		que.push(make_pair(-(du[i]=lnk[i].size()),i));
	for(int t=1;t<=n;t++){
		while(del[que.top().sec]) que.pop();
		int u=que.top().sec;que.pop();
		del[u]=true;
		ans[u]=num[t];
		for(int i=0;i<lnk[u].size();i++){
			int v=lnk[u][i];
			if(del[v]) continue;
			tot+=num[t];
			que.push(make_pair(-(--du[v]),v));
		}
	}
	printf("%lld\n",tot);
	for(int i=1;i<=n;i++){
		printf("%d",ans[i]);
		if(i==n) printf("\n");
		else printf(" ");
	}
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
//#define int __int128
//#define ll __int128
typedef pair<int, int   > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
//typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#define mp(a, b) make_pair(a, b)

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

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

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

ll ans = 0;


void gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (!b) {
        ans -= a;
        return;
    }
    ll cnt = a / b;
    ans += cnt * b * 2;
    gcd(b, a % b);
}


void smain() {

    ll n, x;
    cin >> n >> x;
    gcd(n - x, x);
    cout << ans + n;
}


Measured memory_bytes: 256
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define ll  long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<b;++i)
#define repb(i,a,b) for(LL i=a;i>b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL a[2000], n;

int main()
{
	FIO;
	cin >> n;
	rep(i,0,n) cin >> a[i];
	sort(a, a+n);
	LL ans = 0;
	rep(i,0,n) rep(j,i+1,n) rep(k,j+1,n) if(a[i] + a[j] > a[k] && a[i] != a[j] && a[j] != a[k] && a[k] != a[i]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
using namespace std;
char A[310000];
char B[310000];
int p[310000];
int q[310000];
int bit[310000];
set<int>zero;
set<int>two;
set<int>bb;
int sum(int a,int b){
	if(a)return sum(0,b)-sum(0,a-1);
	int ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret;
}
void add(int a,int b){
	for(;a<310000;a|=a+1)bit[a]+=b;
}
char in[2];
int main(){
	int a;
	scanf("%d",&a);
	scanf("%s%s",A,B);
	int as=strlen(A);
	int bs=strlen(B);
	two.insert(-1);
	zero.insert(-1);
	for(int i=0;i<as;i++){
		p[i]=A[as-1-i]-'0';
	}
	for(int i=0;i<bs;i++){
		q[i]=B[bs-1-i]-'0';
	}
	int sz=max(as,bs)+1;
	for(int i=0;i<sz;i++){
		if(p[i]+q[i]==2)two.insert(i);
		if(p[i]+q[i]==0)zero.insert(i);
		if(q[i])bb.insert(i);
		if(p[i])add(i,1);
	}
	for(int i=0;i<a;i++){
		scanf("%s",in);
		if(in[0]=='Q'){
			int at=*(bb.rbegin());
			int val=sum(at,sz);
			int ret=val+at;
			if(p[at]==0){
				int nt=*(--(two.lower_bound(at)));
				int nz=*(--(zero.lower_bound(at)));
		//		printf("%d %d\n",nt,nz);
				if(nt>nz){
					ret++;
				}
			}
			printf("%d\n",ret);
		}else if(in[0]=='A'){
			int t;scanf("%d",&t);
			if(p[t]==0){
				if(q[t]+p[t]==0)zero.erase(t);
				p[t]=1;
				if(q[t]+p[t]==2)two.insert(t);
				add(t,1);
			}else{
				if(q[t]+p[t]==2)two.erase(t);
				p[t]=0;
				if(q[t]+p[t]==0)zero.insert(t);
				add(t,-1);
			}
		}else{
			int t;scanf("%d",&t);
			if(q[t]==0){
				if(q[t]+p[t]==0)zero.erase(t);
				q[t]=1;
				if(q[t]+p[t]==2)two.insert(t);
				bb.insert(t);
			}else{
				if(q[t]+p[t]==2)two.erase(t);
				q[t]=0;
				if(q[t]+p[t]==0)zero.insert(t);
				bb.erase(t);
			}
		}
	}
}

Measured memory_bytes: 19128
import java.util.*;


public class Main {
	//template
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		//
		new Main().aoj0533();
	}

	int min(int[] arr){
		int ret = arr[0];
		for(int i = 0; i < arr.length; i++){
			if(ret>arr[i])ret = arr[i];
		}
		return ret;
	}
	
	int max(int[] arr){
		int ret = arr[0];
		for(int i = 0; i < arr.length; i++){
			if(ret<arr[i])ret = arr[i];
		}	
		return ret;
	}
	
	int sum(int[] array){
		int sum = 0;
		for(int v : array){
			sum += v;
		}
		return sum;
	}
	
	
	//--------------------------
	
	void aoj0533(){
		int[] wp = new int[10];
		int[] kp = new int[10];
		for(int i=0; i<10; i++){ wp[i] = sc.nextInt(); }
		for(int i=0; i<10; i++){ kp[i] = sc.nextInt(); }
		
		Arrays.sort(wp); Arrays.sort(kp);
		System.out.println((wp[9]+wp[8]+wp[7]) + " " + (kp[9]+kp[8]+kp[7]));
	}
}

Measured memory_bytes: 15348
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int N;
    cin>>N;
    int cnt=0;

    for(int i=1;i<=N;i+=2) {
        int count=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) {
                count++;
            }
        }
        if(count==8) cnt++;
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    long long int a,b,n,max=0,before,after,x;
    (void)scanf("%lld %lld %lld",&a,&b,&n);
        x=b-1;
        if(n<x)x=n;
        before=(a*x)/b;
        after=x/b;
        max=before-a*after;
    printf("%lld\n",max);
    return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
#define test int t; cin >> t; while (t--)
#define fast ios::sync_with_stdio(NULL); cin.tie(NULL)
#define mod 1073741824
#define endl "\n"
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define all(v) v.begin(),v.end()
#define ll long long
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pb push_back
#define time 1.0 * clock() / CLOCKS_PER_SEC
ll MAX=10e10;

int main(){
    fast;
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int k = sc.nextInt();
    String S = sc.next();
    k--;

    StringBuilder sb = new StringBuilder();
    sb.append(S);
    if(sb.charAt(k)=='A'){
      sb.setCharAt(k, 'a');
    }else if(sb.charAt(k)=='B'){
      sb.setCharAt(k, 'b');
    }else{
      sb.setCharAt(k, 'c');
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 20684
import java.util.*;

public class Main {
	public static void main(String[]  args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m[][] = new int[n][n];
		boolean fixed[] = new boolean[n];
		int d[] = new int[n];
		
		for (int i = 0; i < n; i ++) {
			int u = scanner.nextInt();
			for (int j = 0; j < n; j ++) {
				m[u][j] = 100000 * n + 1;
			}
			int k = scanner.nextInt();
			for (int j = 0; j < k; j ++) {
				m[u][scanner.nextInt()] = scanner.nextInt();
			}
			d[i] = Integer.MAX_VALUE;
		}
		
		scanner.close();
		
		d[0] = 0;
		int u = 0;
		
		for(int i = 0; i < n; i ++) {
			fixed[u] = true;
			for (int j = 0; j < n; j ++) {
				if (fixed[j] == false && d[u] + m[u][j] < d[j]) {
					d[j] = d[u] + m[u][j];
				}
			}
			
			int mincost = Integer.MAX_VALUE;
			for (int j = 0; j < n; j ++) {
				if (fixed[j] == false && d[j] < mincost) {
					mincost = d[j];
					u = j;
				}
			}
		}
		
		for (int i = 0; i < n; i ++) {
			System.out.println(i + " " + d[i]);
		}
	}
} 



Measured memory_bytes: 39872
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    char s[3];
    
    cin >> s;

    if(strcmp(s,"ABC")==0)
    cout << "ARC";
  
    else if(strcmp(s,"ARC")==0)
    cout << "ABC";
    
return 0;
}

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

int main()
{

    unsigned long int X;
    unsigned long int Xout;

    cin >> X;
    
    Xout = (X / 500) * 1000;
    Xout = Xout + (X % 500) / 5 * 5;

    cout << Xout;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  ll n;
  cin >> n;
  if(n%2==0){cout << n << endl;}else{cout << 2*n << endl;}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={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; }

int main(){
    int ans=0;
    int K,S; cin >> K >> S;
    for (int x=0; x<=K; x++){
        for (int y=0; y<=K; y++){
            if (S-(x+y)>=0 && S-(x+y)<=K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll modinv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = modinv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

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

    init(s * 2);

    ll r = 0;
    for (int n = 1;; n++) {
        int x = s - n * 3;
        if (x < 0) break;

        r += comb(x + n - 1, x);
    }

    cout << r % P << endl;

    return 0;
}

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

class Dice
{
public:
    int f[6];
    Dice(){}
    void roll_z(){ roll(1, 2, 4, 3); }
    void roll_y(){ roll(0, 2, 5, 3); }
    void roll_x(){ roll(0, 1, 5, 4); }
    void roll(int i, int j, int k, int l){
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    }
    void move(char ch){
        if (ch == 'E') for (int i = 0; i < 3; i++) roll_y();
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S') for (int i = 0; i < 3; i++) roll_x();
    }
    bool eq(Dice other){
        for (int i = 0; i < 6; i++)
            if (f[i] != other.f[i])
                return false;
        return true;
    }
    bool equals(Dice dice2){
        for (int i = 0; i < 6; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                if (eq(dice2))
                    return true;
                dice2.roll_z();
            }
            if (i % 2 == 0)
                dice2.roll_y();
            else
                dice2.roll_x();
        }
        return false;
    }
};

int n;
Dice dices[100];

bool check()
{
    for (int i = 0; i < n-1; i++)
        for (int j = i+1; j < n; j++)
            if (dices[i].equals(dices[j])) return false;
    return true;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 6; j++)
            cin >> dices[i].f[j];
    
    if (check())
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;

void solve(){

  for(int i=0; i<5; i++){
    int x;
    std::cin >> x;
    if(x==0){
      std::cout << i+1 << std::endl;
      return;
    }
  }
  
}

int main(void){

  solve();
  
  return 0;
}


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

int main() {
    ll n,h[100001];
    std::cin >> n;
    ll dp[100001];
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }
    dp[0] = 0;
    
    dp[1] = abs(h[1]-h[0]);
    
    for (int i = 2; i < n; i++) {
        dp[i] = min( dp[i-1]+abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]) );
    }
    std::cout << dp[n-1] << std::endl;
    
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long long int a,b,x,c,d,e;
    scanf("%lld %lld %lld",&a,&b,&x);
    if(a==0)
    {
        e=(b/x)+1;
    }
    else
    {
        c=(a-1)/x;
        d=b/x;
        e=d-c;
    }

    printf("%lld",e);
    return 0;

}

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

signed main(){
	int N,K;
    cin>>N>>K;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    vector<int> dp(K+1,-1);
    REP(i,a[0]) dp[i]=0;
    REP(i,K+1) REP(j,N){
        int k=i-a[j];
        if(k>=0) dp[i]=max(dp[i],1-dp[k]);
    }
    if(dp[K]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

Measured memory_bytes: 1152
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

def count(s):
    a = 0
    aa = 0
    b = 0
    bb = 0
    for i in range(len(s)):
        if s[i] == ")":
            if aa == 0:
                a = a + 1
            else:
                aa = aa - 1
        if s[i] == "(":
            aa = aa + 1
        if s[len(s)-1-i] == "(":
            if bb == 0:
                b = b + 1
            else:
                bb = bb - 1
        if s[len(s)-1-i] == ")":
            bb = bb + 1
    return [a, b]

N = int(input())

c = []
d = []
for i in range(N):
    s = input()
    e = count(s)
    if e[1] - e[0] >= 0: c.append(e)
    if e[0] - e[1] > 0: d.append(e)

c.sort(key=lambda x: x[0])
d.sort(key=lambda x: x[1], reverse=True)

c = c + d
# print(c)

f = 0
for cc in c:
    f = f - cc[0]
    if f < 0:
        print("No")
        sys.exit()
    f = f + cc[1]

if f == 0:
    print("Yes")
else:
    print("No")




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

int main(){
  int64_t n, k, ans, sub, r, r2;

  cin >> n >> k;

  if(n > k){
    r = n % k;
    r2 = k - r;

    if(r < r2){
      ans = r;
    }else{
      ans = r2;
    }
  }else{
    sub = k - n;

    if(sub < n){
      ans = sub;
    }else{
      ans = n;
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int nextInt();
int med3(int x, int y, int z);
void quickSort(int a[], int left, int right);
void sort(int a[], int size);


int N, A[100000], B[100000], a[100000], mnum, i;
long long int minus, plus;

int main(){
	N=nextInt();
	for(i=0; i<N; i++){
		A[i]=nextInt();
	}
	for(i=0; i<N; i++){
		B[i]=nextInt();
	}
	for(i=0; i<N; i++){
		a[i]=A[i]-B[i];
		if(a[i]>=0){
			plus += a[i];
		}else{
			minus += a[i];
			mnum++;
		}
	}
	if(plus + minus < 0){
		printf("-1\n"); return 0;
	}
	sort(a, N);
	for(i=0; i<N; i++){
		if(minus>=0){break;}
		minus += a[i];
	}
	printf("%d\n", mnum+i); return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}

int med3(int x, int y, int z){
	if(x < y){
		if (y < z){return y;}else if(z < x){return x;}else{return z;}
	} else {
		if (z < y){return y;}else if(x < z){return x;}else{return z;}
	}
}

void quickSort(int a[], int left, int right){
	if(left >= right){return;}
	int pivot = med3(a[left], a[left+(right-left)/2], a[right]);
	int l=left, r=right;
	while(1){
		while (a[l] > pivot){l++;}
		while (pivot > a[r]){r--;}
		if(l>=r){break;}
		int t=a[l]; a[l]=a[r]; a[r]=t;
		l++; r--;
	}
	quickSort(a, left, l-1);
	quickSort(a, r+1, right);
}

void sort(int a[], int size){
	quickSort(a, 0, size-1);
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, k, s; cin >> n >> k >> s;
    vint ans(n);
    if (s != inf) {
        rep(i,n) ans[i] = inf;
        rep(i,k) ans[i] = s;
    } else {
        rep(i,n) ans[i] = 1;
        rep(i,k) ans[i] = s;
    }
    rep(i,n) cout << ans[i] << " ";
}

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

struct NODE{
	int id = -100;
	int parent = -1;
	int num_children = -100;
	int depth = -100;
	vector<int> children;
};

void check_depth(NODE *nodes, int id, int d){
	nodes[id].depth = d;	

	for(int i=0; i<nodes[id].num_children; ++i){
		check_depth(nodes, nodes[id].children[i], d+1);
	}
}

void show(NODE *nodes, const int &n){
	for(int i=0; i<n; ++i){
		cout << "node " << nodes[i].id << ": ";
		cout << "parent = " << nodes[i].parent << ", ";
		cout << "depth = " << nodes[i].depth << ", ";

		if(nodes[i].parent == -1){
			cout << "root, ";
		}else if(nodes[i].num_children == 0){
			cout << "leaf, ";
		}else{
			cout << "internal node, ";
		}

		cout << "[";
		for(int j=0; j<nodes[i].num_children; ++j){
			cout << nodes[i].children[j];

			if(j != nodes[i].num_children - 1)
				cout << ", ";
		}
		cout << "]";

		cout << endl;
	}
}

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

	NODE *nodes = new NODE[n];
	int n_children;
	int temp;
	int id;
	for(int i=0; i<n; ++i){
		cin >> id >> n_children;
		nodes[id].id = id;
		nodes[id].num_children = n_children;
	
		for(int j=0; j<n_children; ++j){
			cin >> temp;
			nodes[id].children.push_back(temp);
			nodes[temp].parent = id;
		}
	}	

	// Find root
	int root_id;
	for(int i=0; i<n; ++i){
		if(nodes[i].parent == -1){
			root_id = i;
			break;
		}
	}

	check_depth(nodes, root_id, 0);	
	show(nodes, n);

	return 0;
}


Measured memory_bytes: 7716
#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,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i] >> p[i];
    const ll inf = 5e18;
    vector<ll> ans(n+1, inf);

    vector<vector<ll>> xcost(1<<n, vector<ll>(n, inf)), ycost(1<<n, vector<ll>(n, inf));
    rep(bit, 1<<n) {
        vector<int> xs, ys;
        xs.push_back(0); ys.push_back(0);
        rep(i, n) if (bit >> i & 1) xs.push_back(x[i]), ys.push_back(y[i]);
        rep(i, n) {
            rep(j, xs.size()) chmin(xcost[bit][i], 1LL * p[i] * abs(x[i] - xs[j]));
            rep(j, ys.size()) chmin(ycost[bit][i], 1LL * p[i] * abs(y[i] - ys[j]));
        }
    }
    
    auto cost = [&](vector<int>& how) {
                    int bitx = 0, bity = 0;
                    rep(i, n) {
                        if (how[i] == 1) bitx |= 1<<i;
                        if (how[i] == 2) bity |= 1<<i;
                    }
                    ll res = 0;
                    rep(i, n) if (!how[i]) {
                        res += min(xcost[bitx][i], ycost[bity][i]);
                    }
                    return res;
                };
    
    for (int bit = 0; bit < pow(3, n); ++bit) {
        int tmp = bit;
        vector<int> how(n);
        rep(i, n) {
            how[i] = tmp % 3;
            tmp /= 3;
        }
        int cnt = 0;
        rep(i, n) if (how[i]) cnt++;
        
        chmin(ans[cnt], cost(how));
    }
    rep(i, n+1) cout << ans[i] << endl;
}


Measured memory_bytes: 12936
n=int(input())
dp=[[0]*3 for x in range(n)]
umi,yama,ie=0,1,2
for i in range(n):
    ai,bi,ci=map(int,input().split())
    if i==0:
        dp[i][umi]=ai
        dp[i][yama]=bi
        dp[i][ie]=ci
        continue
    dp[i][umi]=max(dp[i-1][yama],dp[i-1][ie])+ai
    dp[i][yama]=max(dp[i-1][umi],dp[i-1][ie])+bi
    dp[i][ie]=max(dp[i-1][umi],dp[i-1][yama])+ci
print(max(dp[-1]))

Measured memory_bytes: 60268
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		long k = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		long ans = 1;

		if(b - a > 2 && k >= a - 1) {
			k -= a - 1;
			ans += a - 1;

			ans += (k / 2) * (b - a);
			ans += k % 2;
		} else {
			ans += k;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 23508
#include <stdio.h>

void insertionSort(int *a, int n, int g, int *cnt);

int main(int argc, char const *argv[])
{
  int n,i,a[1000001],cnt=0, m, g[101];

  scanf("%d", &n);
  for(i=0;i<n;i++)
    scanf("%d", a+i);

  g[0] = 1;
  for(i=1;i<100; i++) {
    g[i] = 3*g[i-1] +1;
    if(n< g[i]) {
      m = i;
      break;
    }
  }

  printf("%d\n", m);
  for(i=m-1;i>0;i--)
    printf("%d ", g[i]);
  printf("%d\n", g[i]);

  for(i=m-1;i>=0;i--)
    insertionSort(a,n,g[i], &cnt);

  printf("%d\n", cnt);
  for(i=0;i<n;i++)
    printf("%d\n", a[i]);

  return 0;
}

void insertionSort(int *a, int n, int g, int *cnt)
{
  int i,v,j;
  for(i=g;i<n;i++) {
    v = a[i];
    j = i - g;
    while(j>=0 && a[j] > v) {
      a[j+g] = a[j];
      j = j-g;
      (*cnt)++;
    }
    a[j+g] = v;
  }
}

Measured memory_bytes: 6660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int n, m, k, ans=0;
const int mod=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int i, j, temp=0;
    int a, b;
    cin>>n>>m>>a>>b;
    if(2*a>m||2*b>n)
    {
        cout<<-1;
        return 0;
    }
    for(i=0;i<b;i++)
    {
        for(j=0;j<a;j++) cout<<0;
        for(;j<m;j++) cout<<1;
        cout<<'\n';
    }
    for(;i<n;i++)
    {
        for(j=0;j<a;j++) cout<<1;
        for(;j<m;j++) cout<<0;
        cout<<'\n';
    }
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back

int main()
{
    ll n, q, m, a = 2, k, x, i, tc, j, ans = 1, l, sum = 0;
    map < ll, ll > mp;
    vector < ll > v;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a;
        v.pb(a);
        ans += mp[a];
        mp[a]++;
    }

    for(i = 0; i < n; i++){
        cout << ans - mp[v[i]] << endl;
    }

    return 0;
}


Measured memory_bytes: 11120
n=int(input())
#約数列挙
div=[]
for i in range(1,int((n**0.5)//1)+1):
    if(n%i==0):
        div.append(i)
        div.append(n//i)
div=sorted(list(set(div)))

ans=[0]
#iをmで割った商とiをmで割った余りが等しいときのm
#i//m + i%m
#m*x + x = i
#x = i/(m+1)
#m+1はiの約数
#xはm未満
for divi in div:
    m=divi-1
    if(n//divi < m):
        ans.append(m)
print(sum(ans))


Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
int l[3000],n,ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>l[i];
	sort(l,l+n);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			ans+=lower_bound(l,l+n,l[i]+l[j])-l-j-1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=1000006;

int n,a[N],sum[N];
char s[N];
bool one=false;
bool odd=false;
bool two=false;

inline int Abs(int x) {
	return x<0?-x:x;
}
bool C2(int n,int m) {
	return sum[n]-sum[m]-sum[n-m];
}
int main() {
	scanf("%d",&n); n--;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) {
		a[i]=Abs(s[i]-s[i+1]);
		if(!(i&1)) sum[i]=sum[i>>1]+1;
	}
	for(int i=1;i<=n;i++)
		sum[i]+=sum[i-1];
	for(int i=1;i<=n;i++) {
		if((a[i]&1)) {
			if(!C2(n-1,i-1))
				odd=!odd;
			one=true;
		} else if(a[i]==2)
			if(!C2(n-1,i-1))
				two=!two;
	}
	if(odd) puts("1");
	else if(one||!two) puts("0");
	else puts("2");
	return 0;
}

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

using ll=long long;

string s;
ll k;
ll f[111][2];

int main() {
    cin>>s>>k;
    set<char> sc;
    for (char c:s) sc.insert(c);

    if ((int)s.size()<2||(int)sc.size()<2) {
        ll res=1ll*s.size()*k;
        cout<<res/2ll;
        return 0;
    }

    f[0][0]=0;
    f[0][1]=1;
    int n=s.size();
    for (int i=1; i<n; ++i) {
        if (s[i]==s[i-1]) {
            f[i][0]=f[i-1][1];
            f[i][1]=min(f[i-1][0], f[i-1][1])+1ll;
        }
        else {
            f[i][0]=min(f[i-1][0], f[i-1][1]);
            f[i][1]=f[i][0]+1ll;
        }
    }
    ll ans_0=f[n-1][0], ans_1=f[n-1][1];
    f[0][0]=1;
    f[0][1]=1;
    for (int i=1; i<n; ++i) {
        if (s[i]==s[i-1]) {
            f[i][0]=f[i-1][1];
            f[i][1]=min(f[i-1][0], f[i-1][1])+1ll;
        }
        else {
            f[i][0]=min(f[i-1][0], f[i-1][1]);
            f[i][1]=f[i][0]+1ll;
        }
    }
    bool ok=f[n-1][0]==ans_0;
    ll res;
    if (ans_1<=ans_0) {
        res=ans_1*k;
    }
    else {
        res=ans_0*k;
        if (s[0]==s[n-1]&&!ok)
            res+=k-1ll;
    }
    cout<<res;
}


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

int main(){
    for (int i=0;; i++) {
        int x, y;
        cin >> x >> y;
        if (x==0 && y==0) break;
        if (x > y) {cout << y << " " << x << endl;}
        else {cout << x << " " << y << endl;}
        }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    reverse(a.begin(), a.end());
    for (int j = 0; j < n; ++j) {
        if (j == 0) cout << a[j];
        else cout << " " << a[j];
    }
    cout << endl;
}



Measured memory_bytes: 3112
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int  m, k , i;
//=======================

void solve() {
    int n ;
    cin>>n;

    // vector<int> fre(101,0);

    // fo(i,n){
    //     cin>>m;
    //     fre[m]++;
    // }

    // int a = -1 , b = -1;
    // int c = 0;
    // for(i = 0 ; (i<101) && (c<2);i++){

    //     cout<<fre[i]<<" at "<<i<<endl;

    //     if(fre[i]>=2)continue;

    //     else if(fre[i] == 1 && a<0)a = i,c++;
    //     else if ( fre[i] ==1)b  =i , c++;
    //     else {
    //         if(a<0)a = i;
    //         if(b<0)b = i;
    //         c+=2;
    //     }
    // }

    unordered_set<int> a,b;

    fo(i,n){
        cin>>m;

        if(a.count(m)){
            b.insert(m);
        }else {
            a.insert(m);
        }
    }

    fo(i, 101)if(!a.count(i))break;

    int ans = i;

    fo(i,101)if(!b.count(i))break;

    ans +=i;

    cout<<ans<<"\n";
}

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

    int t = 1;
    // ll a ,b ,c , d;
    // cin >> a>>b>>c>>d;

    // vector<long long> v{a*c,a*d,b*c,b*d,b*c};

    // cout<<*max_element(v.begin(),v.end());

    ll f ;

    cin>>f;

    if(f<2)cout<<0;
    else{

        ll c = 1e9 + 7;
        //i need 10^n - 8^n :)
        // A^B mod C = ( (A mod C)^B ) mod C
        ll ten = 1 , eight = 1 , nine = 1;

        for(int i = 0 ; i< f ; i++){
            ten = ((ten%c) * (10)) % c;
            //rasied to ?
            eight = ((eight%c) * (8)) % c;

            nine = ((nine%c) * (9)) % c;
        }

        cout<<( (ten + eight - nine -nine + c + c)%c);


    }

    // ll base = 0 , ans = 0;
    // ll mul  = 1;
    // while(mul<f){
    //     ans += f - mul + 1;
    //     mul *=3;
    // }

    return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const int INF=1e9+7;

int main() {
	ll D,G,r=INF;
	cin >> D >> G;
	vector<ll> p(D),c(D),s(D);

	rep(i,D) {
		cin >> p.at(i) >> c.at(i);
		s.at(i) = p.at(i)*(i+1)*100 + c.at(i);
	}
	
	rep(i,(int)pow(2,D)-1) {
		ll tq=0,ts=0,m=-1;
		rep(j,D)
			if(i>>j & 1) {
				tq += p.at(j);
				ts += s.at(j);
			} else
				m = j;

		if(ts >= G) {
			r = min(r,tq);
			continue;
		}

		rep(i,p.at(m)) {
			++tq;
			ts += (m+1)*100;
			if(i == p.at(m)-1)
				ts += c.at(m);
			if(ts >= G) {
				r = min(r,tq);
				break;
			}
		}
	}

	cout << r << endl;
}

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

int main(){
    ll x;
    cin>>x;
    ll flag=0;
    for(ll i=1;i<=x;++i){
        for(ll j=2;j<10;++j){
            if(pow(i,j)<=x){
                if(pow(i,j)>flag){
                    flag=pow(i,j);
                }
            }
        }
    }
    cout<<flag<<endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> L(n);
	rep(i, n) cin >> L[i];
	sort(L.begin(), L.end());
	int sum = 0;
	rep(i, n - 1) sum += L[i];
	if (sum > L[n - 1]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

typedef long long ll;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)
#define be(a) a.begin(),a.end()
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
    ll n,a;
    double sum=0;
    cin>>n;
    while(n--)
    {
        cin>>a;
        sum+=pow(a,-1);
    }
    cout<<pow(sum,-1);
    nl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int n, i, p;
    long long a, b, c, d;
    scanf("%d", &n);
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    p = 0;
    for(i = 0; i < n; ++i)
    {
        if(i * c - 1LL * (n - i - 1) * d <= b - a && i * d - 1LL * (n - i - 1) * c >= b - a)
        {
            p = 1;
            break;
        }
    }
    if(p)
        puts("YES");
    else
        puts("NO");
    return 0;
}


Measured memory_bytes: 256