akhauriyash/Code-Regression huggingface dataset:
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll DIV = (ll)1e9+7;
// const ll MAXN = (ll)1e5+10;

int main(void) {
   ll N;
   cin>>N;
   ll ans = 0;
   ll A[N];
   rep(i,0,N) cin>>A[i];
   rep(i,0,N) {
      if (A[i]>=2) {
         ans += A[i]/2;
         A[i] = A[i]%2;
      }
      if (i < N-1 && A[i]==1 && A[i+1]>=1) {
         A[i]--;
         A[i+1]--;
         ans ++;
      }
      // cout<<ans<<endl;
   }
   // ll cnt = 0;
   // rep(i,0,N) {
   //    if (A[i] == 1) cnt++;
   //    if (A[i] == 0 || i == N-1) {
   //       ans += cnt/2;
   //       cnt = 0;
   //    }
   // }
   cout<<ans<<endl;

   return 0;
}



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

int main(void)
{
	int i,j,k;
	int count[50002]={}; //????????????????°??????°????????????
	int n,m,coin[20]; //input

	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&coin[i]);
		count[coin[i]]=1;
	}
	i=1;
	while(1){
		for(j=0;j<n;j++){	//????¨????????????§????????????
			if(count[j]==i){
				for(k=0;k<m;k++){//?????????????????°???????????????
					if(j+coin[k]<=n && count[j+coin[k]]==0){
						count[j+coin[k]]=i+1;
					}
					if(count[n]!=0)break;
				}
			}
			if(count[n]!=0) break;
		}
		if(count[n]!=0) break;
		i++;
	}
	printf("%d\n",count[n]);
	
	return 0;
}

Measured memory_bytes: 800
#include<iostream>
using namespace std;
int main(){
int a, b, ans;
  cin >> a >> b;
  if(a > b) {
    ans = a;
    a = a - 1;
  }
  else {
    ans = b;
    b = b - 1;
  }
  if(a > b) ans += a;
  else ans += b;
  cout << ans << endl;
    return 0;
}

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

using namespace std;

int A[20];
int n;

