akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const P dx[4] = {P(0,0),P(0,0),P(-1,1),P(1,-1)};
const P dy[4] = {P(1,1),P(-1,-1),P(0,0),P(0,0)};
bool bmap[55][55][55][55];
char L_cmap[51][51],R_cmap[51][51];
int main(){
  int H,W;
  while(cin >> W >> H && H+W){
   
    P Ls,Rs,Lg,Rg;
    rep(i,55)
      rep(j,55)
        rep(k,55)
          rep(l,55)
            bmap[i][j][k][l] = false;
   
    rep(i,H){
      string s;
      cin >> s;
      rep(j,W){
	L_cmap[i][j] = s[j];
	if(s[j] == 'L')Ls = P(j,i);
	if(s[j] == '%')Lg = P(j,i);
      }
      s.clear();
      cin >> s;
      rep(j,W){
	R_cmap[i][j] = s[j];
	if(s[j] == 'R')Rs = P(j,i);
	if(s[j] == '%')Rg = P(j,i);
      }
    }
  
    queue<PP> que;
    que.push(PP(Ls,Rs));
    bmap[Ls.F][Ls.S][Rs.F][Rs.S] = true;
    bool fin = false;
    while(!que.empty())
      {
	PP pp = que.front(); que.pop();
	if(pp.F == Lg && pp.S == Rg){
	  fin = true;
	  cout << "Yes" << endl;
	  break;
	}
	if(pp.F == Lg || pp.S == Rg)continue;

	rep(i,4){
	  int L_nx = pp.F.F+dx[i].F,L_ny = pp.F.S+dy[i].F;
	  int R_nx = pp.S.F+dx[i].S,R_ny = pp.S.S+dy[i].S;
	  if(!(0<= L_nx & L_nx < W && 0<= L_ny && L_ny < H) || L_cmap[L_ny][L_nx] == '#'){
	    L_nx = pp.F.F,L_ny = pp.F.S;
	  }
	  if(!(0<= R_nx & R_nx < W && 0<= R_ny && R_ny < H) || R_cmap[R_ny][R_nx] == '#'){
	    R_nx = pp.S.F,R_ny = pp.S.S;
	  }
	  if(bmap[L_nx][L_ny][R_nx][R_ny])continue;
	  bmap[L_nx][L_ny][R_nx][R_ny] = true;
	 
	  que.push(insert(L_nx,L_ny,R_nx,R_ny));
	}
      }
    if(!fin)cout << "No" << endl;
    
  }
return 0;
}

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

