akhauriyash/Code-Regression huggingface dataset:
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int n;cin>>n;int a[n];rep(i,n)cin>>a[i];sort(a,a+n);
	int ans=1;
	rep(i,n-1){
		if(a[i+1]<=a[i]*2)ans++;
		else ans=1;
		a[i+1]+=a[i];
	}
	dans;
}


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

int main(void){
	int A,B,C,K;
	cin >> A >> B >> C >> K;
	vector<int> aoi;
	aoi = {A,B,C};
	sort(aoi.begin(), aoi.end());
	int M = aoi.at(2);
	for(int i = 0;i < K;i++){
	 M *= 2;
	}
	int sum = aoi.at(0) + aoi.at(1) + M;
	cout << sum << endl	 ;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int X;cin>>X;
  int a,b;
  a=0;
  b=0;
  rep(i,-118,119) {
    rep(j,-119,118) {
      if(i*i*i*i*i-j*j*j*j*j==X) {
        a=i;
        b=j;
      }
    }
  }

  pr(a,b);

  return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

   

    System.out.print(a * b);
    System.out.print(" ");
    System.out.println(2 * a + 2 * b);

  }

}

Measured memory_bytes: 26212
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long LL;

const int MAX_N = 1e5 + 6;
LL a[MAX_N];

int main () {
    int n;
    scanf("%d",&n);
    for (int i=1;n>=i;i++) {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1);
    if (a[n] - a[1] >= 2) {
        puts("No");
        return 0;
    }
    else if (a[n] - a[1] ==0) {
        if (a[1] == n-1) puts("Yes");
        else if (a[1] == 1) {
            puts("Yes");
        }
        else if (a[1]*2 <=n ) puts("Yes");
        else puts("No");
    }
    else {
        if (a[1] == 1) {
            if (a[2] == 2) puts("Yes");
            else puts("No");
        }
        else {
            if (a[a[1]+1] == a[1]) puts("No");
            else {
                int dif=0;
                for (int i=1;n>i;i++) {
                    if (a[i] != a[i+1]) {
                        dif=i;
                        break;
                    }
                }
                if (a[1]+1 - (n-1-a[1]) > dif) puts("No");
                else puts("Yes");
            }
        }
    }
}



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

int main(void) {
	
	std::string s;
	std::string t;
	cin >> s;
	cin >> t;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) count++;
	}
	cout << count << endl;
	return 0;

}


