akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define EPS 1e-6
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
long long const INF = 1e18 + 42;

 
int main(){
	fast;
	lli n;
	cin>>n;
	vector<lli> v(n);
	map<lli,lli> mp,m1,m2;
	for(int i=0; i<n ;i++){
	    cin>>v[i];
	    mp[v[i]]++;
	}
	lli ans=0;
	for(auto i: mp){
	    m1[i.ff]= (i.ss)*(i.ss-1)/2;
	    m2[i.ff]= (i.ss-1)*(i.ss-2)/2;
	}
	for(auto i: m1) ans+=i.ss;
	for(int i=0; i<n; i++){
	    cout<<(ans-m1[v[i]]+m2[v[i]])<<"\n";
	}
	return 0;
}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    string s;
    cin >> s;
    if(s[2] == s[3] and s[4] == s[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n + 1), b(n);
    int i;
    for (i = 0; i < n + 1; i++) {
        scanf("%d", &a[i]);
    }
    for (i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    ll ans = 0;
    for (i = 0; i < n; i++) {
        int tmp=MIN(a[i], b[i]);
        a[i] -= tmp;
        int tmp2 = MIN(b[i] - tmp, a[i + 1]);
        a[i + 1] -= tmp2;
        ans += tmp+tmp2;
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5 + 5;
int n, m;
deque<int> a;
int s = 0;
vector<pair<int, int>> q;
int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	while(m--) {
		int b, c;
		cin >> b >> c;
		q.push_back({c, b});
	}
	sort(a.begin(), a.end());
	sort(q.begin(), q.end());
	reverse(q.begin(), q.end());
	int t = 0;
	for(auto i : q) {
		if(a.empty())
			break;
		int b = i.second;
		int c = i.first;
		int cnt = 0;
		int ind = a.front();
		if(ind >= c)
			break;
		if(t == n)
			break;
		while(ind < c && cnt < b && t < n) {
			a.pop_front();
			s += c;
			t++;
			cnt++;
			if(a.empty())
				break;
			ind = a.front();
		}
	}
	int ans = s;
	for(int i : a)
		ans += i;
	cout << ans;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<string> V(N);
  for(int i = 0; i < N; i++){
    cin >> V[i];
  }
  
  set<string> S;
  for(int i = 0; i < N; i++){
    S.insert(V[i]);
  }
  cout << S.size() << endl;
}
      

Measured memory_bytes: 25112
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
const ll mod = 1000000007;

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

    Graph to(n), cost(n);
    rep(i, n-1) {
        ll a, b, w;
        cin >> a >> b >> w;
        a--;  b--;
        to[a].push_back(b);
        to[b].push_back(a);
        cost[a].push_back(w);
        cost[b].push_back(w);
    }

    int q, K;
    cin >> q >> K;
    K--;

    vector<ll> dist(n, -1);  // dist[i] : 頂点iの根からの距離
    queue<ll> Q;

    const int root = K;  // 根は頂点K
    dist[root] = 0;
    Q.push(root);
    while(!Q.empty()) {
        
        ll v = Q.front();
        Q.pop();

        rep(i, to[v].size()) {
            
            ll u = to[v][i];
            
            if(dist[u] != -1) {
                continue;
            }
            
            dist[u] = dist[v] + cost[v][i];
            Q.push(u);
        }
    }

    vector<ll> ans(q);
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        x--;  y--;
        ans[i] = dist[x] + dist[y];
    }

    rep(i, q) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 16232
n = int(input())
tmp = n

def is_prime(x):
    if (x==0 or x==1):
        return False
    for n in range(2,x-1):
        if (x % n) == 0:
            return False
    else:
        return True
    
while True:
    if is_prime(tmp):
        print(tmp)
        break
    else:
        tmp += 1

Measured memory_bytes: 3060
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

s = input()

print("Bad" if s[0]==s[1] or s[1]==s[2] or s[2]==s[3] else "Good")

Measured memory_bytes: 38256
#include <cstdio>

#include <vector>
#include <queue>
#include <tuple>
int v, e;

struct Edge {
  Edge() {}
  Edge(int from, int to, int capacity, int cost, int rev) : from(from), to(to), capacity(capacity), cost(cost), rev(rev) {}
  int from, to;
  int capacity;
  int cost;
  int rev;
};

std::vector<Edge> edges[128];

void addEdge(int from, int to, int capacity, int cost) {
  int n1 = edges[from].size();
  int n2 = edges[to].size();
  edges[from].push_back(Edge(from, to, capacity, cost, n2));
  edges[to].push_back(Edge(to, from, 0, -cost, n1));
}                      

struct Result {
  Result() {}
  Result(int cost, int f) : cost(cost), f(f) {}
  int cost;
  int f;
};

int prev[128];
int prev_id[128];
int w[128];
int max_f[128];
void init_flow() {
  for(int i = 0; i < 128; ++i) {
    prev[i] = -1;
    prev_id[i] = -1;
    w[i] = (1 << 30);
    max_f[i] = 0;
  }
}

Result flow(int from, int to, int rem) {
  std::priority_queue< std::pair<int, int> > q;
  q.push(std::make_pair(0, from));
  w[from] = 0;
  max_f[from] = rem;
  while( not q.empty() ) {
    int n, weight;
    std::tie(weight, n) = q.top(); q.pop();
    // printf("(n) = (%d)\n", n);
    weight = -weight;
    for(int i = 0; i < (int)edges[n].size(); ++i) {
      Edge edge = edges[n][i];
      if( edge.capacity <= 0 ) continue;
      int nw = weight + edge.cost;
      if( w[edge.to] <= nw ) continue;
      w[edge.to] = nw;
      prev[edge.to] = n;
      prev_id[edge.to] = i;
      max_f[edge.to] = std::min(max_f[edge.from], edge.capacity);
      q.push(std::make_pair(-nw, edge.to));
    }
  }
  // for(int i = 0; i < v; ++i) {
  //   printf("node info[%d] : (w, max_f, prev, prev_id) = (%d, %d, %d, %d)\n", i, w[i], max_f[i], prev[i], prev_id[i]);
  // }
  int f = max_f[to];
  if( f == 0 ) return Result(0, 0);
  int m = to;
  int cost = 0;
  while( prev[m] != -1 ) {
    edges[prev[m]][prev_id[m]].capacity -= f;
    edges[m][edges[prev[m]][prev_id[m]].rev].capacity += f;
    cost += f * edges[prev[m]][prev_id[m]].cost;
    m = prev[m];
  }
  return Result(cost, f);
}

int minimum_cost_flow(int from, int to, int rem) {
  int cost = 0;
  for(;;) {
    init_flow();
    Result r = flow(from, to, rem);
    rem  -= r.f;
    cost += r.cost;
    if( rem == 0 ) return cost;
    if( r.f == 0 ) break;
    // printf("(rem, flow rate) = (%d, %d)\n", rem, r.f);
  }
  return -1;
}

int main() {
  int f;
  scanf("%d %d %d", &v, &e, &f);
  for(int i = 0; i < e; ++i) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    addEdge(a, b, c, d);
  }

  printf("%d\n", minimum_cost_flow(0, v - 1, f));
  
  return 0;
}

