akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var c = Console.ReadLine().ToInt();
		
		for(int i = 0; i < 1000; i++)
		{
			if(c - 100 * i == 0)
			{
				Console.WriteLine(1);
				return;
			}
			else if(c - 100 * i < 0)
			{
				break;
			}
			else if(Check(c, i))
			{
				Console.WriteLine(1);
				return;
			}
		}
		Console.WriteLine(0);
	}
	
	public static bool Check(int k, int s)
	{
		int m = k - (s * 100);
		for(int i = 0; i < s; i++)
		{
			for(int j = 5; j >= 1; j--)
			{
				if(m - j == 0)
					return true;
				if(m - j > 0)
				{
					m-=j;
					break;
				}
			}
		}
		return m == 0;
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

int main(void)
{
	int a, b, c, min, max;
	
	scanf("%d %d %d", &a, &b, &c);
	if(a < b && a < c)
	{
		min = a;
	}
	else if(b < a && b < c)
	{
		min = b;
	}
	else
	{
		min = c;
	}
	
	if(a > b && a > c)
	{
		max = a;
	}
	else if(b > a && b > c)
	{
		max = b;
	}
	else
	{
		max = c;
	}
	printf("%d %d %d\n", min, (a + b + c)-max-min, max);	
}


Measured memory_bytes: 2756
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int n,m,x;
        cin>>n>>m>>x;
        vector<vector<int>> a(n,vector<int>(m+1));
        loop(i,0,n-1){
            loop(j,0,m){
                cin>>a[i][j];
            }
        }
        int ans = LLONG_MAX;
        int k = pow(2,n)-1;
        loop(i,0,k){
            string y = bitset<20>(i).to_string();
            reverse(y.begin(),y.end());
            vector<int> fin(m+1,0);
            loop(j,0,n-1){
                if(y[j]=='1'){
                    loop(f,0,m) fin[f]+=a[j][f];
                }
            }
            bool flg = true;
            loop(f,1,m){
                if(fin[f]<x){
                    flg = false;
                    break;
                }
            }
            if(flg) ans = min(ans,fin[0]);
        }
        if(ans==LLONG_MAX) ans = -1;
        cout<<ans<<"\n";
    }
    return 0;
}

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

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

    int N;
    cin >> N;

    vector<int> d(N);

    for(int i = 0; i < N; i++) cin >> d[i];

    sort(d.begin(), d.end());

    int ans = 1;

    for(int i = 1; i < N; i++) {
        if(d[i] != d[i - 1]) ans++;
    }

    cout << ans << endl;
}

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

namespace y.miyoshi
{

    public class Queen8
    {
        static int Max = 8;
        static bool[] vertical;
        static bool[] diagonal1;
        static bool[] diagonal2;
        static Dictionary<byte, byte> queenDic;
        static byte[] skip;
        static bool finish;

        public static void Main()
        {
            var n = byte.Parse(Console.ReadLine());
            skip = new byte[n];
            queenDic = Enumerable.Range(0, n).Select(_ =>
            {
                var line = Console.ReadLine().Split();
                skip[_] = byte.Parse(line[0]);
                return new { x = byte.Parse(line[0]), y = byte.Parse(line[1])};
            }).ToDictionary(e => e.x, e=>e.y);

            Initialize();
            queenDic.ToList().ForEach(q => MarkBoad(q.Key, q.Value, true));

            Search8Queens(0);

        }

        public static void Search8Queens(byte x)
        {
            if (finish) return;

            if (x == Max)
            {
                Display();
                finish = true;
                return;
            }

            if (!skip.Contains(x))
            {
                for (byte i = 0; i < Max; i++)
                {
                    //????????????????
                    if (queenDic.ContainsKey(x)
                        || vertical[i] == true
                        || diagonal1[x + i] == true
                        || diagonal2[x - i + Max - 1] == true)
                        continue;

                    //??????
                    MarkBoad(x, i, true);
                    Search8Queens((byte)(x + 1));
                    MarkBoad(x, i, false);
                }
            }
            else
            {
                Search8Queens((byte)(x + 1));
            }

        }

        public static void Display()
        {
            for (byte i = 0; i < Max; i++)
            {
                for (byte j = 0; j < Max; j++)
                {
                    if (queenDic[i] == j)
                        Console.Write('Q');
                    else
                        Console.Write('.');
                }
                Console.WriteLine();
            }
        }

