akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using LL = long long;
using PII = pair<int, int>;
using ll = long long;
using DBL = double;
using VI = vector<int>;
using VD = vector<DBL>;
using VVI = vector<VI>;
using VVD = vector<VD>;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define ST first
#define ND second

//#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
//template<typename Arg> void __f(const char* name, Arg&& arg) {
//  cerr << name << " = " << arg << std::endl;
//} template <typename Arg1, typename... Args>
//void __f(const char* names, Arg1&& arg1, Args&&... args) {
//  const char* comma = strchr(names + 1, ',');
//  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; // OST: find_by_order, order_of_key
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#pragma GCC optimize("Ofast")
//optimize("unroll-loops")
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
///*** RNGS ***/
//SEED=chrono::steady_clock::now().time_since_epoch().count();
//// or high_resolution_clock
//mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
//uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
//struct chash {int operator()(int x) const {return x^SEED;}};
//gp_hash_table<int,int,chash>m;//use cc if very less updates
///*** FAST IO ***/
//inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
//while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();}
//while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
//return y?-x:x; }

const int MAXN = 1024, MAXW = 10010;

int w[MAXN], s[MAXN], v[MAXN], idx[MAXN];
long long dp[MAXN][MAXW];

long long calc(int pos, int left) {
    auto &y = dp[pos][left];
    if(y != -1) return y;
    if(pos == 0) return y = 0;
    y = calc(pos-1, left);
    if(left >= w[idx[pos]]) y = max(y, v[idx[pos]]+calc(pos-1, min(s[idx[pos]], left-w[idx[pos]])));
    return y;
}

int main() {
    #ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
//    freopen("sample.out", "w", stdout);
    #else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #endif
    memset(dp, -1, sizeof(dp));
    int n;
    cin >> n;
    for(int i=1; i<=n; ++i) {
        cin >> w[i] >> s[i] >> v[i];
        idx[i] = i;
    }
    sort(idx+1, idx+n+1, [](const auto&a, const auto&b) {
        return w[a] + s[a] < w[b] + s[b];
    });
    long long ans = -1e9;
    for(int i=1; i<=n; ++i) {
        ans = max(ans, v[idx[i]] + calc(i-1, s[idx[i]]));
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 83764
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
using namespace std;

int main() {

	string S;
	cin >> S;

	if (S == "Sunny")
		cout << "Cloudy" << endl;

	if (S == "Cloudy")
		cout << "Rainy" << endl;
	
	if (S == "Rainy")
		cout << "Sunny" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }



int main(){
    LL a, p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  ll A, B;
  cin >> A >> B;
  REP(i, 90000) {
    if ((int) (i * 0.08) == A && (int) (i * 0.1) == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	string s, t, u; cin >> s >> t;
	rep(i, n) (u += s[i]) += t[i];
	cout << u << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int x=sc.nextInt();
			if(n==0){
				break;
			}
			System.out.println(result(n,x));
		}
	}

	public static int result(int n, int x){
		int count=0;
		for(int i=1; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				for(int k=j+1; k<=n; k++){
					if((i+j+k)==x){
						count++;
					}
				}
			}
		}
		return count;
	}


}


Measured memory_bytes: 26644
# -*- coding: utf-8 -*-
x = list(map(int, list(input())))
op = ["-","+"]
for i in range(8):
    t = x[0]
    for j in range(3):
        if i>>j&1 == 1:
            t += x[j+1]
        else:
            t -= x[j+1]
    if t==7:
        print("{}{}{}{}{}{}{}=7".format(
            x[0],op[i>>0&1],x[1],op[i>>1&1],x[2],op[i>>2&1],x[3]
        ))
        break


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int an,bn,i,j,count=0;
    scanf("%d",&an);
    int A[an+1];
    for(i=0;i<an;i++)
        scanf("%d",&A[i]);
    scanf("%d",&bn);
    int B[bn+1];
    for(i=0;i<bn;i++)
        scanf("%d",&B[i]);
    
    //search
    for(i=0;i<bn;i++){
        j=0;
        A[an]=B[i];
        while(A[j]!=B[i])
            j++;
        if(j!=an)count++;
        //printf("j=%d\n",j);
    }
    printf("%d\n",count);
    
    return 0;
    
        
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define int long long
#define ss second
#define ff first
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;

    vector<pair<int,int>> primes;
    set<int> nums;

    for(int i=2; i*i <= n; i++){
        if(n%i == 0){
            int qtd = 0;
            while(n%i == 0) n/=i, qtd++;
            primes.push_back({i,qtd});
        }
    }
    
    if(n > 1) primes.push_back({n,1});

    for(pair<int,int> &x: primes){
        int prime = x.first, factor = x.second, cnt = 1;
        while(factor >= cnt){
            nums.insert(prime);
            factor -= cnt;
            cnt++;
            prime = pow(x.first,cnt);
        }
    }

    cout<<nums.size()<<endl;
    // for(int x: nums) cout<<x<<" ";
    // cout<<endl;
}

