akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,C;
	string s;
	while(cin>>N>>K>>C>>s) {
		VI p(K);
		ll si=0;
		REP(i, K) {
			while(s[si]=='x' || si <= (0<=i-1 ? p[i-1] : -INF)+C) si++;
			p[i] = si;
			si++;
		}
		VI origP(p);
//		DD(p);
		REPR(i, K) {
			ll si = i+1 < K ? p[i+1] : N-1;
			while(s[si]=='x' || (i+1<K && p[i+1]<=si+C)) si--;
			p[i] = si;
//			DD(i);
//			DD(p);
		}
		REP(i, K) {
			if(origP[i]==p[i]) cout<<origP[i]+1<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 4988
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
signed main() {
	int cnta=0, cntb=0, cntc=0, cntd=0;
	string s, p;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N')cnta++;
		if (s[i] == 'S')cntb++;
		if (s[i] == 'E')cntc++;
		if (s[i] == 'W')cntd++;
		if (cnta&&cntb == 0)p = "No";
		else if (cnta == 0 && cntb)p = "No";
		else if (cntc&&cntd == 0)p = "No";
		else if (cntc == 0 && cntd)p = "No";
		else p = "Yes";
	}
	cout << p << endl;
	ll
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

d = defaultdict(int)

for i in input():
	d[i]+=1
#print(d)
if abs(d["a"]-d["b"])<2 and abs(d["b"]-d["c"])<2 and abs(d["a"]-d["c"])<2:
	print("YES")
else:
	print("NO")

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

int main(){
	int n;
	cin >> n;
	vector<long long int> h(n);
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	bool flag = true;
	for(int i = 0; i < n; i++){
		if(i != 0 && i != n-1){
			if(h[i]-1 - h[i-1] >= 0)h[i] -= 1;
		}else if(i == 0){
			h[i] -= 1;
		}else if(i == n-1){

		}
	}
	for(int i = 0; i < n - 1; i++){
		if(h[i] > h[i+1]) flag = false;
	}
	string ans = (flag == true)? "Yes": "No";
	cout << ans << endl;

}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a == 1 {
		a = 14
	}
	if b == 1 {
		b = 14
	}

	if a == b {
		fmt.Println("Draw")
	} else if a > b {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}


Measured memory_bytes: 512
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

from collections import deque
import itertools

h,w = map(int,readline().split())
cx,cy = map(int,readline().split())
gx,gy = map(int,readline().split())
cx -= 1
cy -= 1
grid = [readline().rstrip() for i in range(h)]

dist = [[INF]*w for i in range(h)]
dist[cx][cy] = 0

l2 = list(itertools.product([-2,-1,0,1,2],repeat = 2))
l1 = [(-1,0),(1,0),(0,-1),(0,1)]
q1 = deque([(cx,cy)])
q2 = deque([(cx,cy)])

while q1 or q2:
    if q1:
        x,y = q1.popleft()
        for dy,dx in l1:
            ny,nx = y+dy, x+dx
            if not (0 <= ny < w and 0 <= nx < h):
                continue
            if grid[nx][ny] == '#':
                continue
            if dist[nx][ny] != INF:
                continue
            if dist[nx][ny] > dist[x][y]:
                dist[nx][ny] = dist[x][y]
                q1.append((nx,ny))
                q2.append((nx,ny))
    else:
        x,y = q2.popleft()
        for dy,dx in l2:
            ny,nx = y+dy, x+dx
            if not (0 <= ny < w and 0 <= nx < h):
                continue
            if grid[nx][ny] == '#':
                continue
            if dist[nx][ny] != INF:
                continue
            if dist[nx][ny] > dist[x][y]+1:
                dist[nx][ny] = dist[x][y]+1
                q1.append((nx,ny))
                q2.append((nx,ny))

print(dist[gx-1][gy-1] if dist[gx-1][gy-1] != INF else -1)




Measured memory_bytes: 87016
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define MOD 1000000007

using namespace std;

ll powa(ll a, ll b, ll z)
{
    a%=z;
    ll res = 1;
    while(b>0)
    {
        if(b%2 == 1)
            res*=a, res%=z;
        a*=a;
        a%=z;
        b>>=1;
    }
    return res;
}

int main()
{
   FAST/**/
    
   string s;
   cin>>s;
   
   ll n = s.length();
   ll dp[13];
   memset(dp,0,sizeof(dp));
   ll curr = 0;
   for(ll i=0;i<n;i++)
   {
       if(s[i] == '?')
            continue;
      ll temp = (s[i] - 48);
      temp*=powa(10,n-1-i,13);
      temp%=13;
      curr+=temp;
      curr%=13;
   }
   
   dp[curr] = 1;
   //cout<<"curr = "<<curr<<"\n";
   
   for(ll i=0;i<n;i++)
   {
       if(!(s[i] == '?'))
            continue;
       ll inc[13];
       memset(inc,0,sizeof(inc));
       ll mul = powa(10,n-1-i,13);
       //cout<<"mul = "<<mul<<"\n";
       for(ll j=0;j<=9;j++)
       {
           for(ll i1=0;i1<13;i1++)
           {
               ll temp = mul*j + i1;
               temp%=13;
               inc[temp]+=dp[i1];
               inc[temp]%=MOD;
               //cout<<"obtained "<<temp<<" at "<<dp[i1]<<"\n";
           }
       }
       
       for(ll i=0;i<13;i++)
            dp[i]=inc[i], dp[i]%=MOD;
   }
   /*for(ll i=0;i<13;i++)
        cout<<dp[i]<<" ";
   cout<<"\n";   */     
   cout<<dp[5];
   
   return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  for(int b=0;b<(1<<3);++b){
    int ans = S[0] - '0';
    for(int i=1;i<4;++i){
      if(b & (1<<(i-1))){
        ans += S[i] - '0';
      }else{
        ans -= S[i] - '0';
      }
    }
    if (ans == 7){
      for(int i=0;i<3;++i){
        cout << S[i];
        if(b & (1<<i)){
          cout << '+';
        }else{
          cout << '-';
        }
      }
      cout << S[3] << "=7" << endl;
      return 0;
    }
  }



}


Measured memory_bytes: 3604
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

#define MAX_V 200000

struct edge{
	int to;
	long long int cost;
	long long int c;
};

vector<edge> G[MAX_V];
long long int d[MAX_V];

// 速さはO(|E|log|V|)

void shortest_path(int s, int V){ // Vは頂点数
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // 頂点への最小コストを更新
	}
}

int main(){
	while(true){
		int N, M;
		cin >> N >> M;
		if(N == 0){
			break;
		}
		for(int i = 0; i < N; i++){
			G[i].clear();
		}
		for(int i = 0; i < M; i++){
			int u, v, d, c;
			cin >> u >> v >> d >> c;
			u--;
			v--;
			edge e;
			e.to = v;
			e.cost = d;
			e.c = c;
			G[u].push_back(e);
			e.to = u;
			G[v].push_back(e);
		}
		shortest_path(0, N);
		long long int ans = 0;
		for(int i = 1; i < N; i++){
			long long int mini = INF;
			for(int j = 0; j < G[i].size(); j++){
				if(d[i] == G[i][j].cost + d[G[i][j].to]){
					mini = min(mini, G[i][j].c);
				}
			}
			ans += mini;
		}
		cout << ans << endl;
	}
	return 0;
}




Measured memory_bytes: 11056
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define pb push_back
#define LN 30
#define P(x) (100+(x))
using namespace std;
vector<string> ans;
I void Pow(CI x,CI p) {cout<<"+ 1000 "<<x<<" 9\n";for(int i=1;i<=p;++i) puts("+ 9 9 9");}
I void Mul(CI x)
{
	puts("+ 1000 1000 10"),puts("+ 1000 1000 11");for(RI i=LN;~i;--i)
		cout<<"+ 11 "<<P(i)<<" 12\n",puts("< 12 5 13"),Pow(13,i),puts("+ 11 9 11"),
		cout<<"+ "<<x<<" 13 14\n",puts("< 3 14 14"),Pow(14,i),puts("+ 10 9 10");
}
int main()
{
	RI i;puts("37731"),puts("+ 0 1 3"),puts("< 1000 3 3"),puts("+ 0 3 4"),puts("+ 1 3 5");
	for(puts("+ 3 100 100"),i=1;i<=LN;++i) cout<<"+ "<<P(i)-1<<" "<<P(i)-1<<" "<<P(i)<<endl;
	for(i=LN;~i;--i) cout<<"+ 6 "<<P(i)<<" 7\n",puts("< 7 4 8"),
		Pow(8,i),puts("+ 6 9 6"),Mul(8),Pow(10,i),puts("+ 2 9 2");
	return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

/*
  s := s1 s2 ... sn

  hash[1_to_i] := s1*b^(i-1) + s2*b^(i-2) + ... + si*b^0

  hash[1_to_j] := s1*b^(j-1) + s2*b^(j-2) + ... + si*b^(j-i) + ... + sj*b^0


  hash[(i+1)_to_j] = hash[1_to_j] - hash[1_to_i]*b^(j-i)

                   = s(i+1)*b^(j-i-1) + ... + sj*b^0
*/

typedef unsigned long long ull;
const ull HASH_BASE = 9999739;
// build O(N), query O(1)
// MOD は over-flow で代用している
function<ull(int, int)> build_rolling_hash(const string &s) {
    int n = s.size();
    vector<ull> hash(n + 1), pow_base(n + 1);
    pow_base[0] = 1;
    rep(i, n) {
        hash[i + 1] = hash[i] * HASH_BASE + s[i];
        pow_base[i + 1] = pow_base[i] * HASH_BASE;
    }
    return [=] (int l, int r) {
        return hash[r] - hash[l] * pow_base[r - l];
    };
}


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        string S; cin >> S;
        auto hash = build_rolling_hash(S);

        int ans = 0;
        repeat(len, 1, N + 1) {
            set<ull> memo;
            rep(i, N - len + 1) {
                if(i - len >= 0) memo.insert(hash(i - len, i));
                if(i + len <= N) {
                    ull h1 = hash(i, i + len);
                    if(memo.count(h1)) set_max(ans, len);
                }
            }
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 640
import numpy as np
def bin_search(left, right, check):
    while left + 1 < right:
        middle = (left + right) >> 1
        if check(middle):
            right = middle
        else:
            left = middle
    return right

def make_check(A, F, Z, K):
    def check(m):
        return np.maximum(A - m // F, Z).sum() <= K
    return check

N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int32)
F = np.array(input().split(), dtype=np.int32)
Z = np.zeros((N,), dtype=np.int32)
A.sort()
F = F[np.argsort(-F)]
check = make_check(A, F, Z, K)

print(bin_search(-1, 10 ** 12, check))

Measured memory_bytes: 36428
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
   int n;
    scanf("%d", &n);
    vector<int> dp(3);
    // dp[i] - the total cost such that we did activity i on the last considered day
    for(int day = 0; day < n; ++day) {
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for(int i = 0; i < 3; ++i) {
            scanf("%d", &c[i]);
        }

        for (int i = 0;i<3;i++){
            for (int j = 0 ; j<3; j++){
                if (i!=j){
                    new_dp[j] = max(new_dp[j], dp[i]+c[j]);
                }
            }
        }
        dp = new_dp;
}
cout << max({dp[0],dp[1],dp[2]});
}

Measured memory_bytes: 256
# This src was written after reading editional.pdf .

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


an, pn = [1], [1]

for i in range(n):
    an.append(2*an[i]+3)
    pn.append(2*pn[i]+1)

#print(an)

def f(n,x):

    #print(n,x)

    if n == 0:
        return 1 if 0<x else 0
    
    if x <= an[ n-1 ] + 1:
        return f( n-1, x-1 )

    else:# x <= 2*an[n-1] + 3:
        return f(n-1, x-an[n-1]-2) + pn[n-1] + 1


print(f(n,x))

    
#    else if: 
#        pass

Measured memory_bytes: 3064
N=int(input())
t=[[[0]*10 for i in range(3)] for i in range(4)]
for n in range(N):
    b,f,r,v=map(int,input().split())
    t[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        print("",*t[i][j])
    if i!=3:
        print("#"*20)


Measured memory_bytes: 5620
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,K,Q;
  cin>>N>>K>>Q;
  lint p[N];
  REP(i,N)p[i]=K-Q;
  lint A[Q];
  REP(i,Q){
    cin>>A[i];
    A[i]--;
    p[A[i]]+=1;
  }
  REP(i,N)cout<<(p[i]>0?"Yes":"No")<<endl;
  return 0;
}


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

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0, g = 0, p = 0, m = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'p') {
            g++;
            m++;
            continue;
        }
        if (g != p) {
            p++;
            ans++;
        } else g++;
    }
    ans -= max(m - ((p + g) / 2 - p), 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vl a(n);
	rep(i,n) cin >> a[i];
	vl v(n+1,0);
	rep(i,n) v[a[i]]++;
	ll sum = 0;
	rep(i,n+1){
		sum += v[i]*(v[i]-1)/2;
	}
	rep(i,n){
		ll t = v[a[i]]-1;
		ll minus = t*(t-1)/2 - v[a[i]]*(v[a[i]]-1)/2;
		cout << sum + minus << endl;
	}
}

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

