akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String have = br.readLine();
		int[][] card = new int[4][13];
		int exc = 0 ;
		String[] mark = {"S","H","C","D"};
		for(int i= 0 ; i < Integer.parseInt(have) ; i++){
			String str = br.readLine();
			String[] strc = str.split(" ");
			if("S".equals(strc[0])){
				exc =  Integer.parseInt(strc[1]);	
				card[0][exc-1] = exc ;
			} else if("H".equals(strc[0])){
				exc =  Integer.parseInt(strc[1]);	
				card[1][exc-1] = exc ;
			} else if("C".equals(strc[0])){
				exc =  Integer.parseInt(strc[1]);	
				card[2][exc-1] = exc ;
			} else if("D".equals(strc[0])){
				exc =  Integer.parseInt(strc[1]);	
				card[3][exc-1] = exc ;
			}
		}
		for(int j = 0 ; j < card.length ; j++){
			for (int k = 0 ; k < card[j].length ; k++){
				if(card[j][k] == 0 ){
					card[j][k] = k+1;
					System.out.println(mark[j] + " " + card[j][k]);
				}
			}
		}
	}

}

Measured memory_bytes: 16940
#include <iostream>
#include <bits/stdc++.h> 
#define ll long long 
#define MAX 200005
using namespace std;
void solve() 
{
    int n; 
    cin >> n ; 
    int sq = n*n;
    int result = n + sq + n*sq; 
    cout << result << endl; 
}
int main () 
{

    int t=1; 
    for (int i=1;i<=t;i++)
    {
        solve();  
    }
    return 0; 
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    string S;
    cin >> S;
    int N = S.size();

    vector<int64_t> cnt(13);
    cnt[0] = 1;
    for(int i=0; i<N; i++) {
        vector<int64_t> tmp(13);
        if(S[i] == '?') {
            for(int j=0; j<10; j++) {
                for(int n=0; n<13; n++) {
                    tmp[(10*n + j) % 13] += cnt[n];
                    tmp[(10*n + j) % 13] %= MOD;
                }
            }
        } else {
            for(int n=0; n<13; n++) {
                tmp[(10*n + S[i]-'0') % 13] += cnt[n];
                tmp[(10*n + S[i]-'0') % 13] %= MOD;
            }
        }
        cnt = tmp;
    }

    cout << cnt[5] << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int N,R[9][9],cn;

int fn(int i,int arrive[]){
	bool flug=true;
	arrive[i]=1;

	FOR(j,1,N+1){
		if(arrive[j]!=1){
			flug=false;
			if(R[i][j]==1) fn(j,arrive);
			arrive[j]=0;
		}
	}
	if(flug) cn++;
	return 0;
}

int main(void){
	int M,a,b,arrive[9];
	cin>>N>>M;

	cn=0;
	REP(i,9){
		arrive[i]=0;
		REP(j,9) R[i][j]=0;
	}

	REP(i,M){
		cin>>a>>b;
		R[a][b]=1;
		R[b][a]=1;
	}
	fn(1,arrive);
	print(cn);
	return 0;
}


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

vector<string> minesweeper(60);
    int h;
    int w;

char convertIntToChar(int x) {
    switch (x){
        case 1:
            return '1';
        case 2:
            return '2';
        case 3:
            return '3';
        case 4:
            return '4';
        case 5:
            return '5';
        case 6:
            return '6';
        case 7:
            return '7';
        case 8:
            return '8';
        case 9:
            return '9';
        default:
            return '0';
    }
}

void countUp(int y,  int x, int& count){
    if (y<0 || h-1<y) return;
    if (x<0 || w-1<x) return;

    if (minesweeper.at(y).at(x) == '#') count++;
}

int main() {
    cin >> h >> w;

    for (int i = 0; i < h; ++i) cin >> minesweeper.at(i);

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (minesweeper.at(i).at(j) == '.')
            {
                int count = 0;

                countUp(i-1,j-1, count);
                countUp(i,j-1, count);
                countUp(i+1,j-1, count);
                countUp(i-1,j, count);
                countUp(i, j, count);
                countUp(i+1,j, count);
                countUp(i-1,j+1, count);
                countUp(i,j+1, count);
                countUp(i+1,j+1, count); 

                minesweeper.at(i).at(j) = convertIntToChar(count);    
            }
        }
    }

    for (int i = 0; i < h; ++i) cout << minesweeper.at(i) << endl;
}

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

