akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
  int n;
  int i,j,k;
  int build[4][3][10]={{{}}};
  cin >> n;
  int b,f,r,v;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    build[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	cout << " ";
	cout << build[i][j][k];
      }
      cout << endl;
    }
    if(i<3)cout << "####################" << endl;
  }
  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
  while(u != NIL && k !=  u->key ) {
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k) {
	Node *y=NIL;
	Node *x=root;
	Node *z;
	
	z=(Node *)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;
	
	while(x!=NIL) {
		y=x;
		if(z->key < x->key) x=x->left;
		else x=x->right;
	}
	z->parent=y;
	if(y==NIL) root=z;
	else {
		if(z->key < y->key) y->left=z;
		else y->right=z;
	}
}

void inorder(Node *u) {
	if(u==NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u) {
	if(u==NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int i,n,x;
	string com;
	
	scanf("%d",&n);
	
	for(i=0;i<=n-1;i++) {
		cin >> com;
    if(com[0]=='f') {
      scanf("%d", &x);
      Node *t = find(root, x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    } else if(com=="insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com=="print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 22056
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   #ifndef ONLINE_JUDGE
      // freopen("input.txt", "r", stdin);
      // freopen("output.txt", "w", stdout);
   #endif
   int n;
   cin >> n;
   int chk = 1;
   f(i,0,n){
      int x;cin >> x;
      if(!(x & 1)){
         if(x%3!=0 and x%5 != 0){
            cout << "DENIED\n";
            return 0;
         }
      }
   }
   cout << "APPROVED\n";
   return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int array[n];
    for (int i = 0; i < n; i++)
    {
        cin >> array[i];
    }

    int min = array[0];
    int max = array[0];
    long sum = 0;

    for (int i = 0; i < n; i++)
    {
        if (array[i] > max)
        {
            max = array[i];
        }
        else if (min > array[i])
        {
            min = array[i];
        }
        
        sum += array[i];
    }

    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#define llint unsigned long long 
#define B 1000000007

using namespace std;

int Q;
string s;
llint beki[100005];
llint hash[100005];

llint getsub(llint l, llint r)
{
	return hash[r] - hash[l-1] * beki[r-(l-1)];
}

int main(void)
{
	cin >> s;
	int n = s.size();
	s = "#" + s;
	
	beki[0] = 1;
	for(int i = 1; i <= n; i++) beki[i] = beki[i-1] * B;
	for(int i = 1; i <= n; i++) hash[i] = hash[i-1] * B + s[i];
	
	cin >> Q;
	for(int q = 0; q < Q; q++){
		int l, r, t;
		cin >> l >> r >> t;
		
		int L = r - l + 1;
		if(t == L){
			cout << "Yes" << endl;
			continue;
		}
		
		int ub = L-t+1, lb = 0, mid;
		while(ub - lb > 1){
			mid = (ub + lb) / 2;
			if(getsub(l, l+mid-1) == getsub(l+t, l+t+mid-1)) lb = mid;
			else ub = mid;
		}
		if(lb == L-t){
			cout << "Yes" << endl;
			continue;
		}
		
		int x = l+lb, y = l+lb+t;
		llint h = (getsub(l, x-1) * B + s[y]) * beki[(r-t)-x] + getsub(x+1, r-t);
		if(h == getsub(l+t, r)){
			cout << "Yes" << endl;
			continue;
		}
		
		h = (getsub(l, y-1) * B + s[x]) * beki[(r-t)-y] + getsub(y+1, r-t);
		llint h2 = (getsub(l+t, y-1) * B + s[x]) * beki[r-y] + getsub(y+1, r);
		if(h == h2){
			cout << "Yes" << endl;
			continue;
		}
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 4884
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int k;
    string s;
    cin >> s >> k;
    int onecnt = 0;
    rep(i,s.size()){
        if(s[i] - '0' == 1)onecnt++;
        else break;
    }
    if(onecnt >= k)cout << 1 << endl;
    else cout << s[onecnt]- '0' << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    int n;
    cin >> n;
    long long int ans = 1000000000;
    long long int sum = 0;
    int i, j;
    vector<long long int>x(n);
    for (i = 0; i < n; i++)
    {
        cin >> x.at(i);
    }
    for (i = 1; i <= 100; i++)
    {
        for (j = 0; j < n; j++)
        {
            sum += (x.at(j) - i) * (x.at(j) - i);
        }
        ans = min(ans, sum);
        sum = 0;

    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	while(1) {
		s.pop_back();
		string x = s.substr(0, s.size() / 2);
		string y = s.substr(s.size() / 2, s.size() / 2);
		if (x == y) {
			cout << x.size()+y.size() << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A_sum = sum(A)
A_dict = {}

for a in A:
    if a not in A_dict:
        A_dict[a] = 0
    A_dict[a] += 1

Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    b = B[i]
    c = C[i]
    if b not in A_dict:
        num = 0
    else:
        num = A_dict[b]
        A_dict[b] = 0
    print(A_sum - num*b + num*c)
    A_sum = A_sum - num*b + num*c
    if c not in A_dict:
        A_dict[c] = 0
    A_dict[c] += num

Measured memory_bytes: 25976
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    cin >> N;
    if(N==1){
        cout<<"Hello World"<<endl;
        return 0;
    }else{
        int A,B;
        cin >> A >> B;
        cout<<A+B<<endl;
        return 0;
    }
    return 0;
}


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

int main(){

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  bool check = true;

  if (n%2 == 0) {//n:even
    for (int i = 0; i < n; i = i + 2) {
      if (!(i + 1 == a.at(i) && i + 1 == a.at(i+1))) {
        check = false;
        break;
      }
    }
  } else {//n:odd
    for (int i = 1; i < n; i = i + 2) {
      if (a.at(1) == 0 || a.at(0) != 0) {//0は1こまでou最初は0
        check = false;
        break;
      }

      if ((i + 1 == a.at(i) && i == a.at(i+1))) {
        check = false;
        break;
      }
    }
  }

  if (check) {
    ll cnt = 1;
  	for (int i = 1; i <= n / 2; i++) {
      cnt = (cnt << 1) % 1000000007;
  	}
  	cout << cnt << endl;
     } else {
    cout << "0" << endl;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  int a,b;
  cin >> a >> b;
  if(a >= 13){
    cout << b;return 0;
  }
  else if(a <= 5){
    cout << 0;return 0;
  }
  else {
    cout << b/2;return 0;
  }
  return 0;
}


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

static long MOD = 1000000007;

int main(){
     int n;
     char s[100005];
     long dp[100005][13];

     int i,j,ki;
     long res=0;
     scanf("%s\n",s);
    
     n=strlen(s);

     dp[0][0] =1;
     for(i=0; i<n; i++){
         int c;
         if(s[i]=='?') c=-1;
         else c= s[i] - '0';
 
         for(j=0; j<10; j++){
             if(c!=-1 && c != j) continue;
             for(ki=0; ki<13; ki++){
                 dp[i+1][(ki*10+j)%13] += dp[i][ki];
             }
         }
         for(j=0; j<13; j++) dp[i+1][j] %= MOD;
     } 
     res = dp[n][5];

     cout << res << endl;
     return 0;
}

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

bool isSafe[105];

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	
	int i;
	for(i = 1; i <= K; i++)
	{
		int k;
		scanf("%d", &k);
		
		for(int j = 1; j <= k; j++)
		{
			int m;
			scanf("%d", &m);
			
			isSafe[m] = true;
		}
	}
	
	int ans = 0;
	for(i = 1; i <= N; i++)
	{
		if(!isSafe[i])
			ans++;
	}
	
	printf("%d", ans);
}


Measured memory_bytes: 3824
//Distance
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    long long N,D;
    cin >> N >> D;
    long long count = 0;
    for (int i = 0; i < N; i++) {
        long long X,Y;
        cin >> X >> Y;
        double res = sqrt((X*X) + (Y*Y));
        if (res <= (double) D) {
            count++;
        }
    }   
    cout << count << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  rep(i, n) { cin >> w[i]; }
  rep(i, n) {
    rep(j, n) {
      if (i == j) continue;
      if (w[i] == w[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  rep(i, n - 1) {
    int m = sz(w[i]);
    if (w[i][m - 1] != w[i + 1][0]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  sum = 0
  k = i
  while k > 0:
    sum = sum + k % 10
    k = k // 10
  if A <= sum <= B:
    ans = ans + i
print(ans)



  


Measured memory_bytes: 2940
import math
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))
F = sorted(list(map(int,input().split())),reverse=True)
high = 0
for i in range(N):
    high = max(high,A[i]*F[i])
low = -1
while high-low>1:
    mid = (high+low)//2
    flag = 1
    T = K
    for i in range(N):
        if A[i]*F[i]<=mid:continue
        else:
            T -= math.ceil(A[i]-mid/F[i])
            if T<0:
                flag = 0
                break
    if flag==1:
        high = mid
    else:
        low = mid
print(high)

Measured memory_bytes: 121292
#include<iostream>
#include<stdio.h>
using namespace std;
class diceroll{
    public:
    int num[6],new_num[6];
    void refresh();
    void turn_N();
    void turn_S();
    void turn_E();
    void turn_W();
};
    
void diceroll::refresh(){
    for(int i=0;i<6;i++){
        num[i]=new_num[i];
    }    
}
void diceroll::turn_N(){
    new_num[0]=num[1];
    new_num[1]=num[5];
    new_num[5]=num[4];
    new_num[4]=num[0];
    new_num[2]=num[2];
    new_num[3]=num[3];
}

void diceroll::turn_S(){
    new_num[0]=num[4];
    new_num[4]=num[5];
    new_num[5]=num[1];
    new_num[1]=num[0];
    new_num[2]=num[2];
    new_num[3]=num[3];
}

void diceroll::turn_E(){
    new_num[0]=num[3];
    new_num[3]=num[5];
    new_num[5]=num[2];
    new_num[2]=num[0];
    new_num[1]=num[1];
    new_num[4]=num[4];
}

void diceroll::turn_W(){
    new_num[0]=num[2];
    new_num[2]=num[5];
    new_num[5]=num[3];
    new_num[3]=num[0];
    new_num[1]=num[1];
    new_num[4]=num[4];
}

int main(){
    diceroll a;
    int b,num_1[6];
    bool c=false;
    b=0;
    
    for(int i=0;i<6;i++){
        cin >> a.num[i];
    }
    for(int i=0;i<6;i++){
        cin >> num_1[i];
    }
    
    for(int i=0;i<4;i++){
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(a.new_num[0]==num_1[0]&&a.new_num[1]==num_1[1]&&a.new_num[2]==num_1[2]&&a.new_num[3]==num_1[3]&&a.new_num[4]==num_1[4]&&a.new_num[5]==num_1[5]){
                    c=true;
                }
                if(c)break;
                a.turn_W();
                a.refresh();
            }
            if(c)break;
            a.turn_S();
            a.refresh();
        }
        if(c)break;
        a.turn_W();
        a.refresh();
    }
    
    if(c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}




Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N;
    cin >> N;
    const int NUM = 110;
    int vec[NUM], num[NUM] = {};
    REP(i, N) cin >> vec[i];
    
    // calculation
    REP(i, N) {
        num[vec[i]]++;
    }
    
    int sum = 0;
    REP(i, NUM) {
        if (num[i] != 0) {
            sum++;
        }
    }
    
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#define ll long long

using namespace std;

ll N;
vector<long long> ans_vec;

void check(long long x){
    ll keep=x;
    ll three=0,five=0,seven=0;
    while(x>0){
        ll r=x%10;
        if(r==3){
            three++;
            x/=10;
        }
        else if(r==5){
            five++;
            x/=10;
        }
        else if(r==7){
            seven++;
            x/=10;
        }
        else if(r!=3&&r!=5&&r!=7){
            exit(0);
        }
    }
    if(three!=0&&five!=0&&seven!=0&&keep<=N){
        ans_vec.push_back(keep);
    }
}

void dfs(ll x){
    check(x);
    if(x<=N){
        dfs(10*x+3);
        dfs(10*x+5);
        dfs(10*x+7);
    }
}

int main(){
    cin >> N;
    dfs(0);
    cout << ans_vec.size() << endl;
    return 0;
}


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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	vector <vector<int>> letters(26);
	for (int i = 0; i < (int)s.size(); i++) {
		letters[s[i] - 'a'].push_back(i);
	}
	int ind = -1;
	long long total = 0;
	for (auto c : t) {
		int letter = c - 'a';
		if (letters[letter].empty()) {
			cout << -1;
			return 0;
		}
		auto it = upper_bound(letters[letter].begin(), letters[letter].end(), ind);
		if (it == letters[letter].end()) {
			total += (int)s.size() - 1 - ind;
			ind = letters[letter][0];
			total += ind + 1;
		} else {
			int x = *it;
			total += x - ind;
			ind = x;
		}
	}
	cout << total;
	return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (h[i] >= k)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3988
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
A = A[::-1]
X = sum(A)
Y = 1/4/M
ans = 'Yes'
for i in range(M):
  if A[i]/X < Y:
    ans = 'No'
print(ans)

Measured memory_bytes: 9084
S=input()
used=[0,0,0]
for x in S:
  if x=="a" and used[0] == 0:
    used[0]=1
  elif x=="b" and used[1]==0:
    used[1]=1
  elif x=="c" and used[2]==0:
    used[2]=1
  else:
    print("No")
    exit(0)
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a;
  cin>>a;
  V<P<double,string>> b(a);
  fo(i,a){
    cin>>b[i].fi>>b[i].se;
  }
  double c=0;
  fo(i,a){
    if(b[i].se=="JPY")
      c+=b[i].fi;
    else
      c+=b[i].fi*380000.0;
  }
  cout<<yuko(6)<<c<<endl;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())

a = [[1 for i in range(w)] for j in range(h)]

for i in range(h):
    s = input()
    for j in range(w):
        a[i][j] = int(s[j])

best_result = h * w + 1000

for m in range(2 ** (h - 1)):
    mask = m
    num_splits = 0
    splits = []
    i = 0
    while mask > 0:
        if (mask % 2) == 1:
            num_splits += 1
            splits.append(i)
        i += 1
        mask = mask // 2

    #print('mask = ', m, 'splits = ', splits, 'num_splits =', num_splits)

    counts = [0 for j in range(num_splits + 1)]
    current_counts = [0 for j in range(num_splits + 1)]
    result = num_splits

    for j in range(w):
        if result >= best_result:
            break
        split_index = 0
        success = True
        current_counts[0] = 0

        for i in range(h):
            if a[i][j] == 1:
                counts[split_index] += 1
                if counts[split_index] > k:
                    success = False

            current_counts[split_index] += a[i][j]

            if split_index < num_splits and i == splits[split_index]:
                split_index += 1
                current_counts[split_index] = 0

        if not success:
            result += 1
            #print('not success j = ', j, 'result = ', result, 'counts = ', counts)
            fail = False
            for x in range(num_splits + 1):
                if current_counts[x] > k:
                    fail = True
                    break

                counts[x] = current_counts[x]
            if fail: 
                result = best_result + 1
                break
            

    best_result = min(best_result, result)

print(best_result)

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

cnt = [0] * (n+1)
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        p = a[j]
        cnt[p] += 1

ans = 0
for i in range(1, n+1):
    if cnt[i] == 0:
        ans += 1
print(ans)



Measured memory_bytes: 9204
N = input()
n = map(int, raw_input().split())

ans = 0

for i in range(1, len(n) - 1):
  if n[i] < n[i - 1] and n[i] > n[i + 1]:
    ans += 1
  if n[i] > n[i - 1] and n[i] < n[i + 1]:
    ans += 1

print ans

Measured memory_bytes: 2568
def selection_sort(alist):
    """Sort alist by selection sort.
    Returns the sorted list and number of swap operation.

    >>> selection_sort([5, 6, 4, 2, 1, 3])
    ([1, 2, 3, 4, 5, 6], 4)
    """
    size = len(alist)
    c = 0

    for i in range(size):
        mini = i
        for j in range(i, size):
            if alist[mini] > alist[j]:
                mini = j

        if i != mini:
            alist[i], alist[mini] = alist[mini], alist[i]
            c += 1

    return (alist, c)


def run():
    _ = int(input()) # flake8: noqa
    nums = [int(i) for i in input().split()]

    (sortednums, count) = selection_sort(nums)

    print(" ".join([str(i) for i in sortednums]))
    print(count)


if __name__ == '__main__':
    run()



Measured memory_bytes: 5620
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i)=(a);(i)<=(b);(i)++)
#define Rep(i, a, b) for (int (i)=(a)-1;(i)<(b);(i)++)
#define REP(i, a, b) for (int (i)=(a);(i)>=(b);(i)--)
#define reg(i, x) for (int (i)=head[x];(i);i=e[i].next)
#define clr(a) memset(a,0,sizeof(a))
#define Sort(a, len) sort(a + 1, a + len + 1)
#define Sort2(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ull unsigned long long
#define ll long long
#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define Pii pair<int, int>

const int N = 100010 ;
const int iinf = INT_MAX/2 ;
const ll linf = LLONG_MAX/2 ;
const int MOD = 1e9+7 ;

inline int read(){
    int X = 0,w = 0 ;
	char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}

void write(int x){
     if(x < 0) putchar('-'),x = -x;
     if(x > 9) write(x / 10);
     putchar(x%10 + '0');
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

int n, t, tot1, tot2 ;
int a[N], b[N], c[N] ;
vector <Pii> B, C ;

bool cmp(Pii a, Pii b){
	return a.fi > b.fi ;
}

int main(){
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]) ;
	for (int i = 1; i <= n; i++){
		t = max(t, a[i]) ;
		if (i % 2 == 1) b[a[i]]++ ;
		else c[a[i]]++ ;
	}
	for (int i = 1; i <= t; i++) if (b[i] != 0) B.pb(mp(b[i], i)) ;
	for (int i = 1; i <= t; i++) if (c[i] != 0) C.pb(mp(c[i], i)) ;
	B.pb(mp(0, 0)) ;
	C.pb(mp(0, 0)) ;
	sort(B.begin(), B.end(), cmp) ;
	sort(C.begin(), C.end(), cmp) ;
//	for (int i = 0; i < B.size(); i++) cout << B[i].fi << " " << B[i].se << endl ;
//	for (int i = 0; i < C.size(); i++) cout << C[i].fi << " " << C[i].se << endl ;
	if (B[0].se == C[0].se) {
		int ans = min(n - B[1].fi - C[0].fi, n - B[0].fi - C[1].fi) ;
		cout << ans << endl ;
	}
	else cout << n - B[0].fi - C[0].fi << endl ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.特殊情况处理好了么？
	3.做一些总比不做好。
	4.最大值和最小值问题可不可以用二分答案？
	5.有没有贪心策略？否则能不能dp？
	6.实数精度有没有处理？
*/


Measured memory_bytes: 2552
import sys
all_data = sys.stdin.readlines()

line1 = [int(a) for a in all_data[0].split()]
points_num = line1[0]
dimensions = line1[1]

data_int = []
for item in all_data[1:points_num + 1]:
    tuple_str = item.split()
    tuple_int = [int(a) for a in tuple_str]
    data_int.append(tuple_int)
    
def dii(coor1, coor2):
    import math
    pyth_sum = 0
    for dimension in range(0, dimensions):
        pyth_sum += (coor1[dimension] - coor2[dimension])**2
    distance = math.sqrt(pyth_sum)
    if distance % 1 == 0:
        return True
    else:
        return False

num_pairs = 0

for idx1, val1 in enumerate(data_int):
    coor1 = val1
    for idx2, val2 in enumerate(data_int[idx1 + 1:]):
        coor2 = val2
        if dii(val1, val2):
            num_pairs += 1

print(num_pairs, end="")



Measured memory_bytes: 3064
K,S= list(map(int, input().split()))
ans=0
for i in range(S//3,K+1):
    for j in range(i+1):
        if i+j>S:
            break
        if i+j*2<S:
            continue
        if S-i-j<=j:
            k=S-i-j
            if i==j==k:
                ans+=1
            elif i==j or j==k:
                ans+=3
            else:
                ans+=6
print(ans)

Measured memory_bytes: 41836
from itertools import groupby, accumulate, product, permutations, combinations
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
ans = 0
for p in product([0,1],repeat=H+W):
  cnt = 0
  for i in range(H):
    for j in range(W):
      if S[i][j]=='#' and p[i]==0 and p[H+j]==0:
        cnt += 1
  if cnt == K:
    ans += 1
print(ans)

Measured memory_bytes: 68320
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>

using namespace std;

class ATransfer {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b, c;
        in >> a >> b >> c;
        out << max(0, c - (a - b)) << endl;

    }
};


int main() {
	ATransfer solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
/*
  Contest 102
  A - Multiple of 2 and N
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

using ull = unsigned long long int;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    ull n = 0;
    std::cin >> n;
    ull m = n;
    while (1) {
        if ((m % n == 0) && !(m & 1)) {
            std::cout << m << std::endl;
            break;
        }
        m += n;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

vector<pair<int, int> > ans;

void make_ans(int start, int level){
	if (level == 1 || level == 0){
		ans.push_back(make_pair(start+1, start+level+2));
		return;
	}
	ans.push_back(make_pair(start+1, start+level+2));
	make_ans(start+1, level-2);
	return;
}

int main(){
	int n, m;
	cin >> n >> m;
	make_ans(0, m-1);
	if (m > 1) make_ans(m+1, m-2);
	for (int i = 0; i < m; i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 6476
N, X = [int(_) for _ in input().split()]

from itertools import permutations

def calc(x):
    def sub(y, debug=0):
        if debug:
            print("D", y)
        while len(y) > 1:
            y = [sorted(y[i:i+3])[1] for i in range(len(y) - 2)]
            if debug:
                print("D", y)
        return y
    y = sub(x)
    return y[0]

if X == 1 or X == N * 2 - 1:
    print("No")
else:
    print("Yes")
    if X == N * 2 - 2:
        xs = list(range(N - 1, X + 2)) + list(range(1, N - 1))
    else:
        ys = list(range(1, X - 1)) + list(range(X + 3, N * 2))
        xs = ys[:N-3] + [X + 2, X - 1, X, X + 1] + ys[N-3:]
    for x in xs:
        print(x)


Measured memory_bytes: 16088
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

temp = [a,b,c,d,e]
temp.sort()

ans = 0
if N > temp[0]:
    if N%temp[0]!=0:
        ans = 4 + N//temp[0] + 1
    else:
        ans = 4 + N//temp[0]
else:
    ans = 5

print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

class Program
{
    static void Main(string[] args)
    {
        var sp = ReadLine().Split();
        int count = Parse(sp[1]);
        var leftRight = new SortedList<int, int>(count);
        for (int i = 0; i < count; ++i)
        {
            sp = ReadLine().Split();
            int left = Parse(sp[0]);
            int right = Parse(sp[1]);
            if (!leftRight.ContainsKey(left) || right < leftRight[left])
            {
                leftRight[left] = right;
            }
        }
        int minRemoved = MaxValue;
        int result = 0;
        var keys = leftRight.Keys.ToArray();
        for (int i = keys.Length - 1; 0 <= i; --i)
        {
            var left = keys[i];
            var right = leftRight[left];
            if (right <= minRemoved)
            {
                ++result;
                minRemoved = left;
            }
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 18508
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

a, b = Is()
print(a*b)

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

ll calc(ll x) {
    ll ret = 0;
    while(x % 2 == 0) {
        x /= 2;
        ret++;
    }
    return ret;
}

signed main()
{
    ll N;
    cin >> N;
    ll ans = LLINF;
    REP(i, N) {
        ll x;
        cin >> x;
        ans = min(ans, calc(x));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<pair< pair<int,int> ,int> > city(m);
	for(int i = 0; i < m; i++){
		cin >> city[i].first.first >> city[i].first.second;
		city[i].second = i+1;
	}
	sort(all(city));

	int cnt = 1;
	for(int i = 0; i < m; i++){
		city[i].first.second = cnt;
		cnt++;
		if(i!=m-1 && city[i].first.first != city[i+1].first.first) cnt = 1;
	}
	vector<pair<int,pair<int,int>> > ans(m);
	for(int i = 0; i < m; i++){
		ans[i].first = city[i].second;
		ans[i].second.first = city[i].first.first;
		ans[i].second.second = city[i].first.second;
	}
	sort(all(ans));
	for(int i = 0; i < m; i++){
		printf("%06d%06d\n", ans[i].second.first,ans[i].second.second);
	}

	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p.at(i);
  
  int cnt = 0;
  rep(i,n-1){
    if(p.at(i) == i+1){
        cnt ++;
        swap(p.at(i),p.at(i+1));
      }
  }
  
  if(p.at(n-1) == n) cnt ++;
  
  cout << cnt << endl;        
  
  return 0;
}






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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll  long long  int
#define ld   long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e5+5;


int main()
{
    FAST
    ll i,j,k,tc;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
        string s;
        cin>>s;
        ll siz=s.size();
        if(s[siz-1]=='s')
            s+="es";
        else
            s+='s';
        cout<<s<<"\n";
    }

    return 0;
}


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

int main(void)
{
  string S;
  cin >> S;
  for (int j=0; j < 3; ++j) {
    cout << (S[j] == '1' ? 9 : (S[j] == '9' ? 1 : S[j]));
  }
  cout << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

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

    set<char> set(ALL(S));
    if (S.size() == set.size()) cout << "yes" << endl;
    else cout << "no" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c=getchar(),ch,sum=0;
	while((ch=getchar())!='\n')
	{
		if(c==ch) sum++;
		if(sum==2) puts("Yes"),exit(0);
		if(c!=ch) sum=0,c=ch;
	}
	puts("No");
	return 0;
}

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


def main():
    N = int(input())
    A = list(map(int,input().split()))

    for i in range(N):
        if A[i]%2 == 0:
            if A[i]%3 ==0 or A[i]%5 == 0:
                continue
            else:
                print("DENIED")
                return
    
    print("APPROVED")

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
    int w, n;
    int value[1000], weight[1000];
    int dp[2][1001];
    for (int case_num=1; true; case_num++) {
        cin >> w;
        if (w == 0) {
            return 0;
        }
        cin >> n;
        for (int i=0; i<n; i++) {
            cin >> value[i];
            cin.ignore(1);
            cin >> weight[i];
        }
        for (int i=0; i<=1000; i++) {
            dp[1][i] = 0;
        }
        for (int i=0; i<n; i++) {
            for (int j=0; j<=w; j++) {
                if (weight[i] > j) {
                    dp[i%2][j] = dp[(i+1)%2][j];
                }
                else {
                    dp[i%2][j] = max(dp[(i+1)%2][j], dp[(i+1)%2][j-weight[i]]+value[i]);
                }
            }
        }
        for (int j=w; j>=0; j--) {
            if (dp[(n+1)%2][j] != dp[(n+1)%2][w]) {
                cout << "Case " << case_num << ':' << endl;
                cout << dp[(n+1)%2][w] << endl;
                cout << j+1 << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "L" << __LINE__ << ": " << #e << " = " << e << endl
#else
#define debug_echo(e)
#define debug_var(e)
#endif
#ifdef DEBUG
#define debug_echo_dp1(dp, N) { cout << "[ "; rep(i, N) cout << dp[i] << " ";  cout << "]" << endl; }
#else
#define debug_echo_dp1(dp, N)
#endif

#define MAX_N 100
#define MAX_W 10000

int N;
int W;
int v[MAX_N];
int w[MAX_N];

int dp[MAX_W+1];

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

int main() {
  cin >> N >> W;
  rep(i, N) {
    cin >> v[i] >> w[i];
  }
  memset(dp, 0, sizeof(dp));
  dp1();
  cout << dp[W] << endl;
}

Measured memory_bytes: 3156
n,m,p=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
  a=list(map(int,input().split()))
  d=0
  for j in range(m):
    d+=b[j]*a[j]
  if d+p>0:
    ans+=1
print(ans)

Measured memory_bytes: 9188
#include<stdio.h>
#include<string.h>
int main(){
  char a[26];
  scanf("%s",a);
  int n=strlen(a);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(a[i]==a[j]&&i!=j){
        printf("no");
        return 0;
      }
    }
  }
  printf("yes");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int a;
	scanf("%d",&a);
	if(a<1200){
		printf("ABC\n");
	}
	else if(a<2800){
		printf("ARC\n");
	}
	else{
		printf("AGC\n");
	}
	return 0;
}

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

int main() {
    int N, K, X, Y;
    cin >> N;
    cin >> K;
    cin >> X;
    cin >> Y;
    if (N-K>0) {
        cout << K*X + (N-K)*Y << endl;
    } else {
        cout << N*X << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

string str[50];
char c[3] = {'W','B','R'};
int a[51][51][3], b[51][51][3];
int main(){
	int h, w, t1, t2, t3, ans = INF;
	scanf("%d%d", &h, &w);
	rep(i,h)cin >> str[i];
	rrep(i,h)rrep(j,w)rep(k,3){
		a[i][j][k] += a[i][j-1][k];
		if(str[i-1][j-1] == c[k])a[i][j][k]++;
	}
	rrep(i,h)rrep(j,w)rep(k,3){
		b[i][j][k] = a[i][j][k]+b[i-1][j][k];
	}
	for(int i = 1;i <= h-2;i++){
		for(int j = 1;j <= h-i-1;j++){
			t1 = w*i-b[i][w][0];
			t2 = w*j-(b[i+j][w][1]-b[i][w][1]);
			t3 = w*(h-i-j)-(b[h][w][2]-b[i+j][w][2]);
			ans = min(ans, t1+t2+t3);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3356
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] charArray = s.toCharArray();
		char[] notModify = new char[s.length() - 4];
		for(int i = 0 ; i < notModify.length ;i++){
			notModify[i] = charArray[i + 4];
		}
		String notModified = "";
		for(int i = 0 ; i < notModify.length ;i++){
			notModified = notModified + String.valueOf(notModify[i]);
		}
		System.out.println("2018" + notModified);
	}
}

Measured memory_bytes: 21844
import sys


def num_rest(num, base):
    return num % base, num / base


for line in sys.stdin:
    time = int(line)
    sec, rest = num_rest(time, 60)
    min, hour = num_rest(rest, 60)
    print(str(int(hour)) + ":" + str(int(min)) + ":" + str(int(sec)))



Measured memory_bytes: 5612
#include <iostream>

int main(void){
    int n, ans=0;
    std::cin >> n;

    for (int i=0; i<50001; ++i){
        if (i * 108 / 100 == n){
            ans = i;
            break;
        }
    }

    if (ans == 0){
        std::cout << ":(" << std::endl;
    } else {
        std::cout << ans << std::endl;
    }

    return 0;
}

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

for i in range(len(a)):
    a[i] -= i + 1

a.sort()
v = 0
if len(a) % 2 == 0:
    v1 = a[len(a)//2]
    v2 = a[len(a)//2 - 1]
    if abs(v1 + v2) == abs(v1) + abs(v2):
        v = min(v1, v2)
    else:
        v = abs(a[len(a)//2]) - abs(a[len(a)//2 - 1])
else:
    v = a[len(a)//2]
ans = 0
for i in a:
    ans += abs(i - v)
print(ans)

Measured memory_bytes: 25748
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int h,w;
  cin >> h >> w;
  string s;
  for(int i=1; i<=h; ++i) {
    for(char j='A'; j < 'A'+w; ++j) {
      cin >> s;
      if (s == "snuke") {
        cout << j << i << "\n";
      }
    }
  }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
           Console.WriteLine(ABC121_C());
        }

        static long ABC121_C()
        {
            var NM = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];
            var AB = new List<List<long>>();

            for (var n = 0; n < N; n++)
            {
                var ab = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
                AB.Add(ab);
            }

            var ans = 0L;
            var count = 0L;
            var ordered = AB.OrderBy(x => x[0]);
            foreach (var ab in ordered)
            {
                if (count == M) break;
                if (count + ab[1] > M)
                {
                    ans += ab[0] * (M - count);
                    count += (M - count);
                }
                else
                {
                    ans += ab[0] * ab[1];
                    count += ab[1];
                }
            }
            return ans;
        }
    }
}

Measured memory_bytes: 33668
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int A, B, M, a[maxn], b[maxn], x[maxn], y[maxn], c[maxn];
int ans = INT_MAX, ans1 = INT_MAX, ans2 = INT_MAX;
signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> A >> B >> M;
    for (int i = 1; i <= A; ++i)  {
        cin >> a[i];
        if (ans1 > a[i]) ans1 = a[i];
    }
    for (int i = 1; i <= B; ++i) {
        cin >> b[i];
        if (ans2 > b[i]) ans2 = b[i];
    }
    ans = min(ans, ans1 + ans2);
    for (int i = 1; i <= M; ++i) {
        cin >> x[i] >> y[i] >> c[i];
        ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
    }
    return cout << ans << endl, 0;
}

Measured memory_bytes: 2176