akhauriyash/Code-Regression huggingface dataset:
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 15:36:25 2019
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	m := map[int]int{}
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		m[a]++
	}

	arr := make([]int, 0)
	for _, v := range m {
		arr = append(arr, v)
	}
	sort.Ints(arr)

	ans := 0
	for i := 0; i < len(m)-K; i++ {
		ans += arr[i]
	}
	fmt.Println(ans)
}


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

int main() {
  int n;
  int flag = 0;
  int count = 0;
  long long res = 1000000000;
  long long ans = 0;
  long long cur = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> cur;
    if(cur < 0){
      count++;
      cur = cur*-1;
      ans += cur;
    }
    else if(cur == 0){
      flag = 1;
    }
    else{
      ans += cur;
    }
    res = min(res,cur);
  }
  if (count%2 == 1 and flag == 0){
    cout << ans-res*2 << endl;
  }
  else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

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

	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));	
	cout<< dp[n-1] <<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
struct Edge {
	int from, to; long long int cost;
};
int main(){
	int n, m, p; std::cin >> n >> m >> p;
	std::vector<std::vector<Edge>> in_edge(n);
	std::vector<Edge> edges(m);
	for (auto& e : edges) {
		std::cin >> e.from >> e.to >> e.cost;
		e.from--; e.to--;
		in_edge[e.to].push_back(e);
	}
	std::vector<bool> can_reach_goal(n, false);
	can_reach_goal[n - 1] = true;
	std::queue<int> queue; queue.push(n - 1);
	while (!queue.empty()) {
		auto top = queue.front(); queue.pop();
		for (const auto& e : in_edge[top]) if (!can_reach_goal[e.from]){
			can_reach_goal[e.from] = true;
			queue.emplace(e.from);
		}
	}
	std::vector<long long int> max_gain(n, LLONG_MIN); max_gain[0] = 0;
	for (auto i = 0; i < n; ++i) {
		for (const auto& e : edges) {
			if (max_gain[e.from] != LLONG_MIN && can_reach_goal[e.to] && max_gain[e.to] < max_gain[e.from] + e.cost - p) {
				max_gain[e.to] = max_gain[e.from] + e.cost - p;
			}
		}
	}
	if (std::any_of(edges.begin(), edges.end(), [&can_reach_goal, &max_gain, p](const Edge& e) { return max_gain[e.from] != LLONG_MIN && can_reach_goal[e.to] && max_gain[e.to] < max_gain[e.from] + e.cost - p; })) {
		std::cout << -1 << std::endl;
	}
	else {
		std::cout << std::max(0LL, max_gain.back()) << std::endl;
	}
}



Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

int main() {
    
    int A, B, X;
    cin >> A >> B >> X;

    cout << ((A <= X&&A + B >= X) ? "YES" : "NO") << endl;

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
  int key;
  int parent;
  int left;
  int right;
} heap;

heap H[300];

