akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			int count = 0;
			
			for(int a = 0; a < 10; a++){
				for(int b = 0; b < 10; b++){
					for(int c = 0; c < 10; c++){
						for(int d = 0; d < 10; d++){
							if(a + b + c + d == n) count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

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

int main() {
  int K;
  cin >> K;
  vector<int> vec;
  vec={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << vec.at(K) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define S 1050 //1050min = 17:30 //
#define G 1170 //1170min = 19:30 //
using namespace std;
int kiriage(int);
int main(){
	int tmp[7][7]={{0,300,500,600,700,1350,1650},
					{6,0,350,450,600,1150,1500},
					{13,7,0,250,400,1000,1350},
					{18,12,5,0,250,850,1300},
					{23,17,10,5,0,600,1150},
					{43,37,30,25,20,0,500},
					{58,52,45,40,35,15,0}};

	int sIC,sh,sm,gIC,gh,gm,smin,gmin,cost;
	while(cin >> sIC && sIC){
		cin >> sh >> sm >> gIC >> gh >> gm;
		smin = sh * 60 + sm;
		gmin = gh * 60 + gm;
		if(sIC>gIC)swap(sIC,gIC);
		cout << ((((smin >= S && smin <= G) || (gmin >= S && gmin <= G)) && tmp[gIC-1][sIC-1]<=40) ?
			 		kiriage(tmp[sIC-1][gIC-1]/2) : tmp[sIC-1][gIC-1]) << endl;
	}
}
int kiriage(int cost){
	return (cost%50==0?cost:cost/50*50+50);
}

Measured memory_bytes: 1160
h,w = map(int,input().split())
coins = []
ans = []
for i in range(h):
    coins.append(list(map(int,input().split())))
for i in range(h-1):
    for j in range(w):
        if coins[i][j] % 2 != 0:
            coins[i][j] -= 1
            coins[i+1][j] += 1
            ans.append((i+1,j+1,i+2,j+1))
for i in range(w-1):
    if coins[h-1][i] % 2 != 0:
        coins[h-1][i] -= 1
        coins[h-1][i+1] += 1
        ans.append((h,i+1,h,i+2))
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])



Measured memory_bytes: 26660
#include<bits/stdc++.h>
using namespace std;
int k,p,id[1005];
int f[505][505];

void print(int x){
	if(x>=10) print(x/10);
	putchar(x%10+'0');
}

int main(){
	scanf("%d",&k);
	if(k&1){
		p=k/2+1;
		if((p&1)&&p>1){
			p++;
			for(int i=1;i<=p;i++){
				f[i][i]=1;int now=2;
				for(int j=i-1;j>=1;j--){
					if(now+p-1<=k&&i%2==0) f[i][j]=now+p-1;
					else f[i][j]=now;now++;
				}
				for(int j=p;j>i;j--){
					if(now+p-1<=k&&i%2==0) f[i][j]=now+p-1;
					else f[i][j]=now;now++;
				}
			}
		}
		else{
			for(int i=1;i<=p;i++){
				f[i][i]=1;int now=(i&1)?2:3;
				for(int j=i-1;j>=1;j--) f[i][j]=now,now+=2;
				for(int j=p;j>i;j--) f[i][j]=now,now+=2;
			}
		}
	}
	else if(k!=2){
		p=k/2;
		if(p&1){
			p++;
			for(int i=1;i<=k-2;i++) id[i]=i;
			id[k-1]=id[k]=k-1,id[k+1]=id[k+2]=k;
			for(int i=1;i<=p;i++){
				int now=(i&1)?1:2;
				for(int j=i;j<=p;j++) f[i][j]=id[now],now+=2;
				for(int j=1;j<i;j++) f[i][j]=id[now],now+=2;
			}
		}
		else{
			for(int i=1;i<=p;i++){
				int now=(i&1)?1:2;
				for(int j=i;j<=p;j++) f[i][j]=now,now+=2;
				for(int j=1;j<i;j++) f[i][j]=now,now+=2; 
			}
		}
	}
	else p=2,f[1][1]=f[2][2]=1,f[1][2]=f[2][1]=2;
	print(p),puts("");
	for(int i=1;i<=p;i++){
		for(int j=1;j<=p;j++) print(f[i][j]),putchar(' ');
		puts("");
	}

	return 0;
}

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

int mat[105][5], n;
int pref[105], suff[105];

int main(){

    cin >> n;
    for(int j = 0; j < 2; j++)
        for(int i = 1; i <= n; i++)
            cin >> mat[i][j];
    for(int i = 1; i <= n; i++)
        pref[i] = pref[i-1] + mat[i][0];
    for(int i = n; i >= 1; i--)
        suff[i] = suff[i+1] + mat[i][1];
    int res = 0;
    for(int i = 1; i <= n; i++)
        res = max(res, pref[i]+suff[i]);
    cout << res << endl;
    
	return 0;
}


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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
int n, k;
int arr[102];
int dp[100004][3];

int f (int a1, int a2, int turn) {
    if (turn == 0)
        return (min(a1, a2));
    return (max(a1, a2));
}

int go (int k, int turn) {
    if (k < arr[1] || k == 0) {
        return (turn^1);
    }
    if (dp[k][turn] != -1)
        return dp[k][turn];
    int ans = turn^1;
    for (int i=1; i<=n; i++) {
        if (arr[i] <= k) {
            ans = f(ans, go (k-arr[i], turn^1), turn);
        }
        else {
            break;
        }
    }
    dp[k][turn] = ans;
    return ans;
}

void testCase() {
    cin >> n >> k;
    for (int i=0; i<=k; i++) {
        for (int j=0; j<3; j++)
            dp[i][j] = -1;
    }
    for (int i=1; i<=n; i++)
        cin >> arr[i];
    sort (arr+1, arr+n+1);
    (go(k, 0) == 0) ? (cout << "First" << endl) : (cout << "Second" << endl);    
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define ll long long
using  namespace std;
int a[100100],b[100010];
int mi=2e9,mi_1=2e9,mi_2=2e9;
int main(){
   int n,m,k;
   cin>>n>>m>>k;
   for(int i=0;i<n;i++){
       //int q;
       cin>>a[i];
       mi_1= min(mi_1,a[i]);
   }
   for(int i=0;i<m;i++){
       int q;
       cin>>b[i];
       mi_2= min(mi_2,b[i]);
   }
   mi = min(mi,mi_1+mi_2);
   for(int i=0;i<k;i++){
       int x,y,z;
       cin>>x>>y>>z;
       mi = min(mi,a[x-1]+b[y-1]-z);
   }
   cout<<mi;

}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define VI vector<int>
#define VII vector<pair<int, int>>
#define PII pair<int, int>
#define MP make_pair
// #define log(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define log(fmt, ...)
// #define check(...) assert(##__VA_ARGS__)
#define check(...)

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

    int a, b, c;
    cin >> a >> b >> c;
    // ll ans = 4 * (ll)a*b-((ll)c-a-b)*((ll)c-a-b);
    if (c>=a+b && 4 * (ll)a * b < ((ll)c - a - b) * ((ll)c - a - b)) {
        // if (sqrt(a)+sqrt(b)<sqrt(c)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n,k;
    cin >> n >> k;
    vec<long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    
    for (int i = 0; i < n-k; i++)
    {
        long left = a.at(i);
        long right = a.at(i+k);
        if (left < right)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
    
}

Measured memory_bytes: 4840
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	string s;
	int n;
	cin >> s >> n;
	bool on = true;
	loop(i,1,s.size()) {
		if (s[i] != s[i - 1])on = false;
	}
	if (on == true) {
		cout << (s.size()* n) / 2 << endl;
	}
	elif(s[s.size() - 1] != s[0]) {
		int ans = 0;
		loop(i,1,s.size()){
			if (s[i] == s[i - 1]) {
				s[i] = '1';
				ans++;
			}
		}
		cout << ans * n << endl;
	}
	else {
		int a = 1, b = 1;
		loop(i, 1, s.size()) {
			if (s[i] != s[i - 1])break;
			a++;
		}
		for (int i = s.size() - 2; i >= 0; --i) {
			if (s[i] != s[i + 1])break;
			b++;
		}
		int ans = 0;
		loop(i, 1, s.size()) {
			if (s[i] == s[i - 1]) {
				s[i] = '1';
				ans++;
			}
		}
		int sum = a / 2 + b / 2 - (a + b) / 2;
		cout << ans * n - sum * (n - 1) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, A, B;
    cin >> N >> A >> B;
    vl H(N);
    rep(i, N) cin >> H[i];

    ll ng = 0, ok = 1e9;
    while(ok-ng>1){
        ll mid = (ok + ng) / 2;

        ll b = B * mid, cnt = 0;
        rep(i,N){
            cnt += max(0ll, (H[i] - b + A - B - 1) / (A - B));
        }
        (cnt <= mid ? ok : ng) = mid;
    }

    cout << ok << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int mp[10][10] = {0};
int ans = 0;
int n,m;

signed main(){
    // cerr << "aaaa" << endl;
    cin >> n >> m;

    
    rep(i,m){
        int a,b;
        cin >> a >> b;
        mp[a][b] = 1;
        mp[b][a] = 1;
    }
    int x[7] = {2,3,4,5,6,7,8};

    // cerr < ans << endl;

    do{
        int c = 1;
        rep(i,n-1){
            if(i == 0){
                if(mp[1][x[i]] == 0) c = 0;
            }else{
                if(mp[x[i-1]][x[i]] == 0)c = 0;
            }
        }
        if(c == 1)ans++;
        // if(c == 1){
        //     rep(i,n-1)cerr << x[i];
        //     cerr << endl;
        // }
    }while(next_permutation(x,x+n-1));

    
    cout << ans << endl;

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes";
  	else cout << "No";
}


Measured memory_bytes: 256
package main

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

func main() {
    var fp *os.File = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)

    N, _ := strconv.Atoi(readLine(reader))
    line := readLine(reader)
    arr := strings.Split(line, " ")
    var nums []int

    for _, v := range arr {
        num, _ := strconv.Atoi(v)
        nums = append(nums, num)
    }

    sort.Sort(sort.IntSlice(nums))
    before_num := 0.0

    for i := 0; i < N; i++ {
        if (before_num > 0) {
            before_num = (before_num + float64(nums[i])) / 2
        } else {
            before_num = float64(nums[i])
        }
    }

    fmt.Println(before_num)
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 640
N,A = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
dp = Array.new(N+1){Array.new(N*50+1,0)}
dp[0][0] = 1

N.times do |i|
	i.downto(0) do |j|
		(N*49+1).times do |k|
			dp[j+1][k+x[i]] += dp[j][k] if k+x[i] < N*50+1
		end
	end
end

ans = 0
1.upto(N) do |i|
	ans += dp[i][i*A]
end
p ans


Measured memory_bytes: 4860
import math

l = int(input())
a = list(map(int, input().split()))
dict = {}
for n in a:
    ans = []
    i = 2
    k = math.sqrt(n)
    dic = {}
    while i <= k:
        if n%i == 0:
            n = n//i
            ans.append(i)
            i -= 1
            if n == 1:
                break
        i += 1
    if len(ans) == 0 or n != 1:
        ans.append(n)
    for i in ans:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
    for i in dic.keys():
        if i in dict:
            dict[i] = max(dict[i], dic[i])
        else:
            dict[i] = dic[i]
sum = 1
for x,y in dict.items():
    sum *= x**y
print(sum)


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

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

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

int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, X; cin >> N >> X;
    vector<int> vl;
    vector<int> vu;
    REP(i, N) {
        int tmp; cin >> tmp;
        if (tmp>X) vu.push_back(tmp);
        else vl.push_back(tmp);
    }
    sort(vu.begin(), vu.end());
    sort(vl.begin(), vl.end(), greater<int>());
    
    int ml = (vl.size() == 0)? 0 : X - vl[0];
    int mu = (vu.size() == 0)? 0 : vu[0] - X;
    for (int i = 1; i < vl.size(); i++) {
        ml = gcd(ml, vl[i - 1] - vl[i]);
    }
    for (int i = 1; i < vu.size(); i++) {
        mu = gcd(mu, vu[i] - vu[i - 1]);
    }
    if (ml * mu != 0) {
        cout << gcd(ml, mu) << endl;
    } 
    else {
        cout << max(ml, mu) << endl;
    }
    return 0;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int count = 1;
		while (y / x >= 2) {
		    x *= 2;
		    count++;
		}
     System.out.println(count);
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s,t;
  cin >> s >> t;
  int lens = s.size();
  int lent = t.size();
  if(lens < lent){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  vector<string> pack;
  int dlen = lens - lent;
  rep(i,dlen+1){
    string tmp = s;
    //cout << s << endl;
    bool ans = true;
    rep(j,lent){
      if(t.at(j) == s.at(j+i) || s.at(j+i) == '?'){
        tmp.at(j+i) = t.at(j);
        continue;
      }
      //if(i == 2) cout << t.at(j) << " " << s.at(j+i) << endl;
      ans = false;
      break;
    }
    if(ans){
      pack.push_back(tmp);
    }
  }
  if(pack.size() == 0){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  rep(i,pack.size()){
    rep(j,pack.at(i).size()){
      if(pack.at(i).at(j) == '?') pack.at(i).at(j) = 'a';
    }
  }
  int mini = 0;
  for(int i=1;i<pack.size();i++){
    if(pack.at(i) < pack.at(i-1)) mini = i;
  }
  cout << pack.at(mini) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
int main()
{
   string s1;
   string s2;

   cin >> s1>>s2;
   int counter=0;
   int n = s1.length();
   for(int i =0;i<n;i++)
   {
       if(s1[i]!=s2[i])
        counter++;
   }
   cout<<counter;
    return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	if(N%K == 0){

		printf("0\n");

	}else{

		printf("1\n");
	}

	return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10)cout << a * b << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;


int main(){
    string s;
    cin>>s;
    if(s=="KIHBR"||s=="AKIHBR"||s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||
      s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="AKIHABARA"||
      s=="KIHABR"||s=="KIHABAR"||s=="KIHABRA"||s=="KIHABARA"||s=="KIHBAR"||
      s=="KIHBRA"||s=="KIHBARA") cout<<"YES"<<endl;
  	else cout<<"NO"<<endl;
}


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

int display(int n, int a[])
{
  for (int i = 0; i < n - 1; i++)
  {
    cout << a[i] << " ";
  }
  cout << a[n - 1] << endl;

  return 0;
}

int bubbleSort(int n, int a[])
{
  // 未整列要素が残っている
  bool flag = true;

  // 未整列部分の先頭のインデックス
  // 初期値は 0
  int i = 0;

  int count = 0;

  int tmp;
  while (flag)
  {
    // もし内側のループが完了しているなら、フラグは false のままで、ソートは終了する
    flag = false;
    // 配列の末尾から未整列要素の2番目までループ
    for (int j = n - 1; j >= i + 1; j--)
    {
      // 順番が逆になっている未整列要素があれば、交換
      if (a[j] < a[j - 1])
      {
        tmp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = tmp;
        // 内側で交換したら、外側のループを実行できるようフラグを true にする
        // 内側で交換しなかったら、ソートは完了しているので、この時点でソートを終了する
        flag = true;
        count++;
      }
    }
    i++;
  }

  display(n, a);
  cout << count << endl;

  return 0;
}

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

  int a[100];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  bubbleSort(n, a);

  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first 
#define se second
#define pi pair<ll,ll> 
#define pb push_back
#define mk make_pair
int main(){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin>>s;
  if(s[0]=='7' || s[2]=='7' || s[1]=='7')
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


template<unsigned int N> struct IsPrime {
	static const int size=(N>>5) + 1;
	unsigned int is_prime[size];
	constexpr IsPrime() : is_prime() {
		is_prime[0]=0x3;
		for(unsigned int i=2;i<N;i++)
		{
			if((is_prime[i>>5] & (1u<<(i&0x1f))) > 0)  continue;
			for(int j=i+i;j<N;j+=i)
				is_prime[j>>5]|=(1u<<(j&0x1f));
		}
	}
	constexpr bool operator[] (const int p) const
	{
		return (is_prime[p>>5] & (1u<<(p&0x1f))) == 0;
	}
};

template<int N> struct LikelyPrime {
	unsigned short sum[N+1];
	constexpr LikelyPrime(const IsPrime<N> pr) : sum() {
		for(int i=3;i<N;i++)
			sum[i+1]=sum[i]+(unsigned short)((pr[i] && pr[(i+1)/2])?1:0 );
	}
};

int main()
{
	io_speedup();
	constexpr IsPrime<100001> pr;
	constexpr LikelyPrime<100001> s(pr);
	int q;cin>>q;
	REP(i,q)
	{
		int l,r;
		cin>>l>>r;
		cout<<s.sum[r+1]-s.sum[l]<<endl;
		//print(s.sum[r+1]-s.sum[l]);
	}
}


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

int main(){
    string a, b, c;

    cin >> a >> b >> c;

    if((a[a.size()-1] == b[0]) & (b[b.size()-1]==c[0])){
        cout << "YES" << "\n";
    }else{
        cout << "NO" << "\n";
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;

int main(){
	int q=1;
	//cin>>q;
	while(q--){
		int n,m;
		cin>>n>>m;
		int sum=0;
		for(int i=0;i<m;i++){
			int x;cin>>x;
			sum+=x;
		}

		if(sum>n)
			cout<<-1<<endl;
		else
			cout<<n-sum<<endl;
	}
   
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

#define MAX_N 10000

queue<int>Q;

int n;
string S, T;
int C[MAX_N];
int used[MAX_N];
string GR[MAX_N];
vector<int>Y[MAX_N];
vector<string>X[MAX_N];
vector<string>P;
vector<string>B;

int main() {
	while (true) {
		//memset.
		S = ""; T = "";
		P.clear();
		B.clear();
		for (int i = 0; i<MAX_N; i++) {
			used[i] = 0;
			C[i] = 0;
			X[i].clear();
			Y[i].clear();
			GR[i] = "";
		}

		//cin.
		cin >> n;
		if (n == 0) {
			break;
		}
		for (int i = 0; i < n; i++)
		{
			cin >> S;
			int cnt = 0; T = "";
			for (int j = 0; j < S.size(); j++)
			{
				if (S[j] == ':' || S[j] == ',' || S[j] == '.')
				{
					if (cnt == 0) {
						cnt++;
						GR[i] = T;
					}
					else {
						X[i].push_back(T);
					}
					T = "";
				}
				else {
					T += S[j];
				}
			}
		}

		//kaiseki.
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < X[i].size(); j++) {
				P.push_back(X[i][j]);
			}
		}

		sort(P.begin(), P.end());
		int cnt2 = 0;
		for (int i = 0; i < P.size(); i++) {
			int d1 = 0;
			for (int j = 0; j < n; j++) {
				if (P[i] == GR[j]) {
					d1 = 1;
				}
			}
			if (d1 == 0) {
				if (i == 0) {
					B.push_back(P[i]);
				}
				if (i >= 1) {
					if (P[i - 1] != P[i]) {
						cnt2++;
						B.push_back(P[i]);
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < X[i].size(); j++) {
				for (int k = 0; k < n; k++) {
					if (GR[k] == X[i][j]) {
						Y[i].push_back(MAX_N + k);
					}
				}
				for (int k = 0; k < B.size(); k++) {
					if (B[k] == X[i][j]) {
						Y[i].push_back(k);
					}
				}
			}
		}

		//bfs.
		used[0] = true;
		for (int i = 0; i<Y[0].size(); i++) {
			if (Y[0][i] >= MAX_N) {
				used[Y[0][i] - MAX_N] = 1;
				Q.push(Y[0][i] - MAX_N);
			}
		}
		while (!Q.empty()) {
			int p1 = Q.front();
			Q.pop();
			for (int i = 0; i<Y[p1].size(); i++) {
				if (Y[p1][i] >= MAX_N) {
					if (used[Y[p1][i] - MAX_N] == 0) {
						used[Y[p1][i] - MAX_N] = 1;
						Q.push(Y[p1][i] - MAX_N);
					}
				}
			}
		}

		//calc.
		for (int i = 0; i < n; i++) {
			if (used[i] == 1) {
				for (int j = 0; j < Y[i].size(); j++) {
					if (Y[i][j] < MAX_N) {
						C[Y[i][j]] = 1;
					}
				}
			}
		}

		int res = 0;
		for (int i = 0; i < MAX_N; i++) {
			res += C[i];
		}
		cout << res << endl;
	}
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    string input;
    cin >> input;
    for (int i = 0; i < input.length(); i++)
    {
        char c = input[i];
        c = (c + N);
        if (c > 'Z')
        {
            c = c - 'Z' + 'A' - 1;
        }
        cout << (char)c;
    }
    cout << endl;
}


Measured memory_bytes: 256
/*******************************
Author:galaxy yr
LANG:C++
Created Time:2019年01月29日 星期二 08时03分27秒
*******************************/
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=505;
int n,m,a[maxn][maxn],b[maxn][maxn],c;
char ch;
void print(int a[][505])
{
        for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=m;j++)
                        cout<<a[i][j]<<' ';
                cout<<endl;
        }
        return;
}
int main()
{
       // freopen("AND_Grid.in","r",stdin);
      //  freopen("AND_Grid.out","w",stdout);
        cin>>n>>m;
        for(int i=1;i<=n;i++)
                for(int j=1;j<=m;j++)
                {
                        cin>>ch;
                        if(ch=='#')b[i][j]=1;
                }
        c=1;
        //print(b);
        for(int i=1;i<=n;i++,c=!c)
                for(int j=2;j<=m-1;j++)
                        a[i][j]=c;
        for(int i=1;i<=n;++i) a[i][1]=1;
        //print(a);
        for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=m;j++)
                {
                        if(a[i][j] or b[i][j])
                                cout<<'#';
                        else cout<<'.';
                }
                cout<<endl;
        }
        cout<<endl;
        for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=m;j++)
                {
                        if(a[i][j]==0 or b[i][j])
                                cout<<'#';
                        else cout<<'.';
                }
                cout<<endl;
        }
        return 0;
}


Measured memory_bytes: 2688
MOD = 10**9+7

S = input()
N = len(S)
dp = [[0]*4 for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    s = S[i]
    for j in range(4):
        if s == "?":
            dp[i+1][j] += dp[i][j]*3%MOD
        else:
            dp[i+1][j] += dp[i][j]%MOD
        if j < 3 and (s == "?" or s == "ABC"[j]):
            dp[i+1][j+1] += dp[i][j]%MOD
print(dp[N][3]%MOD)


Measured memory_bytes: 29524
import sys
def d(o):
 m=o[-2]/sum(o[-2:])
 l=sum(o[:-2])
 p=lambda x:(sum(o[:x])/l)
 for i in range(1,len(o[:-2])+1):
  if p(i)>=m:return i

l=[list(map(int,t.split(","))) for t in sys.stdin]
[print(i) for i in [d(o) for o in l]]


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


int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    if (s1.at(s1.size()-1) == s2.at(0) && s2.at(s2.size()-1) == s3.at(0)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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 (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {

    int n;
    cin >> n;
    vector<ll> a(3 * n, 0);
    REP(i, a.size()) cin >> a[i];
    
    ll ante = 0, post = 0;
    vector<ll> cante(n+1, 0);
    vector<ll> cpost(n+1, 0);
    priority_queue<ll, vector<ll>, greater<ll>> qante;
    priority_queue<ll> qpost;
    REP(i, n * 2) {
        ante += a[i];
        qante.push(a[i]);
        if (i >= n) {
            ante -= qante.top();
            qante.pop();
        }
        if (i >= n-1) {
            cante[i-n+1] = ante;
        }
    }
    REP(i, n * 2) {
        post += a[3*n - i - 1];
        qpost.push(a[3*n - i - 1]);
        if (i >= n) {
            post -= qpost.top();
            qpost.pop();
        }
        if (i >= n-1) {
            cpost[2*n - i - 1] = post;
        }
    }

    ll ans = 1ll << 63;
    REP(i, n+1) {
        chmax(ans, cante[i] - cpost[i]);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> f(n, 0);
  rep(i, n){
    int add = 0;
    int co = 1;
    rep(j, 10){
      int a;
      cin >> a;
      if(a == 1) add += co;
      co *= 2;
    }
    f.at(i) = add;
  }
  vector<vector<int>> p(n, vector<int>(11));
  rep(i, n){
    rep(j, 11){
      int a;
      cin >> a;
      p.at(i).at(j) = a;
    }
  }
  int ans = -1001001001;
  rep2(bit, 1, 1 << 10){
    int add = 0;
    rep(i, n){
      int co = 0;
      int now = bit & f.at(i);
      rep(bit2, 10){
        if((now & (1 << bit2)) != 0) co++;
      }
      add += p.at(i).at(co);
    }
    ans = max(ans, add);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    sort(all(vec));
    double ans=INF;
    int a;
    cout<<vec.back()<<" ";
    REP(i,n-1){
        if(abs((double)vec[i]-(double)vec.back()/2)<ans){
            ans=abs(vec[i]-vec.back()/2);
            a=vec[i];
        }
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

int main(){
  int i,type,j,x;
  char str[9];
  while(scanf("%s",str)!=EOF){
    type=0;
    for(i=0;i<8;i++){
      if(str[i]=='1'){
	x=i;
	if(i+1<8&&str[i+1]=='1'){
	  if(i+3<8&&str[i+3]=='1'){
	    printf("C\n");
	    type=3;
	  }else{
	    type=2;
	  }
	}else{
	  type=1;
	}
	break;
      }
    }
    for(i=0;i<7;i++){
      scanf("%s",str);
      for(j=0;j<8;j++){

	if(str[j]=='1'){
	  if(type==0){
	    x=j;
	    if(j+1<8&&str[j+1]=='1'){
	      if(j+3<8&&str[j+3]=='1'){
		printf("C\n");
		type=3;
	      }else{
		type=2;
	      }
	    }else{
	      type=1;
	    }
	  }else if(type==1){
	    if(x==j+1){
	      printf("D\n");
	      type=3;
	    }else if(x==j){
	      if(x+1<8&&str[x+1]=='1'){
		printf("F\n");
	      }else{
		printf("B\n");
	      }
	      type=3;
	    }
	  }else if(type==2){

	    if(x==j+1){
	      printf("G\n");
	    }else if(x==j){
	      printf("A\n");
	    }else{
	      printf("E\n");
	    }
	    type=3;
	  }
	  break;
	}
      }
    }
  }
  return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

char s[maxn];

void solve() {
    int n;
    cin >> n;
    cin >> s + 1;
    int l = 1, r = n, res = 0;
    while (l < r) {
        while (l <= n && s[l] == 'R') l++;
        while (r >= 1 && s[r] == 'W') r--;
        if (l < r) swap(s[l],  s[r]), res++;
    }
    cout <<  res << endl;
}

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


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main()
{
string input;
int sum=0;
for(int i=1;i<=10000;i++)
{cin >> input;
if(input!="0")
{for(int i=0;i<=input.length()-1;i++)
{sum=sum+int(input[i])-48;}
cout << sum << endl;
sum=0;
}
}
}


Measured memory_bytes: 3156
N = int(input())
lst = [1] + [int(input()) for _ in range(N)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def lcm(x, y):
    return x * y // gcd(max(x, y), min(x, y))


ret = lcm(lst[0], lst[1])
for x in lst[2:]:
    ret = lcm(ret, x)
print(ret)


Measured memory_bytes: 3064
N, M = map(int, input().split())

s_list = []

for i in range(M):
    s = list(map(int, input().split()))
    s.pop(0)

    s_list.append(s)

p = list(map(int, input().split()))

on_off_list = [0] * N


def rec(index_on_off):

    if index_on_off == N:

        all_on = True

        for index_m in range(M):

            on_count = 0

            for s_value in s_list[index_m]:
                if on_off_list[s_value - 1] == 1:
                    on_count += 1

            if (on_count % 2) != p[index_m]:
                all_on = False

        if all_on:
            return 1
        else:
            return 0

    counter = 0

    on_off_list[index_on_off] = 0
    counter += rec(index_on_off + 1)

    on_off_list[index_on_off] = 1
    counter += rec(index_on_off + 1)

    return counter


print(rec(0))


Measured memory_bytes: 42988
input_date = input()

str_date = input_date.split("/")
int_date = [int(n) for n in str_date]

if (int_date[0] <= 2019 and int_date[1] <= 4 and int_date[2] <= 30):
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    vector<int> a = {1, 3, 5, 7, 8, 10, 12};
    vector<int> b = {4, 6, 9, 11};
    int x, y;
    cin >> x >> y;
    if (find(a.begin(),a.end(),x) != a.end() && find(a.begin(),a.end(),y) != a.end())
        cout << "Yes" << endl;
    else if (find(b.begin(), b.end(), x) != b.end() && find(b.begin(), b.end(), y) != b.end())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  s.erase(s.size()-8);
  
  cout << s << "\n";

}


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

using namespace std;

int N;
int A[300][300];

int main() {
  long long dist[300][300];
  long long ans = 0;

  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%d", &A[i][j]);
      dist[i][j] = A[i][j];
    }
  }

  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      if (A[i][j] > dist[i][j]) {
        printf("-1\n");
        return 0;
      }

      bool flag = false;
      for (int k = 0; k < N; k++) {
        if (k == i || k == j) continue;
        if (A[i][j] == dist[i][k] + dist[k][j]) {
          flag = true;
        }
      }
      if (!flag) {
        ans += A[i][j];
      }
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main() {
      int A[200];
      int N, cmp=0, sum=0;
      cin >> N;
      
      for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i]%2!=0)cmp++;
      }
      
      while(cmp==0){
        for(int i=0; i<N; i++){
          A[i]/=2;
          if(A[i]%2!=0)cmp++;
        }
        sum++;
      }
      
      cout << sum << endl;
      
    }

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N+1];
		int max = 0;
		int max_id = -1;
		int min = 0;
		int min_id = -1;
		for (int i = 1; i <= N; i++) {
			a[i] = sc.nextInt();
			if (max < a[i]) {
				max = a[i];
				max_id = i;
			}
			if (min > a[i]) {
				min = a[i];
				min_id = i;
			}
		}
		if (max >= -min && max_id != -1) {
			System.out.println(2 * N - 2);
			for (int i = 1; i <= N; i++) {
				if (i == max_id) {
					continue;
				}
				System.out.println(max_id + " " + i);
			}
			for (int i = 1; i <= N - 1; i++) {
				System.out.println(i + " " + (i+1));
			}
		} else if (max <= -min && min_id != -1) {
			System.out.println(2 * N - 2);
			for (int i = 1; i <= N; i++) {
				if (i == min_id) {
					continue;
				}
				System.out.println(min_id + " " + i);
			}
			for (int i = N; i > 1; i--) {
				System.out.println(i + " " + (i-1));
			}
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int A, B, T;
    cin >> A >> B >> T;
    cout << (T / A) * B << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
using namespace std;
typedef struct aaa
{
    int a;
    int b;
} cao;

bool cmp (cao a, cao b)
{
    return a.a < b.a;
}

int main()
{
    int n, m;
    cin >> n >> m;
    
    cao ab[n];
    for (int i = 0; i < n; i++)
    {
        cin >> ab[i].a >> ab[i].b;
    }
    sort(ab, ab+n, cmp);
    long long ans = 0;
    int num = 0;
    int record = 0;
    while(num != m)
    {
        for (int i = record; i < n; i++)
        {
            if(ab[i].b > 0)
            {
                ab[i].b--;
                num++;
                ans += ab[i].a;
                record = i;
                break;
            }
        }
    }
    cout << ans << endl;

    
    return 0;
}

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

using namespace std;

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

	if (N.at(0) == N.at(1) && N.at(1) == N.at(2)) {
		cout << "Yes" << endl;
	}
	else if (N.at(1) == N.at(2) && N.at(2) == N.at(3)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3604
n = int(input())
min = n
for i in range(n+1):
    tmp = i
    sum = 0
    while tmp>0:
        sum += tmp%6
        tmp = int(tmp/6)
    tmp = n-i
    while tmp>0:
        sum += tmp%9
        tmp = int(tmp/9)
    min = sum if min>sum else min
print(min)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1 << "\n"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if (0) cerr

const double PI = 3.14159265358979323846264338327950;

void solve() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double ang = PI / 6 * h + PI / 360 * m - PI / 30 * m;
    cout << fixed << setprecision(15) << sqrt(a * a + b * b - 2 * cos(ang) * a * b);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 4120
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef double db;
const int mod = 998244353;
const int N = 2e3 + 5;
const int M = 1e3 + 5;
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll qsm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
ll k;
int a[20], tot;

void add(){
    a[0]++;
    int p=0;
    while(a[p]>9){
        a[p]-=10;
        a[p+1]++;
        tot=max(p+1,tot);
        ++p;
    }
}

int main(){
    cin>>k;
    ll n=0,m;
    while(k--){
        add();
        per(i,tot,1){
            if(a[i-1]<a[i]-1){
                per(j,i-1,0) a[j]=max(0,a[j+1]-1);
                break;
            }
            if(a[i-1]>a[i]+1){
                int p=i-1;
                while(a[p]>a[p+1]+1&&p<tot){
                    ++p;
                    a[p]++;
                }
                if(p==tot&&a[p]>9){
                    tot++;
                    a[p]-=10;
                    a[p+1]=1;
                    p=tot;
                }
                per(j,p-1,0) a[j]=max(0,a[j+1]-1);
                break;
            }
        }
    }
    per(i,tot,0) printf("%d",a[i]);
    return 0;
}
/*
1
2
3
1 2
1 3

*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 256