akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	inputInts := explodeInt(" ", readLine(sc))

	aButton := inputInts[0]
	bButton := inputInts[1]

	var outputValue int

	for index := 0; index < 2; index++ {
		if aButton >= bButton {
			outputValue += aButton
			aButton += -1
		} else {
			outputValue += bButton
			bButton += -1
		}
	}

	fmt.Println(outputValue)
}

// helper

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return strings.TrimSpace(sc.Text())
}

func readLineToInt(sc *bufio.Scanner) int {
	intValue, err := strconv.Atoi(readLine(sc))
	if err != nil {
		panic(err)
	}

	return intValue
}

func explodeString(delimiter string, inputValue string) []string {
	splittedValue := strings.Split(inputValue, delimiter)

	var trimmedValues []string

	for _, value := range splittedValue {
		if value != "" {
			trimmedValues = append(trimmedValues, value)
		}
	}

	return trimmedValues
}

func explodeInt(delimiter string, inputValue string) []int {
	inputStrings := explodeString(" ", inputValue)

	var splittedInts []int

	for _, inputString := range inputStrings {
		var (
			intValue int
			err      error
		)
		intValue, err = strconv.Atoi(inputString)

		if err != nil {
			panic(err)
		}
		splittedInts = append(splittedInts, intValue)
	}

	return splittedInts
}


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

typedef long long int   ll;
#define int             ll
#define PI              3.1415926535897932384626433832795

#define pb              push_back
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]

#define hell            freopen("input.txt","r", stdin);freopen("output.txt", "w", stdout);freopen("error.txt", "w",stderr);
#define fastasF_boi()   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
//#define cerr            if(false)cerr

int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
int mulmod(int a,int b){return ((a%mod)*(b%mod))%mod;}
int addmod(int a,int b){return (((a%mod)+(b%mod))+mod)%mod;}

void solve(){
    int n;cin>>n;
    string s;cin>>s;
    int cnt1=0,cnt2=0;
    for(auto it:s) if(it=='R') cnt1++; else cnt2++;
    if(cnt1==0 or cnt2==0) cout<<0<<endl;
    else {
        int ans=0;
        int p1=0,p2=n-1;
        while(true){
            if(s[p1]=='R'){
                p1++,cnt1--;
                if(cnt1==0){
                    break;
                }
            }
            else{
                while(s[p2]!='R') p2--;
                swap(s[p1],s[p2]);
                ans++;
                cnt1--;
                p1++;
                if(cnt1==0){
                    break;
                }
            }
        }
        cout<<ans<<endl;
    }
}

signed main(){
//    hell;

    fastasF_boi();
    int t=1;
//    cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
}



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



int main()
{
	int n, m;
	cin >> n >> m;
	bool first[200005], second[200005];
	fill(first, first + 200005, false);
	fill(second, second + 200005, false);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		if (a == 1 && b != n) {
			first[b] = true;
		}
		if (a != 1 && b == n) {
			second[a] = true;
		}
	}
	for (int i = 2; i < n; i++) {
		if (first[i] && second[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}



Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n;
lint dp[5010][5010];
pll p[5010];

int main(){
    scanf("%d", &n);
    rep(i, n) scanf("%lld%lld", &p[i].fi, &p[i].se);
    sort(p, p+n, [](const pii &a, const pii &b){return a.fi+a.se < b.fi+b.se;});
    rep(i, n+1)rep(j, n+1) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, n)rep(j, n+1)if(dp[i][j] < INF){
        chmin(dp[i+1][j], dp[i][j]);
        if(dp[i][j] <= p[i].fi) chmin(dp[i+1][j+1], dp[i][j] + p[i].se);
    }
    rrep(j, n+1)if(dp[n][j] < INF){
        printf("%d\n", j);
        break;
    }
}

Measured memory_bytes: 196096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <chrono>
#include <random>
#include <bits/stdc++.h>
 
using namespace std;
template <typename T> T max(T a, T b) {return a>b?a:b;}
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
#define ll long long
#define PI 3.14159265358979323846
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a<b)?(b):(a))
#define abs(a) ((a>0)?a:-(a))

const double eps = (double)1e-6;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dist[22][22];
queue<pair<int,int> > q;
char arr[22][22];
int h,w;
int offset[4][2] = {{1,0}, {0,1}, {-1,0}, {0,-1}};

