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

int main()
{
  int H, W, N, mas[1000][1000], dp[1000][1000];

  while(scanf("%d %d %d", &H, &W, &N), H){
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        scanf("%d", &mas[i][j]);
        dp[i][j] = 0;
      }
    }
    dp[0][0] = N - 1;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(i + 1 < H) dp[i + 1][j] += (dp[i][j] + !mas[i][j]) >> 1;
        if(j + 1 < W) dp[i][j + 1] += (dp[i][j] + mas[i][j]) >> 1;
      }
    }
    int h = 0, w = 0;
    while(h != H && w != W){
      if((dp[h][w] + mas[h][w]) % 2) w++;
      else h++;
    }
    printf("%d %d\n", h + 1, w + 1);

  }
}

Measured memory_bytes: 9000
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '+')
                ans++;
            if (s.charAt(i) == '-')
                ans--;
        }
        System.out.println(ans);
    }

}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; i++) { cin >> p[i] >> c[i]; }
  int ans = INF;
  for (int i = 0; i < (1 << D); i++) {
    int need = G;
    int res = 0;
    for (int j = 0; j < D; j++) {
      if ((i >> j) & 1) {
        need -= ((j + 1) * 100 * p[j] + c[j]);
        res += p[j];
      }
    }
    for (int j = D - 1; j >= 0; j--) {
      if (!((i >> j) & 1)) {
        if (need > 0) {
          int sol = min(p[j], (need - 1) / 100 / (j + 1) + 1);
          need -= (j + 1) * 100 * sol;
          res += sol;
        }
      }
    }
    chmin(ans, res);
  }
  cout << ans << endl;

  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();
  return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int x = ri() - 1;
	int a[m];
	for (int i = 0; i < m; i++) a[i] = ri() - 1;
	int y = std::lower_bound(a, a + m, x) - a;
	std::cout << std::min(y, m - y) << std::endl;
	return 0;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll ans=0;
	int val=a[0];
	for(int i=0;i<n;i++){
		if(a[i]<val){
			ans+=val-a[i];
		}
		else{
			val=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

    int ans = count(s.begin(), s.end(), '2');
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

ll power(ll x,ll n){
    if(n==0) return 1;
    ll res=power(x*x%mod,n/2);
    if(n&1) res=res*x%mod;
    return res;
}

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  ll v[n];
  rep(i,0,n){
    cin>>v[i];
  }
  sort(v,v+n);
  reverse(v,v+n);
  ll sum=0;
  rep(i,0,a){
    sum+=v[i];
  }
  cout<<fixed<<setprecision(10)<<(sum+0.0)/a<<endl;
  int c=0;
  int d=0;
  int e=0;
  rep(i,0,n){
    if(v[i]>v[a-1]) c++;
    else if(v[i]==v[a-1]) d++;
    else e++;
  }
  if(c!=0){
    ll cur=1;
    rep(i,1,a-c+1){
      cur=cur*(d+1-i)/i;
    }
    cout<<cur<<endl;
  }
  else{
    ll ans=0;
    ll cur=1;
    rep(i,1,min(d,b-c)+1){
      cur=cur*(d+1-i)/i;
      if(i>=a-c) ans+=cur;
    }
    cout<<ans<<endl;
  }
}

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

int main(){
  int n,m;
  int k;
  int a;
  cin >> n >> m;
  int t[m] = {};
  for (int i=0;i<n;i++){
    cin >> k;
    for (int j=0;j<k;j++){
      cin >> a;
      t[a-1] += 1;
    }
  }
  int count = 0;
  for (int i=0;i<m;i++){
    if (t[i] == n) count += 1;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
//El Lool
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <string>
#include <string.h>
#include <vector>
#include <sstream>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))
void fast()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
string cop(vector<char>v)
{
	string x;
	for (int i = 0; i < sz(v); i++)
		x += v[i];
	return x;
}
 
int main()
{
	fast();
	int t, n, w;
	long long sum = 0, min = 1e18;
	vector<long long>v;
	string s;
	t=1;
 
	while (t--)
	{
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> w;
			sum += w;
			v.push_back(sum);
		}
		for (int i = 0; i < v.size() - 1; i++)
		{
			long long  x = v[i];
			long long y = sum - v[i];
			if (abs(x-y) < min)
				min = abs(x-y);
		}
		cout << min << endl;
		min = 1e18;
		v.clear();
		sum = 0;
	}
	return 0;
 
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <map>
using namespace std;

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

  int numbers[4];
  for (int i = 0; i < 4; i++) {
    cin >> numbers[i];
  }
  sort(numbers, numbers + 4);

  if (numbers[0] == 1 and numbers[1] == 4 and numbers[2] == 7 and numbers[3] == 9) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 201
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  if (s[s.size() - 1] != 's')
    s = s + "s";
  else
    s = s + "es";
  cout << s << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    vector<vector<ll>>cnt(10,vector<ll>(10,0));
    ll n;cin >>n;
    for (ll i = 1; i <=n; ++i) {
        ll b=i%10;
        ll keta;
        if(i<10)keta=0;
        else if(i<100)keta=1;
        else if(i<1000)keta=2;
        else if(i<10000)keta=3;
        else if(i<100000)keta=4;
        else keta=5;
        ll d=pow(10,keta);
        ll f=i/d;
        cnt[f][b]++;
    }
    ll ans=0;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            ans+=cnt[i][j]*cnt[j][i];
        }
    }
    cout <<ans <<endl;
    return 0;
}



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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

