akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a;
    cin >> a;
    // スペース区切りの整数の入力
    char str[a];
    cin >> str;

    int counter = 0;
    int i;
    if (a%2 == 1)
    {
        counter = 1;
    }else
    {
        for ( i = 0; i < a/2; i++)
        {
            if (str[i] != str[i+a/2])
            {
                counter = counter + 1;
            }
        }
    }

    if (counter == 0)
    {
        cout << "Yes" <<endl;
    }else
    {
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
S = x/a
if S>=(a*b)/2:
    h = (a*b-S)*2/a
    rad = math.atan2(h,a)
else:
    w = 2*S/b
    rad = math.atan2(b,w)
deg = rad/(2*math.pi)*360
print(deg)

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define DIVISOR 1000000007
#define NUM_MAX 200000
// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

struct point2d {
    int row;
    int col;
};

struct pair {
    int x;
    int y;
};

struct pair gcdext(int a, int b) {
    if(a==0) { return (struct pair){0, 1}; }
    struct pair p = gcdext(b%a, a);
    return (struct pair){p.y - (b/a)*p.x, p.x};
}
static int64_t factorial[NUM_MAX+1];
static int64_t inv_factorial[NUM_MAX+1];
void init_combi(int size) {
    factorial[0] = factorial[1] = 1;
    inv_factorial[0] = inv_factorial[1] = 1;
    int i;
    for(i = 2; i <= size; i++) {
        factorial[i] = (factorial[i-1] * i)%DIVISOR;
        struct pair p = gcdext(i, DIVISOR);
        int inv = (p.x + DIVISOR)%DIVISOR;
        inv_factorial[i] = (inv_factorial[i-1] * inv)%DIVISOR;
    }
    return;
}

int64_t calc_combi(int n, int k) {
    if(k > n) return 0;
    int64_t ans = 1;
    ans = (ans * factorial[n])%DIVISOR;
    ans = (ans * inv_factorial[n-k])%DIVISOR;
    ans = (ans * inv_factorial[k])%DIVISOR;
    return ans;
}


int64_t calc_routes(struct point2d p1, struct point2d p2) {
    int rs = p2.row - p1.row;
    int cs = p2.col - p1.col;
    return calc_combi(rs+cs, rs);
}

int main(void) {
    int rows, cols;
    get_int2(&rows, &cols);
    // edge
    rows--; cols--;
    int a, b;
    get_int2(&a, &b);
    init_combi(rows+cols);

    int64_t ans = 0;
    // usually, calc_combi(rows-1+cols-1, cols-1)
    int r;
    struct point2d bp = (struct point2d){rows-a, b};
    for(r = 0; r <= bp.row; r++) {
        int64_t res = 1;
        // lefttop
        struct point2d start1 = (struct point2d){0, 0};
        struct point2d end1 = (struct point2d){r, bp.col};
        res = (res * calc_routes(start1, end1));
        // rows-i-i
        // rightbottom: rows-i, cols-b-1
        struct point2d start2;
        if(r == bp.row) {
            start2 = (struct point2d){r, bp.col};
        } else {
            start2 = (struct point2d){r, bp.col+1};
        }
        struct point2d end2 = (struct point2d){rows, cols};
        res = (res * calc_routes(start2, end2))%DIVISOR;
#ifdef DEBUG
        printf("topleft: (%d %d) -> (%d %d)  ",
            start1.row, start1.col,
            end1.row, end1.col
        );
        printf("bottomright: (%d %d) -> (%d %d)",
            start2.row, start2.col,
            end2.row, end2.col
        );
        printf(" -> %lld\n", res);
#endif
        ans = (ans + res)%DIVISOR;
    }
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 3328
n = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)

puts A.join(" ")
for i in 1..n-1
  v = A[i]
  j = i - 1
  while j >= 0 && A[j] > v
    A[j+1] = A[j]
    j = j-1
    A[j+1] = v
  end
  puts A.join(" ")
end

Measured memory_bytes: 8708
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    long double ans;
    double deg=(h*30+0.5*m-6*m);
    long double cs=cosl(deg*M_PI/180);
    ans=((long double)(a*a+b*b))-((long double )2*a*b*cs);
    cout<<setprecision(20)<<sqrt(ans);


}




Measured memory_bytes: 4076
#include<iostream>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
 
