akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
using namespace std;

int main(){
    int n,taro_point=0,hanako_point=0,j;
    char taro_card[101],hanako_card[101];
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        scanf("%s %s",taro_card,hanako_card);
        for(j=0; taro_card[j]!='\0' && hanako_card[j]!='\0' && taro_card[j]==hanako_card[j]; j++);
            if(taro_card[j]=='\0'){
                if(hanako_card[j]=='\0'){
                    taro_point += 1;
                    hanako_point += 1;
                }else{
                    hanako_point += 3;
                }
            }else if(hanako_card[j]=='\0'){
                taro_point += 3;
            }else if(hanako_card[j]>taro_card[j]){
                hanako_point += 3;
            }else{
                taro_point += 3;
            }
    }
    printf("%d %d\n",taro_point, hanako_point);
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	ll A,B,cnt=0;
	cin>>A>>B;
	while(1){
		if(A<=B){
			cnt++; A*=2;
		}else break;
	}	
	print(cnt);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int a;
    std::cin >> a;

    if(a < 1200) {
      std::cout << "ABC" << '\n';
    }else if(a < 2800) {
      std::cout << "ARC" << '\n';
    }else {
      std::cout << "AGC" << '\n';
    }

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int solve(int, int*, int);

int main() {
    int i, j, n, m;
    int a[2000];
    int cnt = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    scanf("%d", &m);
    for(i = 0; i < m; i++) {
        scanf("%d", &j);
        printf("%s\n", solve(j, a, n) ? "yes" : "no");
    }

    return 0;
}

int solve(int n, int* arr, int m) {
    if (m == 0) return 0;
    if (n == arr[0]) return 1;
    if (n < arr[0]) return solve(n, arr+1, m-1);
    return solve(n-arr[0], arr+1, m-1) || solve(n, arr+1, m-1);
}



Measured memory_bytes: 2048
"use strict";
    
const main = arg => {
    const times = arg.split("\n")[0].split(" ");
    
    const start = Math.max(times[0], times[2]);
    const end   = Math.min(times[1], times[3]);
    
    console.log(end - start > 0 ? end - start : 0);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int n;cin>>n;
  vector<ll> cnt(1e5+1,0);
  ll ans=0;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    ans+=a;
    cnt[a]++;
  }
  int q;cin>>q;
  for(int i=0;i<q;i++){
    ll b,c;cin>>b>>c;
    ans-=b*cnt[b];
    ans+=c*cnt[b];
    cnt[c]+=cnt[b];
    cnt[b]=0;
    cout<<ans<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 4064
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var n = Number(lines.shift());
    var tmp = lines.shift().split(" ");

    var t = Number(tmp[0]);
    var a = Number(tmp[1]);
    var result = {
        i: 0,
        temp: Infinity,
    };
    
    tmp = lines.shift().split(" ");
    for (var i = 0; i < n; i++) {
        //console.log(Math.abs(a - (12 - Number(tmp[i])* 0.006)));
        if (Math.abs(a - (t - Number(tmp[i]) * 0.006)) < result.temp) {
            result.i = i;
            result.temp = Math.abs(a - (t - Number(tmp[i]) * 0.006));
        }
    }

    console.log(result.i+1);

});

Measured memory_bytes: 7756
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s, t;
	bool f = false;
	cin >> s >> t;
	for(int i = s.size() - 1; i >= t.size() - 1; i--){
		for(int j = 0; j < t.size(); j++){
			if(s[i - j] == '?' || s[i - j] == t[t.size() - 1 - j]){
				if(j == t.size() - 1){
					f = true;
					for(int k = 0; k < t.size(); k++){
						s[i - k] = t[t.size() - 1 - k];
					}
				}
			}else{
				break;
			}
		}
		if(f) break;
	}
	if(f){
		for(int i = 0; i < s.size(); i++){
			if(s[i] == '?'){
				s[i] = 'a';
			}
		}
		cout << s << endl;
	}else{
		cout << "UNRESTORABLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_152_d
{

        /// <summary>
        /// https://atcoder.jp/contests/abc152/tasks/abc152_d
        /// </summary>
#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            var N = Int32.Parse(Console.ReadLine());

            // 先頭 i 末尾 j の 数値の数を数える
            // c[i,j] に 発見したものを加算する
            int[,] c = new int[10,10];
            for(int i=1;i<=N;i++)
            {
                int n1 = GetN1(i);
                int n2 = i % 10;
                if (n2 != 0)
                {
                    c[n1, n2]++;
                }
            }

            // 先頭が i 末尾 j (c[i,j] )
            // 先頭が j 末尾 i (c[j,i] ) の 組み合わせ数を
            // 全て加算する

            int ans = 0;
            for(int i=1;i<=9;i++)
            {
                for(int j=1;j<=9;j++)
                {
                    ans += c[i, j] * c[j, i];
                }
            }

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

        /// <summary>
        /// 先頭の1ケタの数字を取得する 1から9 を返す
        /// </summary>
        /// <param name="i"></param>
        /// <returns></returns>
        private static int GetN1(int i)
        {
            int n1 = i;
            while (n1 >= 10) n1 = n1 / 10;
            return n1;
        }
#if TEST
#else
    }
}
#endif

