akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

bool dp_x[8001][2 * 8000 + 1], dp_y[8001][2 * 8001 + 1]; //1-indexed

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    s += 'T'; // sentinell
    int cnt_F = 0, cnt_T = 0, cnt_X = 0, cnt_Y = 1;
    dp_y[0][8000] = true;
    rep(i, s.size()) {
        if (s[i] == 'F') {
            ++cnt_F;
        } else {
            ++cnt_T;
            if (cnt_T % 2) {
                if (cnt_T == 1) {
                    dp_x[cnt_X][8000 + cnt_F] = true;
                    ++cnt_X;
                } else {
                    for (int j = 0; j < 16001; ++j) {
                        if (! dp_x[cnt_X - 1][j]) continue;
                        if (j - cnt_F >= 0) dp_x[cnt_X][j - cnt_F] |= dp_x[cnt_X - 1][j];
                        if (j + cnt_F < 16001) dp_x[cnt_X][j + cnt_F] |= dp_x[cnt_X - 1][j];
                    }

                    ++cnt_X;
                }
            } else {
                for (int j = 0; j < 16001; ++j) {
                    if (! dp_y[cnt_Y - 1][j]) continue;
                    if (j - cnt_F >= 0) dp_y[cnt_Y][j - cnt_F] |= dp_y[cnt_Y - 1][j];
                    if (j + cnt_F < 16001) dp_y[cnt_Y][j + cnt_F] |= dp_y[cnt_Y - 1][j];
                }

                ++cnt_Y;
            }

            cnt_F = 0;
        }
    }

    if (dp_x[cnt_X - 1][8000 + x] && dp_y[cnt_Y - 1][8000 + y]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 125696
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

const ll MAXN=100000;
ll n;
string s;
vector<char> c(MAXN);

bool check(char c0,char c1){
  bool B=true;
  c[0]=c0;
  c[1]=c1;
  FOR(i,2,n){
    if(s[i-1]=='o'&&c[i-1]=='S'||s[i-1]=='x'&&c[i-1]=='W'){
      c[i]=c[i-2];
    }
    else{
      if(c[i-2]=='W'){
        c[i]='S';
      }
      else{
        c[i]='W';
      }
    }
  }
  ll cnt=0;
  if(c[0]=='W'){
    cnt++;
  }
  if(s[0]=='x'){
    cnt++;
  }
  if(c[n-1]!=c[1]){
    cnt++;
  }
  if(cnt%2!=0){
    B=false;
  }
  if(c[n-1]=='W'){
    cnt++;
  }
  if(s[n-1]=='x'){
    cnt++;
  }
  if(c[n-2]!=c[0]){
    cnt++;
  }
  if(cnt%2!=0){
    B=false;
  }
  return B;
}
  
int main() {
  cin >> n >> s;
  if(check('S','S')){
    rep(i,n){
      cout << c[i];
    }
  }
  else if(check('S','W')){
    rep(i,n){
      cout << c[i];
    }
  }
  else if(check('W','S')){
    rep(i,n){
      cout << c[i];
    }
  }
  else if(check('W','W')){
    rep(i,n){
      cout << c[i];
    }
  }
  else{
    cout << -1;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int N;
    string S;
    cin >> N >> S;
    vector<vector<int>> idx(10);
    REP(i,N) idx[S[i]-'0'].emplace_back(i);
    int ans = 0;
    REP(i,10) REP(j,10) REP(k,10){
        int cur = -1;
        auto itr = lower_bound(idx[i].begin(), idx[i].end(), cur + 1);
        if(itr == idx[i].end()) continue;
        cur = *itr;
        itr = lower_bound(idx[j].begin(), idx[j].end(), cur + 1);
        if(itr == idx[j].end()) continue;
        cur = *itr;
        itr = lower_bound(idx[k].begin(), idx[k].end(), cur + 1);
        if(itr == idx[k].end()) continue;
        ans++;
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<"";cout<<endl
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
// #define endl '\n'

#define mod 1000000007

ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
ll sub(ll a , ll b){return (a%mod - b%mod + mod)%mod;}
ll mul(ll a, ll b){return (a%mod * b%mod)%mod;}
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll MOD){ll res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define dbg(x) cout<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;

#define upb upper_bound
#define lwb lower_bound

//end of template

int main(int argc, char const *argv[])
{
	crap;
	double n, k;
	cin >> n >> k;
	double ans = 0.0;
	for (double i = 1 ; i <= n; i++){
		if ( i >= k){
			ans += 1.0;
			continue;
		}
		int x = ceil(log2(k/i));
		ans += 1.0/poww(2LL, (ll)x);
	}

	ans /= n;
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

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

int main(void){
    int n = 0, k = 0;
    int x[101];
    int ans = 0;

    scanf("%d%d", &n, &k);

    for(int i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }

    for(int i = 0; i < n; i++){
        // Aが回収
        if(x[i] <= k / 2){
            ans += x[i] * 2;
        }else{ // Bが回収
            ans += (abs(k - x[i])) * 2;
        }
//        printf("ans = %d\n", ans);

    }

    printf("%d\n", ans);
    return 0;

} 


Measured memory_bytes: 764
def bfs(queue, visited):
    while len(queue) > 0:
        dest = queue.pop(0)
        for i in G[dest]:
            if visited[i] == -1:
                visited[i] = visited[dest] + 1
                queue.append(i)
    return visited


n,x,y = map(int, input().split())

G = {}
G[0]=[1]

for i in range(n-1):
    G[i+1] = [i]
    if i==0:
        continue
    G[i].append(i+1)
G[x-1].append(y-1)
G[y-1].append(x-1)

dis_table=[]
for i in range(n):
    visited = [-1]*n
    queue = []
    visited[i]=0
    queue.append(i)
    dis_table.append(bfs(queue, visited))

ans = [0]*(n-1)
for i in range(1,n):
    for j in range(0,i):
        ans[dis_table[i][j]-1]+=1

for i in ans :
    print(i)



Measured memory_bytes: 77788
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair<int,int> P;

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int h=N/2;
    if(d[h]-d[h-1]==0){
        cout << 0 << endl;
    }
    else{
        cout << d[h]-d[h-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 640
# 多分全探索だと思われるけども
# 2111 ~
# 2115 解法にはbit全探索を用いる.各列，行について塗るか塗らないかでbit探索をしてあげるとたかだか2**(6*2) で10**4程度の計算量に収まる
# 実装

H,W,K = map(int,input().split())
Mo = [[] for _ in range(H)]
for i in range(H):
    Mo[i] = list(input())

H_num = 2**H
W_num = 2**W
ans = 0
import copy
for i in range(H_num):
    for j in range(W_num):
        M = copy.deepcopy(Mo)
        # sumの計算をしないといけない
        dumi = i
        dumj = j
        SH = [(dumi & 2**kh)//(2**kh) for kh in range(H)]
        SW = [(dumj & 2**kw)//(2**kw) for kw in range(W)]
        num = 0
        for ih,h in enumerate(SH):
            if h == 1:
                M[ih] = ['.' for _ in range(W)]
        for iw,w in enumerate(SW):
            if w == 1:
                for k in range(H):
                    M[k][iw] = '.'
        count = 0
        for ii in range(H):
            for jj in range(W):
                if M[ii][jj] == '#':
                    count += 1
        if count == K:
            ans += 1

print(ans)




Measured memory_bytes: 9272
a, b, c = map(int, input().split())

ans = 50 * 10

for i in range(-100, 101):
  if a > i:
    ac = abs(a - i)
  else:
    ac = (abs(a - i) - 1) // 2 + 1 + abs(a - i) % 2 

  if b > i:
    bc = abs(b - i)
  else:
    bc = (abs(b - i) - 1) // 2 + 1 + abs(b - i) % 2 
    
  if c > i:
    cc = abs(c - i)
  else:
    cc = (abs(c - i) - 1) // 2 + 1 + abs(c - i) % 2 

  ans = min(ans, ac + bc + cc)
  
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>

using namespace std;

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

    int check =0;

    for(int i=0;i<3;i++){
        int a =N[i];
        if(a==55){check=1;}
    }

    if(check==1)cout << "Yes" << endl;
    if(check==0)cout << "No" << endl;

}



Measured memory_bytes: 3624
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
a_list.reverse()
index = 1
counter = 0
ans = a_list[0]

for i in range(2, n):
    ans += a_list[index]
    counter += 1
    if counter == 2:
        counter = 0
        index += 1

print(ans)


Measured memory_bytes: 31508
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9

using namespace std;
inline int read()
{
		int x = 0, f = 1; char ch = getchar();
		while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
		while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
		return x * f;
}
const int N = 2010;
int i,j,k,l,s,n,m,a[N][N],b[N][N],ans;
set<int>St;
set<int>::iterator It;
struct node 
{
	int x,v;
}q[N];
char c;
bool cmp(node x, node y) 
{
	return x.v < y.v;
}
int main() 
{
	n = read();
	m = read();
	rep(i, 1, n)
		rep(j, 1, m)
		{ 
			c = getchar();
			while (c != '#' && c != '.') c = getchar();
			if (c == '#') a[i][j] = 1;
			else a[i][j] = 0;
		}
	rep(i, 1, m) b[1][i] = m;
	rep(i, 2, n)
	{
		int j = 1;
		while (j <= m) 
		{
			int bb;
			if (a[i][j] == a[i - 1][j]) bb = 0;
			else bb = 1;
			k = j + 1;
			while (k <= m) 
			{
				if (abs(a[i][k] - a[i - 1][k]) != bb) break;
				k ++;
			}
			for (; j < k; j ++) b[i][j] = k - 1;
		}
	}
	ans = m;
	rep(i, 1, m)
	{
		rep(j, 2, n) q[j - 1].v = b[j][i], q[j - 1].x = j;
		sort(q + 1, q + n, cmp);
		for (j = 1; j < n;) 
		{
			int k = j + 1;
			int L, R;
			while (k < n && q[k].v == q[j].v) k ++;
			int ii = j;
 			for (; j < k; j ++) 
 			{
				It = St.lower_bound(q[j].x);
				if (It == St.end()) R = n;
				else R = (*It) - 1;
				if (It == St.begin()) L = 2;
				else It --, L = (*It) + 1;
				ans = max(ans, (R - L + 2) * (q[j].v - i + 1));
			}
			j = ii;
			for (; j < k; j ++) St.insert(q[j].x);
		}
		St.clear();
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 31872
A,B,C,D,E,F = map(int,input().split())
 
use_water = [] 
for i in range(0,31):
  for j in range(0,31):
    tmp = A*i + B*j
    if((tmp != 0)and(tmp <= 30)): 
      if(tmp*100 <= F):
        use_water.append(tmp)
use_water = list(set(use_water))
use_water.sort()
 
Conc = [] 
for i in range(101):
  for j in range(51):
    for k in range(len(use_water)):
      sugar = C*i + D*j
      water = use_water[k]*100
      if(sugar + water <= F):
       if(sugar <= use_water[k]*E):
        conc = sugar/(sugar + water)
        Conc.append([conc,water+sugar,sugar])
 
Conc.sort(reverse = True)
ans_water,ans_sugar = Conc[0][1],Conc[0][2]
print(ans_water,ans_sugar)

Measured memory_bytes: 9548
#include <stdio.h>
int main(){
    int n, i;
    scanf("%d", &n);
    int input, primes = 0;
    for(i = 0; i < n; i++){
        scanf("%d", &input);
        if(isPrime(input)) primes++;
    }
    printf("%d\n", primes);
}
int isPrime(int test){
    if (test==2) return 1;
    for (int i = 2; i <= test/i; i++){
        if (test%i==0) return 0;
    }
    return 1;
}



Measured memory_bytes: 2040
// inputに入力データ全体が入る
function Main(input) {
  input = input.split(' ');
  var a = parseInt(input[0]);
  var b = parseInt(input[1]);
  var c = parseInt(input[2]);
  var count = 0;
  for (var i = 1; i <= c; i++) {
    if (b < a) {
      break;
    }
    count++;
    b = b - a;
  }
  console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int x;
    cin >> x;
    int sta = x/100;
    x = sta;
    if(x >= 4 && x <= 5)cout << 8 << "\n";
    if(x >= 6 && x <= 7)cout << 7 << "\n";
    if(x >= 8 && x <= 9)cout << 6 << "\n";
    if(x >= 10 && x <= 11)cout << 5 << "\n";
    if(x >= 12 && x <= 13)cout << 4 << "\n";
    if(x >= 14 && x <= 15)cout << 3 << "\n";
    if(x >= 16 && x <= 17)cout << 2 << "\n";
    if(x >= 18 && x <= 19)cout << 1 << "\n";


    return 0;
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), ans(n);
    rep(i, n) {
        cin >> a[i];
        ans[i] = 1000000 * a[i] + i + 1;
    }
    sort(ans.begin(), ans.end());
    rep(i, n) {
        if(i != n - 1)
            cout << ans[i] % 1000000 << " ";
        else
            cout << ans[i] % 1000000 << endl;
    }
}


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

string solve(ll N){

    string res;
    ll t = 26;
    ll idx = 0;

    while(idx + t < N){
        idx += t;
        t *= 26;
    }

    idx = N - idx - 1;
    while(t > 26){
        t /= 26;
        res += (idx / t) + 'a';
        idx %= t;
    }
    
    res += (N - 1) % t + 'a';
    return res;
}

int main(){

    ll N;
    cin >> N;

    cout << solve(N);
    return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] a = new String[h][w];
        int[] counth = new int[w];// 一列ごとの.の個数
        Arrays.fill(counth, 0);
        int[] countw = new int[h];// 一行ごとの.の個数
        Arrays.fill(counth, 0);
        for (int i = 0; i < h; i++) {
            a[i][0] = sc.next();
        }
        for (int i = 0; i < h; i++) {
            a[i] = a[i][0].split("");
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (a[i][j].equals("."))
                    countw[i]++;
            }
        }
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                if (a[j][i].equals("."))
                    counth[i]++;
            }
        }
        for (int i = 0; i < h; i++) {
            if (countw[i] == w) {

            } else {
                for (int j = 0; j < w; j++) {
                    if (counth[j] == h) {

                    } else {
                        System.out.print(a[i][j]);
                    }
                }
                System.out.println();
            }
        }
    }
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

void set_bingo(int x){
    for(int i =0; i < 3; i++){
        for(int j= 0; j < 3; j++){
            if(a[i][j] == x){
                bingo[i][j] = true;
            }
        }
    }
}
bool is_bingo(void){

    if(bingo[0][0]==true && bingo[0][1]==true && bingo[0][2]==true){
        return true;
    }
    else if(bingo[1][0]==true && bingo[1][1]==true && bingo[1][2]==true){
        return true;
    }
    else if(bingo[2][0]==true && bingo[2][1]==true && bingo[2][2]==true){
        return true;
    }
    else if(bingo[0][0]==true && bingo[1][0]==true && bingo[2][0]==true){
        return true;
    }
    else if(bingo[0][1]==true && bingo[1][1]==true && bingo[2][1]==true){
        return true;
    }
    else if(bingo[0][2]==true && bingo[1][2]==true && bingo[2][2]==true){
        return true;
    }
    else if(bingo[0][0]==true && bingo[1][1]==true && bingo[2][2]==true){
        return true;
    }
    else if(bingo[0][2]==true && bingo[1][1]==true && bingo[2][0]==true){
        return true;
    }
    else{
        return false;
    }
}
int main(){
    for(int i =0; i < 3; i++){
        for(int j= 0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    for(int i =0; i < 3; i++){
        for(int j= 0; j < 3; j++){
            bingo[i][j] = false;
        }
    }    
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        set_bingo(b);
    }
    if(is_bingo()) cout << "Yes" << endl;
    else cout <<"No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a[10001]={};
    int count=0;
    
   for(int i=0;i<10001;i++){
     cin>>a[i];
       count++;
      if(a[i]==0)break;
   }
    
    for(int j=0;j<count-1;j++){
        cout<<"Case "<<j+1<<": "<<a[j]<<endl;
    }
}

Measured memory_bytes: 3116
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
p = 10**9 + 7
ans = 0
for i in range(60):
  c = np.count_nonzero(a & 1)
  ans = (ans + c*(n-c)*2**i) % p
  a = a >> 1
print(ans)

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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    X += (D - 1) / a + 1;
  }
  cout << X << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val(a, b) = readListOfInt()
    val ans = a - 1 + if(a <= b) 1 else 0
    println(ans)
    
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 35956
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (((100*a+10*b+c)%4==0) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int    n, rslt;
        int[]  d = new int[101];

        n   = int.Parse(Console.ReadLine());    /* 標準入力                          */

        for(int cnt = 0; cnt < n; cnt++){
            d[int.Parse(Console.ReadLine())]++;
        }

        rslt = 0;
        for(int cnt = 100; cnt >= 0; cnt--){
            if(d[cnt] != 0){
                rslt++;
            }
        }

        Console.WriteLine("{0}", rslt);     /* 改行付き出力 */
    }
}


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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int A, B,C,D;
        private void Scan()
        {
            var sc = new Scanner();
            A = sc.NextInt();
            B = sc.NextInt();
            C = sc.NextInt();
            D = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            var c = (A + B).CompareTo(C + D);
            switch(c)
            {
                case 1:
                    Console.WriteLine("Left");
                    break;
                case 0:
                    Console.WriteLine("Balanced");
                    break;
                case -1:
                    Console.WriteLine("Right");
                    break;
            }
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 11092
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
N=int(a[0])
L=int(a[1])


if L>=0 :
    X=N*L+N*(N-1)*0.5-L
    print(int(X))
else:
    if abs(L)>=N:
        X=N*L+N*(N-1)*0.5-(L+N-1)
        print(int(X))
    else:
        X=N*L+N*(N-1)*0.5
        print(int(X))


Measured memory_bytes: 3064
n = list(map(int, input().split(' ')))
n.sort()
n1 = n[0]
n2 = n[3]
n3 = n[2]
n4 = n[1]
if n1 == 1 and n2 == 9 and n3 == 7 and n4 == 4:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9104
// AOJ Volume 0 Problem 0013

#include <stdio.h>

int main(void)
{
    int s;
    int d;
    int x;

    while (scanf("%d", &d) != EOF){
        s = 0;
        for (x = 0; x < 600; x += d){
            s += x * x * d;
        }

        printf("%d\n", s);
    }
        
    return (0);
}

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

int main () {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  vector<int64_t> M(N);
  for (int i = 0; i < N; i++) {
    int l = -1;
    int r = N;
    while (r - l > 1) {
      int mid = (l + r) / 2;
      if (A.at(mid) < B.at(i)) {
        l = mid;
      }
      else {
        r = mid;
      }
    }
    M.at(i) = (l + 1);
  }
  int64_t ans = 0;
  for (int i = 0; i < N; i++) {
    int l = -1;
    int r = N;
    while (r - l > 1) {
      int mid = (l + r) / 2;
      if (C.at(mid) > B.at(i)) {
        r = mid;
      }
      else {
        l = mid;
      }
    }
    ans += (M.at(i) * (N - r));
  }
  cout << ans << endl;
}

Measured memory_bytes: 5088
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    ans = 1
    for i in d.keys():
        ans *= d[i]+1
        ans %= mod
    print(ans-1)
#B
def B():
    n = I()
    c = IR(n)
    v = [[i+1] for i in range(n-1)]
    v.append([])
    d = defaultdict(deque)
    for i in range(n):
        d[c[i]].append(i)
    for i in d.keys():
        x = None
        while d[i]:
            y = d[i].popleft()
            if x != None and y != x+1:
                v[x].append(y)
            x = y
    path = [0]*(n)
    path[0] = 1
    q = [0]
    while q:
        x = heappop(q)
        for y in v[x]:
            if path[y] == 0:
                heappush(q,y)
            path[y] += path[x]
            path[y] %= mod
    print(path[-1])
#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 192116
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  vector<int> A(N-1);
  
  for(int i = 0; i < N - 1; i++){
    cin >> A.at(i);
  }
  
  vector<int> count(N);
  for(int i = 0; i < N; i++){
    count.at(i) = 0;
  }
  
  int num = 0;
  for(int i = 0; i < N - 1; i++){
    num = A.at(i);
    count.at(num - 1)++;
  }
  
  for(int i = 0; i< N; i++){
    cout << count.at(i) << endl;
  }
}
    
    




Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef tuple<int,int,int> TP;
constexpr int INF = 2e9;

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  vector<vector<int>> g(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  rep(i,n) cin >> c[i];
  sort(c.begin(), c.end(), greater<int>());
  int sum = accumulate(c.begin() + 1, c.end(), 0);

  queue<P> que;
  vector<P> res;
  que.push(make_pair(0, -1));
  int id = 0;
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    int u = p.first;
    int par = p.second;
    res.emplace_back(make_pair(u, c[id]));
    id++;
    for (auto v : g[u]) {
      if (v == par) continue;
      que.push(make_pair(v, u));
    }
  }
  sort(res.begin(), res.end());
 
  cout << sum << endl;
  for (auto e : res) {
    cout << e.second << " ";
  }
  cout << endl;
  return 0;
} 

Measured memory_bytes: 4168
#include <cstdio>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
int main() {
    int n; scanf("%d", &n);
    vector<int> a(n); repeat (i,n) scanf("%d", &a[i]);
    whole(sort, a);
    int n_unique = whole(unique, a) - a.begin();
    int n_duplicated = n - n_unique;
    int ans = n_unique - (n_duplicated % 2 == 0 ? 0 : 1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int A[1000000], n;

/*二分探索*/
int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1; /*keyを発見*/
		if (key > A[mid]) left =  mid + 1; /*後半を探索*/
		else if (key < A[mid]) right = mid; /*前半を探索*/
	}
	return 0;
}

int main(){
	int i, q, k, sum = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &k);
		if ( binarySearch( k ) ) sum++;
	}
	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 2104
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

long long solve(long long x, long long k, long long d) {
	x = abs(x);
	if (k == 0) {
		return x;
	}
	if (k % 2 == 1) {
		return min(solve(x - d, k - 1, d), solve(x + d, k - 1, d));
	}
	d *= 2;
	k /= 2;
	if (x / k >= d) {
		return x - d * k;
	}
	x %= d;
	return min(x, d - x);
}
int main()
{
	std::ios::sync_with_stdio(false);
	long long x, k, d;
	cin >> x >> k >> d;
	cout << solve(x, k, d) << endl;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 60
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

int main() {
	optimizar_io
	int n, k; cin >> n >> k;
	vector<int> v(n);
	fore(i, 0, n) cin >> v[i];
	sort(v.begin(), v.end());
	int sum = 0;
	fore(i, 0, k) sum += v[i];
	cout << sum << endl;
}

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

const long long INF = 1LL << 60;
const ll MOD = ll(1e9)+7;

bool has_key(unordered_map<string, ll> &m, string s){
    if (m.find(s) == m.end()){
        return false;
    }
    else{
        return true;
    }
}


bool vector_find(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}


void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}


int main() {

  ll N;

  cin >> N;

  ll tmp = 0;
  vector<ll> vec_sum(12, 0);
  for (ll i = 1; i <= 11; i++) {
    tmp += pow(26, i);
    vec_sum.at(i) = tmp;
  }

  string ans = "";


  vector<string> alphabet{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};


  ll div_tmp;

  for (ll i = 1; i <= 11; i++) {
    
    if (N <= vec_sum.at(i)) {
      N -= vec_sum.at(i-1);
      N -= 1;

      for (ll j = 0; j < i; j++) {
        ans += alphabet.at(N%26);
        N = N / 26;
      }

      break;
    }

  }
  

  reverse(ans.begin(), ans.end());


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4080
#include <stdio.h>

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  if (n > 1 && m > 1) {
    printf("%ld\n", (n-2)*(m-2));
  } else if (n > 1) {
    printf("%ld\n", n-2);
  } else if (m > 1) {
    printf("%ld\n", m-2);
  } else {
    printf("1\n");
  }

  return 0;
}

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

int partition(int A[], int p, int r)
{
	int i,j,x,temp;
	
	x=A[r];
	i=p-1;
	for(j=p;j<=r-1;j++)
	{
		if(A[j]<=x)
		{
			i++;
			temp=A[j];
			A[j]=A[i];
			A[i]=temp;
		}
	}
	temp=A[r];
	A[r]=A[i+1];
	A[i+1]=temp;
	return i+1;
}

int main()
{
	int i,n,j,k=0;
	int A[100000];
	
	scanf("%d",&n);
	for(i=0;i<=n-1;i++) scanf("%d",&A[i]);
	j=partition(A,0,n-1);
	for(i=0;i<=n-1;i++)
	{
		if(i>0) printf(" ");
		if(i==j) printf("[%d]",A[i]);
		else printf("%d",A[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3524
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int can_win(vector<int> fst, vector<int> snd, int l, int r, int pass = 0) {
    if(!fst.size()) return true;
    if(pass == 2) return -1;

    bool exist_neg = false;
    vector<int> res;
    
    for(size_t i=0; i<fst.size(); i++) {
        int v = fst[i];
        bool ok = false;
        ok |= (l - 1 == v);
        ok |= (r + 1 == v);
        if(ok) {
            vector<int> nfst = snd, nsnd;
            for(size_t k=0; k<fst.size(); k++) {
                if(fst[k] != v) nsnd.emplace_back(fst[k]);
            }
            int nl = min(l, v), nr = max(r, v);
            int a = can_win(nfst, nsnd, nl, nr, 0);
            if(a < 0) exist_neg = true;
            else res.emplace_back(a);
        }
    }

    int ans_val = -1;
    if(res.size() or exist_neg) {
        if(exist_neg) {
            ans_val = 0;
            for(auto e : res) ans_val |= !e;
        }
        else {
            ans_val = 0;
            for(auto e : res) ans_val |= !e;
        }
    }
    else {
        int a = can_win(snd, fst, l, r, pass + 1);
        if(a < 0) ans_val = -1;
        ans_val = !a;
    }
    return ans_val;
}

void solve() {
    vector<int> fst(6);
    for(int i=0; i<6; i++) cin >> fst[i];
    sort(fst.begin(), fst.end());

    vector<int> snd;
    for(int i=1; i<=13; i++) {
        if(i == 7) continue;
        bool found = false;
        for(int k=0; k<6; k++) found |= (fst[k] == i);
        if(!found) snd.push_back(i);
    }

    int r = can_win(fst, snd, 7, 7);
    cout << (r <= 0 ? "no" : "yes") << endl;
}

int main() {
    int N; cin >> N;
    while(N--) solve();
    return 0;
}



Measured memory_bytes: 3128
#include <stdio.h>

int main()
{
    int h, w;

    while (scanf("%d %d", &h, &w))
    {
        bool ok = true, go = false;

        if (h == 0 && w == 0)
            break;

        for (int i = 0; i < h; i++)
        {
            if (ok)
            {
                go = true;
                for (int j = 0; j < w; j++)
                {
                    if (go)
                    {
                        printf("#");
                        go = false;
                    }
                    else
                    {
                        printf(".");
                        go = true;
                    }
                }
                printf("\n");
                ok = false;
            }
            else
            {
                go = true;
                for (int j = 0; j < w; j++)
                {
                    if (go)
                    {
                        printf(".");
                        go = false;
                    }
                    else
                    {
                        printf("#");
                        go = true;
                    }
                }
                printf("\n");
                ok = true;
            }
        }
        printf("\n");
        ok = true, go = false;
    }
    return 0;
}


Measured memory_bytes: 2604
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInt()
	b := scanInt()
	c := scanInt()
	l := scanInts(n)

	ans := 1 << 31-1

	bitExhaustiveSearch(n,func(a1 []int) {
		bitExhaustiveSearch(n, func(a2 []int) {
			nabc := [4]int{}
			cost := 0
			for i := 0; i < n; i++ {
				d := a1[i]*2+a2[i]
				if nabc[d] != 0 && d!=0 {
					cost += 10
				}

				nabc[d] += l[i]
			}

			if nabc[1]==0||nabc[2]==0||nabc[3]==0 {
				return
			}
			cost += abs(a-nabc[1])+abs(b-nabc[2])+abs(c-nabc[3])
			ans = min(ans, cost)
		})
	})

	fmt.Fprintln(wr, ans)
}

func bitExhaustiveSearch(n int, fn func(a []int)) {
	all := 1 << uint(n)
	a := make([]int, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = 1 } else {a[j] = 0 }
		}
		fn(a)
	}
}


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

int main(){

   char arr[6];
   
for(int i = 0 ; i < 6 ; i++){

    cin>>arr[i];
}

     
     if(arr[2] == arr[3]  && arr[4] == arr[5]){
         cout<<"Yes";
     }

     else{
         cout<<"No";
     }

     return 0;
}

Measured memory_bytes: 256
import itertools

def main():
  n, m, q = map(int,input().split())
  ans_li = []
  li = []
  for i in range(q):
    a, b, c, d = map(int,input().split())
    li.append([a,b,c,d])
  
  for i in itertools.combinations_with_replacement(range(1,m+1), n):
    ans = 0
    for j in li:
      if i[j[1]-1] - i[j[0]-1] == j[2]:
        ans += j[3]
    ans_li.append(ans)
  print(max(ans_li))

if __name__ == '__main__':
  main()

Measured memory_bytes: 12688
n = int(input())
a = list(map(int,input().split()))
mn = min(a)
mx = max(a)+1
ans = 10**9
for i in range(mn, mx):
  cost = 0
  for aa in a:
    cost += (i - aa)**2
  if ans > cost:
    ans = cost
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
#define ds(q) scanf("%lld",&q)
pair<ll,ll>ans[100005];
int main()
{
    ll n;
    ds(n);
    for(ll i=0; i<n; i++)
    {
        ds(ans[i].first);
        ans[i].second=i;
    }
    sort(ans,ans+n);
    for(ll i=0; i<n; i++)
    {
        if(i!=0)
            printf(" ");
        printf("%lld",ans[i].second+1);
    }
    return 0;

}


Measured memory_bytes: 2432
def nx(chr)
    if chr == 'z'
        'a'
    else
        (chr.ord + 1).chr
    end
end


def dif(chr)
    if chr == 'a'
        0
    else
        ('z'.ord - chr.ord) + 1
    end
end

ans = ''
s = gets.chomp.chars
k = gets.to_i

s.each_with_index {|c, i|
    if i == s.size - 1
        d = c
        k %= 26
        while k > 0
            k -= 1
            d = nx(d)
        end
        ans += d
    elsif dif(c) <= k
        ans += 'a'
        k -= dif(c)
    else
        ans += c
    end
}

puts ans


Measured memory_bytes: 94988
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()

from itertools import accumulate
Acumsum = list(accumulate(A))

i=0
while i<N:
  if Acumsum[i] <= x:
    i+=1
  else:
    break

if i==N and Acumsum[-1]!=x:
    print(N-1)
else:
    print(i)

Measured memory_bytes: 3060
A, B = map(int,input().split())
mi = 10 * B - 1
x = 0
ma = 15 * B + 1


while x == 0:
    if int(mi * 0.08) == A and int(mi * 0.1) == B:
        x = 1
    elif mi == ma:
        x = 1
        mi = -1
    else:
        mi += 1
print(mi)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
int n,x,a[150],d,sum,k,s;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>d>>x;
for(int i=1;i<=n;i++){
    cin>>a[i];
}
for(int i=1;i<=n;i++){
        for(int j=1;j<=d;j++){
            sum=0;
    sum+=(j*a[i]+1);
    if(sum<=d)k++;
}}
s+=k;
s+=n;
s+=x;
cout<<s;

return 0;}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {

  int A, B, H, M;
  cin >> A >> B >> H >> M;

  const double PI=3.14159265358979323846;
  double Hdeg = 2 * PI * (H + M / 60.0) / 12.0;
  double Mdeg = 2 * PI * M / 60.0;

  double deg = min(abs(Hdeg - Mdeg), 2 * PI - abs(Hdeg - Mdeg));
  double ans = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(deg));

  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 4104
(defun count-happy-people (s)
  (labels ((inner (s &optional (cnt 0))
             (cond
               ((null (cdr s)) cnt)
               ((char-equal
                 (first s)
                 (second s))
                (inner (rest s) (1+ cnt)))
               (t
                (inner (rest s) cnt)))))
    (inner s)))

(defun solve (n k s)
  (let ((start (count-happy-people s)))
    (min (+ start (* k 2))
         (1- n))))


(defun main ()
  (let* ((n (read))
         (k (read))
         (s (concatenate 'list (read-line))))
    (format t "~a~%" (solve n k s))))

(main)

Measured memory_bytes: 27232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl

typedef long long ll;

ll mod = 1e9+7;  // 1e9+9

ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}
ll mpow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll divi(ll x,ll y){return mul(x,mpow(y,mod-2));}
ll fact[10000000]={1}, factc=0;
ll Fact(ll x){
  while( factc < x ){
    factc++;
    fact[factc]=mul( fact[factc-1] , factc );
  }
  return fact[x];
}

ll nCr(ll n,ll r){
  return divi( Fact(n) , mul( Fact(n-r) , Fact(r) )   );
}
ll nHr(ll n,ll r){
  return nCr( n+r-1 , n-1 );
}
int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    rep(i,0,min(n-1,k)){
        ans+=nCr(n,i)*nHr(n-i,i)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}


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

#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

ofstream outfile;
ifstream infile;
int main()
{
	infile.open("input.txt");
	outfile.open("output.txt");

	fastIO;
	int n, i, t, u, v, q, k, j;
	lli c, sum = 0;


	vector <vector <pair <int, lli>>> graph;
	vector <pair <int, lli>> temp;
	cin >> n;

	for(i = 0; i <= n; ++i)
		graph.pb(temp);


	for(i = 1; i < n; ++i){
		cin >> u >> v >> c;
		graph[u].pb(MP(v, c));
		graph[v].pb(MP(u, c));
	}

	//cout << "ok?";
	cin >> q >> k;

	queue <int> myq;
	myq.push(k);
	vector <lli> dist;
	vector <bool> visited;

	for(i = 0; i <= n; ++i){
		dist.pb(0);
		visited.pb(0);
	}

	while(!myq.empty()){

		t = myq.front();
		myq.pop();

		for(j = 0; j < graph[t].size(); ++j){
			if(!visited[graph[t][j].fi] ){

				visited[graph[t][j].fi] = 1;

				dist[graph[t][j].fi] = dist[t] + graph[t][j].se;

				myq.push(graph[t][j].fi);
			}
		}
	}

	for(i = 0; i < q; ++i){
		cin >> u >> v;
		cout << dist[u] + dist[v] << "\n";
	}
}

Measured memory_bytes: 11376