int main(){
    int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K; cin>>K;
    cout<<A[K-1]<<endl;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String tmp = br.readLine();
			
			if(tmp == null){
				break;
			}

			String[] tmpArray = tmp.split(" ");
			int a = Integer.parseInt(tmpArray[0]);
			int b = Integer.parseInt(tmpArray[1]);
			
			//??????a???b??\?????????????????????????????????
			if(b > a){
				int tmpInt = b;
				b = a;
				a = tmpInt;
			}
			//?????§??¬?´???°????±???????
			int GCD = 1;
			
			int j = b;
			while(j > 1){
				if(a%j == 0 && b%j == 0){
					GCD *= j;
					a/=j;
					b/=j;
					j = b;
				}
				else {
					j--;
				}
			}
			
			int LCM = GCD * a * b;
			System.out.println(GCD + " "+ LCM);
		}
	}

}

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

int main(){
  int n;
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  int e=0;
  string s;
  int i=0;
  cin >> n;
  
  for( ; i<n;i++){
    cin >> s;
    
    if(s=="P"){
      if(a!=1){
        a=1;
      }
    }
    if(s=="G"){
      if(b!=1){
        b=1;
      }
    }
    if(s=="W"){
      if(c!=1){
        c=1;
      }
    }
    if(s=="Y"){
      if(d!=1){
        d=1;
      }
    }
  }
  e=a+b+c+d;
  if(e==3){
    cout << "Three" << endl;
  }
  if(e==4){
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
#C
N = int(input())
X = list(map(int, input().split()))
ans = 10 ** 12

for i in range(1, max(X)+1):
    tmp_ans = 0
    for xi in X:
        tmp_ans += (xi - i) ** 2
    ans = min(ans, tmp_ans)
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n,i,j,k,t,temp,tc;
    cin>>n;
    //vector<LL> v(n+1);
    LL cnt=0;
    for(i=1;i<=n;i++)
    {
        cin>>j;
        if(i%2==1 && j%2==1)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll d, t, s;
  cin >> d >> t >> s;
  if(d <= t*s){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main(){

    string s,t;
    cin >> s >> t;

    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    if(s < t) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, w;
	cin >> n >> w;
	vector<pair<int, int>> a(n);
	for(auto i = 0; i < n; ++ i){
		cin >> a[i].first >> a[i].second;
	}
	const int mx = 1e5, inf = numeric_limits<int>::max();
	vector<int> dp(mx + 1, inf);
	dp[0] = 0;
	for(auto i = 0; i < n; ++ i){
		for(auto j = mx - a[i].second; j >= 0 ; -- j){
			if(dp[j] != inf && dp[j] + a[i].first <= w){
				ctmin(dp[j + a[i].second], dp[j] + a[i].first);
			}
		}
	}
	for(auto i = mx; i >= 0; -- i){
		if(dp[i] != inf){
			cout << i;
			return 0;
		}
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
    int n,cnt=0;
    cin >> n;
    int a[100] = {};
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i<n; i++) {
        int m = a[i],k=i;
        for (int j = i + 1;j < n;j++) {
            if (m > a[j]) {
                m = a[j];
                k = j;
            }
        }
        if (i != k) {
            swap(a[i], a[k]);
            cnt++;
        }
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; i++){
        if(i % 2){
            a += b /= 2;
        }else{
            b += a /= 2;            
        }
    }
    cout << a << " " << b << "\n";
}

Measured memory_bytes: 256
N = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(N):
    S = input()
    if S == "AC":
        c0 += 1
    elif S == "WA":
        c1 += 1
    elif S == "TLE":
        c2 += 1
    elif S =="RE":
        c3 += 1
print("AC x " +str(c0))
print("WA x " +str(c1))
print("TLE x "+str(c2))
print("RE x "+str(c3))

Measured memory_bytes: 9208
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  for (int a = 1; a < 10; ++a) {
    if (N % a == 0) {
      int b = N / a;
      if (b < 10) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <climits>

int merge(int* A, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	int *L = new int[n1+1];
	for (int i=0; i<n1; i++) L[i] = A[left + i];
	L[n1] = INT_MAX;
	int *R = new int[n2+1];
	for (int i=0; i<n2; i++) R[i] = A[mid + i];
	R[n2] = INT_MAX;
	
	int i = 0, j = 0;
	for (int k=left; k<right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i]; i++;
		} else {
			A[k] = R[j]; j++;
		}
	}
	
	delete[] L;
	delete[] R;
	
	return right - left;
}

int mergeSort(int* A, int left, int right)
{
	int comparisons = 0;
	if (left+1 < right) {
		int mid = (left + right) / 2;
		comparisons += mergeSort(A, left, mid);
		comparisons += mergeSort(A, mid, right);
		comparisons += merge(A, left, mid, right);
	}
	return comparisons;
}

int main()
{
	int n;
	std::cin >> n;
	
	int *S = new int[n];
	for (int i=0; i<n; i++) std::cin >> S[i];
	
	int comparisons = mergeSort(S, 0, n);
	
	std::cout << S[0];
	for (int i=1; i<n; i++) std::cout << " " << S[i];
	std::cout << std::endl;
	std::cout << comparisons << std::endl;
	
	return 0;
}




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

int main(){
    string s;

    cin >> s;

    string a,b;

    a="ABC";
    b="ARC";

    if(s==a){
        cout << b << endl;
    }else{
        cout << a <<endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  int X, Y;
  
  cin >> X >> Y;
  
  if (2 * X <= Y && Y <= 4 * X && (Y & 1) == 0) {
    cout << "Yes" << endl;
  } else {
    cout <<  "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3568
N, M = map(int, input().split())
if M%2 != 0:
    center = M + 1
else:
    center = M
c = center//2
d = (center + 1 + 2*M + 1) // 2

i = 0
while i < c:
    print(c-i, c+1+i)
    i += 1
j = 0
while i < M:
    print(d-(j+1), d+(j+1))
    i += 1
    j += 1

Measured memory_bytes: 9236
#include <iostream>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn];
bool cmp(int a, int b){
    return a > b;
}
signed main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    n--;
    int k = n / 2;
    int ans = 0;
    for(int i = 0; i <= k; ++i){
        ans += (a[i] << 1);
    }
    ans -= a[0];
    if(n % 2 == 0) ans -= a[k];
    cout << ans;
    return 0;
}


Measured memory_bytes: 5120
#![allow(non_snake_case, dead_code)]

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


fn main(){
    // let cin = stdin();
    // let cin = cin.lock();
    // let mut sc = Scanner::new(cin);

    loop {
        // let n: String = sc.read();
        let mut n = String::new();
        stdin().read_line(&mut n).unwrap();
        n = n.replace("\n", "").replace("\r", "");
        if n == "." { break; }
        let mut g = Vec::new();
        let mut fl = true;
        for x in n.chars() {
            if x == '(' || x == '[' {
                g.push(x);
            } else if x == ')' {
                if g.last().unwrap_or(&'$') != &'(' {
                    println!("{}", "no");
                    fl = false;
                    break;
                } else {
                    g.pop();
                }
            } else if x == ']' {
                if g.last().unwrap_or(&'$') != &'[' {
                    println!("{}", "no");
                    fl = false;
                    break;
                } else {
                    g.pop();
                }
            }
        }
        if fl {
            println!("{}", if g.is_empty() {"yes"} else {"no"});
        }
    }
}



Measured memory_bytes: 5040
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    S = input()
    R = ""

    for s in S:
        if s == "B":
            if len(R) >= 1:
                R = R[:-1]
        else:
            R += s
    
    print(R)


main()


Measured memory_bytes: 4692
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN=100005,P=1e9+7;
int n,a[MAXN],ans[MAXN],pos_le,pos_ri,fac[MAXN],fac_inv[MAXN],last_pos[MAXN];

inline int read(){
	char c; int x;
	while(c=getchar(),c<'0' || '9'<c);
	x=c-'0';
	while(c=getchar(),'0'<=c && c<='9')
		x=x*10+c-'0';
	return x;
}

inline void pre_tab(){
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=(long long)fac[i-1]*i%P;
	fac_inv[n]=1;
	for(int i=P-2,tmp=fac[n];i;i>>=1,tmp=(long long)tmp*tmp%P){
		if(i&1) fac_inv[n]=(long long)fac_inv[n]*tmp%P;
	}
	for(int i=n-1;i>=0;--i)
		fac_inv[i]=(long long)fac_inv[i+1]*(i+1)%P;
}

inline int C(int m,int n){
	return (long long)fac[m]*fac_inv[n]%P*fac_inv[m-n]%P;
}

int main(){
	n=read();
	++n;
	pre_tab();
	for(int i=1;i<=n;++i){
		a[i]=read();
		if(last_pos[a[i]]){
			pos_le=last_pos[a[i]];
			pos_ri=i;
		}
		last_pos[a[i]]=i;
	}
	ans[1]=n-1;
	for(int i=2;i<=n;++i){
		ans[i]=C(n,i);
		if(n-pos_ri+pos_le>=i-1)
			ans[i]=(ans[i]-C(n-pos_ri+pos_le-1,i-1)+P)%P;
		//for(int j=max(i-1-n+pos_ri,0);j<=pos_le-1;++j)
			//ans[i]=(ans[i]-(long long)C(pos_le-1,j)*C(n-pos_ri,i-j-1)%P+P)%P;
	}
	for(int i=1;i<=n;++i)
		printf("%d\n",ans[i]);
	return 0;
}

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

int main(void){
    int h, a, count = 0;
    cin >> h >> a;
    
    while(h > 0){
        h -= a;
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
class flower{
public:
    int ht;
    int bt;
};
int main(){
	int n;
	cin>>n;
    flower arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i].ht;
    }
    for(int i=0;i<n;i++){
        cin>>arr[i].bt;
    }
    map<int,long long> mp;
    long long dp[n];
    dp[0] = arr[0].bt;
    mp[arr[0].ht] = arr[0].bt;
    for(int i=1;i<n;i++){
        dp[i] = arr[i].bt;
        auto it = mp.lower_bound(arr[i].ht);
        if(it != mp.begin()){
            it--;
            dp[i] += it->second;
            it++;
        }
        mp[arr[i].ht] = dp[i];
        while(it != mp.end() and it->second <= dp[i]){
            auto curr = it;
            it++;
            mp.erase(curr);
        }
    }
    long long ans = 0;
    for(int i=0;i<n;i++){
        ans = max(ans, dp[i]);
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 15872
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int result = 0;
  if (n == 100000) {
    result = 9 + 999 - 99 + 99999 - 9999;
  } else if (    1 <= n && n <=     9) {
    result = n;
  } else if (   10 <= n && n <=    99) {
    result = 9;
  } else if (  100 <= n && n <=   999) {
    result = 9 + n - 99;
  } else if ( 1000 <= n && n <=  9999) {
    result = 9 + 999 - 99;
  } else if (10000 <= n && n <= 99999) {
    result = 9 + 999 - 99 + n - 9999;
  } else {
    cerr << "unexpected case";
    return 1;
  }
  cout << result << '\n';
  return 0;
}


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

int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int a=0, b=0, c[15]={0};
		int flag = 0;
		int tmp = 0;
		for(int k =0;k<10;k++){
			cin >> c[k];
		}
		for(int k =0;k<10;k++){
			if(c[k]>a){
				if(c[k]>b){
					b=c[k];
				}
				else{
					a=c[k];
				}
			}
			else{
				flag = 1;
				break;
			}	
		}
		if(flag)cout << "NO"<<endl;
		else cout << "YES"<<endl;
		
	}
	
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i = 0;i < n;i++){
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  int c=1;
  int z=1;
  for(int i=1;i<n;i++){
    if (s[i-1]==s[i]){
      z++;
      c=max(c,z);
    }
    else{
      z=1;
    }
  }
  z=1;
  if(n==1){
    cout<<s[0]<<endl;
  }
  else if(c==1){
    for(int i=0;i<n;i++){
    cout<<s[i]<<endl;
    }
  }
  else{
    for(int i=1;i<n;i++){
      if(s[i-1]==s[i]){
        z++;
      }
      else{
        z=1;
      }
      if(c==z){
        cout<<s[i-1]<<endl;
      }
    }
  }
}

Measured memory_bytes: 9552
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ConnectionAndDisconnection | diff ConnectionAndDisconnection.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ConnectionAndDisconnection.cpp && ./a.out

/*
 
 10/5/2019
 
 14:37-
 
 */

string S;
LL K;

void solve() {
  LL N=SZ(S);
  VI xs;
  REP(i,N) {
    if(i==0||S[i-1]!=S[i]) xs.push_back(1);
    else xs.back()++;
  }
  int M=SZ(xs);
  LL res=0;
  if(SZ(xs)==1) res=N*K/2;
  else if(S.front()==S.back()) {
    res=xs.front()/2+xs.back()/2;
    REP(i,M) if(i!=0&&i!=M-1) res+=(LL)xs[i]/2*K;
    res+=((LL)xs.back()+xs.front())/2*(K-1);
  } else {
    REP(i,M) res+=(LL)xs[i]/2*K;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S>>K;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    int X = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();
    Arrays.sort(a);

    long[][] dp = new long[N + 1][X + 1];
    for (int i = 0; i <= X; i++) dp[0][i] = i;
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= X; j++) {
        dp[i][j] = (long)(i - 1) * dp[i - 1][j] % M;
        dp[i][j] += dp[i - 1][j % a[i - 1]];
        dp[i][j] %= M;
      }
    }
    System.out.println(dp[N][X]);
  }
}


Measured memory_bytes: 241620
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
int main()
{
    int n,sum=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)   cin>>a[i];
    for(int i=0;i<n-1;i++)
    {
       for(int j=i+1;j<n;j++)
       {
          sum+=a[i]*a[j];
       }
    }
    cout<<sum;
    nl;
    return 0;
}


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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

int n;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    int x =  800*n;
    int y = 200*(n/15);
    cout<<x-y<<"\n";
}

Measured memory_bytes: 3616
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

typedef long long LL;

int a[70], cnt;
LL f[70][10][2];

LL dfs(int pos, int la, bool limit, bool pre) {
	if (pos == 0) return pre ? 1 : 0;
	if (f[pos][la][pre] != -1 && !limit) return f[pos][la][pre];
	int up = limit ? a[pos] : 9;
	LL res = 0;
	for (int i = 0; i <= up; i++) {
		if (pre&&abs(i - la) >= 2) continue;
		res += dfs(pos - 1, i, i == up && limit, pre | i);
	}
	if (!limit) f[pos][la][pre] = res;
	return res;
}

LL check(LL x) {
	cnt = 0;
	while (x) a[++cnt] = x % 10, x /= 10;
	LL res = 0;
	if (cnt > 1) res += dfs(cnt - 1, 0, false, false);
	for (int i = 1; i <= a[cnt]; i++) res += dfs(cnt - 1, i, i == a[cnt], true);
	return res;
}
int main() {
	memset(f, -1, sizeof f);
	int x;
	cin >> x;
	LL l = 1, r = 3234566667, res;
	while (l <= r) {
		LL mid = (l + r) >> 1;
		if (check(mid) >= x) res = mid, r = mid - 1;
		else l = mid + 1;
	}
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String num = sc.nextLine();
			int[] a = new int[4];
			
			for (int i = 0; i < 4; i++) {
				a[i] = num.charAt(i) - '0';
			}
			
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < 2; j++){
					for (int k = 0; k < 2; k++) {
						StringBuilder sb = new StringBuilder();
						sb.append(a[0]);
						int tmp = a[0];
						if (i == 0) {
							tmp += a[1];
							sb.append("+");
						} else {
							tmp -= a[1];
							sb.append("-");
						}
						sb.append(a[1]);
						if (j == 0) {
							tmp += a[2];
							sb.append("+");
						} else {
							tmp -= a[2];
							sb.append("-");
						}
						sb.append(a[2]);
						if (k == 0) {
							tmp += a[3];
							sb.append("+");
						} else {
							tmp -= a[3];
							sb.append("-");
						}
						sb.append(a[3]);
						
						if (tmp == 7) {
							sb.append("=7");
							System.out.println(sb.toString());
							return;
						}
 					}
				}
			}
		}
	}
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dist[334][334];