const int MAX = 7368791;
//const int MAX = 800000;

int main() {

  while(1){
    int m, n;
    cin>>m>>n;
    if(m==0 && n==0) break;

    bool sieve[MAX+1];
    REP(i,0,MAX+1) sieve[i] = true;

    int p = m;
    REP(i,0,n){
      while(!sieve[p]) p++;
      for(int j = p; j < MAX+1; j += p){
        sieve[j] = false;
      }
    }

    int ans = p;
    while(!sieve[ans]) ans++;
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 10180
n = int(raw_input())
p = map(float, raw_input().split())
dp = [[0.00 for i in xrange(3001)] for _ in xrange(3001)]

dp[0][1] = p[0]
dp[0][0] = 1.0-p[0]

for i in xrange(1, n):
    for j in xrange(i + 1):
        dp[i][j] += (1.0 - p[i]) * dp[i-1][j]
        dp[i][j+1] += p[i] * dp[i-1][j]

res = 0.0
for i in xrange(n + 1):
    red = n - i
    if i > red:
        res += dp[n-1][i]
print res
        
        



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

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){
 
  int n, k; cin >> n >> k;
  string s; cin >> s;
  vi v;
  if(s[s.length() - 1] == '1')s += '0';
  else s += '1'; 
    
  int cnt = 0;
  int sum = 1;
  if(s[0] == '0')v.pb(0);

  for(int i = 1; i < n + 1; i++){
    if(s[i] != s[i - 1]){ 
      v.pb(sum);
      sum = 1;
    }
    else 
      sum++;
  }
  if(v.size() % 2 == 0) v.pb(0);

  vector<ll> wa(v.size()+ 1, 0);

  rep(i, v.size()){
      wa[i + 1] = wa[i] + v[i];
  }

  int add = 2 * k + 1;
  ll ans = 0;
  for(int i = 0; i < v.size(); i += 2){
    int left = i;
    int right = min(i + add, (int)v.size());
    chmax(ans, wa[right] - wa[left]);
  }

  pr(ans);

  return 0;
}


Measured memory_bytes: 1656
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    if(len(Counter(S))==3):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 64108
def build_combinations_counter(N=10**5, p=10**9+7):
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # mod p におけるnの逆元 n^(-1)
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    
    def cmb(n, r, p, fact, factinv):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return fact[n] * factinv[r] * factinv[n-r] % p
    
    import functools
    return functools.partial(cmb, p=p, fact=fact, factinv=factinv)

def resolve():
    N, K = list(map(int, input().split()))
    A = sorted(list(map(int, input().split())))
    cmb = build_combinations_counter()
    ans = 0
    MOD = 10**9+7
    for i in range(N):
        if i >= K-1:
            ans += cmb(i, K-1)*A[i]
            ans %= MOD
        if N-i-1 >= K-1: 
            ans -= cmb(N-i-1, K-1)*A[i]
            ans %= MOD
    print(ans)

    
if __name__ == "__main__":
    resolve()



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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;

bool pal(string str){
	string temp = str;
	reverse(all(temp));
	return str == temp;
}

void solve(){
	ll L;
	cin >> L;
	double t = ((double)L)/3.0;
	double ans = t*t*t;
	cout << setprecision(10) << ans << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}




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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;

	Vi L(M), R(M);
	for (int i = 0; i < M; ++i) {
		cin >> L[i] >> R[i];
		--L[i]; --R[i];
	}

	Vi p(Q), q(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> p[i] >> q[i];
		--p[i]; --q[i];
	}

	vector<Vi> ans(N + 1, Vi(N + 1));
	for (int i = 0; i < M; ++i) {
		++ans[0][R[i]];
		--ans[L[i] + 1][R[i]];
		--ans[0][N];
		++ans[L[i] + 1][N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			ans[i][j + 1] += ans[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			ans[i + 1][j] += ans[i][j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		cout << ans[p[i]][q[i]] << endl;
	}

	return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>
 
int main(){
   int n;
  long long int k;
  scanf("%d%lld",&n,&k);
 
  long long int num[100001] = {0};
  for(int i = 1; i <=n; i++){
    int a,b;
    scanf("%d%d",&a,&b);
    num[a] += b;
  }
  for(int i = 1; i <= 100000; ++i){
    k = k-num[i];
    if( k <= 0 ){
      printf("%d",i);
      return 0;
    }
  }
 
  return 0;
 
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int r;
    while(cin>>n>>r,n)
    {
        int isi;
        int num[50]={0};
        int t=0;
        isi=r;
        while(true)
        {
            if(isi==0)
            {
                isi=num[t];
                num[t]=0;
                t++;
            }
            else if(isi>0)
            {
                num[t]++;
                isi--;
                t++;
            }
            if(t==n)t=0;
            if(isi==0)
            {
                int cnt=0;
                for(int i=0;i<n;i++)
                {
                    if(num[i]==0)cnt++;
                }
                if(cnt==n-1)break;
            }
        }
        for(int i=0;i<n;i++)
        {
            if(num[i]!=0)
            {
                cout<<i<<endl;
            }
        }
    }
    return 0;
}
 

Measured memory_bytes: 1160
#include <stdio.h>


int main(void) {

	// 1_3-A Print Many Hello World

	int i,nums = 0;
	int inum;
	int num[10000];

	for(i=0; i<10000; i++){
		scanf("%d",&inum);
		if(inum == 0){
			break;
		}
		num[i] = inum; 
		nums++;
	}
	for(i=0;i<nums;i++){
		printf("Case %d: %d\n",i+1,num[i]);
	}
        return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	string S;
	cin>>S;
	
	long long ans = 0;
	
	if(S.size()==1){
		cout<<S<<endl;
		return 0;
	}
	
	int num = 1;
	for(int i=0;i<S.size()-1;i++)num*=3;
	
	for(int i=0;i<num;i++){
		vector<int> V;
		int x = i;
		for(int j=0;j<S.size()-1;j++){
			V.push_back(x%3);
			x/=3;
		}
		bool f = true;
		for(int j=0;j<S.size()-1;j++){
			//if(V[j]==V[j+1]&&V[j]==0)f=false;
			if(V[j]==1)f=false;
		}
		if(!f)continue;
		long long now = 0;
		long long add = S[0]-'0';
		
		for(int j=0;j<S.size()-1;j++){
			if(V[j]==0){
				now += add;
				add = S[j+1]-'0';
			}
			else if(V[j]==1){
				now += add;
				add = -(S[j+1]-'0');
			}
			else{
				if(add>0){
					add = add*10 + (S[j+1]-'0');
				}
				else{
					add = add*10 - (S[j+1]-'0');
				}
			}
		}
		now += add;
		//cout<<now<<endl;
		ans += now;
		
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n), cnt(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		++cnt[a[i]];
	}
	ll answer = 0;
	for (int i = 0; i <= n; ++i) {
		answer += 1ll * cnt[i] * (cnt[i] - 1) / 2;
	}
	for (int i = 0; i < n; ++i) {
		ll ans = answer;
		ll x = cnt[a[i]];
		ans -= x * (x - 1) / 2;
		--x;
		ans += x * (x - 1) / 2;
		cout << ans << '\n';
	}
	cout << '\n';
 	return 0;
}


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

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

  int sum = A * 3 + P;

  cout << sum / 2 << endl;
}

Measured memory_bytes: 3572
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int max = 1;
		long x = A;
		while(true){
			if(x * 2 <= B){
				max++;
				x *= 2;
				continue;
			}
			break;
		}
		Console.WriteLine(max);
		
	}
	
	long A,B;
	public Sol(){
		var d = rla();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
import java.io._
import scala.io.StdIn.{readInt, readLine}

object Main {
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0
  class Node(var key:Int, var left:Node = null, var right:Node = null) { }

  def insert(tree:Node, key:Node) = {
    val keyNode = key
    def getNodeToInsert(node:Node):Node =
      if(node.key > keyNode.key) {
        if(node.left == null) node
        else getNodeToInsert(node.left)
      } else {
        if(node.right == null) node
        else getNodeToInsert(node.right)
      }

    val target = getNodeToInsert(tree)

    if(keyNode.key < target.key) target.left = keyNode
    else target.right = keyNode
  }

  def inOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      inOrder(tree.left)
      out.write(" ")
      out.write(tree.key.toString)
      if(count<100) count += 1
      else {
        out.flush
        count = 0
      }
      inOrder(tree.right)
    }

  def preOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      out.write(" ")
      out.write(tree.key.toString)
      if(count<100) count += 1
      else {
        out.flush
        count = 0
      }
      preOrder(tree.left)
      preOrder(tree.right)
    }

  def main(args:Array[String]) = {
    val n = readInt
    val tree = new Node(-1)

    for(i<-0 until n) {
      val s = readLine.split(" ")
      s(0) match {
        case "insert" =>
          if(tree.key == -1) tree.key = s(1).toInt
          else insert(tree, new Node(s(1).toInt))
        case _ => {
          inOrder(tree)
          out.write("\n")
          out.flush()
          preOrder(tree)
          out.write("\n")
          out.flush()
        }
      }
    }
  }
}

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

using namespace std;

int main(){
	int x,y;
	cin>>x>>y;
	for(int i=0;i<=x;i++){
		if(i*2+(x-i)*4==y){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3628
let cul a op b = match op with
    '+' -> Printf.printf "%d\n" (a + b)
  | '-' -> Printf.printf "%d\n" (a - b)
  | '*' -> Printf.printf "%d\n" (a * b)
  | '/' -> Printf.printf "%d\n" (a / b)
  | _ -> raise Not_found ;;
let checker a op b = (op <> '?') ;;
let parrot () =
  let s = ref "" in
  while (s := read_line(); (Scanf.sscanf !s "%d %c %d" checker))
  do
    Scanf.sscanf !s "%d %c %d" cul
  done ;;
parrot();;


Measured memory_bytes: 2464
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

/*
    Ball and Boxes 10
    分割数
*/

const ll MOD = 1000000007;
const int MAX_N = 1010;
const int MAX_K = 1010;
ll p[MAX_N][MAX_K];

void Partition_Number_init(){
    srep(i,0,MAX_N){
        srep(j,1,MAX_K){
            if(i <= 1 || j == 1){
                p[i][j] = 1;
            }else if(i < j){
                p[i][j] = p[i][j-1];
            }else{
                p[i][j] = p[i][j-1] + p[i-j][j];
            }
            p[i][j] %= MOD;
        }
    }
}

int main() {
    ll n, k;
    cin >> n >> k;

    Partition_Number_init();

    cout << p[n][k] << endl;
    return 0;
}
 
 



Measured memory_bytes: 11092
import sys

# sx, sy, tx, ty
sx, sy, tx, ty = map(int, input().split())

root = ""

# 1回目の　s => t
# まず、Y座標分上がる
root += "U" * (ty - sy)
# X座標分分右に移動
root += "R" * (tx - sx)

# 1回目の t => s
# まず、Y座標分下がる
root += "D" * (ty - sy)
# X座標分左に戻る
root += "L" * (tx - sx)

# 2回目の　s => t (sx - 1, sy) => (tx, ty + 1)
# まず、X座標に左に１つ移動し、座標分上がる
root += "L"
root += "U" * ((ty + 1) - sy)
# X座標分右に移動、Y座標を１つ下がる
root += "R" * (tx - (sx - 1))
root += "D"

# 2回目の t => s (tx + 1, ty) => (sx, sy - 1)
# まず、X座標に右に１つ移動し、Y座標分下がる
root += "R"
root += "D" * (ty - (sy - 1))
# X座標分左に移動し、Y座標を１つ上がる
root += "L" * ((tx + 1)  - sx)
root += "U"

print(root)

Measured memory_bytes: 3064
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>
#include <functional>

using namespace std;
using ll = long long;

#define all(x) (x).begin(),(x).end()
#define PRI(n) cout << n << " "<<endl;
#define PRI2(n, m) cout << n << " " << m << " "<<endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

struct edge;
struct UnionFind;

bool isPrime(ll x);

ll GCD(ll a, ll b);

ll LCM(ll a, ll b);

ll nCr(int n, int r);


struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int N) {
        for (int i = 0; i < N; ++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

ll M, N;

int main() {
    ll N, M;
    string S;
    cin >> N;
    ll sum = 0;
    vector<ll> A(N);
    REP(i, N) {
        ll a;
        cin >> a;
        A[i] = a - i + 1;
    }
    sort(all(A));
    ll ans = 0;
    REP(i, N) {
        ans += abs(A[i] - A[N / 2]);
    }
    PRI(ans)
    return 0;
}

struct edge {
    int to, cost;
    bool flag = false;
};

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) for (int j = min(i, r); j < 1; --j)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    cnt = 0
    
    mab = max(A,B)
    for i in range(mab,0,-1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            print(i)
            break




# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

const int N = 100'009;

int p[N];

int find(int x) {
  if (p[x] != x) {
    p[x] = find(p[x]);
  }
  return p[x];
}

int a[N];
vector<int> g[N];
bool was[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    --a[i];
  }
  for (int i = 0; i < n; ++i) {
    p[i] = i;
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    p[find(x)] = find(y);
  }
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < n; ++i) {
    g[find(i)].push_back(i);
  }
  memset(was, false, sizeof was);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j : g[i]) {
      was[a[j]] = true;
    }
    for (int j : g[i]) {
      if (was[j]) {
        ++ans;
      }
    }
    for (int j : g[i]) {
      was[a[j]] = false;
    }
  }
  printf("%d\n", ans);
}


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

typedef long long ll;

vector<pair<int, int> > adj[100002];
bool vis[100002], color[100002];

void dfs(int u, int b, int w) {
    //cout << "*" << u << " " << b << " " << w << endl;
    vis[u] = true;
    if(b & 1) color[u] = 1, w = 0;
    else b = 0;

    for(auto v : adj[u]) {
        if(vis[v.first]) continue;
        if(color[u] == 0) dfs(v.first, b + v.second, w + v.second);
        else dfs(v.first, b + v.second, w + v.second);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;

    for(int i = 1; i < n; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }

    dfs(0, 0, 0);

    for(int i = 0; i < n; i++) {
        cout << color[i] << endl;
    }
}

/**
1 / n * (1/2)^k
*/


Measured memory_bytes: 8192
#include<iostream>
using namespace std;
#define MAX_N 200010

int main() {
    long long n, a[MAX_N];
    long long dic[MAX_N]= {};

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

    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += dic[i] * (dic[i] - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        if (dic[a[i]] > 1) cout << sum - dic[a[i]] + 1 << endl;
        else cout << sum << endl;
    }
}

Measured memory_bytes: 6736
s = input()

b = int(s[:2])
a = int(s[2:])

def yorm(i):
    flag = 'none'
    if 0<i<=12:
        flag = 'MM'
    elif i<100:
        flag = 'YY'
    return flag

bf = yorm(b)
af = yorm(a)
   
ans = bf+af
if len(ans) != 4:
    ans = 'NA'
if ans == 'MMMM':
    ans = 'AMBIGUOUS'
if ans == 'YYYY':
    ans = 'NA'
print(ans)

Measured memory_bytes: 9084
N, Y = map(int, input().split())
a = -1
b = -1
c = -1

Y = Y//1000
for i in range(N+1):
    for j in range(N-i+1):
        if Y == i*9 + j*4 +N:
            a = i
            b = j
            c = N-i-j
            #print(a,b,c)
            break
        else:
            continue
        break
        
          
print(a, b, c , sep=(' '))


Measured memory_bytes: 40744
N = int(input())
A = []
B = []
for i in range (0,N):
	a, b = map(int, input().split())
	A.append(a)
	B.append(b)
    
A = sorted(A)
B = sorted(B)

from statistics import median

if N%2 ==1:
	print(median(B)-median(A)+1)
else:
	print(int((median(B)-median(A))*2+1))

Measured memory_bytes: 28328
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int N; std::cin >> N;
  std::cout << 180*(N-2) << std::endl;
  return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <string.h>
#include <ctype.h>


int main()
{
	char c;
	int N, M;
	int *time_box;
	int *juice_box;
	int num, bk, sum;
	int i, j;


	scanf("%d", &N);

	time_box = (int *)malloc(sizeof(int) * N);

	i = 0;
	while( (c = fgetc(stdin)) && i < N){
		if(isdigit(c)){
			ungetc(c, stdin);
			scanf("%d", &time_box[i]);
			i++;
		}
	}

	scanf("%d", &M);

	juice_box = (int *)malloc(sizeof(int) * M);

	// 出力処理
	for(i = 0; i < M; i++){
		scanf("%d %d", &num, &bk);

		sum = 0;
		for(j = 0; j < N; j++){
			if(j == num - 1)
				sum += bk;
			else
				sum += time_box[j];
		}
		printf("%d\n", sum);
	}

	return 0;
}

Measured memory_bytes: 128
//stop myself from getting UKE

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
char s[N];
map <char,int> cot;
int main(){
//a	freopen("1.txt","r",stdin);
	cin>>s+1;
	int len=strlen(s+1);
	for(int i=1;i<=len;i++) cot[s[i]]++;
	long long ans=len;
	ans*=(len-1);
	ans/=2;
	ans++;
	//cout<<len<<endl;
	//cout<<ans<<endl;
	for(int i=1;i<=len;i++) if(cot[s[i]]){
		long long dep=cot[s[i]];
		dep*=cot[s[i]]-1;
		dep/=2;
		ans-=dep;//'cot[s[i]]*(cot[s[i]]-1)/2;
		//cout<<cot[s[i]]<<" ";
		//cout<<ans<<endl;
		cot[s[i]]=0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        
        int adivb = a/b;
        int amodb = a % b;
        double adivb_f = a / (b * 1.0);
        
        System.out.printf("%d %d %f", adivb, amodb, adivb_f);
        
    }
}


Measured memory_bytes: 26620
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("a.in","r",stdin);
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    double l;
    cin>>l;
    printf("%.12lf\n",l*l*l/27.0);

}

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

int main() {
  int N, M;
  cin >> N >> M;
  int S = 0;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    S += A;
  }
  cout << max(N - S, -1) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

ll func(ll n) 
{
    ll ret;

    if(n%2 == 0) {
        ret = n / 2;
    } else {
        ret = 3*n+1;
    }
    return ret;
}

int main() 
{
    vector<ll> a(1000000,0);
    vector<ll> b(1000000,0);
    cin >> a[0];
    b[a[0]]++;

    ll i;
    for(i = 1; i <= 1000000; i++) {
        a[i] = func(a[i-1]);
        b[a[i]]++;
        if(b[a[i]] == 2) { break; }
    }

    cout << i+1 << endl;

    return 0;
}



Measured memory_bytes: 15872
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
         break
    for h in range(H):
        for w in range(W):
            if (h+w)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7008
#include <iostream>
#include <vector>
#include <algorithm>

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

    std::vector<std::string> S(N);

    std::string line;
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }

    std::sort(S.begin(), S.end());
    for (std::string s : S) {
        std::cout << s;
    }
    std::cout << std::endl;
}

