akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int n; cin >> n;
  vector<ll> a(n),b(n),c(n);
  rep(i, n) cin >> a[i]; sort(all(a));
  rep(i, n) cin >> b[i]; sort(all(b));
  rep(i, n) cin >> c[i]; sort(all(c));

  ll ans = 0LL;
  rep(i, n){
    ll ai = lower_bound(all(a),b[i]) - a.begin();
    ll ci = upper_bound(all(c),b[i]) - c.begin();
    //printf("ai:%d ci:%d\n", ai, ci);
    ans += ai*(n-ci);
  }

  std::cout << ans << '\n';
}


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

using namespace std;
typedef long long ll;

void push(char C, int time){
	for (int i = 0; i < time; i++)
	{
		cout << C;
	}
}

int main(int argc, char const *argv[])
{
	int sx,sy,tx,ty;
	cin >>sx>>sy>>tx>>ty;

	push('U',ty-sy);
	push('R',tx-sx);
	push('U',1);
	push('L',tx-sx+1);
	push('D',ty-sy+1);
	push('R',1);
	push('R',tx-sx);
	push('U',ty-sy);
	push('R',1);
	push('D',ty-sy+1);
	push('L',tx-sx+1);
	push('U',1);
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<vector<pair<int,int>>>v(N);
	for (int i = 0; i < N; i++) {
		cin >> K;
		for (int j = 0; j < K; j++) {
			cin >> L >> R;
			L--;
			v[i].push_back({ L,R });
		}
	}
	int ans = 0;
	for (int i = 0; i < 1 << N; i++) {
		bool can = true;
		for (int j = 0; j < N; j++) {
			if ((i >> j) & 1) {
				for (auto k : v[j]) {
					if (((i >> k.first) & 1) != k.second)can=false;
				}
			}
		}
		if (can) {
			int num = 0;
			for (int j = 0; j < N; j++) {
				num += (i >> j) & 1;
			}
			ans = max(ans, num);
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    REP(i,n)cin>>a[i];
    for(int i=n-1;i>0;i--)cout<<a[i]<<" ";
    cout<<a[0]<<endl;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<int>> a(h,vector<int>(w,0)),b(h,vector<int>(w,0));;
    for (int i = 0;i < h;++i) cin >> s[i];
    for (int i = 0;i < h;++i) {
        int k = -1,sum = 0;
        for (int j = 0;j < w;++j) {
            if (s[i][j] == '#') {
                for (int l = j-1;l > k;--l) a[i][l] = sum;
                k = j;
                sum = 0;
            } else sum++;
        }
        for (int l = w-1;l > k;--l) a[i][l] = sum;
    }
    for (int j = 0;j < w;++j) {
        int k = -1,sum = 0;
        for (int i = 0;i < h;++i) {
            if (s[i][j] == '#') {
                for (int l = i-1;l > k;--l) b[l][j] = sum;
                k = i;
                sum = 0;
            } else sum++;
        }
        for (int l = h-1;l > k;--l) b[l][j] = sum;
    }
    // for (int i = 0;i < h;++i) p_ary(a[i],0,w,j);
    // cout << endl;
    // for (int i = 0;i < h;++i) p_ary(b[i],0,w,j);
    int ans = 0;
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) ans = max(ans,a[i][j]+b[i][j]-1);
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < N; i++) {
		cout << S.substr(i, 1) << T.substr(i, 1);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt64()
	if isPrime(n) == true {
		fmt.Println(n - 1)
		return
	}

	_, divlist := getDivlistSlow(n)
	sort.Slice(divlist, func(i int, j int) bool {
		return divlist[i] < divlist[j]
	})

	var minwalk int64 = n
	for _, v := range divlist {
		nowwalk := (v - 1) + (n/v - 1)
		minwalk = min(minwalk, nowwalk)
		if v*v > n {
			break
		}
	}
	fmt.Println(minwalk)
}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}

// 約数列挙リストを作成(愚直)
func getDivlistSlow(a int64) (cnt int64, divlist []int64) {
	for i := int64(1); i*i <= a; i++ {
		if a%i == 0 {
			cnt++
			divlist = append(divlist, i)
			if i*i != a { // 6*6=36 などを重複カウントしない
				cnt++
				divlist = append(divlist, a/i)
			}
		}
	}
	return cnt, divlist
}