int main(){
  while(1){
    int H;
    cin>>H;

    if(H==0){
      break;
    }

    int S[10][5];
    for(int y=0;y<H;y++){
      for(int x=0;x<5;x++){
        cin>>S[y][x];
      }
    }

    int sco=0;

    while(1){
      bool flg=0;

      for(int y=0;y<H;y++){
        int m=S[y][2];
        if(m==0){
          continue;
        }

        if(S[y][0]==m&&S[y][1]==m){
          sco+=m*3;
          S[y][0]=S[y][1]=S[y][2]=0;
          flg=1;
          if(S[y][3]==m){
            sco+=m;
            S[y][3]=0;
            if(S[y][4]==m){
              sco+=m;
              S[y][4]=0;
            }
          }
        }else if(S[y][1]==m&&S[y][3]==m){
          sco+=m*3;
          S[y][1]=S[y][2]=S[y][3]=0;
          flg=1;
          if(S[y][4]==m){
            sco+=m;
            S[y][4]=0;
          }
        }else if(S[y][3]==m&&S[y][4]==m){
          sco+=m*3;
          S[y][2]=S[y][3]=S[y][4]=0;
          flg=1;
        }
      }

      if(!flg){
        break;
      }

      for(int x=0;x<5;x++){
        for(int y=H-1;y>=0;y--){
          if(S[y][x]!=0){
            continue;
          }

          for(int y2=y-1;y2>=0;y2--){
            if(S[y2][x]!=0){
              S[y][x]=S[y2][x];
              S[y2][x]=0;
              break;
            }
          }
        }
      }
    }
    cout<<sco<<endl;
  }
  return 0;
}



Measured memory_bytes: 3068
#include<iostream>

using namespace std;