Measured memory_bytes: 256
//ABC069A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n-1)*(m-1) << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIT = lambda: tuple(MI())
MIS = lambda: input().split()


class WHeap(object):
    def __init__(self):
        self._heap1 = []
        self._heap2 = []
        self.sum_h1 = 0
        self.sum_h2 = 0

    def __len__(self):
        return len(self._heap1) + len(self._heap2)

    def iter(self):
        for i in self._heap1:
            yield -i
        for i in self._heap2:
            yield i

    def __str__(self):
        return str(self._heap1) + " " + str(self._heap2)

    def push(self, n):
        if len(self) % 2 == 0:
            if not self._heap2 or n <= self._heap2[0]:
                heapq.heappush(self._heap1, -n)
                self.sum_h1 += n
            else:
                d = self._heap2[0]
                heapq.heappush(self._heap1, -heapq.heappop(self._heap2))
                self.sum_h1 += d
                self.sum_h2 -= d
                heapq.heappush(self._heap2, n)
                self.sum_h2 += n
        else:
            if n < -self._heap1[0]:
                d = -self._heap1[0]
                heapq.heappush(self._heap2, -heapq.heappop(self._heap1))
                self.sum_h1 -= d
                self.sum_h2 += d
                heapq.heappush(self._heap1, -n)
                self.sum_h1 += n
            else:
                heapq.heappush(self._heap2, n)
                self.sum_h2 += n

    def med(self):
        return -self._heap1[0]

    def pop(self, n):
        result = self.med()
        if len(self) % 2 == 0:
            heapq.heappop(self._heap1)
            heapq.heappush(self._heap1, -heapq.heappop(self._heap2))
        else:
            heapq.heappop(self._heap1)