// 素数判定
func isPrime(a int64) bool {
	for i := int64(2); i*i <= a; i++ {
		if a%i == 0 {
			return false
		}
	}
	return true
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
int n,x;
  cin >> n >> x;
int a[n];
  for(int i=0;i<n;i++){
  cin >> a[i];  
  }
  sort(a,a+n);
  int count=0;
for(int i=0;i<n;i++){
  x-=a[i];
 count++;
  if(x<=0)break;
} 

 
  if(x==0) cout << count << endl;
  else    cout << count-1 << endl;
}

Measured memory_bytes: 3628
n, a, b, c = map(int,input().split())
s = [input() for i in range(n)]
dic = {'A':a, 'B':b, 'C':c}
l = []
for i in range(n):
    temp1 = s[i][0]
    temp2 = s[i][1]
    if dic[temp1] == 0 and dic[temp2] == 0:
        print('No')
        exit()

    if dic[temp1] < dic[temp2]:
        dic[temp1] += 1
        dic[temp2] -= 1
        l.append(temp1)
    elif dic[temp1] == dic[temp2] and i != n - 1:
        n1, n2 = s[i + 1]
        if (n1, n2) == (temp1, temp2):
            dic[temp2] += 1
            dic[temp1] -= 1
            l.append(temp2)
        else:
            if temp1 == n1 or temp1 == n2:
                dic[temp1] += 1
                dic[temp2] -= 1
                l.append(temp1)
            else:
                dic[temp2] += 1
                dic[temp1] -= 1
                l.append(temp2)
    else:
        dic[temp2] += 1
        dic[temp1] -= 1
        l.append(temp2)
print('Yes')
print(*l, sep = '\n')

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

int main(void) {
	int n,x=0,max=-1000;
	string s;
	cin >> n >> s;
	for(int i = 0; i < s.length(); i++){
		if(s[i]=='I') x++;
		else x--;
		if(x>max) max = x;
	}
	if(max < 0) max=0;
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
S = gets.chomp

ans = 0
cnt = 1
e = S.each_char
c = e.next
loop do
  s = e.next
  if c == s
    cnt += 1
  else
    cnt -= 1
    ans += 2
    if cnt == 0
      cnt = 1
      c = e.next
    end
  end
end
puts ans


Measured memory_bytes: 2044
#include <iostream>

using namespace std;

int main(void)
{
    int N;
    int a;
    cin >> N;
    int ans = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
from collections import Counter
c0 = Counter(a[::2])
c1 = Counter(a[1::2])
kv0 = [(v,k) for k,v in c0.items()]
kv1 = [(v,k) for k,v in c1.items()]
kv0.sort()
kv1.sort()
if kv0[-1][1]!=kv1[-1][1]:
    ans = len(a[::2])-max(c0.values()) + len(a[1::2])-max(c1.values())
else:
    vals = []
    if len(kv0)>len(kv1):
        kv0, kv1 = kv1, kv0
    v0 = sum(item[0] for item in kv0)
    v1 = sum(item[0] for item in kv1)
    if len(kv0)==1:
        if len(kv1)==1:
            ans = min(v0, v1)
        else:
            ans = min(v0+v1-kv0[-1][0]+kv1[-2][0], v0+v1-kv1[-1][0])
    else:
        ans = min(v0+v1-kv0[-1][0]-kv1[-2][0], v0+v1-kv0[-2][0]-kv1[-1][0])
print(ans)

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

using namespace std;

vector<int> dp;
vector<vector<int>> G;

int rec(int u) {
  if (dp[u] != -1) return dp[u];
  int res = 0;
  for (int v : G[u]) {
    res = max(res, rec(v) + 1);
  }
  return dp[u] = res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  G.resize(N), dp.resize(N, -1);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].emplace_back(y);
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    res = max(res, rec(i));
  }
  cout << res << '\n';
  return 0;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  int c[55] = {};
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    c[a]++;
    c[b]++;
  }
  
  for (int i = 1; i <= n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare_string(const void *a, const void *b) {
  return strcmp(( char * )a , ( char * )b );
}

int main(void){
  int i,j;
  char ii[200000][11];
  char aa[11];
  int len,flg;
  int cnt,maxcnt;
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%s\n",ii[i]);
  }

  qsort(ii,  len,sizeof(ii[0]), compare_string);
  
  maxcnt = 1;	
  cnt = 1;
  for(i=1;i<len;i++){
    if (strcmp(ii[i-1],ii[i]) == 0){
      cnt++;	
      if(maxcnt < cnt){
        maxcnt = cnt;
      }
    }
    else{
      cnt=1;
    }
  }

  cnt = 1;
  for(i=0;i<len;i++){
    if (maxcnt == 1){
      printf("%s\n",ii[i]);
    }
    if (strcmp(ii[i-1],ii[i]) == 0){
      cnt++;	
      if(maxcnt <= cnt){
        printf("%s\n",ii[i]);
      }
    }
    else{
      cnt=1;
    }
  }
  return 0;
}