bool ok(int i, int j) {
    return (i >= 1 && i <= h && j >= 1 && j <= w && arr[i][j] != '#');
}

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

    cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> arr[i][j];
        }
    }
    int ans = -1;


    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (!ok(i,j)) continue;
            memset(dist, -1, sizeof(dist));
            auto start = make_pair(i,j);
            q.push(start);
            dist[i][j] = 0;
            while (!q.empty()) {
                int curri = q.front().first, currj = q.front().second;
                q.pop();

                for (int k = 0; k < 4; k++) {
                    int x = curri+offset[k][0];
                    int y = currj+offset[k][1];
                    if (ok(x,y) && dist[x][y] == -1) {
                        q.push(make_pair(x,y));
                        dist[x][y] = dist[curri][currj] + 1;
                        ans = max(ans, dist[x][y]);
                    }
                }

            }
        }
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 256
h,w,k = list(map(int,input().split()))
mr_list = [input() for i in range(h)]
output = 0
import copy
for i in range(2**(h+w)):
  row = []
  m_list = copy.copy(mr_list)
  for j in range(h+w):
    if ((i >> j) & 1):
      row.append(j)
  for r in row:
    if r < h:
      m_list[r] = "r"*w
    else:
      for i,m in enumerate(m_list):
        m_list[i] = m[:r-h] + 'r' + m[r-h+1:]
  out =0
  for m in m_list:
    out += m.count("#")
  if out == k:
    output += 1
print(output)
      

Measured memory_bytes: 69920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

ll modP(ll x, ll y, ll MOD)
{
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
    ll n; 
    double d; 
    cin>>n>>d; 
    for(int i=0;i<n;i++) 
    {
        double x,y,res; 
        cin>>x>>y; 
    res=sqrt((x*x)+(y*y)); 
    if(res<=d) ans++;
    }

    cout<<ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t ;
    t = 1;
//    cin >> t;

    for (int i = 1; i <= t; i++)
    {
        solve();
    }
    return 0;
}




Measured memory_bytes: 3860
# -*- coding: utf-8 -*-

A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if( 500*a + 100*b + 50*c == X): count += 1

print(count)

Measured memory_bytes: 9112
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut n = read::<i64>();
    let mut ans = (n / 11) * 2;
    n %= 11;
    if n > 6 {
        ans += 2;
    } else if n > 0 {
        ans += 1;
    }

    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
N, Q = map(int,input().split())
S = input()
R = [0]*(N+1)
A = False
C = False
for i in range(0,N):
  char = S[i]
  if char == 'A':
    A = True
  elif char == 'C' and A:
    R[i+1]+=1
    A = False
  else:
    A = False
  R[i+1]+=R[i]
for _ in range(Q):
  l, r = map(int,input().split())
  print(R[r]-R[l])


Measured memory_bytes: 77008
#include <stdio.h>

int bubblesort(int,int *);
int A[102];