Measured memory_bytes: 11092
import java.util.*;

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

        char a = sc.next().charAt(0);
        char b = sc.next().charAt(0);
        char c = sc.next().charAt(0); 
    
    //char型を文字列として出力する際は「 "" + 」を記述する。
    System.out.println("" + a + b + c);
    }
}

Measured memory_bytes: 21716
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(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 kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n,m=map(int,input().split())
    ans=0
    if n==0:
        ans=cmb(m,2)
    elif n==1 and m==1:
        ans=0
    elif n==1 and m>=2:
        ans=cmb(m,2)
    elif n>=2 and m<=1:
        ans=cmb(n,2)
    elif n>=2 and m>=2:
        ans=cmb(n,2)+cmb(m,2)
    print(ans)


if __name__ == "__main__":

    main()

Measured memory_bytes: 38384
def tri(q):
    x = q/2
    while(abs(x**3-q) >= 0.00001*q):
        x = x - (x**3-q)/(3*x**2)
    return x

while(1):
    n = int(input())
    if n == -1:
        break
    print("{:.6f}".format(tri(n)))


Measured memory_bytes: 5664
import sys
readline=sys.stdin.buffer.readline
 
S=readline().rstrip().decode("utf-8")
K=int(readline())
N=len(S)
#print("SK:",S*K)
 
if len(set(S))==1:
  answer=N*K//2
else:
  P=[0] #point
  C=[] #continuous
  S=S+"X"
  
  for i in range(N):
    if S[i]!=S[i+1]:
      P.append(i+1)
  for i in range(len(P)-1):
    C.append(P[i+1]-P[i])
  #print("C:",C)
    
  S=S[0:-1]
  answer=0
  if S[0]==S[-1]:
    for i in range(1,len(C)-1):
      answer+=C[i]//2
    answer*=K
    answer+=C[0]//2+C[-1]//2+((C[0]+C[-1])//2)*(K-1)
  else:
    for c in C:
      answer+=c//2
    answer*=K
print(answer)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 500000 + 5;
const int M = 100000 + 5;

int n, m, idx;
map<int, int> mp[M];
std::vector<int> v[N], w[N];
int p[N], q[N], c[N];
int d[N], inq[N];
queue<int> Q;

void add(int x, int y, int z) {
	v[x].push_back(y);
	w[x].push_back(z);
}

void SPFA() {
	for (int i = 1; i <= idx; i++) d[i] = INF;
	d[1] = 0; Q.push(1); inq[1] = 1;
	while (!Q.empty()) {
		int x = Q.front(); Q.pop(); inq[x] = 0;
		for (int i = 0; i < v[x].size(); i++) {
			int y = v[x][i];
			if (d[x] + w[x][i] < d[y]) {
				d[y] = d[x] + w[x][i];
				if (!inq[y]) {
					inq[y] = 1;
					Q.push(y);
				}
			}
		}
	}
}

int main() {
	read(n), read(m);
	for (int i = 1; i <= m; i++) read(p[i]), read(q[i]), read(c[i]);
	idx = n;
	for (int i = 1; i <= m; i++) {
		if (!mp[p[i]][c[i]]) {
			mp[p[i]][c[i]] = ++idx;
			add(p[i], idx, 1);
			add(idx, p[i], 0);
		}
		if (!mp[q[i]][c[i]]) {
			mp[q[i]][c[i]] = ++idx;
			add(q[i], idx, 1);
			add(idx, q[i], 0);
		}
	}
	for (int i = 1; i <= m; i++) {
		int x = mp[p[i]][c[i]], y = mp[q[i]][c[i]];
		add(x, y, 0), add(y, x, 0);
	}
	SPFA();
	printf("%d\n", d[n] == INF ? -1 : d[n]);
	return 0;
}

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

sum_dA = abs(A[0]) + abs(A[N-1])

for i in range(N-1):
    sum_dA += abs(A[i] - A[i+1])

A.append(0)
A.insert(0, 0)

for i in range(1, N+1):
    ans = sum_dA
    if (A[i-1] - A[i]) * (A[i] - A[i+1]) < 0:
        ans = ans - 2 * min(abs(A[i]-A[i-1]), abs(A[i]-A[i+1]))
    print(ans)

Measured memory_bytes: 14172
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    string s;
    cin>>s;
    if(s.size()==6 && s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int loop = B + 1 - A;
  int Pn;
  for (int i = 0; i < loop; i++){
    int N = A + i;
    int a = N / 10000;
    int b = N / 1000 % 10;
    int c = N / 100 % 10;
    int d = N / 10 % 10;
    int e = N % 10;
    if (a == e && b == d){
      Pn++;
    }
  }
  cout << Pn << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String S[] = new String[N];
		Map<String, Integer> map = new HashMap<String, Integer>();
		for(int i = 0; i < N; i++) {
			S[i] = sc.next();
			map.put(S[i], 1);
		}
		System.out.println(map.size());
	}
}