#define BUILDING_NUM 4
#define FLOOR_NUM 3

int main(int argc, char *argv[])
{
    // initialize
    vector<vector<vector<int>>> officialRegidence;
    for (int i = 0; i < BUILDING_NUM; i++)
    {
        vector<vector<int>> building;
        for (int j = 0; j < FLOOR_NUM; j++)
        {
            vector<int> floor = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
            building.push_back(floor);
        }
        officialRegidence.push_back(building);
    }

    // // input
    int n;
    cin >> n;
    int b, f, r, v;
    for (int i = 0; i < n; i++)
    {
        cin >> b >> f >> r >> v;
        officialRegidence[b - 1][f - 1][r - 1] += v;
    }

    // show result
    for (int i = 0; i < BUILDING_NUM; i++)
    {
        for (int j = 0; j < FLOOR_NUM; j++)
        {
            for (int k = 0; k < officialRegidence[i][j].size(); k++)
            {
                cout << " " << officialRegidence[i][j][k];
            }
            cout << endl;
        }
        if (i != officialRegidence.size() - 1)
            cout << "####################" << endl;
    }
}

Measured memory_bytes: 3164
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    
    int top = stdIn.nextInt();
    int back = stdIn.nextInt();
    int right = stdIn.nextInt();
    int left = stdIn.nextInt();
    int front = stdIn.nextInt();
    int bottom = stdIn.nextInt();

    String str = stdIn.next();
    char[] c = str.toCharArray();

    Dice dice = new Dice(top, back, right, left, front, bottom);

    for (int i = 0; i < c.length; i++) {
      dice.roll(c[i]);
    }

    System.out.println(dice.getTop());
  }
}