Measured memory_bytes: 4116
#include <iostream>
#define A  600
#define B  800
#define C 1000
#define D 1200
#define E 1400
#define F 1600
#define Z    0

using namespace std;

int rmn_max( int x, int y ){
  return x > y ? x : y;
}

int main(){
  int n;
  while( 1 ){
    cin >> n;
    if( !n ){ return 0; }
    int cost = 0;
    for( int i = 0; i < n; i++ ){
      int x, y, h, w;
      cin >> x >> y >> h >> w;
      int ml = x + y + h;
      
      int lcost = A;
      if( ml > 160 ){
        lcost = Z;
      }else if( ml > 140 ){
        lcost = F;
      }else if( ml > 120 ){
        lcost = E;
      }else if( ml > 100 ){
        lcost = D;
      }else if( ml > 80 ){
        lcost = C;
      }else if( ml > 60 ){
        lcost = B;
      }else{
        lcost = A;
      }
      if( lcost == Z ||  w > 25 ){
        lcost = Z;
      }else if( w > 20 ){
        lcost = rmn_max( F, lcost );
      }else if( w > 15 ){
        lcost = rmn_max( E, lcost );
      }else if( w > 10 ){
        lcost = rmn_max( D, lcost );
      }else if( w > 5 ){
        lcost = rmn_max( C, lcost );
      }else if( w > 2 ){
        lcost = rmn_max( B, lcost );
      }else{
        lcost = rmn_max( A, lcost );
      }
      cost += lcost;
    }
    cout << cost << endl;
  }
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String name=br.readLine();
		int kaz=Integer.parseInt(name);
		int num;
		int compare;

		int[] a=new int[3];
		int big;
		int i=0;

		for(int j=0; j<kaz; j++){
			name=br.readLine();
			try{
				StringTokenizer st=new StringTokenizer(name," ");
			     while (st.hasMoreTokens()) {
			    	 a[i]=Integer.parseInt(st.nextToken());
			    	 i++;
			     }i=0;
			     a[0]*=a[0]; a[1]*=a[1]; a[2]*=a[2];
				big = Math.max((Math.max(a[0], a[1])),(Math.max(a[0], a[2])));

				if(big==a[0]){
					if(a[0]==a[1]+a[2]){
						System.out.println("YES");
					}
					else{
						System.out.println("NO");
					}
				}

				else if(big==a[1]){
					if(a[1]==a[2]+a[0]){
						System.out.println("YES");
					}
					else{
						System.out.println("NO");
					}
				}

				else if(big==a[2]){
					if(a[2]==a[1]+a[0]){
						System.out.println("YES");
					}
					else{
						System.out.println("NO");
					}
				}

				a[0]=0;
				a[1]=0;
				a[2]=0;


			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 25560
#include<stdio.h>
#define num 8
 
int D[num][num]={0};
 
 
 
void printboard(){
  int i,j;
     
  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      if(D[i][j]==1){
	printf("Q");
      }
      else printf(".");
    }
    printf("\n");
  }
 
}
 
 
int check(int y,int x){
  int i,j;
     
  for(i=0;i<num;i++){
    if(i!=x && D[y][i]==1){
      return 0;
    }
  }
  for(i=0;i<num;i++){
    if(i!=y && D[i][x]==1){
      return 0;
    }
  }
  i=y-1; j=x+1;
  while(i>=0 && j<num){
    if(D[i--][j++]==1){
      return 0;
    }
  }
  i=y-1; j=x-1;
  while(i>=0 && j>=0){
    if(D[i--][j--]==1){
      return 0;
    }
  }
  i=y+1; j=x-1;
  while(i<num && j>=0){
    if(D[i++][j--]==1){
      return 0;
    }
  }
  i=y+1; j=x+1;
  while(i<num && j<num){
    if(D[i++][j++]==1){
      return 0;
    }
  }
     
  return 1;
     
}
 
 
int Get_Solution(int t){
  int i;
     
  for(i=0;i<num;i++){
    if(D[t][i]==1){
      if(!Get_Solution(t+1)){
	return 0;
      }
    }
  }
     
 
  if(t==num){
    printboard();
    return 1;
  }
  else {
    for(i=0;i<num;i++){
      if(D[t][i]==0 && check(t,i)){
	D[t][i]=1;
	if(!Get_Solution(t+1)){
	  D[t][i]=0;
	}
      }
    }
  }
     
     
  return 0;
 
}
 
int main(){
  int n,i,j,x,y,t=0;
     
  scanf("%d",&n);
     
  for(i=0;i<n;i++){
    scanf("%d %d",&y,&x);
    D[y][x]=1;
  }
     
  i=Get_Solution(t);
 
  return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include <assert.h>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int, int> P;
constexpr ll SIZE = 100010;

ll N, A[100010], B[SIZE];
ll ans = 0, sum = 0, wa = 0;
int main() {
	std::ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
		wa += i + 1;
	}
	REP(i, N) {
		B[i] = A[(i + 1) % N] - A[i];
	}
	bool f = true;
	if (sum%wa != 0) { cout << ("NO") << endl; return 0; }
	if(0){
		ll SSS = 0;
		REP(i, N) {
			SSS += B[i];
		}
		assert(SSS == 0);
	}
	REP(i, N) {
		B[i] -= sum / wa;
		//cout<<B[i]<<' ';
	}
	//cout<<"\n================================\n";
	ll cnt = 0;
	REP(i, N) {
		if (B[i]<=0 && (-B[i]) % N == 0) { cnt += (-B[i]) / N; }
		else f = false;
	}
	if (f && cnt != sum / wa) {
		f = false;
		assert(false);
	}
	
	cout << (f ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 1792
s = gets.to_i

def f(n)
  n % 2 == 0 ? n / 2 : 3 * n + 1
end

hash = {}
hash[s] = 1

count = 1
found = false
n = f(s)
while !found do
  if hash[n]
    puts count + 1
    found = true
  else
    hash[n] = 1
    count += 1
    n = f(n)
  end
end


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

#define int long long

using namespace std;


int dp[100005];


signed main(){
    int q=1;
    // cin>>q;
    while(q--){
        int n,d,count=0;
        cin>>n>>d;
        for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            if(x*x+y*y <= d*d){
                count++;
                // cout<<"Printing "<<x<<" "<<y<<"\n";
            }
        }
        cout<<count<<"\n";
    }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	vi v(4);
	rep(i, 4) cin >> v[i];
	sort(all(v));
	cout << (v[0] == v[1] && v[2] == v[3] ? "yes" : "no") << endl;
	return 0;
}


Measured memory_bytes: 3212
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    uint32_t W, H, N;
    uint32_t posL, posR, posB, posT;
    uint32_t i;

    /* read W, H, N from stdin */
    scanf("%u %u %u", &W, &H, &N);

    /* init white area info */
    posL = 0;
    posR = W;
    posB = 0;
    posT = H;

    /* update posX */
    for (i = 0; i < N; i++) {
        uint32_t x, y, a;
        scanf("%u %u %u", &x, &y, &a);
        switch (a) {
        case 1:
            if (posL < x) posL = x;
            break;
        case 2:
            if (posR > x) posR = x;
            break;
        case 3:
            if (posB < y) posB = y;
            break;
        case 4:
            if (posT > y) posT = y;
            break;
        default:
            /* unreachable */
            break;
        }
    }

    /* print answer */
    if (posL >= posR || posB >= posT) {
        printf("0\n");
    } else {
        const uint32_t width  = posR - posL;
        const uint32_t height = posT - posB;
        const uint32_t ans = width * height;
        printf("%u\n", ans);
    }

    return 0;
}



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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> data(N);
  for(int i=0;i<N;i++){
    cin >> data[i];
  }
  sort(data.begin(),data.end());
  for(int i=0;i<N;i++){
    cout << data[i];
  }
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())