int main()
{
  int h,key,i;

  scanf("%d",&h); /* ヒープのサイズ */

  /* 初期化 */
  for(i = 0;i < h+1;i++){
    H[i].key = -2000000001;
    H[i].parent = -2000000001;
    H[i].left = -2000000001;
    H[i].right = -2000000001;
  }

  for(i = 1;i < h+1; i++){
    scanf("%d",&key);
    H[i].key = key;
  }
  for(i = 1;i < h+1; i++){
    H[i].parent = H[i/2].key; /* 親の設定 */
    if((2*i) < h+1) H[i].left = H[2*i].key; /* 左の設定 */
    if((2*i+1) < h+1) H[i].right = H[2*i+1].key; /* 右の設定 */
  }

  /* 出力 */
  for(i = 1; i < h+1; i++){
    printf("node %d: key = %d, ",i,H[i].key);
    if(H[i].parent != -2000000001) printf("parent key = %d, ",H[i].parent);
    if(H[i].left != -2000000001) printf("left key = %d, ",H[i].left);
    if(H[i].right != -2000000001) printf("right key = %d, ",H[i].right);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 604
program A323A
    implicit none
    integer(8)::N,K,ans,i
    integer(8),allocatable,dimension(:)::L
    read*,N,K
    allocate(L(N))
    read*,L
    call heapsort(N,L)
    ans=0

    do i=0,K-1
        ans=ans+L(N-i)
    end do

    print'(i0)',ans
end program A323A

subroutine heapsort(n,array)
    implicit none
    integer(8),intent(in) :: n
    integer(8),intent(inout) :: array(1:n)
   
    integer(8) ::i,k,j,l
    integer(8) :: t
   
    if(n.eq.1)return
  
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       enddo
       array(i)=t
    enddo
  
    return
  end subroutine heapsort

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll R, G, B, N;
    ll count = 0;
    cin >> R >> G >> B >> N;
    for(ll r = 0;r <= N / R;r++) {
        for(ll g = 0;g <= N / G;g++) {
            ll b = max(0LL, (N - r * R - g * G) / B);
            if(r * R + g * G + b * B == N) count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll N,K,a;
    vector<ll> A,B;
    cin >> N >> K;
    REP(i,N){
        cin >> a;
        if(a>=0){
            A.push_back(a);
        }else{
            B.push_back(-a);
        }
    }
    sort(A.begin(),A.end(),greater<>());
    sort(B.begin(),B.end(),greater<>());
    //REP(i,A.size()){cout << A[i] << " ";}cout << endl;
    //REP(i,B.size()){cout << B[i] << " ";}cout << endl;
    
    //非負をつくれない:非負要素がないかつKが奇数
    //またはK=Nかつ|B|%2==1
    if(A.size()==0 && K%2==1){
        ll Ans=1;
        REP(i,K){
            Ans = (Ans*B[B.size()-1-i])%MOD;
        }
        cout << MOD-Ans << endl;
        return 0;
    }
    if(K==N && (B.size())%2==1){
        ll Ans=1;
        REP(i,A.size()){
            Ans = (Ans*A[i])%MOD;
        }
        REP(i,B.size()){
            Ans = (Ans*B[i])%MOD;
        }
        cout << MOD-Ans << endl;
        return 0;
    }
    
    //正:K個 負:0個
    //正:K-2個 負:2個
    //・・・
    bool broken = false;
    ll L=0;
    for(ll i=0;i+1<B.size();i+=2){
        L=i;
        if(K-1-i < 0 || (ll)(A.size()) <= K-2-i)continue;
        if(A[K-1-i]*A[K-2-i] >= B[i]*B[i+1]){
            broken = true;
            break;
        }
        //cout << K-1-i MM K-2-i MM i MM i+1 << endl;
    }
    if(!broken){
        L = (min(K,(ll)B.size())/2)*2;
    }
    
    //cout << L << endl;
    
    ll Ans=1;
    REP(i,K-L){
        Ans = (Ans*A[i])%MOD;
    }
    REP(i,L){
        Ans = (Ans*B[i])%MOD;
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 5440
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  cout << (ld) ((ll) (n+1)/2)/n << newl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

bool check(int n){
    for (int i=2; i*i<=n; i++){
        if (n % i == 0) return false;
    }
    return true;
}

vi vec(100010);
void primes(void){
    REP(i,3,100001){
        if (check(i) && check((i+1)/2)) vec[i+1] = vec[i] + 1;
        else vec[i+1] = vec[i];
        //printf("%d ", vec[i]);
    }
    //printf("\n");
}


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

    primes();
    rep(i,60){
        //printf("i:%d vec[i]:%d\n", i, vec[i]);
    }
    rep(i,q){
        int l, r;
        cin >> l >> r;
        int ans = vec[r+1] - vec[l];
        cout << ans << endl;
    }
    return 0;
}


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

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

Node *root, *NIL;

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 n, i, x;
  string com;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    cin >> com;

    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: 26716
#include <bits/stdc++.h> 
using namespace std; 
  
string a = "", b = "";
int ai, bi, idx;
void permute(string str) 
{ 
  sort(str.begin(), str.end()); 
  idx = 1;
  do { 
    if(str == a) ai = idx;
    if(str == b) bi = idx;
    idx++;
  } while (next_permutation(str.begin(), str.end())); 
} 
  
// Driver code 
int main() 
{  
  int n;
  string tmp;
  cin >> n;
  for(int i=0; i<n; i++)
  {
  	cin >> tmp;
  	a += tmp;
  }
  for(int i=0; i<n; i++)
  {
  	cin >> tmp;
  	b += tmp;
  }
  // cout << a << " " << b << endl;
  string ans = a;
  sort(ans.begin(), ans.end());
  permute(ans);
  // cout << ai << " " <<bi << endl;
  cout << abs(ai - bi) << '\n';
  return 0; 
} 

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<pair<int,bool>>v(9);
	int n,w;
	for(int i=0;i<9;i++){
		cin>>v.at(i).first;
	}
	cin>>n;
	for(int i=0;i<n;i++){
			cin>>w;
			for(int i=0;i<9;i++){
					if(v.at(i).first==w){
						v.at(i).second=true;
					}
				}
	}
	if(v.at(0).second==true&&v.at(1).second==true&&v.at(2).second==true ||
			v.at(3).second==true&&v.at(4).second==true&&v.at(5).second==true ||
			v.at(6).second==true&&v.at(7).second==true&&v.at(8).second==true ||
			v.at(0).second==true&&v.at(3).second==true&&v.at(6).second==true ||
			v.at(1).second==true&&v.at(4).second==true&&v.at(7).second==true ||
			v.at(2).second==true&&v.at(5).second==true&&v.at(8).second==true ||
			v.at(0).second==true&&v.at(4).second==true&&v.at(8).second==true ||
			v.at(2).second==true&&v.at(4).second==true&&v.at(6).second==true ){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
dp = [-1]*(n+1)
path = [[] for i in range(n)]
X = []; Y = []
for i in range(m):
    x, y = map(int, input().split())
    X.append(x-1); Y.append(y-1)
    path[x-1].append(y-1)

def dfs(i):
    if dp[i]>0: return dp[i]
    res = 0
    for k in path[i]:
        res = max(res, dfs(k)+1)
    dp[i] = res
    return res

ans = 0
for i in range(n):
    ans = max(ans, dfs(i))
print(ans)

Measured memory_bytes: 67028
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine()) % 500;
        var a = int.Parse(Console.ReadLine());

        if (n <= a)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
using namespace std;
 
int a[11];
 
int main(){
	int n;
  	scanf("%d", &n);
    int sum = 0;
    for (int i = 0; i < n; i++){
    	scanf("%d", a + i);
      	sum += a[i];
    }
  sort(a, a + n);
  sum -= a[n - 1];
  if (sum > a[n - 1])
    	puts("Yes");
  else 
    	puts("No");
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int sx,sy,tx,ty,i;
	cin >> sx >> sy >> tx >> ty;
	for(i=sx; i<tx; ++i){
		cout << "R";
	}
	for(i=sy; i<ty; ++i){
		cout << "U";
	}
	for(i=sx; i<tx; ++i){
		cout << "L";
	}
	for(i=sy; i<ty; ++i){
		cout << "D";
	}
	cout << "D";
	for(i=sx; i<tx; ++i){
		cout << "R";
	}
	cout << "RU";
	for(i=sy; i<ty; ++i){
		cout << "U";
	}
	cout << "LU";
	for(i=sx; i<tx; ++i){
		cout << "L";
	}
	cout << "LD";
	for(i=sy; i<ty; ++i){
		cout << "D";
	}
	cout << "R";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
def solve():
    input_string = input()
    part_string = input()

    for i in range(len(input_string) - len(part_string), -1, -1):
        possible_part_string = input_string[i:i+len(part_string)]  # part_stringの可能性のある文字列
        for j in range(len(part_string) + 1):  # 1つ多くループしているのは最後の処理のため
            if j == len(part_string):
                result = input_string[:i] + part_string + input_string[i + len(part_string):]
                result = result.replace("?", "a")
                print(result)
                return  # 今回のテストケースの終了
            if possible_part_string[j] == "?" or possible_part_string[j] == part_string[j]:
                continue
            else:  # 再度ずらして探索する
                break

    print("UNRESTORABLE")
solve()

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

const int N = 2 * 100 * 1000 + 20, mod = 1e9 + 7;
int n, k, sumMn[N], sumMx[N], ans;

int sum(int a, int b) {
	return ((1LL * a + b) % mod + mod) % mod;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n + 1; i++)
		sumMn[i] = sum(sumMn[i - 1], i - 1);
	for (int i = 1; i <= n + 1; i++)
		sumMx[i] = sum(sumMx[i - 1], n + 1 - i);
	for (int i = k; i <= n + 1; i++)
		ans = sum(ans, sum(sumMx[i], - sumMn[i] + 1));
	cout << ans << endl;
}


Measured memory_bytes: 5172
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>

using namespace std;

bool erase(std::map<int, std::set<int>>& m, int h, int w) {
    auto it = m.find(h);
    if (it == m.end()) return false;
    auto it_w = it->second.find(w);
    if (it_w == it->second.end()) return false;

    it->second.erase(it_w);
    if (it->second.empty()) m.erase(it);

    return true;
}

void add(std::map<int, std::set<int>>& m, int h, int w) {
    auto it = m.find(h);
    if (it == m.end()) m[h] = std::set<int>();
    m[h].insert(w);
}

void move(std::map<int, std::set<int>>& m,
          std::queue<std::pair<int, int>>& q) {
    std::queue<std::pair<int, int>> q_buf;
    q.swap(q_buf);
    while (! q_buf.empty()) {
        const std::pair<int, int> &p = q_buf.front();
        bool suc{true};
        suc = erase(m, p.first+1, p.second);
        if (suc) q.push(std::make_pair(p.first+1, p.second));
        suc = erase(m, p.first-1, p.second);
        if (suc) q.push(std::make_pair(p.first-1, p.second));
        suc = erase(m, p.first, p.second+1);
        if (suc) q.push(std::make_pair(p.first, p.second+1));
        suc = erase(m, p.first, p.second-1);
        if (suc) q.push(std::make_pair(p.first, p.second-1));
        q_buf.pop();
    }
}

int main(int argc, char** argv) {
    int h, w;
    cin >> h >> w;
    std::queue<std::pair<int, int>> q;
    std::map<int, std::set<int>> m;

    char c;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> c;
            if (c == '.') {
                add(m, i, j);
            } else {
                q.push(std::make_pair(i, j));
            }
        }
    }
    int ans{0};
    while (! m.empty()) {
        move(m, q);
        ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 47232
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t string
	fmt.Scanln(&s)
	fmt.Scanln(&t)
	s = strings.Repeat(s, 2)
	if strings.Contains(s, t) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,t1,t2,s1,s2,minn=9000000;
	cin>>n;
	for(i=1;i<n;i++)
	{
		t1=i;
		t2=n-i;
		s1=s2=0;
		while(t1!=0)
		{
			s1+=t1%10;
			t1/=10;
		}
		while(t2!=0)
		{
			s2+=t2%10;
			t2/=10;
		}
		minn=min(s1+s2,minn);
	}
	cout<<minn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main( void )
{
    int a, b, c;
    char op;
    
    while ( true )
    {
        std::cin >> a >> op >> b;
        if ( op == '?' )    break;
        
        switch ( op )
        {
            case '+': c = a + b; break;
            case '-': c = a - b; break;
            case '*': c = a * b; break;
            case '/': c = a / b; break;
            default: break;
        }
        std::cout << c << std::endl;
    }
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector <int> cnt(M,0);
  for(int i = 0; i < N; i++){
    int K;
    cin >> K;
    for(int j = 0; j < K; j++){
      int A;
      cin >> A;
      A--;
      cnt[A]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < M; i++){
    if(cnt[i] == N){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1]={0};
	for(int i=0; i<k; i++)
	{
		int d;
		cin>>d;
		while(d--)
		{
			int temp;
			cin>>temp;
			a[temp]+=1;
		}
	}
	int count=0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]==0)
		{
			count+=1;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3652
/*Unknown_Ghost*/
/*AGC033B LRUD Game*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;

#define LL long long
#define MAXN 200000
#define MOD 998244353
#define Pr pair<int,int>
#define X first
#define Y second
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
int add(int x,int y){return (x+y>=MOD)?x+y-MOD:x+y;}
int dec(int x,int y){return (x-y<0)?x-y+MOD:x-y;}
int mul(int x,int y){return 1LL*x*y%MOD;}

int h,w,n,sx,sy;
char S[MAXN+5],T[MAXN+5];
char dir[]={'L','R','U','D'};
int px[]={0,0,-1,1},py[]={-1,1,0,0};
int main()
{
    h=read(),w=read(),n=read();
    sx=read(),sy=read();
    scanf("%s %s",S+1,T+1);
    for(int k=0;k<4;k++){
        int nx=sx,ny=sy;
        for(int i=1;i<=n;i++){
            if(S[i]==dir[k])nx+=px[k],ny+=py[k];
            if(!(nx>=1&&ny>=1&&nx<=h&&ny<=w)){printf("NO\n");return 0;}
            if(T[i]==dir[k^1])nx+=px[k^1],ny+=py[k^1];
            nx=min(h,max(1,nx)),ny=min(w,max(1,ny));
        }
    }
    printf("YES\n");
}


Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
ll res = 0;

void solve(ll H, ll n){
    res += n; 
    if(H == 1){
        return;
    }
    solve(H/2, n*2);
}

int main(){
    long long H;
    scanf("%lld",&H);
    solve(H, 1);
    cout<< res<<endl;
    return 0;
}


Measured memory_bytes: 256
M,D=map(int,input().split())

answer=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d10=d//10
    d1=d%10    
    if d1>=2 and d10>=2 and d1*d10==m:
      answer+=1
      
print(answer)

Measured memory_bytes: 9096
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

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

const int INF = 1e9;
const long long LINF = 1e18;

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

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

    sort(v.begin(), v.end());

    double ans = static_cast<double>(v[0] + v[1]) / 2.0;
    for (int i = 2; i < N; i++) {
        ans = (ans + v[i]) / 2.0;
    }

    printf("%.10f\n", ans);

    return 0;
}


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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N,Q;
// *********************************************************
int main(){

    cin >>  N;

    map<ll,ll> mp;
    rep(i,N){
        ll a;
        cin >> a;
        ++mp[a];
    }

    map<ll, ll> mpseki;
    ll sum = 0;
    for(auto str=mp.begin(); str!= mp.end(); ++str){
        mpseki[str->first] = str->first * str->second;
        sum += mpseki[str->first];
    }

    cin >>Q;
    vll B, C;
    rep(i,Q){
        int b,c;
        cin >> b>>c;
        B.emplace_back(b);
        C.emplace_back(c);
    }

    rep(i,Q){

        sum += C.at(i) * mp[B.at(i)];
        sum -= B.at(i) * mp[B.at(i)];
        mp[C.at(i)] += mp[B.at(i)];
        
        //mpseki[C.at(i)] = C.at(i) * mp[C.at(i)];


        mp[B.at(i)] = 0;



        cout << sum << endl;
    }



    return 0;
}

Measured memory_bytes: 14568
import itertools
import sys
import numpy as np
import collections
s=input()
a,b,c,d=s[0],s[1],s[2],s[3]
ia,ib,ic,id=int(a),int(b),int(c),int(d)
l=[ia,ib,ic,id]
if sum(l) == 7:
    print('{0}+{1}+{2}+{3}=7'.format(a,b,c,d))
    exit(0)
elif ia+ib+ic-id ==7:
    print('{0}+{1}+{2}-{3}=7'.format(a, b, c, d))
elif ia+ib-ic+id ==7:
    print('{0}+{1}-{2}+{3}=7'.format(a, b, c, d))
elif ia+ib-ic-id ==7:
    print('{0}+{1}-{2}-{3}=7'.format(a, b, c, d))
elif ia-ib+ic+id ==7:
    print('{0}-{1}+{2}+{3}=7'.format(a, b, c, d))
elif ia-ib+ic-id ==7:
    print('{0}-{1}+{2}-{3}=7'.format(a, b, c, d))
elif ia-ib-ic+id ==7:
    print('{0}-{1}-{2}+{3}=7'.format(a, b, c, d))
else:
    print('{0}-{1}-{2}-{3}=7'.format(a, b, c, d))


Measured memory_bytes: 12504
#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <cctype>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int sigma = 0;
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		sigma += a;
	}
	if(sigma > n){
		cout << -1 << endl;
	}else{
		cout << n-sigma << endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>
#include<climits>
#include<queue>
#define rep(i, n) for (int i=0; i<n; ++i)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> depth(n, INT_MAX);
    depth[0] = 0;
    vector<vector<int>> path(n);
    rep(i, m){
        int tmpA, tmpB;
        cin >> tmpA >> tmpB;
        path[tmpA-1].push_back(tmpB-1);
        path[tmpB-1].push_back(tmpA-1);
    }
    
    queue<int> todo;
    todo.push(0);
    while(!todo.empty()){
        int tmp = todo.front();
        todo.pop();
        for(int x : path[tmp]){
            if(depth[x] > depth[tmp]+1){
                depth[x] = depth[tmp]+1;
                todo.push(x);
            }
        }
    }

    cout <<"Yes"<<endl;
    for (int i=1; i<n; ++i){
        int result = path[i][0];
        for(auto&& x : path[i]){
            if(depth[x] < depth[result]){
                result = x;
            }
        }
        cout << result+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10164
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

h,w,k = nm()
s = [list(map(int, list(ns()))) for _ in range(h)]
ans = h*w
for bit in range(1<<(h-1)):
    d = dict()
    l = list()
    q = [0]
    for j in range(h-1):
        if bit & (1<<j):
            l.append(tuple(q))
            q = list()
        q.append(j+1)
    l.append(tuple(q))
    t = len(l)
    for i in range(t):
        for x in l[i]:
            d[x] = i
    cur = bin(bit).count('1')
    g = [0]*t
    for j in range(w):
        c = [0]*t
        for i in range(h):
            c[d[i]] += s[i][j]
        if max(c) > k:
            cur = h*w
            break
        for i in range(t):
            g[i] += c[i]
        if max(g) > k:
            cur += 1
            g = c[:]
    if ans > cur: ans = cur
print(ans)


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

const int MOD = 1e9+7;
int main()
{
    int n,m;
    cin>>m>>n;
    char a[m][n];
    int ans[m][n];
    memset(ans,-1,sizeof(ans));
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
            if(a[i][j]=='#'){
                ans[i][j]=0;
            }
        }
    }
    bool state = false;
    for(int j=0;j<n;j++){
        if(state){
            while(j<n){
                ans[0][j]=0;
                j++;
            }
        }
        if(a[0][j]=='#'){
            state = true;
            continue;
        }
        ans[0][j]=1;
    }
    state = false;
    for(int j=0;j<m;j++){
        if(state){
            while(j<m){
                ans[j][0]=0;
                j++;
            }
        }
        if(a[j][0]=='#'){
            state = true;
            continue;
        }
        ans[j][0]=1;
    }
    for(int i=1;i<m;i++){
        for(int j=1;j<n;j++){
            
            if(ans[i][j]==-1)
            ans[i][j]=(ans[i-1][j]+ans[i][j-1])%MOD;
            //cout<<ans[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<ans[m-1][n-1]%MOD<<endl;
    return 0;
}

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

int main() {
	int x, y, c;
	int cnt = 0;
	int max=0;
	int map[10][10];
	int dx[] = { 0, -1, 1, 0, -1, 1, -1, 1, 0, -2, 2, 0 };
	int dy[] = { -1, 0, 0, 1, -1, -1, 1, 1, -2, 0, 0, 2 };
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			map[i][j] = 0;
		}
	}
	while (scanf("%d,%d,%d", &x, &y, &c) != EOF) {
		map[y][x]++;
		for (int i = 0; i < c * 4; ++i) {
			int mx = dx[i] + x;
			int my = dy[i] + y;
			if (mx >= 0 && mx < 10 && my >= 0 && my < 10) {
				map[my][mx]++;
			}
		}
	}
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			if(max<map[i][j])max=map[i][j];
			if (map[i][j] == 0) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	cout<<max<<endl;
}

Measured memory_bytes: 3124
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,k=mii()

chk=[0]*n
for i in range(k):
    d=ii()
    arr=limii()
    for j in range(d):
        chk[arr[j]-1]=1

print(n-sum(chk))







Measured memory_bytes: 72840
import sys
import math
import fractions
from functools import reduce
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)


N, K = MI()
ans = (N // K) ** 3
if K % 2 == 0:
    ans += ((N + K//2) // K) ** 3
print(ans)


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int dp[100010];
int main() {
  int N;
  cin>>N;
  dp[0]=0;
  for(int n=1;n<=100000;n++){
    dp[n]=999999;
    int power=1;
    while(power<=n){
      dp[n]=min(dp[n],dp[n-power]+1);
      power*=6;
    }
    power=1;
    while(power<=n){
      dp[n]=min(dp[n],dp[n-power]+1);
      power*=9;
    }
  }
  cout<<dp[N]<<endl;
  return 0;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define pb push_back
#define SZ(x) ((int)x.size())
typedef vector<int> vec;
typedef long long LL;
const int N=200010;
char Read(){
	char c=getchar();
	while(c<'0'||c>'1')c=getchar();
	return c;
}
int read(){
	char c=getchar();int d=0,f=1;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';d=d*10+c-48,c=getchar());
	return d*f;
}
LL ans;
int n,s[N],w[N],dep[N],Dep[N],g[N][2];
vec e[N];
void add(int x,int y){e[x].pb(y);e[y].pb(x);}
void dfs1(int f,int x){
	ref(i,0,SZ(e[x])-1){int y=e[x][i];
		if(y==f)continue;
		dfs1(x,y);dep[x]=max(dep[x],dep[y]);s[x]+=s[y];
	}
	dep[x]++;s[x]+=w[x];
}
void dfs2(int f,int x){
	int&D1=g[x][0],&D2=g[x][1];
	D1=Dep[x];D2=0;
	int mi=N;if(s[1]-s[x]>0)mi=Dep[x];
	ref(i,0,SZ(e[x])-1){int y=e[x][i];
		if(y==f)continue;
		if(s[y])mi=min(mi,dep[y]);
		if(dep[y]>D1)D2=D1,D1=dep[y];else
		if(dep[y]>D2)D2=dep[y];
	}
	ref(i,0,SZ(e[x])-1){int y=e[x][i];
		if(y==f)continue;
		if(dep[y]==D1)Dep[y]=D2+1;
		else Dep[y]=D1+1;
		dfs2(x,y);
	}
	if(w[x])ans+=min(D1,D2)+1;else
		ans+=max(0,min(D1,D2)-mi+1);
	if(x>1)ans+=(dep[x]<=Dep[x]&&s[x]>0||Dep[x]<=dep[x]&&s[1]-s[x]>0);
}
int main(){
	n=read();
	ref(i,2,n)add(read(),read());
	ref(i,1,n)w[i]=Read()-'0';
	dfs1(0,1);dfs2(0,1);
	cout<<ans<<endl;
}

Measured memory_bytes: 27776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n[3], k;
    cin >> n[0] >> n[1] >> n[2] >> k;
    sort(n, n+3);
    for (int i = 0; i < k; i++) n[2] *= 2;
    cout << n[0] + n[1] + n[2] << endl;
}

Measured memory_bytes: 256
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

calc(eda) = eda >= 10000000000000 ? 10000000000000 : 2*eda


function main()
    N = pread(Int)
    a = readvec(Int, N+1)
    if N == 0
        println(a[1] == 1 ? 1 : -1)
        return
    end

    maxe = zeros(Int, N)
    maxe[1] = 1 - a[1]
    for i in 2:N
        maxe[i] = calc(maxe[i-1])-a[i]
        if maxe[i] <= 0
            println(-1)
            return
        end
    end

    eda = zeros(Int, N+1)
    eda[N+1] = 0
    for i in N+1:-1:2
        tmp = a[i]+eda[i]
        if maxe[i-1] < (tmp+1)÷2
            println(-1)
            return
        end
        eda[i-1] = min(maxe[i-1], tmp)
    end

    if eda[1] != 1
        println(-1)
    else
        println(sum(eda)+sum(a))
    end
end

main()


Measured memory_bytes: 208072
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int V, E, r;
ll dist[100010];
vector<vector<pli>> g;

int main() {
    cin >> V >> E >> r;
    g.resize(V);
    rep(i, E) {
        int s, t; ll d;
        cin >> s >> t >> d;
        g[s].push_back(make_pair(d, t));
    }

    rep(i, V) dist[i] = INF;
    dist[r] = 0;
    priority_queue<pli, vector<pli>, greater<pli>> pq;
    pq.push(make_pair(0, r));

    while (!pq.empty()) {
        pli now = pq.top();
        pq.pop();
        int u = now.second;
        for (auto &e: g[u]) {
            ll cost = e.first;
            int v = e.second;
            if (chmin(dist[v], dist[u] + cost)) {
                pq.push(make_pair(dist[v], v));
            }
        }
    }

    rep(i, V) {
        if (dist[i] == INF) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
}



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

int H, W;

int main() {
  cin >> H >> W;

  vector<vector<char>> grid(H, vector<char>(W));
  rep(i, H) rep(j, W) cin >> grid[i][j];

  vector<vector<int>> C(H, vector<int>(W, 0));

  rep(i, H) {
    int j = W - 1;
    int c = 1;
    while (j >= 0) {
      if (grid[i][j] == '#') c = 0;
      C[i][j] += c;
      ++c;
      --j;
    }
    j = 0;
    c = 1;
    while (j < W) {
      if (grid[i][j] == '#') c = 0;
      C[i][j] += c;
      ++c;
      ++j;
    }
  }
  rep(j, W) {
    int i = H - 1;
    int c = 1;
    while (i >= 0) {
      if (grid[i][j] == '#') c = 0;
      C[i][j] += c;
      ++c;
      --i;
    }
    i = 0;
    c = 1;
    while (i < H) {
      if (grid[i][j] == '#') c = 0;
      C[i][j] += c;
      ++c;
      ++i;
    }
  }

  int ans = 0;
  rep(i, H) rep(j, W) {
    if (grid[i][j] == '#') continue;
    ans = max(ans, C[i][j] - 3);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19968
#include<stdio.h>
#include<string.h>

int main() {
	char x[1024];
	int datas[BUFSIZ];

	for (int i = 0; i < BUFSIZ;i++) {
		//in
		fflush(stdin);
		scanf("%s", x);

		datas[i] = 0;

		if (x[0] == '0') 	break;
		
		//initialize
		int len = strlen(x);

		//sum
		for (int j = 0; j < len; j++) {
			int temp = x[j] - '0';
			datas[i] += temp;
		}

	}
	
	for (int i = 0; i < BUFSIZ && datas[i]; i++) {
		printf("%d\n", datas[i]);
	}
	
	return 0;
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
using ll   = long long;
const ll mod = 1e9+7;

void solve(){
    int n,w, max_val=0;cin>>n>>w;
    vector<vector<ll>> a(n, vector<ll>(2));
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
        max_val += a[i][1];
    }
    vector<ll> dp(max_val+1, mod);
    dp[0]=0;
    for(int i=0;i<n;i++){
        vector<ll> newDp(max_val+1, mod);
        // newDp[0]=0;
        for(int val=0;val<=max_val;val++){
            if(a[i][1]>val){
                newDp[val] = dp[val];
            }else newDp[val] = min(dp[val], dp[val-a[i][1]] + a[i][0]);
        }
        dp = newDp;
    }
    ll ans=0;
    for(int i=0;i<=max_val;i++){
        if(dp[i]<=w)ans = max(ans, (ll)i);
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt", "w", stdout);
    #endif
    int t;
    t=1;
    // cin>>t;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 4704
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> c(N);
    REP(i,Q){
        int a;
        cin >> a;
        ++c[a-1];
    } 

    REP(i,N){
        cout<< (K-Q + c[i] > 0 ? "Yes": "No") << endl;    //strict inequality;
    }
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int x = n%10;
  if(x == 3) {
    cout << "bon" << endl;
  } else if(x == 0 || x == 1 || x == 6 || x == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
using System;

namespace abc164_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int d = int.Parse(str[3]);
            Boolean match = true;
            duelList takahashi = new duelList();
            takahashi.name = "高橋";
            takahashi.hp = a;
            takahashi.attack = b;
            duelList aoki = new duelList();
            aoki.name = "青木";
            aoki.hp = c;
            aoki.attack = d;
            while (takahashi.hp>0 || aoki.hp > 0)
            {
                takahashi.hp = takahashi.hp - aoki.attack;
                aoki.hp = aoki.hp - takahashi.attack;
                if (takahashi.hp <= 0 && aoki.hp > 0)
                {
                    match = false;
                }
            }
            if (match)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
    class duelList
    {
        public string name;
        public int attack;
        public int hp;
    }
}

Measured memory_bytes: 27376
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
typedef long long ll;
using namespace std;
int main(void){
    // Your code here!
    int sum=0,A[3];
    rep(0,i,3){
        cin>>A[i];
        sum+=A[i];
    }
    if(sum>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	DP = [100000000000000000000000000000000 for _ in range(N)]
	DP[0] = 0
	
	for i, val in enumerate(A):
		if i == 0:
			continue
		tmp = 100000000000000000000000000000000
		if i > 1:
			tmp = DP[i-2] + abs(A[i-2] - val)
		DP[i] = min(DP[i], DP[i-1] + abs(A[i-1] - val), tmp)
		
	#print(DP)
	print(DP[N-1])
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 23652
#include <stdio.h>

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
    char c;
    scanf("%c",&c);
    printf("%c\n",'a'-32*(c-'A'<27));
}


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

int main() {
	int n = 0, m = 0, l = 0;
	int a[100][100] = {}, b[100][100] = {};
	long long c[100][100] = {};
	cin >> n >> m >> l;

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0;i < m;i++) {
		for (int j = 0;j < l;j++) {
			cin >> b[i][j];
		}
	}

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < l;j++) {
			for (int k = 0; k < m;k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
			cout << c[i][j];
			if (j != l - 1)
				cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 3252
import math
import re
import copy
import sys

n = int(input())
a = list(map(int,input().split()))
ceil = 10 ** 18
ans = 1
if all([b > 0 for b in a]):
    for i in range(n):
        ans *= a[i]
        if ans > ceil:
            break
if any([b == 0 for b in a]):
    print(0)
elif ans > ceil:
    print("-1")
else:
    print(ans)

Measured memory_bytes: 23156
import numpy as np
def hanten(C, X, V):
	return (C*np.ones(X.shape[0])-X)[::-1], V[::-1]

def solv2(N, X, V):
	r = 0
	rbuf = 0
	pos = 0
	Vsum = V.copy()
	for i in range(N):
		rbuf += V[i] - (X[i]-pos)
		pos = X[i]
		if(rbuf > r):
			r = rbuf
		Vsum[i] = r
	return Vsum

def solv(N, C, X, V):
	r = 0
	rbuf1 = 0
	pos = 0
	ibuf = 0
	iX, iV = hanten(C, X, V) 
	iv = solv2(N, iX, iV)
	#print(iv)
	for i in range(N):
		rbuf1 += V[i] - 2*(X[i]-pos)
		rbuf2 = iv[N-(i+2)]
		if(i == N-1):
			rbuf2 = 0
		rbuf = rbuf1 + rbuf2
		pos = X[i]
		#print(rbuf, rbufbuf)
		if(rbuf > r):
			r = rbuf
	return max(r, iv[-1])
	
def main():
	buf = input().split()
	N = int(buf[0])
	C = int(buf[1])
	X = np.zeros(N)
	V = np.zeros(N)
	for i in range(N):
		buf = input().split()
		X[i] = int(buf[0])
		V[i] = int(buf[1])
	r1 = solv(N, C, X, V)
	X, V = hanten(C, X, V)
	r2 = solv(N, C, X, V)
	print(int(max(r1, r2)))
	#print(solv2(N, X, V))
main()# your code goes here

Measured memory_bytes: 19088
""" AtCoder """

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    tmp = C
    for j in range(M):
        tmp += A[i][j]*B[j]
    if tmp > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060