        public static void MarkBoad(byte x, byte y, bool mark)
        {
            vertical[y] = mark;
            diagonal1[x + y] = mark;
            diagonal2[x - y + Max - 1] = mark;
            if (mark) queenDic[x] = y;
            else queenDic.Remove(x);
        }

        public static void Initialize()
        {
            vertical = new bool[Max];
            diagonal1 = new bool[2 * Max - 1];
            diagonal2 = new bool[2 * Max - 1];
        }

        //public struct Queen
        //{
        //    public byte x;
        //    public byte y;
        //}
    }
}

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

    int c[][] = new int[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        c[i][j]=sc.nextInt();
      }
    }

    if(c[0][0]-c[0][1]!=c[1][0]-c[1][1]){
      System.out.println("No");
      return;
    }
    if(c[1][0]-c[1][1]!=c[2][0]-c[2][1]){
      System.out.println("No");
      return;
    }
    if(c[0][1]-c[0][2]!=c[1][1]-c[1][2]){
      System.out.println("No");
      return;
    }
    if(c[1][1]-c[1][2]!=c[2][1]-c[2][2]){
      System.out.println("No");
      return;
    }
    if(c[0][0]-c[1][0]!=c[0][1]-c[1][1]){
      System.out.println("No");
      return;
    }
    if(c[0][1]-c[1][1]!=c[0][2]-c[1][2]){
      System.out.println("No");
      return;
    }
    if(c[1][0]-c[2][0]!=c[1][1]-c[2][1]){
      System.out.println("No");
      return;
    }
    if(c[1][1]-c[2][1]!=c[1][2]-c[2][2]){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");



  }
    


}


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

int get_middle(int num)
{
    return num / 2;
}

void make_head_foot_line(string& line, int w)
{
    line.erase();
    line.push_back('+');
    
    for(int i = 0; i < w - 2; ++i)
    {
        line.push_back('-');
    }
    line.push_back('+');
}

void make_normal_line(string& line, int w)
{
    line.erase();
    line.push_back('|');
    
    for(int i = 0; i < w - 2; ++i)
    {
        line.push_back('.');
    }
    line.push_back('|');
}

void make_middle_line(string& line, int w, char c)
{
    make_normal_line(line, w);
    line[ get_middle(w) ] = c;
}

int main(void){
    int w, h;
    int middle;
    char c;
    
    cin >> w >> h >> c;
    middle = get_middle(h);
    
    string head_line, foot_line, middle_line, normal_line;

    make_head_foot_line(head_line, w);
    make_head_foot_line(foot_line, w);
    make_normal_line(normal_line, w);
    make_middle_line(middle_line, w, c);

    cout << head_line << endl;
    for(int i = 1; i < h - 1; ++i)
    {
        if(i == middle)
        {
            cout << middle_line << endl;
        }
        else
        {
            cout << normal_line << endl;
        }
    }
    cout << foot_line << endl;
    
    return 0;
}



Measured memory_bytes: 3240
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();
		long ret = 0L;
		long kijun = a[0];
		for(int i = 1; i < n; i++) {
			if(kijun > a[i]) {
				ret += kijun - a[i];
			} else {
				kijun = a[i];
			}
		}
		prtln(ret);
	}
	public static <T> void prtln(T t) { System.out.println(t); }
}


Measured memory_bytes: 51572
s=input()
q=int(input())
f=0
l,r='',''
for i in range(q):
    a=list(input().split())
    if a[0]=='1':
        f+=1
    else:
        if (int(a[1])-1)^(f%2)==0:
            l+=a[2]
        else:
            r+=a[2]
if f%2==1:
    print(r[::-1]+s[::-1]+l)
else:
    print(l[::-1]+s+r)

Measured memory_bytes: 4468
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}

int main(void) {

int input[100];
int j,count;
int A,B,C;

inp_str(input);
A=input[0];
B=input[1];
C=input[2];

//printf("%d\n",A);
//printf("%d\n",B);
//printf("%d\n",C);

if((A==B)&&(B==C)) {
	printf("Yes\n");
}else{
printf("No\n");
}
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

ll MAX = 1e9+1;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 1;

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

    switch (n%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        default:
            cout << "bon" << endl;
            break;
    }

    //cout.precision(20);
    //cout << ans << endl;
}


int main() {
    solve();
	return 0;
}




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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;