Measured memory_bytes: 77764
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv
comb = Combination(10**6)
x,y = inpl()
if (x+y)%3 or max(x,y) > min(x,y)*2:
    print(0)
    quit()
n = (x+y)//3
c = comb(n,x-n)
print(c)

Measured memory_bytes: 138388
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
long long A, B, N;

long long func(long long x)
{
    return (A * x) / B - A * (x / B);
}

int main()
{
    cin >> A >> B >> N;
    long long m = B <= N ? B - 1 : N;
    cout << func(m) << endl;
    return 0;
}


Measured memory_bytes: 3624
class Array
  def minus(other)
    a = self.dup
    other.each do |i|
      d = false
      a = a.reject{|j| i==j && !d ? d=true : false } 
    end
    a
  end
end

def c(a)
  return false if (1..9).any?{|i| a.count(i)>4 }
  return a.uniq.size==1 if a.size==2
  parts = (1..7).map{|i| [i,i+1,i+2] } +
          (1..9).map{|i| [i,i  ,i  ] }
  parts.each do |i|
    if a.size - (a.minus(i)).size == 3
      return true if c(a.minus(i))
    end
  end
  return false
end

readlines.each do |l|
  a = l.chomp.chars.map(&:to_i)
  r = (1..9).select{|i| c(a+[i])}
  puts r.empty? ? 0 : r * " "
end

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

int main() {
  int N,K,X;
  cin>>N>>K;
  X=1;
  for(int i=0;i<N;i++){
    if(K<X){
      X+=K;
    }
    else{
      X*=2;
    }
  }
  cout<<X<<endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        mut v: [i64; n]
    }
    let d = 1000000007;
    let mut stair: Vec<i64> = (0..n as i64).collect();
    stair[0] = 1;
    for i in 1..n {
        stair[i] = stair[i - 1] * stair[i] % d;
    }
    let stair_i: Vec<i64> = stair.iter().cloned().map(|x| inv_m(x, d)).collect();
    v.sort();
    let mut smax = 0;
    let mut smin = 0;
    for i in 0..n {
        if i >= k - 1 {
            smax = (smax + stair[i] * stair_i[k - 1] % d * stair_i[i + 1 - k] % d * v[i] % d) % d;
        }
        if i + k <= n {
            smin = (smin + stair[n - i - 1] * stair_i[k - 1] % d * stair_i[n - k - i] % d * v[i] % d) % d;
        }
    }
    println!("{}", (smax + d - smin) % d);
}

fn pow_m(n: i64, mut p: i64, d: i64) -> i64 {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: i64, d: i64) -> i64 {
    pow_m(n, d - 2, d)
}


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

using namespace std;

typedef long long int ll;