int main(){
  int n, ans = 0, l, i = 0;
  int paf[20], value[20];
  cin >> n;
  while(i < n){
    cin >> l;
    value[i] = l;
    i++;
  }
  i = 0;
  while(i < n){
    cin >> l;
    paf[i] = value[i] - l;
    i++;
  }
  i = 0;
  while(i < n){
    if(paf[i] > 0){
      ans += paf[i];
    }
    i++;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

int main() {
  INCANT;
  cin >> N;
  cout << N+pow(N,2)+pow(N,3) << "\n";
  return 0;
}

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

int main(){
    string str;
    cin>>str;
    char s1=str[0];
    int s1k=1;
    int s2k=0;
    char s2;
    rep(i,3){
        if(s1!=str[i+1]){
            if(s2k==0){
                s2k++;
                s2=str[i+1];
            }else{
                if(s2!=str[i+1]){
                    cout<<"No"<<endl;
                    return 0;
                }else{
                    s2k++;
                }
            }
        }else{
            s1k++;
        }
    }
    if(s1k==s2k){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main {

  def keta(x: Int): Int = {
    if (x == 0) 0
    else keta(x / 10) + 1
  }
  
  def main(args: Array[String]): Unit = {
    val n = StdIn.readInt()
    val ans = (1 to n).foldLeft(0){ (acc, i) => 
      acc + keta(i) % 2
    }
    println(ans)
  }
  
}

Measured memory_bytes: 29752
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main(void){
    int n;
    std::cin >> n;
    if(n % 10 == 3) std::cout << "bon" << std::endl;
    else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) std::cout << "pon" << std::endl;
    else std::cout << "hon" << std::endl;

    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int n,q,key,t,x;
	cin>>n>>q;
	priority_queue<int> Q[1001];
	for(int i=0;i<q;i++){
		cin>>key>>t;
		if(key==0){
			cin>>x;
			Q[t].push(x);
		}else if(key==1){
			if(Q[t].empty()==0)cout<<Q[t].top()<<endl;
		}else{
			if(Q[t].empty()==0)Q[t].pop();
		}
	}
	return 0;
}


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

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    for(int i=0; i<N; i++) cin >> m[i];
    
    sort(m.begin(), m.end());
    
    int cnt=0;
    for(int i=0; i<m.size(); i++){
        X -= m[i];
        cnt++;
    }
    while(X>=0){
        X -= m[0];
        cnt++;
    }
    
    cout << cnt-1 << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        String S = scan.next();
        char[] data = S.toCharArray();
        int[] sum_rock = new int[N+1];
        int[] sum_empty = new int[N+1];
        sum_rock[0] = 0;
        sum_empty[0] = 0;
        for (int i = 0; i < N; i++) {
            if (data[i] == '#') {
                sum_rock[i + 1] = sum_rock[i] + 1;
                sum_empty[i + 1] = 0;
            } else {
                sum_rock[i + 1] = 0;
                sum_empty[i + 1] = sum_empty[i] + 1;
            }
        }
        boolean cannot_move_A_to_C = false;
        for (int i = A; i <= C; i++) {
            if (2 <= sum_rock[i]) {
                cannot_move_A_to_C = true;
                break;
            }
        }
        boolean cannot_move_B_to_D = false;
        for (int i = B; i <= D; i++) {
            if (2 <= sum_rock[i]) {
                cannot_move_B_to_D = true;
                break;
            }
        }
        boolean answer = solve(sum_empty, cannot_move_A_to_C, cannot_move_B_to_D, A, B, C, D);
        System.out.println(answer ? "Yes" : "No");
    }
    public static boolean solve(int[] sum_empty, boolean cannot_move_A_to_C, boolean cannnot_move_B_to_D, int A, int B, int C, int D) {
        if (cannot_move_A_to_C || cannnot_move_B_to_D) {
            return false;
        }
        // A<C<B<D
        // BをDに移動して、AをCに移動する
        if (C < B) {
            return true;
        }
        // A<B<C<D
        // BをDに移動して、AをCに移動する
        if (B < C && C < D) {
            return true;
        }
        // A<B<D<C
        // AをCに移動して、BをDに移動する
        // AがBを追い越す場所があるが
        if (D < C) {
            if (can_jump(sum_empty, B, D)) {
                return true;
            }
        }
        return false;
    }
    public static boolean can_jump(int[] sum_empty, int B, int D) {
        if (sum_empty[B+1] == 0) {
            for(int i = B+1; i <= D+1; i++) {
                if (2 < sum_empty[i]) {
                    return true;
                }
            }
        } else {
            for (int i = B; i <= D+1; i++) {
                if (2 < sum_empty[i]) {
                    return true;
                }
            }
        }
        return false;
    }
}


Measured memory_bytes: 28792
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef unsigned long long ll;
using namespace std;
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    long double w,h,x,y,a,b,ans=0;
    cin>>w>>h>>a>>b;
    ans=(w*h);
    ans/=2;
    int p=0;
    if(a==(w/2) && b==(h/2.0))p=1;
    printf("%.6LF %d\n",ans,p);
    return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    ll n,k;
    cin>>n>>k;
    vector<int>p(n+1),c(n+1);
    for(int i=1;i<=n;i++)cin>>p[i];
    for(int i=1;i<=n;i++)cin>>c[i];
    ll best=-9223372036854775808;
    for(int i=1;i<=n;i++){
        //start at index i;

        ll score=0;ll tracker=-9223372036854775808;

        ll moves=0;
        int index=i;ll lm=0;
        for(int j=1;j<=k;j++){
            //go to square p[i];
            if(p[index]==i){
                score+=c[i];
                moves=j;
               if(score>tracker){
                tracker=max(tracker,score);
                lm=j;
                }
                break;
            }
            else{
                score+=c[p[index]];
                index=p[index];
                moves=j;
                if(score>tracker){
                tracker=max(tracker,score);
                lm=j;
                }
            }


        }

        ll f=k/moves;ll nn=score;
        score=f*score;
        ll q=k%moves;
        index=i;ll z=score;
        for(int j=0;j<q;j++){
            z+=c[p[index]];
                index=p[index];
                score=max(score,z);
        }
        best=max(best,score);

        best=max(best,tracker);
       best=max(best,(f-1)*nn+tracker);



    }
    cout<<best;

    return 0;
}


Measured memory_bytes: 3648
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
#define LL long long int
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL N;
LL A[100001];

mint ans[100002];

void solve(){
	//ダブりを検出
	vector<LL> num(N+1,0);//数値iの出現回数をnum[i]とする
	LL dup;//重複しているのはどの数かを記録
	for(int i=0;i<=N;i++){
		if(num[A[i]]==1){
			dup = A[i];
			break;
		}
		num[A[i]]++;
	}
	int first_index = -1;//ダブった当の数が最初に出現する箇所
	int second_index = -1;//ダブった当の数が2番目に出現する箇所
	for(int i=0;i<=N;i++){
		if(dup==A[i]){
			if(first_index==-1) first_index = i;
			else second_index = i;
		}
	}

	//長さiの部分文字列の個数を見ていく
	combination c(N+1);
	for(int i=1;i<=N+1;i++){
		LL rang = first_index + (N-second_index);
		ans[i] = c(N+1,i) - c(rang,i-1LL);
	}
}

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

    solve();

    for(int i=1;i<=N+1;i++) cout << ans[i].x << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>

int a, b, c;
int ans;

int main(void)
{
	scanf("%d %d %d", &a, &b, &c);
	
	ans = a - b;
	ans = c - ans;
	
	if(ans <= 0)
		printf("0");
	else
		printf("%d", ans);
	
	return 0;
}