Measured memory_bytes: 4476
a, b, k = map(int, input().split())

lower_list = [i for i in range(a, a + k)]
upper_list = [i for i in range(b, b - k, -1)]
out_list = sorted(set(lower_list + upper_list))

for out_val in out_list:
    if a <= out_val <= b:
        print(out_val)

Measured memory_bytes: 3060
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        double sum = 0, hp = 0;

        for (int i = 0; i < n; i++)
        {
            sum += input[i];
        }

        for (int i = 0; i < n; i++)
        {
            hp += Math.Pow(input[i] - Math.Round(sum / n), 2.0);
        }

        Console.WriteLine(hp);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b,x;
	int Aml,Bml;
	int i,j;
	int min;
	
	cin>>a>>b>>x;
	Aml=x/1000; Bml=x/500;
	if(x%1000!=0) Aml++;
	if(x%500!=0) Bml++;
	min=(a+b)*(Aml+Bml);
	for(i=0;i<=Aml;i++){
		for(j=0;j<=Bml;j++){
			if(i*1000+j*500<x) continue;
			if(min>i*a+j*b){
				min=i*a+j*b;
				//printf("i=%d j=%d\n",i,j);
			}
		}
	}
	cout<<min<<endl;
	
	return 0;
}


Measured memory_bytes: 3136
fn main() {
    proconio::input! {
        a: [[u8;3];3],
        n: usize,
        b: [u8;n],
    }
    let mut c=[[false;3];3];
    for b in b {
        for i in 0..3 {
            for j in 0..3 {
                if a[i][j]==b {
                    c[i][j]=true;
                }
            }
        }
    }
    for i in 0..3 {
        let mut f1=true;
        let mut f2=true;
        for j in 0..3 {
            f1 = f1 && c[i][j];
            f2 = f2 && c[j][i];
        }
        if f1 || f2 {
            println!("Yes");
            return;
        }
    }
    let mut f1=true;
    let mut f2=true;
    for i in 0..3 {
        f1 = f1 && c[i][i];
        f2 = f2 && c[i][2-i];
    }
    if f1 || f2 {
        println!("Yes");
        return;
    }
    println!("No");
}

Measured memory_bytes: 2148
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

N = int(read())

def test(S):
    f,e,s,t,i,v,a,l = 0,0,0,0,0,0,0,0
    for x in S:
        if x == 'F':
            f += 1
        elif x == 'E':
            e += f
        elif x == 'S':
            s += e
        elif x == 'T':
            t += s
        elif x == 'I':
            i += t
        elif x == 'V':
            v += i
        elif x == 'A':
            a += v
        elif x == 'L':
            l += a
    return l

test('FESSSSSSSTIVAL'),test('FFEESSTTIIVVAALL')

A = [x * 200 + 'FESTIVA' for x in [''] + list('FESTIVA')]
B = list(itertools.accumulate(A))

# 各単語の直後にLを挿入する価値
value = [test(word+'L') for word in B]

cnt = [0] * 8
rest = N
for n in range(7,-1,-1):
    q,r = divmod(rest,value[n])
    rest = r
    cnt[n] = q

answer = ''
for x,y in zip(A,cnt):
    answer += x + 'L' * y

print(answer)

Measured memory_bytes: 3188
// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    ll n,ans=1;
    cin>>n;
    cinv(a,n)
    FOR(i,0,n)
    {
    	if(a[i]==0){cout<<0;return 0;}
    }
    
    FOR(i,0,n)
    {
    	if(a[i]<=1000000000000000000/ans)
    	{
    		ans*=a[i];
    	}
    	else{cout<<-1;return 0;}
    }
    cout<<ans;
    return 0;
}


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

vector<vector <int>> c;

void pre(int id) {
	if (id == -1)
		return;
	cout << " " << id;
	pre(c[id][0]);
	pre(c[id][1]);
}

void in(int id) {
	if (id == -1)
		return;
	in(c[id][0]);
	cout << " " << id;
	in(c[id][1]);
}

void post(int id) {
	if (id == -1)
		return;
	post(c[id][0]);
	post(c[id][1]);
	cout << " " << id;
}

