akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
flag = true
words = %W(#{gets.chomp})
(n-1).times do |_|
  w = gets.chomp
  if words.include?(w) || words.last[-1] != w[0,1]
    flag = false
    break
  else
    words << w
  end
end

puts flag ? 'Yes' : 'No' 

Measured memory_bytes: 3836
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don’t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         char[] arr = input.toCharArray();
         int N = arr.length;
         String prev = ""+arr[0];
         String t = "";
         int res = 1;
         for(int i=1; i < N; i++)
         {
            t += arr[i];
            if(!t.equals(prev))
            {
               res++;
               prev = t;
               t = "";
            }
         }
         System.out.println(res);
      }
   }

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

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

    string s;cin>>s;
    vector<ll>a(s.size()+1);
    for(ll i = 0; i < s.size();i++)
    {
        if(s[i] == '<')a[i+1] = a[i]+1;
    }


    for(ll i = s.size()-1 ; i >= 0;i--)
    {
        if(s[i] == '>')a[i] =max( a[i+1]+1,a[i]);
    }


    ll sum = 0;

    rep(i,a.size())
    {
        sum += a[i];
    }

    cout<<sum<<endl;
    

    return 0;
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  cin >> a;
  priority_queue<int> q;
  rep(i, n) q.push(a[i]);
  rep(i, m) {
    int x = q.top();
    q.pop();
    q.push(x / 2);
  }
  ll ans = 0;
  rep(i, n) {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}
// x/2/2 = x/(2^2) ?