Measured memory_bytes: 128
import bisect as bs
def prime(m):
  N = range(1,m+1, 2)
  N[0] = 2
  n = len(N)
  for i in range(1, n):
    x = N[i]
    if x: N[i+x::x] = [0]*len(N[i+x::x])
  return filter(None, N)

P = prime(10000)
x = []
a = P[0]
for b in P[1:]:
  if b-a==2: x.append(b)
  a=b
while 1:
  n = int(raw_input())
  if n==0: break
  a = x[bs.bisect_right(x, n)-1]
  print a-2, a

Measured memory_bytes: 4660
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 998244353
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll gcd(int a,int b)
{
    return b ? gcd(b, a % b) : a;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(all(a));
    int ans = 1;
    rep(i,n){
        ans = ans * gcd(a[i],i) % MOD;
    }
    cout << ans << "\n";
    return 0;
}

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

int main()
{
	ll n;
	cin >> n;
	vector<ll> A(n);
	rep(i,n)
	cin >> A[i];
	rep(i,n)A[i]-=i+1;
	//rep(i,n)A[i]=abs(A[i]);
	sort(ALL(A));
	ll b=A[n/2];
	ll ans = 0;
	rep(i,n)
	{
		ans += abs(A[i]-b);
	}
	cout<<ans<<endl;

	


	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
typedef long long ll;
using namespace std;

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) return a.first < b.first;
    else return a.second < b.second;
}

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<pair<int, int>> s(n);
    for(int i=0; i<n; i++) {
        cin >> a >> b;
        s[i] = make_pair(a, b);
    }
    sort(s.begin(), s.end(), compare_by_a);

//    for(date=1; date<m; date)

    priority_queue<int> que;

    ll reward=0;

    int j=0;
    for(int i=1; i<=m; i++) {
        while(s[j].first==i) {
            que.push(s[j].second);
            j++;
        }
        if(que.empty()) continue;
        else {
            reward += que.top();
            que.pop();
        }
    }
    cout << reward << endl;
    return 0;
}



Measured memory_bytes: 1660
N = int(input())

coordinates = []
for _ in range(N):
    x, y = map(int, input().split())
    coordinates.append((x, y))
    
import math

distance = []
for i in range(N):
    for j in range(i+1, N):
        x1, y1 = coordinates[i]
        x2, y2 = coordinates[j]
        d = math.sqrt((x1-x2)**2+(y1-y2)**2)
        distance.append(d)
        
        
each_pattern = 1
for i in range(1, N):
    each_pattern *= i
each_pattern *= 2

total_distance = 0
for d in distance:
    total_distance += d*each_pattern
    
pass_pattern = 1
for i in range(1, N+1):
    pass_pattern *= i
    
print(total_distance / pass_pattern)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    int n,m;

    scanf("%d%d",&n,&m);

    printf("%d\n",(n - 1) * (m - 1));
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define fordec(i,a,b) for(int i=(a);i>=(b);i--)
#define vi vector<int>
#define vl vector<ll>
#define vd vector<double>
#define vs vector<string>
#define pb push_back
#define vpi vector<pair<int, int>
#define vpl vector<pair<ll, ll>>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
    long times; cin >> times;
    cout << (times) * (times-1) / 2;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

H, W = rl()
A = [list(rs()) for _ in range(H)]
answer = 0
que = deque()
data = [[-1] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            data[i][j] = 0
            que.append((j, i))
while que:
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    p = que.popleft()
    for i in range(4):
        nx = p[0] + dx[i]
        ny = p[1] + dy[i]
        if 0 <= ny <= H-1 and 0 <= nx <= W-1:
            if data[ny][nx] == -1:
                data[ny][nx] = data[p[1]][p[0]] + 1
                que.append((nx, ny))
answer = max([max(z) for z in data])
print(answer)
# 54


Measured memory_bytes: 121052
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

const int N = 2e5 + 7;
vector <vector <int> > v(N);
vector <bool> visited(N, 0);

int dfs(int x) {
    visited[x] = 1;
    int c = 1;
    for (int y : v[x]) {
        if (!visited[y]) {
            c += dfs(y);
        }
    }
    return c;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].pb(b); v[b].pb(a);
    }
    int ans = INT_MIN;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
           int count = dfs(i);
           ans = max(ans, count);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 23520
#include "bits/stdc++.h"
using namespace std;

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

	int A = 0, B = 0;
	cin >> A >> B;
	
	int ans = 0;
	int outlet = 1;
	while (outlet < B)
	{
		--outlet;
		outlet += A;
		++ans;
	}

	cout << ans;
	return 0;
}

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

