akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int[] ans = new int[N];
        for (int i = 0; i < N-1; i++){
            int index = input.nextInt();
            ans[index-1] += 1;
        }
        for (int i = 0; i < N; i++){
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 60636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    ll ans=0;
    while(true){
        bool updated=false;
        rep(i,N){
            ll cnt=a[i]/N;
            if (cnt) updated=true;
            ans+=cnt;
            a[i]%=N;
            rep(j,N) if (j!=i) a[j]+=cnt;
        }
        if (!updated) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import collections

N=int(input())
D=list(map(int,input().split()))
mod=998244353
data=collections.Counter(D)

if D[0]==0 and data[0]==1:
    count=1
    for i in range(1,len(data)):
        count*=data[i-1]**data[i]
        count%=mod
    print(count)
else:
    print(0)


Measured memory_bytes: 19936
package main

import (
	"fmt"
	"os"
	"strconv"
	"strings"
	"bufio"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	buf = make([]byte, 1000)
)

func scanText() string{
	sc.Scan()
	return sc.Text()
}

func scanTextArray(n int) []string {
	out := make([]string, n)
	for i, v := range(strings.Split(scanText(), "")) {
		out[i] = v
	}
	return out
}

func scanInt() int {
	out, e := strconv.Atoi(scanText())
	if e != nil {
        panic(e)
    }
	return out
}

func scanIntArray(n int) []int {
	out := make([]int, n)
	for i, v := range(strings.Split(scanText(), " ")) {
		num, e := strconv.Atoi(v)
		if e != nil {
			panic(e)
		}
		out[i] = num
	}
	return out
}
//  template end

var (
	root_map = make([][]string, 0)
	dist_map = make([][]int, 0)
	H, W, ans = 0, 0, 0
	queue = make([][]int, 0)
)

func f(x, y, dist int) {
	if x<0 || x>W-1 || y<0 || y>H-1 {
		return
	} else if root_map[y][x] == "#" && dist_map[y][x] == 0{
		dist_map[y][x] = -1
	} else if x==W-1 && y==H-1 && dist_map[y][x] == 0 {
		ans -= dist
		dist_map[y][x] = dist
	} else if dist_map[y][x] == 0 {
		dist_map[y][x] = dist
		queue = append(queue, []int{x+1, y, dist+1})
		queue = append(queue, []int{x, y+1, dist+1})
		queue = append(queue, []int{x, y-1, dist+1})
		queue = append(queue, []int{x-1, y, dist+1})
	}
}

func main() {
	sc.Buffer(buf, 10000)
	hw := scanIntArray(2)
	H, W = hw[0], hw[1]
	ans = H*W
	root_map = make([][]string, H)
	dist_map = make([][]int, H)
	for i:=0; i<H; i++ {
		root_map[i] = scanTextArray(W)
		dist_map[i] = make([]int, W)
	}
	queue = append(queue, []int{0,0,1})
	for {
		if len(queue) == 0 {
			break
		}
		xyz := queue[0]
		queue = queue[1:]
		f(xyz[0], xyz[1], xyz[2])
	}
	for i:=0; i<H; i++ {
		for j:=0; j<W; j++ {
			if root_map[i][j] == "#" {
				ans--
			}
		}
	}
	if dist_map[H-1][W-1] == 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> data(5);
  for (int i = 0; i < 5; i++) {
  cin >> data.at(i);
 }
   sort(data.begin(), data.end());
   int k;
   cin >> k;
   if(k < data.at(4) - data.at(0))
   cout << ":(" << endl;
   else
   cout << "Yay!" << endl;
  } 
   

  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>

#define INF 9

typedef std::pair<int,int> pair;

int h,w,n;
std::vector<std::vector<char> >data;
std::vector<std::vector<int> >cost;

int dfs(int sx,int sy,int gx,int gy){
	for(unsigned int i=0;i<cost.size();i++){
		for(unsigned int j=0;j<cost[i].size();j++){
			cost[i][j]=INF;
		}
	}
	int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
	std::queue<pair>q;
	cost[sy][sx]=0;
	q.push(pair(sx,sy));

	while(q.size()){
		int x=q.front().first,y=q.front().second;
		if(x==gx&&y==gy)return cost[y][x];
		q.pop();
		for(int i=0;i<4;i++){
			if(x+dx[i]>=0&&x+dx[i]<=w-1&&y+dy[i]>=0&&y+dy[i]<=h-1){
				if(data[y+dy[i]][x+dx[i]]!='X'&&cost[y+dy[i]][x+dx[i]]==INF){
					cost[y+dy[i]][x+dx[i]]=cost[y][x]+1;
					q.push(pair(x+dx[i],y+dy[i]));
				}
			}
		}
	}
	return 0;
}

int main(){
	int sx,sy,ans=0;
	pair g[10];
	std::cin>>h>>w>>n;
	for(int i=0;i<h;i++){
		data.push_back(std::vector<char>());
		cost.push_back(std::vector<int>());
		for(int j=0;j<w;j++){
			char a;
			std::cin>>a;
			data[i].push_back(a);
			cost[i].push_back(INF);
			if(a=='S')sx=j,sy=i;
			if(a!='S'&&a!='X'&&a!='.')g[a-'0']=pair(j,i);
		}
	}

	for(int i=1;i<=n;i++){
		ans+=dfs(sx,sy,g[i].first,g[i].second);
		sx=g[i].first,sy=g[i].second;
	}

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 6288
#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;


const int SZ = 5003;
int N;
ll A[SZ];
vector<int> adj[SZ];
vector<int> children[SZ];
int tsz[SZ];

void readInput() {
	//freopen("input.txt", "r", stdin);
	cin >> N;
	for (int i=1; i<=N; i++) cin >> A[i];
	for (int z=0; z<N-1; z++) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

void dfs(int p, int u) {
	tsz[u] += 1;
	for (int v : adj[u]) if (v != p) {
		dfs(u, v);
		children[u].push_back(v);
		tsz[u] += tsz[v];
	}
}


ll D[SZ][SZ];
bool E[SZ][SZ];
void solve(int u) {
	D[u][0] = A[u];
	E[u][0] = A[u] > 0;
	if (children[u].empty()) return;
	for (int v : children[u]) solve(v);

	int sz = 1;
	for (int v : children[u]) {
		static ll DD[SZ];
		static bool EE[SZ];
		memset(DD, 1, sizeof(DD));
		memset(EE, 0, sizeof(EE));

		for (int a=0; a<sz; a++) for (int b=0; b<tsz[v]; b++) {
			DD[a+b] = min(DD[a+b], D[u][a]+D[v][b]);
			if (D[v][b]<0 || E[v][b]) DD[a+b+1] = min(DD[a+b+1], D[u][a]);
		}
		if (A[u]>0) for (int a=0; a<sz; a++) for (int b=0; b<tsz[v]; b++) {
			if (A[v]>0) EE[a+b] = EE[a+b] || (E[u][a] && E[v][b]);
			if (D[v][b]<0 || E[v][b]) EE[a+b+1] = EE[a+b+1] || E[u][a];
		}

		sz += tsz[v];
		memcpy(D[u], DD, sizeof(D[u]));
		memcpy(E[u], EE, sizeof(E[u]));
	}

	/*
	printf("[debug]\n");
	for (int k=0; k<sz; k++) cout << D[u][k] << " ";
	cout << endl;
	for (int k=0; k<sz; k++) cout << P[u][k] << " ";
	cout << endl;
	cout << endl;
	*/
}



int main() {
	readInput();
	dfs(-123, 1);
	solve(1);

	int ans = 1e9;
	for (int k=0; k<N; k++) {
		if (D[1][k] < 0) ans = min(ans, k);
		if (E[1][k]) ans = min(ans, k);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 221312
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF = (1LL<<60)-1;
const int maxN = 1000001;
int32_t main(){
    SPEED;
    int a, b;
    cin >> a >> b;
    int ans = 0,curr = 1;
    while(1){
        if(curr >= b) break;
        ans++;
        curr--;
        curr += a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
from math import *
a, b, h, m = map(int, input().split())
t = h*60+m
a1 = 2*pi*t/(12*60)
a2 = 2*pi*m/60
x1, y1 = a*cos(a1), a*sin(a1)
x2, y2 = b*cos(a2), b*sin(a2)
res = ((x1-x2)**2+(y1-y2)**2)**0.5
print("%.12f" % res)

Measured memory_bytes: 62704
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n = readInt()
p = readInts()

minV = p[0]
ans = 1

for i in range(1,n):
	if minV >= p[i]:
		minV = p[i]
		ans+=1

print(ans)

Measured memory_bytes: 25844
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 1; i <= n; i++) {
            if (a[i - 1] <= a[i]) {
                ans += a[i - 1];
                a[i] -= a[i - 1];
            } else if (a[i] == 0) {
                ans += a[i - 1] / 2;
            } else {
                ans += (a[i - 1] + 1) / 2;
                a[i] -= a[i - 1] % 2;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50696
<?php
  $n = trim(fgets(STDIN));
  $t=[0]; 
  $x=[0]; 
  $y=[0];
  for($i=0; $i<$n; $i++){
      fscanf(STDIN,"%d%d%d", $t[],$x[],$y[]);
  }
  
  for($i=1; $i<=$n; $i++){
      $t_diff = $t[$i]-$t[$i-1];
      $x_diff = abs($x[$i]-$x[$i-1]);
      $y_diff = abs($y[$i]-$y[$i-1]);
      $xy_diff = $x_diff+$y_diff;
      if($t_diff < $xy_diff || $t_diff%2 != $xy_diff%2){
          echo "No";
          exit;
      }
  }
  echo "Yes";

Measured memory_bytes: 22128
n,x = map(int,input().split())
preA = list(map(int,input().split()))
A = sorted(preA)
ans = 0 if sum(A) >= x else -1
sm = 0
for a in A:
    sm += a
    if sm <= x:
        ans += 1
    elif sm == ans:
        ans += 15
        break
    else:
        break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int main(){
  	int N, x;
    cin >> N;
    cin >> x;
    
  	int a[N] = {};
    for (int i = 0; i < N; i++){
      cin >> a[i];
    }
  
  	long long count = 0;
    for (int i = 0; i < N-1; i++){
      int sum = a[i] + a[i+1];
      if (sum > x){
        int diff = sum - x;
        if (diff <= a[i+1]){
          count += diff;
          a[i+1] -= diff;
        }
        else{
          a[i] -= diff - a[i+1];
          a[i+1] = 0;
          count += diff;
        }
      }
    }
    
    cout << count << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s.size()==2){
        if(s[0] == s[1]){
            cout<<"1 2"<<endl;
            return 0;
        }
        cout<<"-1 -1"<<endl;
        return 0;
    }
    for(int i=0;i<s.size()-2;i++){
        if(s[i]==s[i+1]||s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<"-1 -1"<<endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())
z100 = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1,n+1):
  h = int(str(i)[0])
  t = int(str(i)[-1])
  z100[h][t] += 1
ans = 0
for h in range(10):
  for t in range(10):
    ans += z100[h][t] * z100[t][h]
print(ans)

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

int pow10(int n)
{
	if (n == 0)
	{
		return 1;
	}

	int ans = 1;
	for (int i = 0; i < n; ++i)
	{
		ans *= 10;
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	int temp = N;
	int keta = 0;
	while(temp != 0)
	{
		temp /= 10;
		keta++;
	}

	//cout << keta << endl;
	//cout << pow10(keta) << endl;

	int ans = 0;

	if (keta % 2 == 0)
	{
		keta -= 1;

		while(keta > 0)
		{
			ans += pow10(keta-1) * 9;
			keta -= 2;
		}
	}
	else
	{
		ans += N - (pow10(keta-1) - 1);
		keta -= 2;
		while(keta > 0)
		{
			ans += pow10(keta-1) * 9;
			keta -= 2;
		}
	}

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

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

int main() {
  int N,X;
  cin>>N>>X;
  vector<int> xs(N),ds(N);
  for(int i=0;i<N;i++){cin>>xs.at(i);}
  xs.push_back(X);
  sort(xs.begin(),xs.end());
  for(int i=0;i<N;i++){ds.at(i)=xs.at(i+1)-xs.at(i);}
  int gcd=ds.at(0);
  for(int i=1;i<ds.size();i++){gcd=__gcd(gcd,ds.at(i));}
  cout<<gcd<<endl;
}

Measured memory_bytes: 1536
w=["AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","KIHBARA", "KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR","KIHBRA","KIHBAR","KIHABR","AKIHBR" ,"KIHBR"]
s=input()
ans=0
if s in w: ans=1
print(["NO","YES"][ans])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
 using namespace std;
 
 #define REP(i, a, n) for(int i=a; i<n; i++)
 #define sortv(v) sort(v.begin(), v.end());
 #define sortg(v) sort(v.begin(), v.end(), greater<>());
 int main() {
   int n;
   cin >> n;
   vector<int> v(n), c(n);
   REP(i, 0, n) cin >> v[i];
   REP(i, 0, n) cin >> c[i];
   int z=0;
   REP(i, 0, n){
     if(v[i]-c[i]>0){
       z+=v[i]-c[i];
     }
   }
   cout << z << endl;
 }
 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a, b; cin >> a >> b;
    if(a==b) cout << 'H';
    else cout << 'D';
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;
using ll = long long;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int n; cin >>n;
  vector<int> l(n);
  for(int i=0; i<n; ++i) cin >> l[i];

  int cnt = 0;

  for(int i=0;  i<n; ++i){
    for(int j=0; j<i; ++j){
      for(int k=0; k<j; ++k){
        int a = l[i];
        int b = l[j];
        int c = l[k];
        if(a != b && b != c && a != c){
          if(a+b>c && a+c>b && b+c>a) cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

int main() {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    ll dx12 = x2 - x1, dy12 = y2 - y1;
    ll x3, y3, x4, y4;
    if(abs(dx12) <= abs(dy12)) {
        x3 = x2 - dy12;
        y3 = y2 + dx12; 
    } else {
        x3 = x2 - dy12;
        y3 = y2 + dx12;
    }
    x4 = x3 - dx12;
    y4 = y3 - dy12;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

Measured memory_bytes: 3536
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<List<Integer>> ptnList = new ArrayList<>();

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();
		sc.close();

		int t = a1 + a2 + a3;

		if(t >= 22) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}

	}

}


Measured memory_bytes: 21844
#include<stdio.h>
#define TableSize 3 //おまけでテーブルの可変化を実装

int main() {
	//変数宣言。tblでマップフィールドを表現
	int i, j;
	int tbl[TableSize][TableSize];

	//データ入力受付
	for (i = 0; i < TableSize; i++) {
		for (j = 0; j < TableSize; j++) {
			scanf("%d", &tbl[i][j]);
		}
	}

	//一致の条件は(a(i)+b(j))-(a(i+1)+b(j))と
	//(a(i)+b(j+1))-(a(i+1)+b(j+1))を比較すれば求められるから以下の通りになる
	for (i = 0; i < TableSize - 1; i++) {
		for (j = 0; j < TableSize - 1; j++) {
			//条件を満たせなければ失敗とみなして終了する
			if (tbl[i][j] - tbl[i + 1][j] != tbl[i][j + 1] - tbl[i + 1][j + 1]) {
				printf("No\n");
				return 0;
			}
		}
	}

	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var arg   = input.split("\n");
  var line0 = arg[0].split(" ");
  var line1 = arg[1].split(" ");
  var line2 = arg[2].split(" ");
  var line3 = arg[3].split(" ");

  var input1 = Number(line0[0]);
  var input2 = Number(line1[0]);
  var input3 = Number(line2[0]);
  var input4 = Number(line3[0]);
//  var a = input2;
  //var b = input3;

  var ans = "initial_answer";
  //console.log( "[INPUT] "+ input1 +" "+ input2 +" "+ input3 + " " + input4 );
  
  // LOGIC //

  if(input1 < input2) console.log( input3 * input1);
  else console.log( input3 * input2 + ((input1 - input2) * input4) );


  


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7752
n,W = map(int,input().split())
w,v = [0]*n, [0]*n
for i in range(n):
    w[i], v[i] = map(int,input().split())

dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j-w[i]>=0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(dp[n][W])

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

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

const int INF = 1000000007;

int main(void){
	int a,b,c;
	cin>>a>>b>>c;
	bool can = false;

	for(int i=1;i<=b;i++){
		if((a*i) % b == c){
			printf("YES\n");
			can = true;
			break;
		}
	}

	if(!can) printf("NO\n");

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scantString() string { scanner.Scan(); return scanner.Text() }
func scanInt() int {i, _ := strconv.Atoi(scantString()); return i }
func scanFloat64() float64 {f, _ := strconv.ParseFloat(scantString(), 64); return f}

func countDiv(n int, x int, limit int) int {
	if n%x != 0 {
		return 0
	}
	res := 0
	for n%x == 0 && res < limit {
		n /= x
		res++
	}
	return res
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	ans := 0
	n := scanInt()

	var counts [19][19]int
	// O(n)
	for i := 0; i < n; i++ {
		Ai := int(math.Round(scanFloat64() * math.Pow10(9)))
		count2 := countDiv(Ai, 2, 18)
		count5 := countDiv(Ai, 5, 18)
		counts[count2][count5]++
	}

	//O(19**4)
	for j := 0; j < 19; j++ {
		for k := 0; k < 19; k++ {
			if counts[j][k] == 0 {
				continue
			}

			for m := Max(18-j, j); m < 19; m++ {
				var n int
				if m == j {
					n = Max(18-k, k)
				} else {
					n = 18 - k
				}
				for ; n < 19; n++ {
					a := counts[j][k]
					b := counts[m][n]
					if a == 0 || b == 0 {
						continue
					}
					if j == m && k == n {
						ans += a * (a - 1) / 2
					} else {
						ans += a * b
					}
				}
			}
		}
	}

	_, _ = fmt.Fprintln(writer, ans)
	_ = writer.Flush()

}


Measured memory_bytes: 5056
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    string S;
    cin >> S;
    int minDiff = 10000;
    for (int i = 0; i < S.size() - 2; i++) {
        string subS;
        subS = S.substr(i, 3);
        int diff = abs(753 - stoi(subS));
        minDiff = min(minDiff, diff);
    }

    cout << minDiff << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";

int main(){

    int size=0, x=0, i=0;
    char s[100005];
    cin >> s;

    for(i=0; i<100005 && s[i+1] != '\0'; i++){
        if(s[i] == s[i+1]){
            if(s[i+1] == '0') s[i+1] = '1';
            else s[i+1] = '0';
            x++;
            // W(i+1);
        }
    }

    cout << x << endl;
    return 0;
}

Measured memory_bytes: 384
/* kadai4_2
   nabe9393 */

#include<stdio.h>
#include<math.h>

int main(void){
  //短針、長針、時、分、針の角度、答え
  double short_hand, long_hand, hour, minute, angle, answer;
  scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &minute);
  //M_PIは元から定義されている
  //短針は1時間で３０度進み、1分で0.5度進む。
  //長針は1分で６度進む。
  angle = M_PI * (hour * 30.0 + minute / 2.0 - minute * 6.0) / 180.0 ;
  //cos(θ)=-cos(θ)より、角度の正負は考えない。
  //余弦定理を利用。
  answer = sqrt( pow(long_hand, 2) + pow(short_hand, 2) - 2 * long_hand * short_hand * cos(angle));
  printf("%.10lf\n", answer);
  return 0;
}


Measured memory_bytes: 2544
#include <iostream>
#include <string>

static const std::string pattern[4] = { "dream", "dreamer", "erase", "eraser" };
bool can_made_from_pattern(const std::string &str, int left) {
	if (left == 0) return true;
	else {
		for (const auto p : pattern) {
			if (p.size() <= left) {
				if (str.substr(left - p.size(), p.size()) == p) {
					return can_made_from_pattern(str, left - p.size());
				}
			}
		}
		return false;
	}
}int main() {
	std::string str;
	std::cin >> str;
	if (can_made_from_pattern(str, str.size())) {
		std::cout << "YES\n";
	}
	else {
		std::cout << "NO\n";
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define reps(i, s, n) for(int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;

int main() {
    long long N;
    in(N)
    N--;
    long long d;
    int i;
    for(i = 1; ; i++) {
        d = std::pow(26, i);
        if(N - d >= 0) 
            N -= d;
        else
            break;
        
    }
    std::string ans = "";
    int k = i - 1;
    for(int j = 0; j <= k; j++) {
        d = std::pow(26, i - 1);
        ans += (N / d) + 'a';
        N = N % d;
        i--;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 3544
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]
# L = [int(input()) for _ in range(Q)]
# S = input().strip()

su = abs(L[0])
a = [0] * N
for i in range(1, N):
    t = 0
    if L[i - 1] * L[i] < 0:
        t = abs(L[i - 1]) + abs(L[i])
    else:
        t = abs(L[i - 1] - L[i])
    su += t
    a[i] = t
su += abs(L[-1])

if L[0] * L[1] <= 0:
    print(su - abs(L[0]) * 2)
else:
    if L[0] < 0:
        if L[0] > L[1]:
            print(su)
        else:
            print(su - a[1] * 2)
    else:
        if L[0] < L[1]:
            print(su)
        else:
            print(su - a[1] * 2)

for i in range(1, N - 1):
    c = a[i] + a[i + 1]

    t = 0
    if L[i - 1] * L[i + 1] < 0:
        t = abs(L[i - 1]) + abs(L[i + 1])
    else:
        t = abs(L[i - 1] - L[i + 1])

    print(su - c + t)

if L[-2] * L[-1] <= 0:
    print(su - abs(L[-1]) * 2)
else:
    if L[-1] < 0:
        if L[-1] > L[-2]:
            print(su)
        else:
            print(su - a[-1] * 2)
    else:
        if L[-1] < L[-2]:
            print(su)
        else:
            print(su - a[-1] * 2)

Measured memory_bytes: 13540
#include<bits/stdc++.h>
    #define F first
    #define S second
    #define int long long
    #define double long double
    using namespace std;
    typedef pair<int,int> P;
    typedef pair<int,P> iP;
    typedef pair<P,int> Pi;
    typedef pair<P,P> PP;
    double eps=1e-8;
    int mod=1e9+7;
    int inf=1LL<<55;
     
    priority_queue<P,vector<P>,greater<P> > pq;
     
    template <typename T>
    int Count(const vector<T> &v, T l,T r){
      //counting [l,r]
      auto L = lower_bound(v.begin(), v.end(), l );
      auto R = upper_bound(v.begin(), v.end(), r );
      // [l,r) change upper -> lower
      return R-L;
    }
     
    signed main(){
      int q,a,b;
      cin>>q;
      while(q--){
        cin>>a>>b;
        if(a>b)swap(a,b);
        int s=sqrt((double)a*b-1);
        if(s==0){cout<<0<<endl;continue;}
        int mx=(a*b-1)/s;
        int ans=2*s;
        if(mx==s)ans--;
        if(a<=s)ans--;
        //if(b>=mx)p--;
        //  if(s>p-mx)ans--;
        cout<<ans<<endl;
      }
      return 0;
    }

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

using namespace std;

// Function come here..
bool foo(int n)
{
    return (n == 7 || n == 5 || n == 3);
}

int main(int argc, char **argv)
{
    // Problem solution come here...
    int n;
    cin >> n;

    if (foo(n))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long MOD = (long) (Math.pow(10, 9) + 7);
        int n = sc.nextInt();
        long max = 0;
        int num = 0;
        for (int i = 0; i <= n; i++) {
            int count = 0;
            int x = i;
            while (x > 1 && x % 2 == 0) {
                if (x % 2 == 0) {
                    count++;
                }
                x /= 2;
            }
            if (count > max) {
                num = i;
                max = count;
            }
        }
        System.out.println((num == 0) ? 1 : num);
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


Measured memory_bytes: 27020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPoll solver = new CPoll();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPoll {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            List<String> list = new ArrayList<>();
            Map<String, Integer> map = new HashMap<>();

            in.nextLine();
            int max = 0;
            for (int i = 1; i <= n; i++) {
                String s = in.nextLine();
                if (!map.containsKey(s)) {
                    map.put(s, 0);
                }
                int count = map.get(s) + 1;
                max = Math.max(count, max);
                map.put(s, map.get(s) + 1);
            }

            for (String s : map.keySet()) {
                if (map.get(s) == max) {
                    list.add(s);
                }
            }

            Collections.sort(list);

            for (int i = 0; i < list.size(); i++) {
                out.println(list.get(i));
            }
        }

    }
}



Measured memory_bytes: 179748
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}
	sort(all(a));
	ll sum = 0;
	rep(i, k)
	{
		sum += a[i];
	}
	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 3664
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
1 1
---+/
/+---test
3 101
---+/
/+---test
4 4
---+/

void main(string[] args) {
  long X, Y;
  readf(" %d %d ", &X, &Y);

  long ans;
  foreach (x; [X, Y]) {
    if (x == 3) ans += 100000;
    if (x == 2) ans += 200000;
    if (x == 1) ans += 300000;
  }
  if (X == 1 && Y == 1) ans += 400000;

  ans.writeln;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
        
        StringBuilder ab = new StringBuilder();
        StringBuilder ba = new StringBuilder();
      
        for (int i = 0; i < Integer.parseInt(b); i++) {
            ab.append(a);
        }
      
        for (int i = 0; i < Integer.parseInt(a); i++) {
            ba.append(b);
        }

      
        String answer = null;
        if (a.charAt(0) <= b.charAt(0)) {
            System.out.println(ab);
        } else {
            System.out.println(ba);
        }
	}
}

Measured memory_bytes: 22484
(let* ((n (read))
       (lst (loop :repeat n :collect (read))))
  (if (position-if (lambda (f) (and (evenp f) (not (or (= 0 (mod f 3))
                                                       (= 0 (mod f 5))) )))
                   lst)
      (princ "DENIED") (princ "APPROVED")))

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
//int dx[] = { 1, 0 };
//int dy[] = { 0, 1 };
#define mod7 1e9+7;
#define mod9 1e9+9;

//int nextInt(){
//	int a;	cin >> a;return a;
//}
//string next(){
//	string s;cin >> s;return s;
//}
//char nextChar(){
//	char c;cin >> c;return c;
//}

unsigned long long strtoint(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve(){
	int n,k;
	cin >> n >> k;
	vector<int> v;
	vcin(v,n);
	ssort(v);
	rev(v);
	int ans = 0;
	rep(i,k){
		ans += v[i];
	}
	P(ans);
}

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


Measured memory_bytes: 256
/*==============================================*\
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 = (int)2e5+5;
const int logn = 20;
int pos[maxn][27];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s, t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    s = "#"+s;
    t = "#"+t;
    f0(j,26) pos[n][j] = -1;
    fr(i,n-1,0)
    {
        f0(j,26) pos[i][j] = pos[i+1][j];
        pos[i][s[i+1] - 'a'] = i+1;
    }
    ll len = 0;
    int p = 0, ok = 1;
    f1(i,m)
    {
        int c = t[i] - 'a';
       // cout << t[i] << ": " << p << " -> ";
        int nx = pos[p][c];
        if(nx==-1){
            if(p==0){
                ok=0;
                break;
            }
            len+=n-p;
            p = 0;
            nx = pos[p][c];
            if(nx==-1){
                ok=0;
                break;
            }
            len+=nx-p;
            p = nx;
        }
        else{
            len+=nx-p;
            p = nx;
        }
        //cout << p << "\n";
    }
    if(ok) cout << len;
    else cout << "-1";
    return 0;
}


Measured memory_bytes: 12908
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++) cin>>d[i];
    long long sum=1;
    int a[100010]={};
    for(int i=0;i<n;i++){
        a[d[i]]++;
    }
    int b=0;
    for(int i=1;i<n;i++){
        if(a[i]!=0) b=i;
    }
    bool zero=false;
    if(d[0]!=0) zero=true;
    for(int i=1;i<n;i++){
        if(d[i]==0) zero=true;
    }
    for(int i=2;i<=b;i++){
        for(int j=0;j<a[i];j++){
            sum*=(a[i-1]%998244353);
            sum%=998244353;
        }
    }
    if(zero) cout<<0;
    else cout<<sum;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  const string prefix = "MARCH";
  int N;
  cin >> N;
  vector<int> cnt(prefix.size(), 0);
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    for (int j = 0; j < prefix.size(); j++) {
      if (S[0] == prefix[j]) {
        ++cnt[j];
        break;
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < prefix.size(); i++) {
    for (int j = i + 1; j < prefix.size(); j++) {
      for (int k = j + 1; k < prefix.size(); k++) {
        res += 1ll * cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
    long long int x;
    //    scanf("%lld", &x);
    std::cin >> x;
    long long int ans = 0;
    ans = 2 * (x / 11);
    if ((x % 11) > 6) {
        ans += 2;
    } else if (x % 11 != 0) {
        ans += 1;
    }
    //printf("%lld\n", ans);
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    int dp[][];
    int[][] A;
    int N;
    int M;
    int X;
    int[] C;

    private void run() {
        Scanner scanner = new Scanner(System.in);
        this.N = scanner.nextInt();
        this.M = scanner.nextInt();
        this.X = scanner.nextInt();

        this.C = new int[N]; // 参考書の値段
        A = new int[N][M]; // アルゴリズムの理解度
        int[] sum = new int[M];

        this.dp = new int[N][500000];

        for (int i = 0; i < N; i++) {
            C[i] = scanner.nextInt();
            for (int j = 0; j < M; j++) {
                A[i][j] = scanner.nextInt();
                sum[j] += A[i][j];
            }
        }

        for (int j = 0; j < M; j++) {
            if (sum[j] < X) {
                System.out.println(-1);
                return;
            }
        }

        // dp
        System.out.println(rec(0, new int[M]));
    }


    private int rec(int i, int[] x) {
        int res;

        boolean flg = true;
        int[] tmp = new int[M];
        int[] tmp_orig = new int[M];
        if(i < N) {
            for (int j = 0; j < M; j++) {
                tmp_orig[j] = x[j];
                tmp[j] = x[j] + A[i][j];
                if (x[j] < X) flg = false;
            }
        }else {
            for (int j = 0; j < M; j++) {
                if (x[j] < X) {
                    flg = false;
                    break;
                }
            }
        }
        res = 0;
        if(i == N && !flg) {
            // 条件を満たさずに最後に到達した
            res = 99999999;
        } else if(flg) {
            // 満たしているので商品を入れる必要がない
            res = 0;
        } else {
            // 入れない場合と入れる場合
            int a = rec(i + 1, tmp_orig);
            int b = rec(i + 1, tmp) + C[i];
            res = Math.min(a, b);
        }
        return res;
    }
}


Measured memory_bytes: 64860
package main

import (
        "bufio"
        "os"
        "sort"
        "strconv"
)

type SortInterface struct {
        A     []int
        order []int
}

func (s *SortInterface) Len() int           { return len(s.order) }
func (s *SortInterface) Less(i, j int) bool { return s.A[i] < s.A[j] }
func (s *SortInterface) Swap(i, j int) {
        s.A[i], s.A[j] = s.A[j], s.A[i]
        s.order[i], s.order[j] = s.order[j], s.order[i]
}

func main() {
        scanner := bufio.NewScanner(os.Stdin)
        scanner.Split(bufio.ScanWords)
        writer := bufio.NewWriter(os.Stdout)
        defer writer.Flush()

        scanner.Scan()
        N, _ := strconv.Atoi(scanner.Text())
        A := make([]int, N)
        for i := range A {
                scanner.Scan()
                A[i], _ = strconv.Atoi(scanner.Text())
        }

        order := make([]int, N)
        for i := range order {
                order[i] = i
        }
        sort.Sort(&SortInterface{A: A, order: order})

        for i := 0; i < len(order)-1; i++ {
                writer.WriteString(strconv.Itoa(order[i] + 1) + " ")
        }
        writer.WriteString(strconv.Itoa(order[len(order)-1] + 1))
}


Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	vector<int> v;
	int k,tmp;

	for (int i = 0; i < 5; i++) {
		scanf("%d", &tmp);
		v.push_back(tmp);
	}
	cin >> k;

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

	if(k<v.back() - v.front()){
	cout << ":(" << endl;
	}else{
		cout << "Yay!" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 5005
#define mod 1000000007
long long n,len,f[MN][MN],jie;
char s[MN];
int main(){
	n=read();
	scanf("%s",s+1);
	len=strlen(s+1);
	f[0][0]=1;
	for(int i=0;i<=n;i++)for(int j=0;j<=i;j++){
		f[i+1][j+1]=(f[i][j]*2+f[i+1][j+1])%mod;
		f[i+1][j==0?j:j-1]=(f[i][j]+f[i+1][j==0?j:j-1])%mod;
	}
	jie=1;for(int i=1;i<=len;i++) jie<<=1,jie>mod?jie-=mod:0;
	long long m=mod-2,res=1,ans=0;
	while(m){
		if(m&1) res=(res*jie)%mod;
		m>>=1;jie=(jie*jie)%mod;
	}
//	for(int i=0;i<=n;i++) ans+=f[i][len];
//	printf("%d\n",ans);
	printf("%lld\n",(f[n][len]*res)%mod);
	return 0;
}

Measured memory_bytes: 194048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String sl[];
    
    sl = r.readLine().split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int k[] = new int[100005];
    
    for(int i = 0; i < m; i++)
    {
      sl = r.readLine().split(" ");
      k[Integer.parseInt(sl[0])]++;
      k[Integer.parseInt(sl[1]) + 1]--;
    }
    
    int c = 0;
    for(int i = 1; i < 100004; i++)
    {
      k[i] += k[i - 1];
      if(k[i] == m)
      {
        c++;
      }
    }
    
    System.out.println(c);
  }


}

Measured memory_bytes: 66944
#include <stdio.h>

int main(void)
{
        char s[4],t[4];
        int c=0;

        scanf("%s%s",s,t);
        for(int i=0;i<3;i++){
                if(s[i]==t[i]) c++;
        }
        printf("%d\n",c);
        return 0;
}


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

typedef long long lint;

using namespace std;

int main()
{

	int A, B, K;
	cin >> A >> B >> K;

	int ans = 0;
	int cnt = 0;
	for (int i = min(A,B); i >= 1; i--)
	{
		if ((A % i == 0) && (B % i == 0))
		{
			cnt++;
			if (cnt == K)
			{
				ans = i;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256