class Dice {
  int top;
  int back;
  int right;
  int left;
  int front;
  int bottom;

  Dice (int top, int back, int right, int left, int front, int bottom) {
    this.top = top;
    this.back = back;
    this.right = right;
    this.left = left;
    this.front = front;
    this.bottom = bottom;
  }

  public int getTop() { return this.top; }

  public void roll(char c) {
    if (c == 'E') {
      int tmp = top;
      top = left;
      left = bottom;
      bottom = right;
      right = tmp;
    } else if (c == 'N') {
      int tmp = top;
      top = back;
      back = bottom;
      bottom = front;
      front = tmp;
    } else if (c == 'S') {
      int tmp = top;
      top = front;
      front = bottom;
      bottom = back;
      back = tmp;
    } else if (c == 'W') {
      int tmp = top;
      top = right;
      right = bottom;
      bottom = left;
      left = tmp;
    } else {
      System.out.println("roll error");
    }
  }
}


Measured memory_bytes: 26388
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<cassert>

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

template< typename T >
vector< T > shortest_path_faster_algorithm(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);
  vector< int > pending(g.size(), 0), times(g.size(), 0);
  queue< int > que;

  que.emplace(s);
  pending[s] = true;
  ++times[s];
  dist[s] = 0;

  while(!que.empty()) {
    int p = que.front();
    que.pop();
    pending[p] = false;
    for(auto &e : g[p]) {
      T next_cost = dist[p] + e.cost;
      if(next_cost >= dist[e.to]) continue;
      dist[e.to] = next_cost;
      if(!pending[e.to]) {
        if(++times[e.to] >= g.size()) return vector< T >();
        pending[e.to] = true;
        que.emplace(e.to);
      }
    }
  }
  return dist;
}