using namespace std;

#define int     long long
#define pb      push_back
#define all(x)  x.begin(),x.end()
#define sz(x)   x.size()

const int   N   = 401;
const int   inf = 1ll << 60;

struct Edge {
    int u, v;
    int c, f;
    Edge(int u,int v,int c) : u(u), v(v), c(c), f(0)    {}
};

vector<Edge> E;
vector<int>  g[N];

void addEdge(int u,int v,int c) {
    g[u].pb(sz(E)); E.pb({u,v,c});
    g[v].pb(sz(E)); E.pb({v,u,0});
}

int s, t, p[N];

bool bfs()  {
    for(int i = s ; i <= t ; ++i)
        p[i] = -1;
    queue<int>  q;
    q.push(s);  p[s] = inf;
    while(q.size()) {
        int u = q.front();  q.pop();
        for(int i : g[u])   {
            if(E[i].c == E[i].f)    continue;
            int v = E[i].v;
            if(p[v] < 0)    {
                p[v] = i;
                q.push(v);
            }
        }
    }
    return p[t] >= 0;
}

int n, a[N];

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

    cin >> n;   s = 0;  t = n + 1;

    int sum = 0;

    for(int i = 1 ; i <= n ; ++i)   {
        cin >> a[i];
        bool ch = 0;
        for(int j = 1 ; j <= i ; ++j)   {
            if(i % j)   continue;
            addEdge(j,i,inf);
        }
        sum += max(a[i],0ll);
        if(a[i] < 0)addEdge(s,i,-a[i]);
        else        addEdge(i,t,a[i]);
    }

    int Flow = 0;

    while(bfs())    {
        int u = t, F = inf;
        while(u)    {
            int i = p[u];
            F = min(F,E[i].c - E[i].f);
            u = E[i].u;
        }
        u = t;  Flow += F;
        while(u)    {
            int i = p[u];
            E[i].f += F;    i ^= 1;
            E[i].f -= F;    u = E[i].v;
        }
    }

    cout << sum - Flow << endl;
}


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

using namespace std;

