akhauriyash/Code-Regression huggingface dataset:
using System;
class find{
    public static void Main(){
        String str = Console.ReadLine();
        String comp = Console.ReadLine();
        int ans = 0;
        bool flag;
        String l;
        comp com = new comp();
        while(!comp.Equals("END_OF_TEXT")){
            l = comp.ToLower();
            flag = true;
            String[] word = l.Split(' ');
            foreach(String s in word){
                if(s.Equals(str)){
                    ans++;
                }
            }
            comp = Console.ReadLine();
        }
        Console.WriteLine(ans);
    }
}

class comp{
    public int smaller(int n, int m){
        if(n >= m){
            return m;
        }
        else{
            return n;
        }
    }
}


Measured memory_bytes: 17840
n,k=map(int,input().split())
statas=input()
subs=[]
count=1
buf=statas[0]
for string in statas[1:]:
    if buf==string:
        count+=1
    else:
        subs.append(count)
        count=1
        buf=string
if (len(subs)+1)//2 <= k:
    print(n-1)
else:
    print(n-1-len(subs)+2*k)

Measured memory_bytes: 45552
import sys
from itertools import accumulate

N = [int(x) for x in sys.stdin.readline().split(' ')]
w_list = [int(x) for x in sys.stdin.readline().split(' ')]

s = sum(w_list)

min_s = s
for s1 in accumulate(w_list):
    s2 = s - s1
    tmp = abs(s1 - s2)
    if tmp < min_s:
        min_s = tmp
        
print(min_s)

Measured memory_bytes: 3064
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;
int main(){
  int o,a,sl,ss,ansl[82],anss[82];
  cin >> o;
  char n[100],n2[100],nl[82],ns[82],c[80];
  cin.getline(c,80); 
  for(int i=0;i<o;i++){
    cin.getline(n,100);
    cin.getline(n2,100);
    if(strlen(n)>80||strlen(n2)>80){
      cout << "overflow" << endl;
      continue;
    }
    a = 0;
    if( strlen(n)>strlen(n2) ){
      sl = strlen(n);     
      ss = strlen(n2);
      for(int i=sl-1;i>=0;i--){
	nl[a] = n[i];
	a++;
      }
      a = 0;
      for(int i=ss-1;i>=0;i--){
	ns[a] = n2[i];
	a++;
      }
    }
    else{
      sl = strlen(n2);
      ss = strlen(n);
      for(int i=sl-1;i>=0;i--){
	nl[a] = n2[i];
	a++;
      }
      a = 0;
      for(int i=ss-1;i>=0;i--){
	ns[a] = n[i];
	a++;
      }
    }
    for(int i=0;i<sl;i++) ansl[i] = nl[i]-'0';
    for(int i=0;i<ss;i++) anss[i] = ns[i]-'0';
    for(int i=0;i<ss;i++) ansl[i] += anss[i];
    for(int i=0;i<sl;i++){
      if(ansl[i]>=10){
	ansl[i] -= 10;
	if(i+1<sl) ansl[i+1] += 1;
	else{
	  ansl[i+1] = 1;
	  sl += 1;
	}
      }
    }
    if(sl>80) cout << "overflow";
    else  for(int i=sl-1;i>=0;i--) cout << ansl[i];
    cout << endl;
  }
  return 0;
}  

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int hi = 0;


		if (A <= B) {
			hi+=A;
		}
		else{
			hi+=B;
		}
		if (C <= D){
			hi+=C;
		}
		else{ 
			hi+=D;
		}

		System.out.println(hi);
	}

}


Measured memory_bytes: 35628
#include <iostream>

using namespace std;

int main() {
	
	int n;

	while (cin >> n && n != 0) {

		int grade[3];

		for (int i = 0; i < n; i++) {
			cin >> grade[0] >> grade[1] >> grade[2];

			if (grade[0] == 100 || grade[1] == 100 || grade[2] == 100)
				cout << "A\n";

			else if ((grade[0] + grade[1]) / 2 >= 90)
				cout << "A\n";

			else if ((grade[0] + grade[1] + grade[2]) / 3 >= 80)
				cout << "A\n";

			else if ((grade[0] + grade[1] + grade[2]) / 3 >= 70)
				cout << "B\n";

			else if ((grade[0] + grade[1] + grade[2]) / 3 >= 50 &&
				(grade[0] >= 80 || grade[1] >= 80))
				cout << "B\n";

			else
				cout << "C\n";
		}
	}

	return 0;

}







