akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
using namespace std;
#define int                  long long
#define double               long double
#define ass_on_fire          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi                   vector<int>
#define di                   deque<int>
#define si                   set<int>
#define vpii                 vector<pair<int,int>>
#define pi                   pair<int,int>
#define pub                  push_back
#define puf                  push_front
#define pob                  pop_back
#define pof                  pop_front
#define all(a)               a.begin(),a.end()
#define rall(a)              a.rbegin(),a.rend()
#define PI                   3.1415926535897932384626433832795
#define read(a)              for(auto& x:a) cin>>x
#define endl                 '\n'
#define ln                   printf("\n");
#define gap                  ' '
#define min3(a,b,c)          min(a, min(b, c))
#define max3(a,b,c)          max(a, max(b, c))
#define MOD                  1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    ass_on_fire
    int a[5];read(a);
    for(int i=0;i<5;i++) if(a[i]==0) return cout<<i+1,0;
}



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

#define f first
#define s second
#define ins insert
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define no cout << "NO" << endl 
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (int) (c).size()
#define trav(x,c) for (auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define db(x) cout << #x << ": " << x << endl;
#define _db(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios_base::sync_with_stdio(0); cin.tie(0);

int main() { 
    godspeed;
    int n,k;
    vi me;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        me.push_back(a);
    }
    sort(me.begin(),me.end());
    int ans=0;
    for(int i=0;i<k;i++)
        ans+=me[i];
    cout << ans << '\n';
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a;
 int b;
 int multiAB;
 
 cin >> a;
 cin >> b;
 
 multiAB = (a * b) % 2;
 
 if(multiAB == 1){
     cout << "Odd" << endl;
 }else if(multiAB == 0){
     cout << "Even" << endl;
 }
}

Measured memory_bytes: 256
n = gets.to_i
MAX_A = 200_050
cnt = Array.new(MAX_A, 0)
n.times { cnt[gets.split.map(&:to_i).inject(:+)] += 1 }
MAX_A.pred.times do |i|
	cnt[i + 1] += cnt[i] / 2
	cnt[i] %= 2
end
MAX_A.times { |i| puts "#{i} 0" if cnt[i] != 0 }



Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

ll f(ll a) {
  return a*(a-1)/2;
}

int main(){
  string S; cin>>S;
  ll N=S.length();
  UM<char,ll> cnt;
  for(auto c:S) cnt[c]++;
  ll ans=f(N)+1;
  for(auto p:cnt) ans-=f(p.second);
  cout<<ans<<endl;
}


Measured memory_bytes: 640
N = int(input())
Arr = [int(input()) for i in range(N)]

left_max=0
right_max=max(Arr)

for i in range(N):
    n = Arr[i]
    if left_max>=right_max:
        print(left_max)
    else:
        if n==right_max:
            if i ==N-1:
                right_max=left_max
                
            else:
                right_max = max(Arr[i+1:])

        print(right_max)

    if i == N-1:
        break
    left_max=max(n,left_max)


Measured memory_bytes: 12588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,sum=1,count=0,l;
    cin>>n>>k;
    l=n;
    while(sum<k&&n!=0)
    {
        sum=sum*2;
        n--;
        count++;
    }
 //   cout<<count<<endl;
    l=l-count;
    while(l--)
    {
        sum=sum+k;
    }

    cout<<sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    constexpr auto M = 1000000007L;
    int64_t n;
    cin >> n;

    vector<int64_t> c(n);
    for (auto&& cc : c) {
        cin >> cc;
    }

    sort(c.begin(), c.end());
    int64_t ans = 0;
    for (auto i : irange(0L, n)) {
        ans += c[i] * (n - i + 1);
        ans %= M;
    }
    for (auto i : irange(0L, n - 1)) {
        ans *= 4;
        ans %= M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 200005

using namespace std;

ll n,x,arr[sz],brr[sz];

int main()
{
    scanf("%lld",&n);

    arr[0]=0;
    brr[0]=0;

    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&x);

        if(x>=0)
        {
            arr[i]=arr[i-1]+x;
            brr[i]=brr[i-1];
        }

        else
        {
            brr[i]=brr[i-1]+(x*(-1));
            arr[i]=arr[i-1];
        }
    }

    ll mn=INT_MAX;

    for(ll i=2; i<=n; i++)
    {
        ll sum1=arr[i-1]-brr[i-1];
        ll sum2=(arr[n]-arr[i-1])-(brr[n]-brr[i-1]);

        ll dif=fabs(sum1-sum2);

        mn=min(mn, dif);
    }

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

    return (0);
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> cnt(N);
    rep(i, N) cnt[A[i] - 1]++;

    vector<int> cntmap(N + 1), cntsum(N + 2);
    rep(i, N) cntmap[cnt[i]]++;
    rep(i, N + 1) cntsum[i + 1] = cntsum[i] + cntmap[i];
    vector<ll> prosum(N + 1);
    rep(i, N) prosum[i + 1] = prosum[i] + (ll)i * cntmap[i];

    vector<int> ans(N);
    rep(i, 1, N + 1) {
        // 単調増加列の個数がi+1個
        ans[i - 1] = prosum[i] / i + (cntsum[N + 1] - cntsum[i]);
    }

    rep(i, N) {
        int a = lower_bound(ans.rbegin(), ans.rend(), i + 1) - ans.rbegin();
        write(N - a);
    }
}