bool solve(int i, int m)
{
	if (m == 0)return true;
	else if (i >= n || m < 0)return false;
	else return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main()
{
	int i, q, m;
	stringstream s;
	cin >> n;
	for (i = 0; i < n; i++)cin >> A[i];
	cin >> q;
	for (i = 0; i < q; i++)
	{
		cin >> m;
		if (solve(0, m))s << "yes" << endl;
		else s << "no" << endl;
	}
	cout << s.str();
    return 0;
}

Measured memory_bytes: 1216
N = int(input())
H = list(map(int, input().split()))

cnt = 0
ans = 0
for idx,val in enumerate(H):
        if idx == N - 1:
                if cnt > ans:
                        ans = cnt
                cnt = 0
                break
        if H[idx + 1] <= val:
                cnt += 1
        else:
                if cnt > ans:
                        ans = cnt
                cnt = 0

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<int,P> PP;

void Main() {
  int n;
  R n;
  PP a[n+1];
  a[0]=PP(0,P(0,0));
  REP(i,1,n+1) cin >> a[i].F >> a[i].S.F >> a[i].S.S;
  sort(a,a+n+1);
  REP(i,1,n+1) {
    int d=abs(a[i-1].S.F-a[i].S.F)+abs(a[i-1].S.S-a[i].S.S);
    int t=abs(a[i-1].F-a[i].F);
    if(d>t||d%2!=t%2) {
      pr("No");
      return;
    }
  }
  pr("Yes");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1408
import java.io.*;
  
public class Main {
    public static void main(String[] args) {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));       
        try {
            String line;
            while((line=r.readLine())!=null){
                /* input from here */
                int m,n;
                m = Integer.parseInt(line.split(" ")[0]);
                n = Integer.parseInt(line.split(" ")[1]);
                if(m<n){
                    int t = m;
                    m = n;
                    n = t;
                }
                /* input till here */
                /* processing from here */
                while(n!=0){
                    int t = n;
                    n = m%n;
                    m = t;
                }
                /* processing till here */
                /* output */
                System.out.println(m);              
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

bool check(int L, int R){
  bool ans = false;
  for(int i = L; i <= R; i++){
    if(i%2019 == 0) ans = true;
  }
  return ans;
}

int main(){
  int L, R;
  cin >> L >> R;
  int ans = 1e9;
  if(R - L >= 2018) cout << 0 << endl;
  else{
    for(int i = L; i < R; i++){
      for(int j = i + 1; j <= R; j++){
        ans = min(ans, ((i%2019)*(j%2019))%2019);
      }
    }cout << ans << endl;
  }
}


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

ll a[110],nw,n,cnt;
char ans[110];
int main(){
	cin>>n;
	
	a[0]=1;
	for(int i=1;i<=100;i++) a[i]=a[i-1]*26;
	while(nw<n){
		nw+=a[++cnt];
	}
	nw-=a[cnt];
	n-=nw;
	for(int i=1;i<=cnt;i++){
		ll x=n/a[cnt-i];
        if(n%a[cnt-i]==0) x--;
        n-=x*a[cnt-i];
        ans[i]=x+'a';
	}
	for(int i=1;i<=cnt;i++)
		cout<<ans[i];
	
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999

int main() {
	int n, a[101] = {},k,ans = 0;
	cin >> n;
	REPO(i, n) {
		cin >> k;
		a[k]++;
	}
	REP(i, 101) if(a[i] > 0) ans++;
	cout << ans << endl;

}




Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String str = sc.next(), ans = "";
			for(int i=0;i<str.length();i++) {
				if( str.charAt(i) == '@' ) {
					i++; int n = str.charAt(i++) - '0';
					for(int j=0;j<n;j++) ans += str.charAt(i);
				} else {
					ans += str.charAt(i);
				}
			}
			System.out.println(ans);
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 11000
import sys
readline = sys.stdin. buffer.readline


s = readline().rstrip()
t = readline().rstrip()
f = 0

if (len(t) - len(s) == 1):
    for i, j in zip(s, t):
        if i != j:
            f = 0
            break
        f = 1

print(['No', 'Yes'][f])

Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#define rep(i,a,b) for(int i = a; i < b; i++)
using namespace std;

int main(){
	int n , d;
	cin >> n >> d;
	int grid[n+1][d+1];
	rep(i,0,n){
		rep(j,0,d){
			cin >> grid[i][j];
		}
	}
	int count = 0;
	rep(x,0,n){
		rep(y,x+1,n){
			long long sum  = 0;
				rep(j,0,d){
					sum += (grid[x][j]-grid[y][j])*(grid[x][j]-grid[y][j]);
				}
				int h = 1;
				while (h*h<=sum){
					if(h*h==sum){
						count ++;
					}
					h++;
				}
			}
		}
		cout << count << endl;
	
}



Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

hands = [None] * N
d1 = {'r': 'p', 's': 'r', 'p': 's'}
d2 = {'r': P, 's': R, 'p': S}
result = 0
for i in range(len(T)):
    if i >= K and d1[T[i]] == hands[i - K]:
        if i + K < N:
            hands[i] = list(set('rps') - set(d1[T[i]]) - set(d1[T[i + K]]))[0]
        else:
            hands[i] = T[i]
    else:
        hands[i] = d1[T[i]]
        result += d2[T[i]]
print(result)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
int main() {
  ll n,k;
  string s;
  cin >> n>>s>>k;
  for (ll i=0;i<n;i++) {
    if (s[i]!=s[k-1]) {
      s[i]='*';
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 101
#define WHITE 0
#define GRAY -1
#define BLACK 1

typedef struct{
  int id;
  int k;
  int color;
  int adj[MAX];
}Graph;

void DFS(void);
void DFSvisit(Graph);
Graph G[MAX];
int d[MAX];
int f[MAX];
int color[MAX];
int n,time;

int main(){
  int u,k,i,j,tmp;
  for(i=1;i<MAX;i++){
    for(j=1;j<MAX;j++){
      G[i].adj[j]=0;
    }
  }
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    G[u].id=u;
    G[u].k=k;
    for(j=1;j<=k;j++){
      scanf("%d",&tmp);
      G[u].adj[j]=tmp;
    }
  }
  DFS();
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;

}

void DFS(){
  int i;
  for(i=1;i<=n;i++){
    G[i].color=WHITE;
  }
  time=0;
  for(i=1;i<=n;i++){
    if(G[i].color==WHITE)DFSvisit(G[i]);
  }
}

void DFSvisit(Graph U){
  int i;
  G[U.id].color=GRAY;
  time++;
  d[U.id]=time;

  for(i=1;i<=U.k;i++){
    if(G[U.adj[i]].color==WHITE){
      DFSvisit(G[U.adj[i]]);
    }
  }
  G[U.id].color=BLACK;
  time++;
  f[U.id]=time;
}

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

const int mod = 998244353;
const int MAX_N = int(2e5) + 10;

int n;
char s[MAX_N];
int pre[MAX_N], f[MAX_N];

int check(int x) {
	int cur = 1, flag = 0;
	for (int i = 1; i <= n; ++i) {
		int t1 = (s[cur] - '0') ^ flag, t2 = s[i] - '0';
		if (t1 > t2)
			return 0;
		else {
			if (t1 < t2) return 1;
			++cur;
			if (cur > x) cur = 1, flag ^= 1;
		}
	}
	return 1;
}

int get(int x) {
	if ((n / x) & 1)
		return pre[x] + check(x);
	else
		return 0;
}

int main() {
	scanf("%d%s", &n, s + 1);
	int tot = 0;
	for (int i = 1; i <= n; ++i) {
		tot = 1LL * tot * 2 % mod;
		if (s[i] == '1')
			tot = (tot + 1) % mod;
		pre[i] = tot;
	}

	for (int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			f[i] = get(i);
			if (n / i != i)
				f[n / i] = get(n / i);
		}
	}

	for (int i = 1; i <= n; ++i) {
		for (int j = i + i; j <= n; j += i) {
			f[j] = (f[j] - f[i] + mod) % mod;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (n % i == 0) {
			ans = (ans + 1LL * f[i] * 2 * i % mod) % mod;
		}
	}
	printf("%d\n", ans);
}

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

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

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


const ll mod = 1000000007;
//const ll mod = 998244353;

const int MAX_N = 1000010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void generate_table(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    generate_table(1000000);
    vector<ll> d(1000010);
    d[0] = 0;
    d[1] = d[2] = d[3] = 1;
    for (int i = 0;i < n;++i) {
        if (i > 2) d[i+1] = (d[i]+d[i-1]+d[i-3])%mod;
        if (i < n-1) (ans += d[i+1]*(n-1)%mod*(n-1)%mod) %= mod; 
        if (i < n-2) (ans += d[i+1]*(i+2)) %= mod;
        else (ans += d[i+1]*(i+1)) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 31488
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int k;
	cin >> k;

	int gu = k / 2;
	int ki = (k + 1 )/ 2;

	cout << gu * ki << endl;

	debug;

}

Measured memory_bytes: 504
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>

using namespace std;

const double eps=1e-8;
const double g=9.8;
const int maxn=10000;

#define Equ(a,b) ((fabs((a)-(b)))<(eps))
#define Less(a,b) (((a)-(b))<(-(eps)))
#define LessEqu(a,b) (((a)-(b))<(eps))
#define More(a,b) (((a)-(b))>(eps))
#define MoreEqu(a,b) (((a)-(b))>(-(eps)))

int main()
{
    //freopen("12381.txt","r",stdin);

    int n;
    double v,X,Y,x,y,t,vx,vy,t1,t2,x1,x2;
    double L[60],B[60],R[60],T[60];
    while(scanf("%d%lf%lf%lf",&n,&v,&X,&Y)!=EOF)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%lf%lf%lf%lf",&L[i],&B[i],&R[i],&T[i]);
        }
        if(Equ(v,0.0))
        {
            printf("No\n");
            continue;
        }

        bool flag=0;

        for(int k=1;k<maxn;k++)
        {
            vx=v*k/maxn;
            vy=sqrt(v*v-vx*vx);
            t=X/vx;
            y=vy*t-0.5*g*t*t;
            if(Less(y,Y)) continue;

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

                if(MoreEqu(X,L[i]))
                {
                    t=L[i]/vx;
                    y=vy*t-0.5*g*t*t;
                    if(MoreEqu(y,B[i])&&LessEqu(y,T[i]))
                    {
                        flag=0;
                        break;
                    }
                }

                if(MoreEqu(vy*vy,2.0*g*B[i]))
                {
                    t1=(vy-sqrt(vy*vy-2.0*g*B[i]))/g;
                    t2=(vy+sqrt(vy*vy-2.0*g*B[i]))/g;
                    x1=vx*t1;
                    x2=vx*t2;
                    if((MoreEqu(X,x1)&&MoreEqu(x1,L[i])&&LessEqu(x1,R[i]))||(MoreEqu(X,x2)&&MoreEqu(x2,L[i])&&LessEqu(x2,R[i])))
                    {
                        flag=0;
                        break;
                    }
                }

                if(MoreEqu(vy*vy,2.0*g*T[i]))
                {
                    t1=(vy-sqrt(vy*vy-2.0*g*T[i]))/g;
                    t2=(vy+sqrt(vy*vy-2.0*g*T[i]))/g;
                    x1=vx*t1;
                    x2=vx*t2;
                    if((MoreEqu(X,x1)&&MoreEqu(x1,L[i])&&LessEqu(x1,R[i]))||(MoreEqu(X,x2)&&MoreEqu(x2,L[i])&&LessEqu(x2,R[i])))
                    {
                        flag=0;
                        break;
                    }
                }

                flag=1;
            }

            if(n==0) flag=1;

            if(flag==1) break;
        }

        if(flag==1) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define N 100005
typedef long long ll; 
using namespace std;
ll k,a[N],best;
ll check(ll x)
{
    for(ll i=1;i<=k;i++){
        if(x<a[i])return -1;
        x-=x%a[i];
    }return x;
}
int main()
{
    scanf("%lld",&k);
    for(ll i=1;i<=k;i++)scanf("%lld",&a[i]);
    best=-1;ll l=0,r=1000000000000000000LL;
    while(l<=r){
        ll mid=(l+r)>>1LL;
        if(check(mid)==-1)l=mid+1;else r=mid-1;
        if(check(mid)==2)best=mid;
    }printf("%lld ",best);if(best==-1){return 0;}
    l=0,r=1000000000000000000LL;best=-1;
    while(l<=r){
        ll mid=(l+r)>>1LL;
        if(check(mid)==-1||check(mid)<=2)l=mid+1;else r=mid-1;
        if(check(mid)==2)best=mid;
    }printf("%lld",best);if(best==-1){return 0;}
    return 0;
}

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

int main(void) {
  ll A, B, C;
  cin >> A >> B >> C;

  cout << min(B / A, C) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i= 1;i<=n;i++) {
            if (String.valueOf(i).length() % 2 == 1 ) ans++;
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 27348
import java.util.Arrays;
    import java.util.Scanner;
     
    public class Main {
    	public static void main (String[] args) {
    		Scanner in = new Scanner(System.in);
    		int h = in.nextInt();
    		int w = in.nextInt();
    		String[] a = new String[h];
    		for (int i = 0; i < h; i++) {
    			a[i] = in.next();
    		}
     
    		boolean[] row = new boolean[h];
    		Arrays.fill(row, false);
    		boolean[] col = new boolean[w];
    		Arrays.fill(col, false);
    		for (int i = 0; i < h; i++) {
    			for (int j = 0; j < w; j++) {
    				if (a[i].charAt(j) == '#') {
    					row[i] = true;
    					col[j] = true;
    				}
    			}
    		}
     
    		for (int i = 0; i < h; i++) {
    			if (row[i]) {
    				for (int j = 0; j < w; j++) {
    					if (col[j]) {
    						System.out.print(a[i].charAt(j));
    					}
    				}
    				System.out.println();
    			}
    		}
    	}
    }

Measured memory_bytes: 24268
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

int main() {
  int N, K, C;
  string s;
  cin >> N >> K >> C >> s;
  ++C;

  vector<int> v1, v2;
  {
    int cnt = 0;
    int i = 0;
    while (cnt < K) {
      if (s[i] == 'o') {
        v1.push_back(i);
        ++cnt;
        i += C;
      } else {
        ++i;
      }
    }
  }

  {
    int cnt = 0;
    int i = N - 1;
    while (cnt < K) {
      if (s[i] == 'o') {
        v2.push_back(i);
        ++cnt;
        i -= C;
      } else {
        --i;
      }
    }
  }

  reverse(v2.begin(), v2.end());
  for (int i = 0; i < K; ++i) {
    // cout << v1[i] << endl;
    // cout << v2[i] << endl;
    if (v1[i] == v2[i]) {
      cout << v1[i] + 1 << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3448
#include<stdio.h>

int board[1000][1000];
int stock[1000000];
int stock2[1000000];
int main(){
  int H,W,i,j,st = 0,st2 = 0,y,x,flag,count = 0;
  char s[1000];
  scanf("%d %d",&H,&W);
  for(i = 0;i < H;i++){
    scanf("%s\n",s);
    for(j = 0;j < W;j++){
      board[i][j] = s[j] == '.';
      if(s[j] == '#'){stock[st] = i*1000+j;st++;}
    }
  }
  while(1){
    flag = 0;st2 = 0;
    for(i = 0;i < st;i++){
      y = stock[i]/1000;
      x = stock[i]%1000;
      if(y > 0&&board[y-1][x]==1){stock2[st2] = stock[i];st2++;flag = 1;}
      if(y < H-1&&board[y+1][x]==1){stock2[st2] = stock[i];st2++;flag = 1;}
      if(x > 0&&board[y][x-1]==1){stock2[st2] = stock[i];st2++;flag = 1;}
      if(x < W-1&&board[y][x+1]==1){stock2[st2] = stock[i];st2++;flag = 1;}
    }
    if(flag == 0){break;}count++;
    st = 0;
      for(i = 0;i < st2;i++){
        y = stock2[i]/1000;
        x = stock2[i]%1000;
        if(y > 0&&board[y-1][x]==1){stock[st] = (y-1)*1000+x;st++;board[y-1][x] = 0;}
        if(y < H-1&&board[y+1][x]==1){stock[st] = (y+1)*1000+x;st++;board[y+1][x] = 0;}
        if(x > 0&&board[y][x-1]==1){stock[st] = y*1000+x-1;st++;board[y][x-1] = 0;}
        if(x < W-1&&board[y][x+1]==1){stock[st] = y*1000+x+1;st++;board[y][x+1] = 0;}
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 11008
#include <iostream>
    #include <stdio.h>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <algorithm>
    #include <string.h>
    #include <vector>
    #include <queue>
    #include <stack>
    #include <set>
    #include <map>
    #include <time.h>
    #define _USE_MATH_DEFINES
    #define LL long long
    #define UN unsigned
    using namespace std;
    const double PI = acos(-1.0);
     
    int max_num(int ary[], int length) {
    	int max = ary[0];
    	for (int i = 1; i < length; i++)
    		if (max < ary[i]) max = ary[i];
    	return max;
    }
     
    int max_ord(int ary[], int length) {
    	int max;
    	max = max_num(ary, length);
    	for (int i = 0; i < length; i++) {
    		if (ary[i] == max) return i;
    	}
    	return -1;
    }
     
    int min_num(int ary[], int length) {
    	int min = ary[0];
    	for (int i = 1; i < length; i++)
    		if (min > ary[i]) min = ary[i];
    	return min;
    }
     
    int min_ord(int ary[], int length) {
    	int min;
    	min = min_num(ary, length);
    	for (int i = 0; i < length; i++) {
    		if (ary[i] == min) return i;
    	}
    	return -1;
    }
     
    int main() {
    	int a, b, c, d, st, go, ans;
    	cin >> a >> b >> c >> d;
    	st = max(a, c);
    	go = min(b, d);
    	ans = go - st;
    	if (ans < 0)
    		ans = 0;
    	cout << ans << endl;
     
    	return 0;
    }

Measured memory_bytes: 256
n = gets.to_i
foods = []
3.times { foods << gets.split(' ').map(&:to_i) }

count = 0
n.times do |i|
  num = foods[0][i]
  count += foods[1][num-1]
  if  num == foods[0][i-1] + 1 && i > 0
    count += foods[2][num-2]
  end
end

puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(1){
        C -= B;
        if (C <= 0){
            cout << "Yes";
            return 0;
        }
        A -= D;
        if (A <= 0){
            cout << "No";
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int g[105][105];

int main()
{
    int n,k; cin >> n >> k;
    if(((n-1) * (n-2))/2 < k){
        cout << -1 << endl;
    }else{
        rep(i,n) rep(j,n) g[i][j] = false;
        rep(i,n){
            rep(j,n){
                if(i == j) continue;
                if(i == 0){
                    g[i][j] = true;
                    g[j][i] = true;
                }
            }
        }
        int cnt = ((n-1) * (n-2))/2;
        rep(i,n) rep(j,n){
            if(i != j && !g[i][j] && k < cnt){
                g[i][j] = true;
                g[j][i] = true;
                cnt--;
            }
        }
        cout << (n*(n-1))/2 - k << endl;
        rep(i,n){
            for(int j = i+1; j < n; j++){
                if(g[i][j]) cout << i+1 << ' ' << j+1 << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int n, k = 2;
int dp[(int)1e5+10];
int a[(int)1e5+10];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n; cin >> a[i++]);
	for(int i = 0; i <= n; ++i) dp[i] = 1e9; 
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= k; ++j)
			if(j <= i) dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1024
import sys
from collections import deque, defaultdict
import copy
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N = int(input())
b = list(map(int, input().split()))

tejun = []
for iteration in range(N):
    judge = 0
    for i in range(len(b)-1, -1, -1):
        if b[i] == i+1:
            judge = 1
            tejun.append(copy.deepcopy(b[i]))
            del b[i]
            break
    if judge == 0:
        break

if judge == 0:
    print(-1)
else:
    for i in range(len(tejun)-1, -1, -1):
        print(tejun[i])

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

int ramen =700;
string s;
int main(){
	cin>>s;
	if(s[0]=='o')ramen=ramen+100;
	if(s[1]=='o')ramen=ramen+100;
	if(s[2]=='o')ramen=ramen+100;
cout<<ramen<<endl;
return 0;
}

Measured memory_bytes: 256
import sys
a=list(map(int,input().split()))
flg=0
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
for i in range(len(A)):
    if A[i]==a[0]:
        for j in range(len(A)):
            if A[j]==a[1]:
                flg=1
for i in range(len(B)):
    if B[i]==a[0]:
        for j in range(len(B)):
            if B[j]==a[1]:
                flg=1
if flg==1:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
	
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n+1);
	vector<long long> aa(n+2);
	vector<int> b(m+1);
	vector<long long> bb(m+2);

	aa[n + 1] = 1ll << 60;
	bb[m + 1] = 1ll << 60;

	int tmpres = 0;
	bool chkflg = false;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		aa[i] = aa[i - 1] + a[i];
		if (aa[i] > k && chkflg == false) {
			chkflg = true;
			tmpres = i - 1;
		}
		if (i == n && chkflg==false) {
			tmpres = n;
		}
	}

	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		bb[i] = bb[i - 1] + b[i];
	}

	int res = tmpres;
	for (int i = tmpres; i >= 0; i--) {

		long long amari = k - aa[i];
		auto itr = lower_bound(bb.begin(), bb.end(), amari) ;
		//cout << *itr << " " << *(itr++) << endl;
		if (*itr != amari) { itr--; }
		int pos = distance(bb.begin(), itr);
		res = max(res, i + pos);

	}

	cout << res << endl;


	return 0;
}

Measured memory_bytes: 8000
#include <stdio.h>
#define SMAX 10000
#define TMAX 500

int main( )
{
  int i=0,j=0,n,q,count=0;
  int S[SMAX],T[TMAX];
  
  scanf("%d",&n);
 
  while(i < n){
    scanf("%d",&S[i]);
    i++;
  }
  
  scanf("%d",&q);

  
  while(j < q ){
  scanf("%d",&T[j]);
  j++;
  }

  for(j=0;j < q;j++){
    for(i=0;i < n;i++){
      if(T[j]==S[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
W , H , x , y = map(int,input().split())
if x == 0 or x == W:
	x_on_line = True
else:
	x_on_line = False
if y == 0 or y == H:
	y_on_line = True
else:
	y_on_line = False


if x_on_line or y_on_line:
	pattern = 0
	S = W * H / 2
else:
	if (W / 2) == float(x):
		x_half_point = True
	else:
		x_half_point = False
	if (H / 2) == float(y):
		y_half_point = True
	else:
		y_half_point = False
	if x_half_point and y_half_point:
		pattern = 1
		S = W * H / 2
	elif x_half_point or y_half_point:
		pattern = 0
		S = W * H / 2	
	else:
		S = W * H / 2
		pattern = 0
print(S,pattern)
	
	

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for(int i = 0;i<N;i++){
    int count = 0;
    for(char c='a';c<='z';c++){
      bool left = false;
      bool right = false;
      for(int j = 0;j<=i;j++){
        if(c == S.at(j)) {
          left = true;
        }
      }
      for(int j = i+1;j<N;j++){
        if(c == S.at(j)) {
          right = true;
        }
      }
      if(left && right) {
        count++;
      }
      ans = max(ans,count);
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e5+1;
const ll INF=4e18;
ll a[maxn],b[maxn],c[maxn];
ll dp[maxn][3];
// dp[i][0] : denotes the maximum happiness that is got by
//			  swimming on the ith day
// dp[i][1] : denotes the maximum happiness that is got by
//			  catching bug on the ith day
// dp[i][2] : denotes the maximum happiness that is got by
//			  doing homework
void solve()
{
	ll N;
	cin>>N;
	for(ll i=1;i<=N;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	
	// Base cases
	dp[1][0]=a[1];
	dp[1][1]=b[1];
	dp[1][2]=c[1];
	
	// Calculating dp[i][0],dp[i][1],dp[i][2] for each i
	for(ll i=2;i<=N;i++)
	{
		// By doing swimming on the ith day, the maximum happiness
		// till the ith day
		// can be got by catching bugs or doing homework on i-1 th day
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		
		// By catching bugs on the ith day, the maximum happiness
		// till the ith day
		// can be got by swimming or doing homework on i-1 th day
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		
		// By doing homework on the ith day, the maximum happiness
		// till the ith day
		// can be got by swimming or catching bugs on i-1 th day
		dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
	}
	ll ans=max(dp[N][0],max(dp[N][1],dp[N][2]));
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 4992
import Data.Functor( (<$>))
import Data.Array.IArray
import Data.Array.Unboxed
import Data.Array.MArray( newListArray, freeze)
import Data.Array.IO
import Control.Monad

main = do
    n <- read <$> getLine
    values <- (read <$>) . words <$> getLine 
    a <- newListArray (0,n-1) values		::IO (IOUArray Int Int)
    let
	selectionScan i_
	  = do
	    let
		searchMinIx::Int -> Int -> Int -> IO Int
		searchMinIx nowMin ixNowMin iterator
		  | n <= iterator		    = return ixNowMin
		  | otherwise
		    = do
			v <- readArray a iterator
			if v < nowMin
			then searchMinIx    v	iterator (iterator+1)
			else searchMinIx nowMin ixNowMin (iterator+1)

		swap::Int -> Int -> IO ()
		swap i j = do
		    temp <- readArray a i
		    writeArray a i =<< readArray a j
		    writeArray a j temp

	    startmin <- readArray a i_
	    ixmin <- searchMinIx startmin i_ i_
	    if i_/=ixmin
	    then swap i_ ixmin >> return 1
	    else return 0
    
    selectionSortSwapCount <- sum <$> forM [0..n-1]
					    selectionScan
    ia <- freeze a  ::IO (UArray Int Int)
    putStrLn . unwords $ show <$> elems ia
    print selectionSortSwapCount




Measured memory_bytes: 4148
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                Boolean[][] check = new Boolean[9][9];
                for (int i = 0; i < 9; i++) {
                        for (int j = 0; j < 9; j++) {
                                check[i][j] = false;
                        }
                }
                for (int i = 0; i < 3; i++) {
                        for (int j = 0; j < 3; j++) {
                                if (i + 1 < 3) {
                                        check[i*3+j][(i+1)*3+j] = true;
                                        check[(i+1)*3+j][i*3+j] = true;
                                }
                                if (i - 1 >= 0) {
                                        check[i*3+j][(i-1)*3+j] = true;
                                        check[(i-1)*3+j][i*3+j] = true;
                                }
                                if (j + 1 < 3) {
                                        check[i*3+j][i*3+j+1] = true;
                                        check[i*3+j+1][i*3+j] = true;
                                }
                                if (j - 1 >= 0) {
                                        check[i*3+j][i*3+j-1] = true;
                                        check[i*3+j-1][i*3+j] = true;
                                }
                        }
                }
                for (int i = 0; i < 1000; i++) {
                        String S = sc.next();
                        int now = S.charAt(0) - 'A';
                        boolean f = true;
                        for (int j = 1; j < S.length(); j++) {
                                int next = S.charAt(j) - 'A';
                                if (check[now][next]) {
                                        now = next;
                                        continue;
                                }else{
                                        f = false;
                                        break;
                                }
                        }
                        if (f) {
                                System.out.println(S);
                        }
                }
        }
}

Measured memory_bytes: 30268
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e9 + 7;
ll inf = 1e9 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}





int main() {
    int n;
    cin >> n;
    vector<ll>vec(n);
    cin >> vec;
    ll maxx = 0;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        if (vec[i] < maxx) sum += maxx - vec[i];
        maxx = max(maxx, vec[i]);
    }
    cout << sum;

}

Measured memory_bytes: 4460
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll h;
ll dfs(ll x)
{
	if(x==1)return 1;
	return 2*dfs(x/2)+1;
}
int main()
{
	scanf("%lld",&h);
	printf("%lld\n",dfs(h));
	return 0;
} 

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

using namespace std;
typedef long long int ll;

#define p(V) for(int iiv=0;iiv<V.size();iiv++) cout<<V[iiv]<<" ";
#define mp make_pair
#define pb push_back
#define graph vector<vector<int> >
#define pf first
#define ps second
#define pq priority_queue
const int N = 2e5;
const int l = 18;
const double pi = acos(-1);
int n , w ;
ll dp[111][N];
vector<pair<int,int> > v;
ll calc(int idx,int w){
    if(idx==n || (!w)) return 0;
    if(dp[idx][w]!=-1) return dp[idx][w];
    ll ret = calc(idx+1,w);
    if(v[idx].pf <= w) ret = max(ret,v[idx].ps+calc(idx+1,w-v[idx].pf));
    return dp[idx][w]=ret;
}
int main(){
    memset(dp,-1,sizeof dp);
    cin >> n >> w;
    v.resize(n);
    for(int i=0;i<n;i++) cin >> v[i].pf >> v[i].ps;
    cout<<calc(0,w);
    return 0;
}


Measured memory_bytes: 173696
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    double r, l, s;
    
    scanf("%lf", &r);
    
    l = r * 2 * M_PI;
    s = r * r * M_PI;
    
    printf("%lf %lf\n", s, l);
    
    return 0;
}


Measured memory_bytes: 2104
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

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

const ll mod = 998244353;
const double eps = DBL_EPSILON;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ll n, k;
    cin >> n >> k;
    if (n > k) n = n - k * (n / k);
    cout << min(n, k - n) << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
p=['6']
ans='Yes'
for i in range(N):
  W=input()
  if i!=0:
    if p[-1][-1]!=W[0]:
      ans='No'
      break
  if W in p:
    ans='No'
    break
  else:
    p.append(W)
print(ans)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) (c).begin(),(c).end()
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,X;
int S[210];
int dp[210][100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> X;
  REP(i,N) cin >> S[i];
  sort(S,S+N);
  REP(i,100010) dp[0][i] = i;
  REP(i,N) REP(j,100010) {
    (dp[i+1][j] += dp[i][j%S[i]]) %= MOD;
    (dp[i+1][j] += dp[i][j]*i) %= MOD;
  }
  cout << dp[N][X] << endl;

  return 0;
}

Measured memory_bytes: 157952
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

int a[20][20];

void solve(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int>b(m);
  forn(i,m) cin >> b[i];
  forn(i,n)forn(j,m) cin >> a[i][j];
  int ans = 0;
  forn(i,n){
    int sm = 0;
    forn(j,m){
      debug() << imie(a[i][j] * b[j]);
      sm += a[i][j] * b[j];
    }
    debug() << imie(sm);
    sm += c;
    debug() << imie(c);
    debug() << imie(sm);
    ans += sm > 0;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    vector<int> hoge(3);

    rep_i(i, 3) cin >> hoge[i];
    
    cout << *min_element(hoge.begin(), hoge.end()) << " " << *max_element(hoge.begin(), hoge.end()) << endl;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    set<string> visit;
    string W; cin >> W;
    char z = W.at(W.size() - 1);
    string ans = "Yes";
    visit.insert(W);
    for (int i = 0; i < N - 1; i++) {
        cin >> W;
        if (visit.count(W)) {
            ans = "No";
            break;
        }
        visit.insert(W);
        if (W.at(0) != z) {
            ans = "No";
            break;
        }
        z = W.at(W.size() - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

ll = []
for i in range(k):
    ll.append(t[i::k])

ans = 0
for l in ll:
    x = ""
    for v in l:
        if x != v:
            if v == "r":
                ans += p
            elif v == "s":
                ans += r
            else:
                ans += s
            x = v
        else:
            x = ""
            
print(ans)

Measured memory_bytes: 47472
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define in(x) scanf("%d",&x)
#define out(x) printf("%d\n",x)
#define ll long long

int a,b,ans;
signed main(){
	in(a),in(b);
	ans=3*a+b;
	if(ans<2){
		cout<<0<<endl;
		return 0;
	}
	ans/=2;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  print_newline ();
  preorder (fun e -> print_string " "; print_int e) t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    match read_line () |> split_on_char ' ' with
    | ["insert"; n] -> t := insert (int_of_string n) !t
    | ["find"; n] -> print_endline (if find (int_of_string n) !t then "yes" else "no")
    | _ -> print !t
  done

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

#define int long long

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

string s, t;
char s_ary[100] = {}, t_ary[100] = {};

signed main() {
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        s_ary[i] = s[i];
    }
    for (int i = 0; i < t.length(); i++) {
        t_ary[i] = t[i];
    }
    sort(s_ary, s_ary + s.length());
    sort(t_ary, t_ary + t.length(), [](int x, int y) {
        return x > y;
    });
    for (int i = 0; i < 100; i++) {
        if (s_ary[i] < t_ary[i]) {
            cout << "Yes" << endl;
            return 0;
        }
        if (s_ary[i] > t_ary[i]) {
            break;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main() {
  int N;
  cin >>N;
  vector<int> vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
sort(all(vec));
  vector<int> C(100);
  repl(i,1,101) {
    
      int sum=0;
      rep(j,N) {
        sum +=(i-vec.at(j))*(i-vec.at(j));
      }
    C.at(i-1)=sum;
  }
  sort(all(C));
  cout<<C.at(0)<< endl;
}
 

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

int main() {
    long N;
    cin >> N;
    long sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0) {
            continue;
        }
        else if (i % 5 == 0) {
            continue;
        }
        else {
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3596