if a + b <= c * 2:
    print(a*x+b*y)
else:
    if x > y:
        print(min(x*2*c,y*2*c+(x-y)*a))
    else:
        print(min(y*2*c,x*2*c+(y-x)*b))

Measured memory_bytes: 9084
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    l = list(map(int,input().split()))
    l = [((i-1)//n, (i-1) % n) for i in l]
    check = [[1 for j in range(n)] for i in range(n)]
    d =  [[min(i, n-i-1, j, n-j-1) for j in range(n)] for i in range(n)]

    ans = 0
    for x,y in l:
        check[x][y] = 0
        ans += d[x][y]
        q = []
        q.append((x,y,d[x][y]))
        while q:
            bx,by,z = q.pop()

            if bx != 0:
                if d[bx-1][by] > z:
                    d[bx-1][by] = z
                    q.append((bx-1,by,z+check[bx-1][by]))
            if bx != n-1:
                if d[bx+1][by] > z:
                    d[bx+1][by] = z
                    q.append((bx+1,by,z+check[bx+1][by]))
            if by != 0:
                if d[bx][by-1] > z:
                    d[bx][by-1] = z
                    q.append((bx,by-1,z+check[bx][by-1]))
            if by != n-1:
                if d[bx][by+1] > z:
                    d[bx][by+1] = z
                    q.append((bx,by+1,z+check[bx][by+1]))  
    print(ans)
if __name__ =="__main__":
    main()


Measured memory_bytes: 198436
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int,int> P;
 
int main(){
    int N, M, d, p;
 
    while(cin >> N >> M, (N | M)){
	vector<P> vec;
	for(int i = 0 ; i < N ; i++){
	    cin >> d >> p;
	    vec.push_back(P(-p,d));
	}
   
	int res = 0;
	sort(vec.begin(),vec.end());
	for(int i = 0 ; i < N ; i++){
	    P now = vec[i];
	    if(M-now.second >= 0){
		M -= now.second;
	    }else{
		if(M){
		    now.second -= M;
		    M = 0;
		}
		res += now.second*(-now.first);
	    }
	}
	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
from math import factorial


def factorize(n):
    a = 2
    fct = []
    while a * a <= n:
        while n % a == 0:
            n //= a
            fct.append(a)
        a += 1
    if n > 1:
        fct.append(n)
    return fct


n = int(input())
f = [0] * 101
for p in factorize(factorial(n)):
    f[p] += 1
cnt24 = 0
cnt14 = 0
cnt4 = 0
ans = 0
tmp = 0
for i in range(1, n + 1):
    if f[i] >= 74:
        ans += 1
    for j in range(1, n + 1):
        if i == j:
            continue
        if f[i] >= 24 and f[j] >= 2:
            ans += 1
        if f[i] >= 14 and f[j] >= 4:
            ans += 1
        for k in range(1, n + 1):
            if i == k or j == k:
                continue
            if f[i] >= 4 and f[j] >= 4 and f[k] >= 2:
                tmp += 1
print(ans + tmp // 2)


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

int main(){
    int N , K, ans = 0;
    cin >> N >> K;
    vector<double> x(N+1);
    for(int i = 1; i <= N; ++i) cin >> x[i];
    for(int i = 1; i <= N; ++i){
        ans += 2 * min(x[i], sqrt(pow(x[i] - K, 2)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3744
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n = in();
  vi p(n);
  rep(i,n) cin >> p[i];
  
  int ans = 0;
  for (int i = 1; i <= n-2; ++i) {
    int a = p[i-1];
    int b = p[i];
    int c = p[i+1];
    int m2 = (a+b+c) - max({a,b,c}) - min({a,b,c});
    if (p[i] == m2) ans++;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System. in);
    String passWord = sc.next();
    String ans = "";

    for (int i=0; i < passWord.length()-1; i++) {
      if (passWord.substring(i, i + 1).equals(passWord.substring(i+1, i+2))) {
        ans = "Bad";
        break;
      } else {
        ans = "Good";
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
N = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

ans = 0
for i in range(1, N):
    a1[i] = a1[i-1] + a1[i]
    a2[N-i-1] = a2[N-i] + a2[N-i-1]

for i in range(N):
    ans = max(ans, a1[i] + a2[i])

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int c=1,i,n,s,y=0,j,m=1;
    cin>>n;
    int a[n],b[n],ara[n];
     for(i=0;i<n;i++){
        ara[i]=i+1;
       cin>>a[i];
     }
     for(i=0;i<n;i++){
        cin>>b[i];
     }
     for(i=0;i<40321;i++){

        for( j=0;j<n;j++){
           if(ara[j]==a[j]){
            y++;
           }
        }
        if(y==n){
            j=n;i=40322;
        }
        else{
            c++;
        }

        y=0;
        //cout<<endl;
        next_permutation(ara,ara+n);
     }
     y=0;
     for(i=0;i<n;i++){
        ara[i]=i+1;

     }
     for(i=0;i<40321;i++){

        for( j=0;j<n;j++){
           if(ara[j]==b[j]){
            y++;
           }
        }
        if(y==n){
            j=n;i=40322;
        }
        else{
            m++;
        }

        y=0;
        //cout<<endl;
        next_permutation(ara,ara+n);
     }
     cout<<abs(m-c)<<endl;
}




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

class Program
{
    public static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();

        var N = line[0];
        var M = line[1];

        int max = 0;
        int min = 0;

        for (int i = 0; i < M; i++)
        {
            var line2 = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();

            var L = line2[0];
            var R = line2[1];

            if (max < L)
            {
                max = L;
            }

            if (i == 0)
            {
                min = R;
            }
            else if (min > R)
            {
                min = R;
            }
        }

        if (min >= max)
        {
            Console.WriteLine(min - max + 1);
        }
        else
        {
            Console.WriteLine(0);
        }
    }
}




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

int main()
{
	int A, B, C;

	cin >> A >> B >> C;

	for (int i = A; i <= 1000000; i += A) {
		if (i % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}

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

namespace abc168_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
           
            if(S == T.Substring(0,S.Length))
            {
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
            Console.Read();
        }
    }
}


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

int main()
{
	int n,a,b,c,x;
	while(cin>>n>>a>>b>>c>>x && n!=0){
		vector<int> V(n);
		for(int i=0;i<n;i++)
			cin>>V[i];

		int idx=0;
		int ans=-1;
		for(int i=0;i<=10000;i++){
			if(x==V[idx])
				idx++;
			if(idx==n){
				ans=i;
				break;
			}
			
			x=(a*x+b)%c;

		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 908
#include <iostream>
#include <vector>
using namespace std;
#define ll long long

int main(){
	ll h,k;
	cin>>h>>k;
	ll sum=0;
	vector<ll> a(h);
	for(ll i=0;i<h;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	for(ll i=0;i<h-k;i++){
		sum+=a[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 4460
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P>PP;
int a[100006];
int gcd(int a, int b) {
	if (!b)return a; return gcd(b, a%b);
}
signed main() {
	int n, m; cin >> n >> m;
	int LCM = 1;
	int ng = 0;
	rep(i, n) {
		cin >> a[i];
		a[i]/= 2;
		LCM = LCM*a[i] / gcd(LCM, a[i]);
		if (LCM > m)ng++;
	}
	if (ng)cout << 0 << endl;
	else {
		rep(i, n) {
			if ((LCM / a[i]) % 2 == 0) {
				cout << 0 << endl; return 0;
			}
		}
		int ans = m / LCM;
		ans = (ans + 1) / 2;
		cout << ans << endl;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='T'){
            if(cnt>=1){
                ans+=2;
                cnt--;
            }
            else cnt=0;
        }
        else cnt++;
    }
    Cout(Size(s)-ans);
    return 0;
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  string s; cin >> s;
  if(s=="ARC") pr("ABC");
  else pr("ARC");
  return 0;
}

Measured memory_bytes: 3568
def main():
    inp = input()
    arr = inp.split(" ")
    print(rate(int(arr[0]), int(arr[1])))


def rate(n, er):
    if (n < 10):
        return er + (100 * (10 - n))
    else:
        return er


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>

const long long P=998244353;
int k,n;
long long fac[6000],invfac[6000];
long long pow2[6000];

long long C(int N,int M){return fac[N]*invfac[M]%P*invfac[N-M]%P;}

long long Calc(int x,int y,int z){
	long long ret=0;
	for (int i=0;i<=x&&i<=z;i++)
		ret=(ret+C(x,i)*pow2[i]%P*C(z+y-1,i+y-1)%P)%P;
	return ret;
}

int N,K;

int main(){
	scanf("%d%d",&K,&N);
	fac[0]=fac[1]=invfac[0]=invfac[1]=pow2[0]=1;
	pow2[1]=2;
	for (int i=2;i<=5000;i++){
		fac[i]=fac[i-1]*i%P;
		invfac[i]=(P-P/i)*invfac[P%i]%P;
		pow2[i]=pow2[i-1]*2%P;
	}
	for (int i=2;i<=5000;i++) invfac[i]=invfac[i-1]*invfac[i]%P;
	for (int i=2;i<=K+K;i++){
		int law=std::min(i-1,K+K-i+1);
		if (i&1) printf("%lld\n",Calc(law/2,K-law,N));
		else printf("%lld\n",(Calc(law/2,K-law,N)+Calc(law/2,K-law,N-1))%P);
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
bool flag[500];
bool fri[500][500];
int cnt;
int N,M;
void dfs(int i,int d){
    cnt += !flag[i];
    flag[i] = 1;
    if(d > 1)return;
    for(int j = 1;j < N;j++){
        if(fri[i][j])dfs(j,d+1);
    }
}
main(){
    cin >> N >> M;
    while(N){
        fill(flag,flag+500,0);
        fill(fri[0],fri[500],0);
        for(int i = 0;i < M;i++){
            int a,b;
            cin >> a >> b;
            fri[a-1][b-1] = fri[b-1][a-1] = 1;
        }
        cnt = 0;
        dfs(0,0);
        cout << cnt-1 << endl;
        cin >> N >> M;
    }
}

Measured memory_bytes: 3328
k, a, b = map(int, input().split())
cookie_num = 1
prefer_task = (b - a) > 2
minimum_task = a - 1
remain_time = k - minimum_task
remain_task = remain_time // 2
if prefer_task:
  cookie_num  = 1 + minimum_task + remain_task * (b - a) + (remain_time % 2)
else:
  cookie_num = 1 + k
print(cookie_num)

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

int main() {
    int n, ans = 1e9, i;
    vector <pair<int, int>> v, w;
    map <int, int> mp1, mp2;
    map <int, int>::iterator it;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        if (i % 2 == 0) {
            mp1[x]++;
        } else {
            mp2[x]++;
        }
    }
    
    mp1[1e9] = 0;
    mp2[1e9] = 0;
    
    for (it = mp1.begin(); it != mp1.end(); it++) v.push_back(make_pair(it->second, it->first));
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    
    for (it = mp2.begin(); it != mp2.end(); it++) w.push_back(make_pair(it->second, it->first));
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());
    
    for (i = 0; i < v.size(); i++) {
        int p = 0;
        
        if (v[i].second == w[0].second) p = 1;
        
        ans = min(ans, n - (v[i].first + w[p].first));
    }
    
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 6136
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int v = scn.nextInt();
      	int b = scn.nextInt();
      	int w = scn.nextInt();
      	int t = scn.nextInt();
      	double tt = 0;
      	String ans = "YES";
      	if(b>a) tt = (double)(b-a)/(v-w);
      	if(a>b) tt = (double)(a-b)/(v-w);
        if(t<tt) ans = "NO";
        if(w>v) ans = "NO";
      	System.out.println(ans);
	}
}


Measured memory_bytes: 35712
//
// Created by Ciafrino on 1/6/19.
//
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
const int mod = 1000000007;
typedef long long lint;

struct Matrix {
    lint mat[60][60];
};

Matrix matrix_mul(Matrix a, Matrix b) {
    Matrix ans;
    for (int i = 0; i < 60; i++)
        for (int j = 0; j < 60; j++)
            for (int k = ans.mat[i][j] = 0; k < 60; k++) {
                ans.mat[i][j] += (a.mat[i][k] % mod) * (b.mat[k][j] % mod);
                ans.mat[i][j] %= mod;
            }
    return ans;
}

Matrix matrix_pow(Matrix base, lint p) {
    Matrix ans;
    int i, j;
    for (i = 0; i < 60; ++i)
        for (j = 0; j < 60; ++j)
            ans.mat[i][j] = (i == j);
    while (p) {
        if (p&1) ans = matrix_mul(ans, base);
        base = matrix_mul(base, base);
        p >>= 1;
    }
    return ans;
}
Matrix mat;

int main() {
    lint n, k;
    scanf("%lld %lld", &n, &k);
    for(int i = 0; i < n; ++i) 
        for (int j = 0; j < n; ++j) 
            scanf("%lld", &mat.mat[i][j]);
    Matrix result = matrix_pow(mat, k);
    lint ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            ans = (ans + result.mat[i][j]) % mod;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
// C - Lower
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int ans = 0;
	int count = 0;
	int pre, now; cin>>pre;;
	for(int i=1; i<N; ++i){
		cin>>now;
		if(pre>=now) ++count; else count = 0;
		ans = max(ans, count);
		pre = now;
	}
	cout<< ans <<endl;
}

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

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

////////////////////////

int const N = 311;/////////////////////////////////////////////////////////
int const MOD = 1e9 + 7;

void add(int &a, int b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int n, m;
int l[N], r[N], x[N];
int d[2][3][N][N];
vector<int> q[N];

bool correct(int id, int p1, int p2){
	int cnt = 1;
	if(l[id] <= p1 && r[id] >= p1) ++cnt;
	if(l[id] <= p2 && r[id] >= p2) ++cnt;
	return x[id] == cnt;
}

bool correctAll(int x, int p1, int p2){
	rep(i, 0, sz(q[x])){
		if(!correct(q[x][i], p1, p2)) return false;
	}
	return true;
}

void clear(int id){
	rep(c, 0, 3) rep(i, 0, N) rep(j, 0, N) d[id][c][i][j] = 0;
}

void solve(){
	cin >> n >> m;
	rep(i, 0, m){
		cin >> l[i] >> r[i] >> x[i];
		q[r[i]].pb(i);
	}
	d[0][0][0][0] = 1;

	rep(i, 0, n){
		int nxtp = ((i + 1) & 1);
		int curp = (1 ^ nxtp);
		clear(nxtp);
		rep(c, 0, 3){
			rep(p1, 0, i+1){
				rep(p2, 0, i+1){
					if(correctAll(i+1, p1, p2)) 
						add(d[nxtp][c][p1][p2], d[curp][c][p1][p2]);
					if(c == 2){
						if(correctAll(i+1, p1, i))
							add(d[nxtp][1][p1][i], d[curp][c][p1][p2]);
						if(correctAll(i+1, p2, i))
							add(d[nxtp][0][p2][i], d[curp][c][p1][p2]);
					}else{
						if(c == 0){
							if(correctAll(i+1, i, p2))
								add(d[nxtp][1][i][p2], d[curp][c][p1][p2]);
							if(correctAll(i+1, i, p1))
								add(d[nxtp][2][i][p1], d[curp][c][p1][p2]);
						}else{
							if(correctAll(i+1, i, p2))
								add(d[nxtp][0][i][p2], d[curp][c][p1][p2]);
							if(correctAll(i+1, p1, i))
								add(d[nxtp][2][p1][i], d[curp][c][p1][p2]);
						}
					}
				}
			}
		}
	}

	int ans = 0;
	rep(c, 0, 3) rep(p1, 0, n) rep(p2, 0, n) add(ans, d[(n & 1)][c][p1][p2]);
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 2688
def digitCount(num):
  digits = 0
  while num > 0:
    digits += 1
    num = num // 10
  return digits

def main():
  n = int(input())
  ans = 0
  for i in range(1,n+1):
    if digitCount(i) % 2 != 0:
      ans += 1
  print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
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; }
const int INF=100100100100100;
const int MAXR=500010;

signed main(){
  int a,b,x;cin>>a>>b>>x;
  string ans="NO";
  if(a<=x && x<=a+b)ans="YES";
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());
#define mp make_pair
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;


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

	int a, b;
	cin >> a >> b;
	int x = (a + b + 1) / 2;
	cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,N,f=0;
    cin>>n;
    N=n;
    for(int i=0;i<=10;i++)
    {
        f+=n%10;
        n=n/10;
    }
    if(N%f==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main(){
    ll n,sum=0;
    cin>>n;
    ll a[n];
    map <ll,ll> x,q;
    rep(i,n)cin>>a[i],x[a[i]]++;
    for(auto z:x) q[z.first]=z.second*(z.second-1)/2,sum+=q[z.first];
    rep(i,n){
        cout<<sum-q[a[i]]+(x[a[i]]-2)*(x[a[i]]-1)/2<<endl;
    }
}


Measured memory_bytes: 18944
N = int(input())
A = list(map(int,input().split()))

n_senior = [0] * (N-1)

for i in range(N-1):
    senior_number = A[i]
    n_senior[senior_number-1] += 1

n_senior = n_senior + [0]
print("\n".join(map(str,n_senior)))


Measured memory_bytes: 32968
#include<iostream>
#include<array>
#include<set>
#include<queue>
using namespace std;
int k;
string s,t;
main()
{
	while(cin>>k,k)
	{
		cin>>s>>t;
		array<int,10>a;
		for(int i=0;i<k;i++)a[i]=(t[i]-s[i]+10)%10;
		set<array<int,10> >S;
		S.insert(a);
		queue<pair<array<int,10>,int> >P;
		P.push({a,0});
		while(!P.empty())
		{
			array<int,10>b=P.front().first;
			int cost=P.front().second;
			P.pop();
			int L=0;
			while(L<k&&b[L]==0)L++;
			if(L==k)
			{
				cout<<cost<<endl;
				break;
			}
			else
			{
				array<int,10>c=b;
				for(int i=L;i<k;i++)
				{
					c[i]=(c[i]-b[L]+10)%10;
					if(S.find(c)==S.end())
					{
						S.insert(c);
						P.push({c,cost+1});
					}
				}
			}
		}
	}
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n, m; cin >> n >> m;
    cout << (n-1)*(m-1) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define MOD 1000000007
#define N 1000006
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;
// int my_rand(){ int a=rand(); int b=rand(); return a*(RAND_MAX+1)+b; }

#define int long long int

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}

void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans = 0;
    map<char, set<int>> mp;

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(s[i]!=s[j]){
                char ck;
                string temp = "";
                temp += s[i];
                temp += s[j];

                sort(temp.begin(), temp.end());
                if(temp=="GR"){
                    ans += mp['B'].size();
                    if(mp['B'].find((2*i)-j) != mp['B'].end()){
                        ans--;
                    }
                }
                else if(temp=="BG"){
                    ans += mp['R'].size();
                    if(mp['R'].find((2*i)-j) != mp['R'].end()){
                        ans--;
                    }
                }
                else if(temp=="BR"){
                    ans += mp['G'].size();
                    if(mp['G'].find((2*i)-j) != mp['G'].end()){
                        ans--;
                    }
                }
            }
        }
        mp[s[i]].insert(i);
    }
    cout<<ans<<"\n";
}

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

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

using namespace std;

int main(void)
{
    int n, k, q, abuf;
    cin >> n >> k >> q;
    vector<int> narray(n);
    for (size_t i = 0; i < q; i++)
    {
        cin >> abuf;
        narray[abuf-1]++;
    }

    for (auto it = narray.begin();it!= narray.end(); it++)
    {
        if (k-(q-*it) > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        // cout << k - (q -*it) << endl;
    }
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main()
{
    int n, x;
    cin >> n >> x;
    int l[n+1], cnt=0;
    l[0] = 0;
    FOR(i, 1, n+1) cin >> l[i];
    REP(i, n+1){
        if(i != 0) l[i] = l[i-1] + l[i];
        if(l[i] <= x) cnt++;
    }
    cout << cnt << endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            
            Dictionary<int, int> T = new Dictionary<int, int>();
            var temp = A.OrderBy(a => a).ToArray();
            for (int i = 0; i < n; i++) T[temp[i]] = i;

            bool[] V = new bool[n];

            int s = A.Min();
            int result = 0;

            for(int i = 0; i < n; i++)
            {
                if (V[i]) continue;

                int cur = i;
                int sum = 0;
                int min = int.MaxValue;
                int an = 0;

                while (true)
                {
                    V[cur] = true;
                    an++;

                    if (min > A[cur]) min = A[cur];
                    sum += A[cur];
                    cur = T[A[cur]];

                    if (V[cur]) break;
                }
                result += Math.Min(sum + (an - 2) * min, min + sum + (an + 1) * s);
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 10284
#include<stdio.h>
#include<math.h>

int main(){
	
	int a,b;
	double C,S,L,h,pi=acos(-1);
	
	scanf("%d %d %lf",&a,&b,&C);
	
	C=C/180*pi;
	h=sin(C)*b;
	S=a*h/2;
	L=a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C));
	
	printf("%.8lf\n%.8lf\n%.8lf\n",S,L,h);
    
    return 0;

}



Measured memory_bytes: 2044
#include <iostream>
using namespace std;
int adj[100][100] = {0};
int main()
{
	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		int j, k;
		cin >> j >> k;
		j--;
		for (int m=0;m<k;m++) {
			int a;
			cin >> a;
			a--;
			adj[j][a]=1;
		}
	}

	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			if (j) cout << ' ';
			cout << adj[i][j];
		}
		cout << endl;
	}
		
	return 0;
}

Measured memory_bytes: 3128
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, K = map(int, input().split())
    ans = 0.0
    for i in range(1, N + 1):
        if i < K:
            num = 0
            while i < K:
                i *= 2
                num += 1
            ans += (1 / (2**num)) * (1 / N)

        else:
            ans += 1 / N

    print("{0:.10f}".format(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948