#define mod (int ) (1e9+7)


 
 ll ncr(ll x, ll y){
 	ll ans=1;
 	
 	y=(y > x-y? x-y: y);
 	
 	for(ll i=0; i<y; i++){
 		ans=ans*(x-i);
 		ans=ans/(i+1);
 		ans=ans%mod;
 	}
 
 	
 	return ans;
 }

ll power(ll x, ll y){
    ll ans=1;
    while(y){
        if(y&1){
            ans=ans*x;
            ans=ans%mod;
        }
        
        x=x*x;
        x=x%mod;
        y=y>>1;
    }
    
    return ans;
    
}
 
void solve(){

 string s; cin>>s;
 
 ll ans=0,count=0;
 
 for(int i=0; i<s.size(); i++){
 	if(s[i]=='R'){
 		count++;
 	}else{
 		ans=max(ans,count);
 		count=0;
 	}
 }
 
 ans=max(ans,count);
 
 cout<<ans<<"\n";

    return ;
	
}

int main(){
    ios_base::sync_with_stdio(0);
    
    cin.tie(0);
    
    int t=1; //cin>>t; 
    
   
    
    // clock_t begin, end;
    
    // double time_spent;
    
    // begin = clock(); // Time taken till now.
    
    
    while(t--){
    	
	  solve();
        
    }
   
   //end= clock(); // Total  Time taken till now.
   
   //time_spent= (end- begin) / CLOCKS_PER_SEC;
   
   //cout<<time_spent<<"\n";
	
	return 0;
}

Measured memory_bytes: 3652
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

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

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

	int n, d ;
    cin >> n >> d;
    
    int counter = 0 , r = 0;
    while(r<n){
        r += 2*d + 1;
        counter++;
    }
    
    cout << counter << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


ll dp[51][51][51*51];

int main(void){
    int N, A; cin >> N >> A;
    vector<int> x(N+1);
    for(int i=1; i<=N; i++) cin >> x[i];

    dp[0][0][0] = 1;

    for(int j=0; j<=N; j++){
        for(int k=0; k<=N; k++){
            for(int s=0; s<=50*50+1; s++){
                if(j>=1 && x[j]>s) dp[j][k][s] = dp[j-1][k][s];
                if(j>=1 && k>=1 && s>=x[j]) dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
            }
        }
    }


    ll ans = 0;
    for(int k=1; k<=N; k++){
        ans += dp[N][k][k*A];
    }
    cout << ans << endl;
}

Measured memory_bytes: 52096
#include <bits/stdc++.h>
#define ld long double
#define fr first
#define se second
#define pb push_back
using namespace std;
long long a , b;
string s , s1;
int main(){
    ios_base::sync_with_stdio( false );
    cin >> a >> b;
     for( int i= 0 ;i < a;i ++ ){
     s+=to_string(b);
     }
    for( int i= 0 ;i < b;i ++ ){
     s1+=to_string(a);
     }
     cout << min( s , s1 ) ;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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



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

    int N;cin >> N;
    vector<long long> retu(N);
    long long now = 1000;
    long long kabu = 0;
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    for(int i = 0;i<N-1;i++){
        if(retu.at(i) < retu.at(i+1)){
            //買う
            kabu += now/retu.at(i);
            now = now%retu.at(i);
            
            //売る
            now += kabu*retu.at(i+1);
            kabu = 0;
        }
        //cout << now << " " << kabu << endl;
    }
    cout << now << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,i,j,n,m,k,ans,cnt=0,sum=0,c=0,b=0,w=1;
    string s,s1,s2,tmp;
    cin>>s;
    k=s.size();
    for(i=0;i<k;i++){
        if(s[i]=='B')b++;
        else if(s[i]=='W'&& b>0)
        {
            c=c+b;
        }
    }
    cout<<c<<endl;
    return 0;
}



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

int main()
{
	double avg=0;
	int n, result, sum = 0;
	cin >> n;
	int* p = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
		avg += p[i];
	}
	avg /= n;
	if (2 * avg >= 2 * (int)avg + 1) result = avg + 1;
	else result = avg;

	for (int i = 0; i < n; i++)
	{
		sum += pow(p[i] - result, 2);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string b;
int a,c;
double d;
stringstream ss;
int main(){
    cin>>a>>b;
    ss<<b;
    ss>>c;
    d=sqrt(a*pow(10,b.length())+c);
    if(d-(int)d==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int  A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B<C+D)
  cout<<"Right"<<endl;
  else if(A+B==C+D)
  cout<<"Balanced"<<endl;
  else if(A+B>C+D)
  cout<<"Left"<<endl;
   }

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2 ** 20)