Measured memory_bytes: 2752
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T, class U> inline void chmax(T &a, const U &b) { if ((a) < (b)) (a) = (b); }
template <class T, class U> inline void chmin(T &a, const U &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int x;cin>>x;
    cout << (x == 1 ? 0 : 1) << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3688
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef unsigned long long ull;

int tmp_cost(int p){
  if( p==1)return 0;
  int ret=tmp_cost(p/2)+1+p%2;
  return ret;
}

ull expect(int p,int n,ull tar){
  ull ret=n;
  while(p--&&ret<tar)ret+=ret;
  return ret;
}

int ans;
bool solve(int cnt,int limit,int now,int tar,int num,int *made,bool *visited){
  if (cnt>limit)return false;
  if ( now>=tar*2)return false;//may not be need?
  
  if (now == tar ){
    ans=min(ans,cnt);
    return true;
  }
  if ( cnt==limit)return false;

  int findmax=0;
  REP(i,0,num)findmax=max(findmax,made[i]);
  if( expect(limit-cnt,findmax,(ull)tar)<(ull)tar){
    return false;
  }



  for(int i=num-1;i>=0;i--){
    //mul
    if ( visited[now+made[i]]==false){
      visited[now+made[i]]=true;
      made[num]=now+made[i];
      if (solve(cnt+1,limit,now+made[i],tar,num+1,made,visited)){
	visited[now+made[i]]=false;
	return true;
      }
      visited[now+made[i]]=false;
    }


    //div
    if( now-made[i]>0 && visited[now-made[i]]==false){
      visited[now-made[i]]=true;
      made[num]=now-made[i];
      if (solve(cnt+1,limit,now-made[i],tar,num+1,made,visited)){
	visited[now-made[i]]=false;
	return true;
      }
      visited[now-made[i]]=false;
    }


  }

  return false;
}

main(){
  int n;
  while(cin>>n&&n){
    int upper=tmp_cost(n);
    bool visited[5002]={false};
    int  made[30];
    visited[1]=true;
    visited[2]=true;
    made[0]=1;
    made[1]=2;
        
    
    int lower=0,tmp=1;
    while(tmp<n){
      tmp*=2;
      lower++;
    }
    
    for(int i=upper-1;i>=lower;i--){
      ans=i;
      if (solve(1,i,2,n,2,made,visited) ){
	//cout << "solved at " <<i<<" with " << ans << endl;
	upper=ans;
	i=ans;
      }
      //else cout << "unsolved at " <<i<<endl;

    }
    cout << upper << endl;

  }
  return false;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

#define int64 int64_t
#define uint64 uint64_t
#define uint unsigned

int main()
{
    int n;
    while(cin >> n){
        if(n <= 0) break;
        map<char, char> che;
    REP(i, n)
    {
        char a, b;
        cin >> a >> b;
        che[a] = b;
    }
    int m;
    cin >> m;
    string s;
    REP(i, m)
    {
        char tmp;
        cin >> tmp;
        auto c = che.find(tmp);
        s.push_back(c != che.end() ? c->second : tmp);
    }
    cout << s << '\n';
    }
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    ll N; cin >> N;
    ll x = 2;   // 割る数（xに代入されるのは2, 3, 5, 7, 11, ...）
    ll cnt = 0; // あるxで割った回数（ansに加算される度に0に戻す）
    ll th = 1;  // ansに加算するための閾値
    ll ans = 0; // 処理回数
    while(N != 1) {
        if (N % x == 0) {
            N /= x;
            cnt++;
            if(cnt == th) {
                ans++;
                cnt = 0;
                th++;
            }            
        } else if (N < x * x) {
            ans++;
            break;
        }
        else {
            if (x == 2) {
                x = 3;
            } else {
                x += 2;
            }
            cnt = 0;
            th = 1;
        }
    }
    cout << ans << "\n";
}   

Measured memory_bytes: 3652
import numpy as np

H,W=map(int,input().split())
max_value = H+W
matrix =[]

for _ in range(H):
    matrix.append([0 if i == '#' else max_value for i in list(input())])
matrix = np.array(matrix)

for c in range(W-1):
    matrix[:,c+1] = np.minimum(matrix[:,c]+1,matrix[:,c+1])
for c in range(W-1,0,-1):
    matrix[:,c-1] = np.minimum(matrix[:,c-1],matrix[:,c]+1)
for r in range(H-1):
    matrix[r+1,:] = np.minimum(matrix[r,:]+1,matrix[r+1,:])
for r in range(H-1,0,-1):
    matrix[r-1,:] = np.minimum(matrix[r,:]+1,matrix[r-1,:])


print(np.max(matrix))


Measured memory_bytes: 29020
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	long long int n,a,b;
	long long int x[100005] = {0};

	scanf("%d %d %d", &n,&a,&b);

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

	long long int sum;

	for(int i = 0; i < n-1; i++)
	{
		sum += min(b, (x[i+1] - x[i]) * a );
	}

	printf("%lld\n", sum);

	return 0;
}
	


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n;
  cin>>n;
  ll one=n%10;
  if(one==2 || one==4 || one==5 || one==7 || one==9)
    cout<<"hon"<<endl;
  else if(one==0 || one==1 || one==6 || one==8)
    cout<<"pon"<<endl;
  else cout<<"bon"<<endl;
  return 0;
}