int main() {
  std::string S;
  std::cin >> S;

  int Q;
  std::cin >> Q;

  std::string buf_front;
  std::string buf_back;

  buf_front.reserve(Q);
  buf_back.reserve(Q);

  bool forward = true;

  for (int q=0; q<Q; q++) {
    int T;
    std::cin >> T;

    if (T==1) {
      forward = ! forward;
    } else {
      int F;
      char c;
      std::cin >> F >> c;
      if (F == 1) {
        if (forward) {
          buf_front.push_back(c);
        } else {
          buf_back.push_back(c);
        }
      } else {
        if (! forward) {
          buf_front.push_back(c);
        } else {
          buf_back.push_back(c);
        }
      }
    }
  }

  if (forward) {
    for (auto it=buf_front.rbegin(); it !=buf_front.rend(); it++)
      std::cout << *it;
    for (auto it=S.begin(); it !=S.end(); it++)
      std::cout << *it;
    for (auto it=buf_back.begin(); it !=buf_back.end(); it++)
      std::cout << *it;
  } else {
    for (auto it=buf_back.rbegin(); it !=buf_back.rend(); it++)
      std::cout << *it;
    for (auto it=S.rbegin(); it !=S.rend(); it++)
      std::cout << *it;
    for (auto it=buf_front.begin(); it !=buf_front.end(); it++)
      std::cout << *it;
  }

  return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  if(N == 1) {
    cout << "No" << endl;
    return 0;
  }
  if(N%2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  string S;
  cin >> S;

  int half = N / 2;
  bool flag = true;
  for(int i = 0; i < half; i++) {
    if(S[i] != S[half+i]) {
      flag = false;
      break;
    }
  }

  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MARK 4
#define RANK 13
#define CHECK 1	
int main(void)
{
	int n,rank,a,i,k;
	char mark;
	int card[4]={0,0,0,0};
	char mk[4]={'S','H','C','D'};
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf(" %c %d", &mark, &rank);
		if(mark == 'S'){
			a=1;
			a <<= rank;
			card[0] += a;
		}else if(mark == 'H'){
			a=1;
			a <<= rank;
			card[1] += a;
		}else if(mark == 'C'){
			a=1;
			a <<= rank;
			card[2] += a;
		}else if(mark == 'D'){
			a=1; 
			a <<= rank;
			card[3] += a;
		}
	}
	for(i=0; i<MARK; i++){
		for(k=0; k<RANK; k++){
			card[i] >>= 1;
			if((card[i] & CHECK) == 0){
				printf("%c %d\n", mk[i], k+1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int a[52][52];
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int cnt[4];
/*  .->0  b,w,b&w->1,2,3  B,W->10,20  WALL->30  */

void paint(int y,int x,int color){
    if(a[y][x]>=3 || a[y][x]==color)return;
    cnt[a[y][x]]--;
    a[y][x] |= color;
    cnt[a[y][x]]++;
    rep(i,4)paint(y+dy[i],x+dx[i],a[y][x]);
}

int main(void){
    int h,w;
    char c;
    while(cin>>w>>h, w|h){
        rep(i,4)cnt[i]=0;
        rep1(y,h){
            rep1(x,w){
                cin>>c;
                if(c=='.')a[y][x] = 0;
                else a[y][x] = (c=='B' ? 10 : 20);
            }
        }
        rep(y,h+2) a[y][0] = a[y][w+1] = 30;
        rep(x,w+2) a[0][x] = a[h+1][x] = 30;

        rep1(y,h)rep1(x,w)if(a[y][x]>=10)rep(i,4)paint(y+dy[i],x+dx[i],a[y][x]/10);

        cout<<cnt[1]<<" "<<cnt[2]<<endl;
    }

    return 0;
}

Measured memory_bytes: 1220
while True:
    a, l = map(int, raw_input().split())
    if((a|l) == 0): break
    dic = {}
    cnt = 0
    dic[a] = cnt
    while True:
        cnt+=1
        La = list(str(a).zfill(l))
        La.sort()
        a = int(''.join(La[::-1])) - int(''.join(La))
        if a in dic:
            print dic[a], a, cnt-dic[a]
            break
        else:
            dic[a] = cnt

Measured memory_bytes: 4228
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

int f(bitset<6> a, bitset<6> b, int h,int w, vector<string> g){
    for(int i=0;i<h;i++)
        if(a[i]==1)
            for(int j=0;j<w;j++) g[i][j]='.';

    for(int j=0;j<w;j++)
        if(b[j]==1)
            for(int i=0;i<h;i++) g[i][j]='.';
    
    int ans=0;
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) ans+=(g[i][j]=='#'?1:0);
    return ans;
}

void solve(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> g(h);
    for(int i=0;i<h;i++) cin>>g[i];    
    int ans=0;
    for(int i=0;i<(1<<h);i++) for(int j=0;j<(1<<w);j++){
        bitset<6> a(i),b(j);
        ans+=(f(a,b,h,w,g)==k?1:0);
    }
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}   

Measured memory_bytes: 3656
A, B, C, X, Y = map(int, input().split())

# xn, yn = 0, 0
# price = 0
# 
# if (A+B) >= 2*C and A >= 1 and B >= 1:
#     ammount = min(X, Y)
#     price += C * ammount * 2
#     xn += ammount
#     yn += ammount
# 
# if A >= 2*C and X > xn:
#     ammount = X - xn
#     price += C * X * 2
#     xn += X
#     yn += X
# 
# if B >= 2*C and Y > yn:
#     ammount = Y - yn
#     price += C * ammount * 2
#     xn += ammount
#     yn += ammount
# 
# price += A * (X - xn)
# price += B * (Y - yn)
# 
# print(price)
# 

min_price = 1 << 32 
for i in range(max(X, Y)+1):
    xn, yn = i, i
    price = (2*C) * i
    price += (max(0, X - xn)) * A
    price += (max(0, Y - yn)) * B
    min_price = min(min_price, price)

print(min_price)

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

LL gcd(LL x,LL y){
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}


LL lcm(LL x,LL y){
    return x*y/gcd(x,y);
}

int main(void){
    LL N, M;
    string S, T;
    cin >> N >> M >> S >> T;
    LL l = lcm(N,M);
    map<LL,char> ma;
    REP(i,N){
        ma[i*(l/N)] = S[i];
    }
    REP(i,M){
        if(ma.find(i*(l/M)) == ma.end())
            ma[i*(l/M)] = T[i];
        else{
            if(ma[(LL)i*(l/M)] != T[i]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << l << endl;
    return 0;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {

    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (z < 0) continue;
            if (z > k) continue;
            ans++;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef gp_hash_table<int, int> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define sz(x) (int)(x).size()

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
int gcd(int a, int b){ return b==0 ? a : gcd(b, a%b); }
ll modpow(ll b, ll e) {
	ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans;}

const int maxn = 1000005;

ld dist (int x, int y, int x2, int y2){
	return sqrt((x-x2)*(x-x2) + (y-y2)*(y-y2));
}



void solve(){
	int n; cin>>n;
	ld z = sqrt(n);
	int x = ceil(z);
	int y = ceil(z)*ceil(z);
	int diff = y - n;
	cout<<"0 0 "<<x<<" "<<1<<" "<<diff<<" "<<x;
}

signed main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    solve();
    end_routine();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
 
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
     
    int a,b; cin>>a>>b;
    int i = a/b;
    int r = a%b;
    double f = (double)a/b;
    
    printf("%d %d %.5f\n",i,r,f);
     
    return 0;
     
}


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

int main()
{
	ios_base::sync_with_stdio(0);
	int n , l;
	cin >> n >> l;
	vector<int> len(n);
	for(auto & x : len)
		cin >> x;
	for(int i = 0; i < n - 1; i++)
	{
		if(len[i] + len[i + 1] >= l)
		{
			cout << "Possible" << endl;
			for(int j = 1; j <= i; j++)
				cout << j << endl;
			for(int j = n - 1; j >= i + 1; j--)
				cout << j << endl;
			return 0;
		}
	}
	cout << "Impossible";
	return 0;
}


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

vector<vector<int>> e;
vector<int> pa;
vector<int> d;

void dfs(int id, int depth) {
    d[id] = depth;
    for ( int i = 0; i < e[id].size(); i++ ) {
        dfs(e[id][i], depth + 1);
    }
}

int main() {
    int N;
    cin >> N;
    e.resize(N, vector<int>());
    pa.resize(N, -1);
    d.resize(N, -1);
    int k,id,c;
    for ( int i = 0; i < N; i++ ) {
        cin >> id >> k;
        for ( int j = 0; j < k; j++ ) {
            cin >> c;
            e[id].push_back(c);
            pa[c] = id;
        }
    }
    for ( int i = 0; i < N; i++ ) {
        if ( pa[i] != -1 ) continue;
        dfs(i, 0);
    }
    int r = 0;
    while ( pa[r] != -1 ) r = pa[r];

    for ( int i = 0; i < N; i++ ) {
        string type;
        if (pa[i] == -1) type = "root";
        else if (e[i].size() == 0) type = "leaf";
        else type = "internal node";

        cout << "node " << i << ": parent = " << pa[i] << ", depth = " << d[i] << ", " << type << ", [";
        for ( int j = 0; j < e[i].size(); j++ ) {
            cout << (j != 0 ? ", " : "" ) <<  e[i][j];
        }
        cout << "]" << "\n";
    }
    return 0;
}


Measured memory_bytes: 6640
n = int(input())
xy = list()
for i in range(n):
    xy.append(list(map(int,input().split())))
 
dsum = 0
dist_l = [[0] * n for k in range(n)]
for i in range(n-1):
    for j in range(i+1, n):
        dist = ((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) ** (1/2)
        dist_l[i][j] = dist
        dist_l[j][i] = dist
        dsum = dsum + dist
 
ans = dsum * (n-1) / (n * (n-1) / 2)
 
print(ans)

Measured memory_bytes: 3064
import sys

input = sys.stdin.readline

def main():
    N = int(input())
    A = []; B = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    
    ans = 0
    for i in range(N):
        a = A.pop()
        b = B.pop()
        if (a + ans)%b == 0:
            continue
        else:
            ans += b - (a + ans)%b
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 16936
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
#https://note.nkmk.me/python-union-find/

    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n
    
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]
    
        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
    
            if x == y:
                return
    
            if self.parents[x] > self.parents[y]:
                x, y = y, x
    
            self.parents[x] += self.parents[y]
            self.parents[y] = x
    
        def size(self, x):
            return -self.parents[self.find(x)]
    
        def same(self, x, y):
            return self.find(x) == self.find(y)
    
        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]
    
        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]
    
        def group_count(self):
            return len(self.roots())
    
        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}
    
        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    n,q=MI()
    uf=UnionFind(n)
    for i in range(q):
        t,u,v=MI()
        if t==0:
            uf.union(u,v)
        else:
            if uf.find(u)==uf.find(v):
                print(1)
            else:
                print(0)
        
        
        
        
        
    
if __name__=="__main__":
    main()



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

struct datum {
	char str[6];
};

datum data[30];

char now[6];
char temp[6];

void rotate() {
	char temp;
	temp = now[0];
	now[0] = now[2];
	now[2] = now[5];
	now[5] = now[3];
	now[3] = temp;
}

void spin () {
	char temp;
	temp = now[1];
	now[1] = now[2];
	now[2] = now[4];
	now[4] = now[3];
	now[3] = temp;
}

int compare ( const void * a, const void * b ) {
	const datum x = *((datum*)a);
	const datum y = *((datum*)b);

	for ( int i=0; i<6; i++ ) {
		if ( x.str[i] != y.str[i] )
			return x.str[i] - y.str[i];
	}
	return 0;
}


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

		if ( n == 0 ) 
			break;

		string str;
		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<6; j++ ) {
				
				cin >> str;
				now[j] = str[0];
			}

			if ( now[1] == 'B' || now[4] == 'B' ) {
				spin();
			}
			while ( now[0] != 'B' ) {
					rotate();
			}

			if ( now[5] == 'Y' ) {
				while ( now[1] != 'C' ) {
					spin();
				}
			}
			else {
				while ( now[1] != 'Y' ) {
					spin();
				}
			}

			for ( int j=0; j<6; j++ ) {
				data[i].str[j] = now[j];
			}
		}

		qsort ( data, n, sizeof(datum), compare);

		int count = 0;

		for ( int i=0; i<n-1; i++ ) {
			bool hit = true;
			for ( int j=0; j<6; j++ ) {
				if ( data[i].str[j] != data[i+1].str[j] ) {
					hit = false;
					break;
				}
			}
			if ( hit ) 
				count ++;
		}

		cout << count << endl;
	}
}

		

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	vector<int> dp(n + 1, inf);
	dp[0] = 0;

	rep(i, n) {
		Rep(j, 1, k + 1) {
			if (i - j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=1e2+3;
int n,s[N],sum;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>s[i],sum+=s[i];
    if(sum%2){
    	cout<<sum<<endl;
    	return 0;
    }
    sort(s+1,s+1+n);
    int flag=0;
    for(int i=1;i<=n;i++){
    	if(s[i]%2){
    		sum-=s[i];flag=1;
    		break;
    	}
    }
    if(!flag) cout<<0<<endl;
    else cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#define DEBUG
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e10+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int a,b,c,d,e,k;cin>>a>>b>>c>>d>>e>>k;
	cout<<((e-a>k)?":(":"Yay!")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-7;

//2489
bool check(int n){
	string s, t;
	stringstream ss;
	ss<<n;
	ss>>s;
	t = s;
	reverse(all(t));
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]) return false;
	}
	return true;
}

int main(){
	int n;
	cin>>n;
	if(check(n)){
		cout<<n<<endl;
		return 0;
	}
	int a = n, b = n;
	while(1){
		a--; b++;
		if(a >= 0 && check(a)){
			cout<<a<<endl;
			return 0;
		}
		if(check(b)){
			cout<<b<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    double d, e;
    while(cin >> d >> e, d){
        double ans = 1e9;
        for(double x = 0.0 ; x <= d ; x += 1.0){
            double y = d - x;
            ans = min(ans, abs(sqrt(x * x + y * y) - e));
        }
        cout << fixed << setprecision(6) << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3280
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int[] count = new int[26];
        //int A = 'a';
        boolean test = true;
        
        for(int i=0; i<str.length(); i++){
            char c = str.charAt(i);
            count[c-97]++;
        }
        for(int i=0; i<26; i++){
            if(count[i]%2 != 0){
                test = false;
                break;
            }
        }
        if(test){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        //System.out.println(A);
    }
}

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

using namespace std;
#define mp make_pair
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vl a(n);
    int i;
    vl se(n,0), so(n,0);
    for(i=0;i<n;i++){
        cin >> a[i];
        if(i > 0){
            se[i] += se[i-1];
            so[i] += so[i-1];
        }
        if(i%2==0) se[i] += a[i];
        else so[i] += a[i];
    }
    
    vl dp(n);
    dp[0] = 0;
    dp[1] = max(a[0],a[1]);
    for(i=2;i<n;i++){
        if(i%2==1){
            dp[i] = max(a[i] + dp[i-2], se[i-1]);
        }else{
            dp[i] = max(a[i] + dp[i-2], dp[i-1]);
        }
    }

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

    return 0;
}

Measured memory_bytes: 9516
h,w,k=map(int,input().split())
c=[list(input()) for i in range(h)]
black =0
for i in range(h):
  for j in range(w):
    if c[i][j]=='#':
      black+=1
      c[i][j]=1
    else:
      c[i][j]=0
ans=0
for i in range(2**h):
  for j in range(2**w):
    cnt = black
    for p in range(h):
      for q in range(w):
        if i >> p & c[p][q]:
          cnt-=1
          continue
        if j >> q & c[p][q]:
          cnt-=1
    if cnt == k:
      #print(i,j,cnt)
      ans+=1
print(ans)

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];

signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin >>s;
		int n = s.size();
		int ans=0;
		for(int i =0 ;i < n;i++){
			if(i > n-1-i && s[i]!=s[n-1-i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
	
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}


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

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

  int n;
  cin >> n;
  lint ans = 0;
  for (int len = 1; len <= n; len++) {
    ans += 1ll * len * (n - len + 1);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    ans -= 1ll * u * (n - v + 1);
  } 
  cout << ans << "\n";
}


Measured memory_bytes: 3592
#include<iostream>
#include<string>
using namespace std;
int main()
{
  // 入力
  string s;
  cin >> s;
  
  int n = atoi(s.c_str());
  int fst, scd;
  fst = n / 100;
  scd = n % 100;
  
  // 出力
  if ((1 <= fst && fst <= 12) && (1 <= scd && scd <= 12))
    cout << "AMBIGUOUS" << endl;
  else if ((0 <= fst && fst <= 99) && (1 <= scd && scd <= 12))
    cout << "YYMM" << endl;
  else if ((1 <= fst && fst <= 12) && (0 <= scd && scd <= 99))
    cout << "MMYY" << endl;
  else
    cout << "NA" << endl;
  
  return 0;
}

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

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int temp;
    int *b = new int[n - 1];
    for (int i = 0; i < n - 1; i++)
    {
        cin >> b[i];
    }

    int sum = b[0];
    for (int i = 1; i < n - 1; i++)
    {
        sum += min(b[i - 1], b[i]);
    }
    sum += b[n - 2];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
  char a,b; cin>>a>>b;
  
  if((a=='H')&&(b=='H')){cout<<"H"<<endl; return 0;}
  if((a=='D')&&(b=='D')){cout<<"H"<<endl; return 0;}
  
  cout<<"D"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout<<n*(n-1)/2-n/2<<endl;
    if(n%2==0){
        
        rep3(i,1,n+1){
            rep3(j,i+1,n+1){
                if(i+j==n+1)
                    continue;
                cout << i << " " << j << endl;
            }
        }
    }else{
        
        rep3(i, 1, n + 1)
        {
            rep3(j, i + 1, n + 1)
            {
                if (i + j == n)
                    continue;
                cout << i << " " << j << endl;
            }
        }
    }
}


Measured memory_bytes: 256
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    a, b, c = MI()

    if a == b:
        print(c)
    elif a == c:
        print(b)
    else:
        print(a)

    pass


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); 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; }
const ll MOD = 1e9+7;

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

    bool fail = false;
    if(N%2 == 1)
        fail = true;

    REP(i,N/2){
        char x = S[i];
        char y = S[i+N/2];
        if(x != y)
            fail = true;
    }

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


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    REP(i, N) cin >> P[i], P[i]--;
    REP(i, N) cin >> C[i];

    int ans = -1e12;
    // スタート位置
    REP(i, N) {
        vector<int> v;
        int now = i;
        while (true) {
            now = P[now];
            v.emplace_back(C[now]);
            if (now == i) {
                break;
            }
        }
        int loopSum = accumulate(ALL(v), 0LL);
        int cnt = v.size();
        int t = 0;
        REP(j, min(cnt, K)) {
            t += v[j];
            // ループ内の合計x残りループ回数を加算する
            // ループ内の合計が負なら無視
            ans = max(ans, t + max(0LL, loopSum) *
                                   ((int32_t)(K - j - 1) / (int32_t)cnt));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3816
inp=input
li=list
iinp=lambda : int(inp())
ent=lambda : map(int,inp().split())
lient=lambda : [int(i) for i in inp().split()]
li0= lambda x: [0 for i in range(x)]
livalor=lambda valor,x: [valor for i in range(x)]
stent=lambda : [i for i in inp()]
filldp=lambda valor,x,y: [[valor for i in range(y)] for i in range(x)]

cantsnukes,cantdulces=ent()
personas=[0 for i in range(cantsnukes)]
for i in range(cantdulces):
    cant=iinp()
    numeros=lient()
    for i in numeros:
        personas[i-1]+=1
res=0
for i in personas:
    if i==0: res=res+1
print(res)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)

using namespace std;

void solve(int N, vector<int> h) {

  int ans(0);

  while (true) {
    // find the first positive in h as Left
    auto l = h.begin();
    while (*l == 0 && l != h.cend())
      ++l;
    // if no positive found, demand is satidfied
    if (l == h.cend())
      break;

    // find the first non-positive after Left in h as Right
    auto r = l;
    while (*r > 0 && r != h.cend())
      ++r;

    // reduce Left~Right in h
    for (auto i = l; i != r; ++i)
      (*i)--;

    ans++;
  }
  cout << ans << endl;
    
}

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

  int N;
  cin >> N;
  vector<int> h(N);
  REP(i, N)
    cin >> h[i];

  solve(N, move(h));
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto abc = readln.split.to!(int[]);
    auto A = abc[0];
    auto B = abc[1];
    auto C = abc[2];
    writeln(min(B / A, C));
}

Measured memory_bytes: 256
import heapq

n, m = list(map(int, input().split()))
A = [int(x) * -1 for x in input().split()]
heapq.heapify(A)

ans = 0
for _ in range(m):
    tmp_max = -(-1 * heapq.heappop(A) // 2)
    heapq.heappush(A, tmp_max)

for i in range(n):
    ans += heapq.heappop(A) * (-1)

print(ans)


Measured memory_bytes: 14180
import java.util.Scanner;

//Binary Digit A Doctor Loved
public class Main{

	static String f(int x){
		StringBuilder sb = new StringBuilder();
		while(x>0){
			sb.append(x%2);
			x/=2;
		}
		return sb.reverse().toString();
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			double x = sc.nextDouble();
			if(x<0)break;
			String d = f((int)x);
			x*=16;
			String s = (x+"").split("\\.")[1];
			if(!s.equals("0"))System.out.println("NA");
			else{
				for(int i=0;i<8-d.length();i++)System.out.print("0");
				System.out.print(d+".");
				String z = f((int)x);
				System.out.println(z.substring(z.length()-4, z.length()));
			}
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

// dp[i][j][k]
// i桁目まで決めて、
// j個のnon0を使って。
// k:0そこまでの桁はnと一致
// k:1そこまでの桁はn未満

int main() {
  string s;
  ll k, n;
  cin >> s >> k;
  n = s.size();
  ll dp[101][4][2]{};
  dp[0][0][0] = 1;

  rep(i, n) rep(j, 4) rep(l, 2) {
    ll nd = s[i] - '0';
    rep(d, 10) {
      int nj = j, nl = l;
      if (d) nj++;
      if (nj > k) continue;
      if (nl == 0) {
        if (d < nd) nl = 1;
        if (d > nd) continue;
      }
      dp[i + 1][nj][nl] += dp[i][j][l];
    }
  }

  cout << dp[n][k][0] + dp[n][k][1] << endl;
  return 0;
}


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

int data[100][100];
int sum[100][100];

int main(){
  int n;
  cin >> n;
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      cin >> data[i][j];
      sum[i][j] = 0;
    }
  }

  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      sum[i][j] = (i-1<0?0:sum[i-1][j]) 
	+ (j-1<0?0:sum[i][j-1]) 
	+ data[i][j]
        - ((i-1<0 || j-1<0)?0:sum[i-1][j-1]);
    }
  }


  int res = -1e8;
  for(int y1 = 0 ; y1 < n ; y1++){
    for(int x1 = 0 ; x1 < n ; x1++){
      for(int y2 = y1 ; y2 < n ; y2++){
	for(int x2 = x1 ; x2 < n ; x2++){
	  res = max(res,sum[y2][x2]
		    + ((y1-1<0 || x1-1<0)?0:sum[y1-1][x1-1])
		    - (y1-1<0?0:sum[y1-1][x2])
		    - (x1-1<0?0:sum[y2][x1-1]));
	}
      }
    }
  }





  
  cout << res << endl;

  return 0;
}

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