int main() {
	ll n;
	cin >> n;
	vector<ll> vs(n);
	rep(i, n) cin >> vs[i];
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0) continue;
		if (vs[i-1] % 2 == 0) continue;
		sum++;
	}
	cout << sum << endl;
	return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while (x->left!=NIL) x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while (x->right!=NIL) x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  Node ret = NIL;
  if (u->key==k) return u;
  else if (u->key>k) {
    if (u->left!=NIL)
      return treeSearch(u->left, k);
  } else if (u->right!=NIL)
    return treeSearch(u->right, k);
  return ret;
}

Node treeSuccessor(Node x){
  if (x->right!=NIL)  return treeMinimum(x->right);
  Node y = x->parent;
  while (x->parent != NIL && x->parent->right==x) {
    x = y->parent;
  }
  return x;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if (z->left==NIL && z->right==NIL) { // has no child
    if (z->parent->left==z)  z->parent->left=NIL;
    else                     z->parent->right=NIL;
    free(z);
  } else  if (z->left!=NIL && z->right!=NIL) { // has two children
    y = treeSuccessor(z);
    z->key=y->key;
    treeDelete(y);
  } else { // if (z->left!=NIL || z->right!=NIL) { //  has just one child
    x = (z->left!=NIL) ? z->left : z->right;
    if (z->parent->left==z)   z->parent->left=x;
    else                      z->parent->right=x;
    x->parent = z->parent;
    free(z);
    return;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x!=NIL) {
    y = x;
    if (z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if (y==NIL)
    root = z;
  else if (z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void inorder(Node u){
  if (u->left!=NIL) inorder(u->left);
  printf(" %d", u->key);
  if (u->right!=NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if (u->left!=NIL) preorder(u->left);
  if (u->right!=NIL) preorder(u->right);
}

void print()
{
  if (root==NIL) return;
  preorder(root);
  printf("\n");
  inorder(root);
  printf("\n");
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for (i = 0; i < n; i++){
    scanf("%s", com);
    switch (com[0]) {
    case 'f':
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
      break;
    case 'i':
      scanf("%d", &x);
      insert(x);
      break;
    case 'p':
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      break;
    case 'd':
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

int32 N;
Mat a;

int64 dp[1 << 16] = {}, sum[1 << 16] = {};

int main(void){
	cin >> N;
	a.resize(N, Row(N));
	REP(i, N){
		REP(j, N){
			cin >> a[i][j];
		}
	}
	REP(i, 1 << N){
		REP(j, N){
			FOR(k, j+1, N){
				if(i >> j & 1 && i >> k & 1){
					sum[i] += a[j][k];
				}
			}
		}
	}
	
	for(int32 i = (1 << N)-1;i >= 0;i--){
		for(int32 j = i;j >= 0;j = (j-1)&i){
			chmax(dp[j], dp[i] + sum[i ^ j]);
			if(j == 0) break;
		}
	}
	cout << dp[0] << endl;

}


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

int k, n, a[200000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> k >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	int mn = a[n - 1] - a[0];
	for(int i = 0; i < n - 1; i++) mn = min(mn, k - a[i + 1] + a[i]);
	cout << mn << "\n";
	return 0;
}


Measured memory_bytes: 1024
import itertools
from math import factorial
from collections import Counter

ans = 0
N, L = map(int, input().split())
x = list(map(int, input().split()))
y = itertools.accumulate(x)
y = [e % L for e in y]
#print(y)
#print(y)
so = set(y)
#print(so)
#print(so)
counter = Counter([0]+y)
#print(counter.values())
#print
for i in counter.values():
    #print(ans)
    ans+=i * (i - 1) // 2
print(ans)

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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << '\n';cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const int inf = 0x3f3f3f3f;
const int mod = 998244353;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

const int inc_x[]{-1, 1, 0, 0};
const int inc_y[]{0, 0, -1, 1};

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int h,w; cin >> h >> w;
	int ch, cw, dh, dw; cin >> ch >> cw >> dh >> dw;
	ch--, cw--, dh--, dw--;
	char grid[h][w];
	for (int i= 0; i<h; i++) {
		string s; cin >> s;
		for (int j = 0; j<w; j++) grid[i][j] = s[j];
	}
	int dist[h][w];
	memset(dist, inf, sizeof(dist));
	dist[ch][cw] = 0;
	deque<pair<int, int>> Q;
	Q.push_back(make_pair(ch, cw));
	while (!Q.empty()) {
		pair<int, int> curr = Q.front();
		Q.pop_front();
		
		int x1 = curr.first, y1 = curr.second;
		for (int i = 0; i<4; i++) {
			int x2 = x1 + inc_x[i], y2 = y1 + inc_y[i];
			if (inrange(x2, 0, h-1) && inrange(y2, 0, w-1)) {
				if (grid[x2][y2] != '#' && dist[x2][y2] > dist[x1][y1]) {
					dist[x2][y2] = dist[x1][y1];
					Q.push_front(make_pair(x2, y2));
				}
			}
		}
		
		for (int i = max(curr.first-2, 0); i<=min(curr.first+2, h-1); i++) {
			for (int j = max(curr.second-2, 0); j <= min(curr.second+2, w-1); j++) {
				if (grid[i][j] != '#' && dist[i][j] > dist[curr.first][curr.second]+1) {
					dist[i][j] = dist[curr.first][curr.second] + 1;
					Q.push_back(make_pair(i, j));
				}
			}
		}
	}
	cout << (dist[dh][dw] == inf ? -1 : dist[dh][dw]) << '\n';
}


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

using namespace std;

int main() {
    int count = 0;
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++)
    {
        if (s.at(i) == '1')
        {
            count++;
        }
        
    }
    
    cout << count << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <list>

using namespace std;
list<int> ax[200005];
int bx[200005];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int i,j,a,b;
    for(i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        ax[a].push_back(b);
        ax[b].push_back(a);
    }
    list<int>::iterator p;
    for(p=ax[1].begin();p!=ax[1].end();p++){
        bx[*p]=1;
    }
    bool flag = 0;
    for(p=ax[n].begin();p!=ax[n].end();p++){
        if(bx[*p])flag = 1;
    }
    if(flag)printf("POSSIBLE");
    else printf("IMPOSSIBLE");
    return 0;
}


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

int calc_max_part(const string& s, char target)
{
  int maxl = 0;
  for (size_t pos = 0, nextpos;; pos = nextpos + 1) {
    nextpos = s.find(target, pos);
    int l;
    if (nextpos == string::npos) {
      l = s.size() - pos;
    } else {
      l = nextpos - pos;
    }
    if (maxl < l) maxl = l;
    if (nextpos == string::npos) break;
  }
  return maxl;
}

int main(int argc, char *argv[])
{
  string s;
  cin >> s;
  int count[26] = {0};
  for (string::iterator c = s.begin(); c != s.end(); ++c) {
    count[*c - 'a']++;
  }

  int minl = s.size();
  for (char target = 'a'; target <= 'z'; ++target) {
    if (count[target - 'a'] > 0) {
      int l = calc_max_part(s, target);
      minl = (minl < l)? minl : l;
    }
  }

  cout << minl << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    X, Y = map(int, input().split())
    for i in range(X + 1): #亀の総数
        if 4 * i + 2 * (X - i) == Y:
            print("Yes")
            break
    else: print("No")

    return 0

if __name__ == "__main__":
    solve()

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

using namespace std;

int main() {
	long long a, b, c;
	cin >> a >> b >> c;

	long long ret = 0;
	if (c > 0) {
		ret++;
		c--;
	}

	if (b >= c) {
		ret += b + c;
	} else {
		ret += b * 2;
		c -= b;

		ret += min(c, a);
	}

	cout << ret << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (k == 0) return 1;
	return n * COM(n - 1, k - 1) / k;
}
int main(){
  int N;
  cin >> N;
  vector< vector<string> > mem(5);
  rep(i,N){
    string input;
    cin >> input;
    if(input[0] == 'M')         mem[0].push_back(input);
    else if(input[0] == 'A')    mem[1].push_back(input);
    else if(input[0] == 'R')    mem[2].push_back(input);
    else if(input[0] == 'C')    mem[3].push_back(input);
    else if(input[0] == 'H')    mem[4].push_back(input);
  }
  //descendingSort
  rep(i,5) sort(all(mem[i]));

  //unique
  rep(i,5) mem[0].erase(unique(all(mem[0])),mem[0].end());

  long long sum = 0;
  FOR(i,0,5){
    FOR(j,i+1,5){
      FOR(k,j+1,5){
        sum += mem[i].size() * mem[j].size() * mem[k].size();
      }
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 5748
#include <stdio.h>
typedef long long ll;
using namespace std;

ll max(ll a, ll b) {
  return a > b ? a : b;
}

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld", &n);
  ll h[n], a[n], sm = 1;
  for(i = 0; i < n; ++i) scanf("%lld", &h[i]);
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  while(sm < n) sm *= 2;
  ll seg[sm * 2], las[sm * 2], now = 1;
  for(i = 1; i < sm * 2; ++i) {
    if(now * 2 == i) now *= 2;
    las[i] = sm / now * (i - now + 1);
    seg[i] = 0;
  }
  for(i = 0; i < n; ++i) {
    ll tmp = 0;
    now = h[i] + sm - 1;
    while(now) tmp = max(tmp, seg[now]), now /= 2;
    tmp += a[i];
    if(ans < tmp) ans = tmp;
    if(h[i] == n) continue;
    now = h[i] + sm;
    while(1) {
      while(!(now & 1)) now >>= 1;
      seg[now] = max(seg[now], tmp);
      if(las[now] == sm) break;
      now++;
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 11520
#include <algorithm>
#include <cstdio>
#include <cstring>

const int MAX = 20000000;
const int NIL = -1;
int tree_size = 0;
int tree[MAX + 1];

void maxHeapify(int i)
{
  int l = 2 * i;
  int r = 2 * i + 1;

  // Select the node which has the maximum key value
  int maximum_i = i;
  if (l <= tree_size && tree[l] > tree[maximum_i])
    maximum_i = l;
  if (r <= tree_size && tree[r] > tree[maximum_i])
    maximum_i = r;

  if (maximum_i != i)
  {
    // Call recursively
    std::swap(tree[i], tree[maximum_i]);
    maxHeapify(maximum_i);
  }
}

void buildMaxHeap()
{
  for (int i = tree_size / 2; i >= 1; --i)
    maxHeapify(i);
}

void replaceKey(int i, int key)
{
  tree[i] = key;
  while (i > 1 && tree[i] > tree[i / 2])
  {
    std::swap(tree[i], tree[i / 2]);
    i /= 2;
  }
}

void insertKey(int key)
{
  if (tree_size == MAX)
    return;

  ++tree_size;
  tree[tree_size] = key;
  replaceKey(tree_size, key);
}

void extractMax()
{
  if (tree_size == 0)
    return;

  printf("%d\n", tree[1]);

  // Remove root node
  tree[1] = tree[tree_size];
  --tree_size;
  maxHeapify(1);
}

int main()
{
  for (int i = 0; i < MAX; ++i)
  {
    char command[7];
    scanf("%s", command);

    if (command[0] == 'i')
    {
      int key;
      scanf("%d", &key);
      insertKey(key);
    }
    else if (command[1] == 'x')
      extractMax();
    else
      break;
  }

  return 0;
}


Measured memory_bytes: 6468
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 1;
    rep(i,1,N+1){
        (ans *= i) %= MOD;
    }
    print(ans);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  double ans=0;
  for(int i = 0; i < n; i++) ans += 1.0/a.at(i);
  cout << 1.0/ans;
}

Measured memory_bytes: 256
#include<iostream>
using ll = long long;
using namespace std;
int main(){
    ll n;
    cin >> n;
    int ans=n;
    for(int i=0;i<=n;i++){
        int a=0,b=i;
        while(b>0){
            a+=b%9;
            b/=9;
        }
        b=n-i;
        while(b>0){
            a+=b%6;
            b/=6;
        }
        if(ans>a)   ans=a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
X,Y = map(int,input().split())
money = [300000,200000,100000]
ans = 0
if X - 1 < 3:
	ans += money[X - 1]
if Y - 1 < 3:
	ans += money[Y - 1]
if X == 1 and Y == 1:
	ans += 400000
print(ans)

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abhm = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
            var a = abhm[0];
            var b = abhm[1];
            var h = abhm[2];
            var m = abhm[3];
            var kakuB = Math.PI / 30 * m;
            var kakuA = Math.PI / 6 * h + Math.PI / 360 * m;
            var kaku = 0d;
            var tmp = Math.Abs(kakuB - kakuA);
            if (tmp == Math.PI)
            {
                Console.WriteLine(a + b);
                return;
            }
            else if (tmp > Math.PI)
            {
                kaku = 2 * Math.PI - tmp;
            }
            else
            {
                kaku = tmp;
            }

            Console.WriteLine(Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(kaku)));
        }
    }
}

Measured memory_bytes: 28668
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*n
for i in range(n):
    a[i] = int(input())
ans = a[0]-1
prev = 1
for i,num in enumerate(a[1:]):
    if prev+1<num:
        while num-(prev+1)>0:
            v = (num-1)//(prev+1)
            num -= v*(prev+1)
            ans += v
            if num==prev+1:
                num = prev
                break
    prev = max(prev, num)
print(ans)

Measured memory_bytes: 76964
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>

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

using namespace std;

typedef long long ll;


ll n;
ll p[20];


int main() {


//    cin.rdbuf(in.rdbuf());

    cin >> n;
    ll ans = 0;
    REP(i, n) {
        cin >> p[i];
        if (i > 1) {
           if ((p[i-2] > p[i - 1] && p[i - 1] > p[i]) || (p[i-2] < p[i-1] && p[i-1] < p[i])) {
               ans++;
           }
        }
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 256
def main():
    from fractions import gcd
    import sys
    input = sys.stdin.readline
    def lcm(a,b):
        return a*b // gcd(a,b)
    N = int(input())
    A = list(map(int,input().split()))
    M = 10**9+7
    l = 1
    for a in A:
        l = lcm(l,a)
    ans = 0
    for a in A:
        ans += l//a
    print(ans%M)
if __name__ == '__main__':
    main()


Measured memory_bytes: 6200
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
//stl
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <list>
#include <bitset>
#include <iomanip>

#define ll long long
#define ioio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define F first
#define S second
const ll mod = 1000000007;
const double eps = 1e-9;
const double pi = acos(-1.0);

using namespace std;

int module(int a, int b)
{
	return (a % b + b) % b;
}

vector<vector<int>>g;
vector<int>used;

bool dfs(int v, int pcol)
{
	if (pcol == 1)
		used[v] = 2;
	else
		used[v] = 1;
	int call = used[v];
	bool f = 1;
	for (auto i : g[v])
	{
		if (used[i] == 0)
		{
			f &= dfs(i, call);
		}
		else
		{
			if (used[v] == used[i])
			{
				return false;
			}
		}
	}
	return f;
}


void solve()
{
	string a, b;
	int n, m;
	string t;
	cin >> a >> b >> n >> m >> t;
	if (a == t)
		n--;
	if (b == t)
		m--;
	cout << n << ' ' << m;
}


int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ioio;
	/*int n;
	cin >> n;
	for (int i = 0; i < n; ++i)*/
	{
		solve();
	}
}

Measured memory_bytes: 256
main = do
    putStrLn . show . solve =<< getLine

-- |
-- >>> solve "575"
-- 4
-- >>> solve "3600"
-- 13
-- >>> solve "999999999"
-- 26484

solve s = length . filter pred . concat $ candidates
  where
    prepend = concatMap (\x -> ['3':x, '5':x, '7':x])
    candidates = take (length s) $ iterate prepend ["3", "5", "7"]
    pred s'
        | (read s' :: Int) > (read s :: Int) = False
        | '3' `elem` s' && '5' `elem` s' && '7' `elem` s' = True
        | otherwise            = False


Measured memory_bytes: 1916
A, B, C, D = map(int, input().split())

"""
count = 0

for i in range(0,101):
    if A <= i and i < B and C <= i and i < D:
        count += 1

print(count)
"""

lower = max(A, C)
upper = min(B, D)

ans = max(0, upper - lower)

print(ans)

Measured memory_bytes: 2940
from operator import itemgetter

n,m = map(int,input().split())
a = [int(i) for i in input().split()]
w = []
x = 0
for i in range(m):
    b,c = map(int,input().split())
    w.append((b,c))
w = list(sorted(w,key=itemgetter(1)))
w.reverse()
for i in w:
    a += [i[1]] * i[0]
    x += b
    if x > n:
        break
a.sort()
a = a[len(a)-n:]
print(sum(a))


Measured memory_bytes: 44388
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	string s;
	cin >> s;
	int n = (int) s.size();
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] != s[i - 1]) ans++;
	}
	cout << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int N,L;
  cin>>N>>L;
  int data[N];
  int m=1000,sum=0;
  rep(i,N){
      data[i]=L+i;
      m=min(m,abs(data[i]));
      sum+=data[i];
  }
  bool exist=false;
  rep(i,N){
      if(m==data[i]){
          exist=true;
          break;
      }
  }
  int ans;
  if(exist==true){
      ans=sum-m;
  }
  else{
      ans=sum+m;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void)
{
    int y, m, d;
    char a;
    scanf("%d%c%d%c%d", &y, &a, &m, &a, &d);
    if (m <= 4)
    {
        printf("Heisei");
    }
    else
    {
        printf("TBD");
    }
    return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())

#塗れる最大数
#すなわち、（すべての白）ー（最短経路距離）
g = [input() for _ in range(h)]
from collections import *
d = [[-1]*w for _ in range(h)]
d[0][0] = 0

q = deque([(0, 0)])

while q:
    tx, ty = q.popleft()
    for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        nx, ny = tx + dx, ty + dy
        if 0 <= nx < h and 0 <= ny < w and g[nx][ny] == '.' and d[nx][ny] < 0:
            d[nx][ny] = d[tx][ty] + 1
            q.append((nx, ny))

if d[-1][-1] < 0:
    print(-1)
    exit()
else:
    print(sum([s.count('.') for s in g]) - d[-1][-1] - 1)

Measured memory_bytes: 68108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
	int n,i,j,win,len1,len2,sarchN,lenWin=-1,taroP=0,hanakoP=0;
	char taro[101],hanako[101];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%s %s",taro,hanako);
		len1=strlen(taro);
		len2=strlen(hanako);
		lenWin=-1;
		win=-1;
		
		//右:win=0 左:win=1
		if(len1>len2){
			sarchN=len1;
			lenWin=0;
		}
		else if(len1<len2){
			sarchN=len2;
			lenWin=1;
		}
		else{
			sarchN=len1;
			lenWin=-1;
		}
		
		for(j=0;j<sarchN;j++){
			if(taro[j]>hanako[j]){
				win=0;
				break;
			}
			else if(taro[j]<hanako[j]){
				win=1;
				break;
			}
			else win=-1;
		}
		
		/*printf("lenWin:%d,Win:%d(0:右,1:左)\nよって:\n",lenWin,win);
		if(win==0)puts("右");
		else if(win==1)puts("左");
		else if(lenWin==0) puts("右");
		else if(lenWin==1) puts("左");
		else puts("同");
		*/
		if(win==0)hanakoP+=3;
		else if(win==1)taroP+=3;
		else if(lenWin==0) hanakoP+=3;
		else if(lenWin==1) taroP+=3;
		else {
			taroP++;
			hanakoP++;
		}
	}
	//仕様と逆になってしまったので無理やり出力を逆にした
	printf("%d %d\n",hanakoP,taroP);

return 0;
}

Measured memory_bytes: 596
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;
static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s, t;
  cin >> s >> t;

  ll n = s.size();
  ll nt = t.size();

  map<char, vll> mp;
  rep(i, n) mp[s[i]].push_back(i);
  
  for(char c : t) if(!mp.count(c)) {
    puts("-1");
    return 0;
  }

  ll fmhk = 0;
  ll j = 0;
  ll i = 0;
  while(i < nt){
    char c = t[i];
    ll idx = Lower_bound(mp[c], j);
    if(idx == (ll)mp[c].size()) {
      fmhk += n;
      j = 0;
    } else {
      j = mp[c][idx] + 1;
      i++;
    }
  }
  fmhk += j;

  cout << fmhk << endl;

  return 0;
}


Measured memory_bytes: 4624
from heapq import heappop,heappush
from collections import defaultdict
x, y, z, K = map(int,input().split())
a = sorted(list(map(int, input().split())),reverse=True)
b = sorted(list(map(int, input().split())),reverse=True)
c = sorted(list(map(int, input().split())),reverse=True)
q =[]
ans = []
sc = defaultdict(bool)
heappush(q,(-a[0] - b[0] - c[0], 0, 0, 0))

while len(ans) < K:
    deli, i, j, k = heappop(q)
    print(-deli)
    ans.append(-deli)
    
    if i + 1 < x and not sc[(i + 1, j, k)]:
        heappush(q,(-a[i + 1] - b[j] - c[k], i + 1, j, k))
        sc[(i + 1, j, k)] = True
    
    if j + 1 < y and not sc[(i, j + 1, k)]:
        heappush(q,(-a[i] - b[j + 1] - c[k], i, j + 1, k))
        sc[(i, j + 1, k)] = True
    
    if k + 1 < z and not sc[(i, j, k + 1)]:
        heappush(q,(-a[i] - b[j] - c[k + 1], i, j, k + 1))
        sc[(i, j, k + 1)] = True

Measured memory_bytes: 5168
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int L[]=new int[N];
		int count=0;
		for(int i=0;i<N;i++){
			L[i]=sc.nextInt();
		}
		if(N==2){
			System.out.println(0);
			return;
		}
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				for(int k=j+1;k<N;k++){
					if(L[i]!=L[j]&&L[j]!=L[k]&&L[i]!=L[k]&&L[i]+L[j]>L[k]&&L[i]+L[k]>L[j]&&L[k]+L[j]>L[i])count++;
				}
			}
		}
		System.out.println(count);
	}
}

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(void){
  int N,M,K;
  cin >> N >> M >> K;
  
  vector<set<int>> exclusives(N);
  
  UnionFind uf(N);
  
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    --A;--B;
    uf.merge(A,B);
    exclusives[A].insert(B);
    exclusives[B].insert(A);
  }
  for(int i=0;i<K;i++){
    int C,D;
    cin >> C >> D;
    --C;--D;
    if(!uf.issame(C,D)){continue;}
    exclusives[C].insert(D);
    exclusives[D].insert(C);
  }
  
  for(int i=0;i<N;i++){
    int result = uf.size(i) - 1;
    if(exclusives[i].size()>0){
      result -= exclusives[i].size();
    }
    
    if(i>0){ cout << " ";}
    
    cout << result;
  }
  
  cout << endl;
}