Measured memory_bytes: 3008
#include <iostream>
#include <algorithm>
using namespace std;
int h,w,a;
int c[10][10];
int ans;
int main(){
    cin>>h>>w;
    for(int i=0;i<10;i++)for(int j=0;j<10;j++)cin>>c[i][j];
    for(int k=0;k<10;k++)
        for(int i=0;i<10;i++)
            for(int j=0;j<10;j++)
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a;
            if(a!=-1)ans+=c[a][1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    ans = 1
    for i in range(1, N + 1):
        ans = ans * i % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8924
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  long long n,a,mod=1e9+7,A[101]={0},C[101]={0},G[101]={0},T[101]={0},AG[101]={0},AC[101]={0},GA[101]={0},AT[101]={0};
  cin>>n;
  A[1]=1,G[1]=1,C[1]=1,T[1]=1;
  for(int i=2;i<=n+1;i++){
    a=(A[i-1]+G[i-1]+C[i-1]+T[i-1])%mod;
    A[i]=a,G[i]=(a-AC[i-1]+mod)%mod,C[i]=(a-AG[i-1]-GA[i-1]-AG[i-2]*2-AT[i-2]+mod*10)%mod,T[i]=a;
    AG[i]=A[i-1],AC[i]=(A[i-1]-GA[i-1]+mod)%mod,GA[i]=G[i-1],AT[i]=A[i-1];
  }
  cout<<a;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 100020
int vis[N],a[N],s[N];
int main()
{
    int i,j,k,n,l,r;
    memset(vis,0,sizeof(vis));
    for(i=2;i<=100010;i++)
    {
        if(vis[i])
            continue;
        for(j=i+i;j<=100010;j=j+i)
            vis[j]=1;
    }
    memset(a,0,sizeof(a));
    for(i=2;i<=100000;i++)
    {
        if(i%2==1&&vis[i]==0&&vis[(i+1)/2]==0)
        {
            a[i]=1;
        }
    }
    s[0]=0;
    for(i=1;i<=100000;i++)
        s[i]=s[i-1]+a[i];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&l,&r);
        printf("%d\n",s[r]-s[l-1]);
    }
    return 0;
}


Measured memory_bytes: 1664
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

int32_t main()
{
    IOS
    

    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;++i)
    {
        int count=0,count1=0;
        for(int j=0;j<n;++j)
        {
            if(j==i)
                continue;
            if(a[j]<a[i] and j<i)
            {
                count++;
            }
            if(a[j]<a[i] and j>i)
                count1++;
        }
        //cout<<count<<" "<<count1<<endl;
        ans+=(k*count1)%mod+(((power(k,2)-k+mod)%mod*(power(2,mod1))%mod)%mod)*(count+count1);
        ans%=mod;
    }
    cout<<(ans+mod)%mod;

}

Measured memory_bytes: 256
a = int(input())
b = a % 10
if b == 0 :
    print("pon")
if b == 1 :
    print("pon")
if b == 2 :
    print("hon")
if b == 3 :
    print("bon")
if b == 4 :
    print("hon")
if b == 5 :
    print("hon")
if b == 6 :
    print("pon")
if b == 7 :
    print("hon")
if b == 8 :
    print("pon")
