akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.group_count = n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.group_count -= 1

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

def int_(num_str):
    return int(num_str) - 1


N, K, L = map(int, input().split())
uf1 = UnionFind(N)
for _ in range(K):
    p, q = map(int_, input().split())
    uf1.union(p, q)
uf2 = UnionFind(N)
for _ in range(L):
    r, s = map(int_, input().split())
    uf2.union(r, s)
from collections import Counter
pair = [(uf1.find(i), uf2.find(i)) for i in range(N)]
ans = Counter(pair)
print(*[ans[p] for p in pair])


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

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 ll INF = 1LL << 60;

//---main---------------------------------------------
int main(){
    //main
    ll N;
    cin >> N;
    string ans ="";

    int aidx;

    while(N>0){
        N--;
        aidx = N%26;
        char a = aidx+97;
        //if(aidx == 0) a = 'z';
        ans = a + ans;
        N = N/26;

        //cout << N << " " << aidx << " " << a << " " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    
    int H,W;
    
    while(1){
        cin>>H>>W;
        if (H==0&&W==0) break;
        
        for (int i=0;i<H;i++){
            for (int j=0;j<W;j++){
                if ( (i+j) %2==0){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout<<"\n";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<math.h>
using namespace std;
main()
{
     int a,h;
	 cin>>h>>a;
	 if(h%a==0)
	 {
	 	cout<< h/a <<endl;
		 }	
		 else
		 {
		 	cout<< h/a + 1 << endl;
		 }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    int k, a, b;
    cin >> k >> a >> b;
    REP(i, 1001)
    {
        if(i*k < a)
        {
            continue;
        }
        else if((i*k >= a)&& (i*k <= b))
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

int main()
{
    int a,b;
    int c=0,d=1;
    cin >> a >> b;

    while(d<=2){
     if( a>=b ){
      c = c+a;
      a--;
     }
     else{
      c = c+b;
      b--;
     }
     
     d++;
    }
    cout << c;

    return 0;
}

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

int n, m, cnt;
int f[10010];
struct Point{
	int x, y, id;
}point[10010];

struct Edge{
	int form, to;
	double dis;
}edge[10010 * 10010];

int Find(int x){
	return f[x] == x ? x : f[x] = Find(f[x]);
}

void Union(int x, int y){
	int fx = Find(x);
	int fy = Find(y);
	if(fx != fy)
	f[fy] = fx;
}
void Addedge(int form, int to, double dis){
	edge[cnt].form = form;
	edge[cnt].to = to;
	edge[cnt++].dis = dis;
}

double dis(Point x, Point y){
	return sqrt(1.0*(x.x - y.x)*(x.x - y.x) + 1.0 * (x.y - y.y)*(x.y - y.y));
}
bool cmp1(Edge a, Edge b){
	return a.dis > b.dis;
}

double Kruskal(){
	sort(edge, edge + cnt, cmp1);
	for(int i = 1; i <= n; i++)
	f[i] = i;
	double sum = 0;
	int tot = 0;
	int i;
	for(i = 0; i < cnt; i++){
		if(Find(edge[i].form) == Find(edge[i].to)){
			sum += edge[i].dis;
			continue;	
		} 
		Union(edge[i].form, edge[i].to);
	}
	return sum;
}
int main(){
	while(~scanf("%d%d", &n, &m)){
		cnt = 0;
		for(int i = 1; i <= n; i++){
			cin>>point[i].x>>point[i].y;
			point[i].id = i;
		}
		for(int i = 1; i <= m; i++){
			int a, b;
			double w;
			cin>>a>>b;
			w = dis(point[a], point[b]);
			Addedge(a, b, w);
		}
		printf("%.3f\n", Kruskal());	
	}
	return 0;
}


Measured memory_bytes: 3836
import java.util.Scanner;

public class Main{
	public static void main (String[] args){
		String s;
		int a,z;
		Scanner sc = new Scanner(System.in);
		s = sc.next();
		a = s.indexOf("A");
		z = s.lastIndexOf("Z");
		System.out.println(z - a + 1);
	}
}


Measured memory_bytes: 26540
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


a,b = map(int,input().split())
if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 4084
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000000000LL
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 5005
int n, k;
string s, t, u;

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

    cin >> n >> k >> s;
    F0R(i, k){
        t = s;
        reverse(t.begin(), t.end());
        u = s+t;
        string mn = s;
        F0R(i, n){
            string nw = u.substr(i, n);
            mn = min(mn, nw);
        }
        s = mn;
        reverse(s.begin(), s.end());

        //cout << s << "\n";

        bool bleh = true;
        F0R(i, n-1){
            if(s[i] != s[i+1]){
                bleh = false;
                break;
            }
        }
        if(bleh) break;
    }
    reverse(s.begin(), s.end());
    cout << s << "\n";

    return 0;
}


Measured memory_bytes: 384
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map(fun x -> int x)
let char2String(value) = List.ofSeq value |> List.toArray |> System.String

let a, b = readIntArray() |> fun x -> (x.[0], x.[1])
if a = b then
    a + b
else if a < b then 
    b + b - 1
else 
    a + a - 1
|> printfn "%d"

Measured memory_bytes: 13916
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int INF=1001001001;
const int mod=1000000007;


int main() {
  string s;cin>>s;
  int n=s.size();
  int dp[n+5][2];
  rep(i,n+5)rep(j,2)dp[i][j]=0;
  dp[0][0]=1;//同じ
  dp[0][1]=0;//未満
  rep(i,n) {
    { // a+b = 0
      if (s[i] == '0') {
        dp[i+1][0] = dp[i][0];
        dp[i+1][1] = dp[i][1];
      } else {
        dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod;
      }
    }
    { // a+b = 1
      if (s[i] == '0') {
        (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;
      } else {
        (dp[i+1][0] += dp[i][0]*2 % mod) %= mod;
        (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;
      }
    }
  }
  int ans=dp[n][0]%mod+dp[n][1]%mod;
  ans=ans%mod;
  
  cout<<ans;

  }


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int D;
    cin >> D;

    switch (D) {
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 25:
            cout << "Christmas" << endl;
            break;
        default:
            break;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a, b;
		final double s = 3.305785;

		a = sc.nextInt();
		b = sc.nextInt();
		
		System.out.println(a * b / s);
	}
}

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

int sumofdigits(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }

  return sum;
}//各桁の和を計算する関数
 
int main() {
  
  int A,B,count=0;

  cin >> A >> B; 

  for(int i=A;i<=B;i++){
    int a=i/10000,b=i/1000,c=i/10;
    if((a%10==i%10)&&(b%10==c%10)) count++;
  }
 
  cout << count << endl;
 
  return 0;
}

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

const int n = 1e5 + 10;

int N, M;
vector<int> G[n];

bool vis[n];
stack<int> S;
int res;
vector<int> R;
set<pair<int,int>> V;
set<int> G2[n];

void dfs(int cur){
  while(!G2[cur].empty()){
    int x = * (G2[cur].begin());
    G2[cur].erase(x);
    G2[x].erase(cur);
    dfs(x);
  }
  R.push_back(cur);
}

void er(int i){
  if(G2[i].size() != 2)
    return;
  int a = * (G2[i].begin());
  G2[i].erase(a);
  int b = * (G2[i].begin());
  G2[i].erase(b);

  G2[a].erase(i);
  G2[b].erase(i);
  if(G2[a].count(b)){
    G2[a].erase(b);
    G2[b].erase(a);
    res++;
    er(a);
    er(b);
  }
  else{
    G2[a].insert(b);
    G2[b].insert(a);
  }
}

int main(){
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  bool flag = true;
  int cnt = 1;
  for(int i=0; i<N; i++){
    int g = G[i].size();
    G2[i].insert(G[i].begin(), G[i].end());
    if(g%2){
      flag = false;
    }
    cnt += (g-2)/2;
  }

  if(!flag || cnt < 3){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<N; i++){
    er(i);
  }
  for(int i=0; i<N; i++){
    if(G2[i].size())
      dfs(i);
  }
  for(auto cur : R){
    //cout << cur << endl;
    if(vis[cur]){
      int x;
      do{
        x = S.top();
        S.pop();
        vis[x] = false;
      } while(x != cur);
      res++;
    }
    vis[cur] = true;
    S.push(cur);
  }
  if(res >= 3){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 20352
X, Y, A, B, C = map(int, input().split())
*P, = map(int, input().split())
*Q, = map(int, input().split())
*R, = map(int, input().split())
P = sorted(P, reverse=True)
Q = sorted(Q, reverse=True)
R = sorted(R, reverse=True)
P = P[:X]
Q = Q[:Y]
PQ = sorted(P + Q)
ans = 0
cnt = 0
if X + Y > C:
    ans += sum(PQ[C:])
    cnt += X + Y - C
    PQ = PQ[:C]
PQR = PQ + R
PQR = sorted(PQR, reverse=True)
ans += sum(PQR[:X + Y - cnt])
print(ans)

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

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str, T: str):
    if S == T[:-1]:
        ret = YES
    else:
        ret = NO
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


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

map<long long, int> prime_factor(long long n)
{
    map<long long, int> ret;

    for (long long i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1)
    {
        ret[n] = 1;
    }

    return ret;
}

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

    long long x;
    long long ans = 0LL;
    for (int i = 0; i < N; i++)
    {
        cin >> x;
        map<long long, int> m;
        m = prime_factor(x);
        ans += m[2];
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m,ans;
    string s;
    map<string,int> mp;
    while(cin >> n)
    {
        mp.clear();
        for(int i = 0; i < n; i++)
        {
            cin >> s;
            mp[s]++;
        }
        cin >> m;
        for(int i = 0; i < m; i++)
        {
            cin >> s;
            mp[s]--;
        }
        ans = 0;
        for(auto p : mp)
            ans = max(ans, p.second);
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int a;
  double b;
  cin >> a >> b;

  int ans = a * (int)(b * 100 + 0.5);
  ans /= 100;
  cout << ans << endl;  

  return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int GCD(int a, int b) {
    if (b == 0) return a;
    return GCD(b, a % b);
}
int main()
{
    int N;
    cin >> N;
    vector<int> A(N), L(N + 1, 0), R(N + 1, 0);
    rep(i, N) cin >> A[i];

    rep(i, N) {
        L[i + 1] = GCD(L[i], A[i]);
    }
    for (int i = N - 1; i >= 0; i--) {
        R[i] = GCD(R[i + 1], A[i]);
    }

    int ans = 0;
    rep(i, N) {
        ans = max(GCD(L[i], R[i + 1]), ans);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <map>

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

    std::multimap<long long, long long> tasks;
    for(int i = 0; i < n; ++i){
        long long a, b;
        std::cin >> a >> b;

        tasks.insert(std::make_pair(b, a));
    }

    auto itr = tasks.begin();
    long long sum = 0;
    while(tasks.end() != itr){
        sum += itr->second;
        if(itr->first < sum){
            break;
        }
        itr++;
    }

    std::string ans = "No";
    if(tasks.end() == itr){
        ans = "Yes";
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
#include<string.h>
int main(){
    char S[100];
    int N;
    scanf("%s",S);
    N=strlen(S);
    for (int i=0; i<(N/2)-1; i++) {
        if (S[i]!=S[N-i-1]) {
            printf("No\n");
            return 0;
        }
    }
    for (int i=0; i<((N-1)/2)-i-1; i++) {
        if (S[i]!=S[((N-1)/2)-i-1]) {
            printf("No\n");
            return 0;
        }
    }
    for (int i=0; i<(N-((N+3)/2))/2; i++) {
        if (S[(((N+3)/2))-1+i]!=S[N-1-i]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int phase = 1;
        int i = 1;
        int x = 0;
        while(phase != 0){
            switch(phase){
                case 1:
                x = i;
                if(x%3==0){
                    System.out.printf(" %d",i);
                    phase = 3;
                    continue;
                }
                case 2:
                if(x%10==3){
                    System.out.printf(" %d",i);
                    phase = 3;
                    continue;
                }
                x/=10;
                if(x!=0){
                    phase = 2;
                    continue;
                }
                case 3:
                if(++i<=n){
                    phase = 1;
                    continue;
                }
            }
            System.out.printf("\n");
            phase = 0;
        }
    }
}


Measured memory_bytes: 40584
<?php

$x = array();
while (true) {
    $a = rtrim(fgets(STDIN));
    if ($a === '') {
        break;
    }
    list($n, $d) = explode(',', $a);
    if (!isset($x[$n])) {
        $x[$n] = 0;
    }
    $x[$n]++;
}

$y = array();
while (true) {
    $a = rtrim(fgets(STDIN));
    if ($a === '') {
        break;
    }
    list($n, $d) = explode(',', $a);
    if (!isset($x[$n])) {
        continue;
    }
    if (!isset($y[$n])) {
        $y[$n] = $x[$n];
    }
    $y[$n]++;
}

ksort($y);
foreach ($y as $k => $v) {
    echo sprintf('%d %d', $k, $v) . PHP_EOL;
}

Measured memory_bytes: 7256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i + k - 1 <= n)ans += 1;
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
	static int inf = Integer.MAX_VALUE/2;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N+K];
		Arrays.fill(h, inf);
		for(int i=0; i < N; i++) h[i] = sc.nextInt();
		int[] dp = new int[N+K];
		Arrays.fill(dp, inf);
		dp[0] = 0;
		for(int i = 0; i < N; i++) {
			for(int j = 1; j <= K; j++)
			dp[i+j] = Math.min(dp[i+j], dp[i] + Math.abs(h[i] - h[i+j]));
		}
		System.out.println(dp[N-1]);
	}
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b,n;
	cin >> a >> b >> n;
	cout << (a*min(n,(b-1)))/b << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

using P = pair<ll,int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vec<ll> A(N);
    for(auto& x:A) cin >> x;
    sort(A.begin(),A.end());
    vec<P> Q(M);
    for(auto& p:Q) cin >> p.second >> p.first;
    sort(Q.rbegin(),Q.rend());
    ll ans = 0;
    int id = 0;
    for(int i=0;i<N;i++){
        if(id==M) ans += A[i];
        else if(Q[id].first>A[i]){
            ans += Q[id].first;
            Q[id].second--;
            if(!Q[id].second) id++;
        }else ans += A[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5556
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long goal = sc.nextLong();
      	long i = 1;
      	long num1 = 1;
      	long num2 = goal;
      
      	while(i <= goal/i){
          if(goal % i == 0) {
            num1 = i;
            num2 = goal/i;
          }
          i++;
        }
 		
      	System.out.println(num1 + num2 - 2);
        
	}
}


Measured memory_bytes: 35876
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, M, D;
  cin >> N >> M;
  D=0;
  vector<int> A(M);
  for (int i=0; i<M; i++) {
    cin >> A[i];
  }
  for (int j=0; j<M; j++) {
    D=D+A[j];
  }
  cout << max((N-D),-1) << endl;
}

Measured memory_bytes: 3664
#define L long long int
m[31][50];main(n,p,d,x){L a[50],b;for(;scanf("%d",&n),n;){memset(m,0,6200);for(p=0;p<n;a[p]=(L)1<<p,p++)for(scanf("%d",&x);x;x--)scanf("%d",&d),m[d][p]=1;for(d=1;b=0,d<31;d++){for(b=p=0;p<n;p++)if(m[d][p])b|=a[p];for(p=0;p<n;p++)if(m[d][p]&&(a[p]=b)==((L)1<<n)-1){printf("%d\n",d);goto s;}}puts("-1");s:;}return 0;}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
int prime[20000], isPrime[20000], Anum[20000], top, top2, current;

int cmp(const void* a, const void* b){
    return *(int*)  a - *(int*) b;
}
void build(){
    int i, j, k;
    top= top2 = current = 0;
    i = j = 0;
    while(i*i<20000){
        for(j=i; i*i+j*j<20000 ; j++){
            if(!i && (j==1 || !j))  continue;
      //!      printf("i=%d,j=%d\n",i,j);
            int now =  i*i+j*j;
            if(now>20000)   continue;

            Anum[top2++] = now;
        }
        i++;
    }
    qsort(Anum, top2, sizeof(int), cmp);
    while(current < top2){
        int tot = Anum[current++];
        if(isPrime[tot])   isPrime[tot] = 2, prime[top++] = tot;
        for(k=current-1; k<top2; k++){
    //!        printf("Anum[k]=%d\n",Anum[k]);
            if(Anum[k]*tot > 20000)    break;
            isPrime[Anum[k]*tot] = 0;
        }
    }
    /*
    for(i=2; i<20000; i++){
     //   printf("isPrime[%d]=%d\n",i,isPrime[i]);
      //  if(!(i%2)) continue;
        if(!isPrime[i])  continue;
        prime[top++] = i;
        for(j=i+1; j<20000; j++)
            if(j%i == 0){
              //  printf("j,i=%d,%d\n",j,i);
                isPrime[j] = 0;
            }
    }*/
}
int gcd(int a, int b){
    return 0==b ?a  :gcd(b,a%b);
}
int main(){
    int m, n, i, T;
    for(i=0; i<20000; i++)  isPrime[i] = 1;
    build();
  /*  for(i=0; i<20; i++)
        printf("%d\n",prime[i]);
    for(i=0; i<20; i++)
        printf("isPrime[%d] = %d\n",i,isPrime[i]);
    printf("top=%d\n",top);*/
    scanf("%d", &T);
    while(T--){
        scanf("%d%d", &m, &n);
        if(gcd(m,n)>1 &&m &&n)
            printf("C\n");
        else if(isPrime[m*m+n*n] == 2)
            printf("P\n");
        else
            printf("C\n");
    }
    return 0;
}

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

b=0
for i in range(n):
  if a[i]%2==1:
    b +=0
  else:
    if a[i]%3 ==0 or a[i]%5==0:
      b +=0
    else:
      b +=1
      
if b == 0:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;scanf("%d",&N);
    double x[N],y[N];
    for(int i=0;i<N;i++)scanf("%lf%lf",&x[i],&y[i]);
    int a[N];
    for(int i=0;i<N;i++)a[i]=i;
    double ans=0,cnt=0;
    do{
        cnt++;
        for(int i=0;i<N-1;i++){
            ans+=sqrt(pow((x[a[i]]-x[a[i+1]]),2)+pow((y[a[i]]-y[a[i+1]]),2));
        }
    }while(next_permutation(a,a+N));
    printf("%lf\n",ans/cnt);
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();

        Set<Integer> ans = new HashSet<>();
        ans.add(1);
        ans.add(2);
        ans.add(3);
        ans.remove(A);
        ans.remove(B);
        System.out.println(ans.toArray()[0]);
    }
}


Measured memory_bytes: 35580
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

const int mod=1e9+7;

int maxProductSubarrayOfSizeK(int A[], int n, int k) 
{ 
    // sorting given input array 
    sort(A, A + n); 
  
    // variable to store final product of all element 
    // of sub-sequence of size k 
    int product = 1; 
  
    // CASE I 
    // If max element is 0 and 
    // k is odd then max product will be 0 
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
  
    // CASE II 
    // If all elements are negative and 
    // k is odd then max product will be 
    // product of rightmost-subarray of size k 
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) 
            product =(product*A[i])%mod; 
        return product; 
    } 
  
    // else 
    // i is current left pointer index 
    int i = 0; 
  
    // j is current right pointer index 
    int j = n - 1; 
  
    // CASE III 
    // if k is odd and rightmost element in 
    // sorted array is positive then it 
    // must come in subsequence 
    // Multiplying A[j] with product and 
    // correspondingly changing j 
    if (k & 1) { 
        product =(product* A[j])%mod;
        j--; 
        k--; 
    } 
  
    // CASE IV 
    // Now k is even 
    // Now we deal with pairs 
    // Each time a pair is multiplied to product 
    // ie.. two elements are added to subsequence each time 
    // Effectively k becomes half 
    // Hence, k >>= 1 means k /= 2 
    k >>= 1; 
  
    // Now finding k corresponding pairs 
    // to get maximum possible value of product 
    for (int itr = 0; itr < k; itr++) { 
  
        // product from left pointers 
        int left_product = A[i] * A[i + 1]; 
  
        // product from right pointers 
        int right_product = A[j] * A[j - 1]; 
  
        // Taking the max product from two choices 
        // Correspondingly changing the pointer's position 
        if (left_product > right_product) { 
            left_product%=mod;
            product = (product*left_product)%mod;
            i += 2; 
        } 
        else { 
            right_product%=mod;
            product =(product* right_product)%mod;
            j -= 2; 
        } 
    } 
  
    // Finally return product 
    return product; 
} 
int solve(){
    int n,k; cin>>n>>k;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int t=maxProductSubarrayOfSizeK(a,n,k);
    cout<<(t+mod)%mod;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 5220
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int n,m; cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}


Measured memory_bytes: 3556
N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(list(map(str, A))))



Measured memory_bytes: 5600
//与えられた文字列targetが円文字列circleの中に見つかるか 
//ただし、1周以内とする

#include <stdio.h>
#define Num 120

int main () {
	char a;
	char ch[Num]; //circle
	char c[Num]; //target
	char b[Num]; //chの中でcと一致し始めたところから
	int i,j,k,l,m,n,o,p;
	i=0;
	j=0;
	k=0;
	l=0;
	m=0;
	n=0;
	
	
	//それではcircleのchを読み込みましょう
	while (1) {
		scanf ("%c",&a); 
		if (a == '\n') { //enter押したら
			break;
		}
		ch[i] = a; 
		i ++;
	}
	//whileを抜けるとiが読み込んだ文字数になります
	
	j = 0;
	
	//next read target c
	//ほぼ上と同じ
	while (1) {
		scanf ("%c",&a);
		if (a == '\n') {
			break;
		}
		c[j] = a;
		j ++;
	}
	
	/*next target c[0]がcircle chの何番目と始めて一致するか　
	  そこからcが全て一致すればよい */
	for (k = 0;k < i;k ++) { //i == circle の文字数
		//circleでtargetと一致するまで辿ります
		//一致しなければ k == i-1 まで
		if (ch[k] == c[0]) {
			l = k; //一致した番号記録
			n = 0; //why
			//circleを一致し始めてからに並べ変え
			for (m = 0;m < (i-1) - k + 1;m ++) { 
			//circleの最後まで　一致してから　
				l ++; //k -> k+(i-k-1) = i-1
				b[m] = ch[l-1]; //why l-1
				n ++; //0 -> i-k-1
			}
			
			//l再利用
			l = 0;
			
			//b[m]の続き circleの始めから
			for (m = n;m < n+1+k;m ++) {
				l ++; //l-1 == 0 -> i-1
				b[m] = ch[l-1];
			}
			o = 0; //why
			for (n = 0;n < j;n ++) {
				if (b[n] == c[n]) {
					o ++; //o == j ならyes
				}
			}
			
        }
	
		if (o == j) {
	        printf ("Yes\n");
	        break;
	    } else if (k == i-1) { //c[0]がなかった
	        printf ("No\n");
        }
	}
	
				
    return 0;		
	
}






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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b,x;

main() {
    cin >> x >> a >> b;
    ct((x-a)%b)
}






Measured memory_bytes: 256
use std::str::FromStr;
use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let mut s = i.read::<usize>();
    let mut ss = Vec::new();
    while s != 0 {
        ss.push(s % 10);
        s /= 10;
    }
    // 和とパターン数を返す
    fn f(ss: &[usize]) -> (usize, usize) {
        if ss.len() == 0 {
            return (0, 1);
        }
        let mut sum = 0;
        let mut count = 0;
        let mut b = 1;
        let mut value = 0;
        for i in 0..ss.len() {
            value += ss[i] * b;
            let (i_sum, i_count) = f(&ss[i + 1..]);
            sum += i_sum;
            sum += i_count * value;
            count += i_count;
            b *= 10;
        }
        (sum, count)
    }
    writeln!(o, "{}", f(&ss).0).unwrap();
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
    }
}


Measured memory_bytes: 4352
arr = []
n = STDIN.gets.chomp.to_i
arr = STDIN.gets.chomp.split(" ").map { |e| e.to_f }

ave = arr.inject(:+).to_i / n
ave_p1 = ave + 1
ave_m1 = ave - 1

sum = 0
sum_p1 = 0
sum_m1 = 0

arr.each do |num|
	sum += (ave-num) ** 2
	sum_p1 += (ave_p1-num) ** 2
	sum_m1 += (ave_m1-num) ** 2
end


STDOUT.print "#{[sum,sum_p1,sum_m1].min.to_i}\n"


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;
  ll v[n];
  map<ll, ll> ma, mb;
  REP(i, n){
    cin >> v[i];
    if(i % 2) mb[v[i]]++;
    else ma[v[i]]++;
  }
  ll a1, a2, b1, b2;
  ll ca = 0, ca2 = 0, cb = 0, cb2 = 0;
  REP(i, ma.size()){
    if(ma[i] > ca){
      a1 = i;
      ca = ma[i];
    }
  }
  REP(i, ma.size()){
    if(ma[i] > ca2 && i != a1){
      a2 = i;
      ca2 = ma[i];
    }
  }
  REP(i, mb.size()){
    if(mb[i] > cb){
      b1 = i;
      cb = mb[i];
    }
  }
  REP(i, mb.size()){
    if(mb[i] > cb2 && i != b1){
      b2 = i;
      cb2 = mb[i];
    }
  }

  if(a1 != b1) cout << n - ca - cb << endl;
  else{
    ll ans = min(n - ca - cb2, n - ca2 - cb);
    cout << ans << endl;
  }
}


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

int N,M;
int W[100010],V[100010];
int dp[110][10100];
int ans = 0;

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 1; i <= N; i++)
        scanf("%d%d",V + i,W + i);


    for(int i = 0; i <= N; i++)for(int j = 0; j <= M; j++)dp[i][j] = -10000000;
    dp[0][0] = 0;

    for(int i = 1; i <= N; i++)
    {
        for(int j = 0; j <= M; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if(j - W[i] >= 0)dp[i][j] = max(dp[i][j],dp[i - 1][j - W[i]] + V[i]);
            ans = max(dp[i][j],ans);
        }
    }

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

Measured memory_bytes: 7180
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
    if n > 1:return {n} 
    return set(ret)
def main():
    n=int(input())
    a=list(map(int,input().split()))
    g=a[0]
    for i in a[1:]:g=gcd(g,i)
    if g!=1:
        print("not coprime")
        exit()
    ans=0
    s=set()
    for i in a:
        p=primeFactor(i)
        ans+=len(p)
        s|=p
    if ans!=len(s):print("setwise coprime")
    else:print("pairwise coprime")
if __name__ == "__main__":
    main()

Measured memory_bytes: 204512
/**Coder Khỏe ♥♥♥ Code Vui**/
#include<bits/stdc++.h>

using namespace std;

#define ii pair<int, int>
#define li pair<long long, int>
#define si pair<string, int>
#define is pair<int, string>
#define ci pair<char, int>
#define ic pair<int, char>
#define iii pair<pair<int, int>, int>
#define fi first
#define se second
#define FOR(i,x,y) for (int i=x; i<=y; i++)
#define FOD(i,x,y) for (int i=x; i>=y; i--)

const int oo=1e9+9;
const int nmax=1e6+9;
const int cot[4]={0, 0, -1, 1};
const int dong[4]={-1, 1, 0, 0};
long long k;
long long a[59];
//------------------------------------------
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("text.inp",  "r", stdin);
    //freopen("text.out", "w", stdout);
    cin>>k;
    FOR(i,1,50)
        a[i]=49+k/50;
    k%=50;
    FOR(i,1,k)
    {
        a[i]+=50+1;
        FOR(j,1,50) a[j]--;
    }
    cout<<50<<endl;
    FOR(i,1,50)
    {
        cout<<a[i]<<' ';
    }
    return 0;
}
/**NXKhang ♥ VNgHT**/





Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        ntok();
        String s = spar();
        ntok();
        String t = spar();
        int same = 0;
        for (int i = 0; i < s.length(); i++)
        {
            if (s.charAt(i) == t.charAt(i))
            {
                same++;
            }
        }
        out.println(same);

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

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


