akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int X, Y;
	cin >> X >> Y;

	int kotae = 2e9;
	if (Y >= X) kotae = min(kotae, Y - X);
	if (-Y >= X)  kotae = min(kotae, -Y - X + 1);
	if (Y >= -X) kotae = min(kotae, Y + X + 1);
	if (-Y >= -X) kotae = min(kotae, -Y + X + 2);

	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 256
import math
def ip():return int(input())
def imp():return map(int,input().split())
def impstr():return map(str,input().split())
def limp():return list(map(int,input().split()))
def limpstr():return list(map(str,input().split()))

a,b=imp()
for i in range(0,a+1):
    if i*2+(a-i)*4==b:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 62096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n, b, r,count=0;
    cin >> n >> b >> r;
    if(n==0) cout << "0" << endl;
    else
    {
        ll result = (n/(b+r));
         count = result*(b);
        ll k = n%(b+r);
        if(k>=b) count+=b;
        else count += k;
    }
    cout << count << endl;
 
}

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

#define REP(i, n) for (int i = 1; i <= int(n); ++i)
#define PER(i, n) for (int i = int(n); i >= 1; --i)
#define REP0(i, n) for (int i = 0; i < int(n); ++i)
#define PER0(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define FOR(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ROF(i, l, r) for (int i = int(l); i >= int(r); --i)
#define DO(n) for (int QAQ = 0; QAQ < int(n); ++QAQ)

#define SZ(x) int(x.size())
#define ALL(x) (x).rbegin(), (x).rend()
#define LLA(x) (x).rbegin(), (x).rend()
#define fi first
#define se second

using DB = double;
using LDB = long double;
using LL = long long;
using ULL = unsigned long long;

const int INF = 1e9;
const DB PI = acos(-1.0);

template<typename T>
T pow(T a, T b) {
    T c = 1;
    while (b) {
        if (b & 1) c = c * a;
        a = a * a;
        b >>= 1;
    }
    
    return c;
}