Measured memory_bytes: 3584
// Last Change: 03/24/2019 14:00:21.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  int dayMax[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  int ans = 0;
  for (int i = 1; i <= a; ++i) {
    for (int j = 1; j <= dayMax[i]; ++j) {
      if (i == j) {
        ++ans;
      }
      if (i == a and j == b) {
        cout << ans << endl;
        // NS::LoopUntilZeroInpput();
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n = 0;
  int num = 0;
  char class;
  int card[4][13]={{1,2,3,4,5,6,7,8,9,10,11,12,13},{1,2,3,4,5,6,7,8,9,10,11,12,13},{1,2,3,4,5,6,7,8,9,10,11,12,13},{1,2,3,4,5,6,7,8,9,10,11,12,13}};
  int i;
  int j = 0;

  
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf(" %c %d", &class, &num);

    if(class == 'S')
      j = 0;
    if(class == 'H')
      j = 1;
    if(class == 'C')
      j = 2;
    if(class == 'D')
      j = 3;

    card[j][num - 1] = 0;

  }

  for(i = 0; i < 13; i++)
    if(card[0][i])
      printf("S %d\n", card[0][i]);
  for(i = 0; i < 13; i++)
    if(card[1][i])
      printf("H %d\n", card[1][i]);
  for(i = 0; i < 13; i++)
    if(card[2][i])
      printf("C %d\n", card[2][i]);
  for(i = 0; i < 13; i++)
    if(card[3][i])
      printf("D %d\n", card[3][i]);
  
  return 0;
}

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

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  if (A == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll q = N/(A+B);
  ll r = N%(A+B);
  if (r > A) r = A;
  cout << q*A + r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    char *s[] = {"1", "1", "1", "2", "1", "2", "1", "5", "2", "2", "1", "5", "1", "2", "1", "14", "1", "5", "1", "5", "2", "2", "1", "15", "2", "2", "5", "4", "1", "4", "1", "51"
};
    int i;
    scanf("%d", &i);
    printf("%s", s[i - 1]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    vector<int> v[11];
    string s;
    while(cin >> s) {
        rep(i, 11) v[i].clear();
        rep(i, 10) v[0].push_back(s[i] - '0');
        for(int i = 1; i <= 10; i++) {
            rep(j, v[i-1].size() - 1) {
                v[i].push_back((v[i-1][j] + v[i-1][j+1]) % 10);
            }
        }
        cout << v[9][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
using System;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long x = long.Parse(input[0]);
		long y = long.Parse(input[1]);
    long a = Math.Abs(Math.Abs(x)-Math.Abs(y));

    if(x<y && y<=0 || 0<=x && x<y) a += 0;
    else if(y<x && x<0 || 0<y && y<x) a += 2;
    else a += 1;
		Console.WriteLine(a);
	}
}

Measured memory_bytes: 11092
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0: break
    count = 0
    for i in range(1,n - 1):
        for j in range(i + 1 ,n):
            for k in range(j + 1 ,n + 1):
                if i + j + k == x: count += 1
    print(count)

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

int main (){
	int a[4],ans=0;
	cin>>a[0]>>a[1]>>a[2];
	while(1){
		sort(a,a+3);
		if(a[0]==a[2]) break;
		if(a[1]==a[2]) a[0]+=2;
		else a[0]++,a[1]++;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())

    ans = 0

    for i in range(1,n+1):
        count = 0
        while i < k:
            i *= 2
            count += 1
        ans += 1 / n * 0.5 ** count
        
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39024
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    ll sum=0;
    int cnt=0;
    rep(i,n){
        sum+=a.at(i);
        cnt++;
        if(sum>x)break;
    }
    if(sum==x)cout << cnt << endl;
    else cout << cnt-1 << endl;
}



    
   


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

using fint64 = int_fast64_t;
struct Combination {
	const int MAX = 5000010;
	const int MOD;
	vector<fint64> FAC;
	vector<fint64> INV;
	vector<fint64> FAC_INV;
	Combination(fint64 MOD) :
		MOD(MOD),
		FAC(vector<fint64>(MAX)),
		INV(vector<fint64>(MAX)),
		FAC_INV(vector<fint64>(MAX))
		{
			FAC[0] = INV[1] = FAC_INV[0] = 1;
			for(int i = 1; i < MAX; ++i) {
				FAC[i] = FAC[i - 1] * i % MOD;
				if(i > 1) INV[i] = MOD - INV[MOD % i] * (MOD / i) % MOD;
				FAC_INV[i] = FAC_INV[i - 1] * INV[i] % MOD;
			}
		}
	fint64 C(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[r] % MOD * FAC_INV[n - r] % MOD;
	}
	fint64 P(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[n - r] % MOD;
	}
	fint64 H(int n, int r) {
		if(r == 0) return 1;
		return C(n + r - 1, r);
	}
};

int main() {
    const int MOD = 1e9 + 7;
	Combination com(MOD);
	int n, k; cin >> n >> k;
	int b = k, r = n - k;
	for(int i = 1; i <= k; ++i) {
		cout << com.C(b - 1, i - 1) % MOD * com.H(i + 1, r - (i - 1)) % MOD << '\n';
	}
	return 0;
}

Measured memory_bytes: 117504
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	week := map[string]int{
		"SUN": 7,
		"MON": 6,
		"TUE": 5,
		"WED": 4,
		"THU": 3,
		"FRI": 2,
		"SAT": 1,
	}
	fmt.Println(week[S])
}


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

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j;
	ll ret;
	
	string s,t;
	
	cin >> s>>t;
	
	t.erase(s.size());
	
	if (t == s) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 3628
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A,B,C;

int main() {
	cin>>A>>B>>C;
	if(C-(A-B)<0){
		cout<<0<<endl;
	}else{
	    cout<<C-(A-B)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  cin >> n>> m;
  vp baito(n);
  rep(i,n){
    cin >> baito[i].fi >> baito[i].se;
  }
  sort(rng(baito));
  queue<P> pq;
  rep(i,n) pq.push(baito[i]);
  priority_queue<int> q;
  int ans = 0;
  rep(i,m){
    while(1){
      if(pq.empty()) break;
      if(pq.front().fi<= i+1){
        q.push(pq.front().se);
        pq.pop();
      }else break;
    }
    if(q.empty()) continue;
    ans+=q.top();
    q.pop();
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 2448
#include <stdio.h>
#include <algorithm>

long long int checks[1000000];

using namespace std;

int main() {
    long long int N, res = 0;
    scanf("%lld", &N);
    long long int k = N; 
    int pos = 0;
    long long int x = 1, sum = 0;
    while (pos < 1000000) {
        sum += x;
        x++;
        checks[pos++] = sum;
    }
    long long sqrt_N;
    sqrt_N = sqrt(N);

    for (long long int i = 2; i<=sqrt_N; i++) {
        if (N % i != 0) continue;

        long long int acc = 0;
        while (N % i == 0) {
            acc++;
            N /= i;
        }

        for (pos = 0; pos < 1000000; pos++) {
            if (acc < checks[pos]) {
                res += pos;
                break;
            }
        }
    }

    if ( N != 1) res++;

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

Measured memory_bytes: 11044
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> C(N-1),S(N-1),F(N-1);
    rep(i,N-1) cin >> C[i] >> S[i] >> F[i];
    rep(i,N-1){
        int time = S[i];
        repr(j,i,N-1){
            while(time % F[j] != 0 || time < S[j]){
                time++;
            }
            time += C[j];
        }
        cout << time << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
import copy
import sys
import math

def main():
	n,y = map(int,input().split())
	for i in range(n+1):
		for j in range(n-i+1):
			k = n-i-j
			if(y == i*10000 + j*5000 + k*1000):
				print('{} {} {}'.format(i,j,k))
				sys.exit()
	print('-1 -1 -1')


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define pb push_back
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int) a.size())
#define REP(i,n) for(int i=0;i<(n);i++)
#define MP make_pair
#define SORT_UNIQUE(v) v.resize(unique(ALL(v))-v.begin())
#define GET_POS(v,a) lower_bound(ALL(v),a)-v.begin();

const int maxn=505;
const int INF=0x3f3f3f3f;

string s[maxn];

bool r[maxn][maxn],b[maxn][maxn];

int main(){
    int n,m;
    cin>>n>>m;
    REP(i,n) cin>>s[i];
    REP(i,m) r[0][i]=1;
    REP(i,m) b[n-1][i]=1;
    REP(i,m) for(int j=1;j<n-1;j++){
        if(i%2) r[j][i]=1;
        else b[j][i]=1;
    }
    REP(i,n) REP(j,m){
        if(s[i][j]=='#') r[i][j]=b[i][j]=1;
    }
    REP(i,n) REP(j,m){
        if(r[i][j]) cout<<'#';
        else cout<<'.';
        if(j==m-1) cout<<'\n';
    }
    cout<<'\n';
    REP(i,n) REP(j,m){
        if(b[i][j]) cout<<'#';
        else cout<<'.';
        if(j==m-1) cout<<'\n';
    }
}


Measured memory_bytes: 1536
#include<iostream>

using namespace std;

int main ()
{
    char a='0',b='0',c='0',d='0';
    int x=0;

    cin>>a;
    for(int i=0;i<3;i++){
        cin>>b;
        if(b==a ||b==c)x++;
        else c=b;
    }
    if(x==2)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    if(n%2==1){n++;}
    int ans=n/2;
    if(ans>=k){puts("YES");}else{puts("NO");}
    
    
    
return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

 
public class Main {
	static final long MOD=1000000007;//998244353;
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int x=sc.nextInt();
		if (x==0) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
   	}
	
		static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
	}

Measured memory_bytes: 32480
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum += 1 / (double) std.nextInt();
        }

        System.out.println(Math.pow(sum, -1));
    }
}

Measured memory_bytes: 21844
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
S = inpl_s()
hoge = set()
for s in S:
	hoge.add(s)

if len(hoge) == 3:
	print('Three')
else:
	print('Four')


Measured memory_bytes: 4204
// #define int long long
// #define repeat(i, n) for (int i = 0; i < n; ++i)

#include <cmath> // cmath includes sqrt, abs
#include <iostream> // iostream includes cout, endl
#include <string> // string
#include <algorithm> // algorithm includes sort

#include <set>

using namespace std;

int main() {
  bool can = false;
  int num = 0;
  int sum = 0;
  string S;
  int N;

  int W, H;

  int x[150];
  int y[150];
  int a[150];

  // int d[150][150];

  cin >> W >> H >> N;

  for (int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> a[i];

  int x_left, x_right;
  int y_lower, y_upper;

  x_left = y_lower = 0;
  x_right = W;
  y_upper = H;

  for (int i = 0; i < N; ++i) {
    if (a[i] == 1) {
      x_left = max(x[i], x_left);
    }
    if (a[i] == 2) {
      x_right = min(x[i], x_right);
    }
    if (a[i] == 3) {
      y_lower = max(y[i], y_lower);
    }
    if (a[i] == 4) {
      y_upper = min(y[i], y_upper);
    }
  }

  // cout << x_left << ":" << x_right << endl;
  // cout << y_lower << ":" << y_upper << endl;

  if (x_left < x_right && y_lower < y_upper) {
    sum = (x_right - x_left) * (y_upper - y_lower);
  }
  
  // for (int i = 0; i <= W; ++i) {
  //   for (int j = 0; j <= H; ++j) {
  //     d[i][j] = 0;
  //   }
  // }

  // for (int i = 0; i < N; ++i) {
  //   if (a[i] == 1) {
  //     for (int k = 0; k < x[i]; ++k) {
  //       for (int l = 0; l <= H; ++l) {
  //         d[k][l] = 1;
  //       }
  //     }
  //   } else if (a[i] == 2) {
  //     for (int k = x[i]; k <= W; ++k) {
  //       for (int l = 0; l <= H; ++l) {
  //         d[k][l] = 1;
  //       }
  //     }
  //   } else if (a[i] == 3){
  //     for (int k = 0; k <=  W; ++k) {
  //       for (int l = 0; l < y[i]; ++l) {
  //         d[k][l] = 1;
  //       }
  //     }
  //   } else if (a[i] == 4){
  //     for (int k = 0; k <=  W; ++k) {
  //       for (int l = y[i]; l <= H; ++l) {
  //         d[k][l] = 1;
  //       }
  //     }
  //   }
  // }
  

  // for (int i = 0; i <= W; ++i) {
  //   for (int j = 0; j <= H; ++j) {
  //     if (d[i][j] == 1) {
  //       sum += 1;
  //     }
  //   }
  // }

  

  cout << sum << endl;
  
  // if (can) cout << "Yes" << endl;
  // else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int time[101];
    rep(i,101){
        time[i]=0;
    }
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(int i=a;i<b;i++){
        time[i]++;
    }
    for(int i=c;i<d;i++){
        time[i]++;
    }

    int ans=0;
    for(int i=0;i<101;i++){
        if(time[i]==2){
            ans++;
        }
    }
   
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
n=int(input())
while n!=0:
    a=list(map(int,input().split()))
    ans=10**18
    for i in range(len(a)):
        for j in range(len(a)):
            if i!=j:
                ans=min(ans,abs(a[i]-a[j]))
    print(ans)
    n=int(input())


Measured memory_bytes: 5624
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		int d1 = scanInt();
		int d2 = scanInt();
		int d1s = 0, d2s = 0;
		while ((d1 & 3) == 0) {
			++d1s;
			d1 >>= 2;
		}
		while ((d2 & 3) == 0) {
			++d2s;
			d2 >>= 2;
		}
		int need = n * n;
		for (int i = 0; i < 2 * n; i++) {
			for (int j = 0; j < 2 * n; j++) {
				if ((d1 & 3) == 1 && (((i >> d1s) ^ (j >> d1s)) & 1) != 0) {
					continue;
				}
				if ((d1 & 3) == 2 && ((i >> d1s) & 1) != 0) {
					continue;
				}
				if ((d2 & 3) == 1 && (((i >> d2s) ^ (j >> d2s)) & 1) != 0) {
					continue;
				}
				if ((d2 & 3) == 2 && ((i >> d2s) & 1) != 0) {
					continue;
				}
				out.println(i + " " + j);
				if (--need == 0) {
					return;
				}
			}
		}
		throw new AssertionError();
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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

using namespace std;

int n;
vector<int> ans;

int main(){
	while(1){
		cin >> n;
		if(n == 0) break;
		int count = 0;
		for(int i = 1;i < n;i++){
			int sum = i;
			for(int j = i+1; sum < n;j++){
				sum += j;
				if(sum == n) count++;
			}
		}
		ans.push_back(count);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3088
// Last Change: 04/26/2020 21:09:15.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  set<string> st;
  for (ll i = 0; i < N; ++i) {
    string ipt;
    cin >> ipt;
    st.insert(ipt);
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 15724
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 50;
int n, m, c, ans;
int a[MAXN], b[MAXN];
int main(){
	scanf("%d%d%d", &n, &m, &c);
	for(int i = 1; i <= m; i++)
		scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++){
		int tmp = c;
		for(int j = 1; j <= m; j++){
			scanf("%d", &b[j]);
			tmp += b[j] * a[j];
		}
		ans += tmp > 0;
	}
	cout<<ans;
	
		
	return 0;
}


Measured memory_bytes: 256
n = int(input())
x,y = map(int,input().split())
lx = x+y
ly = (x-y)
maxlx = lx
minlx = lx
maxly = ly
minly = ly
for _ in range(n-1):
  x,y = map(int,input().split())
  lx = x+y
  ly = (x-y)
  maxlx = max(maxlx,lx)
  minlx = min(minlx,lx)
  maxly = max(maxly,ly)
  minly = min(minly,ly)
print(max(maxlx-minlx,maxly-minly))

Measured memory_bytes: 72608
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

const int N = 2e6 + 5;
long long inv[N], fact[N], ifact[N];
void pre()
{
	inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (int i = 2; i < N; i++)
	{
		inv[i] = mul(MOD - MOD / i, inv[MOD % i], MOD);
		fact[i] = mul(i * 1ll, fact[i - 1], MOD);
		ifact[i] = mul(inv[i], ifact[i - 1], MOD);
	}
	return;
}
long long nCr(long long n, long long r)
{
	if (n >= 0 && r >= 0 && n >= r)
		return mul(fact[n], mul(ifact[r], ifact[n - r], MOD), MOD);
	return 0;
}
long long binpow(long long x, long long y, long long m)
{
	long long res = 1;
	x %= MOD;
	while (y)
	{
		if (y & 1)
			res = mul(res, x, m);
		y = (y >> 1);
		x = mul(x, x, m);
	}
	return res;
}
void solve(int tc)
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.length();
	pre();
	ll ans = binpow(26, n + k, MOD);
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		ll tmp = nCr(n + k, i);
		tmp = mul(tmp, binpow(25, n + k - i, MOD), MOD);
		sum = add(sum, tmp, MOD);
	}
	ans = add(ans, MOD - sum, MOD);
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 51196
# Educational DP Contest E-knapsack 2


N,W=list(map(int,input().split()))
items=[]
for _ in range(N):
    w,v=list(map(int,input().strip().split()))
    items+=[(w,v)]
    
MAX_val=N*10**3+1 # 最大の価値
dp=[[10**9+1]*MAX_val for i in range(N)] # 最大の価値でinitialize(価値の表）
dp[0][items[0][1]]=items[0][0] # 最初の品物の価値の場所に、最初の品物の重さを入れる
for i in range(1,N):
    for val in range(1,MAX_val):
        if val-items[i][1]>0: # アイテムの価値がvalを上回っていた場合
            dp[i][val]=min(dp[i-1][val],dp[i-1][val-items[i][1]]+items[i][0])
        elif val==items[i][1]: # アイテムの価値がvalと同様の場合
            dp[i][val]=min(items[i][0],dp[i-1][val])
        dp[i][val]=min(dp[i][val],dp[i-1][val])

MAX=0
for i in range(len(dp[-1])): # dpの最終行の数を調べて、最もWに近いものを出力
    if dp[-1][i]<=W:
        #print(i)
        MAX=i
print(MAX)
    

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

int main(void) {
  int N;
  string S;
  map<int, int> cnt_alpha;
  map<int, int> cnt_coef;

  cin >> N >> S;

  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '+') continue;
    cnt_alpha[S[i]-'a']++;
  }

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 26; j++) {
      if (cnt_alpha[j] == i) cnt_coef[i]++;
    }
  }

  int cnt_term = 0;
  int ans = 0;

  for (int i = 1; i <= N; i++) {
    if (cnt_coef[i] == 0) continue;

    if (i == 1) {
      ans += cnt_coef[i];
      cnt_term += cnt_coef[i];
    } else if (cnt_coef[i] == 1) {
      ans += cnt_coef[i] * 3;
      cnt_term += cnt_coef[i];
    } else {
      ans += 4 + 2 * cnt_coef[i] - 1;
      cnt_term++;
    }
  }

  ans += cnt_term - 1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3180
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp90 {
    class Program {
        static long N;
        static long[] A;

        static void Main(string[] args) {
            N = long.Parse(Console.ReadLine());
            A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var A_new = new long[N];

            for (int i = 0; i < N; i++) {
                A_new[i] = A[i] + i + 1;
            }

            var minMaxList = new List<long>();
            for (int i = 0; i < N; i++) {
                minMaxList.Add(A[i] - (i + 1));
            }

            minMaxList.Sort();

            Console.WriteLine(Calculate(minMaxList[(int)N / 2]));
        }

        //悲しさを計算する
        static long Calculate(long b_) {
            long value = 0;
            for (int i = 0; i < N; i++) {
                value += Math.Abs(A[i] - (b_ + i + 1));
            }
            return value;
        }
    }
}

Measured memory_bytes: 38080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x=n%10;
    if(x==2|| x==4|| x==5 || x==7 || x==9)
    {
        cout<<"hon"<<endl;
    }
    else if(x==0 || x==1 || x==6 || x==8)
    {
        cout<<"pon"<<endl;
    }
    else if(x==3)
    {
        cout<<"bon"<<endl;
    }
}


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


int main(){
	int n;
	int m[4];
	cin >> n;
	
	for (int i = 0; i <= 4;i++) {
		m[i] = (n % 10); n /= 10;
	}

	if (m[0]==m[1] && m[1]==m[2]) {
		cout << "Yes" << endl;
	}else if(m[1] == m[2] && m[2] == m[3]){
		cout << "Yes" << endl;
	}else if (m[0] == m[1] && m[1] == m[2]) {
		if (m[2] == m[3]) cout << "Yes" << endl;;
	}else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

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

    int d = max({a,b,c});
    int ans = d;

    for (int i = 0; i < k; ++i) {
        ans *= 2;
    }
    print(ans + a + b + c - d );
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b;
    cin, a, b;
    print(lcm(a, b));
    return 0;
}


Measured memory_bytes: 256