akhauriyash/Code-Regression huggingface dataset:
//#define LOCAL

#include <cstdio>

int bubbleSort(int a[], int n) {
	int counter = 0;
	bool flag = 1;
	for(int i=0; flag; ++i) {
		flag = 0;
		for(int j=n-1; j>i; --j) {
			if(a[j] < a[j-1]) {
				int temp = a[j]; a[j] = a[j-1]; a[j-1] = temp;
				flag = 1; ++counter;
			}
		}
	}
	return counter;
}

int main()
{
	#ifdef LOCAL
		freopen("E:\\Temp\\input.txt", "r", stdin);
		freopen("E:\\Temp\\output.txt", "w", stdout);
	#endif

	int n, counter, a[110];
	scanf("%d", &n);
	for(int i=0; i<n; ++i) scanf("%d", &a[i]);
	counter = bubbleSort(a, n);

	for(int i=0; i<n; ++i) {
		if(i) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n%d\n", counter);

	return 0;
}

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

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

  int cnt = 0;
  for(int i = a; i <= b; i++){
    if(c%i == 0) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3104
//
//  nomura_b.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll INF = 1000000007;
#define PI 3.14159265


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

  string ans;
  for (int i = 0; i < t.length(); i++) {
    if (t[i] == '?') ans += 'D';
    else ans += t[i];
  }

  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 3840
# AGC008A - Simple Calculator
# change the sings of xy or not -> 2 * 2 = 4 patterns & y >= x
def main():
    X, Y = map(int, input().split())
    cand = [Y - X, Y + X + 1, -Y - X + 1, -Y + X + 2]
    ans = min(i for i in cand if i >= 0)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>

using namespace std;

void APluralForm(std::istream& in, std::ostream& out) {
    string s;
    in >> s;
    if (s.back() == 's') s += "es";
    else s += "s";
    out << s << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    APluralForm(in, out);
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#define MAX 100

int main()
{
  int i;
  int j;
  int n;
  int u,k,v;
  int A[MAX][MAX];

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++){
    for( j = 0 ; j < n; j++){
      A[i][j] = 0;//とりあえず全部０にする
    }
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u,&k);
    u--;//配列は０から始まるので１ずつ引く
    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;
      A[u][v] = 1;
      
    }
  }
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      if( j > 0 ) printf(" ");
      printf("%d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}
  
  



Measured memory_bytes: 2132
def main():
    N = int(input())
    S = input()
    if N % 2 != 0:
        print('No')
    else:
        A = S[:N//2]
        B = S[N//2:N]
        if A == B:
            print('Yes')
        else:
            print('No')

  

if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

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


Measured memory_bytes: 4036
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 123456789
//0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;


int main(void){
	ll X,Y;
	cin>>X>>Y;
	ll hoge=X-Y;
	if(hoge==0||hoge==-1||hoge==1)cout<<"Brown"<<endl;
	else cout<<"Alice"<<endl;
}

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


int main(){
    string str;
    cin>>str;
    int q,q1,t,f,i=0,k=0;
    int query[200020],rev[200010];
    cin>>q1;q=q1;
    char c[200010],con[200010];
    while(q1--)
    {
        cin>>t;
        if(t==1){query[i]=1;con[i]='r';i++;}
        else {
            cin>>f>>c[i];
            if(f==1)
            {
                con[i]='p';
            }
            else con[i]='s';
            query[i]=2;
            i++;
        }
    }//cout<<query[0]<<' '<<query[1]<<' '<<query[2]<<' '<<query[3]<<endl;
    //cout<<con[0]<<' '<<con[1]<<' '<<con[2]<<' '<<con[3]<<endl;
    if(query[q-1]==1){rev[q-1]=1;}
    else rev[q-1]=0;
    for(int j=q-2;j>=0;j--)
    {
        if(query[j]==1){rev[j]=1+rev[j+1];/*cout<<"revhere"<<' '<<j<<' ';*/}
        else {rev[j]=rev[j+1];/*cout<<"rere"<<' '<<j<<' ';*/}
    }
    //cout<<rev[0]<<' '<<rev[1]<<' '<<rev[2]<<' '<<rev[3]<<endl;
    string pre,suf;int counter=0,s=0,p=0;
    for(int j=0;j<q;j++)
    {
        if(query[j]==2)
        {
            if(rev[j]%2==0)
            {
                if(con[j]=='p'){pre.push_back(c[j]);p++;}
                else {suf.push_back(c[j]);s++;}
            }
            else
            {
               if(con[j]=='p'){suf.push_back(c[j]);s++;}
               else {pre.push_back(c[j]);p++;}
            }
        }
        else
        {
            counter++;
        }
    }//cout<<counter<<' '<<p<<' '<<s<<endl;

   /* for(int j=0;j<q;j++)
    {cout<<"here";
        cout<<query[i]<<' ';
    }cout<<endl;
    for(int j=0;j<q;j++)
    {
        cout<<con[i]<<' ';
    }cout<<endl;
    for(int j=0;j<q;j++)
    {
        cout<<rev[i]<<' ';
    }cout<<endl;*/

    string res[str.size()+q-counter];
    if(counter %2==0)
    {int ind=0;
    for(int j=p-1;j>=0;j--)
    {
        res[ind]=pre[j];
        ind ++;
    }
    for(ind=p;ind<p+str.size();ind++)
    {
        res[ind]=str[ind-p];
    }ind=0;
    for(int j=0;j<s;j++)
    {
        res[ind+p+str.size()]=suf[j];
        ind ++;
    }
    for(int j=0;j<str.size()+q-counter;j++)
    {
        cout<<res[j];
    }
    }
    else
    {
      int ind=0;
    for(int j=p-1;j>=0;j--)
    {
        res[ind]=pre[j];
        ind ++;
    }int h=str.size()-1;
    for(ind=p;ind<p+str.size();ind++)
    {
        res[ind]=str[h];
        h--;
    }ind=0;
    for(int j=0;j<s;j++)
    {
        res[ind+p+str.size()]=suf[j];
        ind ++;
    }
    for(int j=0;j<str.size()+q-counter;j++)
    {
        cout<<res[j];
    }
    }
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3);
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3);
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int n;
    cin>>n;
    cout<<3*n*n;
}


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

int main()
{
  int n, i, j, k;
  int b[100];
  stack<int> a;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> b[i];

  for (k = n-1; k >= 0; k--) {
    int cnt = 0;
    for (i = k; i >= 0; i--) {
      if (i+1 == b[i]) {
	a.push(b[i]);
	for (j = i+1; j <= k; j++)
	  b[j-1] = b[j];
	cnt++;
	break;
      }
    }
    if (cnt == 0) {
      cout << "-1" << endl;
      goto end;
    }
  }
  for (i = 0; i < n; i++) {
    cout << a.top() << endl;
    a.pop();
  }
 end:
  return 0;
}


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

// flag を用いたバブルソート
int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = 1;
    for ( int i = 0; flag; i++ ) {
        flag = 0;
        for ( int j = N - 1; j >= i + 1; j-- ) {
            if ( A[j] < A[j - 1] ) {
                // 隣接要素を交換する
                swap( A[j], A[j - 1] );
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for ( int i = 0; i < N; i++ ) cin >> A[i];

    sw = bubbleSort(A, N);

    for ( int i = 0; i < N; i++ ) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}


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

typedef long long int lli;
typedef pair<lli,lli> PII;

#define M 100005
#define ep emplace_back
#define mp make_pair

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

//	freopen("input.txt","rt",stdin);
	
	string s,t;
	cin>>s>>t;
	
	int ns,nt;
	cin>>ns>>nt;
	
	string u;
	cin>>u;
	
	if(u==s)
		cout<<ns-1<<" "<<nt<<"\n";
	else
		cout<<ns<<" "<<nt-1<<"\n";
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

string s,t;

// dp[i+1][j+1]: sのi文字目まで．tのj文字目まで，
// この2つの部分文字列のLCSの長さ
int dp[3010][3010];

int main()
{
  cin >> s >> t;
  int m = s.length();
  int n = t.length();

  // Init:
  REP(i,0,m) dp[i][0] = 0;
  REP(j,0,n) dp[0][j] = 0;
  // Update:
  REP(i,0,m) REP(j,0,n) {
    if (s[i] == t[j]) {
      dp[i+1][j+1] = dp[i][j] + 1;
    } else {
      dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    }
  }

  // LCSの長さ
  // cout << dp[m][n] << endl;

  // 復元 (後ろの文字から)
  string res = "";
  // dp[m][n]がどのように更新されてきたか？
  int i = m-1, j = n-1;
  while (i >= 0 && j >= 0) {
    if (dp[i+1][j+1] == dp[i][j+1]) --i;
    else if (dp[i+1][j+1] == dp[i+1][j]) --j;
    // (i,j) -> (i+1,j+1) と更新された場合:
    // このときs[i]==t[j]
    else {
      res = s[i] + res;
      --i; --j;
    }
  }
  cout << res << endl;

  return 0;
}


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

A = []
for i in range(a):
    X = list(map(int, input().split()))
    A.append(X[1:])

count = 0
sum= 0
for i in A[0]:
    for j in range(a):
        if(i in A[j]):
            count+=1
    if(count == a):
        sum+=1
    count= 0
print(sum)

Measured memory_bytes: 3064
n = int(input())
b = list(map(int, input().split()))

ans = 0

ans += b[0]
ans += b[len(b)-1]

for i in range(len(b)-1):
    if (b[i] < b[i+1]):
        ans += b[i]
    else:
        ans +=b[i+1]
print(ans)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define a(a)         \
    for (auto i : a) \
        cout << i << " ";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main()
{

    ll n, m, c = 0;
    cin >> n >> m;
    rep(i, n)
    {
        string s;
        cin >> s;
        rep(i, s.le)
        {
            if (s[i] == '#')
                c++;
        }
    }
    if (c == n + m - 1)
        c("Possible") else c("Impossible")
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,x,y;map<ll,ll>m;
    cin>>a>>b;
    for(int i=1;i<999;i++){
        x=(i*(i+1))/2;
        y=((i+2)*(i+1))/2;
        if(x-a==y-b&&x-a>0&&y-b>0){
            cout<<y-b<<endl;return 0;
        }
    }

}


Measured memory_bytes: 3648
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

H, W = list(map(int, sys.stdin.buffer.readline().split()))

if H == 1 or W == 1:
    print(1)
    exit()

h1 = (H + 1) // 2
h2 = H // 2
w1 = (W + 1) // 2
w2 = W // 2
ans = h1 * w1 + h2 * w2
print(ans)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int N_MAX = 101;
int INF = 2000000000;
typedef pair<int,int> P;
int main()
{
  int n;
  cin >> n;
  // 取りうる高さのmin,max
  P mm[N_MAX][N_MAX];
  for(int x=0;x<N_MAX;x++)
    for(int y=0;y<N_MAX;y++)
      mm[x][y] = P(0,INF);
  int X,Y,H,h;
  for(int i=0;i<n;i++){
    cin >> X >> Y >> H;
    if(H>0)
      for(int x=0;x<N_MAX;x++)
        for(int y=0;y<N_MAX;y++){
          h=H+abs(x-X)+abs(y-Y);
          if(h>=mm[x][y].first
             && h<=mm[x][y].second)
            mm[x][y] = P(h,h);
          else
            mm[x][y] = P(0,0);
        }
    else  
      for(int x=0;x<N_MAX;x++)
        for(int y=0;y<N_MAX;y++){
          h=abs(x-X)+abs(y-Y);
          if(h>=mm[x][y].first
             && h<=mm[x][y].second)
            mm[x][y].second = h;
          else if(h<mm[x][y].first)
            mm[x][y] = P(0,0);
        }
  }
  for(int x=0;x<N_MAX;x++)
    for(int y=0;y<N_MAX;y++)
      if(mm[x][y].second>0){
        cout << x << " " << y << " "
        << mm[x][y].second << endl;
        return 0;
      }
  return 0;
}


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

int main() {

	ll n; cin >> n;
	vector <pair<ll, ll>> pa;
	for (int i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		pa.push_back({ b, a });
	}
	sort(pa.begin(), pa.end());
	ll time = 0;
	bool can = true;
	for (int i = 0; i < n; i++) {
		time += pa[i].second;
		if (pa[i].first < time) {
			can = false;
			break;
		}
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define INF_LL (int64)1e18
//#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

class UnionFind{
private:
    ::std::vector<int_fast32_t> par, edge;
    size_t n;

public:
    UnionFind(){}
    UnionFind(size_t n):n(n){
        par.resize(n, -1);
        edge.resize(n, 0);
    }

    uint_fast32_t find(uint_fast32_t x){
        return par[x] < 0 ? x : par[x] = find(par[x]);
    }

    size_t size(uint_fast32_t x){
        return -par[find(x)];
    }

    bool unite(uint_fast32_t x, uint_fast32_t y){
        x = find(x);
        y = find(y);
        edge[x] += 1;
        if(x == y) return false;
        if(size(x) < size(y)) std::swap(x, y);
        par[x] += par[y];
        edge[x] += edge[y];
        par[y] = x;
        return true;
    }

    bool same(uint_fast32_t x, uint_fast32_t y){
        return find(x) == find(y);
    }

    size_t esize(uint_fast32_t x) {
        return edge[find(x)];
    }
};

int main(void) {
    int64 N, K;
    cin >> N >> K;
    double res = 0;
    vector<double> p2(30, 1);
    FOR(i, 1, 30) {
        p2[i] = p2[i-1] / 2;
    }
    FOR(i, 1, N+1) {
        int64 cnt = 0;
        while ((i << cnt) < K) {
            cnt++;
        }
        res += p2[cnt];
    }
    cout << fixed << setprecision(10) << res/(double)N << endl;
}


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

int main(){
  int n;
  cin>>n;
  long x=1;
  long y=1;
  long z=1;
  for(int i=0;i<n;i++){
    x*=10;
    x%=MOD;
    y*=9;
    y%=MOD;
    z*=8;
    z%=MOD;
  }
  long p=x+z-2*y+MOD+MOD+MOD;
  cout<<p%MOD;
}

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

int main(){
    int a, b;

    cin >> a >> b;

    if(a + b == 15){
        cout << "+" << endl;
    }else if(a*b == 15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;

using ll = long long;

int main() {
	int time[5];
	int mod = 10;
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		cin >> time[i];
		ans += (((time[i]-1) / 10)+1);
		mod = min(mod, ((time[i]+9) % 10)+1);
	}
	cout << ans*10-10+mod;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int N;
	char str[1024];
	char out[128];

	char ntostr[][8] = {
		{},
		".,!? ",
		"abc",
		"def",
		"ghi",
		"jkl",
		"mno",
		"pqrs",
		"tuv",
		"wxyz"
	};

	std::cin >> N;
	for (int I = 0; I < N; I++) {
		std::cin >> str;
		int i = 0;
		int d = 0;
		int oi = 0;
		int cn = -1;
		while (str[i]) {
			int num = str[i] - '0';
			if (!num) {
				if (cn >= 0) {
					out[oi++] = ntostr[cn][d];
					cn = -1;
				}
			}
			else {
				if (cn != num) {
					cn = num;
					d = 0;
				}
				else {
					d++;
					if (!ntostr[cn][d]) d = 0;
				}
			}
			i++;
		}
		out[oi] = '\0';
		std::cout << out << '\n';
	}
	return 0;
}

Measured memory_bytes: 3048
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int D;
	scanf("%d", &D);
	if (D == 25) {
		printf("Christmas");
	}else if (D == 24) {
		printf("Christmas Eve");
	}else if (D == 23) {
		printf("Christmas Eve Eve");
	}else if (D == 22) {
		printf("Christmas Eve Eve Eve");
	}
}

Measured memory_bytes: 128
s = input()[::-1]
n = len(s)
idx = 0
while idx < n:
    if s[idx:idx+5] == 'maerd':
        idx += 5
    elif s[idx:idx+7] == 'remaerd':
        idx += 7
    elif s[idx:idx+5] == 'esare':
        idx += 5
    elif s[idx:idx+6] == 'resare':
        idx += 6
    else:
        print("NO")
        exit()
print("YES")



Measured memory_bytes: 9276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll n,k,a[55][55];
const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

ll msum(ll M[][55],ll n,ll m){
  ll s=0;
  fr(i,n) fr(j,m) s=ad(s,M[i][j]);
  return s;
}


ll L[55][55]={};
void mlt(ll M[][55],ll N[][55],ll n,ll r,ll m){
  fr(i,n) fr(j,m) L[i][j]=0;
  fr(i,n) fr(j,m) fr(k,r) L[i][j]=ad(L[i][j],mlt(M[i][k],N[k][j]));
}

ll w[55][55]={};
void pwr(ll M[][55],ll n,ll k){
  ll pw[62][55][55]={};
  fr(i,n) fr(j,n) pw[0][i][j]=M[i][j];
  fr(i,n) fr(j,n) w[i][j]=(i==j);
  fr(i,61){
    mlt(pw[i],pw[i],n,n,n);
    fr(k,n) fr(j,n) pw[i+1][k][j]=L[k][j];
  }
  fr(i,62){
    if(k%2){
      mlt(w,pw[i],n,n,n);
      fr(k,n) fr(j,n) w[k][j]=L[k][j];
    }
    k/=2;
  }
}

int main(){
  cin>>n>>k;
  fr(i,n) fr(j,n) cin>>a[i][j];
  pwr(a,n,k);
  cout<<msum(w,n,n)<<endl;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <math.h>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;
static const double pi = 3.141592653589793;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

int main(void){
  ios::sync_with_stdio(false);
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double tansin = h * 30 + 0.5 * m;
  long double tyosin = m * 6;
  long double angle = abs(tansin - tyosin);
  long double ans;
  if (angle > 180) angle = 360 - angle;
  long double val = 180;
  angle = angle / val * pi;

  if (angle != 0){
    ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(angle));
  }
  else if (angle == 0) ans = abs(a - b);
  cout << fixed << setprecision(25) << ans << endl;
  return 0;
}



Measured memory_bytes: 4212
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;
const int oo=(1<<30)-1;

int mn[2][20][N];
int A[2][N];
int Lg[N];
int n;

struct node{
	int l,r,t;
	bool operator < (const node &B) const{
		return A[t&1][t]>A[B.t&1][B.t];
	}
};priority_queue<node> Q;

int cmp(int t,int x,int y){
	return A[t][x]<A[t][y]?x:y;
}
int calmn(int t,int l,int r){
	int _=Lg[r-l+1];
	return cmp(t,mn[t][_][l],mn[t][_][r-(1<<_)+1]);
}
void Push(int l,int r){
	if (l>r) return;
	assert((r-l+1)%2==0);
	Q.push((node){l,r,calmn(l&1,l,r)});
}

int main(){
	Lg[1]=0;
	For(i,2,N) Lg[i]=Lg[i>>1]+1;
	For(i,0,2){
		For(j,0,N){
			A[i][j]=oo;
			mn[i][0][j]=j;
		}
	}
	n=IN();
	For(i,1,n+1) A[i&1][i]=IN();
	For(t,0,2){
		For(x,1,20){
			for (int i=1;i+(1<<x)-1<=n;i++){
				mn[t][x][i]=cmp(t,mn[t][x-1][i],mn[t][x-1][i+(1<<x-1)]);
			}
		}
	}
	Push(1,n);
	while (!Q.empty()){
		node P=Q.top();Q.pop();
		printf("%d ",A[P.t&1][P.t]);
		int w=calmn(P.r&1,P.t+1,P.r);
		printf("%d ",A[w&1][w]);
		Push(P.l,P.t-1);
		Push(P.t+1,w-1);
		Push(w+1,P.r);
	}
	puts("");
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define int long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()

// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vector<int> graph[100000];
int dist[100000];

int dfs(int v) {
	// cout<<v<<" ";
	
	if(dist[v])
		return dist[v];

	for(auto i:graph[v]) {
		dist[v] = max(dist[v], dfs(i));
	}
	
	dist[v] += 1;
	return dist[v];
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	int n, m, ans = 0;
	cin>>n>>m;

	for(int i=0; i<m; i++) {
		int x, y;
		cin>>x>>y;
		graph[x-1].pb(y-1);
	}

	for(int i=0; i<n; i++) {
		if(!dist[i]) {
			ans = max(ans, dfs(i) - 1);
		}
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 7936
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)

ll N, K, i, j, k;
ll dp[111][5][2];
int main(void) {
	char str[200];
	scanf("%s", str);
	N = strlen(str);
	scanf("%d", &K);
	dp[0][0][1] = 1;
	for (i = 0; i < N; i++) {
		for (j = 0; j <= K; j++) {

			for (k = 0; k < 10; k++) {
				dp[i + 1][j + (k != 0)][0] += dp[i][j][0];
			}

			ll MX = str[i] - '0';
			for (k = 0; k < MX; k++) {
				dp[i + 1][j + (k != 0)][0] += dp[i][j][1];
			}

			dp[i + 1][j + (MX != 0)][1] += dp[i][j][1];
		}
	}

	printf("%d",dp[N][K][0] + dp[N][K][1]);
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll k;cin>>k;
    string s;cin>>s;
    if(s.size()<=k)cout<<s;
    else {f(i,0,k)cout<<s[i];cout<<"...";}
    return 0;  
} 





Measured memory_bytes: 3636
s = gets.chomp
h = {}
"a".upto("c") { |c| h[c] = s.count(c) }
t = h.values.sort
if t[0] == t[1] && t[1] == t[2]
  puts "YES"
elsif t[0] == t[1] && t[2] == t[0] + 1
  puts "YES"
elsif t[0] == t[1] - 1 && t[1] == t[2]
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 2044
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int C[30];
string xyz="abcdefghijklmnopqrstuvwxyz";

int main(){
  int num;
  string s;
  cin>>s;

  num=(int)s.size()-2;

  cout<<s[0]<<num<<*(s.end()-1)<<endl;
}


Measured memory_bytes: 256
L = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for x in range(int(input())):
    n = raw_input().split()
    b = int(n[0])
    f = int(n[1])
    r = int(n[2])
    v = int(n[3])

    L[b-1][f-1][r-1] += v

for i in L:
    for j in i:
        print (" {}" * 10).format(*j)
    if i is not L[-1] :print "#" * 20

Measured memory_bytes: 6360
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  int sum = 0;
  REP(i, N - 1) {
    sum += abs(A[i + 1] - A[i]);
  }
  sum += abs(A[0]) + abs(A[N - 1]);

  REP(i, N) {
    int a, b;
    if (i == 0) {
      b = abs(A[0]) + abs(A[1] - A[0]);
      a = abs(A[1]);
    } else if (i == N - 1) {
      b = abs(A[N - 1]) + abs(A[N - 1] - A[N - 2]);
      a = abs(A[N - 2]);
    } else {
      b = abs(A[i + 1] - A[i]) + abs(A[i] - A[i - 1]);
      a = abs(A[i + 1] - A[i - 1]);
    }
    cout << (sum - b + a) << endl;
  }
  return 0;
}

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

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

    vector<int64_t> a(n), b(m);
    vector<int64_t> as(n + 1, 0), bs(m + 1, 0);
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        if(i != 0) as[i + 1] = as[i] + a[i];
        else as[i + 1] = a[i];
    }
    for (auto i = 0; i < m; i++) {
        cin >> b[i];
        if(i != 0) bs[i + 1] = bs[i] + b[i];
        else bs[i + 1] = b[i];
    }
    int64_t ans = 0;
    for (auto i = 0; i <= n; i++) {
        if(k - as[i] < 0) break;
        auto itr = lower_bound(bs.begin(), bs.end(), k - as[i]);
        if(*itr != k - as[i]) itr--;
        ans = max(ans, max(itr - bs.begin(), 0L) + i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9532
import sys


def main():
    N = int(input())
    count = 0
    for i in range(0, N):
        D1, D2 = list(map(int, input().split()))
        if D1 == D2:
            count += 1
            if count == 3:
                print('Yes')
                sys.exit()
        else:
            count = 0
    print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

signed main(){
	ll n;
	cin>>n;
	vector<ll>h(n);
	ll maxv=0;
	rep(i,n)cin>>h[i];
	rep(i,n){
		maxv=max(maxv,h[i]);
		if(maxv-h[i]>1){
			cout<<"No"<<endl;
			return 0;
		}
			
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
int main(){
  lint i,n,k;
  cin>>n>>k;
  if((n-1)%(k-1)){
    i=((n-1)/(k-1))+1;
  }else{
    i=(n-1)/(k-1);
  }
  cout<<i<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int H, W;

bool check_existance (PII num) {
  if (0 <= num.first && num.first < H && 0 <= num.second && num.second < W) {
    return true;
  } else {
    return false;
  }
}

int main(void){
  cin >> H >> W;
  char matrix[H][W];
  queue<PII> q;

  int counter = 0;

  for (int i = 0; i < H*W; i++) {
    cin >> matrix[i/W][i%W];
    if (matrix[i/W][i%W] == '#') q.push(make_pair(i/W, i%W));
  }

  while(!q.empty()) {
    int queueSize = q.size();

    for (int i = 0; i < queueSize; i++) {
      PII index = q.front();
      q.pop();

      PII n[4];  // neighbours
      n[0] = make_pair(index.first, index.second - 1);  // up
      n[1] = make_pair(index.first, index.second + 1);  // down
      n[2] = make_pair(index.first - 1, index.second);  // left
      n[3] = make_pair(index.first + 1, index.second);  // right

      for (int j = 0; j < 4; j++) {
        if (check_existance(n[j]) && matrix[n[j].first][n[j].second] == '.') {
          q.push(n[j]);
          matrix[n[j].first][n[j].second] = '#';
        }
      }
    }
    counter ++;
  }

  cout << counter-1 << '\n';

  return 0;
}

Measured memory_bytes: 9360
#include<stdio.h>

int n,A[20];
int solve(int,int);

int main(){
  int i,q,k;
  int Q[200];

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++) scanf("%d",&Q[i]);
  
  for(k = 0; k < q; k++){
    if(solve(0,Q[k])) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  if( solve(i + 1,m) || solve(i + 1,m - A[i])) return 1;
}



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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int A, B, C;
  cin >> A >> B >> C;
  string ans = "No";
  if (A == B && B != C || A != B && B == C || A == C && B != C) ans = "Yes";
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, x;

	while(true) {
		cin >> n >> x;
		if(n == 0 && x == 0) {
			break;
		}
		int count = 0;
		for(int i=1; i<=n; i++) {
			for(int j=i+1; j<=n; j++) {
				for(int k=j+1; k<=n; k++) {
					if(i+j+k == x) {
						count++;
					}
				}
			}
		}
		cout << count << endl;
	}

	return 0;
}


Measured memory_bytes: 3100
// https://atcoder.jp/contests/abc099/tasks/abc099_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int target = 0, tmp = 0, sum = 0, ans = INF;
    cin >> target;

    // 目標値を2つに分割して、6進数と9進数にする
    for (int i = 0; i <= target; i++) {
        sum = 0;
        tmp = i;
        // tmpを6進数にする
        while (tmp > 0) {
            sum += tmp % 6;
            tmp /= 6;
        }
        tmp = target - i;
        // tmpを9進数にする
        while (tmp > 0) {
            sum += tmp % 9;
            tmp /= 9;
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
fn main() {
    let n: i32 = read();

    let mut ans = Vec::new();
    for i in 0..n+1 {
        if i % 2 == 0 {
            continue;
        }
        let mut count = 0;
        for j in 1..i+1 {
            if i % j == 0 {
                count += 1
            }
        }
        ans.push(count);
    }

    let fil: Vec<i32> = ans.into_iter().filter(|e| e == &8).collect();
    println!("{}", fil.len());
}



use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed toparse token")
}

Measured memory_bytes: 4352
def main():
    import sys
    sys.setrecursionlimit(100000)
    n=int(input())
    a=[int(input()) for _ in [0]*(n-1)]
    a=[[i+2,a[i]] for i in range(n-1)]
    l=[[] for _ in [0]*n]
    for i,j in a:
        l[j-1].append(i-1)
    def dps(i):
        if l[i]==[]:
            return 0
        temp=[]
        for j in l[i]:
            temp.append(dps(j))
        temp.sort(reverse=True)
        temp=[temp[i]+i+1 for i in range(len(temp))]
        return max(temp)
    print(dps(0))
main()

Measured memory_bytes: 159060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int h,w,k;
    string s[300];
    cin>>h>>w>>k;
    rep(i,h) cin>>s[i];
    int ans[300][300]={0};
    int x=1,y=0,a=1;
    rep(i,h){
        int z=0;
        rep(j,w) if(s[i][j]=='#') z=1;
        if(!z){
            a++;
            continue;
        }
        rep(j,w){
            if(s[i][j]=='#'){
                if(y) x++;
                else y++;
            }
            rep(k,a) ans[i-k][j]=x;
        }
        y=0;
        x++;
        a=1;
    }
    int z=0;
    rep(i,h) if(ans[i][0]==0){z=i;break;}
    if(z) for(int i=z;i<h;i++)rep(j,w) ans[i][j]=ans[z-1][j];
    rep(i,h){rep(j,w) cout<<ans[i][j]<<" ";cout<<endl;}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
string s; 
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>s;
	int a,b;
	a=b=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0')a++;
		else b++;
	}
	cout<<min(a,b)*2<<endl;
    return 0; 
}

Measured memory_bytes: 512
import numpy as np
from itertools import product

h, w, k = map(int, input().split())
grid = np.array([list(map(str, input().rstrip())) for _ in range(h)])

ans = 0
for i in np.array(list(product([0, 1], repeat=h)), np.bool):
    for j in np.array(list(product([0, 1], repeat=w)), np.bool):
        if np.any(i) and np.any(j):
            arr = grid[i].copy()
            arr = arr[:, j]
            arr = arr.flatten()
            if np.where(arr == "#")[0].shape[0] == k:
                ans += 1

print(ans)

Measured memory_bytes: 27132
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll K,X; cin >> K >> X;
    
    if(500*K >= X) return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	string ans;
	// 1
	string R1(tx - sx, 'R');
	string U1(ty - sy, 'U');
	string L1(tx - sx, 'L');
	string D1(ty - sy, 'D');
	ans += R1 + U1 + L1 + D1;

	// 2
	ans += 'D';
	ans += R1;
	ans += "RU";
	ans += U1;
	ans += "LU";
	ans += L1;
	ans += "LD";
	ans += D1;
	ans += 'R';

	cout << ans << endl;






	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    LL t;
    cin >> t;
    if(t==0){
        cout << 0 << endl;
        return 0;
    }
    LL ans = LLINF;
    for(int h=1; ;h++){
        LL now = 0, spd = 1;
        LL ct = 0;
        rep(i, h){
            now += spd;
            spd *= 3;
            ct++;
        }
        spd /= 3;
        LL top = spd;
        while(spd > 3){
            spd /= 3;
            now += spd;
            ct++;
        }
        if(now > t) break;
        LL rem = t - now;
        // cout << top << " " << rem << endl;
        spd = top;
        while(rem > 0){
            while(rem >= spd){
                LL tmp = rem/spd;
                rem %= spd;
                ct += tmp;
            }
            spd /= 3;
        }
        chmin(ans, ct);

    }
    cout << ans << endl;





}


Measured memory_bytes: 3208
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

def main():
    #N, M = map(int, input().split())
    X = int(input())
    LARGE = 100000

    d = {}
    for a in range(LARGE):
        d[a**5] = a

    for a in range(LARGE):
        A = a ** 5
        remain = A - X
        abs_remain = abs(remain)
        if abs_remain in d:
            b = d[abs_remain]
            if remain < 0:
                b = -b
            break

    print("{} {}".format(a, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 23916
#include<bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<double,int> D;
const double EPS = 1e-8;

P p[100];
double r[100],d[100];
int n,s,g;

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;   // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(cross(b,c) < -EPS) return -1; // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool isIntersect(L s1, L s2){
  return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
           ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}

double getDistanceSP(L s, P p){
  if(dot(s.second - s.first, p - s.first) < -EPS) return abs(p - s.first);
  if(dot(s.first - s.second, p - s.second) < -EPS) return abs(p - s.second);
  return abs(cross(s.second - s.first, p - s.first) / abs(s.second - s.first)); }

double getDistanceSS(L s1, L s2){
  if(isIntersect(s1,s2)) return 0.0;
  return min( min(getDistanceSP(s1, s2.first), getDistanceSP(s1, s2.second)),
              min(getDistanceSP(s2, s1.first), getDistanceSP(s2, s1.second)));
}

double cal(){
  for(int i=0;i<n;i++)cin>>p[i].x>>p[i].y>>d[i]>>r[i];
  
  priority_queue<D,vector<D>,greater<D> > Q;
  int used[100]={};
  Q.push(D(0,s-1));
  while(!Q.empty()){
    double cs=Q.top().first;
    int pos=Q.top().second;
    Q.pop();
    if(used[pos]++)continue;
    if(pos==g-1)return cs;
    
    for(int i=0;i<n;i++){
      if(i==pos)continue;

      for(int j=0;j<5;j++){
	
	double na=M_PI*(d[i]+72*j+90)/180;
	double na1=M_PI*(d[i]+72*(j+2)+90)/180;
	L S=L(P(r[i]*cos(na),r[i]*sin(na))+p[i],P(r[i]*cos(na1),r[i]*sin(na1))+p[i]);
	for(int k=0;k<5;k++){
	  double nb=M_PI*(d[pos]+72*k+90)/180;
	  double nb1=M_PI*(d[pos]+72*(k+2)+90)/180;
	  L G=L(P(r[pos]*cos(nb),r[pos]*sin(nb))+p[pos],P(r[pos]*cos(nb1),r[pos]*sin(nb1))+p[pos]);
	  Q.push(D(cs+getDistanceSS(S,G),i));
	}
      }
    }
  }
}

int main(){
  while(cin>>n>>s>>g,n)printf("%.8lf\n",cal());
  return 0;
}

Measured memory_bytes: 10524
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt(),d = sc.nextInt(),z = 0;
        while(true){
            c -= b;
            a -= d;
            if(c <= 0) {
                System.out.println("Yes");
                System.exit(0);
            }if(a <= 0){
                System.out.println("No");
                System.exit(0);
            }
        }
    }
}


Measured memory_bytes: 35936
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main :: IO ()
main = do
  [n, l] <- map read . words <$> getLine
  a <- zip [1..n] . map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  let
    f [_] = []
    f ((i, x):(j, y):xs) = if x + y >= l then i : f ((j, y):xs) else f ((j, y):xs)
    po = f a
  if null po
    then putStrLn "Impossible"
    else do
      putStrLn "Possible"
      let x = head po
      putStr $ unlines $ map show $ [1..x-1] ++ reverse [x+1..n-1] ++ [x]


Measured memory_bytes: 10876