Measured memory_bytes: 9088
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    if(n % 2 == 0) {
      System.out.println(n/2);
    } else {
      System.out.println(n/2+1);
    }

  }

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef pair<int, long double> pd;
typedef pair<long double, int> dfpd;
typedef pair<pi, long double> ppd;
#define f first
#define s second

pi t;
int N;
ppd c[1005];
vector<pd> v[1005];
long double d[1005];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> c[0].f.f >> c[0].f.s >> t.f >> t.s;
	cin >> N;
	c[N+1].f = t;
	c[0].s = c[N+1].s = 0;
	for (int i = 1; i <= N; i++ ) {
		cin >> c[i].f.f >> c[i].f.s >> c[i].s;
	}
	for (int i = 0; i <= N+1; i++) {
		d[i] = (long double) 1e10;
		for (int j = i+1; j <= N+1; j++) {
			long double dst = (long double) sqrt( ((long double) (c[j].f.f - c[i].f.f) * (long double) (c[j].f.f - c[i].f.f)) + ((long double) (c[j].f.s - c[i].f.s) * (long double) (c[j].f.s - c[i].f.s)));
			dst -= (c[i].s + c[j].s);
			dst = max(dst, (long double) 0.0);
			if (i != N+1 && j != 0) v[i].push_back(pd(j, dst));
			if (j != N+1 && i != 0) v[j].push_back(pd(i, dst));
		}
	}
	d[0] = (long double) 0;
	
	priority_queue<dfpd, vector<dfpd>, greater<dfpd> > pq;
	pq.push(dfpd((long double)0, 0));
	while (!pq.empty()) {
		int x = pq.top().s;
		long double dst = pq.top().f;
		pq.pop();
		for (auto it:v[x]) {
			if (dst + it.s >= d[it.f]) continue;
			d[it.f] = dst + it.s;
			pq.push(dfpd(dst+it.s, it.f));
		}
	}
	cout << fixed << setprecision(10) << d[N+1];
}


Measured memory_bytes: 43024
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y){
	REP(i,X+1){
		if(i*2+(X-i)*4==Y){
			cout<<YES<<endl;
			return;
		}
	}
	cout<<NO<<endl;
}

int main(){
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  solve(X, Y);
  return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int D;	cin >> D;
  switch(D){
    case 25 : cout << "Christmas" << endl; break;
    case 24 : cout << "Christmas Eve" << endl; break;
    case 23 : cout << "Christmas Eve Eve" << endl; break;
    case 22 : cout << "Christmas Eve Eve Eve" << endl; break;
  }
  
  return 0;
}
      

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