int main(){ 
    int r,c,rs,cs=0,total=0;
    cin >> r >> c;
	int sheet[r][c]={};
	for (int i=0;i<r;i++){
		for (int j=0;j<c;j++){
			cin >> sheet[i][j];
			total+=sheet[i][j];
		}
	}
	for (int i=0;i<r+1;i++){
		for (int j=0;j<c+1;j++){
			if (i<r && j<c){
				cout << sheet[i][j] << " ";
				cs+=sheet[i][j];
			}
			if (i<r && j==c){
				cout << cs << endl;
				cs=0;
			}
		}
	}
	for (int i=0;i<c;i++){
		for (int j=0;j<r;j++){
			rs+=sheet[j][i];
		}
		cout << rs << " " ;
		rs=0;
	}
	cout << total << endl;
} 


Measured memory_bytes: 3124
require 'matrix'
h, w = gets.split.map(&:to_i)
a = []
h.times do
  a.push gets.chomp.split('')
end
m = Matrix.rows(a)
empty_rows = []
empty_columns = []
ans = []
h.times do |i|
  empty_rows.push(i) if m.row(i).select { |e| e != '.' }.empty?
end
w.times do |i|
  empty_columns.push(i) if m.column(i).select { |e| e != '.' }.empty?
end
h.times do |i|
  next if empty_rows.include?(i)
  row = []
  w.times do |j|
    next if empty_columns.include?(j)
    row.push(m[i, j])
  end
  ans.push(row)