int main()
{
	int n = 0, id = 0;

	cin >> n;

	c.resize(n);
	vector<int> p(n, -1);

	for (int i = 0; i < n; i++) {
		int l = 0, r = 0;
		cin >> id >> l >> r;
		c[id].push_back(l);
		c[id].push_back(r);

		if (l != -1)
			p[l] = id;
		if (r != -1)
			p[r] = id;
	}

	cout << "Preorder" << endl;

	int r = 0;

	for (int i = 0; i < n; i++) {
		if (p[i] == -1) {
			r = i;
			break;
		}
	}

	pre(r);

	cout << endl << "Inorder" << endl;

	in(r);	

	cout << endl << "Postorder" << endl;

	post(r);

	cout << endl;

	return 0;
}

Measured memory_bytes: 3164
// 2015/01/19 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int N, W;
	cin >> N >> W;

	int v[100];
	int w[100];
	for(int i=0; i<N; i++){
		cin >> v[i] >> w[i];
	}

	int dp[10001] = {0};

	for(int i=0; i<N; i++){
		for(int j=W; j>=w[i]; j--){
			dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
		}
	}

	cout << dp[W] << endl;

	return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){

char str[22];
char t[25];
int i,j,k;

scanf("%s",str);

k=strlen(str);

for(i=k-1,j=0;i>=0;i--,j++){
t[j]=str[i];
}
t[j]='\0';

printf("%s\n",t);
return 0;
}

Measured memory_bytes: 524
n = int(input())
lst = [int(x) for x in input().split()]
a = 0
for i in range(n):
    lst[i] = lst[i] - (i + 1)
lst.sort()
def sum(k):
    a = 0
    for i in range(n):
        a += abs(lst[i]-k)
    return a
ans = 0
if ans % 2 == 0:
    ans = min([sum(lst[int(n/2)-1]),sum(lst[int(n/2)])])
else:
    ans = sum(lst[int(n/2)])
print(str(ans))

