akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n == 0){
        cout << 0 << '\n';
        return 0;
    }
    int cnt = 42;
    string ans;
    while(cnt && n){
        cnt--;
        bool need = false;
        // auto get = [&](int shift){ return cnt - shift >= 0 ? 1ll << (cnt - shift) : 0; };
        auto get = [&](int shift){ 
            if(cnt < shift){ return 0ll; }
            ll bit = 1ll << (cnt - shift), ret = 0;
            while(bit){
                ret |= bit;
                bit >>= 2;
            }
            return ret;
        };
        if(cnt & 1){
            if(n > 0){
                need = n > get(1);
                // need = n >= (get(1) | get(2));
            }else{
                need = abs(n) > get(2);
                // need = abs(n) >= (get(2) | get(3));
            }
        }else{
            if(n > 0){
                need = n > get(2);
                // need = n >= (get(2) | get(3));
            }else{
                need = abs(n) > get(1);
                // need = abs(n) >= (get(1) | get(2));
            }
        }
        if(need){
            n -= (1ll << cnt) * (cnt & 1 ? -1 : 1);
            ans += '1';
        }else{
            if(ans.size()){
                ans += '0';
            }
        }
    }
    while(cnt){
        cnt--;
        ans += '0';
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
  long N,D,x,y;
  int count=0;
  double X[2*(int)pow(10,5)],Y[2*(int)pow(10,5)];
  scanf("%ld",&N);
  scanf("%ld",&D);
  for(int n=0;n<N;n++){
    scanf("%ld",&x);
    scanf("%ld",&y);
    X[n]=x;
    Y[n]=y;
    if(sqrt(pow(X[n],2)+pow(Y[n],2))<=D){
      count++;
    }
  }
  printf("%d\n",count);
return 0;
}

Measured memory_bytes: 5220
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static boolean dfs(int deep, int limit, int a, int b, int c) {
		if(deep >= limit) {
			return a < b && b < c;
		}else {
			if(a < b && b < c) { return true; }
			return dfs(deep + 1, limit, a * 2, b, c) || dfs(deep + 1, limit, a, b * 2, c) || dfs(deep + 1, limit, a, b, c * 2);
		}
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int C = sc.nextInt();
			final int K = sc.nextInt();
			
			System.out.println(dfs(0, K, A, B, C) ? "Yes" : "No");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    char s;
    cin >> s;
    string ss = "abcdefghijklmnopqrstuvwxyzz";
    rep(i, ss.length()) {
        if ( s == ss[i] ) {
            cout << ss[i+1] << endl;
            break;
        }
    }
    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 rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	V<string> s(n);
	vi t(n);
	rep(i, n)cin >> s[i] >> t[i];
	string x;
	cin >> x;

	bool sleep = false;

	int ans = 0;
	rep(i, n) {
		if (sleep)ans += t[i];
		else if (s[i] == x)sleep = true;
	}
	
	cout << ans << endl;

}

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

int main()
{
	int N;
	cin >> N;
	vector<pair<int, int>> A( N );
	for( int i = 0; i < N; i++ ) {
		int a;
		cin >> a;
		A[i] = make_pair( a, i );
	}

	sort( A.begin(), A.end() );
	int cnt = 1;
	int idx = A[N - 1].second;
	int ma = A[N - 1].first;
	for( int i = N - 2; i >= 0; i-- ) {
		if( A[i].first < ma ) {
			break;
		}
		cnt++;
		break;
	}

	if( cnt == 1 ) {
		for( int i = 0; i < N; i++ ) {
			if( i == idx ) {
				cout << A[N - 2].first << endl;
			}
			else {
				cout << ma << endl;
			}
		}
	}
	else {
		for( int i = 0; i < N; i++ ) {
			cout << ma << endl;
		}
	}
}


Measured memory_bytes: 3200
N = int(input())
mod = 10**9 + 7
dp = [[0]*4 for _ in range(N+1)]
dp[1][0] = 8
dp[1][1] = 1
dp[1][2] = 1

for i in range(2, N+1):
    dp[i][0] = dp[i-1][0]*8 % mod
    dp[i][1] = (dp[i-1][0] + dp[i-1][1]*9) % mod
    dp[i][2] = (dp[i-1][0] + dp[i-1][2]*9) % mod
    dp[i][3] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3]*10) % mod

print(dp[N][3]%mod)

Measured memory_bytes: 198680
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    edges[a].append(b)
    edges[b].append(a)

values = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    values[p-1] += x

stack = [0]
visited = [0]*n
while stack:
    v = stack.pop()
    if visited[v]:
        continue
    visited[v] = 1
    for v2 in edges[v]:
        if visited[v2]:
            continue
        values[v2] += values[v]
        stack.append(v2)