class Node():
    def __init__(self, parent=-1, left=-1, right=-1):
        '''
        :param parent: parent node
        :param left: left child
        :param right: right child
        '''
        self.parent = parent
        self.left = left
        self.right = right

    def __repr__(self):
        return '<Node object: parent={}, left={}, right={}>' .format(self.parent, self.left, self.right)


n = int(input())
# initialize tree
T = [Node() for _ in range(n)]
for i in range(n):
    idx, left, right = map(int, input().split())
    T[idx].left = left
    T[idx].right = right

    # set children's parent if Node idx is not leaf
    if left != -1:
        T[left].parent = idx
    if right != -1:
        T[right].parent = idx


def preParse(u):
    if u == -1:
        return
    print(f' {u}', end='')
    preParse(T[u].left)
    preParse(T[u].right)

def inParse(u):
    if u == -1:
        return
    inParse(T[u].left)
    print(f' {u}', end='')
    inParse(T[u].right)

def postParse(u):
    if u == -1:
        return
    postParse(T[u].left)
    postParse(T[u].right)
    print(f' {u}', end='')


for i in range(n):
    if T[i].parent == -1:
        print('Preorder')
        preParse(i)
        print()
        print('Inorder')
        inParse(i)
        print()
        print('Postorder')
        postParse(i)
        print()
        break


Measured memory_bytes: 5648
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    S = input(str)

    if len(S) == 2 and S[0] == S[1]:
        print("1 2")
        return
    for n in range(2, len(S)):
        if S[n - 2] == S[n - 1] or S[n - 2] == S[n] or S[n - 1] == S[n]:
            print(n - 1, n + 1)
            break
    else:
        print(-1, -1)
    return

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

template < uint_fast64_t MOD = 1000000007, uint_fast64_t base = 9973 >
class RollingHash {
public:
        using u64 = uint_fast64_t;
        using i32 = int_fast32_t;
        RollingHash() {}

        RollingHash(const string &s) {
                i32 n = s.size();
                hash.assign(n + 1, 0);
                power.assign(n + 1, 1);
                for ( i32 i = 0; i < n; i++ ) {
                        hash[i + 1] = (hash[i] * base + s[i]) % MOD;
                        power[i + 1] = power[i] * base % MOD;
                }
        }

        //[l, r)
        u64 get(i32 l, i32 n) {
                u64 value = hash[l + n] + MOD - hash[l] * power[n] % MOD;
                return ( value - (value >= MOD ? MOD : 0) );
        }

private:
        vector < u64 > hash, power;
};

template < uint_fast64_t MOD = 1000000007, uint_fast64_t base1 = 2009, uint_fast64_t base2 = 9973 >
class RollingHash2D {
public:
        using u64 = uint_fast64_t;
        using i32 = int_fast32_t;

        RollingHash2D () {}
        
        RollingHash2D(const vector < string > &D, i32 R, i32 C) : row(R), col(C) {
                i32 H = D.size(), W = D[0].size();
                vector < RollingHash < MOD, base2 > > data;

                hash.assign(H - R + 1, vector < u64 >(W - C + 1, 0));
                for ( const string &s : D ) data.emplace_back(s);

                for ( i32 j = 0; j < W - C + 1; j++ ) {
                        vector < u64 > hh(H + 1, 0);
                        vector < u64 > power(H + 1, 1);
                        for ( i32 i = 0; i < H; i++ ) {
                                hh[i + 1] = (hh[i] * base1 + data[i].get(j, C)) % MOD;
                                power[i + 1] = power[i] * base1 % MOD;
                        }
                        for ( i32 i = 0; i < H - R + 1; i++ ) {
                                hash[i][j] = hh[i + R] + MOD - hh[i] * power[R] % MOD;
                                if ( hash[i][j] >= MOD ) hash[i][j] -= MOD;
                        }
                }
        }
        u64 get(i32 y, i32 x) { return ( hash[y][x] ); }
        
private:
        vector < vector < u64 > > hash;
        i32 row, col;
};