Measured memory_bytes: 256
import           Control.Exception (assert)
import           Data.Bits         (bit, testBit, xor)
import           Data.List         (foldl', partition)

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  assert (length as == n) $ print $ solve k as

f :: Int -> [Int] -> Int
f x = sum . map (`xor` x)

solve :: Int -> [Int] -> Int
solve k xs =
  let
    xBits =
      map (\i -> if majority $ map (`testBit` i) xs then 0 else bit i) $ take (nDigit k) [0..]
      -- map (\i -> if majority $ map (`testBit` i) xs then 0 else bit i) [0 .. finiteBitSize (undefined :: Int)]
    x = underK k $ reverse xBits -- xBits 上の桁から並ぶようにしておく
  in
    f x xs

underK :: Int -> [Int] -> Int
--underK k = foldl1' (\acc xBit -> if acc + xBit > k then acc else acc + xBit)
underK k = foldl' (\acc xBit -> if acc + xBit > k then acc else acc + xBit) 0

majority :: [Bool] -> Bool
majority bs =
  let
    (trues, falses) = partition id bs
  in
    length trues > length falses
    -- k 以下という条件があるため、 1 と 0 が同数のときは 0 になったほうが有利

nDigit :: Integral a => a -> Int
nDigit n = 1 + floor (logBase 2 (fromIntegral n) :: Double)


Measured memory_bytes: 71804
#include<stdio.h>

int main(void)
{
   int n, h[20], i, a, x=1;

   scanf("%d",&n);
   for(i=0;i<n;i++)
      scanf("%d",&h[i]);

   a=h[0];
   for(i=1;i<n;i++)
      if(a<=h[i]){
         x++;
         a=h[i];
      }

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; 

int main(){
  int n,m;
  cin >> n >> m;
  pair<int,string> p[m];
  for(int i=0; i<m; i++){
    cin >> p[i].first >> p[i].second;
  }
  int wa[n];
  for(int i=0; i<n; i++){
    wa[i] = 0;
  }
  bool fir[n];
  for(int i=0; i<n; i++){
    fir[i] = true;
  }
  int penalty = 0;
  int ac = 0;
  for(int i=0; i<m; i++){
    if(p[i].second == "WA"){
      wa[p[i].first-1]++;
      //cout << wa[p[i].first-1] << endl;
    }
    else if(p[i].second == "AC" && fir[p[i].first-1]){
      penalty += wa[p[i].first-1];
      ac++;
      fir[p[i].first-1] = false;
    }
    //cout << penalty << endl;
  }
  cout << ac << " " << penalty << endl;
}

Measured memory_bytes: 7040
A, B, C, D = map(int, input().split())
# S = input()
# X1_list = [int(input()) for i in range(N)]
# X2_list = [list(map(int,input().split())) for i in range(N)]
while True:
    C -= B
    #print(C)
    if C <= 0:
        print('Yes')
        break
    A -= D
    #print(A)
    if A <= 0:
        print('No')
        break

Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define lli long long
#define pb push_back
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
 
int main()
{
    fast
    int arr[5],temp;
    rep(i,0,5){
        cin>>arr[i];
        if(!arr[i])
        temp=i+1;
    }
    cout<<temp;
 
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans=0;
  vector<int> A(N),B(N),C(N-1);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
    ans+=B.at(i);
  }
  for(int i=0;i<N-1;i++){
    cin >> C.at(i);
  }
  for(int i=0;i<N-1;i++){
    if(A.at(i+1)==A.at(i)+1){
      ans+=C.at(A.at(i)-1);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

#define ERAS 4
static char* NAME[ERAS]={"heisei","showa","taisho","meiji"};
static int YEAR[ERAS]={1989,1926,1912,1868};
static int MONTH[ERAS]={1,12,7,9};
static int DATE[ERAS]={8,25,30,8};
static char* OTHERWISE="pre-meiji";

int main(int argc, char *argv[]){
     int y, m, d, i;
     
     while(~scanf("%d %d %d",&y,&m,&d)){
	  for(i=0; i<ERAS; i++){
	       if(y<YEAR[i]) continue;
	       if(y==YEAR[i] && m<MONTH[i]) continue;
	       if(y==YEAR[i] && m==MONTH[i] && d<DATE[i]) continue;
	       
	       printf("%s %d %d %d\n",NAME[i],y-YEAR[i]+1,m,d);
	       break;
	  }
	  
	  if(i==ERAS) puts(OTHERWISE);
     }
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

const int MAX_N = 1007;

int answ[MAX_N][MAX_N], H, W, A, B;

void solve()
{
	cin >> H >> W >> A >> B;

	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
		{
			int val1 = i < H - B;
			int val2 = j < W - A;

			answ[i][j] = val1 ^ val2;
		}
	}

	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
			cout << answ[i][j];

		cout << endl;
	}
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
using namespace std;

bool solve(vector<int>& a, int k, int lim) {
	int sum = 0;
	int n = a.size();
	for(int i=0; i<n; ++i) {
		int x = (a[i]-1)/lim+1;
		sum += x-1;
	}
	if(sum>k) return false;
	return true;
}
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0; i<n; ++i) {
		cin>>a[i];
	}
	int lo = 1, hi = 1e9, ans=1e9;
	while(lo<=hi) {
		int mid = (lo+hi)/2;
		if(solve(a, k, mid)) {
			ans = mid;
			hi = mid-1;
		}
		else {
			lo=mid+1;
		}
	}
	cout<<ans;
}



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

int main() {
  int N,i,s,c=0,m=0;
  cin >> N;
  vector<int> H(N);
  for(i=0; i<N; i++)
    cin >> H.at(i);
  s = H.at(0);
  
  for(i=1; i<N; i++) {
    if(s >= H.at(i)) {
      c++;
      s = H.at(i);
    } else {
      s = H.at(i);
      if(c>m)
        m = c;
      c = 0;
    }
  }
  
  if(c>m)
    m = c;
  cout << m << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int x;
	int i;
	i = 0;
	
	
	while(i<10000){
		scanf("%d",&x);
		i++;
		if(x==0){
			break;
		}else {
			printf("Case %d: %d\n",i,x);
		}
	}
		return 0;
	}

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

int main(){
  string s;
  cin >> s;
  int q;
  cin >> q;
  vector<char> mem_front;
  vector<char> mem_back;
  bool change = false;
  for (int i=0; i<q; i++){
    int t;
    cin >> t;
    if (t==1){
      change = !change;
    }
    if (t==2){
      int f;
      cin >> f;
      char c;
      cin >> c;
      if (f == 1){  // front
        if (change){  // change
          mem_back.push_back(c);
        }
        else{
          mem_front.push_back(c);
        }
      }
      else {   // back
        if (change) {    // change
          mem_front.push_back(c);
        }
        else {
          mem_back.push_back(c);
        }
      }
    }
  }

  if (change){
    for(int i=0; i<mem_back.size(); i++){
      cout << mem_back[mem_back.size()-i-1];
    }
    for(int i=0; i<s.size(); i++){
      cout << s[s.size()-i-1];
    }
    for(int i=0; i<mem_front.size(); i++){
      cout << mem_front[i];
    }
    cout << endl;
  }
  else{
    for(int i=0; i<mem_front.size(); i++){
      cout << mem_front[mem_front.size()-i-1];
    }
    cout << s;
    for(int i=0; i<mem_back.size(); i++){
      cout << mem_back[i];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	REP(i, 3) {
		if (S[i] == S[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 256
a,b,c,x = [int(input()) for _ in range(4)]

count = 0

for i in range(a+1):
    y = x-500 * i
    if y >= 0:
        for j in range(b+1):
            z = y-100*j
            k = int(z/50)
            if k <= c and k >= 0:
                count += 1

print(count)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1; 
    while(t--){
	    int n,k;
	    cin>>n>>k;
	    vector<int>p(n);
	    for(auto &it : p)  cin>>it;
	    sort(p.begin(),p.end());
           // int ans=accumulate(p.begin(),p.begin()+k-1,0);
	    int ans=0;
	    for(int i=0;i<k;i++)
		    ans+=p[i];
	    cout<<ans<<endl;

    
    }
    return 0;
} 


Measured memory_bytes: 3652
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
N, M = [int(_) for _ in input().split()]

# 隣接関係は隣接リストで管理する
lst_edge = [[] for _ in range(N)]

for _ in range(M):
  # indexを0スタートにする。
  x, y = [int(_)-1 for _ in input().split()] 
  lst_edge[x].append(y)
        
# dp[v] := ノードvを始点とした時の有向パスの長さの最大値
# -1 未訪問で初期化。
dp = [-1] * N

# メモ化再帰
def rec(v):
  # 既に更新済み
  if dp[v] != -1:
    return dp[v]
  ans = 0
  lst_nv = lst_edge[v] # ノードvからいけるノード
  for nv in lst_nv:
    ans = max(ans, rec(nv) + 1) # 一歩進む
  dp[v] = ans # ノードvを始点とした時の有向パスの長さの最大値
  return dp[v]
    
# 全ての点に対して更新する
ans = 0
for v in range(N):
  ans = max(ans, rec(v))
    
print(ans)
    

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    repall (c, s) {
        int enc = c - 'A';
        enc += n;
        enc %= 26;
        c = 'A' + enc;
    }
    print(s);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;


int n, m;
bool check(const string &s, int x){
	for(int i = x; i < x+n*2+1; i+=2) if(s[i] != 'I') return false;
	for(int i = x+1; i < x+n*2+1; i+=2) if(s[i] != 'O') return false;
	return true;
}

int main(){
	while(cin >> n, n){
		cin >> m;
		string s;
		cin >> s;
		int ans = 0;
		rep(i, m-n*2+1){
			int ret = check(s, i);
			if(ret) ans++, i++;
		}
		cout << ans << endl;
	}

    return 0;
}

Measured memory_bytes: 2108
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
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; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

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

	int x;
	cin >> x;

	int t = (x / 11) * 11;
	int ans = t / 11 * 2;

	for (int i = 0; t < x; i++) {
		if (i % 2 == 0)t += 6;
		if (i % 2 == 1)t += 5;
		ans++;
	}
	cout << ans << endl;

	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>

using namespace std;

int main(void){
  int n;
  cin>>n;
  while(n--){
    char str[1000]={0};
    cin>>str;
    char ans[1000]={0};
    ans[0]=str[0];

    bool check[1280]={0};
    check[str[0]] = 1;

    int x = 1;
    for(int i = 3 ; i < strlen(str); i += 3){
	if(check[str[i]]== 1) continue;
	check[str[i]]=1;
	
	if(str[i-1]=='>'){
	  ans[x] =str[i];
	  x++;
	}
	else if(str[i-2] == '<'){
	  for(int j = x;j > 0; j--)ans[j] = ans[j-1];
	  ans[0] = str[i];
	  x++;
	}
      }
    
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
N,M = map(int,input().split())
X = sorted(list(map(int,input().split())))
if N>=M:
    print(0)
else:
    L = []
    for i in range(1,M):
        L.append(X[i]-X[i-1])
    L = sorted(L,reverse=True)
    tot = sum(L[N-1:])
    print(tot)

Measured memory_bytes: 92604
using System;
using System.Collections.Generic;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        var map = new Dictionary<string, int>()
        {
            {"AC", 0},
            {"WA", 0},
            {"TLE", 0},
            {"RE", 0}
        };
        for (int i = 0; i < n; i++)
        {
            map[sc.Next()]++;
        }

        foreach (KeyValuePair<string, int> pair in map)
        {
            Console.WriteLine($"{pair.Key} x {pair.Value}");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 34104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)




int main(){
	int n;
	cin >> n;
	if (n == 1) cout << "Hello World" << endl;
	else{
		int a,b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	
	return 0; 
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    ll P[200000] = {0};

    ll ans = 0;
    ll mv = INF;
    REP(i, N) {
        in >> P[i];
        if (P[i] < mv) {
            ans++;
            mv = P[i];
        }
    }
    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans;
    ans = k + 1;
    ll cnt = k;
    ll tot = a;
    cnt -= (a - 1);
    tot += (cnt / 2) * (b - a) + cnt % 2;

    ans = max(ans, tot);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    vector<char> alpha = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    rep(i,s.size()){
        char c=s[i];
        int num = c-'A';
        num = (num+n)%26;
        cout<<alpha[num];
    }


    return 0;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		while self.table[x] >= 0:
			if self.table[self.table[x]] >= 0:
				self.table[x] = self.table[self.table[x]]
			x = self.table[x]
		return x

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
		return

n, q = map(int, input().split())
uf = UnionFind(n)
for _ in range(q):
	t, u, v = map(int, input().split())
	if t == 0:
		uf.unite(u, v)
	else:
		if uf.find(u) == uf.find(v):
			print(1)
		else:
			print(0)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  vector<int> per(n);
  for (int i = 0; i < n; i++) {
    per[i] = i + 1;
  }
  int cnt = 0, pi = 0, qi = 0;
  do {
    cnt++;
    if (per == p) pi = cnt;
    if (per == q) qi = cnt;
  } while (next_permutation(per.begin(), per.end()));
  cout << abs(pi - qi) << '\n';
  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int main(){

	int a,b,c,N,i,j,k,r;
	while(true){

		cin >> a >> b >> c;
		if(a==0 && b==0 && c==0) break;
		cin >> N;

		vector<int>v(a+b+c+1,2);
		int u[N][4];

		rep(p,N){
		cin >> i >> j >> k >> r;

		if(r==1){
		v[i]=1; v[j]=1; v[k]=1;
		u[p][0]=i; u[p][1]=j; u[p][2]=k; u[p][3]=r;
		}
		else{
		u[p][0]=i; u[p][1]=j; u[p][2]=k; u[p][3]=r;
		}
		}

		rep(i,N){
		if(u[i][3]==0){
		if(v[u[i][0]]==1 && v[u[i][1]]==1) v[u[i][2]]=0;
		if(v[u[i][0]]==1 && v[u[i][2]]==1) v[u[i][1]]=0;
		if(v[u[i][1]]==1 && v[u[i][2]]==1) v[u[i][0]]=0;
		}
		}

		REP(i,1,a+b+c) cout << v[i] << endl;

	}

	return 0;
}

Measured memory_bytes: 1208
#include"bits/stdc++.h"
using namespace std;
int main() {
	int N;
	double sum = 0;
	cin >> N;
	vector<double> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += 1 / A[i];
	}
	cout << 1/sum;
}

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

long long const MOD = 1000000007LL;

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

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

    int res = 0;
    int diff = 100000;
    for (int i = 0; i < n; i++) {
        if (diff > abs(aji[i])) {
            res = sum - aji[i];
            diff = abs(aji[i]);
        }
    }
    cout << res << endl;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int count=0;
    int z=0;
    while(n>=1)
    {
      z=n/k;
      n=z;
      count++;
    }
    cout<<count;
}


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

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    int n, m; std::cin >> n >> m;
    std::vector<std::vector<int>> edge(n);
    for(int i = 0; i < m; ++i){
        int u, v; std::cin >> u >> v; --u; --v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    std::vector<bool> Yet(n, true);
    std::vector<int> Stack(n);
    int res = 0;
    for(int i = 0; i < n; ++i) if(Yet[i]){
        int len = 0, cnt = 0;
        Stack[len++] = i; ++cnt; Yet[i] = false;
        while(len){
            const int v = Stack[--len];
            for(const int nv : edge[v]) if(Yet[nv]){
                Stack[len++] = nv; ++cnt; Yet[nv] = false;
            }
        }
        if(res < cnt) res = cnt;
    }
    std::cout << res << '\n';
  
    return 0;
}


Measured memory_bytes: 15548
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b})<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    int N; cin >> N;
    Vi A(N); vector<vector<int> > x(N),y(N);
    int ans=0;
    rep(i,0,N){
        cin >> A[i];
        x[i].rs(A[i]); y[i].rs(A[i]);
        rep(j,0,A[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    for(int bit=0; bit < (1<<N); bit++){
        Vi S(N,0); bool flag = true; int temp=0;
        rep(i,0,N){
            if(bit & (1<<i)){
                S[i]=1;
                temp++;
            }
            //cout << S[i];
        }
        //cout << ", " << temp<<endl;
        rep(i,0,S.size()){
            if(S[i]==0) continue;
            rep(j,0,A[i]){
                if((y[i][j]==1 && S[x[i][j]]==1)
                || (y[i][j]==0 && S[x[i][j]]==0)) continue;
                flag = false;
            }
        }
        if(flag) ans = max(ans,temp);
    }
    COUT(ans);
}

Measured memory_bytes: 256
from collections import deque


def AND(a, b):
    if a == "0" or b == "0":
        return "0"
    elif a == b == "2":
        return "2"
    else:
        return "1"


def OR(a, b):
    if a == "2" or b == "2":
        return 2
    elif a == b == "0":
        return "0"
    else:
        return "1"


def NOT(a):
    if a.count("-") % 2 == 1:
        if a[0] == "0":
            return "2"
        elif a[0] == "2":
            return "0"
        else:
            return "1"
    else:
        return a[0]


def solve(S):
    que = deque()
    for s in S:
        if s == ")":
            formula = ""
            while True:
                q = que.pop()
                if q == "(":
                    break
                formula += q
            if "+" in formula:
                a, b = formula.split("+")
                a = NOT(a)
                b = NOT(b)
                que.append(str(OR(a, b)))
            if "*" in formula:
                a, b = formula.split("*")
                a = NOT(a)
                b = NOT(b)
                que.append(str(AND(a, b)))
        else:
            que.append(s)
    return NOT("".join(reversed(que)))


while True:
    S = input()
    if S == ".":
        break
    count = 0
    for p in range(3):
        for q in range(3):
            for r in range(3):
                if solve(S.replace("P", str(p)).replace("Q", str(q)).replace("R", str(r))) == "2":
                    count += 1
    print(count)


Measured memory_bytes: 5972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int x = sc.nextInt(), n = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for(; n > 0; n--) {
			list.add(sc.nextInt()-x);
		}
		Collections.sort(list);
		int ab = -100;
		for(int i  = -99; i <= 99; i++) {
			if(!list.contains(i) && Math.abs(ab) > Math.abs(i)) {
				ab = i;
			}
		}
		System.out.println(x + ab);
		
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

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


Measured memory_bytes: 32764
n = int(input())
a = list(map(int, input().split()))

ruiseki = [0]*(n+1)
for i in range(n):
    ruiseki[i+1] = ruiseki[i] + a[i]

ans = 10**18
for i in range(n-1):
    ans = min(abs(abs(ruiseki[n] - ruiseki[i+1]) - ruiseki[i+1]), ans)
print(ans)

Measured memory_bytes: 89552
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;
const int INF = 1e9;

class TaskA {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int x;
		cin >> x;
		if(x % 10 == 3){
			cout << "bon" << endl;
		}else{
			if(x % 10 <= 1 or x % 10 == 6 or x % 10 == 8){
				cout << "pon" << endl;
			}else{
				cout << "hon" << endl;
			}
		}
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};

int main(){
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3620
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll n, m, c;
	cin >> n >> m >> c;
	Vec a(m), b(m);
	rep(i, m) cin >> b[i];

	ll ans = 0;
	rep(i, n){
		rep(i, m) cin >> a[i];
		ll sum = c;
		rep(i, m) sum += a[i] * b[i];
		if(sum > 0) ans++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 0

parents = 1

if n == 0:
    if a[0] > 1:
        ans = -1
    else:
        ans = a[0]

if a[0] == 1:
    parents = 0
    ans = 1
    if n != 0:
        ans = -1

parentsls = [0 for _ in range(n+1)]
parentsls[0] = parents

bicapls = [0 for _ in range(n+1)]

for i in range(1, n+1):
    if i != n and parents == 0:
        ans = -1    
        break
    if a[i] > parents*2:
        ans = -1
        break
    else:
        parents = parents*2 - a[i]
        parentsls[i] = parents
    
if ans != -1 and ans != 1:
    node = 0
    for i in range(n):
        if parentsls[n-1-i] >= node + a[n-i]:
            ans += node + a[n-i]
            node = node + a[n-i]
        else:
            ans += node + a[n-i]
            node = parentsls[n-1-i]

    ans += 1

print(ans)


Measured memory_bytes: 669284
n=int(input())
a=[]
import collections as cc
a=[input() for i  in range(n)]
f=cc.Counter(a)
ch=max(f.values())
ans=[]
for i in a:
    if f[i]==ch:
        ans.append(i)
ans=list(set(ans))
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 45812
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);


bool valid(long x) {
    string s = x.to!string;
    return "357".all!(c => s.count(c) > 0)
        && "0124689".all!(c => s.count(c) == 0);
}

int n;
long[] nums;
void dfs(long x) {
    if (x > n) return ;
    if (valid(x))
        nums ~= x;
    dfs(10 * x + 3);
    dfs(10 * x + 5);
    dfs(10 * x + 7);
}

int solve(int x) {
    dfs(0);
    return nums.length.to!int;
}

void main() {
    n = read();
    n.solve.writeln;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define sz(obj) ((int)(obj).size())

int main()
{
  string str;
  int cnt = 0;
  while (cin >> str){
    int ccnt = 0;
    REP(i, sz(str) / 2) if (str[i] == str[sz(str) - (i + 1)]) ccnt++;
    if (ccnt == sz(str) / 2) cnt++;
  }
  cout << cnt << endl;
}

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

int main(){
  int n;
  int count = 1;
  cin >> n;
  vector<char> A(100);
  rep(i,n) cin >> A[i];
  if(n%2 == 1) count = 0;
  else if(n%2 == 0){
    rep(i,n/2){
      if(A[i] != A[i+n/2]){
        count = 0;
        break;
    }
  }
}
  if(count == 0) puts("No");
  if(count == 1) puts("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    
    int M,N,K;
    int array[30+1]={};
    scanf("%d %d",&N,&M);
    for(int i=0; i<N; i++){
        scanf("%d",&K);
        for(int j=0; j<K; j++){
            int a;
            scanf("%d",&a);
            array[a]++;
        }
    }
    int count=0;
    for(int i=0; i<30+1; i++){
        if(array[i] == N)
            count++;
    }
    printf("%d\n",count);
    return 0;
}


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

int main()
{
  int n; cin >> n;
  
  vector<int>a(n);
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort( a.begin(), a.end());
  
  cout << a[n-1] - a[0]  << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, C;
    cin >> n >> C;
    vector<vector<int>> D(C, vector<int>(C, 0));
    rep(i, C) {
        rep(j, C) cin >> D[i][j];
    }
    vector<vector<int>> fi(n, vector<int>(n, 0));
    rep(i, n) {
        rep(j, n) cin >> fi[i][j], --fi[i][j];
    }

    vector<vector<int>> cost(3, vector<int>(C, 0));
    rep(i, C) {
        rep(j, n) {
            rep(k, n) {
                cost[(j + k) % 3][i] += D[fi[j][k]][i];
            }
        }
    }

    int res = INF;
    int c[3];
    for (c[0] = 0; c[0] < C; ++c[0]) {
        for (c[1] = 0; c[1] < C; ++c[1]) {
            if (c[1] == c[0]) continue;
            for (c[2] = 0; c[2] < C; ++c[2]) {
                if (c[2] == c[0] || c[2] == c[1]) continue;
                int tmp = 0;
                for (int it = 0; it < 3; ++it) tmp += cost[it][c[it]];
                res = min(res, tmp);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;


class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] a=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i]=s.nextInt();
        }
        String ret="APPROVED";
        for (int i = 0; i < n; i++) {
            if(a[i]%2==0&&(a[i]%3!=0&&a[i]%5!=0)){
                ret="DENIED";
                break;
            }

        }

        System.out.println(ret);

    }
}

Measured memory_bytes: 22996