def main():
    Q = II()
    wh = WHeap()
    B = 0
    for _ in range(Q):
        query = MIT()
        if query[0] == 1:
            wh.push(query[1])
            B += query[2]
        else:
            x = wh.med()
            if len(wh) % 2 == 0:
                f = - wh.sum_h1 + wh.sum_h2 + B
            else:
                f = x - wh.sum_h1 + wh.sum_h2 + B
            print(x, f)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13256
tp = {}
while 1:
	t,p = map(int,raw_input().split(","))
	if t==p==0:break
	tp[t]=p
ls=sorted(list(set([tp[key] for key in tp.keys()])),reverse=True)
while 1:
	try:team=int(raw_input())
	except:break
	print ls.index(tp[team])+1

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N], b[N], c[N];
vector<int> vt;

bool cmp(int a, int b){return a > b;}
int main()
{
	int x, y, A, B, C; scanf("%d%d%d%d%d", &x, &y, &A, &B, &C);
	for (int i = 1; i <= A; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= B; ++i) scanf("%d", &b[i]);
	for (int i = 1; i <= C; ++i) scanf("%d", &c[i]);
	sort(a + 1, a + A + 1, cmp);
	sort(b + 1, b + B + 1, cmp);
	sort(c + 1, c + C + 1, cmp);
	long long ans = 0;
	
	for (int i = 1; i <= x; ++i) vt.push_back(a[i]);
	for (int i = 1; i <= y; ++i) vt.push_back(b[i]);
	sort(vt.begin(), vt.end());
	int p = 0;
	for (int i = 1; i < c[i]; ++ i)
	{
		if(vt[p] < c[i]) vt[p] = c[i], p ++;
		else break;
	}
	for (int i = 0; i < vt.size(); ++ i) ans += vt[i];
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 2552
h, w=map(int, input().split())
s=[[0]*(w+2)]+[[0]+list(input())+[0] for i in range(h)]+[[0]*(w+2)]
for i in range(1, h+1):
  for j in range(1, w+1):
    if s[i][j]=='.':
      s[i][j]=0
for i in range(1, h+1):
  for j in range(1, w+1):
    if s[i][j]=='#':
      for k in range(i-1, i+2):
        for l in range(j-1, j+2):
          if s[k][l]!='#':
            s[k][l]+=1
for i in range(1, h+1):
  print(''.join(map(str, s[i][1:w+1])))

Measured memory_bytes: 3064
//周♂雨扬是最强的！！！
//大佬祝您AK
//沈哲♂贝是最强的！！！
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<fstream>
using namespace std;
//ifstream fin(.in);
//ofstream fout(.out);
int n,num[103],xx=101,x,sum;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
		sum+=num[i];
		if(num[i]%10!=0){
			xx=min(xx,num[i]);
			x++;
		}
	}
	if(sum%10!=0){
		cout<<sum<<endl;
	}else{
		if(!x){
			cout<<0<<endl;
		}else{
			cout<<sum-xx<<endl;
		}
	}
	return 0;
}
//沈♂哲贝是最强的！！！
//大佬祝您AK
//周♂雨扬是最强的！！！