int main(){

    int h,w;
    cin >> h >> w;

    vector<string> a(h);

    rep(i,h) cin >> a[i];

    bool f=true;
    while(f){
        f=false;
        string row(a[0].size(),'.');

        rep(i,a.size()){
            if(a[i]==row){
                a.erase(a.begin()+i);
                f=true;
                i--;
            }
        }

        rep(i,a[0].size()){
            rep(j,a.size()){
                if('.'!=a[j][i]){
                    break;
                }
                if(j==a.size()-1){
                    
                    rep(k,a.size()){
                        a[k].erase(a[k].begin()+i);
                    }
                    f=true;
                    i--;
                }
            }
        }
    }

    rep(i,a.size()){
        cout << a[i] << endl;
    }

    return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    int N, M; cin >> N >> M;
    vector<vector<int>> G(N, vi(N, INF));

    vector<tuple<int, int, int>> edges(M);

    REP(i, M)
    {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        edges[i] = mt(a, b, c);
        G[a][b] = c;
        G[b][a] = c;
    }

    REP(k, N)
    {
        REP(i, N)
        {
            REP(j, N)
            {
                chmin(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    int ans = 0;
    REP(i, M)
    {
        int a, b, c;
        tie(a, b, c) = edges[i];
        if(G[a][b] < c) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3700
# ------------------------------------------------------------
# THIS IS METADATA FOR ATCODER_TOOLS
# BE CAREFULL WHEN YOU CHANGE THE VALUE
# 
# METADATA::START
# test-1
# input: "2 5\n"
# output: "10\n"
# test-2
# input: "100 100\n"
# output: "10000\n"
# MODE: TEST
# METADATA::FINISH
# 
# 
# select MODE from NONE, DEBUG, RUN, TEST
# problem: https://atcoder.jp/contests/abc169/tasks/abc169_a
# -------------------------------------------------------------

arr = gets.split(' ').map(&:to_i)
puts(arr[0] * arr[1])


Measured memory_bytes: 14320
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define INF 10000000000;
using namespace std;
typedef unsigned long ul;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll D, G;
    cin >> D >> G;
    ll p[11], c[11];
    ll i, j;
    ll ans=100*D, scr, cnt;
    ll restM;
    for(i=1; i<=D; i++) {
        cin >> p[i] >> c[i];
    }
    
    for(i=0; i<1<<D; i++) {
        scr=0;
        cnt=0;
        restM=0;
        bool q[11]={false};
        for(j=1; j<=D; j++) {
            if(1&i>>(j-1)) {
                q[j]=true;
                scr+=100*j*p[j]+c[j];
                cnt+=p[j];
            } else {
                restM=j;
            }
        }
        if(scr<G) {
            ll s1=100*restM;
            ll need=(G-scr)%s1==0 ? (G-scr)/s1 : (G-scr)/s1+1;
            if(need>=p[restM])
                continue;
            cnt+=need;
        }
        
        ans=min(ans, cnt);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
s=input()

a=int(s[:2])
b=int(s[2:])

if 0<a<=12 and (b>12 or b==0):
    print('MMYY')
elif 0<b<=12 and (a>12 or a==0):
    print('YYMM')
elif 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')    
else:
    print('NA')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
 
using namespace std;
 
map<string, char> n;
map<char, string> m;
 
void init1()
{
    m[' '] = "101";
    m['\''] = "000000";
    m[','] = "000011";
    m['-'] = "10010001";
    m['.'] = "010001";
    m['?'] = "000001";
    m['A'] = "100101";
    m['B'] = "10011010";
    m['C'] = "0101";
    m['D'] = "0001";
    m['E'] = "110";
    m['F'] = "01001";
    m['G'] = "10011011";
    m['H'] = "010000";
    m['I'] = "0111";
    m['J'] = "10011000";
    m['K'] = "0110";
    m['L'] = "00100";
    m['M'] = "10011001";
    m['N'] = "10011110";
    m['O'] = "00101";
    m['P'] = "111";
    m['Q'] = "10011111";
    m['R'] = "1000";
    m['S'] = "00110";
    m['T'] = "00111";
    m['U'] = "10011100";
    m['V'] = "10011101";
    m['W'] = "000010";
    m['X'] = "10010010";
    m['Y'] = "10010011";
    m['Z'] = "10010000";
}
 
void init2()
{
    n["00000"] = 'A';
    n["00001"] = 'B';
    n["00010"] = 'C';
    n["00011"] = 'D';
    n["00100"] = 'E';
    n["00101"] = 'F';
    n["00110"] = 'G';
    n["00111"] = 'H';
    n["01000"] = 'I';
    n["01001"] = 'J';
    n["01010"] = 'K';
    n["01011"] = 'L';
    n["01100"] = 'M';
    n["01101"] = 'N';
    n["01110"] = 'O';
    n["01111"] = 'P';
    n["10000"] = 'Q';
    n["10001"] = 'R';
    n["10010"] = 'S';
    n["10011"] = 'T';
    n["10100"] = 'U';
    n["10101"] = 'V';
    n["10110"] = 'W';
    n["10111"] = 'X';
    n["11000"] = 'Y';
    n["11001"] = 'Z';
    n["11010"] = ' ';
    n["11011"] = '.';
    n["11100"] = ',';
    n["11101"] = '-';
    n["11110"] = '\'';
    n["11111"] = '?';
}
 
int main()
{
    string str;
 
    init1();
    init2();
 
    while (getline(cin, str)) {
	string s = "";
	for (int i = 0; i < (int)str.size(); i++) {
	    s += m[str[i]];
	}
     
	if ((int)s.size() % 5) {
	    for (int i = 0; i < (int)s.size() % 5; i++) {
		s += '0';
	    }
	}
     
	string ans = "";
	for (int i = 0; i < (int)s.size(); i += 5) {
	    ans += n[s.substr(i, 5)];
	} 
	cout << ans << endl;
    }
    return 0;
}

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

#define sz(o) ((int)o.size())
#define all(o) o.begin(), o.end()
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<int> vi;

ll findSubArrays(vll arr, int n) {
    unordered_map<ll, ll> mp;
    ll out = 0;
    ll sum = 0;
    rep(i, 0, n-1){
        sum += arr[i];
        if (sum == 0) out++;
        if (mp.find(sum) != mp.end()) out += mp[sum];
        mp[sum]++;
    }
    return out;
}

void solve(int testcase) {
    int n;
    cin >> n;
    vll v(n);
    rep(i, 0, n-1) cin >> v[i];
    cout << findSubArrays(v, n);
}

int main() {
    #ifdef VPAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(2);
    clock_t b = clock();
    int t = 1;
    //cin >> t;
    rep(tt, 1, t) solve(tt);
    clock_t e = clock();
    cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
    return 0;
}



Measured memory_bytes: 11592
//初めての尺取り

#include<stdio.h>
#include<iostream>
using namespace std;

#define GOMAE (long long)50000
#define EPS (long long)4000
#define TO_OUTSIDE (long long)1500
#define IS_NOT_EVEN_HOBBY (long long)114
int N;
long long input;
long long A[300010];
long long ans;

int solve( long long X ){
	int i,j=0,k=0;
	
	if( X >= (A[N]>>1) )
		return 0;
	for( i = 0; i < N; i++ ){
		//大きさがX以上になるように切る
		for( ; j < N+i; j++ ){
			if( A[j]-A[i] >= X )
				break;
		}
		//できるだけ真ん中で切る
		for( ; k < N+i; k++ ){
			if( A[k]-A[j] >= A[N+i]-A[k] )
				break;
		}
		if( min( A[j]-A[i], min( A[k]-A[j], A[i+N]-A[k] ) ) >= X )
			break;
		k--;
		if( min( A[j]-A[i], min( A[k]-A[j], A[i+N]-A[k] ) ) >= X )
			break;
	}
	if( i < N )
		return 1;
	return 0;
}
				
int main(){
	int i,j,k;
	long long s = 0, e = GOMAE * EPS * TO_OUTSIDE * IS_NOT_EVEN_HOBBY * EPS;
	scanf("%d",&N);
	if( N > 100000 )
		return 0;
		
	for( i = 1; i < N+1; i++ ){
		scanf("%d",&input);
		A[i] = A[i-1]+input;
	}
	for( i = N+1; i < 3*N+1; i++ ){
		A[i] = A[i-N] + A[N];
	}
	
	//printf("%lld %lld\n",s,e);
	while( s <= e ){
		ans = (s+e)>>1;
		if( solve(ans) ){
			if( solve(ans+1) )
				s = ans+1;
			else
				break;
		}
		else{
			e = ans-1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3536
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
		for(int i = 0 ; i < n ; i++) {
			if(map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], 1);
			}
		}
		int ans = 0;
		for(int key : map.keySet()) {
			int cnt = 0;
			for(int i = key - 1 ; i <= key + 1 ; i++) {
				if(map.containsKey(i)) cnt += map.get(i);
			}
			ans = Math.max(ans, cnt);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 51392
H, W, n = map(int, input().split())
obst = []
for _ in range(n):
	x, y = map(int, input().split())
	if x >= y:
		obst.append([x-1, y-1, x-y])

bothered = [1000000] * (H+1)

for i in range(len(obst)):
	h, w, gap = obst[i][0], obst[i][1], obst[i][2]
	bothered[gap+1] = min(bothered[gap+1], h+1)

obst.sort(key=lambda x: x[0])

for i in range(len(obst)):
	h, w, gap = obst[i][0], obst[i][1], obst[i][2]
	if gap == 0:
		continue
	if h < bothered[gap]:
		print(h)
		break

else:
	print(H)

Measured memory_bytes: 82264
N = int(input())
x = [0]*N
u = ['']*N
sum = 0
for i in range(N):
    x[i], u[i] = input().split()
    if u[i] == 'JPY':
        u[i] = 1
    else:
        u[i] = 380000
    sum += float(x[i]) * u[i]
print(sum)

Measured memory_bytes: 3060
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define mp make_pair
const ll mod = 1000000007;
const ll nmax=500003;
int n, b[202], s;


int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
  for(int i=1; i<n; i++){cin>>b[i];
                        if(i==1) s+=b[i]; else s+=min(b[i], b[i-1]);}
  cout<<s+b[n-1];
}


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

using namespace std;

typedef long long ll;

vector<int> x;
int c[200010];

int main(int, char**)
{
	ll a, w = 0, b = 0, ans = 0;
	string s;
	cin >> a >> s;

	c[0] = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '#') {
			b++;
		} else {
			w++;
		}
		c[i+1] = b;
	}
	ans = a - c[a];
	for (int i = 0; i <= s.length(); i++) {
		ll x = c[i] + (a - i) - (c[a] - c[i]);
		ans = min(ans, x);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int n,nn[100000],h[4444]={},sum[4444]={};
  string a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a; 
    int num=0;
    num+=(a[0]-'0')*1000;
    num+=(a[2]-'0')*100;
    num+=(a[3]-'0')*10;
    num+=(a[4]-'0');
    h[num]++;
    nn[i]=num;
  }
  int cnt=0;
  for(int i=0;i<=4000;i++){
    sum[i]=cnt;
    cnt+=h[i];
  }
  for(int i=0;i<n;i++){
    cout<<h[nn[i]]-1+sum[nn[i]]*3<<endl;
  }
  return 0;
}

Measured memory_bytes: 3572
from math import sqrt
def dist(a,b):
    return sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
n = int(input())
data = [list(map(int,input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(n):
        ans += dist(data[i],data[j])

print(ans/n)

Measured memory_bytes: 38768
N = int(input())
A = list(map(int, input().split()))

A.sort()
MAX = A.pop(-1)
ans = MAX
MIN = A.pop(0)
MIN2 = MIN
MAX2 = MAX

if MIN2 <= 0:
    if N == 2:
        ans -= MIN2
    else:
        for a in A:
            if a > 0:
                MIN2 -= a
            else:
                
                MAX2 -= a
        ans = MAX2 - MIN2
       
        
else:
    if N == 2:
        ans -= MIN2
        
    else:
        b = A.pop(-1)
        
        MIN2 -= b
        for a in A:
            if a > 0:
                
                MIN2 -= a
            else:
                
                MAX2 -= a
        ans = MAX2 - MIN2

print(ans)

if MIN <= 0:
    if N == 2:
        ans -= MIN
        print("{0} {1}".format(MAX, MIN))
    else:
        
        for a in A:
            if a > 0:
                print("{0} {1}".format(MIN, a))
                MIN -= a
            else:
                print("{0} {1}".format(MAX, a))
                MAX -= a
        print("{0} {1}".format(MAX, MIN))
        
else:
    if N == 2:
        ans -= MIN
        print("{0} {1}".format(MAX, MIN))
    else:
      
        print("{0} {1}".format(MIN, b))
        MIN -= b
        for a in A:
            if a > 0:
                print("{0} {1}".format(MIN, a))
                MIN -= a
            else:
                print("{0} {1}".format(MAX, a))
                MAX -= a
        print("{0} {1}".format(MAX, MIN))


Measured memory_bytes: 14260
#include <stdio.h>

int main(){
  int W, a, b;
  scanf("%d %d %d", &W, &a, &b);
  if(a + W < b){
    printf("%d\n", b - (a + W));
  }else if(a < b && b <= a + W){
    printf("%d\n", 0);
  }else if(a - W < b && b <= a){
    printf("%d\n", 0);
  }else if(b <= a - W){
    printf("%d\n", a - (b + W));
  }
  return 0;
}


Measured memory_bytes: 128
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};
const main=()=>{
  let [a,b,k]=tnn(3)
  if(a>=k){
    [a,k]=[a-k,0]
  }else{
    [a,k]=[0,k-a]
  }
  if(b>=k){
    [b,k]=[b-k,0]
  }else{
    [b,k]=[0,k-b]
  }
  to(a,b)
}
main()


Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//map
int main()
{
    int H,W;

    while(true)
    {
        cin >> H >> W;
        if(H + W == 0)break;

        REP(i,H)
        {
            REP(j,W)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
 
#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}
 
ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}
 
ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
/*long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}*/
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return 
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}
 
 
 
/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/

#define int ll
const int MX = 1e3 +9;

int32_t main(){
    IO;
	ll a,b;
	cin>>a>>b;
	ll ans = -1;
	for(ll i = 1; i <= 1e5; i++){
		ll xx = i*8/100;
		ll yy = i*10/100;
		if(xx == a && yy == b && ans == -1) ans = i; 
	}
	cout<<ans;
    return 0;
}


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

int main(){
	int n;
  	cin >> n;
  	int c[n],s[n],f[n];
  	for(int i=1;i<n;i++)cin >> c[i] >> s[i] >> f[i];
	for(int i=1;i<=n;i++){
     	int t=0 ;
    	for(int j=i;j<n;j++){
        	if(t-s[j]<0) t=s[j];
          	else if ((t-s[j])%f[j]!=0) t=t-(t-s[j])%f[j]+f[j]; 
          	t+=c[j];
        }  
    	cout << t << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 500005
using namespace std;

int fr[27];

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (auto it : s){
    	fr[it - 'a']++;
    }
    ll ans = 1LL * s.size() * (s.size() + 1) / 2;
    for (int i=0;i<26;i++){
    	ans -= 1LL * fr[i] * (fr[i] + 1) / 2;
    }
    cout << ans + 1 << '\n';
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

pair<int, int> search_bingo(std::vector<std::vector<int>> A, int val)
{
    for (size_t i = 0; i < 9; i++)
    {
        if (val == A[i / 3][i % 3])
        {
            return make_pair(i / 3, i % 3);
        }
    }

    return make_pair(3, 3);
}

void solve(std::vector<std::vector<int>> A, int N, std::vector<int> b)
{
    vector<vector<bool>> flag(3, vector<bool>(3, false));

    for (int i = 0; i < N; i++)
    {
        pair<int, int> index = search_bingo(A, b[i]);
        if (index != make_pair(3, 3))
        {
            flag[index.first][index.second] = true;
        }
    }

    bool bingo_horizon, bingo_vert, bingo_diag;

    bingo_horizon = (flag[0][0] == true && flag[0][1] == true && flag[0][2] == true);
    bingo_horizon = bingo_horizon || (flag[1][0] == true && flag[1][1] == true && flag[1][2] == true);
    bingo_horizon = bingo_horizon || (flag[2][0] == true && flag[2][1] == true && flag[2][2] == true);

    bingo_vert = (flag[0][0] == true && flag[1][0] == true && flag[2][0] == true);
    bingo_vert = bingo_vert || (flag[0][1] == true && flag[1][1] == true && flag[2][1] == true);
    bingo_vert = bingo_vert || (flag[0][2] == true && flag[1][2] == true && flag[2][2] == true);

    bingo_diag = (flag[0][0] == true && flag[1][1] == true && flag[2][2] == true);
    bingo_diag = bingo_diag || (flag[2][0] == true && flag[1][1] == true && flag[0][2] == true);

    if (bingo_horizon || bingo_vert || bingo_diag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::vector<std::vector<int>> A(3, std::vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    std::vector<int> b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }
    solve(std::move(A), N, std::move(b));
    return 0;
}


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

using namespace std;

int main()
{
    int H, W;
    while (scanf("%d%d", &H, &W) == 2)
    {
        if (H == 0 && W == 0)
        {
            break;
        }
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (i != 0 && j != 0 && j != W - 1 && i!= H-1)
                {
                    printf(".");
                }
                else
                {
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 3120
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
struct St{
    int pl,rank;
    St(){
        rank=0;
    }
    bool operator<(const St &o) const{
        if(rank<o.rank) return true;
        else if(rank==o.rank && pl>o.pl) return true;
        return false;
    }
};
int main(){
    int n,m;
    for(;;){
        scanf("%d%d",&n,&m);
        if(n==0 && m==0) break;
        vector<St> ps(m);
        for(int i=0;i<m;i++){
            ps[i].pl=i+1;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                int ins;
                scanf("%d",&ins);
                if(ins==1) ps[j].rank++;
            }
        }
        sort(ps.begin(),ps.end());
        for(int i=m-1;i>0;i--){
            printf("%d ",ps[i].pl);
        }
        printf("%d\n",ps[0].pl);
    }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;

namespace abc121_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var a = CIn.ReadLong();
      var b = CIn.ReadLong();

      Console.WriteLine(Calc(a - 1) ^ Calc(b));
    }

    static long Calc(long a)
    {
      if (a % 2 == 0)
      {
        return a ^ (a / 2 % 2);
      }
      else
      {
        return (a + 1) / 2 % 2;
      }
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 11220
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<cassert>

int top, S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a, b, x, no, np;
  top = 0;
  char s[100];
  no = np = 0;
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a + b);
      no++;
    } else if ( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a - b);
      no++;
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a * b);
      no++;
    } else {
      x = atoi(s);
      assert(0 <= x && x <= 1000000);
      push(x);
      np++;
    }
  }
  assert(2 <= np && np <= 100);
  assert(1 <= no && no <= 99);
  assert( no+1 == np );
  printf("%d\n", pop());

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  map<string, int> blue;
  rep(i, n){
    string s; cin >> s;
    blue[s]++;
  }
  int m; cin >> m;
  map<string, int> red;
  rep(i, m){
    string s; cin >> s;
    red[s]++;
  }
  
  int ma = 0;
  for(auto p: blue){
    auto word = p.first;
    chmax(ma, blue[word] - red[word]);
  }

  cout << ma << endl;

  return 0;
}


Measured memory_bytes: 256
use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        mut s: Chars,
    }
    let len = s.len();
    if s[len - 1] == 's' {
        s.push('e');
    }
    s.push('s');
    let ans = s.into_iter().collect::<String>();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007;
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int cnt[2010];
signed main(){
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int d = min( abs(j-i), abs(x-i)+1+abs(y-j) );
			cnt[d]++;
		}
	}
	for(int i=1;i<=n-1;i++){
		cout<<cnt[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[200];
int main()
{
    int cnt=0;
    int f=1;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
        while(1)
        {
            for(int i=0; i<n; i++)
            {
                if(a[i]&1)
                {
                    f=0;
                }
                a[i]>>=1;
            }
            if(f) cnt++;
            else break;
        }
        cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		// [house] [floor] [room]
		int[][][] bldgs = new int[4][3][10];

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

		sc.close();

		StringBuilder sb = new StringBuilder();
		boolean flag = true;;
		
		for (int[][] f : bldgs) {
			if (flag) flag = false;
			else sb.append("####################\n");
			
			for (int[] r : f) {
				for (int v : r) {
					sb.append(" ").append(v);
				}
				sb.append("\n");
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 29116
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;

lli gcd(lli a, lli b){
    if(a%b==0) return b;
    return gcd(b,a%b);
}
lli lcm(lli a, lli b){
    return a /gcd(a,b) *b;
}

struct segmentTree{
    vector<lli> node;
    int n;
    
    segmentTree(vector<lli> v){
        int s = v.size();
        n = 2;
        while(n < s) n *= 2;
        node = vector<lli>(2*n -1, 1LL);
        for(int i=0; i<s; i++){
            node[i +n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = lcm(node[2*i +1], node[2*i +2]);
        }
    }
    segmentTree(){}
    
    lli Get(int l, int r){
        if(l == r) return 1LL;
        return _get(l, r, 0, 0, n);
    }
    lli _get(int l, int r, int k, int cl, int cr){
        if(l <= cl && cr <= r){
            return node[k];
        }
        if(r <= cl || cr <= l){
            return 1LL;
        }
        int m = (cl +cr)/2;
        return lcm(_get(l, r, 2*k+1, cl, m), _get(l, r, 2*k+2, m, cr));
    }
};

int main(){
    lli n,q;
    cin >> n >> q;
    vector<lli> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
        p[i]--;
    }
    vector<lli> c(n, 1), t(n, 0);
    for(int i=0; i<n; i++){
        int curr = i;
        t[i] += i+1;
        while(p[curr] != i){
            curr = p[curr];
            c[i]++;
            t[i] += curr+1;
        }
    }
    segmentTree lcmtree(c);

    vector<vector<lli>> csum(41, vector<lli>(n+1, 0));
    for(int i=0; i<n; i++){
        csum[c[i]][i+1] = t[i];
    }
    for(int i=1; i<=40; i++){
        for(int j=0; j<n; j++){
            csum[i][j+1] += csum[i][j];
            csum[i][j+1] %= mod;
        }
    }

    for(int rep=0; rep<q; rep++){
        int l,r;
        cin >> l >> r;
        lli cicle = lcmtree.Get(l-1, r);
        lli ans = 0;
        for(int i=1; i<=40; i++){
            if(cicle%i != 0) continue;
            lli quot = cicle/i %mod;
            ans += quot*(csum[i][r] -csum[i][l-1] +mod) %mod;
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 40176
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n;
string s;

int main(){
    cin>>n>>s;
    int ans=0;
    for(int i=1;i<n-1;i++){
        string left=s.substr(0,i);
        string right=s.substr(i,n-i);
        int cnt=0;
        rep(j,26){
            if(left.find(char('a'+j))!=string::npos && 
            right.find(char('a'+j))!=string::npos) cnt++;
        }
        chmax(ans,cnt);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<ctype.h>

int main(void)
{
	char s1[11], s2[11], s3[11];
	char a, b, c;

	scanf("%s %s %s", s1, s2, s3);
	a = toupper(s1[0]);
	b = toupper(s2[0]);
	c = toupper(s3[0]);

	printf("%c%c%c", a, b, c);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	int k,a,b,flag=0;
	cin >> k;
	cin >> a >> b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
	return 0;
}

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

bool is_pal(int i)
{
  string s = to_string(i);
  for(int i=0;i<s.length()/2;i++)
    if(s[i]!=s[s.length()-1-i]) return false;
  return true;
}
int main()
{
 int a,b,c=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++)
    if(is_pal(i))
      c++;
  cout<<c<<"\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define N 2000000
#define MAX 10000
 
int main(){
  int k,i,j,C[MAX+1];
  unsigned short  *A,*B;
   
  scanf("%d",&k);
 
  A = malloc(sizeof(short)*k+1);
  B = malloc(sizeof(short)*k+1);
 
  for(i = 0; i <= MAX; i++){
    C[i] = 0;
  }
 
  for(i = 1; i <= k; i++){
    scanf("%d",&A[i]);
    C[A[i]]++;
  }
   
   
  for(i = 1; i <= MAX; i++){
    C[i] += C[i-1];
  }
 
  for(j = k; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i = 1; i <= k; i++){
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }
 
  printf("\n");
 
  return 0;
}

Measured memory_bytes: 8460
#include <cstdio>

typedef long long ll;

ll a[111111];

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

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

int main(void)
{
	ll n, m, i, LCM = 1;

	scanf("%lld %lld" ,&n, &m);
	for (i = 0; i < n; i++)
	{
		scanf("%lld" ,&a[i]);
		a[i] /= 2;

		LCM = lcm(LCM, a[i]);

		if (LCM > m)
		{
            puts("0");
            return 0;
		}
	}

	for (i = 0; i < n; i++)
		if (LCM / a[i] % 2 == 0)
		{
			puts("0");
			return 0;
		}

	printf("%lld" ,m / LCM % 2 == 0 ? m / LCM / 2 : m / LCM / 2 + 1);
	return 0;
}

Measured memory_bytes: 896
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	char a[2000];
	char b[2000];
	int d=0;
	scanf("%s",b);
	int len=strlen(b);
	forin(i,0,len)
	{
		b[i]=toupper(b[i]);
	}
	scanf("%s",a);
	while(strcmp(a,"END_OF_TEXT")!=0)
	{
		len=strlen(a);
		forin(i,0,len)
		{
			a[i]=toupper(a[i]);
		}
		if(strcmp(a,b)==0)
		d++;
		
		scanf("%s",a);
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 3228