if b == 9 :
    print("hon")

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());

            Console.WriteLine(N % 500 <= A ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
/**
*    created: 23.05.2020 02:50:44
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int g;
    cin >> g;
    rep(i,n-1) {
        int a;
        cin >> a;
        g = __gcd(g,a);
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    long long int a,b;
    scanf("%lld %lld",&a,&b);
    long long int r=0,x=0,temp;
    x = a*b;
    if(a<b){
        temp = a;
        a = b;
        b = temp;
    }
    r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a%b;
    }
    printf("%lld\n",x/b);
    return 0;
}


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

typedef complex<double> P;

#define EPS (1e-10)

double dot(P a,P b){
	return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a,P b){
	return (a.real() * b.imag() - a.imag() * b.real());
}

double distance_ls_p(P a,P b,P c){
	if(dot(b-a,c-a) < EPS) return abs(c-a);
	if(dot(a-b,c-b) < EPS) return abs(c-b);
	return abs(cross(b-a,c-a)) / abs(b-a);
}

bool intersected(P a,P b,P o,double r){
	double ao = abs(a-o);
	double bo = abs(b-o);
	if( (ao<r && bo>r || ao>r && bo<r) ||
		  (ao>r && bo>r && distance_ls_p(a,b,o) <= r) )
		return true;

	return false;
}

int main(void){
	int n,m;

	while(cin>>n && n){
		P o[n];
		double r[n];

		for(int i=0;i<n;i++){
			cin>>o[i].real()>>o[i].imag()>>r[i];
		}

		cin>>m;
		while(m--){
			P taro,oni;
			cin>>taro.real()>>taro.imag()>>oni.real()>>oni.imag();

			bool flg = true;
			for(int i=0;i<n;i++){
				if(intersected(taro,oni,o[i],r[i])){
					flg = false;
					break;
				}
			}

			if(flg) cout<<"Danger\n";
			else cout<<"Safe\n";
		}
	}

	return 0;
}

Measured memory_bytes: 0
n,a,b = map(int, input().split())
# n = int(input())

def get_sum(i):
    sum = 0
    while i > 0:
        sum += (i%10)
        i = int(i/10)
    return sum

cnt = 0
for i in range(1,n+1):
    sum = get_sum(i)
    if sum >= a and sum <= b:
        cnt += i

print(cnt)

Measured memory_bytes: 3060
# 2019-08-27 22:59:05
H, W = list(map(int, input().split()))

S = []
for i in range(H):
    s = list(input())
    S.append(s)
f = "Yes"
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            r = 0
            if i != 0:
                if S[i - 1][j] == "#":
                    r += 1
            if j != 0:
                if S[i][j - 1] == "#":
                    r += 1
            if i + 1 != H:
                if S[i + 1][j] == "#":
                    r += 1
            if j + 1 != W:
                if S[i][j + 1] == "#":
                    r += 1
            if r == 0:
                f = "No"
                break
    if f == "No":
        break

print(f)

Measured memory_bytes: 3064
def main():
    inf = 10 ** 8 + 1
    N, M = map(int, input().split())

    dp = [inf] * (1 << N)
    dp[0] = 0

    for _ in range(M):
        price, _ = map(int, input().split())
        c = (int(x) - 1 for x in input().split())
        k = sum(1 << x for x in c)
        for bit in reversed(range(1 << N)):
            nbit = bit | k
            dp[nbit] = min(dp[nbit], dp[bit] + price)

    ans = dp[(1 << N) - 1]
    if ans == inf:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3188
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;


void main() {
    auto S = readln.chomp;
    auto T = readln.chomp;
    auto N = S.length.to!int;
    auto M = T.length.to!int;
    auto st = new SegmentTree(N);
    auto tt = new SegmentTree(M);
    foreach (i; 0..N) if (S[i] == 'A') st.add(i, 1);
    foreach (i; 0..M) if (T[i] == 'A') tt.add(i, 1);

    auto Q = readln.chomp.to!int;
    foreach (q; 0..Q) {
        auto s = readln.split.map!(to!int);
        auto a = s[0]-1;
        auto b = s[1]-1;
        auto c = s[2]-1;
        auto d = s[3]-1;
        auto n = b - a + 1;
        auto m = d - c + 1;
        auto sa = st.sum(a, b);
        auto sb = n - sa;
        auto ta = tt.sum(c, d);
        auto tb = m - ta;

        sa += sb * 2;
        ta += tb * 2;
        writeln((sa-ta)%3==0 ? "YES" : "NO");
    }
}


class SegmentTree {
    int[] table;
    int size;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new int[](size);
    }

    void add(int pos, int num) {
        return add(pos, num, 0, 0, size/2-1);
    }

    void add(int pos, int num, int i, int left, int right) {
        table[i] += num;
        if (left == right)
            return;
        auto mid = (left + right) / 2;
        if (pos <= mid)
            add(pos, num, i*2+1, left, mid);
        else
            add(pos, num, i*2+2, mid+1, right);
    }

    int sum(int pl, int pr) {
        return sum(pl, pr, 0, 0, size/2-1);
    }

    int sum(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return 0;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                sum(pl, pr, i*2+1, left, (left+right)/2) +
                sum(pl, pr, i*2+2, (left+right)/2+1, right);
    }
}


Measured memory_bytes: 5656
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)
from itertools import combinations_with_replacement

def main():
    N,M,Q = map(int,input().split())
    ABCD = [tuple(map(int,input().split())) for _ in range(Q)]
    
    ans = 0
    for cmb in combinations_with_replacement(range(M),N):
        score = 0
        for a,b,c,d in ABCD:
            if cmb[b - 1] - cmb[a - 1] == c:
                score += d
        ans = max(ans,score)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include <iostream>
using namespace std;
 
int main() {
int a,b ;
char c;
scanf("%d %c %d",&a,&c,&b) ;
if(c=='+' ) {
printf("%d\n",a+b) ;
} 
else{
printf("%d\n",a-b) ;
 
} 
 
}

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

const int mod = 1000000007;

int main(){
  ll x;
  cin >> x;
  ll tmp = 100;
  ll ans = 0;
  while (tmp < x){
    ll r = tmp / 100;
    if (r == 0) r = 1;
    tmp += r;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc127/tasks/abc127_c

#include <bits/stdc++.h>
using namespace std;

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

    // [l,r]
    // (1-indexed)
    int l = 1;
    int r = n;
    for (int i = 0; i < m; i++)
    {
        int l_, r_;
        cin >> l_ >> r_;
        l = max(l, l_);
        r = min(r, r_);
    }

    cout << max(0, r - l + 1) << endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	string rem;
	for (char c : s) {
		if (rem.empty() || rem.back() == c) {
			rem += c;
		} else {
			rem.pop_back();
		}
	}
	cout << s.size() - rem.size() << '\n';

	return 0;
}


Measured memory_bytes: 592
// https://atcoder.jp/contests/abc114/tasks/abc114_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int len = 0, cnt = 0, n;

void rege(string s) {
    // 3, 5, 7が含まれている
    if (s.find("3") != std::string::npos && s.find("5") != std::string::npos &&
        s.find("7") != std::string::npos && stoi(s) <= n) {
        cnt++;
    }
    if (s.size() < len) {
        rege(s + "3");
        rege(s + "5");
        rege(s + "7");
    }

    return;
}

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

    s = to_string(n);
    len = s.size();
    rege("");

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static Integer[] l;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        l=new Integer[n];
        for(int i=0;i<n;i++) {
            l[i]=sc.nextInt();
        }
        Arrays.sort(l,Comparator.reverseOrder());
        double max=Math.max(f(2,3,0,1), f(0,3,1,2));
        for(int i=2;i<n-1;i++) {
            max=Math.max(max, f(0,1,i,i+1));
        }
        System.out.printf("%5f",max);
    }
    static double f(int a,int b,int c,int d) {
        return (double)(l[a]+l[b])/(double)(l[c]-l[d]);
    }
}


Measured memory_bytes: 32612
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;

int main(){
    
    lli n,m;
    cin >> n>>m;
    vector < vector <lli> > dp(n+1,vector <lli> (m+1));
    for(int i =1;i<=n;i++){
        for(int j =1;j<=m;j++){
            char x;
            cin >> x;
            dp[i][j] = x =='.'?0:-1;
        }
    }
        dp[n][m]= 1;
        for(int i =n;i>=1;i--){
            for(int j = m ;j>=1;j--){
                if(dp[i][j]==-1)continue;
                if(j+1<=m && dp[i][j+1]!=-1)dp[i][j] =(dp[i][j]+dp[i][j+1])%mod;
                if(i+1<=n && dp[i+1][j]!=-1)dp[i][j] =(dp[i][j]+dp[i+1][j])%mod;
                dp[i][j]%=mod;
            }
        }
//        for(int i =1;i<=n;i++)
//        for(int j =1;j<=m;j++){
//            cout << dp[i][j] << " ";
//        }
//        }
//        cout << endl;
        cout << dp[1][1] << endl;


}


Measured memory_bytes: 8064
/*
AuThOr GaRyMr
技巧:
1.区别对待大数据&小数据！
2.Dp难推时算贡献！
3.long long (尤其乘法)！
4.long long INF 要大
5.Dp on trees: 换根法，每次清空当前的节点和换到的子节点
6.long double | 输出浮点数
7.注意特判!(prince and princess)
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,low=-1;
int li=-1,ri=INF,longest=-1;
mp a[100000+10];
set<int> s;
map<int,int> cnt;
int main(){
	scanf("%d",&n);
	rb(i,1,n) scanf("%d %d",&a[i].FIR,&a[i].SEC),li=max(li,a[i].FIR),ri=min(ri,a[i].SEC),longest=max(longest,a[i].SEC-a[i].FIR+1);
	int res=longest+max(0,ri-li+1);
	sort(a+1,a+1+n);
	rb(i,1,n) if(a[i].SEC!=ri){
		s.insert(a[i].SEC),cnt[a[i].SEC]++;
	}
	else{
		low=max(low,a[i].FIR);
	}
	rb(i,1,n){
		if(a[i].FIR==li||a[i].FIR>ri) break;
		cnt[a[i].SEC]--;
		if(!cnt[a[i].SEC]) s.erase(a[i].SEC);
		if(a[i].FIR>=low){
			if(*s.begin()-li+1>0){
				res=max(res,*s.begin()-li+1+ri-a[i].FIR+1);
			}
		}
	}
	cout<<res<<endl; 
	return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] -= (i+1);
  }

  sort(ALL(a));
  ll b = 0;
  if (n == 1) {
    b = a[0];
  } else if (n % 2 != 0) {
    b = a[n/2];
  } else {
    if (a[n/2 - 1] > 0) b = a[n/2 - 1];
    else if (a[n/2] < 0) b = a[n/2];
  }

  ll ans = 0;
  for (auto v : a) ans += abs(v - b);

  cout << ans << endl;

  return 0;
}


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

int n, k;
string p;
vector<pair<string, int>> restaurants;
map<pair<string, int>, int> num;

bool sortByLex(const pair<string, int> &a, const pair<string, int> &b) {
  for (int i = 0; i < min(a.first.size(), b.first.size()); i++) {
    if (a.first[i] < b.first[i])
      return true;
    if (a.first[i] > b.first[i])
      return false;
  }
  if (a.first.size() > b.first.size())
    return false;
  if (a.first.size() < b.first.size())
    return true;
  if (a.second < b.second)
    return false;
  if (a.second > b.second)
    return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p;
    cin >> k;
    restaurants.push_back(make_pair(p, k));
    num[make_pair(p, k)] = i + 1;
  }
  sort(restaurants.begin(), restaurants.end(), sortByLex);
  for (int i = 0; i < n; i++) {
    cout << num[restaurants[i]] << '\n';
  }
  cin >> n;
}

Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<string>
using namespace std;
int main(){
	string s;
	cin >> s;
	if (s == "SUN"){
		cout << 7 << endl;
	}
	else if (s == "MON"){
		cout << 6 << endl;
	}
	else if (s == "TUE"){
		cout << 5 << endl;
	}
	else if (s == "WED"){
		cout << 4 << endl;
	}
	else if (s == "THU"){
		cout << 3 << endl;
	}
	else if (s == "FRI"){
		cout << 2 << endl;
	}
	else if (s == "SAT"){
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
  var K int
  var X int
  
  fmt.Scan(&K)
  fmt.Scan(&X)
  
  for i := X - K + 1; i < X + K; i++{
    fmt.Print(i)
    if(i - 1 == X + K){
      break
    }else{
      fmt.Print(" ")
    }
  }
}
  

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  vector<string> word(n);
  map<string, int> mp;
  bool ok = true;
 
  REP(i,n){
    string  w;
    cin >> w;
    word[i] = w;
    mp[w]++;
    if(mp[w] == 2){
      ok = false;
    }
    if(i == 0) continue;
    if(*word[i-1].rbegin() != *word[i].begin()) ok = false;
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    string N;
    cin >> N;

    int r = 0;

    for (auto c : N)
        r = (r + c - '0') % 9;

    auto ans = (r == 0 ? "Yes" : "No");

    cout << ans << '\n';

    return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("2 4");
            WillReturn.Add("1 9");
            WillReturn.Add("1 8");
            WillReturn.Add("4 9");
            WillReturn.Add("3 12");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("334 1000");
            WillReturn.Add("334 1000");
            WillReturn.Add("334 1000");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("30");
            WillReturn.Add("384 8895");
            WillReturn.Add("1725 9791");
            WillReturn.Add("170 1024");
            WillReturn.Add("4 11105");
            WillReturn.Add("2 6");
            WillReturn.Add("578 1815");
            WillReturn.Add("702 3352");
            WillReturn.Add("143 5141");
            WillReturn.Add("1420 6980");
            WillReturn.Add("24 1602");
            WillReturn.Add("849 999");
            WillReturn.Add("76 7586");
            WillReturn.Add("85 5570");
            WillReturn.Add("444 4991");
            WillReturn.Add("719 11090");
            WillReturn.Add("470 10708");
            WillReturn.Add("1137 4547");
            WillReturn.Add("455 9003");
            WillReturn.Add("110 9901");
            WillReturn.Add("15 8578");
            WillReturn.Add("368 3692");
            WillReturn.Add("104 1286");
            WillReturn.Add("3 4");
            WillReturn.Add("366 12143");
            WillReturn.Add("7 6649");
            WillReturn.Add("610 2374");
            WillReturn.Add("152 7324");
            WillReturn.Add("4 7042");
            WillReturn.Add("292 11386");
            WillReturn.Add("334 5720");
            //Yes
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct TaskDef
    {
        internal int A;
        internal int B;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        var TaskList = new List<TaskDef>();
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            TaskDef WillAdd;
            WillAdd.A = wkArr[0];
            WillAdd.B = wkArr[1];
            TaskList.Add(WillAdd);
        }

        int CurrTime = 0;
        foreach (TaskDef EachTask in TaskList.OrderBy(pX => pX.B)) {
            CurrTime += EachTask.A;
            if (CurrTime > EachTask.B) {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 63672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

struct DisjointSet{
  vector<int> rank, p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    rep(i, size) makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }

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

  void unit(int x, int y){
    link(findSet(x), findSet(y));
  }

  void link(int x, int y){
    if(rank[x] > rank[y]) p[y] = x;
    else if(rank[x] < rank[y]) p[x] = y;
    else {p[x] = y; rank[y]++;}
  }

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

int main(){
  int n, q; cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  rep(i, q){
    int x, y;
    cin >> x >> y;
    x--, y--;
    if(!ds.same(x, y)) ds.unit(x, y);
  }
  rep(i, n) ds.findSet(i);

  vector<int> cnt(n, 0);
  rep(i, n){
    cnt[ds.p[i]]++;
  }
  sort(all(cnt));

  cout << cnt[n-1] << endl;

  return 0;
}



Measured memory_bytes: 5608
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = 300005;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
//    cin>>t; 
    while(t--)
    {
        int n; cin>>n;
        map<string, int> m;
        f0(i,n) 
        {
            string s; cin>>s; m[s]++;
        }
        cout << "AC x " << m["AC"] << "\n";
        cout << "WA x " << m["WA"] << "\n";
        cout << "TLE x " << m["TLE"] << "\n";
        cout << "RE x " << m["RE"] << "\n";
        
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{   
    int N;
    cin >> N;
    int A[N];
    REP(i,N) cin >> A[i];

    sort(A,A+N);
    ll ans = 0;
    REPD(i,1,N){
        //cout << A[N-i/2-1] << endl;
        ans += A[N-i/2-1];
    }
    fin(ans);
    return 0;
}

Measured memory_bytes: 3908
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,Q,A;
	while(cin>>N>>K>>Q) {
		VI p(N);
		REP(i, Q) {
			cin>>A;A--;
			p[A]++;
		}
		REP(i, N) cout<<YN(Q<K+p[i])<<endl;
	}
	
	return 0;
}


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

// one-based numbering
template<class T> struct Fenwick2D {
    vector<vector<T>> bit; int N, M;
    Fenwick2D(int n, int m) {
        N = n; M = m;
        bit.assign(n+1, vector<T>(m+1, 0));
    }
    void add(int a, int b, T w) {
        for (int x = a; x <= N; x += x & -x) {
            for (int y = b; y <= M; y += y & -y) {
                bit[x][y] = (bit[x][y] + w);
            }
        }
    }
    T sum(int a, int b) {
        if (!a || !b) return 0;
        T ret = 0;
        for (int x = a; x > 0; x -= x & -x) {
            for (int y = b; y > 0; y -= y & -y) {
                ret = (ret + bit[x][y]);
            }
        }
        return ret;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<long long> A(N), B(N, 0), C(N, 1), X(N, 0), Y(N, 0);
    for (int i = 0; i < N; i++) {
        string S; cin >> S;
        bool dot = false;
        long long cur = 0;
        for (auto &c: S) {
            if (c == '.') {
                dot = true;
                A[i] = cur; cur = 0;
            } else {
                if (dot) C[i] *= 10, X[i]--, Y[i]--;
                cur = cur * 10 + c - '0';
            }
        }
        if (dot) B[i] = cur;
        else A[i] = cur;
        A[i] = A[i] * C[i] + B[i];
        while (A[i] % 2 == 0) {
            A[i] /= 2, X[i]++;
        }
        while (A[i] % 5 == 0) {
            A[i] /= 5, Y[i]++;
        }
    }
    int offset = 100;
    Fenwick2D<int> f(300, 300);
    long long Ans = 0;
    for (int i = 0; i < N; i++) {
        long long curr = i;
        curr -= f.sum(-X[i]+offset-1, 300);
        curr -= f.sum(300, -Y[i]+offset-1);
        curr += f.sum(-X[i]+offset-1, -Y[i]+offset-1);
        Ans += curr;
        f.add(X[i]+offset, Y[i]+offset, 1);
    }
    cout << Ans << "\n";
    return 0;
}

Measured memory_bytes: 11388
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] s = stdIn.nextLine().split(" ");
		char[] headChars = {s[0].charAt(0), s[1].charAt(0), s[2].charAt(0)};
		String head = new String(headChars);
		System.out.println(head.toUpperCase());

	}

}


Measured memory_bytes: 23892
import java.util.*;
public class Main{
    
    public static void main(String[] args){
        int N;
        Scanner Sc = new Scanner(System.in);
        N = Sc.nextInt();
        int t = N, c = 0;
        while(t > 0){
            c+= t % 10;
            t/= 10;
        }
            if(N % c == 0){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
    }
}


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

int main(){
  int64_t a,b,c;
  cin>>a>>b>>c;
  if(c<=a+b) cout<<"No"<<endl;
  else{
    if((c-a-b)*(c-a-b)-4*a*b>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::io;

fn whitespace_single() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    buf
}

fn main() {
    let mut s = whitespace_single();
    let mut flg: bool = false;
    let mut old: char = ' ';
    for i in s.as_str().chars() {
        if(i == old){
            flg = true;
        }
        old = i;
    }
    let res = if(flg) {
        "Bad"
    }else {
        "Good"
    };
    println!("{}", res);
}

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    if (X == 1 || X == 2 * N - 1) {
        puts("No");
        return 0;
    }

    deque<int> ans;
    ans.push_back(X);

    vector<bool> used(2*N);
    used[X] = true;
    bool flg = true;
    rep(i, N) {
        if (flg) {
            if (!used[i+1])     ans.push_front(i+1);
            used[i+1] = true;
            if (!used[2*N-1-i]) ans.push_back(2*N-1-i);
            used[2*N-1-i] = true;
        } else {
            if (!used[2*N-1-i]) ans.push_front(2*N-1-i);
            used[2*N-1-i] = true;
            if (!used[i+1])     ans.push_back(i+1);
            used[i+1] = true;
        }
        flg = 1 - flg;
    }

    puts("Yes");
    for (auto &i : ans) cout << i << endl;
}

Measured memory_bytes: 2304
import java.util.*;


class Com implements Comparator<Point>{
    public int compare(Point a,Point b){
        int c = a.c.compareTo(b.c);
        if (c==0){
            return b.p-a.p;
        }
        return c;
    }
}
class Point{
    String c;
    int p;
    int in;
    Point(String a,int b,int d){
        c = a;
        p = b;
        in = d;
    }
}
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        TreeSet<Point> list = new TreeSet<>(new Com());
        for (int i=0;i<N;i++){
            String name = scan.next();
            int point = scan.nextInt();
            list.add(new Point(name,point,i+1));
        }
        Object[] arr = list.toArray();
        for (int i=0;i<arr.length;i++){
            Point as = (Point)arr[i];
            System.out.println(as.in);
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

double dp[310][310][310];

double go(int a,int b,int c,int &n){
	if(dp[a][b][c]>=0) return dp[a][b][c];
	if(a==0 && b==0 && c==0) return 0;
	
	double sm=a+b+c;
	dp[a][b][c]=n;
	if(a>0) dp[a][b][c]+=go(a-1,b,c,n)*a;
	if(b>0) dp[a][b][c]+=go(a+1,b-1,c,n)*b;
	if(c>0) dp[a][b][c]+=go(a,b+1,c-1,n)*c;
	dp[a][b][c]/=sm;
	return dp[a][b][c];
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	memset(dp,-1,sizeof(dp));
	int n; cin>>n;
	int a=0,b=0,c=0,t;
	For(i,0,n-1){
		cin>>t;
		if(t==1) a++;
		else if(t==2) b++;
		else c++;
	}
	cout<<fixed<<setprecision(15);
	cout<<go(a,b,c,n)<<"\n";
	return 0;
}


























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

int main(){
  int N;
  cin >>N;
  int ma=0,mi=10000;
  for(int i=0;i<N;i++){
    int a;
    cin >>a;
    ma =max(ma,a);
    mi =min(mi,a);
  }
  cout << ma-mi << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

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

	for(int i = 0; i < N.length(); ++i){
		if(N[i] == '9'){
			std::cout << "Yes" << endl;
			return 0;
		}
	}
	std::cout << "No" << endl;
	return 0;
}


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

int main(){
	int N, A, B, C, D, x, y, i = 1, ans;
	cin>>N>>A>>B>>C>>D;
	
	while(1){
		if(A * i >= N) {
			x = B * i;
			break;
		}
		i++;
	}
	i = 1;
	while(1){
		if(C * i >= N) {
			y = D * i;
			break;
		}
		i++;
	}
	if(x > y) ans = y;
	else ans = x;
	
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String stra = scan.nextLine();
    String strb = scan.nextLine();
    char chara,charb;
    int ans = 0;

    for (var i = 0; i < stra.length(); i++) {
      chara = stra.charAt(i);
      charb = strb.charAt(i);
      if (chara != charb) {
        ans++;
      }
    }

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

Measured memory_bytes: 42880
#include <bits/stdc++.h>
#define INF 2e9
#define int ll
#define vi          vector<int>
#define de          deque<int>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()//全範囲指定を簡略化
typedef long long ll;
using namespace std;
//配列の要素数は　sizeof(ar)/sizeof(ar[0]) で求める
signed main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int H;
    cin >> H;
    int ans = 0, i = 0;
    while (H != 0){
        H /= 2;
        ans += pow(2,i);
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

keta_count = [0] * 65
first_appear = [0] * 65

for a in A:
    i = 0
    while a:
        keta_count[i] += a % 2
        a //= 2
        i += 1

for a in A:
    i = 0
    
    while (a & (1<<(i+1) -1)) != 1<<i:
        i += 1
    first_appear[i] += 1


# print(keta_count)
# print(first_appear)

ans = 0
for i in range(64, -1, -1):
    if keta_count[i] % 2 != 0:

        if first_appear[i] > 0:
            first_appear[i] -= 1
            keta_count[i] -= 1
            ans += 1
            for i in range(0,i):
                keta_count[i] += 1
            # first_appear[0] += 1
        else:
            print(-1)
            exit()

if keta_count[0] % 2 != 0:
    print(-1)
else:
    print(ans)

# print(keta_count)
# print(first_appear)


Measured memory_bytes: 50416
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define be(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

int main()
{
    int m,n1,n2;
    while(cin>>m>>n1>>n2)
    {
        if(m==0)return 0;
        vector<pair<int,int> >pp(m-1);
        //vector<int>p(m);
        int now,fo;
        cin>>now;
        REP(i,m-1)
        {
            fo=now;
            cin>>now;
            pp.push_back(make_pair(fo-now,i+1));
        }
        sort(pp.begin(),pp.end());
        reverse(pp.begin(),pp.end());
        //bool flag=0;
        REP(i,m-1)
        {
            if(pp.at(i).second>=n1&&pp.at(i).second<=n2)
            {
                cout<<pp.at(i).second<<endl;
                //flag=1;
                break;
            }
        }
    }
}


Measured memory_bytes: 3072
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Integer> numbers = new TreeMap<>();
        int maxTimes = 0;
        for (int i = 0; i < n; ++i) {
            final String s = scanner.next();
            int current = numbers.getOrDefault(s, 0);
            numbers.put(s, current + 1);
            maxTimes = Math.max(current + 1, maxTimes);
        }
        final int max = maxTimes;
        numbers.entrySet()
                .stream()
                .filter(numberTimes -> numberTimes.getValue() == max)
                .forEach(
                        numberTimes -> {
                            System.out.println(numberTimes.getKey());
                        }
                );
    }
}


Measured memory_bytes: 86364
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if( abs(a-c) <= d or ( abs (a-b) <= d and abs(b-c) <= d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){


int N,M;
cin>>N>>M;
vector<int>x;
int t;
rep(i,M){
cin>>t;
x.push_back(t);
}
sort(x.begin(),x.end());

vector<int>d;
rep(i,M-1){
d.push_back(x[i+1]-x[i]);
}
sort(d.begin(),d.end());

int Ans=0;
if(M<=N);
else{
    rep(i,M-N){
    Ans+=d[i];

    }
}
cout <<Ans <<endl;
 return 0;
}

Measured memory_bytes: 1400