int main()
{
        constexpr int mod = 1000000007, base1 = 2009, base2 = 9973;
        int H, W, R, C;
                        
        cin >> H >> W;
        vector < string > S(H);
        for ( string &s : S ) cin >> s;
        cin >> R >> C;
        vector < string > T(R);
        for ( string &t : T ) cin >> t;
        
        RollingHash2D < mod, base1, base2 > r1(S, R, C);
        RollingHash2D < mod, base1, base2 > r2(T, R, C);
        
        uint_fast64_t b = r2.get(0, 0);
        for ( int i = 0; i < H - R + 1; i++ ) {
                for ( int j = 0; j < W - C + 1; j++ ) {
                        if ( r1.get(i, j) == b ) cout << i << " " << j << endl;
                }
        }
        return ( 0 );
}


Measured memory_bytes: 27292
def gcd(a, b) :
  if a % b == 0 :
    return b
  
  return gcd(b, a%b)

K = int(input())
ans = 0

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans += gcd(gcd(a,b) , c)

print(ans)

Measured memory_bytes: 80296
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <complex>
#include <bitset>
 
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()

using namespace std;

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

int main() {
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    

    string s;
    cin >> s;
    vector<int> cnt(3);
    for (int i = 0; i < sz(s); ++i) {
        ++cnt[s[i] - 'a'];
    }
    sort(all(cnt));
    cout << (cnt[2] - cnt[0] <= 1 ? "YES\n" : "NO\n");
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if (A == B && B == C)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>

using namespace std;

const int kNil = -1;
const int kMaxV = 100010;

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

template <class Edge>
decltype(auto) Dijkstra(const vector<Edge> & edges,
                 typename vector<Edge>::size_type node_num,
                 typename vector<Edge>::size_type source) {
  using size_type = typename vector<Edge>::size_type;
  using w_type = typename Edge::w_type;

  const w_type kInf = numeric_limits<w_type>::max();

  bitset<kMaxV> bs;
  vector<vector<Edge>> adjacency_list(node_num, vector<Edge>());
  for (const auto & e: edges) {
    adjacency_list[e.u].push_back(e);
  }
  vector<w_type> dist(node_num, kInf);
  vector<int> parent(node_num, kNil);
  dist[source] = 0;

  using Pair = pair<size_type, w_type>;
  auto compare = [](const Pair & x, const Pair & y) {
    return y.second < x.second || (!(x.second < y.second) && y.first < x.first);
  };
  priority_queue<Pair, vector<Pair>, decltype(compare)> que(compare);
  que.emplace(source, 0);

  while (!que.empty()) {
    auto top_no = que.top().first;
    auto top_dist = que.top().second;
    que.pop();
    bs.set(top_no);
    for (const auto & e: adjacency_list[top_no]) {
      const auto cost = dist[e.u] + e.w;
      if (dist[e.v] > cost && !bs.test(e.v)) {
        dist[e.v] = cost;
        parent[e.v] = e.u;
        que.emplace(e.v, cost);
      }
    }
  }

  return dist;
}

int main(int argc, char const *argv[]) {
  using w_type = unsigned;

  const w_type kInf = numeric_limits<w_type>::max();

  vector<Edge<w_type>> edges;
  unsigned V, E, r;
  cin >> V >> E >> r;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    w_type w;
    cin >> u >> v >> w;
    edges.emplace_back(u, v, w);
  }

  auto dist = Dijkstra(edges, V, r);
  for (unsigned i = 0; i < V; ++i) {
    if (dist[i] == kInf) {
      cout << "INF\n";
    } else {
      cout << dist[i] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 23436
#include <stdio.h>
#include <math.h>

int count[3][1001];
int data[1000][3];

int main() {
	int N,i,j,k;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		for (j = 0; j < 3; j++) {
			scanf("%d", &k);
			data[i][j] = k;
			count[j][k]++;
		}
	}
	for (i = 0; i < N; i++) {
		int sum = 0;
		for (j = 0; j < 3; j++) {
			if (count[j][data[i][j]] == 1) sum += data[i][j];
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 2724
#include <cstdio>
#include <set>

using namespace std;

set <int> s[200000];

int main() {
    int n, m, i;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        s[x].insert(y);
        s[y].insert(x);
    }
    
    for (i = 1; i < n - 1; i++) {
        if (s[i].count(0) && s[i].count(n - 1)) {
            puts("POSSIBLE");
            
            return 0;
        }
    }
    
    puts("IMPOSSIBLE");
    
    return 0;
}


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

int ord2(int n) {
    int sum = 0;
    while (n > 0) { sum += n/2; n /= 2; }
    return sum;
}

// nCk mod 2
int comb(int n, int k) {
    if (k == 0 || n == k) return 1;
    return ord2(n) == ord2(k) + ord2(n-k) ? 1 : 0;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int a[n];
    for (int i = 0; i < n; i++) a[i] = s[i] - '1';
    int cnt[3] = {};
    for (int b : a) cnt[b]++;
    if (cnt[1] == 0) {
        int sum = 0;
        for (int i = 0; i < n; i++)
            if (a[i] == 2) sum += comb(n-1, i);
        cout << sum % 2 * 2 << endl;
        return 0;
    }
    int sum = 0;
    for (int i = 0; i < n; i++)
        if (a[i] % 2) sum += comb(n-1, i);
    cout << sum % 2 << endl;
}


Measured memory_bytes: 5380
N,M=map(int,input().split())
xyz=[]
for i in range(N):
    x,y,z=map(int,input().split())
    xyz.append([x,y,z])
ans=0
for k in range(8):
    A=[k>>2 &1,k>>1 &1,k>>0 &1]
    l=[]
    for i in range(N):
        t=0
        for j in range(3):
            if A[j]==0:
                t+=xyz[i][j]
            else:
                t-=xyz[i][j]
        l.append(t)
    l.sort(reverse=True)
    ans=max(ans,sum(l[:M]))
print(ans)


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

int main()
{
  long long ntown, k;
  cin >> ntown >> k;
  vector<int> to(ntown);
  for (int i = 0; i < ntown; i++) {
    int id;
    cin >> id;
    id--;
    to.at(i) = id;
  }
  vector<int> step(ntown, -1);
  int next_town = 0;
  int before_loop = 0;
  int loop_len = 0;
  int loop_start = 0;
  for (int i = 0; i < ntown; i++) {
    if (step.at(next_town) != -1) {
      before_loop = step.at(next_town);
      loop_len = i - step.at(next_town);
      loop_start = next_town;
      break;
    }
    step.at(next_town) = i;
    next_town = to.at(next_town);
  }
  if (k < before_loop) {
    int tmp = 0;
    for (int i = 0; i < k; i++) {
      tmp = to.at(tmp);
    }
    cout << tmp+1 << '\n';
  } else {
    k = (k - before_loop) % loop_len;
    int tmp = loop_start;
    for (int i = 0; i < k; i++) {
      tmp = to.at(tmp);
    }
    cout << tmp+1 << '\n';
  }
  return 0;
}


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

int main() {
  string A;
  cin >> A;
 
  if(A=="Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(A=="Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
	cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        double ans = 0;
        for (int i = 0; i < n; ++i) {
            int t = in.nextInt();
            ans += 1.0 / t;
        }
        System.out.println(1.0 / ans);
    }
}


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

int main()
{
    int A, B, C, X, count = 0;
    cin >> A >> B >> C >> X;
    for (int i = 0; i <= A; i++)
    {
        for (int j = 0; j <= B; j++)
        {
            for (int k = 0; k <= C; k++)
            {
                if ((500 * i + 100 * j + 50 * k) == X)
                {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

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

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

    int mini;
    mini = n/(max(h,w));

    if((n%(max(h,w))) == 0)
        printf("%d\n",mini);
    else
        printf("%d\n",mini+1);

}


Measured memory_bytes: 256
from decimal import Decimal, getcontext
import math
n = input().split()

def cal(a,b):
  if '.' in list(a):
    c = Decimal(a)
  else:
    c = int(a)
  
  if '.' in list(b):
    d = Decimal(b)
  else:
    d = int(b)
    
  return c*d


print(math.floor(cal(n[0],n[1])))

Measured memory_bytes: 10076
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final long N = sc.nextInt();

    		System.out.println(N*(N-1)/2);

    	} finally {
    		sc.close();
    	}
    }
}



Measured memory_bytes: 21844
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn dp(n: usize, x: usize, l: &[usize], p: &[usize]) -> usize {
    if n == 0 {
        return 1;
    }
    if x == 1 {
        0
    } else if x <= 1 + l[n - 1] {
        dp(n - 1, x - 1, l, p)
    } else if x == 2 + l[n - 1] {
        1 + p[n - 1]
    } else if x <= 2 + 2 * l[n - 1] {
        1 + p[n - 1] + dp(n - 1, x - 2 - l[n - 1], l, p)
    } else {
        1 + 2 * p[n - 1]
    }
}

fn main() {
    input! {
        n: usize,
        x: usize,
    }

    let mut l = vec![1; n + 1];
    let mut p = vec![1; n + 1];
    for i in 1..=n {
        l[i] = 2 * l[i - 1] + 3;
        p[i] = 2 * p[i - 1] + 1;
    }

    println!("{}", dp(n, x, &l, &p));
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
bool vis[1001][1001];
int d[1001][1001];
int cx,cy,dx,dy,h,w;
int main(){
	cin>>h>>w>>cx>>cy>>dx>>dy;
	string s[h+1];
	for(int i=1;i<=h;i++){
		cin>>s[i];
	}
	deque<pair<int,int> > q;
	q.push_back(make_pair(cx,cy));
	for(int i=1;i<=h;i++){
		fill(vis[i]+1,vis[i]+w+1,false);
		fill(d[i]+1,d[i]+w+1,1000001);
	}
	d[cx][cy]=0;
	vis[cx][cy]=true;
	while(!q.empty()){
		pair<int,int> k=q.front();
		q.pop_front();
		int x=k.first;
		int y=k.second;
		if(x==dx && y==dy){
			cout<<d[x][y]<<endl;
			return 0;
		}
		for(int i=-2;i<=2;i++)
			for(int j=-2;j<=2;j++){
				int curx=x+i,cury=y+j;
				if(curx>0 && curx<=h && cury>0 && cury<=w && s[curx][cury-1]=='.'){
					if(vis[curx][cury]) continue;
					if(abs(i)+abs(j)<2){
						vis[curx][cury]=true;
						d[curx][cury]=d[x][y];
						q.push_front(make_pair(curx,cury));
					}else{
						if(d[curx][cury]>d[x][y]+1){
							d[curx][cury]=d[x][y]+1;
							q.push_back(make_pair(curx,cury));
						}
					}
				}
			}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 10452
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#define ll long long
#include<utility>
#define mkpair(a,b) pair<int,int>(a,b)

using namespace std;

bool func(pair<int,int>p1,pair<int,int>p2)
{
    return p1.second>p2.second;
}

int main()
{
    int n,m;
    cin>>n>>m;

    priority_queue<int,vector<int>,greater<int>>Q;
    while(n--)
    {
        int x;
        cin>>x;
        Q.push(x);
    }

    int i = m;
    vector<pair<int,int>>V;
    while(i--)
    {
        int b,c;
        cin>>b>>c;

        V.push_back(mkpair(b,c));
    }

    sort(V.begin(),V.end(),func);
    // for(i=0;i!=m;i++)
    //     cout<<V[i].first<<' '<<V[i].second<<'\n';

    for(i=0;i!=m;i++)
    {
        int j;
        for(j=0;j!=V[i].first;j++)
        {
            if(Q.top() < V[i].second)
            {
                Q.pop();
                Q.push(V[i].second);
            }
            else
                break;
        }
    }

    ll s = 0;
    while(!Q.empty())
    {
        s += Q.top();
        Q.pop();
    }

    cout<<s;

    return 0;
}


Measured memory_bytes: 1784
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3648
N = gets.chomp.to_i
V = gets.split(' ')
C = gets.split(' ')

sum = 0
i = 0
N.times do
    cal = V[i].to_i - C[i].to_i
    if cal > 0 then
        sum = sum + cal
    end
    i = i + 1
end

print sum

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    string s, l[] = {"dream", "dreamer", "erase", "eraser"};
    cin>>s;
    bool flag;
    while(s.size() > 0) {
        flag = true;
        each(t, l) {
            if(t.size() > s.size()) continue;
            if(t == s.substr(s.size() - t.size())) {
                flag = false;
                s.erase(s.size() - t.size());
            }
        }
        if(flag) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using vv = vector<V<T>>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  ll n;
  cin >> n;
  ll a[5];
  REP(i,5) cin >> a[i];
  ll mn = 1e16;
  REP(i,5){
    mins(mn,a[i]);
  }
  ll ans = 4;
  ans += (n+mn-1)/mn;
  cout << ans << endl;
}

Measured memory_bytes: 256