const int MAXN = 2501;
bool used1[MAXN];
bool used2[MAXN];
vector<int> G1[MAXN], G2[MAXN];

void bfs1(int s) {
   used1[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G1[cur]) {
         if (used1[g]) continue;
         used1[g] = true;
         q.push(g);
      }
   }
}

void bfs2(int s) {
   used2[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G2[cur]) {
         if (used2[g]) continue;
         used2[g] = true;
         q.push(g);
      }
   }
}

int main() {
   int N, M, P;
   cin >> N >> M >> P;
   int A[M], B[M], C[M];
   for (int i = 0; i < M; i++) {
      cin >> A[i] >> B[i] >> C[i];
      A[i]--;
      B[i]--;
      C[i] = -1 * (C[i] - P);
      G1[A[i]].push_back(B[i]);
      G2[B[i]].push_back(A[i]);
   }
   memset(used1, false, sizeof(used1)); 
   memset(used2, false, sizeof(used2)); 

   bfs1(0);
   bfs2(N - 1);
   /*
   for (int i = 0; i < N; i++) {
      cout << i << " " << used1[i] << " " << used2[i] << endl;
   }
   */
   
  	WeightedGraph< int > g(N);
   for (int i = 0; i < M; i++) {
      if (!used1[A[i]]) continue;
      if (!used1[B[i]]) continue;
      if (!used2[A[i]]) continue;
      if (!used2[B[i]]) continue;
      g[A[i]].emplace_back(B[i], C[i]);
   }
  
	auto res = shortest_path_faster_algorithm(g, 0);
   if (res.empty()) cout << "-1" << endl;
   else {
      assert(res[N - 1] != numeric_limits<int>::max());
      cout << max(0, -1 * res[N - 1]) << endl;
   }
   return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

vi prime(int x) {
  vi data;
  data.push_back(2);
  data.push_back(3);
  int a = 5;
  while(data.size() <= x) {
    bool check = true;
    for(int i = 2; i * i <= a; i++) {
      if(a % i == 0) {
        check = false;
        break;
      }
    }
    if(check) data.push_back(a);
    a++;
  }
  return data;
}

int main() {
  int n;
  cin >> n;
  vi data = prime(n);
  int ans = 0;
  int i = 0;
  while (ans == 0) {
    if(data[i] == n) ans = data[i];
    else if(data[i] < n && data[i + 1] > n) ans = data[i + 1];
    else i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
L, R = map(int, input().split())

import sys

mi=10**10
for l in range(L,R+1):
    for r in range(l+1,R+1):
        mod = (l*r) % 2019
        if mod < mi:
            mi=mod
        if mi==0:
            print(mi)
            sys.exit()
print(mi)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	const long INFL = 4011686018427387913L;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		WriteLine(LongestCommonSubsequence(Str, Str));
	}
	public static string LongestCommonSubsequence(string s, string t)
	{
		var n = s.Length;
		var m = t.Length;
		var memo = new int[n + 1, m + 1];
		var ans = new int[n + 1, m + 1, 2];
		for (var i = 0; i <= n; i++) { ans[i, m, 0] = n; ans[i, m, 1] = m; }
		for (var j = 0; j <= m; j++) { ans[n, j, 0] = n; ans[n, j, 1] = m; }
		for (var i = n - 1; i >= 0; i--)
			for (var j = m - 1; j >= 0; j--)
				if (s[i] == t[j])
				{
					memo[i, j] = memo[i + 1, j + 1] + 1;
					ans[i, j, 0] = i;
					ans[i, j, 1] = j;
				}
				else
				{
					if (memo[i + 1, j] > memo[i, j + 1])
					{
						memo[i, j] = memo[i + 1, j];
						ans[i, j, 0] = ans[i + 1, j, 0];
						ans[i, j, 1] = ans[i + 1, j, 1];
					}
					else
					{
						memo[i, j] = memo[i, j + 1];
						ans[i, j, 0] = ans[i, j + 1, 0];
						ans[i, j, 1] = ans[i, j + 1, 1];
					}
				}
		var sb = new StringBuilder();
		int a = 0, b = 0;
		while (a < n)
		{
			if (ans[a, b, 0] == a && ans[a, b, 1] == b)
			{
				sb.Append(s[a]);
				a++;
				b++;
			}
			else
			{
				var a2 = ans[a, b, 0];
				b = ans[a, b, 1];
				a = a2;
			}
		}
		return sb.ToString();
	}
}


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

ll mod1 = 1e9+7, mod2 = 1e9+9;
ll mul1 = 1009, mul2 = 1007;
map<pair<ll,ll>,bool> mp,mp2;
int len = 1e5;

void rori(string s,bool p){
    int n = s.size();
    ll a=0,b=0;
    bool fs=false;
    if(mp2.size()==0) fs=true; 
    for(int i=0;i<n;i++){
        a = (a*mul1 + s[i]) % mod1;
        b = (b*mul2 + s[i]) % mod2;
        if(p==0) mp[make_pair(a,b)] = true;
        else{
            if(fs){
                mp2[make_pair(a,b)] = true;
                len = i+1;
            }
            else{
                if(!mp2.count(make_pair(a,b))) len = min(len,i);
            }
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);
 
    string s;
    cin>>s;
    int n=s.size();
    ll cnt[3]={};
    for(int i=0;i<n;i++){
        cnt[s[i] - 'a']++;
    }
    ll ma=0,mi=1e9;
    for(int i=0;i<3;i++){
        ma = max(ma,cnt[i]);
        mi = min(mi,cnt[i]);
        //cerr<<cnt[i] << endl;
    }
    if(ma - mi > 1){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;

}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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


int main() {
string s;
getline(cin,s);
int sl = s.length();
REP(i, sl){
	if ('a'<=s[i]&&s[i]<='z')
		s[i] += 'A' - 'a';
}
cout<<s<<endl;
}

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

const int MAX = 200000;
int main() {
	int N, A[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> A[i];
	
	int64_t sum = 0, ans = 0;
	for (int l = 0, r = 0;l < N;) {
		if (r < N && (sum ^ A[r]) == sum + A[r]) { // lからrまでの範囲で条件を満たす
			sum += A[r];
			r ++;
		} else {
			ans += r - l; // lからr-1までは条件を満たしていたので
			sum -= A[l]; // 次はl+1からrまでを満たすか調べる
			l ++;
			if (l > r) r ++;
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

A_iからA_jが条件を満たすならA_iからA_(j-1)も条件を満たす
また、A_iからA_jが条件を満たさないならどの部分集合も条件を満たさない
ということで、尺取り法
*/

Measured memory_bytes: 1024
/*
 * @ProblemId: 
 * @Probtitle: 
 * @Location: 
 * @Author: Morales
 * @Date: 2020-05-05 13:44:25
 * @LastEditTime: 2020-05-05 13:48:44
 * @Space: https://space.bilibili.com/350869102
 * @E-mail: lovexposed@foxmail.com
 * @Blog: https://blog.csdn.net/baidu_41248654
 * @Powered by: Havoc_Wei
 */
// 颜色相异取出 相同合并
// 栈顶同||栈空-压栈 栈顶不同-出栈
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
stack<char> cube;
string s;
int cnt = 0;
int main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(cube.empty() || cube.top()==s[i])
            cube.push(s[i]);
        else
        {
            cube.pop();
            cnt += 2;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 512
anslist = []
def sarch(i, j, visited):

    if 0 < i:
        if visited[i - 1][j] == 0:
            visited[i - 1][j] = 1
            sarch(i - 1, j, visited)
    if i < len(visited) - 1:
        if visited[i + 1][j] == 0:
            visited[i + 1][j] = 1
            sarch(i + 1, j, visited)
    if 0 < j:
        if visited[i][j - 1] == 0:
            visited[i][j - 1] = 1
            sarch(i, j - 1, visited)
    if j < len(visited[0]) - 1:
        if visited[i][j + 1] == 0:
            visited[i][j + 1] = 1
            sarch(i, j + 1, visited)
    return visited


while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    grid = [list(input()) for i in range(h)]
    visited = [[0 for i in range(w)] for j in range(h)]
    starti = 0
    startj = 0
    for i in range(h):
        for j in range(w):
            if grid[i][j] == "@":
                starti = i
                startj = j
                visited[i][j] = 1
            elif grid[i][j] == "#":
                visited[i][j] = -1
            else:
                visited[i][j] = 0

    visited = sarch(starti, startj, visited)
    #print(visited)
    ans = 0
    for i in visited:
        for j in i:
            if j == 1:
                ans += 1
    anslist.append(ans)

for i in anslist:
    print(i)


Measured memory_bytes: 5776
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s.size()==t.size()){
        REP(i,s.size()){
            if(s[i]<t[i]){
                cout<<"Yes";
                return 0;
            }
            if(s[i]>t[i]){
                cout<<"No";
                return 0;
            }
        }
    }else if(s.size()<t.size()){
        REP(i,s.size()){
            if(s[i]<t[i]){
                cout<<"Yes";
                return 0;
            }
            if(s[i]>t[i]){
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
        return 0;
    }else{
        REP(i,t.size()){
            if(s[i]<t[i]){
                cout<<"Yes";
                return 0;
            }
            if(s[i]>t[i]){
                cout<<"No";
                return 0;
            }
        }
        cout<<"No";
        return 0;
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
from functools import lru_cache
@lru_cache(maxsize=None)
def b(n):
    if n<1:return 1
    return b(n-1)*2+3
@lru_cache(maxsize=None)
def p(n):
    if n<1:return 1
    return p(n-1)*2+1
def solve(n,x):
    if n<1:return int(x>0)
    if x-2<b(n-1):return(solve(n-1,x-1))
    return p(n-1)+solve(n-1,x-b(n-1)-2)+1
print(solve(*map(int,input().split())))

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n, a, b;
    cin >> n >> a >> b;
    int min = n * a;
    if (min <= b)
        cout << min << endl;
    else
        cout << b << endl;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    const V = arg[1].split(" ").map(n=>parseInt(n));
    
    let answerList = [0];
    
    for(let a=0; a<=Math.min(K, N); a++) {
        for(let b=0; b<=Math.min(K, N); b++) {
            const rest = K - (a + b);
            
            if(N < a + b) continue;
            if(rest < 0) continue;
            
            let list = [];
            
            list = [...V.slice(0, a), ...V.slice(V.length - b, V.length)];

            
            list.sort((a,b)=>a-b);
            // console.log("取り出されたのは:" + list);
            // console.log("戻せる回数は:" + rest);
            
            let deleteCnt = 0;
            
            for(let i=0; i<rest; i++) {
                if(list[i] < 0) {
                    deleteCnt++;
                } else {
                    break;
                }
            }
            
            list.splice(0, deleteCnt);
            
            // console.log("加工後:" + list);
            
            if(list.length) {
                // console.log("価値は:" + list.reduce((m,n)=>m+n))
                answerList.push(list.reduce((m,n)=>m+n));
            }
            // console.log("---------------------");
        }
    }
    
    const answer = answerList.sort((a,b)=>b-a)[0];
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
	int N;
	cin >> N;
	vector<int> taco (N);
	for(int i=0;i<N;i++){
		cin >> taco.at(i);
	}
	
	int sum =0;
	
	for(int i=0;i<N-1;i++){
		for (int k=i+1;k<N;k++){
			sum = sum + taco.at(i)*taco.at(k);
		}
	}
	
	cout << sum <<endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i,ii,pm,pe,pj;
	while(scanf("%d",&ii) , ii != 0){
		for (i = 1;i <= ii;i++){
			scanf("%d%d%d",&pm,&pe,&pj);
			if(pm == 100 || pe == 100 || pj == 100 || (pm + pe) >= 180 || (pm + pe + pj) >= 240){
				printf("A\n");
			}
			else if ((pm + pe + pj) >= 210){
				printf("B\n");
			}
			else if ((pm + pe + pj) >= 150 && pm >= 80){
				printf("B\n");
			}
			else if ((pm + pe + pj) >= 150 && pe >= 80){
				printf("B\n");
			}
			else {
				printf("C\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
      int n;
      Scanner sc=new Scanner(System.in);
      n=sc.nextInt();
      sc.nextLine();
      String s=sc.nextLine();
      int cntr=1;
      for(int i=1;i<s.length();i++)
      if(s.charAt(i)!=s.charAt(i-1))
      cntr++;
      System.out.println(cntr);
    }
}

Measured memory_bytes: 28356
//................ DON'T WISH IT WERE EASIER, WISH YOU WERE BETTER........................
//............ WHEN LIFE PUTS YOU IN TOUGH SITUATIONS, DONT SAY "WHY ME" SAY "TRY ME".......

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define endl "\n"
#define f first
#define mp make_pair
#define s second
#define int long long
#define delrep(v)  (v).erase(unique((v).begin(),(v).end()),(v).end());
#define all(a)  (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define sz(x)   (int)x.size()
#define lll __int64
const int N=1e6+10; const int M=100000;
const int mod=998244353;
using namespace std;
typedef long long ll;
const long long MAX_SIZE = 3000003;
vector<pair<int,int>>v[N]; map<int,int>hashx;
vector<int>a(N); vector<int>b(N); int pref[N]; int suff[N]; int sum[N];
vector<ll>dp(N,-1);
ll n,k;
int mindis(ll x)        // top down dp
{
    if(x==0) return 0;
    if(dp[x]!=-1) return dp[x]; int ans=INT_MAX;
     for(int i=1;i<=k;i++) 
         {
            if(x-i>=0) 
             { 
                int ans2=mindis(x-i)+abs(a[x]-a[x-i]); 
                ans=min(ans,ans2); dp[x]=ans;  
             }
           }
  return dp[x];
}

int32_t main()
{
   int n; cin>>n>>k; for(int i=0;i<n;i++) cin>>a[i]; 
   mindis(n-1);
   cout<<dp[n-1]; return 0;
}
 
 

Measured memory_bytes: 54272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s, t;
  cin >> s >> t;
  bool ok = true;
  rep(i, 3) if(s[i] != t[2 - i]) ok = false;
  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int H,W;
int h[1500],w[1500];

void solve(){
    for(int i=0;i<H;i++)scanf("%d",&h[i]);
    for(int i=0;i<W;i++)scanf("%d",&w[i]);

    map<int,int>Y,X;

    for(int i=0;i<H;i++){
        int sum=0;
        for(int j=i;j<H;j++){
            sum+=h[j];
            Y[sum]++;
        }
    }

    for(int i=0;i<W;i++){
        int sum=0;
        for(int j=i;j<W;j++){
            sum+=w[j];
            X[sum]++;
        }
    }

    long long ans=0;

    for(map<int,int>::iterator it=Y.begin();it!=Y.end();it++){
        ans+=(long long)it->second*X[it->first];
    }

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

}

int main(){
    while(scanf("%d%d",&H,&W),H||W)solve();
    return 0;
}

Measured memory_bytes: 32460
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <set>
#include <utility>
#include <iomanip>
#include <climits>
#include <map>
using namespace std;
#define ll long long
#define MOD 1000000007
#define INF 1000000000000000000
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll stack<ll>
#define qll queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
int main() 
{ 
    fast_io;
    ll n,k,i,mini;
    cin>>k>>n;
    ll a[2*n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(i=n;i<2*n;i++)
    a[i]=a[i-n]+k;
    mini=LLONG_MAX;
    for(i=0;i<n;i++)
    {
        mini=min(mini,a[i+n-1]-a[i]);
    }
    cout<<mini<<endl;
    return 0;
} 

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long mod_pow(long long x, long long y){
  return y ? mod_pow(x * x % MOD, y >> 1) * (y & 1 ? x : 1) % MOD : 1;
}

long long combination(long long n, long long k){
  k = min(k, n - k);
  long long x = 1, y = 1;
  for(long long i = 0; i < k; ++i){
    x = x * (n - i) % MOD; 
    y = y * (i + 1) % MOD;
  }
  return x * mod_pow(y, MOD - 2) % MOD;
}
int main(){
  long long n, a, b; cin >> n >> a >> b;
  long long all_combination = mod_pow(2, n) - 1;
  long long minus1 = combination(n, a);
  long long minus2 = combination(n, b);
  all_combination += MOD * 2; 
  cout << (all_combination - minus1 - minus2) % MOD << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		Integer n = sc.nextInt();
		Integer d = sc.nextInt();
		Integer count = 0;

		for (Integer i = 0; i < n; i++) {
			Long x = sc.nextLong();
			Long y = sc.nextLong();

			Long z = x * x + y * y;
			if (z < 0) {
				z *= -1;
			}

			Double distance = Math.sqrt(z);

			if (distance <= d) {
				count++;
			}

		}

		System.out.println(count);

	}

}

Measured memory_bytes: 59264
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int n;
    cin >> n;
    vector<int>x(n);
    vector<int>y(n*n);
    vector<int>a(n*n);
    rep(i,n)cin >> x[i],a[x[i]-1] = i+1,y[x[i]-1] =i+1;
    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq,pq2;
    rep(i,n)pq.push(MP(x[i]-1,i+1)),pq2.push(MP(x[i]-1,i+1));
    int t = 0;
    bool flag = 0;
    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();  
        int z = 1;
        while(z < p.second){
            if(t > p.first){
                flag = 1;
                break;
            }
            if(a[t]!=0){
                t++;
            }else{
                z++;
                a[t] = p.second;
            }
        }

        if(flag)break;
    }
    
    vector<int>s(n+1);
    rep(i,n+1)s[i] = i;
    while(!pq2.empty()){
        auto p = pq2.top();
        pq2.pop();
        while(s[p.second]<n){
            if(a[t]==0){
                a[t] = p.second;
                s[p.second]++;
                t++;
            }else{
                t++;
            }
        }
    }
    vector<int> q(n+1);
    rep(i,n*n){
        q[a[i]]++;
        if(y[i]!=0){
            if(q[a[i]]!=a[i])flag = 1;
        }
    }
    if(flag){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        rep(i,n*n){
            cout << a[i];
            if(i!=n*n-1)cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
S = input()
l = len(S)

cnt = 0

for _ in range(l):
    cnt += 1
    S = S[:-1]
    #print(S)
    if len(S) % 2 == 1:
        continue
    f = True
    for i in range(len(S) // 2):
        if S[i] != S[len(S) // 2 + i]:
            f = False
            break
    if f:
        print(l - cnt)
        break


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

namespace ARC091C
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = line[0];
            long M = line[1];

            long ans = 0;
            if (N == 1 && M == 1) ans = 1;
            else if (N == 1) ans = M - 2;
            else if (M == 1) ans = N - 2;
            else
            {
                ans = (N - 2) * (M - 2);
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


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

int main() {
    string str;
    int x, y;
    cin >> x >> y;
    cin >> str;
    y = y - 1;
    if (str[y] == 'A') {
        str[y] = 'a';
    }
    else if (str[y] == 'B') {
        str[y] = 'b';
    }
    else if (str[y] == 'C') {
        str[y] = 'c';
    }
    cout << str << endl;

    return 0;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int x;
    cin>>x;
    if(x>=400 && x<=599)
    {
        cout<<"8"<<endl;
    }
    else if(x>=600 && x<=799)
    {
        cout<<"7"<<endl;
    }
    else if(x>=800 && x<=999)
    {
        cout<<"6"<<endl;
    }
    else if(x>=1000 && x<=1199)
    {
        cout<<"5"<<endl;
    }
    else if(x>=1200 && x<=1399)
    {
        cout<<"4"<<endl;
    }
    else if(x>=1400 && x<=1599)
    {
        cout<<"3"<<endl;
    }
    else if(x>=1600 && x<=1799)
    {
        cout<<"2"<<endl;
    }
    else if(x>=1800 && x<=1999)
    {
        cout<<"1"<<endl;
    }
    return 0;

}





































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

using namespace std;

int main(){

  long long int n;
  cin>>n;
  vector<long long> cnt(n+1,1);
  long long int ans=1;
  long long int MOD=1000000007;

  for(int i=1; i<=n; i++){
    long long int index=i;
    long long int j=2;
    while(j<=index){
      if(index%j==0){
        cnt[j]+=1;
        index=index/j;
      }
      else if(index%j!=0) j++;
    }
  }

  for(int i=0; i<cnt.size(); i++){
    ans*=cnt[i];
    ans=ans%MOD;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3544