int main(void)
{
    int i;
    int N,k;
    
    scanf("%d", &N);
    for (i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    k = bubblesort(N, A);

    printf("%d", A[0]);
    for (i = 1; i < N; i++){
        printf(" %d", A[i]);
    }
    printf("\n");
    printf("%d\n", k);


    return (0);
}

int bubblesort(int N, int *A){
    int i;
    int flag;
    int temp;
    int count;

    flag = 1;
    count = 0;
    while (flag){
        flag = 0;
        for (i = N - 1; i > 0; i--){
            if (A[i] < A[i-1]){
                temp = A[i];
                A[i] = A[i - 1];
                A[i - 1] = temp;
                flag = 1;
                count++;
            }
        }
    }
    return count;

}


Measured memory_bytes: 2044
#include<stdio.h>

int main(){

    char result[15];
    scanf("%s", result);

    int total_lose = 0;

    for (int i = 0; i < 15; i++){

        if(result[i] == 'x'){
            total_lose += 1;
        }
    }

    if(total_lose < 8){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T> *A) {
  for (auto itr = A->begin(); itr < A->end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(vector<T> *A) {
  for (auto itr = A->begin(); itr < A->end(); ++itr) cout << *itr << " ";
  cout << endl;
}

static inline void MainTask() {
  string S;
  cin >> S;
  map<char, int> mp;
  for (uint32_t i = 0; i < S.length(); ++i) {
    mp[S[i]]++;
  }
  uint32_t flag = 0;
  for (uint32_t i = 0; i < S.length(); ++i) {
    flag |= mp[S[i]];
  }

  if (flag == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  MainTask();

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    K = int(input())
    S=input()
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    if len(S)<=K:
        print(S)
    else:
        print(S[0:K]+"...")




if __name__ == "__main__":
    main()

Measured memory_bytes: 68044
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool H[20000][20000];

int getChar(char c)
{
	if (c == 'A')return 1;
	else if (c == 'C')return 2;
	else if (c == 'G')return 3;
	else if (c == 'T')return 4;
}

ll getUpperKey(string s)
{
	ll sum = 0, p = 1;
	FOR(i, s.length(), 6)
	{
		sum += p*getChar(s[i]);
		p *= 5;
	}
	return sum;
}
ll getLowerKey(string s)
{
	ll sum = 0, p = 1;
	REP(i, std::min((int)s.length(), 6))
	{
		sum += p*getChar(s[i]);
		p *= 5;
	}
	return sum;
}

void insert(string s)
{
	ll u = getUpperKey(s);
	ll l = getLowerKey(s);
	H[u][l] = true;
}

string find(string s)
{
	ll u = getUpperKey(s);
	ll l = getLowerKey(s);
	return H[u][l] ? "yes" : "no";
}

int main()
{
	int N;
	cin >> N;
	vector<string> ans;
	REP(i, N)
	{
		string com, s;
		cin >> com >> s;
		if (com == "insert")
		{
			insert(s);
		}
		else if (com == "find")
		{
			ans.push_back(find(s));
		}
	}
	REP(i, ans.size())
	{
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 31560
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Map<Integer, Integer>> al = new ArrayList<Map<Integer,Integer>>();
        for(int i = 0; i < N; i++){
            int A = sc.nextInt();
            HashMap<Integer,Integer> tmpl = new HashMap<Integer, Integer>();
            for(int j = 0; j < A; j++){
                int xn = sc.nextInt();
                int yn = sc.nextInt();
                tmpl.put(xn,yn);
            }
            al.add(tmpl);
        }
        int ans = 0;
        int max_q = (int)Math.pow(2,N);
        for(int i = 0; i < max_q; i++){
            boolean bool = true;
            int cnt = 0;
            for(int j = 0; j < N; j++){
                if((i >> j) % 2 == 0){
                    continue;
                }
                cnt++;
                for(Map.Entry<Integer, Integer> entry : al.get(j).entrySet()){
                    int key = entry.getKey()-1;
                    int val = entry.getValue();
                    if((i >> key) % 2 != val){
                        bool = false;
                    }
                }
            }
            if(bool){
                ans = Math.max(ans,cnt);
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 33592
print("YNEOS"[input() not in ["KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA","AKIHABARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA"]::2])

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
  long h, i=1, cnt=1;
  vector<long> H;
  cin >> h;
  while(true)
  {
    if(h==1)
      break;
    
    h = floor(h/2);
    cnt += 2*i;
    i = 2*i;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int H, W;
    cin >> H>> W;

    int a[500][500];
    int b[500][500];
    REP(i,H)REP(j,W) {
      cin>>a[i][j];
      b[i][j]=a[i][j];
    }
    int ans=0;
    REP(i,H)REP(j,W-1){
      if(a[i][j]%2==1){
        a[i][j]--;
        a[i][j+1]++;
        ans++;
      }
    }
    REP(i,H-1){
      if(a[i][W-1]%2==1){
        a[i][W-1]--;
        a[i+1][W-1]++;
        ans++;
      }
    }
    cout<<ans<<endl;
  
    REP(i,H)REP(j,W)
      a[i][j]=b[i][j];
    
    REP(i,H)REP(j,W-1){
      if(a[i][j]%2==1){
        a[i][j]--;
        a[i][j+1]++;
        cout<<i+1<<" "<<j+1<<" "<<i+1<<" "<<j+2<<endl;
      }
    }
    REP(i,H-1){
      if(a[i][W-1]%2==1){
        a[i][W-1]--;
        a[i+1][W-1]++;
        cout<<i+1<<" "<<W<<" "<<i+2<<" "<<W<<endl;
      }
    }
}


Measured memory_bytes: 6016
//#include <bits/stdc++.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e6 + 10;
inline int lc(int x) { return x << 1; }
inline int rc(int x) { return x << 1 | 1; }
int const MOD = 1e9 + 7;
int ans = 0;
// int vis[maxn][maxn];
ll n, m;
// map<pdi, int> dp;

void dfs(int x, int y) {
    if (x > n || y > m) return;
    if (x == n && y == m) {
        ans++;
        if (ans > MOD) ans -= MOD;
        return;
    }
    dfs(x + 1, y + 2);
    dfs(x + 2, y + 1);
}

ll pow_mod(ll a, ll x, ll mod) {
    if (x == 0) return 1;
    ll ans = pow_mod(a, x >> 1, mod);
    ans = ans * ans % mod;
    if (x & 1) ans = ans * a % mod;
    return ans;
}

ll calc(ll n) {
    ll ans = 1;
    for (ll i = 1; i <= n; i++) {
        ans = (ans * i) % MOD;
    }
    return ans;
}

ll C(ll n, ll m) {
    ll ans = 1;
    ans = (ans * calc(n)) % MOD;
    ans = (ans * pow_mod(calc(m), MOD - 2, MOD)) % MOD;
    ans = (ans * pow_mod(calc(n - m), MOD - 2, MOD)) % MOD;
    return ans;
}

int main(void) {
    FAST_IO;
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        puts("0");
        return 0;
    } 
    if (2 * y < x || 2 * x < y) {
        puts("0");
        return 0;
    } 
    int X = (2 * y - x) / 3, Y = (2 * x - y) / 3;
    cout << C(X + Y, X) % MOD << endl;

    return 0;
}

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

int main(){
    map<string, int> mp;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }

    int maxv = 0;
    for(auto m : mp){
        if(m.second > maxv) maxv = m.second;
    }

    vector<string> v;
    for(auto m : mp){
        if(m.second == maxv) v.emplace_back(m.first);
    }

    for(int i = 0; i < v.size(); i++) cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 28272
#include <iostream>
#include <cmath>
#define INF 10000000000
using namespace std;
typedef long long int ll;
ll h[100001],dp[100001],n,k;
int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i = 0; i < n; i++)scanf("%lld",&h[i]);
    //start dp
    fill(dp,dp+n,INF);
    dp[0] = 0;
    for(int i = 1; i < n; i++)
    {
        for(int j = max(0ll,i-k);j<i;j++)
        {
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    printf("%lld\n",dp[n-1]);
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    iostream::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    set<int> stronger[5000];
    for(int i=0; i<m; i++){//m
        int w,l;
        cin >> w >> l;
        w--; l--;
        stronger[l].insert(w);
    }

    bool already[5000] = {};
    int ans = 0;
    for(int i=0; i<n; i++){
        int tmp = -1;
        for(int j=0; j<n; j++){
            if(already[j]) continue;
            if(stronger[j].size() == 0){
                if(tmp != -1) ans = 1;
                else tmp = j;
            }
        }
        cout << tmp + 1 << endl;
        already[tmp] = true;
        for(int j=0; j<n; j++){
            if(stronger[j].count(tmp) == 1) stronger[j].erase(tmp);
        }
    }
    cout << ans << endl;
    
    
    return 0;
}



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

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_B
 * 
 * @author Kyoro
 *
 */
public class Main {

	BufferedReader reader;
	private int n;
	private int r[];
	private int c[];
	private long dp[][];

	public Main() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public static void main(String[] args) {
		Main main = new Main();
		try {
			main.read();
			long result = main.solve();
			System.out.println(result);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private void init(int n) {
		dp = new long[n][n];
		r = new int[n];
		c = new int[n];
	}

	private void read() throws IOException {
		String line = reader.readLine();
		String tokens[];
		n = Integer.parseInt(line.trim());
		init(n);
		for (int i = 0; i < n; i++) {
			line = reader.readLine();
			tokens = line.trim().split(" ");
			r[i] = Integer.parseInt(tokens[0]);
			c[i] = Integer.parseInt(tokens[1]);
		}
	}

	private long solve() {
		for (int i = 0; i < n; i++) {
			dp[i][i] = 0;
		}
		for (int j = 1; j < n; j++) {
			for (int i = j - 1; i >= 0; i--) {
				// i <= k < j となるすべてのkで分割を試す
				dp[i][j] = 100000000;
				for (int k = i; k < j; k++) {
					dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k+1][j]+ (r[i] * c[k] * c[j]));
				}
			}
		}

		return dp[0][n - 1];
	}

}



Measured memory_bytes: 24740
#include<cstdio>
#include<cstring>

#define MAX(X,Y) ((X>Y)?(X):(Y))

int map[100][100];
int smap[100][100];
int ssmap[100][100];

int main(void) {
    while(true) {
        int n,w,h,s,t,res=0;
        scanf("%d",&n);
        if(!n) break;

        memset(map, 0, sizeof(map));
        memset(smap, 0, sizeof(smap));

        scanf("%d%d",&w,&h);
        for(int i=0; i<n; i++) {
            int x,y;
            scanf("%d%d",&x,&y);
            map[x-1][y-1] = 1;
        }

        scanf("%d%d",&s,&t);

/*        for(int j=0; j<h; j++) {
            for(int i=0; i<w; i++)
                printf("%d ",map[i][j]);
            printf("\n");
        }//*/
        for(int j=0; j<h; j++) {
            int now=0;
            for(int i=0; i<s; i++)
                now += map[i][j];
            smap[0][j] = now;

            for(int i=1; i+s<=w; i++) {
                now -= map[i-1][j];
                now += map[i+s-1][j];
                smap[i][j] = now;
            }
        }
/*        for(int j=0; j<h; j++) {
            for(int i=0; i<w; i++)
                printf("%d ",smap[i][j]);
            printf("\n");
        }//*/
        for(int i=0; i<w; i++) {
            int now=0;
            for(int j=0; j<t; j++)
                now += smap[i][j];
            ssmap[i][0] = now;

            for(int j=1; j+t<=h; j++) {
                now -= smap[i][j-1];
                now += smap[i][j+t-1];
                ssmap[i][j] = now;
            }
        }
        for(int i=0; i+s<=w; i++)
            for(int j=0; j+t<=h; j++)
                res = MAX(res, ssmap[i][j]);

        printf("%d\n",res);
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false),cin.tie(0);
#define ll long long
int main(){
	IO
    int n;
    cin>>n;
    int a[n+1],c[n+2],sumn=0;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>0)
            c[i]=a[i]-a[i-1],sumn+=abs(c[i]);
        else
            c[i]=a[i],sumn+=abs(c[i]);
    }
    c[n]=0-a[n-1],sumn+=abs(c[n]);
    for(int i=0;i<n;i++){
        cout<<sumn-(c[i]*c[i+1]<0? 2*min(abs(c[i]),abs(c[i+1])):0)<<'\n';
    }
}

Measured memory_bytes: 4364
#include<iostream>

using namespace std;

int main(){
int N,A[1001];
double x=0;
cin >> N;
for(int i=0;i<N;i++){
  cin >> A[i];
}
for(int i=0;i<N;i++){
  x=x+1.0000000/A[i];
}
cout<<1.0000000/x;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

template <typename T>
T lis(vector<T>& array, T INF = numeric_limits<T>::max() / 2) {
  vector<T> dp(array.size(), INF);
  for (T& i : array) {
    *lower_bound(dp.begin(), dp.end(), i) = i;
  }
  return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    vector<pii> v;
    for (int i = 0; i < n; i++) {
      int h, r;
      cin >> h >> r;
      v.emplace_back(h, r);
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      int h, r;
      cin >> h >> r;
      v.emplace_back(h, r);
    }
    sort(v.begin(), v.end(), [&](pii a, pii b) {
      return a.first != b.first ? a.first < b.first : a.second > b.second;
    });
    vector<int> a;
    for (int i = 0; i < n + m; i++) {
      a.emplace_back(v[i].second);
    }
    cout << lis<int>(a) << endl;
  }

  return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    if(n==0)
    {
        cout<<0;
    }
    else if(n==1)
    {
        cout<<h[0];
    }
    int inf=1e9;
    vector<int>dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            {dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));}
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int n;
    cin>>n;
    if(n>=1000){
        cout<<"ABD"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
}


Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
c0 = s.count("AC")
c1 = s.count("WA")
c2 = s.count("TLE")
c3 = s.count("RE")
print(f"AC x {c0}")
print(f"WA x {c1}")
print(f"TLE x {c2}")
print(f"RE x {c3}")


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

using namespace std;

int dp[1000+1][1000+1];
char grid[1000+1][1000+1];

const int mod = 1e9+7;

int main(){
  int H, W; cin >> H >> W;
  for(int i=1; i<=H; ++i)
    for(int j=1; j<=W; ++j) cin >> grid[i][j];
  dp[1][1] = 1;
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      if(grid[i-1][j] == '#' && grid[i][j-1] == '#')
        dp[i][j] = 0;
      else if(grid[i-1][j] == '#')
        dp[i][j] = (dp[i][j]%mod + dp[i][j-1]%mod)%mod;
      else if(grid[i][j-1] == '#')
        dp[i][j] = (dp[i][j]%mod + dp[i-1][j]%mod)%mod;
      else
        dp[i][j] = (dp[i][j]%mod + (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod)%mod;
    }
  }
  cout << dp[H][W] << "\n";
  return 0;
}


Measured memory_bytes: 5120
n, k = map(int, input().split())
p = list(map(int, input().split()))

sk = sum(p[:k])
st = p[0]
c = 0
mp = sk

for i in range(k, n):
    sk = sk - p[i-k] + p[i]
    if mp < sk:
        mp = sk

print((mp+k)/2)

Measured memory_bytes: 25060
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int h, n;
  cin >> h >> n;
  int s = 0;
  int a;

  for(int i = 0; i < n; i++){
    cin >> a;
    s += a;
  }
  if(s >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

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

	int sum=0;
	for (int i=0; i<m; i++)
	{
		int days;
		cin >> days;
		sum += days;
	}

	if (sum <= n)
	{
		cout << n - sum << endl;
		return 0;
	}
	else
	{
		cout << -1 << endl;
		return 0;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  string s;
  cin >> a >> s >> b;
  int ans = 0;
  if(s == "+"){
    ans = a + b;
  }
  else{
    ans = a - b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
x,y=map(int,input().split())
if x>=y:
  print(0)
  exit()
a=list(map(int,input().split()))
a.sort()
l=a[0]
m=[]
for i in a[1:]:
  m.append(i-l)
  l=i
m.sort(reverse=True)
print(sum(m[x-1:]))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

int main(){
    vector<pair<int,int>> a;
    int n,t;
    cin >> n >> t;
    rep(i,n){
        int c,tt;
        cin >> c >> tt;
        a.pb(mp(c,tt));
    }
    sort(a.begin(),a.end());
    rep(i,n){
        if(a[i].se <= t) {
            cout << a[i].fi << endl;
            return 0;
        }
    }
    cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k;
  cin>>n>>m>>k;
  for(int i=0;i<=n;++i){
    for(int j=0;j<=m;++j){
      if(i*(m-j)+j*(n-i)==k){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;

int main() {
	long long n, k;
	cin >> n >> k;
	if (n == 1) {
		cout << k << endl;
		return 0;
	}
	long long ans = k;
	for (int i = 0; i < n - 1; i++) {
		ans *= (k - 1);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int check[200010];

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>A;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	for (int i = 0; i < 200010; i++) {
		check[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		check[A[i]]++;
	}
	vector<int>st;
	int sum = 0;
	for (int i = 0; i < 200010; i++) {
		if (check[i] != 0) {
			st.push_back(check[i]);
		}
	}
	sort(st.begin(), st.end());
	sum = 0;
	for (int i = 0; i + K < st.size();i++) {
		sum += st[i];
	}
	cout << sum << endl;

}

Measured memory_bytes: 3316
H, W, K, *S = open(0).read().split()

A = []
c = 0
for i, s in enumerate(S):
    T = []
    r = s.find("#")
    if r != -1:
        l = -1
        while r != -1:
            c += 1
            T += [c] * (r - l)
            l, r = r, s.find("#", r + 1)
        T += [c] * (len(s) - l - 1)
    A.append(T)

for i in reversed(range(len(A) - 1)):
    if not A[i]:
        A[i] = A[i + 1]

for i in range(1, len(A)):
    if not A[i]:
        A[i] = A[i - 1]

for a in A:
    print(*a)

Measured memory_bytes: 7576
import java.util.Scanner;

class Main {
    public static void main(String []args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int area = a*b;
        int circumference = 2*(a+b);
        System.out.print(area);
        System.out.println(" " + circumference);
        
    }
}


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

int main()
{
    string str;
    ll n;
    cin>>n>>str;
    int r=0,w=0;
    for(char c:str)if(c=='R')r++;
    for(int i=0;i<r;i++){
        if(str[i]=='W')w++;
    }
    cout<<w;
}

Measured memory_bytes: 3744
#include <stdio.h>
#include <stdlib.h>

const int comp_double(const void* p, const void* q)
{
  if( *(double*)p > *(double*)q ) return -1;
  if( *(double*)p < *(double*)q ) return 1;
  return 0;
}

int main()
{

  size_t N;
  double H = 0.0, damage = 0.0;
  int count = 0;
  scanf("%zi %lf%*[^\n]%*c", &N, &H);

  double* a = malloc(N * sizeof(double));
  double* b = malloc(N * sizeof(double));
  for (size_t i = 0; i < N; i++)
  {
    scanf("%lf %lf%*[^\n]", &a[i], &b[i]);
    getchar();
  }
  qsort(a, N, sizeof(double), comp_double), qsort(b, N, sizeof(double), comp_double);
  for (size_t i = 0; i < N; i++)
  {
    if (b[i] <= a[0]) break;
    damage += b[i];
    count++;
    if (damage >= H) break;
  }
  while (damage < H) 
  {
    damage += a[0];
    count++;
  }
  printf("%i\n", count);
  free(a);
  free(b);

  return 0;
}


Measured memory_bytes: 2556
@OptIn(ExperimentalStdlibApi::class)
fun main(args : Array<String>) {
    val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
    val k = readLine()!!.toInt()

    val dfs = ArrayDeque<Hand>()
    dfs.addLast(Hand(a, b, c, 0))

    while (dfs.isNotEmpty()) {
        val hand = dfs.removeLast()

        if (hand.red < hand.green && hand.green < hand.blue) {
            println("Yes")
            return
        }

        if (hand.k >= k) continue

        dfs.addLast(Hand(hand.red*2, hand.green, hand.blue, hand.k+1))
        dfs.addLast(Hand(hand.red, hand.green*2, hand.blue, hand.k+1))
        dfs.addLast(Hand(hand.red, hand.green, hand.blue*2, hand.k+1))
    }

    println("No")
}

data class Hand(var red: Int, var green: Int, var blue: Int, var k: Int)

Measured memory_bytes: 39276
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

string S;
int main(void){
    cin >> S;

    bool kuriage = false;
    ll count = 0;
    for (int i = S.length()-1; i >= 0;i--){
        int current_num = S[i] - '0';

        if(kuriage) current_num++;

        if (current_num == 5){
            int next = S[i-1] - '0';
            if(i != 0 and next >= 5){
                count += 10 - current_num;
                kuriage = true;
            }else{
                count += 5;
                kuriage = false;
            }
        }else if(current_num <= 5){
            count += current_num;
            kuriage = false;
        }else{
            count += 10 - current_num;
            kuriage = true;
        }
        // cout << S[i] - '0' << " " << count << endl;
    }
    if (kuriage) count++;

    cout << count << endl;
    return 0;
}



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

int main()
{
	int cnt = 0;
	ll l,r,d;
	cin >> l >> r >> d;
	for(int i = l;i<=r;i++)
	{
		if(i%d==0)cnt++;
	}
	cout << cnt << endl;
}


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

using namespace std;

#define int long long 
#define INF 21000000000

signed main(){
		int n;
		cin >> n;
		int ans = 0;
		for (int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				ans += tmp;
				ans--;
		}
		cout << ans << endl;
}



Measured memory_bytes: 256
//enumerate
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<limits>
#include<utility>

#define c11
#ifdef c11
#include<unordered_set>
#include<unordered_map>
#endif

using namespace std;
typedef long long ll;
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define initz(x) memset(x,0,sizeof(x))
#define initm(x) memset(x,0x7f,sizeof(x))
#define forn(i, n) for(int i = 0; i < (int) n; ++i)
#define for1(i, n) for(int i = 1; i <= (int) n; ++i)
#define fore(i, l, r) for(int i = (int) l; i <= (int) r; ++i)
#define rforn(i, n) for(int i = (int) n - 1; i>= 0; ++i)
#define first fi
#define second se

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

const int INF = 0x7f7f7f7f;
const int MAX_N = 100;
const int MAX_M = 50005;

typedef pair<int, int> P;

bitset<10000> cookie[10];
int R = -1, C = -1;

void do_flip(int conf) {
  forn(j, R) {
    if((conf >> j) & 1) {
      cookie[j].flip();
    }
  }
}

int main() {
  while(1) {
    cin >> R >> C;
    if( R == 0 && C == 0) break;
    forn(i, R) {
      forn(j, C) {
        int up;
        cin >> up;
        cookie[i][j] = up;
      }
    }

    int total = 1 << R;
    int ret = 0;
    forn(i, total) {
      do_flip(i);
      int cur = 0;
      forn(j, C) {
        int cnt = 0;
        forn(k, R) {
          if(cookie[k][j]) {
            cnt++;
          }
        }
        cur += max(cnt, R-cnt);
      }
      do_flip(i);
      ret = max(ret, cur);
    }
    cout << ret << endl;
  }
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int k = n / x;
  if (n % x != 0) k++;
  cout << k * t << endl;
  return 0;
}

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

int main()
{
	int N, K, h;
	cin >> N >> K;
	int getable = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> h;
		if (h >= K)
		{
			getable++;
		}
	}
	cout << getable;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void outputV(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    if (i) {
      cout << ' ';
    }
    cout << v[i];
  }
  cout << endl;
}

void outputV(vector<vector<int>> v) {
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (j) {
        cout << ' ';
      }
      cout << v[i][j];
    }
    cout << endl;
  }
}

int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int> (3));
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  vector<vector<int>> dp(n,vector<int>(3,0));
  
  for(int i=0;i<3;i++){
    dp[0][i]=a[0][i];
  }

  for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k){
          continue;
        }
        int v=dp[i-1][k]+a[i][j];
        dp[i][j]=max(dp[i][j],v);
      }
    }
  }
  int ans=0;
  for(int i=0;i<3;i++){
    ans=max(ans,dp[n-1][i]);
  }
  cout<<ans<<endl;
  return 0;
}

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

    int n;
    cin>>n;
    int i;
    int a[3*n];
    for(i=0;i<3*n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3*n);
    long long int sum=0,cnt=0;
    for(i=3*n-2;cnt<n;i-=2)
        {sum+=a[i];cnt++;}
    cout<<sum;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    vector<int>vec(N);
    vector<int>vec2(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
       vec2.at(i)=vec.at(i);
    }
    sort(vec2.begin(),vec2.end());
    reverse(vec2.begin(),vec2.end());
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(vec.at(i)==vec2.at(j)){
                if(vec2.at(j)==vec2.at(j+1)){
            cout <<vec2.at(j)<<endl;
            break;                    
                }
            }
            if(vec.at(i)!=vec2.at(j)){
            cout <<vec2.at(j)<<endl;
            break;
            }
            
        }
    }

}

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

int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        string x;
        cin>>x;
        int c=0;
        for(char ch:x)
        {
                if(ch=='2')
                        c++;
        }
        cout<<c<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=100005;
ll n,m;

int main(){
	cin>>n>>m;
	vl dp(M,INF);
	dp[0]=0;
	for(int i=0;i<n;i++){
		ll w,v;
		cin>>w>>v;
		vl DP(M,INF);
		for(int j=0;j<M;j++){
			if(j+v<M) DP[j+v]=dp[j]+w;
			DP[j]=min(DP[j],dp[j]);
		}
		dp=DP;
	}
	ll res=0;
	for(int i=0;i<M;i++) if(dp[i]<=m) res=i;
	cout<<res<<endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> f(n);
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int cur;
            cin >> cur;
            f[--cur] = 1;
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += f[i];
    }
    cout << n - res << '\n';
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;

char s[200001];
int dp[2][2019];
const int mod = 2019;

int main() {
    scanf("%s", s);
    int n = strlen(s);
    for (int i = 0; i < n; i++)
        s[i] -= '0';

    dp[0][s[0]]++;
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        memset(dp[i & 1], 0, sizeof(dp[0]));
        dp[i & 1][s[i]]++;

        for (int j = 0; j < 2019; j++)
            dp[i & 1][(j * 10 + s[i]) % mod] += dp[i & 1 ^ 1][j];
        ans += dp[i & 1][0];
    }

    printf("%lld", ans);
}

Measured memory_bytes: 3964
num = int(input())
day, remain = map(int, input().split(' '))
eat_count = 0
for i in range(0, num):
    a = int(input())

    multi = 1
    while True:
        if a > day:
            eat_count += 1
            break
        elif a * multi < day:
            eat_count += 1
        else:
            eat_count += 1
            break

        multi += 1

print(eat_count + remain)

Measured memory_bytes: 3064