print(*values)


Measured memory_bytes: 63848
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<int> _prime;
vector<int> build_prime_table(int max) {
	vector<int> table = vector<int>(max + 1, -1);
	table[0] = 0;
	table[1] = 0;
	table[2] = 1;
	for (int i = 3; i <= max; i++) {
		if (i % 2 == 0) { table[i] = 0; continue; }
		if (table[i] != -1)continue;
		table[i] = 1;
		for (int j = i + i; j <= max; j += i) {
			table[j] = 0;
		}
	}
	return table;
}

inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}


vector<long long> comb = vector<long long>(100 * 100, -1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}



void fill(int from, int end,vector<bool>& table) {
	int f_hour = from / 100;
	int f_min = from % 100;f_min /= 5;
	int e_hour = end / 100;
	int e_min = end % 100; e_min = ceileing(e_min, 5);
	//引数をいじるのは行儀が悪い
	from = f_hour * 12 + f_min;
	end = e_hour * 12 + e_min;
	//区間塗りつぶし
	for (size_t i = from; i < end; i++) {
		table[i] = true;
	}
}

struct Train {
	long long start, span, cost;
};

int main() {
	int N; cin >> N;
	auto trains = vector<Train>(N - 1);
	for (size_t i = 0; i < N - 1; i++) cin >> trains[i].cost >> trains[i].start >> trains[i].span;

	for (size_t i = 0; i < N - 1; i++) {
//		cout << "From" << i << " 0 ->wait&move->";
		long long time = trains[i].start + trains[i].cost;
//		cout << time << "->";
		for (size_t j = i + 1; j < N - 1; j++) {
			if (time < trains[j].start) {
				time = trains[j].start;
//				cout << "wait->" << time << "->";
			}
			if (time%trains[j].span != 0) {
				time += trains[j].span - (time%trains[j].span);
//				cout << time << "->";
			}
			time += trains[j].cost;
//			cout << "move->" << time << "->";
		}
//		cout << "arrive:"<<time << endl;
		cout << time << endl;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 384
N, Y = gets.split.map(&:to_i)

res10000  = -1
res5000   = -1
res1000   = -1
break_flg = false
(0..N).each do |a|
  (0..N - a).each do |b|
    c     = N - a - b
    total = (10000 * a) + (5000 * b) + (1000 * c)
    if total == Y
      res10000 = a
      res5000  = b
      res1000  = c
      break_flg = true
    end
    break if break_flg
  end
  break if break_flg
end

puts [res10000, res5000, res1000].join(' ')


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, A, B; cin >> N >> A >> B;
  vector<ll> V;
  for (ll i = 0; i < N; i++) {
    ll v; cin >> v;
    V.push_back(v);
  }
  sort(V.begin(), V.end(), greater<ll>());
  double s = 0;
  for (ll i = 0; i < A; i++) s += V.at(i);
  cout << s / A << endl;
  ll p = -1;
  ll q = 0;
  ll border = V.at(A-1);
  for (ll i = 0; i < N; i++) {
    if (V.at(i) == border) {
      if (p < 0) p = i;
      q = i;
    }
  }
  ll comNum = 0;
  q++;
  if (q == A) {
    comNum = 1;
  }else if (p > 0) {
    // C(q-p, A-p)
    ll n = q-p;
    ll r = A-p;
    comNum = 1;
    for (ll i = 1; i <= r; i++) comNum = comNum * (n-i+1) / i;
  }else {
    comNum = 0;
    ll z = 1;
    for (ll i = 1; i <= min(B, q); i++) {
      z = z * (q-i+1) / i;
      if (A <= i) comNum += z;
    }
  }
  cout << comNum << endl;

  return 0;
}



Measured memory_bytes: 256
function Main(input) {
  // 入力
	input = input.split('\n');
	
	var n = parseInt(input[0], 10);
	input.shift();
	for (var i = 0; i < n; i++) {
		input[i] = parseInt(input[i], 10);
	}

	// 計算
	var tmp = input.indexOf(Math.max.apply(null, input));
	input[tmp] /= 2; 
	function sum(a) {
		return a.reduce(function(x, y) { return x + y; });
	}

	//出力
	console.log('%d', sum(input));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#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;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<int> A(N), B(N), C(N); cin >> A >> B >> C;
        ll ans = 0;
        rep(i, N) {
            ans += B[A[i] - 1];
            if(i > 0 and A[i - 1] + 1 == A[i]) ans += C[A[i - 1] - 1];
        }
        cout << ans << endl;
        return 0;
    }
};

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
char x,y;
cin>>x>>y;
if(x>y)cout<<'>'<<endl;
else if(x<y)cout<<'<'<<endl;
else cout<<'='<<endl;
//system("pause");
return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

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

    s[3] = '8';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;