end
ans.each do |row|
  puts row.join
end


Measured memory_bytes: 3580
#定義
count = 0 #

##ロジック
N,A,B = map(int, input().split()) # N=参加人数、A=国内予選通過人数、B=海外予選通過人数
                                  # ただし、国内組は海外予選通過人数に余りがあるなら通過
S = input()                       # S=参加者の情報
for i in S:
  if i == "a":
    if A != 0:
      print("Yes")
      A = A - 1
    elif B != 0:
      print("Yes")
      B = B -1
    else:
      print("No")
  elif i == "b":
    if B != 0:
      print("Yes")
      B = B - 1
    else:
      print("No")
  
  else:
    print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int n = (c+b-1)/b;
  int m = (a+d-1)/d;
  if(n <= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
pair<string,int> a[100];
int main(){
	int t=0,g;
	string f,b;
	while(cin>>a[t].first>>a[t].second)t++;
	sort(a,a+t);
	b=a[0].first;
	cout<<b<<endl<<a[0].second;
	for(int i=1;i<t;i++){
		bool n=0;
		f=a[i].first,g=a[i].second;
		if(i)if(f==b)n=1;
		if(n)cout<<" "<<g;
		else cout<<endl<<f<<endl<<g;
		b=f;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

int main(){
int N,m=0,rn=0,pn=0;
string str;
cin>>N;
for(int i=0;i<N;i++)
{
while(1){
cin>>str;
if(str=="OUT"){m++;
if(m==3)break;}
if(str=="HIT"){rn++;
if(rn==4){pn++;rn=3;}}
if(str=="HOMERUN"){
pn+=rn+1;rn=0;}
}
cout<<pn<<endl;
rn=0;pn=0;m=0;
}
return 0;
}

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

const ll logx=30;
const ll N=5e5+5;
const ll M=1e3+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

ll n,a[20][20],ans[(1<<20)];

void Subsets()
{
  for(ll mask=0;mask<(1<<n);mask++)
  {
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
      ll seti=mask&(1<<i);
      if(seti==0){continue;}
      for(ll j=i+1;j<n;j++)
      {
        ll setj=mask&(1<<j);
        if(setj==0){continue;}
        sum+=a[i][j];
      }
    }
    ans[mask]=sum;
  }
}

int main()
{
  cin>>n;
  ll maxi=0;
  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<n;j++){cin>>a[i][j];}
  }
  Subsets();
  for(ll mask=0;mask<(1<<n);mask++)
  {
    for(ll subs=mask;subs>0;subs=(subs-1)&mask){ans[mask]=max(ans[mask],ans[subs]+ans[mask^subs]);}
  }
  cout<<ans[(1<<n)-1]<<endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
LL high(LL x){
	per(i,60,0)if(x&(1ll<<i))return (1ll<<i);
	return 0;
}
int main(){
	LL A,B;scanf("%lld%lld",&A,&B);
	LL ans=B-A+1;
	if(A==B){
		printf("1\n");
		return 0;
	}
	while(A&&high(A)==high(B)){
		A-=high(A);
		B-=high(B);
	}
	LL up=high(B);
	B-=high(B);
	//B~up-1
	//0~A
	swap(A,B);
	if(B<=A){
		printf("%lld\n",up-A+ans-1);
		return 0;
	}
	if(A==0){
		printf("%lld\n",ans+up-B);
		return 0;
	}
	LL w=high(A);
	if(w*2ll-1>=B){
		printf("%lld\n",ans+up-A-1);
		return 0;
	}
	printf("%lld\n",ans+up-B+(w*2ll-1-A));
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

// void test(){
	
	// while(true){
		// int X, Y, Z;
		// cin>>X;
		
		// Z = X;
		
		// for(int i = 0, y = 1; i < 10; i++){
			// cout<<X<<" "<<Z/y<<endl;
			// y *= 2;
			// X /= 2;
		// }
	// }
// }

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N, M;
	int sum = 0;
	vector<int> A;
	priority_queue<int> Q;
	
	// test();
	
	cin>>N>>M;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		Q.push(A[i]);
	}
	// cout<<"x"<<endl;
	
	for(int i = 0; i < M; i++){ //cout<<i<<endl;
		int x = Q.top(); Q.pop();
		
		Q.push(x/2);
	}
	
	// cout<<"t"<<endl;
	for(;!Q.empty();){
		sum += Q.top();
		Q.pop();
	}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int res=0;
int h,w;
int dfs(int x,int y,int xdest,int ydest,char arr[1000][1000],int dp[1000][1000])
{
    if(arr[x][y]=='#')
    {
        return 0;
    }
    if(x==xdest&&y==ydest)
    {
        return 1;
    }
    int p1=0,p2=0;
    if(x+1<=xdest&&y<=ydest)
    {
        p1=dp[x+1][y];
    }
    if(x<=xdest&&y+1<=ydest)
    {
        p2=dp[x][y+1];
    }
    return (p1+p2)%MOD;
}

int main()
{
    
    cin>>h>>w;
    char arr[1000][1000];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            char x;
            cin>>x;
            arr[i][j]=x;
        }
    }
    int dp[1000][1000];
    memset(dp,0,sizeof(dp));
    for(int i=h-1;i>=0;i--)
    {
        for(int j=w-1;j>=0;j--)
        {
             int p=dfs(i,j,h-1,w-1,arr,dp);
             dp[i][j]=p;
        }
    }
    cout<<dp[0][0];
    return 0;
}

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

class Main{
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		str=bfr.readLine();
		StringBuilder sb=new StringBuilder();
		sb.append(str);
		sb.setCharAt(3,'8');
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 21204
import java.util.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        
        int a=sc.nextInt();
        int b=sc.nextInt();
        int x=sc.nextInt();
        if(x>=a*a*b/2){
            double c=(double)x/a/a;
            double d=2*c-b;
            System.out.println(Math.toDegrees(Math.atan((b-d)/a)));
        }else{
            double c=(double)x/a/b*2;
            System.out.println(90-Math.toDegrees(Math.atan(c/b)));
        }
        

        
    


        sc.close();
    }
}


Measured memory_bytes: 23764