Measured memory_bytes: 256
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math, fractions, collections
# ===================================
x, y = [int(x) for x in input().split()]
if x%y == 0:
	print(-1)
else:
	temp = x
	while(temp%y == 0):
		temp += x
	print(temp)

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

int main()
{
	string s;
	cin.sync_with_stdio(false);
	cin >> s;
	int res = s.size() / 2;
	for (auto &c : s) {
		if (c == 'p')
			res--;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*ll t;
    cin>>t;
    ll x=0;
    while(t--)
    {
        ++x;
        ll n;
        cin>>n;
        ll sum=0;
        ll** arr=new ll*[n];
        for(ll i=0;i<n;++i)
        {
            arr[i]=new ll[n];
            for(ll j=0;j<n;++j)
            {
                cin>>arr[i][j];
                if(i==j)
                {
                    sum+=arr[i][j];
                }
            }
        }
        ll r=0;
        ll c=0;
        for(ll i=0;i<n;++i)
        {
            set<ll> s;
            for(ll j=0;j<n;++j)
            {
                s.insert(arr[i][j]);
            }
            if(s.size()!=n)
            {
                ++r;
            }
        }
        for(ll i=0;i<n;++i)
        {
            set<ll> s;
            for(ll j=0;j<n;++j)
            {
                s.insert(arr[j][i]);
            }
            if(s.size()!=n)
            {
                ++c;
            }
        }

    }*/
    ll k;
    cin>>k;
    vector<ll> v;
    for(ll i=1;i<=9;++i)
    {
        v.push_back(i);
    }
    ll idx=0;
    while(v.size()<100000)
    {
        ll cur=v[idx];
        ll rem=cur%10;
        if(rem!=0&&rem!=9)
        {
            ll cp=cur*10;
            v.push_back(cp+rem-1);
            v.push_back(cp+rem);
            v.push_back(cp+rem+1);
        }
        else if(rem==0)
        {
            ll cp=cur*10;
            v.push_back(cp+0);
            v.push_back(cp+1);
        }
        else
        {
            ll cp=cur*10;
            v.push_back(cp+8);
            v.push_back(cp+9);
        }
        ++idx;
    }
    cout<<v[k-1]<<endl;
}
// cout<<"Case #"<<x<<": "<<sum<<" "<<r<<" "<<c<<endl;




















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

int main(){
    vector<int> v;
    int n;
    for (int i = 0; i < 5; i++){
	cin >> n;
	v.push_back(n);
    }
    sort(v.begin(), v.end(), greater<int>());

    for (int i = 0; i < 5; i++)
	printf("%d%c", v[i], (i == 4)? '\n':' ');

}

Measured memory_bytes: 0
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
//ディ　ブルデ　The　尊厳
//-----------------------------------------
int main(void){
    string S;cin>>S;
    ll Q;cin>>Q;
    ll rev=0;
    string s[2];
    while(Q --> 0){
        //cout<<"nokori:"<<Q<<"\n";
        ll q;cin>>q;
        if(q==1){
            //cout<<1<<":";
            rev++;
        }
        else if(q==2){
            //cout<<2<<":";
            ll f;char c;cin>>f>>c;
            s[(f-1+rev)%2].push_back(c);
        }
    }
    
    reverse(ALLv(s[0]));
    if(rev%2==0){
        cout<<s[0]<<S<<s[1]<<"\n";
    }
    else{
        reverse(ALLv(s[0]));
        reverse(ALLv(S));
        reverse(ALLv(s[1]));
        cout<<s[1]<<S<<s[0]<<"\n";
    }
    
}


Measured memory_bytes: 3956