Measured memory_bytes: 21204
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

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

print(ans)


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

const int MAX_N=1e4+10;

int N,a,b,sum=0,now=0;
vector<vector<int>> G(MAX_N);
vector<int> c(MAX_N),ans(MAX_N);

void dfs(int v,int p){
    ans[v]=c[now++];
    for (int u:G[v]){
        if (u!=p) dfs(u,v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i=0;i<N-1;++i){
        cin >> a >> b; --a,--b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    for (int i=0;i<N;++i) cin >> c[i];
    sort(c.begin(),c.begin()+N);
    reverse(c.begin(),c.begin()+N);
    for (int i=1;i<N;++i) sum+=c[i];
    cout << sum << '\n';
    dfs(0,-1);
    for (int i=0;i<N;++i) cout << ans[i] << (i!=N-1?' ':'\n');
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;

  cin >> a >> b;

  if(b % a == 0){
	cout << a + b << endl;
  }else{
	cout << b - a << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;


int main()
{
	long long N, output, count;
	cin >> N;
	output = 0;
	count = 1;
	while (true)
	{
		long long x = (N - count) / count;
		if (x <= count) break;
		if ((N - count) % count == 0)
		{
			output += x;
		}
		count++;
	}
	cout << output << endl;
}

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

int main(){
  int n;
  cin>>n;
  if(n%10==0){
    cout<<10<<endl;
  }else{
    string s=to_string(n);
    int ans=0;
    for(int i=0;i<s.size();i++)ans+=s[i]-'0';
    cout<<ans<<endl;
  }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll ans = 0;
	ll r, g, b, n;cin >> r >> g >> b >> n;
	for(int i = 0;i <= 3000;i++){
		for(int j = 0;j <= 3000;j++){
			ll tmp = n - (i * r + j * g);
			if(tmp >= 0 && tmp % b == 0){
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int

const int hell=1000000007;


int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;
    a%=10000000000LL;}
  return a;
}



int gcd(int a,int b)
{   
  
  if(b==0)return a;
  return gcd(b-a%b,a%b);
}

bool cmp(pii a,pii b)
{
  return a.SS<b.SS;
}


int sum(int a,int b )
{
   int ans=a-a/b; 
   return ans;
}
int solve()
{  
 
int n;
cin>>n;
vii a;
rep(i,0,n)
{
  int l,r;
  cin>>l>>r;
  a.pb({l,r});
}
sort(all(a),cmp);
 
 int sum=0;
 rep(i,0,n)
 {
  sum+=a[i].FF;
  if(sum>a[i].SS)
  {
    cout<<"No";
    return 0;
  }
 }
 cout<<"Yes";return 0;


    return 0;
}


signed main()
{  int t=1;
//pri();
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    


 

  clock_t time_req;

    // Without ung pow function
                                                                                                                   

  //cin>>t;

    int k=1;
   while(t--)
     {
      // cout<<"Case #"<<k<<":"<<" ";k++;
      solve();
     

     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
} 

Measured memory_bytes: 6256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef double d;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=min(a+c,a+d);
    ans=min(min(ans,b+c),b+d);
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> picture(H+2,vector<char>(W+2));
  
  for (int i = 0; i <= H+1; i++){
   for (int j = 0; j <= W+1; j++){
     if ((i == 0)||(i == H+1)||(j == 0)||(j == W+1)) picture.at(i).at(j) = '#';
     else  cin >> picture.at(i).at(j);
   }
  }
  for (int i = 0; i <= H+1; i++){
   for (int j = 0; j <= W+1; j++){
     if(j == W+1) cout << picture.at(i).at(j) << endl;
     else cout << picture.at(i).at(j);
   }
  }
}

Measured memory_bytes: 256