Measured memory_bytes: 4296
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

        ll pow(ll base, ll q, ll mod){
            ll answer = 1;
            while(q > 0){
                if(q & 1LL)
                    answer = (answer * base) % mod;

                q = q >> 1LL;
                base = (base*base) % mod;
            }
            return answer % mod;
        }


        
       
        
        void solve(){
            cin >> n;
            int cnt = 0;
            for(int i=1; i <= n; i++){
                cin >>a;
                if(i%2 && a%2)cnt++;
            }
            cout << cnt << endl;
        }
            
            
        



            



        int main(){
            ios_base::sync_with_stdio(false);

            

    

            

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define reg register
using namespace std;
inline int read()
{
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int m,d,p;
int main()
{
    m  = read();d = read();
    for(int i = 10;i <= d; i++)
    {
        int x = i % 10,y = i / 10;
        if(x >= 2 && y >= 2 &&x * y <= m) p++;
    }
    cout<<p;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

void solve(){
    int N;
    string s;
    cin >> N;
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }
    cin >> s;
    vl ass;
    rrep(i,N){
        ll z=A[i];
        rep(i,ass.size()){
            chmin(z,z^ass[i]);
        }
        if(z){
            if(s[i]=='1'){
                cout << 1 << '\n';
                return;
            }
            ass.pb(z);
        }
    }
    cout << 0 << '\n';
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while(T--){
        solve();
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
  ll N, K, ans;
  cin >> N >> K;

  ans = K;

  for (ll i = 1; i<N; i++){
    ans *=(K-1);
  }

    cout << ans <<endl; 

    return 0;
}

Measured memory_bytes: 256
n= int(input())
ABC = [0]*n
for i in range(n):
  ABC[i]= list(map(int, input().split()))

dp = [[0 for i in range(3)] for j in range(n)]
dp[0] = ABC[0]

for i in range(1,n):
  for j in range(3):
    dp[i][j] = ABC[i][j]+max(dp[i-1][j-1],dp[i-1][j-2])
    
print(max(dp[n-1]))


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CStrawberryCakes {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int H, W, K;
        cin >> H >> W >> K;
        vector<vector<char>> b(H, vector<char>(W));
        REP(i, H) {
            REP(j, W) {
                cin >> b[i][j];
            }
        }

        vector<int> cnt(H);
        REP(i, H) {
            REP(j, W) {
                if (b[i][j] == '#') {
                    cnt[i]++;
                }
            }
        }

        int idx = 0;
        vector<vector<int>> res(H, vector<int>(W));
        REP(i, H) {
            if (cnt[i] == 0) continue;
            bool first = true;
            idx++;
            REP(j, W) {
                if (b[i][j] == '#') {
                    if (first) {
                        first = false;
                    } else {
                        idx++;
                    }
                }
                res[i][j] = idx;
            }
        }

        FOR(i, 1, H - 1) {
            if (cnt[i] != 0) continue;
            int ni = i - 1;
            REP(j, W) {
                res[i][j] = res[ni][j];
            }
        }
        REV(i, H - 2, 0) {
            if (cnt[i] != 0) continue;
            int ni = i + 1;
            REP(j, W) {
                res[i][j] = res[ni][j];
            }
        }

        REP(i, H) {
            REP(j, W) {
                cout << res[i][j] << " ";
            }
            cout << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CStrawberryCakes solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main() {
    char b;
    cin >> b;
    if(b=='A'){
        cout << 'T' << endl;
    }else if(b=='T'){
        cout << 'A' << endl;
    }else if(b=='C'){
        cout << 'G' << endl;
    }else if(b=='G'){
        cout << 'C' << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a,b,v,w,t;
  cin>>a>>v>>b>>w>>t;
  if(t*(v-w)<abs(a-b)) cout<<"NO";
  else cout<<"YES";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int box[100002];
bool red[100002];
int main(){
        REP(i,100002){
            box[i]=1;
            red[i]=false;
        }
        red[1]=true;
	int N,M;
	cin>>N;
	cin>>M;
        REP(i,M){
            int x,y;
            cin>>x>>y;
            box[x]--;
            box[y]++;
            if(red[x]){
               red[y]=true;
            }
            if(box[x]==0){
               red[x]=false;
            }
        }
        int ans=0;
        REP(i,N+1){
            if(red[i]){
               ans++;
            }
        }
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 768
#include<stdio.h>
#define lim(n) n>=0&&n<8
char D[9][10]={0},x;
int i,j,k,c,t,m=0,f,p,r,e;

int dfs(int x,int y,char p,int f)
{
	int mv[3]={-1,0,1},i,j,c,r=0,tx,ty;
	for(i=0;i<4;i++)
		for(j=0;j<4;j++)
		{
			if(f)D[y][x]=(p=='o'?'x':'o');
			for(c=0,tx=x+mv[j],ty=y+mv[i];lim(tx)&&lim(ty)&&D[ty][tx]==p;tx+=mv[j],ty+=mv[i],c++);
			if(lim(tx)&&lim(ty)&&D[ty][tx]==(p=='o'?'x':'o'))
			{
				r+=c;
				if(f)
					for(tx-=mv[j],ty-=mv[i];!(tx==x&&ty==y);tx-=mv[j],ty-=mv[i])
						D[ty][tx]=(p=='o'?'x':'o');
			}
		}
	return r;
}

int main()
{
	for(i=c=t=0;i<8;i++)
		{
			gets(D[i]);
		}
	
	for(f=0;f<100;f++)
	{
		if(f%2)//cheeze
		{
			for(i=7,r=0,p=-1;i>=0;i--)
				for(j=7;j>=0;j--)
					if(D[i][j]=='.'&&(e=dfs(j,i,'o',0))>r)r=e,p=i*10+j;
			if(p!=-1)
				dfs(p%10,p/10,'o',1);
		}
		else//chocolate
		{
			for(i=r=0,p=-1;i<8;i++)
				for(j=0;j<8;j++)
					if(D[i][j]=='.'&&(e=dfs(j,i,'x',0))>r)r=e,p=i*10+j;
			if(p!=-1)
				dfs(p%10,p/10,'x',1);
		}
	}
	for(i=0;i<8;i++)puts(D[i]);
	return 0;
}

Measured memory_bytes: 524
import sys
input = sys.stdin.readline

S=input().strip()

N = len(S)//2
i = 0
while True:
    i += 1
    a = S[0:(N-i)]
    b = S[(N-i):(2*N-2*i)]
    if a == b:
        print(len(a)*2)
        exit()


Measured memory_bytes: 61604
#include <stdio.h>

int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d", &a,&b,&c,&d);
	if (c > b || d < a) {
		printf("%d", 0);
	}
	else if (a <= c && b <= d) {
		printf("%d", b - c);
	}
	else if (c <= a&&d <= b) {
		printf("%d", d - a);
	}
	else if (a <= c&&d <= b) {
		printf("%d", d - c);
	}
	else {
		printf("%d", b - a);
	}
	return 0;
}


Measured memory_bytes: 128
def minesweeper(grid, x, y):
    if grid[x][y] == '.':
        cnt = 0
        for i in range(x-1, x+2): 
            if i < 0 or H-1 < i:
                pass
            else :
                for j in range(y-1, y+2):
                    if j < 0 or W - 1 < j:
                        pass
                    else :
                        if grid[i][j] == '#':
                            cnt += 1
        grid[x][y] = str(cnt)
    return grid


H, W = [int(i) for i in input().split()]

grid = []
for h in range(H):
    grid.append([l for l in input()])
    
for x in range(H):
    for y in range(W):
        grid = minesweeper(grid, x, y)
        
for row in grid:
    print(''.join(row))


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#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;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int a,b; cin >> a >> b;
  int c[100000000][1900000000];
  c[a-2*b][11110] = a;
  cout << max(a - 2*b, 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
import Data.Bool (bool)

main :: IO ()
main = do
  getLine
  ls <- map read . words <$> getLine
  putStrLn (f ls)

f :: [Int] -> String
f = bool "No" "Yes" . ((<) <$> (* 2) . fst <*> snd) . foldr step (0, 0)
  where
    step l (m, s) = (bool m l (m < l), s + l)


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin>>S;
  int N=S.length();
  ll dp[N+1][4];
  for(int i=0;i<=N;i++){
    for(int j=0;j<=3;j++){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  for(int i=0;i<N;i++){
    if(S[i]=='A'){
      dp[i+1][1]+=dp[i][0];
      dp[i+1][0]+=dp[i][0];
      dp[i+1][1]+=dp[i][1];
      dp[i+1][2]+=dp[i][2];
      dp[i+1][3]+=dp[i][3];
      dp[i+1][0]%=MOD;
      dp[i+1][1]%=MOD;
      dp[i+1][2]%=MOD;
      dp[i+1][3]%=MOD;
    }
    if(S[i]=='B'){
      dp[i+1][2]+=dp[i][1];
      dp[i+1][0]+=dp[i][0];
      dp[i+1][1]+=dp[i][1];
      dp[i+1][2]+=dp[i][2];
      dp[i+1][3]+=dp[i][3];
      dp[i+1][0]%=MOD;
      dp[i+1][1]%=MOD;
      dp[i+1][2]%=MOD;
      dp[i+1][3]%=MOD;
    }
    if(S[i]=='C'){
      dp[i+1][3]+=dp[i][2];
      dp[i+1][0]+=dp[i][0];
      dp[i+1][1]+=dp[i][1];
      dp[i+1][2]+=dp[i][2];
      dp[i+1][3]+=dp[i][3];
      dp[i+1][0]%=MOD;
      dp[i+1][1]%=MOD;
      dp[i+1][2]%=MOD;
      dp[i+1][3]%=MOD;
    }
    if(S[i]=='?'){
      dp[i+1][1]+=dp[i][0];
      dp[i+1][2]+=dp[i][1];
      dp[i+1][3]+=dp[i][2];
      dp[i+1][0]+=3*dp[i][0];
      dp[i+1][1]+=3*dp[i][1];
      dp[i+1][2]+=3*dp[i][2];
      dp[i+1][3]+=3*dp[i][3];
      dp[i+1][0]%=MOD;
      dp[i+1][1]%=MOD;
      dp[i+1][2]%=MOD;
      dp[i+1][3]%=MOD;
    }
  }
  cout<<dp[N][3]<<endl;
}


Measured memory_bytes: 3664
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

q=int(input())
ab=[list(map(int,input().split())) for i in range(q)]

for i,j in ab:
    i,j=min(i,j),max(i,j)
    if i==j:
        print(2*i-2)
    elif i+1==j:
        print(2*i-2)
    else:
        ne=int((i*j)**0.5)
        if ne*ne==i*j:
            ne-=1
        if ne*(ne+1)>=i*j:
            print(2*ne-2)
        else:
            print(2*ne-1)

Measured memory_bytes: 75516
# C
def perm(N):
    ans = 1
    for i in range(2, N+1):
        ans *= i
    return ans

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
distance_list = []
for i in range(N-1):
    for k in range(i+1, N):
        distance_list.append(((xy[i][0] - xy[k][0]) ** 2 + (xy[i][1] - xy[k][1]) ** 2) ** 0.5)
##print(distance_list)
tmp = sum(distance_list)
cnt = perm(N-1) * 2
##print(tmp, cnt, perm(N))
print(tmp * cnt / perm(N))

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	var S string
	fmt.Scan(&S)
	MOD := int(math.Pow10(9) + 7)
	N := len(S)
	T := "ABC"

	DP := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		DP[i] = make([]int, 4)
	}
	DP[N][3] = 1

	for i := N - 1; i >= 0; i-- {
		for j := 0; j < 3; j++ {
			m1, m2 := 1, 0
			if S[i] == '?' {
				m1, m2 = 3, 1
			} else if S[i] == T[j] {
				m2 = 1
			}
			DP[i][j] = (m1*DP[i+1][j] + m2*DP[i+1][j+1]) % MOD
		}
		if S[i] == '?' {
			DP[i][3] = (3 * DP[i+1][3]) % MOD
		} else {
			DP[i][3] = DP[i+1][3]
		}
	}
	fmt.Println(DP[0][0])
}


Measured memory_bytes: 7888
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum[ohara], k, q, p, v;
U_MAP mp;

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

  cin >> n >> m >> v >> p;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  rep(i, n) sum[i] = a[i];
  rrep(i, 1, n) sum[i] += sum[i - 1];
  rrep(i, n - p, n) { mp[a[i]] = 1; }
  rrrep(i, n - p - 1, 0LL) {
    ll ju = m * v, af = a[i], cost;
    af += m;
    ju -= m;
    ju -= (p - 1) * m;
    ju -= i * m;
    ju = max(ju, 0LL);
    cost = sum[n - p];
    cost -= sum[i];
    k = (n - p) - i;
    tmp = ((cost + ju) % k == 0 ? (cost + ju) / k : (cost + ju) / k + 1);
    tmp = max(tmp, a[n - p]);
    if (af >= tmp) mp[a[i]] = 1;
  }
  rep(i, n) {
    if (mp[a[i]]) ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
#define fi first
#define sec second
#define INF 1000000000
int N,M;
vector<int> g[100100];
int match[100100];
bool used[100100];
void add_edge(int a,int b){
	g[a].pb(b);
	g[b].pb(a);
}
bool dfs(int v){
	used[v] = true;
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		int w = match[u];
		if(w<0 ||!used[w]&&dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}
int bipartite(){
	int res = 0;
	memset(match,-1,sizeof(match));
	for(int v=0;v<2*N;v++){
		if(match[v]<0){
			memset(used,0,sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}
void efs(int v){
	used[v] = true;
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(used[u])continue;
		efs(u);
	}
	return;
}
int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int x,y;
		cin >> x >> y;
		x--;y--;
		add_edge(x,y+N);
	}
	int cmp = 0;
	memset(used,false,sizeof(used));
	for(int i=0;i<2*N;i++){
		if(!used[i]){
			if(g[i].size()==0)continue;
			efs(i);
			cmp++;
		}
	}
	cout << M-bipartite() << ' ' << M-cmp << endl;
	return 0;
}



Measured memory_bytes: 6028
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,aa;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n;
    cout << "3 5 22 "; ///summa %30==0
    i=3;
    if (n%2==0)
    {
        cout << "30 ";
        i++;
    }
    m=30;
    while (i<n&&m+30<=30000)
    {
        j=28;
        while (j>0&&i<n)
        {
            if (m==30&&j==8)
            {

            }
            else
            {
                cout << m-j << " " << m+j << " ";
                i+=2;
            }
            j-=2;
        }
        m+=60;
    }
    m=30;
    while (i<n&&m+30<=30000)
    {
        j=27;
        if (m==30)
        {
            j=21;
        }
        while (j>0&&i<n)
        {
            cout << m-j << " " << m+j << " ";
            j-=6;
            i+=2;
        }
        m+=60;
    }
    m=30;
    while (i<n&&m+30<=30000)
    {
        j=25;
        if (m==30)
        {
            j=5;
        }
        while (j>0&&i<n)
        {
            cout << m-j << " " << m+j << " ";
            j-=20;
            i+=2;
        }
        m+=60;
    }
    //cout << i << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
struct Plate{
  int w, s, v;
  Plate(){}
  Plate(int _w, int _s, int _v){
    w = _w;
    s = _s;
    v = _v;

  }
} ps[1001];
int n;
ll dp[1001][10001];
ll solve(int in, int can){
  if(can < 0)
    return -1e9;
  if(in == n)
    return 0;
  if(dp[in][can] != -1)
    return dp[in][can];
  return dp[in][can] = max(solve(in + 1, can), ps[in + 1].v + solve(in + 1, min(can - ps[in + 1].w, ps[in + 1].s)));
}
int main()
{
//  freopen("lcm.in", "r", stdin);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
//  cout << 300 << endl;
//  for(int i = 0;i < 300;i++){
//    cout << rand() % 10000 + 1 << ' ' << rand() % 10000 + 1 << ' ' << rand() % 1000000000 + 1 << endl;
//  }
//  return 0;
  cin >> n;
  for(int i = 0;i < n;i++)
    cin >> ps[i].w >> ps[i].s >> ps[i].v;
  sort(ps, ps + n, [](const Plate& a, const Plate& b){
    return min(a.s, b.s - a.w) < min(b.s, a.s - b.w);
  });
  memset(dp, -1, sizeof(dp));

  ll res = 0;
  for(int i = 0;i < n;i++)
    res = max(res, ps[i].v + solve(i, ps[i].s));
  cout << res;
  return 0;
}


Measured memory_bytes: 78592
#include <stdio.h>
 
int main(void){
    int n,ary[100],i,j,buf;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&ary[i]);
    for(i=n-1;i>=0;i--){
        printf("%d",ary[i]);
        if (i>0) printf(" ");
        else printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    char a[4];
    scanf("%s", a);
    for (int i = 0; i < 3; i++)
        if (a[i] == '1' || a[i] == '9')
            a[i] ^= 8;
    printf("%s", a);
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    return arr

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 2*10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

P, Q = map(int,input().split())
L = factorization(Q)
ans = 1
for i in L:
    ans *= cmb(P-1+i,i,mod)

print(ans % mod)

Measured memory_bytes: 81008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair

string s;
set<string > ans;
int n, k;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> s >> k;
n= s.size()-1;
/*
if(n<=50){
    rep(i, 0, n){
    rep(j, i, n){
    ans.pb(s.substr(i, j-i+1))
    }
    }
    sort(ans.begin(), ans.end());
    cout << ans[k-1] << endl;
}
*/
rep(i, 0, n){

rep(j, i, i+5){
ans.insert(s.substr(i, j-i+1));
}

}

int u = 0;

for(auto t: ans){
    u++;
    if(u==k){
        cout << t << endl;
        return 0;
    }

}

return 0;}


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    double n,m,d; cin >> n >> m >> d;
    double ans;
    if(d == 0){
        ans = 1.0/n;
        ans *= (m-1);
        printf("%.10lf",ans);
    }else{
        ans = (2.0 * (n-d))/(n*n);
        ans *= (m-1);
        printf("%.10lf",ans);
    }
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int X, Y;
signed main() {
    cin >> X >> Y;
    int ans = 0;
    if (X == 1) { ans += 300000; }
    if (X == 2) { ans += 200000; }
    if (X == 3) { ans += 100000; }
    if (Y == 1) { ans += 300000; }
    if (Y == 2) { ans += 200000; }
    if (Y == 3) { ans += 100000; }
    if (X == 1 && Y == 1) { ans += 400000; }
    cout << ans << endl;
}


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

template <typename X>
struct SegmentTree {
    using FX = function<X(X, X)>;
    int n;
    FX fx;
    const X ex;
    vector<X> dat;
    SegmentTree(int n_, FX fx_, X ex_) : fx(fx_), ex(ex_) {
        int x = 1;
        while (n_ > x) x *= 2;
        n = x;
        dat.resize(n * 2, ex);
    }

    X get(int i) {
        return dat[i + n - 1];
    }
    void set(int i, X x) {
        dat[i + n - 1] = x;
    }
    void build() {
        for (int i = n - 2; i >= 0; --i) {
            dat[i] = fx(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    void update(int i, X x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    X query(int a, int b) {
        return query_sub(a, b, 0, 0, n);
    }
    X query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return ex;
        }
        else if (a <= l && r <= b) {
            return dat[k];
        }
        else {
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
};

int main() {
    unsigned int n, q, c, x, y;
    cin >> n >> q;
    SegmentTree<unsigned int> rsq(n,
    [](unsigned int x1, unsigned int x2) -> int { return x1 + x2; },
    0 );
    while (q--) {
        cin >> c >> x >> y;
        x--;
        if (c == 0) {
            rsq.update(x, rsq.get(x) + y);
        }
        else {
            cout << rsq.query(x, y) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3836
// 26.07.2020
// 00:38:12

#pragma GCC optimize("O3")

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

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    int x;
    cin >> x;
    for (int i = 0; i < 100; ++i) {
        if (x < 400 + (200 * (i + 1))) {
            cout << 8 - i << '\n';
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3536
#define DEBUG 0

/**
 * File    : F2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-27 01:10:29
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll s[100010];
ll ans = 0;

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> s[i];
  }
  for (auto C = 1; C < N; C++)
  {
    set<int> S;
    ll score = 0;
    int x = 0;
    while (true)
    {
      if (x * C >= N)
      {
        break;
      }
      int A = (N - 1) - x * C;
      int B = A - C;
      if (B <= 0)
      {
        break;
      }
      int forward = N - 1 - x * C;
      if (S.find(forward) != S.end())
      {
        break;
      }
      score += s[forward];
      S.insert(forward);
      int back = x * C;
      if (S.find(back) != S.end())
      {
        break;
      }
      score += s[back];
      S.insert(back);
      ans = max(ans, score);
      x++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[6];
    for(int i=1;i<=5;i++)
    {
        cin>>arr[i];
        if(arr[i]==0)
        {
            cout<<i;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(){

    int a,b;
    int d,r;
    double f;
    
    scanf("%d %d",&a,&b);

    d=a/b;
    r=a%b;
    f=1.000000*a/b;
    
    printf("%d %d %.7lf\n",d,r,f);
    
    return 0;
    
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


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

	REP(i, N)cout << out[i] << " ";
	cout << endl;


	return 0;
}


Measured memory_bytes: 1664
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Collections;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        int n;
        List<long[]> ls = new List<long[]>();

        public void ParseLines()
        {
            n = int.Parse(InputReader.ReadLine());
            foreach (var i in Enumerable.Range(0, n))
            {
                ls.Add(InputReader.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray());
            }

        }

        public class Table
        {
            public long PointA { get; set; } = 0;
            Person A { get; }
            Person B { get; }
            int[] _dishes;

            public Table(Person a, Person b, int ndish)
            {
                this.A = a;
                this.B = b;
                this._dishes = Enumerable.Range(0, ndish).ToArray();
            }

            public long CalculatePoint()
            {
                PointA += _dishes
                .Select(x => A.Taste[x] + B.Taste[x])
                .OrderBy(x => -x)
                .Select((x, i) => x * ((i+1) % 2))
                .Sum();

                PointA -= B.Taste.Values.Sum(x => x);
                return PointA;
            }


        }


        public class Person
        {
            public Dictionary<int, long> Taste { get; }
            public long HappyScore { get; set; } = 0;

            public Person(Dictionary<int, long> taste)
            {
                Taste = taste;
            }

        }


        public string Resolve()
        {
            var range = Enumerable.Range(0, n);

            var a = new Person(range.ToDictionary(i => i, i => ls[i][0]));
            var b = new Person(range.ToDictionary(i => i, i => ls[i][1]));

            var table = new Table(a, b, n);

            return table.CalculatePoint().ToString();
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}

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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll mod=1e9+7;



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

int test=1;
//cin>>test;
while(test--)
{

	int k;
	string s;
	cin>>k>>s;
	for(int i=0;i<min(k,int(s.size()));i++)
		cout<<s[i];
	if(k<s.size())cout<<"...\n";
}
return 0;
}










Measured memory_bytes: 3652
#include <bits/stdc++.h>
  
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 all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int s = max(a, c), t = min(b, d);
	cout << max(0, t -s) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int b, f, r, v;
    int n = sc.nextInt();
    int[][][] room = new int[4][3][10];

    for (int i = 0; i < n; i++) {
      b = sc.nextInt();
      f = sc.nextInt();
      r = sc.nextInt();
      v = sc.nextInt();
      room[b - 1][f - 1][r - 1] += v;
    }

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 10; k++) {
          System.out.print(" " + room[i][j][k]);
        }
        System.out.println();
      }
      if (i != 3)
        System.out.println("####################");
    }
  }
}

Measured memory_bytes: 29152
N = int(input())

if N <= 111:
  print('111')
elif N <= 222:
  print('222')
elif N <= 333:
  print('333')
elif N <= 444:
  print('444')
elif N <= 555:
  print('555')
elif N <= 666:
  print('666')
elif N <= 777:
  print('777')
elif N <= 888:
  print('888')
elif N <= 999:
  print('999')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  if (A + B < 24) {
    cout << A + B << endl;
  } else {
    cout << A + B - 24 << endl;
  }
  
  
  return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;

    pr((N<=1?0:(N*(N-1))/2)+(M<=1?0:(M*(M-1))/2));
}

Measured memory_bytes: 256
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) when x < y -> Node (y, doit l, r)
    | Node (y, l, r) -> Node (y, l, doit r)
  in doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (f x; doit l; doit r)
  in doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (doit l; f x; doit r)
  in doit t

let print t =
  let f e = print_string " "; print_int e in
  inorder f t;
  print_newline ();
  preorder f t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r
  in doit t

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = sub s 0 i in
        doit s1 (sub s (i + 1) (length s - length s1 - 1) :: acc)
  in doit str []

let () =
  let m = read_int () in
  let rec read i t =
    if i < m then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> read (i + 1) (insert (int_of_string n) t)
      | ["find"; n] -> (print_endline (if find (int_of_string n) t then "yes" else "no"); read (i + 1) t)
      | _ -> (print t; read (i + 1) t)
    end in
  read 0 (create ())

Measured memory_bytes: 25064
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> Q = new ArrayDeque<>();
		
		StringTokenizer st = new StringTokenizer(sc.nextLine(), " ");
		while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		}
		System.out.println(Q.pop());
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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


Measured memory_bytes: 26216
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	while (n--) {
		string s;
		cin >> s;
		if (s == "AC") ac++;
		if (s == "WA") wa++;
		if (s == "TLE") tle++;
		if (s == "RE") re++;
	}
	cout << "AC x " << ac << '\n';
	cout << "WA x " << wa << '\n';
	cout << "TLE x " << tle << '\n';
	cout << "RE x " << re << '\n';
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)

using namespace std;
int W,H,N,x,y,nub,ans;
int vis[110][110];
int main()
{
    cin>>W>>H>>N;
    for(int k=1;k<=N;++k)
    {
        cin>>x>>y>>nub;
        if(nub==1)
        {
            for(int i=1;i<=H;++i)
            {
                for(int j=1;j<=x;++j)
                {
                    vis[j][i]=1;
                }
            }
        }
        else if(nub==2)
        {
            for(int i=1;i<=H;++i)
            {
                for(int j=x+1;j<=W;++j)
                {
                    vis[j][i]=1;
                }
            }
        }
        else if(nub==3)
        {
            for(int i=1;i<=W;++i)
            {
                for(int j=1;j<=y;++j)
                {
                    vis[i][j]=1;
                }
            }
        }
        else if(nub==4)
        {
            for(int i=1;i<=W;++i)
            {
                for(int j=y+1;j<=H;++j)
                {
                    vis[i][j]=1;
                }
            }
        }
    }
    for(int i=1;i<=W;++i)
    {
        for(int j=1;j<=H;++j)
        {
            //cout<<vis[i][j]<<" ";
            if(vis[i][j]==0)
            {
                ans++;
            }
        }
        //cout<<endl;
    }

    cout<<ans;
}


Measured memory_bytes: 256