int H, W, K;
int dp[110][10];


bool judge(int bit){
    repif(i, 0, bit>>(i+1))
        if(((bit>>i)&1) && ((bit>>(i+1))&1)) return false;
    return true;
}


int calcV(int bit, int i, int j){
    if(j != W-1 && (bit>>j)&1) return dp[i-1][j+1];
    if(j != 0 && (bit>>(j-1))&1) return dp[i-1][j-1];
    return dp[i-1][j];
}


signed main(){
    cin >> H >> W >> K;

    dp[0][0] = 1;
    repe(i, 1, H){
        rep(j, 0, W){
            rep(k, 0, 1<<(W-1)){
                if(!judge(k)) continue;
                dp[i][j] = ADD(dp[i][j], calcV(k, i, j));
            }
        }
    }

    cout << dp[H][K-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll ans = LONG_LONG_MIN;
    rep(left, k + 1) {
        rep(right, k + 1 - left) {
            if ((left + right) > n) continue;
            priority_queue<ll, vector<ll>, greater<ll>> pq;
            ll tmp = 0;
            rep(i, left) {
                pq.push(v[i]);
                tmp += v[i];
            }
            rep(i, right) {
                pq.push(v[n - 1 - i]);
                tmp += v[n - 1 - i];
            }
            rep(i, k - (left + right)) {
                if (pq.empty()) break;
                ll v = pq.top(); pq.pop();
                if (v >= 0) break;
                tmp -= v;
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

int n, p[100002];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 1, n+1) cin >> p[i];
  int ans = 0;
  FOR(i, 1, n+1){
    if(i == p[i]){
      swap(p[i], p[i+1]);
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
# 2019-11-17 10:52:21(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np

def sum_inverses(a, b):
    return a + 1 / b

def main():
    n, *a = map(int, sys.stdin.read().split())

    ans = 1 / reduce(sum_inverses, a, 0)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
N = int(input())
b1 = dict()
b2 = dict()
b3 = dict()
b4 = dict()

for i in range(1,4):
  for j in range(1,11):
    idx = i*10+j
    b1[idx] = 0
    b2[idx] = 0
    b3[idx] = 0
    b4[idx] = 0

builds = [b1, b2 ,b3 ,b4]

for i in range(N):
  a = list(map(int,input().split()))
  idx = a[1] * 10 + a[2]
  builds[a[0] - 1][idx]  += a[3]

for b in range(4):
  d = builds[b]
  for i in range(11,21):
    print(" {}".format(d[i]),end="")
  print()
  for i in range(21,31):
    print(" {}".format(d[i]),end="")
  print()
  for i in range(31,41):
    print(" {}".format(d[i]),end="")
  print()
  if b < 3:
    print("####################")



Measured memory_bytes: 5628
N = int(input())
A = list(map(int, input().strip().split(' ')))
B = list(map(int, input().strip().split(' ')))

total = 0
c = A[0]
for i in range(N):
	if c + A[i +1] <= B[i]:
		total += c + A[i +1]
		c = 0
	elif c >= B[i]:
		total += B[i]
		c = A[i +1]
	else:
		total += B[i]
		c = c + A[i +1] - B[i]
		
print(total)

Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	int n = s.size();
	int zero = 0;
	int one = 0;
	for(int i = 0; i < n; ++i) {
		if( s[i] - '0' == 0 ) zero++;
		if( s[i] - '0' == 1 ) one++;
	}
	
	cout << 2 * min(zero, one)<< endl;
	
	return 0;
}


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

int main(){
    long n;cin>>n;
    long double check=1;
    long double a;
    long long ans=1;
    for(int i=0;i<n;i++){
        cin>>a;
        ans*=a;
        check*=a;
    } 
    if(check>1000000000000000000){
        cout<<"-1"<<endl;
    }
    else{
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3692
using System;
class Program
{
    static void Main(string[] args)
    {
        double n = double.Parse(Console.ReadLine());
        double a = Math.Floor(n/1.08);
        double b = Math.Ceiling(n/1.08);
        if (n == Math.Floor(a*1.08))
        {
            Console.WriteLine(a);
        } 
        else if (n == Math.Floor(b*1.08))
        {
            Console.WriteLine(b);
        } 
        else
        {
            Console.WriteLine(":(");
        }
    } 
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}




  int main()
  {
      fast;
      ll n,W;
      cin>>n>>W;
      ll w[n+1],v[n+1],sum=0;
      for(int i=1;i<=n;i++)
      {
      	  cin>>w[i]>>v[i];
      	  sum+=v[i];
      }
      ll dp[n+1][sum+1];
      ll ans=0;

      for(int i=0;i<=sum;i++)
      {
      	  dp[0][i]=1e18;                  // with no element no chance for any sum 
      }
      for(int i=0;i<=n;i++) dp[i][0]=0;   // minimum weight required to have cost 0 for each i;
      for(int i=1;i<=n;i++)
      {
      	  for(int j=1;j<=sum;j++)
      	  {   
      	  	  if(j>=v[i])
      	  	  dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]); 
      	  	  else
      	  	  dp[i][j]=dp[i-1][j];   // to take it or not 
      	  }
      	 
      }

      for(int i=0;i<=sum;i++) 
      {
      	 if(dp[n][i]<=W)
      	 {
      	 	ans=i;
      	 }
      }
       
      cout<<ans<<endl; 


        
  }




Measured memory_bytes: 79104
#include<stdio.h>
int pat[10][7];
void set(int n,int a,int b,int c,int d,int e,int f,int g){
	pat[n][0]=a;
	pat[n][1]=b;
	pat[n][2]=c;
	pat[n][3]=d;
	pat[n][4]=e;
	pat[n][5]=f;
	pat[n][6]=g;
}

int main(){
	while(1){
	int n,i;
	scanf("%d",&n);
		if(n==-1)return 0;
	set(0,1,1,1,1,1,1,0);
	set(1,0,1,1,0,0,0,0);
	set(2,1,1,0,1,1,0,1);
	set(3,1,1,1,1,0,0,1);
	set(4,0,1,1,0,0,1,1);
	set(5,1,0,1,1,0,1,1);
	set(6,1,0,1,1,1,1,1);
	set(7,1,1,1,0,0,1,0);
	set(8,1,1,1,1,1,1,1);
	set(9,1,1,1,1,0,1,1);
	int old,now;
	int j;
	scanf("%d",&old);
		for(i=6;i>=0;i--){
			if(pat[old][i]==1)printf("1");
			else printf("0");
		}
		printf("\n");
	for(i=0;i<n-1;i++){
		scanf("%d",&now);
		for(j=6;j>=0;j--){
			if(pat[old][j]!=pat[now][j])printf("1");
			else printf("0");
		}
		printf("\n");
		old=now;
	}
	}
}
			
			
			
		

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

using namespace std;

#define ld long double
#define DIM 200009
#define INF ((1ll<<63ll)-1ll)

struct line{
    long long k,b;
};

line ls[DIM];

long long i,j,k,l,n,m,sz;

bool check(line a1,line a2,line a3){
    return (ld)(a3.b-a1.b)/(ld)(a1.k-a3.k)>=(ld)(a3.b-a2.b)/(ld)(a2.k-a3.k);
}

void add(long long k,long long b){
    while(sz>=2 && check(ls[sz-1],ls[sz],{k,b}))sz--;
    ls[++sz]={k,b};
}

long long can(long long num,long long x){
    return ls[num].k*x+ls[num].b;
}

long long get(long long x){
    long long l=0,r=sz,mid;
    while(r-l>1){
        mid=(l+r)/2;
        if(can(mid,x)<can(mid+1,x))r=mid;
        else l=mid;
    }
    return can(r,x);
}

long long h[DIM],b[DIM],dp[DIM];

int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++)cin>>h[i];

    dp[1]=0;
    add(-2*h[1],h[1]*h[1]);

    for(i=2;i<=n;i++){
        dp[i]=get(h[i])+m+h[i]*h[i];
        add(-2*h[i],dp[i]+h[i]*h[i]);
    }

    cout<<dp[n]<<endl;

    return 0;
}
/**
    k=b[i]
    x=a[i]
    b=dp[i]

    k=-2*h[i]
    x=h[i]
    b=C+dp[i]+h[i]*h[i]
    h[i]*h[i]-2*h[i]*h[j]+h[j]*h[j]+C+dp[j]
*/


Measured memory_bytes: 7552
#include <iostream>
#include <cstring>
#include <queue>

using namespace std;

int N, M, L;

struct Edge {
	int to, dist, enemy;
	Edge(int _t, int _d, int _e) : to(_t), dist(_d), enemy(_e) {}
};
bool operator > (const Edge& e1, const Edge& e2) {
	if (e1.enemy < e2.enemy) return true;
	else if (e1.to > e2.to) return true;
	return e1.dist < e2.dist;
}
bool operator == (const Edge& e1, const Edge& e2) {
	if (e1.enemy == e2.enemy && e1.to==e2.to && e1.dist == e2.dist) return true;
	return false;
}
bool operator != (const Edge& e1, const Edge& e2) { return !(e1 == e2); }
bool operator < (const Edge& e1, const Edge& e2) { return !(e1 > e2) && (e1 != e2); }
bool operator >= (const Edge& e1, const Edge& e2) { return (e1 > e2) && (e1 == e2); }
bool operator <= (const Edge& e1, const Edge& e2) { return (e1 < e2) && (e1 == e2); }

const int INF = 1e9;
int d[110][110];

int main() {
	while (1) {
		cin >> N >> M >> L; if (N==0 && M==0 && L==0) break;
		vector< vector<Edge> > G(N+1, vector<Edge>());
		
		for (int i=0; i<M; i++) {
			int a, b, d, e; cin >> a >> b >> d >> e;
			G[a].push_back(Edge(b, d, e));
			G[b].push_back(Edge(a, d, e));
		}
		
		for (int i=0; i<=N; i++) fill(d[i], d[i] + L + 1, INF);
		
		d[1][0] = 0;
		
		priority_queue<Edge, vector<Edge>, greater<Edge> > q;
		q.push( Edge(1, 0, 0) );
		
		while (!q.empty()) {
			Edge e = q.top(); q.pop();
			
			for (int i=0; i<(int)G[e.to].size(); i++) {
				Edge ne = G[e.to][i];
				
				if (e.dist + ne.dist <= L) {
					if (d[ne.to][e.dist + ne.dist] > e.enemy) {
						d[ne.to][e.dist + ne.dist] = e.enemy;
						q.push(Edge(ne.to, e.dist + ne.dist, e.enemy));
					}
				}
				
				if (d[ne.to][e.dist] > e.enemy + ne.enemy) {
					d[ne.to][e.dist] = e.enemy + ne.enemy;
					q.push(Edge(ne.to, e.dist, e.enemy + ne.enemy));
				}
			}
		}
		
		int ans = INF;
		for (int i=0; i<=L; i++) ans = min(ans, d[N][i]);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 998244353;

int main(){
  int n;
  cin >> n;
  int t;
  cin >> t;
  if(t != 0) {
    puts("0");
    return 0;
  }
  --n;
  vector<int> d(n);
  rep(i, n) {
    cin >> d[i];
    if(d[i] == 0) {
      puts("0");
      return 0;
    }
  }

  ll ans = 1;
  sort(d.begin(), d.end());
  vector<int> cnt(100000);
  for(int i = 0; i < n; ++i) {
    cnt[d[i]]++;
  }
  cnt[0] = 1;
  for(int i = 1; i <= d[n - 1]; ++i) {
    rep(j, cnt[i]) {
      ans *= cnt[i - 1];
      ans %= mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
program main
  integer :: N
  integer :: D
  integer :: i
  integer :: out
  !
  read(*,*) N,D
  i=1
  out = N
  do
     out = out - ( 2*D + 1)
     if ( out <= 0) exit
     i = i+1
  end do
  out = i
  write(*,'(i0)') out
  stop
end program main


Measured memory_bytes: 256
from heapq import heappush, heappop

def checker():
  N=int(raw_input())
  edge=[[] for _ in xrange(N)]
  for _ in xrange(N-1):
    a,b=map(int,raw_input().split())
    edge[a-1]+=[b-1]
    edge[b-1]+=[a-1]
  P=[None]*N
  d=[False]*N
  q=[]
  K=int(raw_input())
  for _ in xrange(K):
    v,p=map(int,raw_input().split())
    P[v-1]=p
    d[v-1]=True
    heappush(q, (p, v-1))
  while q:
    p,v=heappop(q)
    for z in edge[v]:
      if P[z] is None:
        if not d[z]:
          P[z]=p+1
          d[z]=True
          heappush(q, (p+1, z))
      else:
        if P[z] not in (p-1, p+1):
          print "No"
          return
        if not d[z]:
          d[z]=True
          heappush(q, (f[z], z))
  print "Yes"
  for i in P: print i

checker()

Measured memory_bytes: 34492
// D.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 110, MAX_P = MAX_N << 1, INF = 0x3f3f3f3f;

int n, m, ai[MAX_N][MAX_N], bi[MAX_N][MAX_N], ptot;
int rmat[MAX_N], mat[MAX_N][MAX_N], f[MAX_N][MAX_N], g[MAX_N][MAX_N];
pair<int, int> trans[MAX_N * MAX_N];
vector<int> tr[MAX_N][MAX_N];

namespace NetworkFlow
{

	int head[MAX_P], current, deg[MAX_P], start_pos, end_pos, dep[MAX_P], cur[MAX_P];

	struct edge
	{
		int to, nxt, weight, pos;
	} edges[MAX_N * MAX_N << 2];
	
	void addpath(int src, int dst, int weight, int pos)
	{
		edges[current].to = dst, edges[current].nxt = head[src];
		edges[current].weight = weight, edges[current].pos = pos, head[src] = current++;
	}
	
	void addtube(int src, int dst, int weight)
	{
		addpath(src, dst, weight, deg[dst]);
		addpath(dst, src, 0, deg[src]);
		deg[src]++, deg[dst]++;
	}
	
	void build()
	{
		memset(head, -1, sizeof(head)), memset(deg, 0, sizeof(deg));
		current = 0, start_pos = (n << 1) + 1, end_pos = start_pos + 1;
		for (int i = 1; i <= n; i++)
			addtube(start_pos, i, 1), addtube(i + n, end_pos, 1);
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				if (mat[i][j])
					addtube(i, j + n, 1);
	}
	
	bool bfs()
	{
		memset(dep, 0, sizeof(dep));
		queue<int> q;
		q.push(start_pos), dep[start_pos] = 1;
		while (!q.empty())
		{
			int u = q.front();
			q.pop();
			for (int i = head[u]; i != -1; i = edges[i].nxt)
				if (dep[edges[i].to] == 0 && edges[i].weight > 0)
					dep[edges[i].to] = dep[u] + 1, q.push(edges[i].to);
		}
		return dep[end_pos] != 0;
	}
	
	int dfs(int u, int flow)
	{
		if (u == end_pos || flow == 0)
			return flow;
		for (int i = head[u]; i != -1; i = edges[i].nxt)
			if (edges[i].weight > 0 && dep[edges[i].to] == dep[u] + 1)
				if (int di = dfs(edges[i].to, min(flow, edges[i].weight)))
				{
					edges[i].weight -= di, edges[i ^ 1].weight += di;
					return di;
				}
		return 0;
	}
	
	int dinic()
	{
		int ret = 0;
		while (bfs())
		{
			memcpy(cur, head, sizeof(cur));
			while (int di = dfs(start_pos, INF))
				ret += di;
		}
		for (int u = 1; u <= n; u++)
			for (int i = head[u]; i != -1; i = edges[i].nxt)
				if (edges[i].to != start_pos && edges[i].weight == 0)
					rmat[u] = edges[i].to - n;
		return ret;
	}

}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
		{
			scanf("%d", &ai[i][j]), bi[i][j] = ++ptot;
			trans[ai[i][j]].first = i, trans[bi[i][j]].second = i;
		}
	for (int i = 1; i <= n * m; i++)
		tr[trans[i].first][trans[i].second].push_back(i);
	for (int k = 1; k <= m; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				mat[i][j] = !tr[i][j].empty();
		NetworkFlow::build(), NetworkFlow::dinic();
		for (int i = 1; i <= n; i++)
		{
			int x = tr[i][rmat[i]].back();
			tr[i][rmat[i]].pop_back();
			f[i][k] = x, g[rmat[i]][k] = x;
		}
	}
	for (int i = 1; i <= n; i++, puts(""))
		for (int j = 1; j <= m; j++)
			printf("%d ", f[i][j]);
	for (int i = 1; i <= n; i++, puts(""))
		for (int j = 1; j <= m; j++)
			printf("%d ", g[i][j]);
	return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll N, K; cin >> N >> K;
  Vi h(N); REP(i, N) cin >> h[i];
  SORT(h);
  Vi a(N - K + 1);
  REP(i, N - K + 1){
    a[i] = h[i + K - 1] - h[i];
  }
  ll ans = INF;
  REP(i, N - K + 1) chmin(ans, a[i]);
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;

int sta[1000];
int c;

void push(int x){
  sta[++c]=x;
}
int pop(){
  c=c-1;
  return sta[c+1];
}


int main(){
  char st1[1000];
  int math1,math2;
  int c=0;
  while(scanf("%s",st1)!=EOF){
    /*printf("%c\n",st1[0]);
    math1=atoi(st1);
    if(flag==0){
      a=math1;
    }
    flag=1;
    //printf("%d\n",math1);
    //printf("%d\n",a);
    sum=math1+a;
    */
    if(st1[0]=='+'){
      math1=pop();
      math2=pop();
      push(math1+math2);
    }
    else if(st1[0]=='*'){
      math1=pop();
      math2=pop();
      push(math1*math2);
    }
    else if(st1[0]=='-'){
      math2=pop();
      math1=pop();
      push(math1-math2);
    }
    else {
      push(atoi(st1));
    }
  }
  printf("%d\n",pop());
  return 0;
}



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

const int N = 1e5 + 5;

int a[N][3];
ll dp[4][N];
int n;

ll solve(int p, int i) {
  if (i == n)
    return 0;
    if (dp[p][i] != -1)
      return dp[p][i];
  for (int c = 0; c < 3; c++) if (c != p) {
    dp[p][i] = max(a[i][c] + solve(c, i+1), dp[p][i]);
  }
  return dp[p][i];
}

int main () {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  cout << solve(3, 0) << '\n';
  return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int mod = 1000000007;

char s[2][66];
int same[66];

int main() {
	int n;
	scanf("%d%s%s", &n, s[0], s[1]);
	FOR(i,n) same[i] = s[0][i] == s[1][i];
	int st = 1;
	long long ways = 1;
	if (same[0]) {
		st = 1;
		ways = 3;
	} else {
		st = 2;
		ways = 6;
	}
	for (int i = st; i < n; ) {
		if (same[i-1]) ways *= 2;
		if (!same[i-1] && !same[i]) ways *= 3;
		ways %= mod;
		if (same[i]) i++;
		else i+=2;
	}
	printf("%lld\n", ways);
	return 0;
}


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

int main() {

	int n; cin >> n;
	vector<pair<int, int>> pa;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		pa.push_back({ a,i + 1 });
	}
	sort(pa.begin(), pa.end());
	for (int i = 0; i < pa.size(); i++) {
		cout << pa[i].second << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4332
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//constexpr long long MOD = 1e9 + 7;
//constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

const ll MAX = 500000000;
const ll MOD = 1000000007;

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll repNum = n / (a + b);
    ll ans = repNum * a + min(a, n % (a + b));
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, x;
	cin >> n >> m >> x;

	bool *a = new bool[n]; x--;
	for (int i = 0; i < n; i++) { a[i] = false; }
	rep(i, m) {
		int ai;
		cin >> ai;
		ai--;
		a[ai] = true;
	}
	ll ans = 0;
	for (int i = x; i < n; i++) {
		if (a[i]) { ans++; }
	}
	ll ans1 = 0;
	for (int i = x; i >= 0; i--) {
		if (a[i]) { ans1++; }
	}
	cout << min(ans,ans1)<<endl;
	return 0;
}

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

using namespace std;

#define MAX 100002

int n;
long long int a[MAX];

int main(){
	cin >> n;
	int x;
	cin >> x;
	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	long long int BB = 0;
	for (int i = 1; i < n; i++){
		long long int sum = a[i - 1] + a[i];
		if (sum > x){
			BB += sum - x;
			long long int b = min(a[i], sum - x);
			sum -= b;
			a[i] -= b;
		}
	}
	printf("%lld\n", BB);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] h = new int[n];
		int max = 0;
		int cnt = 0;
		for(int i = 0; i < n; i++){
		    h[i] = sc.nextInt();
		    if(max <= h[i]){
		        cnt++;
		        max = h[i];
		    }
		}
		
		// 計算
		int result = cnt;
		
		// 出力
		System.out.println(result);
        
	}
}

Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF   = 1e18;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    REP0 (i, N)
    {
        int a;
        cin >> a;
        if (a % 2 == 0)
            if (!(a % 3 == 0 or a % 5 == 0))
            {
                cout << "DENIED" << endl;
                return;
            }
    }
    cout << "APPROVED" << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,w,a,b;
  char c;
  cin>>n>>w;
  int A[n+1];
  rep(i,n+2) A[i]=i;
  rep(i,w){
    cin>>a>>c>>b;
    swap(A[a],A[b]);
  }
  for(int i=1;i<n+1;i++) cout<<A[i]<<endl;
  
  return 0;
}


Measured memory_bytes: 3084
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		int i=1;
	    while(true){
        	int x=Integer.parseInt(br.readLine());
        	if(x==0) break;
        	sb.append("Case "+i+": "+x+"\n");
    		i++;
            }
		System.out.print(sb);
	}
}

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

using namespace std;

const int N = 1e5 + 5;

int n, a[N], par[N], ind;
long long dp[N], mx = -1e18;
vector <int> ans;

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

      for(int i = 1; i <= n; i ++){
            scanf("%d", &a[i]);
            dp[i] = a[i];
            par[i] = i;
      }

      for(int i = 1; i <= n; i ++){
            for(int j = i - 2; j >= 1; j -= 2){
                  if(dp[j] + a[i] > dp[i]){
                        dp[i] = dp[j] + a[i];
                        par[i] = j;
                  }
            }
      }

      for(int i = 1; i <= n; i ++){
            if(mx < dp[i]){
                  mx = dp[i];
                  ind = i;
            }
      }

      cout << mx << endl;

      for(int i = n; i > ind; i --){
            ans.push_back(i);
      }

      while(ind != par[ind]){
            int md = (ind + par[ind]) >> 1;
            for(int i = md; i > par[ind]; i --)
                  ans.push_back(i);
            ind = par[ind];
      }

      for(int i = 1; i < ind; i ++)
            ans.push_back(1);

      cout << ans.size() << endl;

      for(int i : ans)
            cout << i << endl;
}


Measured memory_bytes: 256
//問題C
//東西に一直線に駅がN個あり，西から順番に番号がついている．
//ある駅から次の駅へ行く手段は駅にf[i]時間ごとに来る電車に乗る事
//西から東にもっとも早くたどり着く時間が知りたい．
//駅にくる電車はC[i]が次の駅までの移動時間，s[i]が電車がはじめに動く時間，f[i]が次の電車が来るまでの時間

//考察
//ゴールから最短時間を調べていった方が良さそう?
//実装がわからなくなったので愚直な方法でとりあえずとく．
#include <iostream>
#define MAX_N 550
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,k,n) for(int i = k; i<n ; i++)
using namespace std;
int main(){
  int n;
  int c[MAX_N],s[MAX_N],f[MAX_N];
  int ans[MAX_N] = {};
  cin >> n;
  rep(i,n-1){
    cin >> c[i] >> s[i] >> f[i];
  }
  rep(k,n-1){
    int t=0;
    REP(i,k,n-1){
      if(t<s[i]) t=s[i];
      if(t%f[i]!=0) t += f[i] - t%f[i];
      t += c[i];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <string>
using namespace std;
 
int main(){
  int n,m; 
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m); 
  int ans = -1; 
  for(int i=0;i<m;i++){
    cin >> s[i] >> c[i];
  }
  int min;
  int max;
  if(n==2){
    min = 10;
    max = 99;
  }else if(n==3){
    min = 100;
    max = 999;
  }else{
    min = 0;
    max = 9;
  }
  vector<int> dig(3);
  int w =0;
  for(int i=min;i<=max;i++){
    w=0;
    for(int j=0;j<m;j++){
      if(n==1){
        dig[0]=i;
      }else if(n==2){
        dig[0]=i/10;
        dig[1]=i%10;
      }else{
        dig[0]=i/100;
        dig[1]=(i/10)%10;
        dig[2]=(i%100)%10;
      }
      if(dig[s[j]-1]!=c[j]){
        w = 1;
        break;
      }
    }
    if(w==0){
      ans = i;
      break;
    }
  }
  cout << ans;
}
 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[(int)1e6+100]={};

int main(){
    int n;
    scanf("%d",&n);
    vector <int> l(n);
    int count=0;
    for (int i=0;i<n;i++) {
        scanf("%d",&l[i]);
        if(dp[l[i]]>0) continue;
        if (dp[l[i]]<0) {
            dp[l[i]]=1;
            continue;
        }
        dp[l[i]]=-1;
        for(int k=l[i]<<1;k<=1e6+99;k+=l[i]){
            dp[k]=1;
        }
    }
    for (int i=0;i<n;i++){
        if (dp[l[i]]==-1) count++;
    }
    printf("%d\n",count);
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    string S;
    cin >> S;

    map<char, ll> m;
    rep (i, S.size()) {
        m[S[i]]++;
    }

    for (auto it : m) {
        if (it.second > 1) {
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        StringBuilder str = new StringBuilder(sc.nextLine());
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String com = sc.next();
            int a = sc.nextInt();
            int b = sc.nextInt()+1;
            if ("replace".equals(com)) {
                String str2 = sc.next();

                str = str.replace(a,b, str2);
            } else if ("reverse".equals(com)) {

                StringBuilder temp  = new StringBuilder(str.substring(a, b));
                temp.reverse();
                str.replace(a, b, temp.toString());

            } else if ("print".equals(com)) {

                System.out.println(str.substring(a, b));
            }
        }
        sc.close();
    }

}

Measured memory_bytes: 22084
def col_name(col_idx)
    name = ""
    while col_idx>0
        mod     = (col_idx-1)%26
        name    = (65+mod).chr + name
        col_idx = ((col_idx-mod)/26).to_i
    end
    name
end

col_index = gets.to_i

d = col_name(col_index).downcase

puts d

Measured memory_bytes: 14368