Measured memory_bytes: 24704
// Problem : D - Banned K
// Contest : AtCoder - AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define plii pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) vlli a(n);FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int n;
	cin>>n;
	vlli arr(n);
	mlli u;
	FOR(i,n)rd(arr[i]),u[arr[i]]++;
	int ans=0;
	for(auto v:u){
		ans+=(v.se*(v.se-1))/2;
	}
	FOR(i,n){
		int val=arr[i];
		int temp=ans-((u[val]*(u[val]-1))/2)+((((u[val]-1)*(u[val]-2))/2));
		pp(temp);
	}	
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


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

namespace AtCoder.Contest.C
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			var a = cin.ArrayLong(n);
			var b = new long[n - 1];
			int ans = 0;
			int now = 0;
			for (int i = 1; i < n; i++)
			{
				b[i - 1] = a[i] - a[i - 1];
				if (a[i - 1] >= a[i])
				{
					now++;
					if (now > ans) ans = now;
				}
				else
				{
					now = 0;
				}
			}
			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 24156
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-4;
const int MAX=2e5+10;
const ll mod=1e9+7;
/***************************************  head  **********************************************/
int main()
{
	ll n,m,d;
	while(~scanf("%lld%lld%lld",&n,&m,&d))
	{
		double ans=1.0*(m-1)*(n-d)*2/n/n;
		if(d==0) ans/=2;
		printf("%.10f\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

struct IsPrime {
 public:
  explicit IsPrime(int max);
  bool operator()(int n);

 private:
  std::vector<bool> is_prime;
};

IsPrime::IsPrime(int max) : is_prime(max + 1, true) {
  is_prime[0] = false;
  is_prime[1] = false;
  for (auto i = 2; i <= std::sqrt(max); i++) {
    if (!is_prime[i]) {
      continue;
    }

    for (auto mult = 2 * i; mult <= max; mult += i) {
      is_prime[mult] = false;
    }
  }
}

bool IsPrime::operator()(int n) { return is_prime[n]; }

int CountPrime(IsPrime& is_prime, int upto) {
  int cnt = 0;
  for (int i = 2; i <= upto; i++) {
    if (is_prime(i)) {
      cnt++;
    }
  }
  return cnt;
}

int main(void) {
  std::vector<int> inputs;
  int n;
  while (std::cin >> n) {
    inputs.push_back(n);
  }

  int max = *std::max_element(inputs.begin(), inputs.end());
  IsPrime is_prime{max};

  for (auto n : inputs) {
    std::cout << CountPrime(is_prime, n) << '\n';
  }
  return 0;
}

Measured memory_bytes: 3148
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)


int Counts[5];
int main(int, char *[])
{
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        std::string s;
        cin >> s;
        switch(s.front())
        {
            case 'M': ++Counts[0];break;
            case 'A': ++Counts[1];break;
            case 'R': ++Counts[2];break;
            case 'C': ++Counts[3];break;
            case 'H': ++Counts[4];break;
            default:break;
        }
    }
    //5C3 = 5*4 / 2
    uint64_t Comb = 0;
    for(int i = 0; i <=2; ++i)
    {
        for(int j = i + 1; j <= 3; ++j)
        {
            for(int k = j+1; k <= 4; ++k)
            {
                uint64_t c = 1;
                c *= Counts[i];
                c *= Counts[j];
                c *= Counts[k];
                Comb += c;
            }
        }
    }

    cout << Comb << endl;

    return 0;
}


Measured memory_bytes: 256