int main() {
	int N, M, X, Y, x = -100, y = 100, k = 0;
	cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; i++) {
		cin >> k;
		if (x < k) {
			x = k;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> k;
		if (y >= k) {
			y = k;
		}
	}
	for (int i = X + 1; i <= Y; i++) {
		if (x < i && y >= i) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("O3")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll n,m;cin>>n>>m;
    multiset<double> a;
    REP(i,n){ll a_;cin>>a_;a.insert(a_);}
    REP(i,m){
        double ne=(*--a.end())/2;
        a.erase(--a.end());
        a.insert(ne);
    }
    ll ans=0;
    for(auto& i:a){
        ans+=ll(i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8320
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int n,o;
    cin >> n;
    vector<int> a(n+1,0);
    for(int i=1;i<n;i++){
        cin >> o;
        a[o]++;
    }
    for(int i=1;i<=n;i++){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 3616
#include<iostream>
#include<climits>
using namespace std;
int main(){
  int n;    
  while(cin >> n,n){
    int ans=INT_MAX;
    for(int i=0;i<=25;i++){
      for(int j=0;j<=17;j++){
	for(int k=0;k<=10;k++){
	  if(i*200+j*300+k*500==n){
	    int temp;
	    temp=i*380+j*550+k*850;;
	    temp-=(i/5)*5*380*20/100+(j/4)*4*550*15/100+(k/3)*3*850*12/100;
	    if(ans>temp){
	      ans=temp;
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
<?php

$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$k = (int)$input[1];

$x_array = explode(' ', trim(fgets(STDIN)));
$min = null;
for($i = 0; $i <= $n - $k; $i++){
    $left = (int)$x_array[$i];
    $right = (int)$x_array[$i+$k-1];
    $tmp = min(abs($right)+abs($right- $left), abs($left)+abs($right- $left));
    if (is_null($min)) {
        $min = $tmp;
    }else{
        $min = min($min, $tmp);
    }
}
echo $min;

Measured memory_bytes: 12792
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> A(n, 0);
    vector<int> B(n, 0);
    vector<int> C(n, 0);

    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        --A[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> B[i];
    }
    for (int i = 0; i + 1 < n; ++i) {
        cin >> C[i];
    }

    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += B[A[i]];
        if (i - 1 >= 0 && A[i - 1] + 1 == A[i]) {
            res += C[A[i] - 1];
        }
    }
    cout << res << "\n";

    return 0;
}

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

int main() {
    
    ll n; cin >> n;
    ll extra = 0;
    set<ll> colors;
    for (int i = 0; i < n; i++) {
        ll a; cin >> a;
        ll val = a/400;
        if (val < 8) {
            colors.insert(val);
        } else {
            extra++;
        }
    }
    if (colors.size()==0) {
        cout << 1 << " " << extra << endl;
    } else {
        cout << colors.size() << " " << colors.size()+extra << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_rinsetsu = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    h_rinsetsu[a - 1].append(b - 1)
    h_rinsetsu[b - 1].append(a - 1)

ans = 0
for i in range(n):
    for j in h_rinsetsu[i]:
        if h[i] <= h[j]: break
    else: ans += 1

print(ans)

Measured memory_bytes: 29440
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<string>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
  if(a+b>=c)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  }





Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int a, b;

	cin >> a >> b;

	cout << (a - 1) * (b - 1) << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int h,w;
int sx,sy,ex,ey;
int grid[1005][1005];
int dis[1005][1005];
int px[]={1,-1,0,0};
int py[]={0,0,1,-1};
bool good(int x,int y){
    return (x>=1 && y>=1 && x<=h && y<=w && grid[x][y]==0);
}
void bfs(){
    deque<pii> dq;
    dq.pb(mp(sx,sy));
    memset(dis,63,sizeof(dis));
    dis[sx][sy]=0;
    while(!dq.empty()){
        pii ha=dq.front();
        dq.pop_front();
        for(int i=ha.fi-2;i<=ha.fi+2;i++)
            for(int j=ha.se-2;j<=ha.se+2;j++){
                if(!good(i,j)) continue;
                if(dis[i][j]>dis[ha.fi][ha.se]+1){
                    dis[i][j]=dis[ha.fi][ha.se]+1;
                    dq.pb(mp(i,j));
                }
            }
        for(int i=0;i<4;i++){
            int nx=px[i]+ha.fi,ny=py[i]+ha.se;
            if(!good(nx,ny)) continue;
            if(dis[nx][ny]>dis[ha.fi][ha.se]){
                dis[nx][ny]=dis[ha.fi][ha.se];
                dq.push_front(mp(nx,ny));
            }
        }
    }
}
int main(){
    scanf("%d %d",&h,&w);
    scanf("%d %d",&sx,&sy);
    scanf("%d %d",&ex,&ey);
    for(int i=1;i<=h;i++){
        char s[1005];
        scanf("%s",s);
        for(int j=1;j<=w;j++)
            if(s[j-1]=='#')
                grid[i][j]=1;
            else
                grid[i][j]=0;
    }
    bfs();
    if(dis[ex][ey]>1e8)
        printf("-1\n");
    else
        printf("%d\n",dis[ex][ey]);
    return 0;
}

Measured memory_bytes: 11724
#include <iostream>
using namespace std;
int gcd(int a, int b);
int gcdd(int a, int b ,int c);
int main(){
    long long sum = 0;
    long long k;
    cin >> k;
    for (long long i = 1; i <= k; i++){ 
        for (long long j = 1; j <= k; j++) {
            for (long long b = 1; b <= k; b++) {
                sum+=gcdd(i,j,b);
            }
        }
    }
    cout << sum;
}
int gcdd (int a, int b, int c){
    return gcd(a, gcd(b,c));
}
int gcd(int a, int b) { 
   if (b == 0) 
      return a; 
   return gcd(b, a % b);  
} 

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

int main(){
    ll n,cnt;
    cin >>n;
    string ans="";
    while(n){
        n--;
        ans+='a'+n%26;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
//21:18
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int NV=10;
ll T[NV][NV];
struct Mat
{
	int r,c;
	ll M[NV][NV];
	Mat()
	{
		memset(M,0,sizeof(M));
	}
	void init(int rc)
	{
		r=c=rc;
		for(int i=0;i<rc;i++)M[i][i]=1;
	}
};
Mat f(Mat&A,Mat&B)
{
	Mat C;C.c=B.c,C.r=A.r;
	for(int i=0;i<C.c;i++)
		for(int j=0;j<C.r;j++){
			ll res=0;
			for(int k=0;k<B.r;k++)res+=B.M[k][i]*A.M[j][k];
			C.M[j][i]=res;
		}
	return C;
}
Mat fastPow(Mat a,ll b)
{
	Mat ans,pp=a;ans.init(a.r);
	while(b>0){
		if(b&1)ans=f(ans,pp);
		b>>=1;pp=f(pp,pp);
	}return ans;
}
Mat In;
#define ld long double
int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	ll a,b,c,k;scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	/*In.r=In.c=3;
	In.M[0][1]=In.M[0][2]=1;
	In.M[1][0]=In.M[1][2]=1;
	In.M[2][0]=In.M[2][1]=1;
	for(int i=1;i<10;i++){
		Mat G=fastPow(In,i);
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++)cout<<G.M[j][k]<<' ';
			cout<<'\n';
		}cout<<'\n';
	}*/
	if(k%2==0)cout<<a-b<<'\n';
	else cout<<b-a<<'\n';
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int S;
    scanf("%d", &S);
    int L = S / 100;
    int R = S % 100;
    if(1<=L&&L<=12){
        if(1<=R&&R<=12)printf("AMBIGUOUS\n");
        else printf("MMYY\n");
    }else{
        if(1<=R&&R<=12)printf("YYMM\n");
        else printf("NA\n");
    }
}


Measured memory_bytes: 3660
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i] = map(int,input().split())
ans=0

towns=list(range(n))
now=1
kaijou=[]
for i in range(1,9):
    now*=i
    kaijou.append(now)

from itertools import permutations
import math
for root in permutations(towns,n):
    ans+=sum([math.sqrt( ( x[root[i]]-x[root[i-1]])**2 +( y[root[i]]-y[root[i-1]])**2 ) for i in range(1,n)])
print(ans/kaijou[n-1] )

Measured memory_bytes: 41452
import java.util.Scanner;

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

		double ans1 = 0;
		for (int i = 0; i < N; i++) {
			ans1 += 1 / (double) sc.nextInt();
		}
		sc.close();
		double ans2 = (1 / ans1);
		System.out.println(ans2);
	}
}

Measured memory_bytes: 22100
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,k,f[100005];
int main(){
	f[0]=1;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)f[i]=min(f[i-1]*2,f[i-1]+k);
	printf("%d\n",f[n]);
	return 0;
}

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

using namespace std;

typedef long long	ll;
const int N = 5;
ll cnt[N];

int main (){
	int n;

	cin >> n;

	for(int i = 0 ; i < n ; i++){
		string name;

		cin >> name;

		if(name[0] == 'M'){
			cnt[0]++;
		}else if(name[0] == 'A'){
			cnt[1]++;
		}else if(name[0] == 'R'){
			cnt[2]++;
		}else if(name[0] == 'C'){
			cnt[3]++;
		}else if(name[0] == 'H'){
			cnt[4]++;
		}
	}

	ll ways = 0;

	for(int i = 0 ; i < 5 ; i++){
		for(int j = i + 1 ; j < 5 ; j++){
			for(int k = j + 1 ; k < 5 ; k++){
				ways += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}

	cout << ways <<  '\n';

	return 0;
}

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

int main () {
    int A , B;
    cin >> A >> B;
    int sum = A + B;

    if (sum % 2 == 0){
        cout << sum / 2 << endl;
    }

    else {
        cout << "IMPOSSIBLE" << endl;
    }
    
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

a, b, c = map(int, input().split())

r = a + b
r += c
if r >= 22:
    ans = 'bust'
else:
    ans = 'win'

print(ans)


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

using namespace std;

#define pb push_back
const int maxi = 1e6+10;
string s;
long long n ,a ,b;

vector<int> v[maxi];

int main()
{
    cin>>n>>a>>b;
    if (b<a) swap(a,b);
    if ((b-a)%2==0) return !printf("%lld\n",(b-a)/2);

   long long p1 = (b-a)/2 +  a;
   long long p2 = (b-a)/2 +  n - b + 1;

   return !printf("%lld\n", min(p1, p2));
   return 0;
}
//Kalifornija koka(kola) i sjaj


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

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;

void solve() {
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> tb(h, vector<bool>(w));

    for (auto &&a:tb) {
        for (auto &&b:a) {
            char c;
            cin >> c;
            b = (c == '.');
        }
    }

    vector<unsigned> r(h, false);
    vector<unsigned> c(w, false);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (!tb[i][j]) {
                r[i] = true;
                c[j] = true;
            }
        }
    }

    unsigned nr = false;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (r[i] & c[j]) {
                nr |= r[i] & c[j];
                cout << (tb[i][j] ? '.' : '#');
            }
        }
        if (nr) {
            nr = 0;
            cout << endl;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
struct node {
    int to,next;
}E[MAXN * 2];
int head[MAXN],sumE;
int mv[MAXN],siz[MAXN],d[MAXN],c[MAXN],son[MAXN];
void add(int u,int v) {
    E[++sumE].next = head[u];
    E[sumE].to = v;
    head[u] = sumE;
}
void calc(int u,int fa,int val) {
    son[u] = 1;
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa && v < val) {
	    calc(v,u,val);
	    son[u] += son[v];
	}
    }
}
void dfs(int u,int fa) {
    mv[u] = max(mv[fa],u);
    siz[u] = 1;
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    dfs(v,u);
	    siz[u] += siz[v];
	    d[u] += d[v];
	}
    }
    if(mv[u] == u) {
	calc(u,fa,mv[fa]);
	d[u] = -siz[u];
    }
    if(mv[fa] == fa) d[u] += siz[u];
}
void dfs2(int u,int fa) {
    if(fa) {
	if(mv[u] == u) {c[u] += son[u];}
	else if(mv[fa] == fa) {c[u] -= son[u];c[u] += d[u];}
	c[u] += c[fa];
    }
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    dfs2(v,u);
	}
    }
}
void Init() {
    read(N);
    int x,y;
    for(int i = 1 ; i < N ; ++i) {
	read(x);read(y);add(x,y);add(y,x);
    }
}
void Solve() {
    dfs(1,0);
    dfs2(1,0);
    for(int i = 2 ; i <= N ; ++i) {
	out(c[i]);
	i == N ? enter : space;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
}


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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  
  int ans = 0;
  for(int i=0; i<=a; i++) {
    for(int j=0; j<=b; j++) {
      for(int k=0; k<=c; k++) {
        if(500*i+100*j+50*k==x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


vector<int> daikus(vector<vector<mp> > &g,int s){
	int n = g.size();
	vector<bool> used(n,false);
	vector<int> res(n,inf) ;
	priority_queue<mp,vector<mp> ,greater<mp> > q;
	q.push(mp(0,s) );
	while(!q.empty() ){
		mp now = q.top();
		q.pop();
		int nn = now.second;
		int cost = now.first;
		if(used[nn])continue;
		used[nn] = true;
		res[nn] = cost;
		for(int i=0;i<g[nn].size();i++){
		    int next  = g[nn][i].second;
		    int nc = g[nn][i].first + cost;
		    if(used[next])continue;
		    q.push(mp(nc,next) );
		}
	}
	return res;
}

vector<int> height(vector<vector<mp> > &g){
	int n = g.size();
    	vector<int> v,v1,v2,res(n);
	v = daikus(g,0);
	int p1 = max_element(v.begin(),v.end()) -v.begin();
	v1 = daikus(g,p1);
	int p2 = max_element(v1.begin(),v1.end())-v1.begin();
	v2 = daikus(g,p2);
	for(int i=0;i<n;i++)res[i] = max(v1[i],v2[i]);
	return res;
}

int main(){
	int n;
	cin>>n;
	vector<vector<mp> > g(n);
	for(int i=0;i<n-1;i++){
		int s,t,w;
		cin>>s>>t>>w;
		g[s].push_back(mp(w,t) );
		g[t].push_back(mp(w,s) );
	}
	vector<int> res = height(g);
	for(int i=0;i<n;i++)cout<<res[i]<<endl;


	return 0;
}



Measured memory_bytes: 4160
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <map>

#define MOD 1000000007

using namespace std;

long long int pow2(int k){
 long long int a = 1;
 while(k>0){
   a*=2;
   a%=MOD;
   k--;
 }
 return a;
}

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

  map<pair<long long int, long long int>, pair<int, int> > gcdMap;
  int z=0;
  for(int i=0;i<N;i++){
    long long int A,B;
    cin >> A >> B;
    if(A==0&&B==0){
      z++;
      continue;
    }else{
      auto d = __gcd(A,B);
      A/=d;
      B/=d;
      if(B<0){
      	A*=-1;
        B*=-1;
      }
    }
    if(A>0) {
      gcdMap[make_pair(A,B)].first++;
    }else{
      gcdMap[make_pair(B,-1*A)].second++;
    }
  }

  long long int answer=1;
  for(auto p : gcdMap){
  	auto p2=p.second;
    answer*=pow2(p2.first)+pow2(p2.second)-1;
    answer%=MOD;
  }
  cout << (answer+z-1+MOD)%MOD << endl;

}


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

int main()
{
  string s;
  cin >> s;
  int ans1=-1, ans2=-1, n;
  
  n = s.length();
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1]){
      ans1=i+1;
      ans2=i+2;
      break;
    }
  }
  for(int i=0;i<n-2;i++){
    if(s[i]==s[i+2]){
      ans1=i+1;
      ans2=i+3;
      break;
    }
  }

  cout<< ans1 << " " << ans2  <<endl;
}


Measured memory_bytes: 512