template<typename T>
T powMod(T a, T b, T mod) {
    T c = 1;
    while (b) {
        if (b & 1) c = 1LL * c * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    
    return c % mod;
}

int main() {
    int a;
    string s;
    cin >> a >> s;
    
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		   int N;
    cin >> N;
    for (int n=1 ; n<=N ; n++){
        ll cnt=0;
        for(int a=1;a*a<n;a++){
            for(int b=1;a*a+a*b+b*b<n;b++){
                for(int c=1;a*a+a*b+b*b+a*c+b*c+c*c<=n;c++){
                    if(a*a+a*b+b*b+a*c+b*c+c*c==n){
                        cnt++;
                        //cout << n << " " << a << " " << b << " " << c;
                        break;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
		return 0;  
}  


Measured memory_bytes: 3592
#include <stdio.h>
 
int main(void)
{
    int i, j;
    int array[5] = {0};
     
    for (i = 0; i < 5; i++)
        scanf("%d", array + i);
    for (i = 0; i < 4; i++)
        for (j = 0; j < 4 - i; j++)
            if (array[j] < array[j + 1])
                array[j] ^= array[j + 1] ^= array[j] ^= array[j + 1];
     
    for (i = 0; i < 5; i++)
        printf("%d%c", array[i], 10 + 22 * (i < 4));
     
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main() {
	int n, x, d = 0, count = 0;
	int l[101];
	scanf("%d %d", &n, &x);
	for (int i=0; i < n; i++) {
		scanf("%d", &l[i]);
	}

	while (d <= x) {
		d += l[count];
		count++;
	}

	printf("%d",count);

	return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::collections::*;

//fn pf_map(x: i64) -> BTreeMap<i64, i64> {
//    fn prime_index(x: i64, divisor: i64) -> (i64, i64) {
//        match x % divisor {
//            0 => {
//                let (last_state, n) = prime_index(x / divisor, divisor);
//                (last_state, n + 1)
//            }
//            _ => (x, 0),
//        }
//    };
//    (2..)
//        .scan(x, |state, i| match *state {
//            1 => None,
//            _ => {
//                let divisor = if i * i <= *state { i } else { *state };
//                let (next_state, index) = prime_index(*state, divisor);
//                *state = next_state;
//                Some((divisor, index))
//            }
//        })
//        .filter(|&(_, num)| num > 0)
//        .collect::<BTreeMap<i64, i64>>()
//}

fn pf_map(x: i64) -> HashMap<i64, i64> {
    (2..)
        .scan(x, |state, i| match *state {
            1 => None,
            _ => {
                let divisor = if i * i <= *state { i } else { *state };
                let mut index = 0;
                while *state % divisor == 0 {
                    *state /= divisor;
                    index += 1;
                }
                Some((divisor, index))
            }
        })
        .filter(|&(_, index)| index > 0)
        .collect()
}

fn main() {
    input! {
        n:i64
    }
    let ans: i64 = pf_map(n)
        .iter()
        .map(|(_, &index)| {
            (1..)
                .take_while(|&i| index >= i * (i + 1) / 2)
                .last()
                .unwrap()
        })
        .sum();
    println!("{}", ans);
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

void print(int n) {
  char c = n + 'A';
  cout << c << endl;
}

int main() {
  vector<string> s(3);
  rep(i, 3) cin >> s[i];

  vector<int> n(3), idx(3, 0);
  rep(i, 3) n[i] = s[i].size();
  int com = 0;
  while (1) {
    if (idx[com] == n[com]) {
      print(com);
      return 0;
    }
    int res = s[com][idx[com]] - 'a';
    idx[com]++;
    com = res;
  }
  



  
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> dam(N);
  vector<int64_t> mount(N);
  for(int i = 0; i < N; i++) {
    cin >> dam.at(i);
  }
  int64_t sum = 0;
  for(int i = 0; i < N; i++) {
    if(i % 2 == 0) {
      sum += dam.at(i);
    }
    else {
      sum -= dam.at(i);
    }
  }
  mount.at(0) = sum;
  for(int i = 1; i < N; i++) {
    mount.at(i) = 2 * (dam.at(i - 1) - mount.at(i - 1) / 2);
  }
  for(int i = 0; i < N; i++) {
    cout << mount.at(i) << endl;
  }
}

Measured memory_bytes: 4844
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    println(op142a(n))
}

fun op142a(n: Int): Double {
    val oddCount = IntRange(0, n).filter { it % 2 != 0 }.count()
    return oddCount.toDouble() / n.toDouble()
}


Measured memory_bytes: 33860
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a[0];
  }
}
$flg = false;
$find = array("a","i","u","e","o");
foreach ($find as $f) {
  if (strpos($key->A[0],$f) !== false) {
    $flg = true;
    break;
  }
}
if ($flg) {
  printf("vowel\n");
}
else {
  printf("consonant\n");
}


Measured memory_bytes: 3832
import java.util.Scanner;

// Java8
public class Main
{
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}

	void run()
	{
		String s = sc.nextLine();
		for(int i=(s.length() - 1)/2; i>0; i--)
		{
			if(s.substring(0, i).equals(s.substring(i, 2*i)))
			{
				System.out.println(i * 2);
				return;
			}
		}
	}
}


Measured memory_bytes: 21844
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 100000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int main() {
	string s; cin >> s;
	bool flag = false;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '7') flag = true;
	}

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, z, n) for(ll i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ll N;
  cin >> N;
  map<ll,ll> A,B;
  
  rep(i, 0, N-1){
    ll temp;
    cin >> temp;
    ll R=i+temp;
    ll L=i-temp;
    if(A.count(R)!=0){
      A[R]++;
    }else{
      A[R]=1;
    }
    if(B.count(L)!=0){
      B[L]++;
    }else{
      B[L]=1;
    }
  }
  ll sum=0;
  for(pair<ll,ll> i:A){
    if(B.count(i.first)>0){
      sum+=B[i.first]*i.second;
    }
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3020
from heapq import heappop, heappush
manhattan = (
 (0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6),
 (1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4, 4, 3, 4, 5),
 (2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3, 5, 4, 3, 4),
 (3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2, 6, 5, 4, 3),
 (1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5),
 (2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4),
 (3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3),
 (4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2),
 (2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4),
 (3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3),
 (4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2),
 (5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1),
 (3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3),
 (4, 3, 4, 5, 3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2),
 (5, 4, 3, 4, 4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1),
 (6, 5, 4, 3, 5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0))
movables = ((1, 4), (0, 2, 5), (1, 3, 6), (2, 7), (0, 5, 8), (1, 4, 6, 9), (2, 5, 7, 10), (3, 6, 11),
            (4, 9, 12), (5, 8, 10, 13), (6, 9, 11, 14), (7, 10, 15), (8, 13), (9, 12, 14), (10, 13, 15), (11, 14))
swap_mul = tuple(tuple((1 << mf) - (1 << mt) for mt in range(0, 64, 4)) for mf in range(0, 64, 4))
destination = 0xfedcba9876543210
i = 0
board_init = 0
blank_init = 0
for _ in range(4):
    for n in map(int, input().split()):
        if n:
            n -= 1
        else:
            n = 15
            blank_init = i
        board_init += n * 16 ** i
        i += 1
estimation_init = sum(manhattan[i][((board_init >> (4 * i)) & 15)] for i in range(16) if i != blank_init)
queue = [(estimation_init, board_init, blank_init)]
visited = set()
while True:
    estimation, board, blank = heappop(queue)
    if board in visited:
        continue
    elif board == destination:
        print(estimation)
        break
    visited.add(board)
    for new_blank in movables[blank]:
        num = (board >> (4 * new_blank)) & 15
        new_board = board + swap_mul[new_blank][blank] * (15 - num)
        if new_board in visited:
            continue
        new_estimation = estimation + 1 - manhattan[new_blank][num] + manhattan[blank][num]
        if new_estimation > 45:
            continue
        heappush(queue, (new_estimation, new_board, new_blank))


Measured memory_bytes: 161188
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	if abs(n-m) >= 2 {
		fmt.Println(0)
		return
	}

	ans := factorial(n) * factorial(m) % 1000000007
	if n == m {
		ans = ans * 2 % 1000000007
	}

	fmt.Println(ans)
}

func factorial(n int) int {
	r := 1
	for i := 1; i <= n; i++ {
		r = r * i % 1000000007
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

const int N=4;

struct state{
  vector<char> board;
  char dist;
  char bi,bj;
  char mh_dist;
  char pre;
};

bool operator<(const state& a,const state& b){
  return a.dist+a.mh_dist > b.dist+b.mh_dist;
}

int di[]={0,1,0,-1};
int dj[]={1,0,-1,0};

/*
int ans[N][N]={
  {0,1,2},
  {3,4,5},
  {6,7,-1},
};*/

int ans[N][N]={
  {0,1,2,3},
  {4,5,6,7},
  {8,9,10,11},
  {12,13,14,-1},
};

P ans_ps[N*N];

bool ida_star(const state& crtstate,char x){
  if(crtstate.mh_dist+crtstate.dist>x)return false;
  if(crtstate.mh_dist==0)return true;

  rep(dir,4){
    if(dir==crtstate.pre)continue;
    int bi=crtstate.bi;
    int bj=crtstate.bj;
    int ni=bi+di[dir];
    int nj=bj+dj[dir];
    if(ni<0||ni>=N||nj<0||nj>=N)continue;
    state nxtstate;
    nxtstate.board=crtstate.board;
    nxtstate.dist=crtstate.dist;
    nxtstate.mh_dist=crtstate.mh_dist;

    char num=crtstate.board[ni*N+nj];
    int ai=ans_ps[num].fi;
    int aj=ans_ps[num].se;
    nxtstate.mh_dist-=abs(ai-ni)+abs(aj-nj);
    nxtstate.mh_dist+=abs(ai-bi)+abs(aj-bj);

    swap(nxtstate.board[bi*N+bj],nxtstate.board[ni*N+nj]);
    nxtstate.dist++;
    nxtstate.bi=ni; nxtstate.bj=nj;
    nxtstate.pre=(dir+2)%4;
    if(ida_star(nxtstate,x))return true;
  }
  return false;
}

int main(){

  clock_t start=clock();

  rep(i,N)rep(j,N){
    if(ans[i][j]==-1)continue;
    ans_ps[ans[i][j]].fi=i;
    ans_ps[ans[i][j]].se=j;
  }

  state inistate;
  inistate.board=vector<char>(N*N);
  inistate.dist=0;
  inistate.mh_dist=0;
  inistate.pre=-1;
  rep(i,N)rep(j,N){
    int input;
    cin>>input;
    input--;
    inistate.board[i*N+j]=input;
    if(input==-1){
      inistate.bi=i;
      inistate.bj=j;
    }else{
      int ai=ans_ps[input].fi;
      int aj=ans_ps[input].se;
      inistate.mh_dist+=abs(ai-i)+abs(aj-j);
    }
  }

  rep(x,45+1){
    if(ida_star(inistate,x)){
      cout<<x<<endl;
      break;
    }
  }

  clock_t end=clock();
  //cerr<<"duration = "<<(double)(end-start)/CLOCKS_PER_SEC<<" sec."<<endl;

  return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define bg begin
#define en end 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll gcd(ll a,ll b){
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll i;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=k;i<n;i++){
        if(a[i]>a[i-k])
        cout<<"Yes\n";
        else
        cout<<"No\n";
    }
}

Measured memory_bytes: 5196
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool neg=c=='-';
	neg?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return neg?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline void mset(T a,int v,int n){memset(a,v,n*sizeof(a[0]));}
const int N=200010;
int f[N];
inline lint Main(){
	const int n=ni;
	for(int i=1;i<=n;i++){
		f[i]=i;
	}
	for(int i=1,las=-1;i<=n;i++){
		const int a=ni;
		if(a>las+1)return -1;
		apmax(f[i-a],i);
		las=a;
	}
	lint ans=0;
	for(int i=1;i<=n;i++){
		ans+=f[i]-i;
	}
	return ans;
}
int main(){
	printf("%lld\n",Main());
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector< vector<ll> > C(2010, vector<ll>(2010, 0));
    for (int i = 0; i < 2010; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if (i == j || j == 0)
                C[i][j] = 1;
            else
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
        }
    }
    for (int i = 1; i <= k; ++i)
        cout << (C[n - k + 1][i] * C[k - 1][i - 1]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll N, A, B, C, D;
map<ll, ll> memo;

ll dfs(ll X) {
    // Xをすでに計算した場合はメモした値を返す
    if (memo.count(X)) {
        // cout << "X already" << X << endl;
        return memo[X];
    }

    // メモがない場合は、6通りのパターンを探索する
    ll min_costs = 1e18;
    ll d2f = (X/2)*2, d2c = ((X+1)/2)*2, 
        d3f = (X/3)*3, d3c = ((X+2)/3)*3, 
        d5f = (X/5)*5, d5c = ((X+4)/5)*5;
    min_costs = min(min_costs, dfs(d2f/2) + abs(X - d2f) * D + A);
    min_costs = min(min_costs, dfs(d3f/3) + abs(X - d3f) * D + B);
    min_costs = min(min_costs, dfs(d5f/5) + abs(X - d5f) * D + C);
    min_costs = min(min_costs, dfs(d2c/2) + abs(X - d2c) * D + A);
    min_costs = min(min_costs, dfs(d3c/3) + abs(X - d3c) * D + B);
    min_costs = min(min_costs, dfs(d5c/5) + abs(X - d5c) * D + C);

    // min_costs > X*Dの場合、Dを使って移動した方が安い
    if (X < min_costs / D) min_costs = X * D;
    memo[X] = min_costs;
    return memo[X];
}

int main() {
    cout << fixed << setprecision(10);
    
    int T; cin >> T;

    rep(i, T) {
        memo[0] = 0;
        cin >> N >> A >> B >> C >> D;
        memo[1] = D;
        // cout << "got" << endl;
        cout << dfs(N) << endl;
        memo.clear();
    }
    return 0;
}
/*
5
11 1 2 4 8
11 1 2 2 8
32 10 8 5 4
29384293847243 454353412 332423423 934923490 1
900000000000000000 332423423 454353412 934923490 987654321

20
19
26
3821859835
23441258666
*/

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=9;i++){
        if(n%i==0){
            if(n/i>=1&&n/i<=9){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def read_h(conv=int):
    return map(conv, input().split())


def read_v(n, conv=int):
    return [conv(input()) for _ in range(n)]


n, x = read_h()
m = read_v(n)

print(len(m) + (x - sum(m)) // min(m))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
int main(){
	ll A, B;
	cin >> A >> B;
	ll ans = 0;
	for(ll i = 0; true; i++){
		if(B == 1 && ans == 0){
			ans = 0;
			break;
		} else {
			if(ans == 0){
				if(B > 0){
					ans++;
					B -= A;
				} else {
					break;
				}
			} else {
				if(B > 0){
					ans++;
					B -= A-1;
				} else {
					break;
				}
			}
		}
	}
	cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// use merge(all(vec1), all(vec2), vec3.begin()) to merge 2 vectors, use vec3.resize(vec1.size() + vec2.size()) first
// ll pos = partition_point(all(vec), pred) - vec.begin(); bool pred(ll a){return a<3};
// print number in binary -> cout << bitset<20>(n);

int main(){
	ll n;cin>>n;
	ll orn=n;
	map<ll,ll>divs;
	for(ll i=2;i*i<=orn&&n>=i;++i){
		while(n%i==0){
			++divs[i];
			n/=i;
		}
	}
	ll cnt=0;
	for(auto m=divs.begin();m!=divs.end();++m){
		ll cn=1;
		while((cn+1)*(cn+2)/2<=m->second)++cn;
		cnt+=cn;
	}
	cout<<cnt+(n!=1&&n>1)<<endl;
}


Measured memory_bytes: 3632
N,M = map(float,input().split())
s = 0.5**M
miss = 1.0-s
dec = 0.0001/1900.0
const = M * 1900.0 + (N-M)*100.0
temp = 0.0
count = 1.0
time = 0
while(True):
    temp2 = temp + s * (miss**(count-1.0))*count
    time2 = int(temp*const )
    if time != time2 or abs(temp - temp2) > dec:
        temp = temp2
        time = time2
        count += 1
        continue
    temp = temp2
    time2 = time
    break

print(int(temp*const+0.5))


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;


ll dp[1005][(1<<12)+5];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll a(m), b(m), c(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    rep(j,b[i]){
      ll x; cin>>x; x--;
      c[i]|=(1<<x);
    }
  }
  
  rep(i,m+1) rep(j,1<<n) dp[i][j]=INF;
  rep(i,m) dp[i][0]=0;
  
  rep(i,m){
    rep(bit,(1<<n)){
      chmin(dp[i+1][bit],dp[i][bit]);
      chmin(dp[i+1][bit|c[i]],dp[i][bit]+a[i]);
    }
  }
  ll ans=dp[m][(1<<n)-1];
  if(ans==INF) cout<<-1<<endl;
  else cout<<ans<<endl;
}

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

using namespace std;
const double eps = 1e-8;

struct Point
{
    double x, y;
};

Point p[505];

double dist(Point A, Point B)
{
    return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
}


/***返回三角形的外心 */
Point circumcenter(Point A, Point B, Point C)
{
    Point ret;
    double a1 = B.x - A.x, b1 = B.y - A.y, c1 = (a1 * a1 + b1 * b1) / 2;
    double a2 = C.x - A.x, b2 = C.y - A.y, c2 = (a2 * a2 + b2 * b2) / 2;
    double d = a1 * b2 - a2 * b1;
    ret.x = A.x + (c1 * b2 - c2 * b1) / d;
    ret.y = A.y + (a1 * c2 - a2 * c1) / d;
    return ret;
}

/***c为圆心，r为半径 */
void min_cover_circle(Point *p, int n, Point &c, double &r)
{
    random_shuffle(p, p + n);
    c = p[0]; r = 0;
    for (int i = 1; i < n; i++)
    {
        if (dist(p[i], c) > r + eps) //第一个点
        {
            c = p[i]; r = 0;
            for (int j = 0; j < i; j++)
                if (dist(p[j], c) > r + eps) //第二个点
                {
                    c.x = (p[i].x + p[j].x) / 2;
                    c.y = (p[i].y + p[j].y) / 2;
                    r = dist(p[j], c);
                    for (int k = 0; k < j; k++)
                        if (dist(p[k], c) > r + eps) //第三个点
                        {   //求外接圆圆心，三点必不共线
                            c = circumcenter(p[i], p[j], p[k]);
                            r = dist(p[i], c);
                        }
                }
        }
    }
}

int main() {
    // freopen("sample3.in", "r", stdin);
    int n;
    Point c;
    double r;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lf%lf", &p[i].x, &p[i].y);
    }
    min_cover_circle(p, n, c, r);
    // printf("%lf %lf %.10lf\n", c.x, c.y, r);
    printf("%.10lf\n", r);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100;
int n,m,x;
struct Node
{
	int c;
	int a[NMAX];
}node[NMAX];
int sum[NMAX],ans = 2e6;
void dfs(int u,int sum[],int cnt)
{
	if(u == n+1)
	{
		for(register int i = 1;i <= m;i++)
			if(sum[i] < x)	return;
		ans = min(ans,cnt);
		return;
	}
	for(register int i = 1;i <= m;i++)
		sum[i] += node[u].a[i];
	dfs(u+1,sum,cnt+node[u].c);
	for(register int i = 1;i <= m;i++)
		sum[i] -= node[u].a[i];
	dfs(u+1,sum,cnt);
}
int main(int argc, char const *argv[])
{
	scanf("%d%d%d",&n,&m,&x);
	for(register int i = 1;i <= n;i++)
	{
		scanf("%d",&node[i].c);
		for(register int j = 1;j <= m;j++)
			scanf("%d",&node[i].a[j]);
	}
	dfs(0,sum,0);
	if(ans >= 2e6)
		printf("-1\n");
	else
		printf("%d\n",ans );
	return 0;
}


Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
vector<long long> a(51, 0);
vector<long long> b(51, 0);
vector<long long> c(51, 0);
vector<long long> d(51, 0);

int main() {
	int N,M;
	cin >> N >> M;
	for (int  i = 0; i < N; i++){
		cin >> a[i] >> b[i];
	}
	for (int j = 0; j < M; j++){
		cin >> c[j] >> d[j];
	}

	for (int i = 0; i < N; i++){
		long long minDes=10000000000;
		long long number = 0;
		for (int j = 0; j < M; j++){
			long long tmpCalc = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (tmpCalc < minDes) {
				minDes = tmpCalc;
				number = j + 1;
			}
		}
		cout << number << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php
error_reporting(0);
$S = trim(fgets(STDIN));
$T = trim(fgets(STDIN));
//$A = explode(" ",trim(fgets(STDIN)));
//list($N,$M) = explode(" ",trim(fgets(STDIN)));
$rt = strrev($T);
if ($rt == $S) printf("YES\n");
else printf("NO\n");


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

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

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll k;cin>>k;
  ll n=50;
  vector<ll>r;
  ll g = (n-1)+k/n-k%n;
  cout<<50<<endl;
  rep(i, n-k%n)cout<<g<<' ';
  rep(i, k%n)cout<<g+n+1<<' ';

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll pow(ll x,ll a,ll mod){
	if(a==0ll)return 1ll;
	ll res=pow(x*x%mod,a/2ll,mod);
	if(a&1)res=res*x%mod;
	return res;
}
int p;
int a[3010];
int rag[3010][3010];
int inv[3010];
int b[3010];
vi pol[3010];
vi mul(vi v,int k){
	// mul (x-k)
	int n = v.size();
	vi res(n+1);
	for(int i=0;i<n;i++){
		res[i] = v[i];
	}
	for(int i=0;i<n;i++){
		res[i+1] += v[i]*(-k);
		res[i+1] %= p;
		res[i+1] = (res[i+1]+p)%p;
	}
	return res;
}
vi div(vi v,int k){
	int n = v.size();
	vi res(n-1);
	for(int i=0;i<n-1;i++){
		res[i] = v[i];
		v[i+1] -= res[i]*(-k);
		v[i+1] %= p;
		v[i+1] = (v[i+1]+p)%p;
	}
	assert(v[n-1]%p==0);
	return res;
}
vector<int> poly;
int main(){
	cin >> p;
	for(int i=0;i<p;i++){
		cin >> a[i];
	}
	for(int i=1;i<p;i++){
		inv[i] = pow(i,p-2,p);
	}
	vi vec;
	vec.pb(1);
	for(int i=0;i<p;i++){
		vec = mul(vec,i);
	}
	for(int i=0;i<p;i++){
		pol[i] = div(vec,i);
	}
	for(int i=0;i<p;i++){
		b[i] = 1;
		for(int j=0;j<p;j++){
			if(i!=j)b[i] = (b[i]*inv[(i-j+p)%p])%p;
		}
	}
	vi ans(p);
	for(int i=0;i<p;i++){
		if(a[i]){
			for(int j=0;j<p;j++){
				ans[j] += pol[i][j]*b[i];
				ans[j] %= p;
				ans[j] += p;
				ans[j] %= p;
			}
		}
	}
	for(int i=0;i<p;i++){
		cout << ans[p-1-i];
		if(i+1<p)cout << ' ';
		else cout << endl;
	}
	return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int N;
  cin >> N;
  set< char > c;
  for(int i = 0; i < N; i++) {
    char p;
    cin >> p;
    c.emplace(p);
  }
  if(c.size() == 3) puts("Three");
  else puts("Four");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;

ll to[1005];
int dfs(ll i,vvi v){
    for(ll x:v[i]){
        to[i]=x;
        if(to[x]!=-1)return i;
        int k=dfs(x,v);
        if(k!=-1)return k;
    }
    to[i]=-1;
    return -1;
}

int main(){
    ll n,m;cin>>n>>m;
    rep(i,n)to[i]=-1;
    vvi v(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        v[a].pb(b);
    }
    rep(i,n){
        ll k=dfs(i,v);
        if(k!=-1){
            vi ito(n,-1);
            ll u=k;
            ito[u]=to[u];
            u=to[k];
            while(u!=k){
                ito[u]=to[u];
                u=to[u];
            }
            while(true){
            vi d;
            rep(i,n)if(ito[i]!=-1)d.pb(i);
            ll from=inf,go;
            for(ll j: d){
             	bool b=false;
                for(ll x: v[j]){
                    if(x!=ito[j]&&ito[x]!=-1){
                        from=j;
                        go=x;
                      	b=true;
                        break;
                    }
                }
              	if(b)break;
            }
            if(from==inf){
                cout<<d.size()<<endl;
                rep(i,d.size())cout<<d[i]+1<<endl;
                return 0;
            }
            ll j=from;
            while(true){
                ll k=ito[j];
                ito[j]=-1;
                j=k;
                if(j==go)break;
            }
            ito[from]=go;
            }
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 55168
#include <stdio.h>

int main(){
	int a;
	int b;
	int c;
	scanf("%d %d %d",&a,&b,&c);
	if (a<b && a<c && b<c){
		printf("Yes\n");}
	if (a>=b){
	printf("No\n");}else if(b>=c){
	printf("No\n");}else if(a>=c){
	printf("No\n");}
	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<cstdio>
#include<queue>

using namespace std;

queue<int> Q;
int A[52][52];
int UP[8]  ={-1, -1, 1, 0, 1, 1, 1, 0};
int SIDE[8]={-1, 0, 1, 1, 1, 0, -1, -1};


void route(int w,int h){

  A[w][h]=0;
  if(A[w+1][h+1]==1)route(w+1,h+1);
  if(A[w+1][h]==1)route(w+1,h);
  if(A[w+1][h-1]==1)route(w+1,h-1);
  if(A[w][h+1]==1)route(w,h+1);
  if(A[w][h-1]==1)route(w,h-1);
  if(A[w-1][h+1]==1)route(w-1,h+1);
  if(A[w-1][h]==1)route(w-1,h);
  if(A[w-1][h-1]==1)route(w-1,h-1);


}

int main(){
  int w,h;
  int count;
  while(true){
    cin>>w>>h;
    if(w==0&&h==0)break;
    for(int i = 1;i<=h;i++){
      for(int j = 1;j<=w;j++){
	cin>>A[i][j];
     
      }
    }
    count=0;
    for(int i = 1;i<=h;i++){
      for(int j = 1;j<=w;j++){
	if(A[i][j]==1){
	  //	  cout<<i<<" "<<j<<endl; 
	  route(i,j);
	  count++;
	}
      }
    }

    //デバック
   
    /*     for(int i = 1;i<=h;i++){
      for(int j = 1;j<=w;j++){
	cout<<" "<<A[i][j];
      }
      cout <<endl;
      }*/
    
    cout<<count<<endl;
   }
  return 0;

}

Measured memory_bytes: 0
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int keta = String.valueOf(N).length();


		PrintWriter out = new PrintWriter(System.out);

		switch (keta) {
		case 1:
			out.println(N);
			break;
		case 2:
			out.println(9);
			break;
		case 3:
			out.println(9 + (N - 99));
			break;
		case 4:
			out.println(909);
			break;
		case 5:
			out.println(909 + (N - 9999));
			break;
		case 6:
			out.println(90909);
			break;

		default:
			break;
		}


		out.flush();
	}

	public static int gcd(int a, int b) {
	    if (b == 0) return Math.abs(a);
	    return gcd(b, a % b);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 22740
//
//  main.cpp
//  A
//
//  Created by 黄宇凡 on 2017/3/12.
//  Copyright © 2017年 黄宇凡. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

long long T[maxn];
long long K,C;
int n;

int main(int argc, const char * argv[]) {
    cin >> n;
    cin >> C >> K;
    for(int i = 1;i <= n;i++){
        int t;
        scanf("%d",&t);
        T[i] = t;
    }
    sort(T + 1,T + 1 + n);
    int num = 0;
    long long s;
    for(int i = 1,j = 1;i <= n;i = j + 1,j = i){
        s = T[i] + K;
        while(j < n && j - i + 1 < C && T[j + 1] <= s){
            j++;
        }
        num++;
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N;
  cin >> N;
  vector<int> T(N);
  REP(i, N) cin >> T[i];
  
  int M;
  cin >> M;

  vector<vector<int>> A(M,vector<int>(2));
  REP(i, M){
    REP(j, 2){
      cin >> A.at(i).at(j);
    }
  }
  
  vector<int> S(N);

  REP(i,M){
    REP(j,N){
      S.at(j) = T.at(j);
    }
    S.at(A.at(i).at(0)-1) = A.at(i).at(1);
    int sum = 0;
    REP(j,N){
      sum+=S.at(j);
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional> 

using namespace std;

#define mp make_pair
#define pb push_back
#define pf push_front
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int (i)=0;(i)<(n);++(i))
#define rep(i,st,ed) for(register int (i)=(st);(i)<=(ed);++(i))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<typename T> inline T qmin(const T a,const T b) {return a<b?a:b;}
template<typename T> inline T qmax(const T a,const T b) {return a>b?a:b;}
template<typename T> inline void getmin(T &a,const T b) {if(a>b) a=b;}
template<typename T> inline void getmax(T &a,const T b) {if(a<b) a=b;}

inline void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=1e9+7;
const ll linf=1e17+7;
const int N=507;

char s[N][N];
int rnum[N],cnum[N];
int n,ans;

int main(){
	scanf("%d",&n);
	bool haveans=false;
	for(int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
		for(int j=1;j<=n;++j){
			if(s[i][j]=='#') ++rnum[i],++cnum[j],haveans=true;
		}
	}
	if(!haveans) return puts("-1"),0;
	ans=inf;
	for(int i=1;i<=n;++i){
		int need=0,rest=n;
		for(int j=1;j<=n;++j){
			if(s[i][j]=='#'){
				bool flag=true;
				for(int k=1;k<=n;++k) if(s[k][j]=='.'){
					flag=false;
					break;
				}
				rest-=flag;
			}else{
				bool flag=false;
				for(int k=1;k<=n;++k){
					if(s[k][j]=='.') continue;
					flag=true;
					if(rnum[k]==n){--rest;break;}
				}
				++need;
				if(flag) continue;
				if(i==j) ++need;
			}
		}
		getmin(ans,need+rest);
	}
	printf("%d\n",ans);
	return 0;
} 

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

int main() {
  string S;
  ll K;
  cin >> S >> K;

  ll ans = 0;
  ll N = S.size();

  ll check = true;
  rep0(i, N) {
    if (S[i] != S[0]) check = false;
  }
  if (check) {
    cout << (N * K / 2) << BR;
    return 0;
  }

  ll ans0 = 0, ans1 = 0, ans2 = 0;
  string S2 = S + S + S;

  rep0(i, 3 * N - 1) {
    if (S2[i] == S2[i + 1]) {
      S2[i + 1] = 'X';

      if(i / N == 0) ans0++;
      else if(i / N == 1) ans1++;
      else ans2++;
    }
  }

  ll k = K / 2;
  if (K == 1) {
    ans = ans0;
  } else if (K == 2) {
    ans = ans0 + ans1;
  } else {
    ans = ans0 + (K - 2) * ans1 + ans2;
  }

  cout << ans << BR;
  return 0;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll r;
    cin>>r;
    ll f=r*r;
    cout<<f;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int a, b, c;
	cin >> a >> b >> c;
	set<int> num;
	num.insert(a);
	num.insert(b);
	num.insert(c);
	cout << num.size() << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
cnt = 0
B = list(map(int, input().split()))

for i in range(N):
    A = list(map(int, input().split()))
    ans = 0
    for j in range(M):
        ans += A[j] * B[j]

    ans += C
    if ans > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
# from bisect import bisect_left,bisect_right
# from collections import Counter

a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))


a=a1+a2+a3

n=int(input())

b=[]
for i in range(n):
    b.append(int(input()))

def aru(n):
    if n in b:
        return True
    else:
        return False
# print(a)
ans=[aru(aa) for aa in a]
    
    
# print(ans)

if (ans[0]*ans[1]*ans[2]==1 or ans[4]*ans[5]*ans[3]==1 or
ans[7]*ans[8]*ans[6]==1 or ans[0]*ans[3]*ans[6]==1 or 
ans[1]*ans[4]*ans[7]==1 or ans[2]*ans[5]*ans[8]==1 or
ans[0]*ans[4]*ans[8]==1 or ans[2]*ans[4]*ans[6]==1):
    print("Yes")
else:
    print("No")
    

# h=list(map(int,input().split()))
# l=sorted(list(map(int,input().split())))



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int K=sc.nextInt();

		long dp[][] = new long[H+1][W];
		dp[0][0]=1;

		int MOD = 1000000007;
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				for(int k=0; k<(1<<W-1); k++) {
					boolean ok = true;
					for(int l=0; l<(1<<W-2); l++) {
						if(((k>>l)&1)==1 && ((k>>(l+1))&1)==1){
							ok=false;
						}
					}
					if(ok) {
						if(j>0 && ((k>>(j-1))&1) == 1) {
							dp[i+1][j-1] += dp[i][j];
							dp[i+1][j-1] %= MOD;
						}
						else if(j<W-1 && ((k>>j)&1)==1){
							dp[i+1][j+1] += dp[i][j];
							dp[i+1][j+1] %= MOD;
						}else {
							dp[i+1][j] += dp[i][j];
							dp[i+1][j] %= MOD;
						}
					}

				}
			}
		}
		System.out.println(dp[H][K-1]);
		sc.close();
	}

}


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




int main(){

  int n;
  cin >> n;

  int count = 0;
  for(int i=1; i<=n; i++){
    if(n%i==0){
      count += n/i - 1;
    }else{
      count += n/i;
    }
  }
  cout << count <<endl;
}

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

int main() {
    
    
    
    int num;
  
    cin >> num;
  
  int gou = num;
  
    int digit=0;
    while(gou!=0){
        gou /= 10;
        digit++;
    }
    
  if (digit == 6){
   cout << 90909 << endl;
  }
  
  if( digit == 5){
    cout << num - 9999 + 909 <<endl;
  }
  
      if (digit == 4){
        cout << 909 << endl;
      }
  
  if( digit == 3){
    cout << num - 99 + 9 << endl;
  }
  
    if (digit == 2){
      cout << 9 << endl;
    }
  
  if( digit == 1){
    cout << num << endl;
  }
  
  
}


Measured memory_bytes: 256