akhauriyash/Code-Regression huggingface dataset:
n = int(input())
lst = [input() for _ in range(n)]

dct = {}
for st in lst:
    if st not in dct:
        dct[st] = 1

    dct[st] += 1


dct_srt = sorted(dct.items(), key=lambda x: x[1], reverse=True)
mx = 0
ans_ = []
for key, value in dct_srt:
    if value >= mx:
        mx = value
        ans_.append(key)
    else:
        break

ans = sorted(ans_)
for i in ans:
    print(i)


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

string check(string color){
	bool flag = true;

	int i=0;
	string result="";
	while(i<color.length()){
		if(color.substr(i,1)==color.substr(i+1,1)){
			result += color.substr(i,1);
			i += 1;
			flag = false;
		}else{
			result += color.substr(i,1);
		}
		i++;
	}

	if(flag){
		return result;
	}
	string result_s = check(result);

	return result_s;
}

int main(){
	int n;
	scanf("%d",&n);

	char* s = new char[n];
	scanf("%s",s);

	string moto = s;

	string result = check(moto);

	cout << result.length()<<endl;

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#define mod 1000000007
#define pb push_back
using namespace std;
long long dp[20][20];
int main(){
	int n;
	long long ans=0;
	string str,red,blue;
	cin>>n;
	cin>>str;
	long long ma=1<<n;
	for(int i=0;i<ma;i++){
		red.clear();blue.clear();
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				dp[j][k]=0;
			}
		}
		dp[0][0]=1;
		for(int j=0;j<n;j++){
			if( (i>>j)%2==0){ red.pb(str[j]);}
			else{ blue.pb(str[j]);}
		}
		int re = red.size(), bl = blue.size();
		for(int j=1;j<=n;j++){
			for(int k=0;k<=j;k++){
				if(k<re && red[k] == str[2*n-j]){
					dp[j][k+1]+=dp[j-1][k];
				}
				if((j-k-1)<bl && blue[j-k-1] == str[2*n-j]){
					dp[j][k]+=dp[j-1][k];
				}
			}
		}
		for(int j=0;j<=n;j++){
			ans+=dp[n][j];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	int n,a, b, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		if (a*a + b*b == c*c || a*a + c*c == b*b || c*c + b*b == a*a)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

using ll = long long;

const int N = 300005;

const int mod = 998244353;

int n, a, b;
ll k;

int power(int a, int n) {
  int r = 1;
  while (n > 0) {
    if (n % 2)
      r = (1LL*r*a) % mod;
    a = (1LL*a*a) % mod;
    n /= 2;
  }
  return r;
}

int fact[N], ifact[N];

void prepare() {
  fact[0] = ifact[0] = 1;
  for (int i = 1; i < N; ++i) {
    fact[i] = (1LL*fact[i-1]*i) % mod;
    ifact[i] = power(fact[i], mod-2);
  }
}

int newton(int n, int k) {
  if (k < 0 || n < k)
    return 0;
  int r = fact[n];
  r = (1LL*r*ifact[k]) % mod;
  r = (1LL*r*ifact[n-k]) % mod;
  return r;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  prepare();
  
  cin >> n >> a >> b >> k;
  
  int r = 0;
  
  for (int x = 0; x <= n; ++x) {
    if ((k - 1LL*a*x) % b != 0)
      continue;
    ll y = (k - 1LL*a*x) / b;
    if (y > n)
      continue;
    r = (r + 1LL*newton(n, x)*newton(n, y)) % mod;
  }
  
  cout << r << '\n';
}


Measured memory_bytes: 2560
<?php
 
list($k, $n) = preg_split('/ /', trim(fgets(STDIN)));
$a = preg_split('/ /', trim(fgets(STDIN)));

$max = $a[0] - $a[$n-1] + $k;
for ($i=1; $i < $n-1; $i++) { 
    $max = max($max, $a[$i+1] - $a[$i]);
}
print $k - $max;

Measured memory_bytes: 19060
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if (A1 + A2 + A3 >= 22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int r,b,w,g; scanf("%d%d%d%d",&r,&b,&w,&g);
    printf("%d\n",r+b+g+w);
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<std::vector<int>> A(N);

    for (int i = 0; i < N; i++)
    {
        int k;
        std::cin >> k;
        A[i].resize(k);
        for (int j = 0; j < k; j++)
        {
            std::cin >> A[i][j];
        }
    }

    int ans = 0;
    for (int i = 1; i <= M; i++)
    {
        bool flag = true;
        for (int j = 0; j < N; j++)
        {
            bool flag2 = false;
            for (int k = 0; k < A[j].size(); k++)
            {
                if (A[j][k] == i)
                {
                    flag2 = true;
                    break;
                }
            }
            if (!flag2)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            ans++;
        }
    }

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

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

// 同じ文字を圧縮する
// O(N)
vector<int> run_length(string &s) {
    vector<int> ans(1, 1);
    for (int i = 1; i < s.size(); i++) {
        if (s[i - 1] == s[i])
            ans[ans.size() - 1]++;
        else
            ans.emplace_back(1);
    }
    return ans;
}

int main() {
    string S;
    ll K;
    cin >> S >> K;

    auto run = run_length(S);
    ll ans   = 0;
    // 全部同じ文字のとき
    if (run.size() == 1) {
        ans = ((ll)run[0]) * K / 2;
    }
    // 両端が違う文字のとき
    else if (S[0] != S[S.size() - 1]) {
        for (auto &&i : run) {
            ans += i / 2;
        }
        ans *= K;
    }
    // 両端が同じ文字のとき
    else if (S[0] == S[S.size() - 1]) {
        for (auto &&i : run) {
            ans += i / 2;
        }
        ans *= K;
        ll cnt = run[0] + run[run.size() - 1];
        if (cnt % 2 == 0) {
            ans += K - 1;
        }
    }
    cout << ans << endl;
}

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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var split = Console.ReadLine().Split(' ');
            int N = int.Parse(split[0]);
            int K = int.Parse(split[1]);
            split = Console.ReadLine().Split(' ');
            long[] x = new long[N];
            int first_notminus = -1;
            bool first_flag = false;
            for (int i = 0; i < N; i++)
            {
                x[i] = long.Parse(split[i]);
            }

            long output = long.MaxValue;
            for (int i = 0; i+K < N+1; i++)
            {
                long hidari = x[i];
                long migi = x[i + K-1];
                long candidate = long.MaxValue;
                if (hidari * migi > 0)
                {
                    if(Math.Max(Math.Abs(hidari), Math.Abs(migi)) <candidate)
                    candidate = Math.Max(Math.Abs(hidari), Math.Abs(migi));
                }
                else
                {
                    if(Math.Abs(hidari) + migi + Math.Min(migi, Math.Abs(hidari))<candidate)
                    candidate = Math.Abs(hidari) + migi + Math.Min(migi, Math.Abs(hidari));
                }
                if (output > candidate) output = candidate;
            }
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 20704
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans=0, x=0;
    if (n <= a+b) {
        if (n <= a) out(n);
        else out(a);
    }
    else if (n > a+b){
        x = n / (a + b);
        n -= (a+b) * x;
        ans += (a * x);
        if (n <= a) ans += n;
        else ans += a;
        out(ans);
    }
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
hs=[]
ms=[]
for i in range(h):
  inp=list(map(lambda x:1 if x=="#" else 0,list(input())))
  hs.append(1 if 1 in inp else 0)
  ms.append(inp)

t=0
f1=True
for i in range(h):
  if hs[i]:
    f2=True
    for j in range(w):
      if ms[i][j]:
        t+=1
        if f2:
          tt=[t for k in range(j)]
          f2=False
      if not f2:
        tt.append(t)
    if f1:
      ans=[tt for k in range(i)]
      f1=False
  if not f1:
    ans.append(tt)
for i in ans:
  print(" ".join(map(str,i)))
      

Measured memory_bytes: 75560
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    string arr = "";
    string brr = "";

    for (int i = 0; i < a; i++)
    {
        brr += to_string(b);
    }
    for (int i = 0; i < b; i++)
    {
        arr += to_string(a);
    }
    cout << (arr < brr ? arr : brr) << endl;
}

Measured memory_bytes: 256
def intminus(i):
    return int(i) - 1
def main(): 
    
    n = int(input())
    A = list(map(intminus, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    cnt = 0
    for i in range(len(A)):
        cnt += B[A[i]]
        if i != 0 and A[i-1]+1 == A[i]:
            cnt += C[A[i-1]]

    print(cnt)
    
if __name__ == "__main__":
    main() 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

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

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

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n;
    cin>>n;
    if(n%2==0) cout<<n/2<<endl;
    else cout<<(n-1)/2 +1<<endl;
    return 0;
}


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

int main(){
    int x;  cin>>x;
    while(x<9)x+=7;
    int a=x-9;

    int res=abs(a)%7;

//    if(x<9)res+=7;

    if(res==0)cout<<"sat"<<endl;
    if(res==1)cout<<"sun"<<endl;
    if(res==2)cout<<"mon"<<endl;
    if(res==3)cout<<"tue"<<endl;
    if(res==4)cout<<"wed"<<endl;
    if(res==5)cout<<"thu"<<endl;
    if(res==6)cout<<"fri"<<endl;





    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n>>h;
    vl a(n+1),b(n+1);
    fo(i,n)cin>>b[i+1]>>a[i+1];
    vvl dp(n+1,vl(h+1,inf*inf));
    fo(i,n+1){
        fo(j,h+1){
            if(i==0||j==0){dp[i][j]=0;continue;}
            dp[i][j]=dp[i-1][j];
            if(j>=b[i]){
                dp[i][j]=max(dp[i][j],dp[i-1][j-b[i]]+a[i]);
            }
        }
    }
    if(dp[n][h]==inf*inf)dp[n][h]=0;
    cout<<dp[n][h];
    return 0;
}


Measured memory_bytes: 80256
<?php
fscanf(STDIN, '%d %d %d', $n, $m, $c);
$b = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = 0;
for ($i  = 0; $i < $n; $i++){
    $a = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $sum = 0;
    for ($j = 0; $j < $m; $j++) {
        $sum += $a[$j] * $b[$j];
    }
    $sum += $c;
    if ($sum > 0) $ans++;
}
echo $ans . PHP_EOL;

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

using namespace std;


void solve() {
    int n, X,Y;
    cin >> n >> X >> Y;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    const int INF = 0x3f3f3f3f;
    int sufA = 0;
    int sufB = INF;
    int res = abs(a[n] - Y);
    for (int i = n-1; i >= 1; i--) {
        int ta = abs(a[i] - a[n]);
        ta = min(ta, sufB);
        int tb = abs(a[i] - a[n]);
        tb = max(tb, sufA);
        sufA = max(sufA, ta);
        sufB = min(sufB, tb);
    }
    res = max(res, sufA);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

struct City{
        int p;
        int y;
        int n;
        bool operator<(const City &another) const
        {
        return y < another.y;
        };
};

int main(){
        int n,m;
        int num[100010]={0};
        City city[100010];
        cin>>n>>m;

        for(int i=0; i<m; i++){
                cin>>city[i].p>>city[i].y;
                city[i].n=i;
        }

        sort(city,city+m);

        for(int i=0; i<m; i++){
                num[city[i].p]++;
                city[i].y=city[i].n;
                city[i].n=num[city[i].p];
        }

        sort(city,city+m);

        for(int i=0; i<m; i++){
                printf("%06d%06d\n", city[i].p,city[i].n);
        }

        return 0;
}


Measured memory_bytes: 3072
using System;
 
namespace abc052
{
    public class Program1
    {
        public static void Main(string[] args)
        {
 
            int n = Convert.ToInt32(Console.ReadLine());
 
            int x = n * 800;
            int y = (n / 15) * 200;
 
            Console.WriteLine((x - y).ToString());
        }
    }
}

Measured memory_bytes: 11220
s = input()
slist = list(s)

rst = []

for i in range(0,len(s)):
	if slist[i] == '0':
		rst[len(rst):] = slist[i]
	elif slist[i] == '1':
		rst[len(rst):] = slist[i]
	elif slist[i]== 'B':
		if len(rst) == 0:
			rst == []
		else:
			rst[len(rst)-1:len(rst)] = ''
		
	

jd = "".join(rst)
print(jd)

Measured memory_bytes: 3064
#include <iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <algorithm>
#include <cstring>
#include<queue>
#include <stack>
using namespace std;

int main(){
    int n;
    cin >> n;
    char a[105];
    char b[105];
    cin >> a;
    cin >> b;
    for(int i = 0;i<n;i++){
        cout << a[i];
        cout << b[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

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

        boolean b = false;
        for (int i=1; i<10; i++) {
            for (int j=1; j<10; j++) {
                if (N.intValue()==i*j) {
                    b = true;
                    break;
                }
            }
        }

        if (b)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 22100
n = int(input())

t = []
for i in range(n):
   x,l = map(int,input().split())
   t.append((x+l,x-l))
t.sort()
max_r = -float('inf')
ans = 0
for i in range(n):
    if max_r<=t[i][1]:
        ans+=1
        max_r=t[i][0]
print(ans)

Measured memory_bytes: 16984
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int h[N];
int n,m;
int ans;
bool f[N];
int main() {
	memset(f,false,sizeof(f));
	cin>>n>>m;
	ans=n;
	for(int i=1;i<=n;i++) cin>>h[i];
	for(int i=1;i<=m;i++) {
		int u,v;
		cin>>u>>v;
		if(h[u]<=h[v] && !f[u]) {
			ans--;
			f[u]=1;
		}
		if(h[u]>=h[v] && !f[v]) {
			ans--;
			f[v]=1;
		}
	}
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 4124
package main

import (
	"fmt"
)

var (
	N, A, B, C, D, E int64
)

func Min(a ...int64) int64 {
	min := a[0]
	for _, aa := range a {
		if min > aa {
			min = aa
		}
	}
	return min
}

func main() {
	fmt.Scan(&N, &A, &B, &C, &D, &E)
	if 0 == N%Min(A, B, C, D, E) {
		fmt.Println(N/Min(A, B, C, D, E) + 4)
	} else {
		fmt.Println(N/Min(A, B, C, D, E) + 5)
	}
}


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

int main()
{
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;

    if (u == s)
        cout << a - 1 << ' ' << b << '\n';
    else 
        cout << a <<  ' ' << b - 1 << '\n';

    return 0;
}

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

int main(){
  int count=0,N,x[100],hand,i,j;

  scanf("%d",&N);
  if(N<1 || N>100){
    printf("Please type 1 to 100.\n");
    exit(1);
  }
  
  for(i=0;i<N;i++){
    scanf("%d",&x[i]);
    if(x[i]<0 || x[i]>100){
      printf("Please type 0 to 100.\n");
      exit(2);
    }
  }
  for(j=0;j<N;j++){
    for(i=N-1;i>j;i--){
      if(x[i] <  x[i-1]){
	hand = x[i];
	x[i] = x[i-1];
	x[i-1] = hand;
	count++;
      }
    }
  }

  for(j=0;j<N;j++){
    if(j==N-1)printf("%d",x[j]);
    else printf("%d ",x[j]);
  }printf("\n%d\n",count);
  

  return 0;
}



Measured memory_bytes: 2084
from itertools import accumulate
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    A = list(accumulate(S))[:-1]
    if all([a == N for a in A]):
        break
print(*A)

Measured memory_bytes: 183508
num = input().split()
 
n = int(num[0])
y = int(num[1])

m = 0
g = 0
s = 0

flag = False


for i in range(n+1):
    if flag:
        break
    m = i
    
    me = m * 10000
    
    if (y - me) / 5000 <= n: 
    
        for e in range(n+1):
            if flag:
                break
            g = e
            
            ge = g * 5000
            
            tmpS =  y - (me+ge)
            
            if (tmpS / 1000) + (m+g) == n and me+ge+tmpS == y and (tmpS / 1000) >= 0:
                flag = True
                ma = m
                ga = g
                if tmpS / 1000 > 0:
                    sa = tmpS / 1000
                    sa = int(sa)
                else: 
                    sa = 0
if flag:
    print(ma,ga,sa)
else:
    print(-1,-1,-1)



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

using namespace std;

string make_code(string s){
	string ans;
	ans+=s[0];
	for(int unsigned i=0;i<s.size()-1;i++){
		if(s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'e' || s[i] == 'o'){
			ans+=s[i+1];
		}
	}
	return ans;
}

int solve(vector<string> v, int max_string){
	for(int k=1;k<=max_string;k++){
		unsigned int i;
		for(i=1;i<v.size() && v[i-1].substr(0,k) != v[i].substr(0,k);i++);
		if(i == v.size()) return k;
	}
	return -1;
}

int main(){
	int n;
	while(cin >> n,n){
		vector<string> v;
		int max_string = 0;
		for(int i=0;i<n;i++){
			string s;
			cin >> s;
			v.emplace_back(make_code(s));
			max_string = max(max_string, (int)s.size());
		}
		sort(v.begin(), v.end());
		cout << solve(v, max_string) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define maxOfThree(a, b, c) max(a, max(b, c))
#define minOfThree(a, b, c) min(a, min(b, c))
#define int long long int

int solve(int H, int W) {
    int diffS = 1000000009;
    for (int w = 0; w < W; w++) {
        int h = H / 2;
        int Sa = h * w;
        int Sb = (H - h) * w;
        int Sc = H * (W - w);
        diffS = min(diffS,
            maxOfThree(Sa, Sb, Sc) - minOfThree(Sa, Sb, Sc)
        );

        int ww = w / 2;
        Sa = H * ww;
        Sb = H * (w - ww);
        diffS = min(diffS,
            maxOfThree(Sa, Sb, Sc) - minOfThree(Sa, Sb, Sc)
        );
    }
    return diffS;
}
signed main() {
    int H, W;
    cin >> H >> W;

    cout << min(solve(H, W), solve(W, H)) << endl;
}


Measured memory_bytes: 256
a = int(input())
lista = input().split()
maxval = -1000000
minval = 1000000
total = 0
for i in range(a):
    if int(lista[i]) > maxval:
        maxval = int(lista[i])
    if int(lista[i]) < minval:
        minval = int(lista[i])
    total += int(lista[i])
print(minval, maxval, total)


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n; cin >> n;
	long long ele_num = 1, set_num = 2;
	while(ele_num*set_num <= n*2){
		if(ele_num*set_num < n*2){
			ele_num++;
			set_num++;
			continue;
		}
		cout << "Yes" << endl;
		cout << set_num << endl;
		long long cnt = 1;
		long long dp[set_num][ele_num];
		for(long long i = 0; i < set_num; i++){
			cout << ele_num;
			for(long long j = 0; j < ele_num; j++){
				if(i <= j){
					dp[i][j] = cnt++;
					cout << " " << dp[i][j];
				}
				else{
					dp[i][j] = dp[j][i-1];
					cout << " " << dp[i][j];
				}
			}
			cout << endl;
		}
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (-a + b <= 0) {
    cout << "delicious" << endl;
  }
  else if (-a + b <= x) {
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
  return 0;
}

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

vector<long long> a;
vector<long long> p;

long long f(long long n, long long x) {
    if (n == 0) {
        if (x <= 0) {
            return 0;
        } else {
            return 1;
        }
    } else if (x <= 1 + a[n - 1]) {
        return f(n - 1, x - 1);
    } else {
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
    }
}
int main() {
    long long n, x;
    cin >> n >> x;
    a.push_back(1);
    p.push_back(1);
    for (long long i = 0; i < n; i++) {
        a.push_back(a[i] * 2 + 3);
        p.push_back(p[i] * 2 + 1);
    }

    cout << f(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
(* O(n log n) *)
Scanf.scanf " %d %d" @@ fun n k ->
  let balls = Array.make n 0 in
  for i = 1 to n do
    let a = Scanf.scanf " %d" @@ (+) 0 in
    balls.(a - 1) <- balls.(a - 1) + 1
  done;
  Array.sort (-) balls;
  Array.sub balls 0 @@ n - k |> Array.fold_left (+) 0 |> Printf.printf "%d\n"

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int map[555][555];
int main(){
    int n,m,Q;
    cin >> n >> m >> Q;
    rep(i,m){
        int l,r;
        scanf("%d %d",&l,&r);
        l--; r--;
        map[l][r]++;
    }
    for(int j=n;j>=0;j--){
        for(int i=n-1;i>=0;i--){
            map[i][j] += map[i+1][j];
        }
    }
    rep(i,n){
        rep(j,n){
            if(j>0) map[i][j] += map[i][j-1];
        }
    }
    rep(i,Q){
        int p,q;
        scanf("%d %d",&p,&q);
        p--; q--;
        cout << map[p][q] << "\n";
    }
    return 0;
}


Measured memory_bytes: 2048
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    string s1,t;
    long long sum=0;
    vector<string> ans;
    cin >> s1 >> t;
    for(int i=0; i<s1.size(); i++){
        if(s1[i]==t[0] || s1[i]=='?'){
            bool same=1;
            for(int j=0; j<t.size(); j++){
                if(s1[i+j]!=t[j] && s1[i+j]!='?'){
                    same=0;
                    break;
                }
            }
            if(same){
                sum++;
                string s=s1;
                for(int j=0; j<s1.size(); j++){
                    if(j>=i && j<=i+t.size()-1)  s[j]=t[j-i];
                    else if(s[j]=='?') s[j]='a';
                }
                ans.push_back(s);
            }
        }
    }
    if(sum==0) cout << "UNRESTORABLE" << endl;
    else{
        sort(ans.begin(),ans.end());
        cout << ans[0] << endl;
    }
}


Measured memory_bytes: 256
s = sorted(input())
t = sorted(input(),reverse=True)
flag = -1
i = 0



while(i < min(len(s),len(t))):
  if s[i] > t[i]:
    flag = -1
    break
  elif s[i] < t[i]:
    flag = 1
    break
  else:
    if (i+1 == len(s)) & (len(s) != len(t)):
      flag = 1
      break
    i += 1

if flag == 1: print("Yes")
else: print("No")



Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, Num[100005];
long long rightSum[100005], leftSum[100005], result = (long long) 1 << 62;

int abs(int num)
{
    return num > 0 ? num : -num;
}

int main()
{
    scanf("%d %d", &N, &K);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d", &Num[i]);
        if(i > 1)
        {
            rightSum[i] = rightSum[i - 1] + abs(Num[i] - Num[i - 1]);
        }
    }
    for(int i = N - 1; i >= 1; i--)
    {
        leftSum[i] = leftSum[i + 1] + abs(Num[i] - Num[i + 1]);
    }
    for(int i = 1; i <= N - K + 1; i++)
    {
        result = min(result, rightSum[i + K - 1] - rightSum[i] + abs(Num[i]));
    }
    for(int i = N; i >= K; i--)
    {
        result = min(result, leftSum[i - K + 1] - leftSum[i] + abs(Num[i]));
    }
    printf("%lld", result);
}

Measured memory_bytes: 2176
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n, k]: number[] = tmp[0].split(" ").map(int => parseInt(int));
    let result: number = 0;
    let a = n;
    while (a > 0) {
      const r = a % k;
      a = (a - r) / k;
      result++;
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P2;
vector<P> kn[3005];
bool used[3005];
ll mincost[3005]={0};
bool dfs(ll pos,ll goal){
  if(pos==goal) return true;
  for(int i=0;i<kn[pos].size();i++){
    ll to=kn[pos][i].first;
    if(!used[to]){
      used[to]=true;
      if(dfs(to,goal)) return true;
    }
  }
  return false;
}
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    ll s,t,cos;
    cin>>s>>t>>cos;
    kn[s].push_back(P(t,-cos));
  }
  ll gs=0;
  vector<P2> node;
  for(int i=1;i<=n;i++){
    for(int j=0;j<3005;j++) used[j]=false;
    used[i]=true;
    if(dfs(i,n)){
      for(int j=0;j<3005;j++) used[j]=false;
      used[1]=true;
      if(!dfs(1,i)) continue;
      for(int j=0;j<kn[i].size();j++) node.push_back(P2(i,kn[i][j]));
      gs++;
    }
  }
  for(int i=2;i<=3005;i++) mincost[i]=17441744174417;
  int cnt=0;
  while(1){
    bool upd=false;
    for(int i=0;i<node.size();i++){
      ll s=node[i].first,t=node[i].second.first,cos=node[i].second.second;
      if(mincost[s]+cos<mincost[t]){
        upd=true;
        mincost[t]=mincost[s]+cos;
      }
    }
    cnt++;
    if(!upd) break;
    if(upd&&cnt>=gs){
      cout<<"inf"<<endl;
      return 0;
    }
  }
  cout<<mincost[n]*-1<<endl;
  return 0;
}


Measured memory_bytes: 512
n, T = map(int, input().split())
t = list(map(int, input().split()))
cum_sub = [0] + [t[i]-t[i-1] for i in range(1,n)]

ans = 0
for each in cum_sub[1:]:
  ans += min(T, each)
  
ans += T
print(ans)

Measured memory_bytes: 25200
#include<stdio.h>

#define N 1000000

typedef struct{
  int num,id;
  char mark;
} card;

void swap(card *a,card* b){
  card t=*a;*a=*b,*b=t;
}

int partition(card *A,int p,int r){
  int x=A[r].num,i=p-1,j;
  for(j=p;j<r;j++){
    if(A[j].num<=x){
      i=i+1;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}

void quickSort(card *A,int p,int r){
  if(p<r){
    int q=partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

int isStable(card *a,int n){
  int i;
  for(i=0;i<n-1;i++){
    if(a[i].num==a[i+1].num && a[i].id>a[i+1].id)return 0;
  }
  return 1;
}

int main(void){

  int n,i;
  card A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c %d",&A[i].mark,&A[i].num);
    A[i].id=i;
  }
  quickSort(A,0,n-1);

  printf("%s\n",isStable(A,n)?"Stable":"Not stable");
  for(i=0;i<n;i++)
    printf("%c %d\n",A[i].mark,A[i].num);
  
  return 0;
}



Measured memory_bytes: 3036
import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline
write = sys.stdout.write

N = int(readline())
G = [None]*N
for v in range(N):
    k, *G[v] = map(int, readline().split())

S = []

FS = [0]*N
depth = [0]*N

*it, = map(iter, G)
P = [-1]*N

stk = [0]
depth[0] = 0
FS[0] = 0
while stk:
    v = stk[-1]
    p = P[v]
    S.append(v)

    w = next(it[v], -1)
    while w != -1:
        if w != p:
            P[w] = v
            depth[w] = len(stk)
            FS[w] = len(S)
            stk.append(w)
            break
        w = next(it[v], -1)
    else:
        stk.pop()

L = len(S)
lg = [0]*(L + 1)
for i in range(2, L+1):
    lg[i] = lg[i >> 1] + 1
st = [None]*(lg[L] + 1)
st0 = st[0] = S
b = 1
for i in range(lg[L]):
    st0 = st[i+1] = [p if depth[p] <= depth[q] else q for p, q in zip(st0, st0[b:])]
    b <<= 1

def query(u, v):
    x = FS[u]; y = FS[v]
    if x > y:
        x, y = y, x
    l = lg[y - x + 1]
    px = st[l][x]; py = st[l][y - (1 << l) + 1]
    return px if depth[px] <= depth[py] else py

Q = int(readline())
ans = []
for q in range(Q):
    u, v = map(int, readline().split())
    ans.append(query(u, v))
write("\n".join(map(str, ans)))
write("\n")


Measured memory_bytes: 70388
N=int(input())
A=list(map(int,input().split()))
count=[0]*(N+1)
for a in A:
    count[a]+=1
combination=0
for i in range(N+1):
    if count[i]!=0:
        combination+=count[i]*(count[i]-1)//2
for a in A:
    print(combination-(count[a]-1))

Measured memory_bytes: 25644
#include <stdio.h>
typedef unsigned int uint;
int euclidean(uint m, uint n) {
	return (n == 0) ? m : euclidean(n, m % n);
}
int main() {
	uint large, small, gcd, lcm;
	while (scanf(" %u %u", &large, &small) != EOF) {
		if (large < small) {
			large ^= small;
			small ^= large;
			large ^= small;
		}
		gcd = euclidean(large, small);
		lcm = large / gcd * small;
		printf("%u %u\n", gcd, lcm);
	}
	return 0;
}

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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll ans, s, a[200005], c[200005];


int main(void) {
    int n;
    cin >> n;
    rep(i, 0, n) scanf("%lld", &a[i]);

    rep(i, 0, n) {
        s += c[a[i]];
        c[a[i]]++;
    }

    rep(i, 0, n) {
        printf("%lld\n", s-(c[a[i]]-1));
    }
    

	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'
#define f(i, n) for (int i = 0; i < n; ++i)

using namespace std;
void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 256
(ns atcoder.abc173c)

(def result {:AC 0 :WA 0 :TLE 0 :RE 0})

(def n (read))

(defn inc-map [keyword {ac :AC wa :WA tle :TLE re :RE :as all}]
  (cond (= keyword :AC) {:AC (inc ac) :WA wa :TLE tle :RE re}
        (= keyword :WA) {:AC ac :WA (inc wa) :TLE tle :RE re}
        (= keyword :TLE) {:AC ac :WA wa :TLE (inc tle) :RE re}
        (= keyword :RE) {:AC ac :WA wa :TLE tle :RE (inc re)}))


(def out  (loop [cnt n
                 result result]
  (cond (= cnt 0) result
        :else (recur (dec cnt)
                     (inc-map (keyword (read)) result)))))

(println (format "AC x %d" (:AC out)))
(println (format "WA x %d" (:WA out)))
(println (format "TLE x %d" (:TLE out)))
(println (format "RE x %d" (:RE out)))

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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;

int n;

/*string make_s(int n, int m){	//n桁,m:動かす桁数
  string s;
  rep1(i,n-m)
    s += 'a';
  rep(i,n-1)
    s += 'a'+i;
  
  cout << s << endl;
  return s;
}*/

void dfs(string s, char mx){
  if(s.size() == n){
    cout << s << endl;
    return;
  }
  for(char c = 'a'; c <= mx+1; c++){
    string t = s;
    t += c;
    dfs(t, max(c, mx));
  }
}

int main(){

  cin >> n;
  
  dfs("", 'a'-1);
  return 0;
}





Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
int N;
int t[10000][10];
bool d[10000];
int a, b, c;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			std::cin >> t[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			if (t[i][j] > a) {
				a = t[i][j];
			}
			else if (t[i][j] > b) {
				b = t[i][j];
			}
			else {
				std::cout << "NO" << "\n";
				a = 0; b = 0;
				break;
			}
			if (j == 9) {
				std::cout << "YES" << "\n";
				a = 0; b = 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

int main(int argc, char *argv[]) {
	int n; cin >> n;

	int a; cin >> a;
	for (int i = 1; i < n; i++) {
		int b; cin >> b;
		a = gcd(a,b);
	}

	cout << a << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	char c[3][3];
    rep(i,3){
      rep(j,3){
        cin >> c[i][j];
      }
    }
    rep(i,3){
      cout << c[i][i];
    }
    cout << endl;
    return 0;
  } 

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

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

  vector<int> h(n);
  for (auto&& hv : h) {
    cin >> hv;
  }

  vector<bool> goodH(n, true);
  for (int i = 0; i < m; ++i) {
    int ix, iy;
    cin >> ix >> iy;
    int x = ix - 1;
    int y = iy - 1;

    if (h.at(x) == h.at(y)) {
      goodH.at(x) = false;
      goodH.at(y) = false;
    } else if (h.at(x) > h.at(y)) {
      goodH.at(y) = false;
    } else if (h.at(x) < h.at(y)) {
      goodH.at(x) = false;
    }
  }

  cout << count(begin(goodH), end(goodH), true) << endl;
}


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

using Graph = vector<vector<int>>;

int dfs(const auto& G, auto cur, auto pre) {
  return accumulate(begin(G[cur]), end(G[cur]), 0, [&](auto g, auto to) {return to!=pre ? g^(dfs(G, to, cur)+1) : g;});
}

int main() {
  int N;
  cin >> N;
  Graph G(N);
  for(auto i = 1; i < N; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  if(dfs(G,0,0)) cout << "Alice" << endl;
  else           cout << "Bob" << endl;
}


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

ll times(ll a) {
  if(a%2==1) return 0;
  return 1+times(a/2);
}

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  ll ans=0;
  rep(i,n) {
    cin >>a[i];
    ans+=times(a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
K=parse(Int,readline())
function solve(K)
tmp=1
if K%7==0
    L=div(9*K,7)
else
    L=9*K
end
res=-1
for i =1:K
    tmp=tmp*10%L
    if tmp==1
        res=i
        break
    end
end
return res
end
println(solve(K))

Measured memory_bytes: 158000
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	N = N % 10
	if N == 3 {
		fmt.Println("bon")
	} else if N == 0 || N == 1 || N == 6 || N == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}



Measured memory_bytes: 1768
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		while (true) {
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0) {
				break;
			}

			int ans = 0;
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					int k = x - (i + j);
					if (k >= j + 1 && k <= n) {
						ans++;
					}
				}
			}
			out.println(ans);
		}

		sc.close();
	}

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



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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int worm[4][4][4][4][4][4][4][4][4][4];

int main() {
    fill_n((int *)worm, 4*4*4*4*4*4*4*4*4*4, -1);
    FOR(len, 2, 11) {
        queue<vi> que;
        FOR(color, 1, 4) {
            vi v(10, 0);
            REP(i, len) v[i] = color;
            que.push(v);
        }
        que.push({});
        int cnt = 0;
        while (1) {
            vi v = que.front(); que.pop();
            if (v.empty()) {
                if (que.empty()) break;
                que.push({});
                cnt++;
                continue;
            }
            if (worm[v[9]][v[8]][v[7]][v[6]][v[5]][v[4]][v[3]][v[2]][v[1]][v[0]] != -1) continue;
            worm[v[9]][v[8]][v[7]][v[6]][v[5]][v[4]][v[3]][v[2]][v[1]][v[0]] = cnt;
            REP(i, len-1) {
                if (v[i+1] != 0 && v[i] == v[i+1]) {
                    int c1 = (v[i]) % 3 + 1, c2 = (v[i]+1) % 3 + 1;
                    vi v1 = v;
                    v1[i] = c1, v1[i+1] = c2;
                    que.push(v1);
                    vi v2 = v;
                    v2[i] = c2, v2[i+1] = c1;
                    que.push(v2);
                }
            }
        }
    }

    string line;
    while (cin >> line, line != "0") {
        vi v(10, 0);
        REP(i, line.size()) v[i] = line[i] % 3 + 1; // rgb -> 123
        int res = worm[v[9]][v[8]][v[7]][v[6]][v[5]][v[4]][v[3]][v[2]][v[1]][v[0]];
        if (res == -1) {
            cout << "NA" << endl;
        } else {
            cout << res << endl;
        }
    }
}

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

int main()
{
	int a, b;
	char s[110][110];

	cin >> a >> b;

	for (int i = 1; i <= 100; i++)
	{
		for (int j = 1; j <= 100; j++)
		{
			if (i <= 50) s[i][j] = '#';
			else s[i][j] = '.';
		}
	}

	int sum_a = 0;
	if (a != 1)
	{
		for (int i = 2; i <= 48; i++)
		{
			for (int j = 2; j <= 99; j++)
			{
				if (s[i][j - 1] != '.' && s[i][j + 1] != '.' && s[i - 1][j] != '.' && s[i + 1][j] != '.')
				{
					if (s[i - 1][j - 1] != '.' && s[i - 1][j + 1] != '.' && s[i + 1][j - 1] != '.' && s[i + 1][j + 1] != '.')
					{
						if (s[i][j] == '#')
						{
							s[i][j] = '.';
							sum_a++;
						}
					}
				}
				if (sum_a == a - 1)
				{
					goto END_a;
				}
			}
		}
	}

END_a:;

	int sum_b = 0;
	if (b != 1)
	{
		for (int i = 52; i <= 99; i++)
		{
			for (int j = 2; j <= 99; j++)
			{
				if (s[i][j - 1] != '#' && s[i][j + 1] != '#' && s[i - 1][j] != '#' && s[i + 1][j] != '#')
				{
					if (s[i - 1][j - 1] != '#' && s[i - 1][j + 1] != '#' && s[i + 1][j - 1] != '#' && s[i + 1][j + 1] != '#')
					{
						if (s[i][j] == '.')
						{
							s[i][j] = '#';
							sum_b++;
						}
					}
				}
				if (sum_b == b - 1)
				{
					goto END_b;
				}
			}
		}
	}
END_b:;

	cout << 100 << " " << 100 << endl;
	for (int i = 1; i <= 100; i++)
	{
		for (int j = 1; j <= 100; j++)
		{
			cout << s[i][j];
		}
		cout << endl;
	}
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,k;
	cin>>n>>k;
	ll dp[n],h[n];
	dp[0]=0;
	forn(i,n){
		cin>>h[i];
	}
	dp[1]=abs(h[1]-h[0]);
	for(ll i= 2;i<n;i++){
		dp[i]=inf;
		forn(j,k+1){
			if(i-j>=0)dp[i] = min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
		}
	}
	cout<<dp[n-1]<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 5212
x,y=map(int,input().split())
m=10**9+7
if (2*x-y)%3==0 and (2*y-x)%3==0 and 2*x>=y and 2*y>=x:
    a,b=(2*x-y)//3,(2*y-x)//3
    c=min(a,b)
    p=1
    for i in range(c):
        p=(p*(a+b-i)*pow(i+1,m-2,m))%m
    print(p)
else:
    print(0)

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>

using namespace std;

int main(){

int cnt = 0;
string s1 = "Sunny";
string s2 = "Cloudy";
string s3 = "Rainy";
string s;

cin >> s;

if(s == "Sunny"){
	cout << "Cloudy" << endl;
}else if(s == "Cloudy"){
	cout << "Rainy" << endl;
}else{
	cout << "Sunny" << endl;
}
  
  return 0;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

            Scanner put = new Scanner(System.in);

            int a  = put.nextInt();
            int b = put.nextInt();
            int c  = put.nextInt();
            if((a + b + c) >= 22) System.out.println("bust"); 
            else System.out.println("win");

    }
}

Measured memory_bytes: 21844
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

a,s,b = map(str, input().split())

print("A"+s[0]+"C")


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (ll)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        int x;
        cin>>x;
        int ans=8-((x-400)/200);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
n = int(input())
l = [int(x) for x in input().split()]
l.sort()
set_l = set(l)
set_l = sorted(set_l)
limit = 10**6+1
mp = [0]*(limit)
pre = None
for i in range(n):
    num = l[i]
    if(pre==num):
        mp[num] += 1
    pre = num

for x in set_l:
    for y in range(x,limit,x):
        mp[y] += 1
        

cnt = 0
for num in set_l:
    if(mp[num]==1):
        cnt += 1
print(cnt)





Measured memory_bytes: 32084