Measured memory_bytes: 26180
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
#include <map>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll N;
    cin >> N;
    vector<ll> t(N+1);
    t[1] = 1;
    for(ll i=2;i<N+1; i+=2)
        t[i] = 2;
    for(ll i=3;i<N+1; i+=2) {
        for (ll j=i; j<N+1; j += i) {
            if (t[j] == 0)
                t[j] = i;
        }
    }
    auto f = [&](ll k) {
        map<int,int> m;
        while(k>1) {
            ll q = t[k];
            m[q]++;
            k /= q;
        }
        ll s=1;
        for (auto& p : m) {
            s *= p.second + 1;
        }
        return s;
    };
    ll ans=0;
    for (ll k=1; k<=N; ++k) {
        ans += k*f(k);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80980
n, k = map(int, input().split())

ans = 0

if k == 0:
  print(n**2)
  exit()

for b in range(k+1, n+1):
  c = n//b
  r = n%b
  #print((b-k)*c+max(0, r-k+1))
  ans += (b-k)*c+max(0, r-k+1)
print(ans)

Measured memory_bytes: 39280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(long long i = 0;i < n;i++)
int main(){
   long long n,a,b,c,d,e,x,ans;
   cin >> n >> a >> b >> c >> d >> e;
   x = min(min(min(min(a,b),c),d),e);
   ans = (n - 1)/x + 5;
   cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
 
int N;
int A[100010];
int ans = 1;
 
int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++){scanf("%d",&A[i]);if(i != 0 && A[i] == A[i - 1]){N--;i--;}}
    for(int i = 0; i < N - 2; i++)
    {
        if((A[i] <= A[i + 1] && A[i + 1] <= A[i + 2]) || (A[i] >= A[i + 1] && A[i + 1] >= A[i + 2]));
        else {ans++;i++;}
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
int main()
{
    int n,a,b;
	std::cin >> n >> a >> b;
	if(n*a<b )
	{
		std::cout<<n*a;
	}
	else if(n*a>b)
	{
		std::cout<<b;
	}
	else if(n*a==b)
	{
       std::cout<<n*a;
	}

}

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

int main(){
	int n, x;
	int i, j, k;
	int sum=0;

	while(1){
		scanf("%d %d", &n, &x);
		
		if((x == 0)&&(n == 0))
			break;
		sum = 0;
		for(i=1; i<=n; i++){
			for(j=i+1; j<=n; j++){
				for(k=j+1; k<=n; k++){
					if(x == i+j+k){
				/*		printf("%d, %d, %d\n", i, j, k);*/
						sum = sum + 1;
					}
				}
			}
		}
		printf("%d\n", sum);

	}

	return 0;

}


Measured memory_bytes: 2040
a=int(input())
ans = 0
tmp = 2 
while tmp*tmp <=a:
    ct = 0 
    while not a % tmp:
        ct+=1
        a/=tmp
    for i in range(1,ct+1):
        if (1+i)*i/2<=ct:
            ans+=1
        else:
            break
    tmp+=1
if a != 1:
    ans+=1
print(ans)

Measured memory_bytes: 9256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> c(9);
    rep(i, n)
    {
        int r = a[i] / 400;
        if (r >= 9)
            r = 8;
        c[r]++;
    }
    int cnt = 0;
    rep(i, 8) if (c[i] > 0) cnt++;
    int mn = cnt;
    if (mn == 0)
        mn++;
    int mx = cnt + c[8];
    printf("%d %d\n", mn, mx);
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int N;
    cin >> N;
    char tmp;
    bool flag = false;
    REP(i, N) {
        cin >> tmp;
        if(tmp == 'Y') flag = true;
    }
    if(flag) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
N=int(input())
S=[input() for i in range(N)]
a=0
w=0
t=0
r=0

for i in range(N):
    if S[i]=="AC":
        a+=1
    elif S[i]=="WA":
        w+=1
    elif S[i]=="TLE":
        t+=1
    elif S[i]=="RE":
        r+=1
print("AC x "+str(a))
print("WA x "+str(w))
print("TLE x "+str(t))
print("RE x "+str(r))

Measured memory_bytes: 79156
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
int main()
{
    ft
    ll t,i,j,n,m,l=1,r;
    cin>>s>>p;
    n=s.size();
    m=p.size();
    for(i=0,j=0;i<n || j<m;)
    {
        if(l%2==1)
        {
            cout<<s[i];
            i++;
        }
        else
        {
            cout<<p[j];
            j++;
        }
        l++;
    }
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}



int main(){
    int n,k;
    cin >> n >> k;
    vint p(n);
    rep(i,n) cin >> p[i];
    sort(all(p));
    int ans = 0;
    rep(i,k){
        ans += p[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <math.h>

#define REP(i, n) for (int i = 0; i < n; i++)

typedef int long long ill;
typedef int long il;

using namespace std;

#define N 100
#define L 100
int n, l;

vector<string> ss;
void set();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> l;
    vector<string> s(n);
    REP(i, n)
    {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    REP(i, n)
    {
        cout << s[i];
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (W, H, N) = readInts()
  var (l, r, t, b) = listOf(0, W, H, 0)
  for (i in 0 until N) {
    val (x, y, a) = readInts()
    when (a) {
      1 -> l = Math.max(l, x)
      2 -> r = Math.min(r, x)
      3 -> b = Math.max(b, y)
      4 -> t = Math.min(t, y)
      else -> throw Error()
    }
  }
  if ((r - l) < 0 || (t - b) < 0) {
    println(0)
  } else {
    println((r - l) * (t - b))
  }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 37744
package main

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

var scan = bufio.NewScanner(os.Stdin)

func main() {
	scanWords()

	list := make([]int, 0, 3)
	for i := 0; i < cap(list); i++ {
		list = append(list, readNextInt())
	}

	sort.Sort(sort.IntSlice(list))
	fmt.Printf("%d %d %d\n", list[0], list[1], list[2])
}

func scanWords() {
	scan.Split(bufio.ScanWords)
}

func readNextInt() int {
	scan.Scan()

	input, err := strconv.Atoi(scan.Text())
	if err != nil {
		panic(err)
	}

	return input
}



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

int main(){
	int N;
	cin >> N;
	int p[N];
	for(int i = 0;i < N;i++)cin >> p[i];
	for(int i = 0;i < N;i++){
		for(int j = i + 1;j < N;j++){
			if(p[i] < p[j]){
				p[i] ^= p[j];
				p[j] ^= p[i];
				p[i] ^= p[j];
			}
		}
	}
	p[0] /= 2;
	int sum = 0;
	for(int i = 0;i < N;i++)sum += p[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <unordered_map>
#include <queue>
#define rep0(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){


  int i,j,k,l,n,m,s,ans=0;
  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq;

  cin >> k >> s;
  
  rep0(x,k+1)rep0(y,k+1){
    if(s-x-y < 0)continue;
    if(s-x-y > k)continue;
    ans++;
  }



  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
s = list(input())
if s[1] == 'S':
    if s[0] == 'S' and s[2] == 'S':
        print(0)
    else:
        print(1)
else:
    if s[0] == 'R' and s[2] == 'R':
        print(3)
    elif s[0] == 'S' and s[2] == 'S':
        print(1)
    else:
        print(2)

Measured memory_bytes: 9044
N, K = map(int, input().split())
S = list(map(int, input()))
lst = []
cnt = 0
now = 1

for i in range(N):
	if S[i] == now:
		cnt += 1
	else:
		lst.append(cnt)
		cnt = 1
		now = 1 - now
		
lst.append(cnt)

#1 0 1 0 1の形にしたい
if len(lst) % 2 == 0:
	lst.append(0)

ret = 0
add = 2 * K + 1
left = 0
right = 0
total = 0

for i in range(0, len(lst), 2):
	nextleft = i
	nextright = min(i + add, len(lst))
	while nextleft > left:
		total -= lst[left]
		left += 1
	while nextright > right:
		total += lst[right]
		right += 1
	ret = max(ret, total)
	
print(ret)

Measured memory_bytes: 48220
#include <bits/stdc++.h>
using namespace std;
int a,t,Max = -1;   
char c[110];        
int main() {
    scanf("%d%s",&a,&c);
    for(int i = 0 ; i < a ; ++ i){
        if(c[i] == 'I') {       
            t++;
        }
        else 
          t--;              
        Max=max(Max,t);       
    }
    if(Max == -1) Max = 0;      
    printf("%d",Max);           
    return 0;
}

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

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

long long MOD = 1000000000 + 7;
ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);

    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    cout << setprecision(10);

    int N;
    cin >> N;
    ll ans;

    for (int i = 0; i < N; i++)
    {
        ll tmp;
        cin >> tmp;
        if (i == 0)
        {
            ans = tmp;
        }
        else
        {
            ans = gcd(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.next()

    val result = (n.charAt(0) == n.charAt(1) && n.charAt(1) == n.charAt(2))

    val ans = if (result) "No" else "Yes"
    println(ans)
  }
}


Measured memory_bytes: 25540
#include<iostream>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	ll a[100005];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	if(n==1){
		cout<<"Yes";
		return 0;
	}
	ll flag=0;
	ll sum=a[0];
	for(int i=1;i<n;i++){
		if(a[i]>sum){
			sum=a[i];
		}
		if(a[i]<=sum-2){
			flag=1;
			break;
		}
	}
	if(flag)
		cout<<"No";
	else
	 	cout<<"Yes";

	return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> x(n);
	for (auto& a : x) cin >> a;
	int ans = 1e9;
	for (int i = 1; i <= 100; ++i) {
		int tmp = 0;
		for (int j = 0; j < n; ++j)
			tmp += (x[j] - i) * (x[j] - i);
		ans = min(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string s;
	cin >> s;
	int n = s.length(), i, j, k;
	for (i = 0; i < n; i++) cout << "x";
	cout << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b;
char p;

while(1){
scanf("%d %c %d",&a,&p,&b);
if(p=='?'){
break;
}else if(p=='+'){
printf("%d\n",a+b);
}else if(p=='-'){
printf("%d\n",a-b);
}else if(p=='*'){
printf("%d\n",a*b);
}else if(p=='/'){
printf("%d\n",a/b);
}
}
return 0;
}

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

const ll MAX = 1e18;

int main() {
    ll N; cin >> N;
    ll tmpT, tmpA; cin >> tmpT >> tmpA;
    ll T, A;
    ll mid, ok, ng, nowT, nowA;
    for (ll i = 1; i < N; i++) {
        cin >> T >> A;
        ng = 0; ok = MAX;
        while(abs(ok-ng) > 1) {
            mid = (ok+ng)/2;
            nowT = (tmpT%mid? tmpT/mid+1:tmpT/mid);
            nowA = (tmpA%mid? tmpA/mid+1:tmpA/mid);
            if (T < nowT || A < nowA) ng = mid;
            else ok = mid;
        }
        tmpT = ok*T;
        tmpA = ok*A;
        //cout << tmpT + tmpA << endl;
    }
    cout << tmpA + tmpT << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    if(s.back() == 's') s += "es";
    else s += "s";
    cout << s << endl;
}


Measured memory_bytes: 3648
from itertools import product

H, W, K = map(int, input().split())
grid = ""

for _ in range(H):
  grid += input()

ans = 10000

for Hcut in product((0, 1), repeat = H-1):
  Gr_num = sum(Hcut) + 1
  old = [0]*Gr_num
  cnt = 0
  for i in range(W):
    #縦一列のchocoを見る
    choco = grid[i::W]
    new = [0]*Gr_num
    gr = 0
    for j in range(H):
      new[gr] += int(choco[j])
      if j < H-1:
        if Hcut[j] == 1:
          gr += 1
    #そもそも一列でオーバーしてたら詰み。
    if max(new) > K:
      cnt += 10000
      break
    #新しい一列を追加しても大丈夫か確認
    check = [old[gr] + new[gr] for gr in range(Gr_num)]
    if max(check) > K:
      old = new[:]
      cnt += 1
    else:
      old = check[:]
  ans = min(ans, cnt+sum(Hcut))

print(ans)

Measured memory_bytes: 74864
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>

#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void){
    int D;
    int N;
    cin >> D >> N;
    int x;
    if(D == 0) {
        x = 1;
        if(N != 100){
            cout << x*N << endl;
        }else{
            cout << x*N + 1 << endl;
        }
    }
    if(D == 1) {
        x = 100;
        if(N != 100){
            cout << x*N << endl;
        }else{
            cout << x*N + 100 << endl;
        }
    }
    if(D == 2) {
        x = 10000;
        if(N != 100){
            cout << x*N << endl;
        }else{
            cout << x*N + 10000 << endl;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var X = r[0];
            var Y = r[1];
            var Z = r[2];
            var remain = X - (Y + 2 * Z);
            int ret = 1;
            while (remain >= Y + Z)
            {
                ret++;
                remain -= Y + Z;
            }
            Console.WriteLine(ret);
        }

    }
}

Measured memory_bytes: 11348
N, X = map(int, input().split())
a,p=[1],[1] 
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
def f(N,X): #X<=0やX>a_Nを許容し解説本文から簡略化
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))

Measured memory_bytes: 3064
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 100000000001
for i in range(n-k+1):
  x = a[i]
  y = a[i+k-1]
  if x*y > 0:
    ans = min(max(abs(x),abs(y)),ans)
  else:
    ans = min(ans, min(abs(x)*2+abs(y),abs(x)+abs(y)*2))
print(ans)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

vector<ll> prime(1000000);
bool is_prime[1000001];

ll copy(ll x){
	return x;
}


ll sieve(ll n){
	ll p = 0;
	for(int i = 0; i <= n; i++) {//初期化
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; i++) {
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2 * i; j <= n; j+= i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}
int main(){
	int n;cin>>n;
	vector<ll> ans;
	sieve(55555);
	ll i = 0;
	ll x = 0;
	while(x < n){
		if((prime[i] % 5LL) == 1LL){
			ans.pb(prime[i]);
			x++;
		}
		i++;
	}
	for(int i = 0; i < n; i++) {
		cout << ans[i] << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,x; cin >> n >> x;
  vi a(n); rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,n-1){
    if(x < a[i]+a[i+1]){
      ans += a[i+1]+a[i]-x;
      a[i+1] = max(0,x-a[i]);
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 0;
    priority_queue<P> q;
    rep(i, 0, n) q.push({a[i], i});
    while(m--){
        P p = q.top(); q.pop();
        p.first /= 2;
        a[p.second] = p.first;
        q.push(p);
    }
    rep(i, 0, n){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
        cout << "Bad" << endl;
        return 0;
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 3620
package main

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

func main() {
	var (
		In              = ReadLineInt()
		SourceCodeCount = In[0]
		//UniqueCount     = In[1]
		C      = In[2]
		B      = ReadLineInt()
		Result = 0
	)

	for i := 0; i < SourceCodeCount; i++ {
		Input := ReadLineInt()
		Current := C
		for i, A := range Input {
			Current += A * B[i]
		}

		if Current > 0 {
			Result++
		}
	}

	fmt.Println(Result)
}

/////////////////////////////////////////

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,x;
  long long d[100010];
  long long div[100000] = {};
  long long ans;
  cin >> n >> x;

  d[n] = x;
  for(int i = 0;i < n;i++){
    cin >> d[i];
  }
  
  sort(d, d + (n + 1));

  for(int i = 0;i < n;i++){
    div[i] = d[i + 1] - d[i];
  }
  
  if(div[1] == 0){
    cout << div[0] << endl;
  }else{
    ans = __gcd(div[0], div[1]);
    for(int i = 2;i < n;i++){
      ans = __gcd(ans, div[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

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

int n;
bool G[110][110];
int d[110], f[110], timer;
bool seen[110];

void dfs(int now){
    d[now] = timer;

    seen[now] = true;

    for(int to=1; to<=n; ++to){
        if(G[now][to] == true && seen[to] == false){
            ++timer;
            dfs(to);
        }
    }

    ++timer;
    f[now] = timer;

}

int main(){
    cin >> n;
    for(int i=0; i<n; ++i){
        int u,k; cin >> u >> k;
        for(int j=0; j<k; ++j){
            int v; cin >> v;
            G[u][v] = true;
        }
    }

    timer = 0;
    for(int i=1; i<=n; ++i){
        if(seen[i] == false){
            ++timer;
            dfs(i);
        }
    }

    for(int i=1; i<=n; ++i){
        printf("%d %d %d\n", i, d[i], f[i]);
    }
}


Measured memory_bytes: 3224
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    int64_t a, b;
    char c;
    scanf("%" SCNd64" %c %" SCNd64, &a, &c, &b);
    printf("%" PRId64 "\n", c == '+' ? a + b : a - b);
    return 0;
}


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

using namespace std;

using ll = long long;

const int MAX_N = 2000;
ll n, z, w;
ll a[MAX_N + 1], dp[2][MAX_N + 1];

ll Solve(const int p, const int idx) {
    if (dp[p][idx] != -1) return dp[p][idx];

    if (p == 0) { // Xの手番
        ll res = 0;
        if (idx == 0) res = max(res, abs(a[n - 1] - w));
        else res = max(res, abs(a[n - 1] - a[idx - 1]));

        for (int i = idx; i < n - 1; ++i)
            res = max(res, Solve(1 - p, i + 1));
        return dp[p][idx] = res;
    }
    else { // Yの手番
        ll res = abs(a[n - 1] - a[idx - 1]);

        for (int i = idx; i < n - 1; ++i)
            res = min(res, Solve(1 - p, i + 1));
        return dp[p][idx] = res;
    }
}

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

    cin >> n >> z >> w;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i)
        dp[0][i] = dp[1][i] = -1;

    cout << Solve(0, 0) << endl;


    return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N, M;
    cin >> N >> M;
    int Lmax = 0;
    int Rmin = inf;

    for (int i = 0; i < M; i++)
    {
        int L, R;
        cin >> L >> R;
        if (L > Lmax)
        {
            Lmax = L;
        }
        if (R < Rmin)
        {
            Rmin = R;
        }
    }
    
    if (Lmax > Rmin)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << Rmin - Lmax + 1 << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long i,j,n,nn,m,p[1001];
while(cin>>n){
cin>>m;
if(n==0)break;
nn=n;
for(i=1;i<=n;i++)p[i]=1;
j=0;
for(;;){
for(i=0;i<m;i++){
j++;
if(j>n)j-=n;
if(p[j]<0)i--;
}
p[j]=-1;nn--;
if(nn==0)break;
}
cout<<j<<endl;
}
return 0;
}

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

int main()
{
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> va(a, 0);
    vector<int> vb(b, 0);
    int minA = 100000, minB=100000;

    for (int i = 0; i < a; i++) {
        cin >> va[i];
        minA = min({ minA,va[i] });
    }
    for (int i = 0; i < b; i++) {
        cin >> vb[i];
        minB = min({ minB,vb[i] });
    }

    int waribikiMin = 200000; //割引券で購入した金額の最小値
    for (int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        int nedan = va[x - 1] + vb[y - 1] - c;
        waribikiMin = min({ waribikiMin,nedan });
    }

    int ans = min({ waribikiMin, minA + minB });

    cout << ans << endl;
    return 0;
}


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

int main() {
  int min_hour = 0;
  int P_hour = 0, Q_hour = 0, R_hour = 0;
  
  cin >> P_hour >> Q_hour >> R_hour;
  
  min_hour = P_hour + Q_hour;
  
  if(Q_hour + R_hour < min_hour)
  {
    min_hour = Q_hour + R_hour;
  }
  if(R_hour + P_hour < min_hour)
  {
    min_hour = R_hour + P_hour;
  }
  
  cout << min_hour;
}



Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	ll N,M;
	cin>>N>>M;
	ll ans=1;
	for(ll i=1;i*i<=M;i++){
		if(M%i!=0)continue;
		ll B=M/i;
		if(N*i<=M)ans=max(i,ans);
		if(N*B<=M)ans=max(B,ans);
	}
	cout<<ans<<endl;
	return 0;
}




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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	if(max(a,c)>min(b,d)){
		cout<<'0'<<endl;
	}else{
		cout<< min(b,d)-max(a,c) <<endl;
	}
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll cnt=0;
    while(n!=0){
        n/=k;
        cnt++;
    }
    cout<<cnt<<endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    vi a(5);
    rep(i, 5) cin >> a[i];
    int k; cin >> k;
    sort(all(a));
    if(a[4] - a[0] > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

int a, b, c, d;
using namespace std;
int main(){
    cin >> a >> b >> c >> d;
    if (c<=a+d && a-d<=c) cout << "Yes" << endl;
    else if (b<=a+d && a-d<=b && c<=b+d && b-d<=c) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256