int main(void){
	int n,m,i,j,k,a,b,q,s,t;
	ll l,c;
	fill(dist[0],dist[334],INFLL);
	cin >> n >> m >> l;
	for(i=0; i<n; ++i){
		dist[i][i] = 0ll;
	}
	for(i=0; i<m; ++i){
		cin >> a >> b;
		--a; --b;
		cin >> dist[a][b];
		dist[b][a] = dist[a][b];
	}
	for(k=0; k<n; ++k){
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			if(i==j){
				dist[i][j] = 0ll;
			}else if(dist[i][j]>l){
				dist[i][j] = INFLL;
			}else{
				dist[i][j] = 1ll;
			}
		}
	}
	for(k=0; k<n; ++k){
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	cin >> q;
	for(i=0; i<q; ++i){
		cin >> s >> t;
		--s; --t;
		cout << ((dist[s][t]<INFLL)?(dist[s][t]-1ll):(-1ll)) << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll ans[114514];
signed main() {
	string s;
	cin >> s;
	ll memo = 0, m;
	ll p;
	s += 'R';
	ll n = s.size();
	rep(i, n - 1) {
		if (s[i] == s[i + 1] || (s[i] == 'L' && s[i + 1] == 'R'))ans[i] = 0;
		memo++;
		if (s[i] == 'L' && s[i + 1] == 'R') {
			if (memo % 2 == 1 && m % 2 == 0) {
				ans[p] = memo / 2;
				ans[p + 1] = memo / 2 + 1;
			}
			else if (memo % 2 == 0) {
				ans[p] = memo / 2;
				ans[p + 1] = memo / 2;
			}
			else {
				ans[p] = memo / 2 + 1;
				ans[p + 1] = memo / 2;
			}
			memo = 0;
		}
		if (s[i] == 'R' && s[i + 1] == 'L') {
			p = i;
			m = memo;
		}
	}
	rep(i, n - 1)cout << ans[i] << " ";
	ggr
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    long long n;
    cin >> n;
    
    long long ans = 0;
    for (int i = 1;i <= n;i++){
        long long N = n/i;
        ans += i *  (N*(N+1))/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
S = input()
if S == 'KIHBR' or S == 'KIHBRA' or S == 'AKIHBR' or S == 'KIHABR' or S == 'KIHBAR' or S == 'AKIHABR' or S == 'AKIHBAR' or S == 'AKIHBRA' or S == 'KIHABAR' or S == 'KIHABRA' or S == 'KIHBARA' or S == 'AKIHABAR' or S == 'AKIHABRA' or S == 'AKIHBARA' or S == 'KIHABARA' or S == 'AKIHABARA':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

ll N = 2020;
ll bit[2020];
void add(ll a, ll w) {
	a++;
	for (ll x = a; x <= N; x += x & -x) bit[x] += w;
}
ll sum(ll a) {
	a++;
	ll ret = 0;
	for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
 return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(2*n);
	vector<char> c(2*n);
	REP(i,2*n) cin>>c[i]>>a[i];
	REP(i,2*n) a[i]--;
	ll ans=0;
	vector<bool> aprd_w(n,false);
	vector<bool> aprd_b(n,false);
	for(ll i=2*n-1; i>=0; i--) {
		if(c[i]=='W') {
			aprd_w[a[i]]=true;
			REP(j,a[i]) if(aprd_w[j])ans++;
		} else {
			aprd_b[a[i]]=true;
			REP(j,a[i]) if(aprd_b[j])ans++;
		}
	}
	vector<vector<ll>> cnt(n,vector<ll>(n+1,0));
	for(ll i=2*n-1; i>=0; i--) {
		if(c[i]=='W') {
			add(a[i],1);
		} else {
			REP(j,n+1) {
				if(j>0) cnt[a[i]][j]+=sum(j-1);
				if(j<n) cnt[a[i]][j]+=(n-j)-(sum(2019)-cnt[a[i]][j]);
			}
		}
	}
	vector<vector<ll>> dp(n,vector<ll>(n+1,INF));
	REP(i,n) {	// 黒 i の球までを
		REP(j,n+1) { // 白 j より左にいれる
			if(j>0) dp[i][j]=dp[i][j-1];
			if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+cnt[i][j]);
			else dp[i][j]=min(dp[i][j],cnt[i][j]);
		}
	}
	ll tmp=INF*INF;
	REP(i,n+1) tmp=min(tmp,dp[n-1][i]);
	cout<<ans+tmp<<endl;
}


Measured memory_bytes: 62976
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = max({a+b, a-b, a*b});
  cout << ans << endl;

  return 0;
}


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

int main(){
	int K, A, B;
	cin >> K >> A >> B;
	string ans = "NG";
	for(int i=A;i<=B;i++){
		if(i % K == 0) ans = "OK";
	}
	cout << ans << endl;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

double N;
int B[3]={};
double X[334][334][334]={};

double solve(int A_,int B_,int C_){
  if(A_==0 and B_==0 and C_==0) return X[A_][B_][C_]=0;
  if(X[A_][B_][C_]!=0) return X[A_][B_][C_];
  double tmp=(double)1-(double)(N-A_-B_-C_)/N;
  X[A_][B_][C_]=(double)1/tmp;
  if(A_>0) X[A_][B_][C_]+=solve(A_-1,B_,C_)*A_/N/tmp;
  if(B_>0) X[A_][B_][C_]+=solve(A_+1,B_-1,C_)*B_/N/tmp;
  if(C_>0) X[A_][B_][C_]+=solve(A_,B_+1,C_-1)*C_/N/tmp;
  return X[A_][B_][C_];
}

int main(){
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  rep(i,N) B[A[i]-1]++;
  cout<<setprecision(10)<<solve(B[0],B[1],B[2])<<endl;
}

Measured memory_bytes: 262272
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int n=s.size(),ans=0,cnt=0;
    rep(i,n){
        if(s[i]=='A' || s[i]=='C' ||
           s[i]=='G' || s[i]=='T') cnt++;
        else cnt=0;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include<stdio.h>

int main(void){
    int N,n;
    scanf("%d",&N);
    n=N%10;

    if(n==2||n==4||n==5||n==7||n==9){
        printf("hon");
    }
    else if(n==3){
        printf("bon");
    }
    else
    {
        printf("pon");
    }
    return 0;
}

Measured memory_bytes: 1728
#include<cstdio>
#include<cctype>
#include<cstring>
#define max(a,b) (a>b?a:b)
#define reg register
typedef long long ll;
template<typename T>inline T read(){
    reg T x=0;reg short f=1;reg char c=getchar();
    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
    for(;isdigit(c);x=x*10+(c^48),c=getchar());
    return x*f;
}
ll ans,a,b,c;
int main(){
	ans+=(a=read<ll>());ans+=read<ll>();read<ll>();ans+=(b=read<ll>());ans+=(c=read<ll>());read<ll>();read<ll>();
	if(!(((a&1)+(b&1)+(c&1))%3))printf("%lld\n",ans);
	else if(a&&b&&c||((a&1)+(b&1)+(c&1))%3==1)printf("%lld\n",ans-1);
	else printf("%lld\n",ans-2);
    return 0;
}

Measured memory_bytes: 128
import sys


def dfs(i, s, val, formula):
    if (i == len(s) - 1):
        if val == 7:
            print(formula + "=7")
            sys.exit()
            return formula
        else:
            return None

    dfs(i + 1, s, val + int(s[i + 1]), formula + "+" + s[i + 1])
    dfs(i + 1, s, val - int(s[i + 1]), formula + "-" + s[i + 1])
    return None


s = input()
ans = dfs(0, s, int(s[0]), s[0])


Measured memory_bytes: 38732
#include <stdio.h>

int main(void){
        int mem[4][3][10]={0};
        int b,f,r,v,n,i,j,k;

        scanf("%d",&n);

        for(i=0;i<n;i++){
                scanf("%d %d %d %d",&b,&f,&r,&v);
                mem[b-1][f-1][r-1]+=v;
        }
        for(i=0;i<4;i++){
                for(j=0;j<3;j++){
                        for(k=0;k<10;k++)
                                printf(" %d",mem[i][j][k]);
                        putchar('\n');
                }
                if(i<3)
                        puts("####################");
        }
        return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N, K;
   string S;
   cin >> N >> K >> S;
   K = min(K, 15);
   S += string(S.rbegin(), S.rend());
   string ans = S.substr(0, N);
   for (int z = 0; z <= N; ++z) {
      ans = min(ans, S.substr(z, N));
   }
   int cnt = 0;
   while (cnt < N && ans[cnt] == ans[0]) cnt++;
   string head = ans.substr(0, cnt);
   string tail = ans.substr(cnt);
   for (int z = 0; z < K - 1; ++z) {
      head += head;
      if (head.size() > N) {
         head.resize(N);
      }
   }
   ans = head + tail;
   ans.resize(N);
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long n,m,k=0;
  cin>>n>>m;
  long long a,b,l=0,r=1001001000;
  for(int i=1;i<=m;i++){
    cin>>a>>b;
    l=max(l,a);
    r=min(r,b);
  }
  cout<<max(r-l+1,k)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,k;
  cin>>k>>a>>b;
  int ans=a,max=0;
  REP(i,a,b+1){
    if(i%k==0){
      cout<<"OK"<<'\n';
      return(0);
    }
  }
  cout<<"NG"<<'\n';
  return(0);
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	int n;
	cin >> n;
	vi a(n);
	for (int x = 0; x < n; x++) {
		cin >> a[x];
	}
	sort (allof(a));
	bool s[1000005] = {0};
	for (int x = 0; x < n; x++) {
		if ((x==0||a[x-1]!=a[x])&&!s[a[x]]) {
			for (int i = a[x]*2; i <= 1000000; i += a[x]) {
				s[i] = true;
			}
		}
	}
	int ans = 0;
	for (int x = 0; x < n; x++) {
		if (!s[a[x]]) {
			if ((x==0||a[x]!=a[x-1])&&(x==n-1||a[x+1]!=a[x])) {
				ans++;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4676
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, mx = -1, u[N], v[N];
char s[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%s",s + 1);
	n = strlen(s + 1);

	for(int i = 1; i <= n; i++)
		u[s[i] - 'a']++;

	if(n == 26){
		for(int i = n; i >= 1; i--){
			mx = 31;
			for(int j = i + 1; j <= n; j++)
				if(s[j] > s[i])
					mx = min(mx, s[j] - 'a');
			if(mx == 31)
				continue;
			s[i] = mx + 'a';
			s[i + 1] = '\0';
			printf("%s\n", s + 1);
			return 0;
		}
		puts("-1");
		return 0;
	}
	printf("%s", s + 1);
	for(int i = 0; i < 26; i++)
		if(!u[i]){
			printf("%c\n", i + 'a');
			break;
		}
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <chrono>
#include <numeric>

using namespace std;


int main(){
  int r, g;
  cin >> r;
  cin >> g;
  cout << 2*g - r << endl;
}


Measured memory_bytes: 256
// Iterative Deepening
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle { int f[N2], space, MD; };

Puzzle state;
int limit;  /* 深さの制限 */
int path[LIMIT];

int getAllMD(Puzzle pz) {
  int sum = 0;
  for ( int i = 0; i < N2; i++ ) {
    if ( pz.f[i] == N2 ) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

bool isSolved() {
  for ( int i = 0; i < N2; i++ ) if ( state.f[i] != i + 1 ) return false;
  return true;
}


bool dfs(int depth, int prev) {
  if ( state.MD == 0 ) return true;
  /* 現在の深さにヒューリスティックを足して制限を超えたら枝を刈る */
  if ( depth + state.MD > limit ) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for ( int r = 0; r < 4; r++ ) {
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
    if ( max(prev, r)-min(prev, r) == 2 ) continue;
    tmp = state;
    /* マンハッタン距離の差分を計算しつつ、ピースをスワップ */
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if ( dfs(depth + 1, r) ) { path[depth] = r; return true; }
    state = tmp;
  }

  return false;
}

/* 反復深化 */
string iterative_deepening(Puzzle in) {
  in.MD = getAllMD(in);  /* 初期状態のマンハッタン距離 */

  for ( limit = in.MD; limit <= LIMIT; limit++ ) {
    state = in;
    if ( dfs(0, -100) ) {
      string ans = "";
      for ( int i = 0; i < limit; i++ ) ans += dir[path[i]];
      return ans;
    }
  }

  return "unsolvable";
}

int main() {
  for ( int i = 0; i < N2; i++ )
    for ( int j = 0; j < N2; j++ )
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

  Puzzle in;

  for ( int i = 0; i < N2; i++ ) {
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterative_deepening(in);
  cout << ans.size() << endl;

  return 0;
}


Measured memory_bytes: 3196
r, c = map(int, input().split(' '))
sheet = [[0 for col in range(c+1)] for row in range(r+1)]
for row in range(r):
    l = list(map(int, input().split(' ')))
    for col in range(c):
        sheet[row][col] = l[col]
    
for row in range(r):
    for col in range(c):
        sheet[row][c] += sheet[row][col]
        
for col in range(c):
    for row in range(r):
        sheet[r][col] += sheet[row][col]
    
for row in range(r):
    for col in range(c):
        sheet[r][c] += sheet[row][col]

for l in sheet:
    l = list(map(str, l))
    print(' '.join(l))
    
    
    
    
    
    


Measured memory_bytes: 5692