akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
  int N,X,sum,count,i;
  int a[10];
  scanf("%d",&N);
  X=N;
  count=0;
  sum=0;
  while(N!=0){
    a[count]=N%10;
    N = (N-a[count])/10;
    count++;
  }
  for(i=0;i<count;i++)sum+=a[i];
  if(X%sum==0)printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
# union-find
# https://note.nkmk.me/python-union-find/

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        # 各要素の親要素を格納する

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.find(self.parents[x])
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return
    
    def size(self, x):
        x = self.find(x)    
        return self.parents[x]*(-1)

def main():
    n, m = map(int, input().split())
    friend = UnionFind(n)

    for _ in range(m):
        a, b = map(int, input().split())
        friend.union(a-1, b-1)
    
    ans = 0
    for i in range(n):
        ans = max(ans, friend.size(i))
    print(ans)

if  __name__ == "__main__":
     main()


Measured memory_bytes: 14588
#include <stdio.h>

int c[3][3];

int main() {

	int i,j;

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			scanf(" %d",&c[i][j]);
		}
	}

	for(i=0;i<=c[0][0];i++){
		int b1=c[0][0]-i;
		int b2=c[0][1]-i;
		int b3=c[0][2]-i;
		if(0<=b1&&b1<=100 && 0<=b2&&b2<=100 && 0<=b3&&b3<=100){
			int a2_x=c[1][0]-b1;
			int a2_y=c[1][1]-b2;
			int a2_z=c[1][2]-b3;
			if(a2_x==a2_y&&a2_x==a2_z &&0<=a2_x&&a2_x<=100){
				int a3_x=c[2][0]-b1;
				int a3_y=c[2][1]-b2;
				int a3_z=c[2][2]-b3;
				if(a3_x==a3_y&&a3_x==a3_z &&0<=a3_x&&a3_x<=100){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}

	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
int lcm(int a,int b){int c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

P m[51];
ll dfs(ll n,ll k){
	if(k<=0)return 0;
	if(n==1){
		if(k==5)return 3ll; 
		else return k-1ll;
	}
	ll leveln = m[n].first + m[n].second;
	if(k==leveln){
		return m[n].second;
	}else if(k==(leveln/2ll+1ll)){
		return m[n-1].second+1ll;
	}else if(k < (leveln/2ll+1ll)){
		return dfs(n-1,k-1);
	}else{
		return m[n-1].second+1ll+dfs(n-1,k-1ll-leveln/2ll);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,x;
	cin >> n >> x;
	m[0] = {0ll,1ll};
	FOR(i,1,51)m[i]={m[i-1].first*2ll+2ll,m[i-1].second*2ll+1ll};//{b,p}
	cout << dfs(n,x) << endl;
}

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

m = 0
for i in range(N):
    cnt = 0
    for j in range(i+1):
        cnt += A1[j]
    for j in range(i,N):
        cnt += A2[j]
    if m < cnt:
        m = cnt

print(m)


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

import itertools
import bisect

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_ = 0
count = 0
for i in range(len(a)):
    if (sum_+a[i]) > k:
        break
    else:
        count += 1
        sum_ += a[i]
a_max = count

sum_ = 0
count = 0
for i in range(len(b)):
    if (sum_+b[i]) > k:
        i = i-1
        break
    else:
        count += 1
        sum_ += b[i]
b_max = count


list_ = list(reversed(a[:a_max])) + b[:b_max]
list_acc = list(itertools.accumulate(list_))


index = bisect.bisect_right(list_acc, k)
ans = index

now_left = 0
now_right = index


# print(list_)
while(now_right != len(list_)):
    k += list_[now_left]
    now_left += 1

    while(now_right != len(list_)):
        if list_acc[now_right] <= k:
            now_right += 1
        else:
            break
    # print(ans)
    ans = max(ans, now_right-now_left)

print(ans)


Measured memory_bytes: 47340
line = readlines.map(&:chomp)
text_a = line[0].split("")
text_b = line[1].split("")
num = 0
ans = 0

text_a.each do |n|
  if n != text_b[num]
  	text_a[num] = text_b[num]
    ans += 1
  end
  num += 1
end

puts ans

Measured memory_bytes: 35208
#include <iostream>
#include <climits>

using namespace std;

int cnt = 0;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    int l = 0, r = 0;
    for (int i = left; i < right; i++) {
        if (L[l] <= R[r]) A[i] = L[l++];
        else A[i] = R[r++];
        cnt++;
    }
}

void mergeSort(int A[], int left, int right) {
    if(right > 1 + left) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

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

    for(int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 6900
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.nextLine());
		long[] count ={0,0,0,0,0};// m a r c h
		String s;
		char ini;
		for (int i = 0;i < n;++i){
			s=scan.nextLine();
			ini = s.charAt(0);
			switch (ini) {
				case 'M':++count[0];
					break;

				case 'A':++count[1];
					break;

				case 'R':++count[2];
					break;
				case 'C':++count[3];
					 break;
				case 'H':++count[4];
					break;
			}
		}
			long ans=0;
			for (int i = 0;i<5;++i){
				for(int k = i+1;k<5;++k){
					for(int j =k+1;j<5;++j){
						ans+=count[i]*count[k]*count[j];
					}
				}
			}
			System.out.print(ans);

	}
}
//end

Measured memory_bytes: 91560
s = input()
n = len(s)
dp = [[0] * 13 for _ in range(n)]
mod = 10**9 + 7

if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1

for i in range(1,n):
    if s[i] == '?':
        for j in range(13):
            for k in range(10):
                dp[i][(j * 10 + k) % 13] += dp[i-1][j]
    else:
        k = int(s[i])
        for j in range(13):
            dp[i][(j * 10 + k) % 13] += dp[i-1][j]
    for j in range(13):
        dp[i][j] %= mod

print(dp[n-1][5]%mod)


Measured memory_bytes: 61916
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    ll N, T;
    cin >> N >> T;

    vector<P> v(N);
    REP(i, N) cin >> v[i].first >> v[i].second;

    sort(v.begin(), v.end(), [](P x, P y) { return x.first < y.first;});

    vector<vector<ll>> dp(N+1, vector<ll>(T+1, 0));

    ll mt = 0;
    REP(i, N)REP(j, T){
        if (j + v[i].first >= T) mt = max(mt, dp[i][j] + v[i].second);
        else dp[i+1][j+v[i].first] = max(dp[i+1][j+v[i].first], dp[i][j] + v[i].second);
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    }
    //REP(i, N) cout << v[i].first << " " << v[i].second << endl;
    //REP(i, T) cout << dp[N][i] << " ";

    cout << mt << endl;

    

    return 0;
}

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

int main() {
  int N,A,B,x1,x2;
  cin >> N >> A >> B;
  x1 = A * N;
  x2 = B;
  if (x1 <= x2)
    cout << x1 << endl;
  else
    cout << x2 << endl;
}

Measured memory_bytes: 256
ns=list(map(str,input().split()))
mp={}
for n in ns:
    if n in mp:
        mp[n] +=1
    else:
        mp[n]=1
long_word=""
freq_word=""
max_len=0
max_fre=0
for k,v in mp.items():
    if max_len<len(k):
        max_len=len(k)
        long_word=k
    if max_fre<v:
        max_fre=v
        fre_word=k
print(fre_word, long_word)



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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    int n;

    cin >> n;

    if(n%2==0){
        cout << setprecision(10) << 0.50000000 << endl;
    } else {        
        cout << setprecision(10) << ceil(n / 2.0) / (n / 1.0) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


 
template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;
 
  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }
 
  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }
 
  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }
 
  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }
 
  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};
 
using RH1 = RollingHash< 1000000007 >;
using RH2 = RollingHash< 1000000021 >;
 
int main(){
    string S,t;cin >> S >> t;
    string s=S;
    while(s.size()<5*1e6) s=s+s;
    RH1 rhs1(s);
    RH1 rht1(t);
    RH2 rhs2(s);
    RH2 rht2(t);
    int ans = 0;
    vector<bool> used(s.size(),false);
    for (int i = 0; i < s.size(); i++) {
        int cnt=0;
        for (int j = i; j < s.size(); j+=t.size()) {
            if(used[j]) break;
            used[j]=true;
            cnt++;
            if(rht1.get(0,t.size())==rhs1.get(j,j+t.size())||rht2.get(0,t.size())==rhs2.get(j,j+t.size())) ans=max(cnt,ans);
            else break;
            if(j>1e6&&i<S.length()){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 149724
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int N;
  int ans=0;
  cin>>N;
  FOR(i,0,N){
    bool y=true;
    int num;
    cin>>num;
    for(int i=2;i*i<=num;i++){
      if(num%i==0){
        y=false;
        break;
      }
    }
    if(y){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> x(m);
	for (int i = 0; i < m; i++) cin >> x[i];
	sort(x.begin(), x.end());

	vector<ll> d(m - 1);
	for (int i = 0; i < m - 1; i++) d[i] = x[i + 1] - x[i];
	ll sum = accumulate(d.begin(), d.end(), 0);
	sort(d.begin(), d.end(), greater<ll>());

	for (int i = 0; i < n - 1; i++) {
		if (i < d.size()) sum -= d[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 1792
N = int(input())
now = (0,0,0)
for i in range(N):
    t,x,y = map(int,input().split())
    diff_dist = abs(x-now[1]) + abs(y-now[2])
    diff_time = t - now[0]
    if diff_time % diff_dist == 0 and diff_time >= diff_dist:
        pass
    else:
        print("No")
        exit()
    now = (t,x,y)
print("Yes")



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

int main(){
	for (;;){
		int N;
		cin >> N;
		if (N == 0) break;

		int ans = 0;
		for (int a = 2; a <= N / 2 + 1; a++){
			for (int b = a - 1; b >= 1; b--){
				int tmp = a * (a + 1) - b * (b - 1);
				if (tmp == 2 * N) ans++;
				else if (tmp > 2 * N) break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    hs <- getLine
    let f "" = Nothing
        f xs = let (a, b) = break (== ',') xs
                in Just (a, drop 1 b)
    let hss = unfoldr f hs
    putStrLn $ unwords hss

Measured memory_bytes: 380
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int min = 10 * N;
		for(int A = 1; A <= N / 2; A++) {
			int B = N - A;
			min = Math.min(min, digitsSum(A) + digitsSum(B));
		}
		System.out.println(min);
	}
	static int digitsSum(int n) {
		int ret = 0;
		String s = Integer.toString(n);
		for(int i = 0; i < s.length(); i++) {
			ret += Integer.parseInt(s.substring(i, i + 1));
		}
		return ret;
	}
}

Measured memory_bytes: 38060
#include <stdio.h>

int main()
{
    char w[10];
    scanf("%s", w);

    if(w[0] == 'S'){
        printf("Cloudy\n");
    } else if(w[0] == 'C'){
        printf("Rainy\n");
    } else {
        printf("Sunny\n");
    }
    return 0;
}
 

Measured memory_bytes: 128
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	int N = 0;
	scanf("%d", &N);

	int i = 0;
	for (i = 0; i< N; i++) {
		printf("ACL");
	}
	printf("\n");
	//yesno(ans);
	//okng(ans);
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int a, b;
    cin >> a >> b;

    if (a + b < 10)
    {
        cout << a + b << '\n';
    }
    else
    {
        cout << "error" << '\n';
    }
    return 0;
}


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

int main() {
  int n, m = 0, x = 0;
  char c;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> c;
    x += (c == 'I') * 2 - 1;
    m = max(m, x);
  }
  cout << m << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = [(int(i) + 1) / 2 for i in input().split()]
a = 0
for j in range(k):
    a += p[j]
m = a
for i in range(1, n - k + 1):
    a += p[i + k-1] - p[i-1]
    if m < a:
        m = a
print(m)


Measured memory_bytes: 23524
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

# N個の県、M個の市
N, M = getNM()
city = []
# i県の中でn番目に→誕生が早い順に全ての都市を並べる
# →i県の市が来た時だけpref[i] += 1する　
# i県の中での順位が効率よく求められる
pref = [1] * (N + 1)
for i in range(M):
    # 市iについて
    # p県に属し、y年生まれ
    p, y = getNM()
    # 入力した順番についてのインデックス(i)を通っておく
    city.append([i + 1, p, y])
# 誕生が早い順に全ての都市を並べる
city = sorted(city, key=lambda i: i[2])

ans = []
for i, p, y in city:
    np = len(str(p))
    uppercode = '0' * (6 - np) + str(p)

    # p県のうちで何番目か
    order = pref[p]
    yp = len(str(order))
    undercode = '0' * (6 - yp) + str(order)
    # 次に来るp県の都市はpref[i] + 1番目に早く生まれた
    pref[p] += 1
    ans.append([i, uppercode + undercode])

ans = sorted(ans, key=lambda i: i[0])
for i in ans:
    print(i[1])

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

int main(){
    int a[5];
    int k;
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
    bool res = true;
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            if(a[j] - a[i] > k){
                res = false;
            }
        }
    }
    if(res){
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

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

double get_radian(double x1, double y1, double x2, double y2) {
	if(fabs(x1-x2) < 0.00000001f) {
		if(fabs(y1-y2) < 0.00000001f) {
			return 0.0f;
		} else if(y1 > y2) {
			return 3 * M_PI / 2;
		} else {
			return M_PI / 2;
		}
	} else if(fabs(y1-y2) < 0.00000001f) {
		if(fabs(x1-x2) < 0.00000001f) {
			return 0.0f;
		} else if(x1 > x2) {
			return M_PI;
		}
		return 0.0;
	}
	
	if(x2 >= x1) {
		if(y2 >= y1) {
			return atan((y2-y1)/(x2-x1));
		}
		return 2 * M_PI + atan((y2-y1)/(x2-x1));
	} else {
		if(y2 >= y1) {
			return M_PI - atan((y2-y1)/(x1-x2));
		}
		return M_PI + atan((y2-y1)/(x2-x1));
	}
}

int main(void) {
	double x1,x2,x3,x4,y1,y2,y3,y4;
	double rad1, rad2;
	double rdiff;
	int i, n;
	
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf\n", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		rad1 = get_radian(x1, y1, x2, y2);
		rad2 = get_radian(x3, y3, x4, y4);
		
		rdiff = fmod(2*M_PI+rad1-rad2, M_PI);

		if(fabs(rdiff) < 0.0000001f || fabs(rdiff-M_PI) < 0.0000001f) {
			printf("2\n");
		} else if(fabs(rdiff-M_PI/2) < 0.0000001f) {
			printf("1\n");
		} else {
			printf("0\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 696
#include <iostream>
using namespace std;
int main(void) {
  string sa, sb;
  cin >> sa >> sb;
  int n = stoi(sa + sb);
  string result = "No";
  for (int i = 1; i * i <= n; i++) {
    if (i * i == n) {
      result = "Yes";
    }
  }
  cout << result << endl;
  return 0;
}

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

using namespace std;

const int maxn = 2010;

const int mod = 1e9+7;

typedef long long ll;

int n, m, k, t, ans;
int dp[maxn*2][maxn*2];
int pre[maxn*2][maxn*2];
int cnt[maxn*2];

int main() {
    scanf("%d%d%d", &n, &m, &k);
    t = (n+m-1)/(k-1);
    for (int i = 0; i <= m; i++) pre[0][i] = 1;
    for (int i = 1; i <= t; i++) {
        for (int j = 0; j <= m; j++) {
            int v1 = pre[i-1][j];
            if (j >= k) v1 -= pre[i-1][j-k];
            if (v1 < 0) v1 += mod;
            dp[i][j] = v1;
        }
        for (int j = 1; j <= m; j++) {
            int v1 = pre[i-1][j-1];
            if (j >= k) v1 -= pre[i-1][j-k];
            if (v1 < 0) v1 += mod;
            if ((j-m)%(k-1) == 0 && 1ll*i*(k-1)-j <= n-1) {
                (ans += v1) %= mod;
            }
        }
        pre[i][0] = dp[i][0];
        for (int j = 1; j <= m; j++) {
            pre[i][j] = (pre[i][j-1]+dp[i][j])%mod;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> H(N);
  
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  
  vector<bool> check(N,true);
  
  for(int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    if(H[A] <= H[B])
      check[A] = false;
    if(H[A] >= H[B])
      check[B] = false;
  }
  
  int sum = 0;
  
  for(int i = 0; i < N; i++){
    if(check[i])
      sum++;
  }
  
  cout << sum << endl;
  
  return 0;
  
}

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

public class AtCoderABC140B
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine();
        var Num = int.Parse(line); // 料理数
        line = Console.ReadLine();
        var Order = line.Split().Select(s=>int.Parse(s)); // 食べた順番
        line = Console.ReadLine();
        var Satisfaction = line.Split().Select(s => int.Parse(s)).ToList(); // 満足度
        line = Console.ReadLine();
        var Bonus = line.Split().Select(s => int.Parse(s)).ToList(); // 追加満足度

        var ret = 0;

        var preOdr = -1; // 前回食べた料理
        foreach (var o in Order)
        {
            ret += Satisfaction[o - 1];
            if (preOdr == (o - 1))
            {
                ret += Bonus[preOdr -1];
            }
            preOdr = o;
        }

        Console.WriteLine(ret.ToString());
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    ll x;
    cin >> x;

    ll cnt500 = 0;
    ll cnt5 = 0;

    cnt500 = x/500;
    ll nokori = x - 500*cnt500;
    cnt5 = nokori/5;

    cout << (ll)(cnt500*1000 + cnt5*5) << endl;
    return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var S = "RGBY";
		
		if(D % 2 == 1){
			char[][] ca = new char[H][];
			for(int i=0;i<H;i++) ca[i] = new char[W];
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					ca[i][j] = (i+j)%2 == 0 ? 'R' : 'G';
				}
			}
			for(int i=0;i<H;i++) Console.WriteLine(new String(ca[i]));
			return;
		} else {
			char[][] ca = new char[H][];
			for(int i=0;i<H;i++) ca[i] = new char[W];
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					int nX = i + j + 10000000;
					int nY = i - j + 10000000;
					
					ca[i][j] = S[ (nX / D % 2) * 2 + (nY / D % 2) ];
				}
			}
			for(int i=0;i<H;i++) Console.WriteLine(new String(ca[i]));
			return;
		}
		
	}
	int H,W,D;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1]; D = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    ll ans = 0;
    rep(i,n)cin>>a[i];
    rep(i,n){
        cin>>b[i];
        ans += b[i];
    }
    rep(i,n-1)cin>>c[i];
    rep(i,n-1){
        if(a[i]+1==a[i+1]){
            ans += c[a[i]-1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
int main(){
  	int L, R, i, min, j;
    cin >> L >>R;
	if(R-L>=2019){
        cout<<0<<endl;
    }else{
      	if(R-L==1){cout<<(L%2019)*(R%2019)%2019<<endl;
        }else{
          min=2019;
          for(i=0; L+i<R; i++){
              for(j=i+1; L+j<=R; j++){
                  if(((L+i)%2019)*((L+j)%2019)%2019<min){
                    min=((L+i)%2019)*((L+j)%2019)%2019;
                  }else{}
                  if(min==0){break;}
              }if(min==0){break;}
          }
          cout<<min<<endl;
        }
    }
 
 
}

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

void Main() {
  ll a,b,t;
  cin >> a >> b >> t;
  pr(t/a*b);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define MAXN 100005
#define mo 974711
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}

struct node {
    int to,next;
}E[MAXN * 2];
int head[MAXN],sumE,N,ans;
int dp[MAXN],fr[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs1(int u,int fa) {
    int son = 0,cnt = 0;
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    ++son;
	    dfs1(v,u);
	    if(dp[v]) ++cnt;
	    dp[u] += dp[v];
	}
    }
    if(cnt < son - 1) dp[u] += son - 1 - cnt;
}
void dfs2(int u,int fa) {
    int sum = 0,son = 0,cnt = 0;
    if(fa != -1) {
	sum = 0,son = 0,cnt = 0;
	for(int i = head[u] ; i ; i = E[i].next) {
	    int v = E[i].to;
	    if(v != fa) {
		++son;
		sum += dp[v];
		if(dp[v]) ++cnt;
	    }
	}
	++son;sum += fr[u];if(fr[u]) ++cnt;
	if(cnt < son - 1) sum += son - 1 - cnt;
	ans = min(ans,sum + 1);
    }
    sum = 0,son = 0,cnt = 0;
    if(fa != -1) {sum += fr[u];++son;if(fr[u]) ++cnt;}
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    ++son;
	    sum += dp[v];
	    if(dp[v]) ++cnt;
	}
    }
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    int t = dp[v] > 0;
	    fr[v] = sum - dp[v];
	    if(son - 2 > cnt - t) fr[v] += son - 2 - cnt + t;
	    dfs2(v,u);
	}
    }
}
void Solve() {
    int x,y;
    read(N);
    for(int i = 1 ; i < N ; ++i) {
	read(x);read(y);
	add(x,y);add(y,x);
    }
    dfs1(0,-1);
    ans = dp[0] + 1;
    dfs2(0,-1);
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 10752
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max 2000
#define INF 100000000000

int main(){
    llong n,z,w;
    cin >> n >> z >> w ;
    llong card[n_max + 5];
    REP(i,n) scanf("%ld",&card[n-i]);

    if(n==1){
        cout << abs(w-card[1]) << endl;
        return 0;
    }

    llong x,y;
    llong x_min=INF;
    llong y_max =- INF;
    FOR(i,1,n){
        x=max( abs(card[1] - card[i+1]) , y_max);
        y=min( abs(card[i+1] - card[1]), x_min);
        y_max=max(y,y_max);
        x_min=min(x,x_min);
    }
    cout << max( abs(card[1]-w) , y_max) << endl;
}

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

int main(){
    string s,t;
    int a,b;
    string u;

    cin >> s >> t >> a >> b >> u;

    int res = s.compare(u);

    if(res == 0) a--;
    else b--;
    
    cout << a << " " << b;
    return 0;
}

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

void solve(long long N, vector<long long> A){
	vector<long long> B(N + 1);
	map<long long, long long> mp;
	for(int i = 0; i < N; ++i) {
		B[i + 1] = B[i] + A[i];
	}
	for(int i = 0 ; i <= N; ++i) {
		mp[B[i]]++;
	}
	long long res = 0;
	for(auto p: mp) {
		res += p.second * (p.second - 1) / 2;
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 17408
a, b, c = map(int, input().split(' '))
modlist = []
result = ""
for i in range(1, b + 1):
    value = a * i
    if value % b == c:
        result = "YES"
        break
    if value % b not in modlist:
        modlist.append(value % b)
    else:
        result = "NO"
        break
print(result)


Measured memory_bytes: 2940
#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;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 3e5 + 123;
int n, a[N], k;
ll p[N], s[N];
priority_queue <int, vector <int>, greater <int> > P;
priority_queue <int> S;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	n *= 3;
	k = n / 3;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n - k; i++) {
		p[i] = p[i - 1];
		P.push(a[i]), p[i] += a[i];
		if ((int)P.size() > k)
			p[i] -= P.top(), P.pop();
	}
	ll res = -1e18;
	for (int i = n; i > k; i--) {
		s[i] = s[i + 1];
		S.push(a[i]), s[i] += a[i];
		if ((int)S.size() > k)
			s[i] -= S.top(), S.pop();
		if (i <= n - k + 1) {
			res = max(res, p[i - 1] - s[i]);
		}
	}
	cout << res;
}


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

using namespace std;

typedef pair<int, int> pii;

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

    int m; cin >> m;

    long long len = 0, sum = 0;
    for(int i = 0; i < m; ++i) {
        long long c;
        int d;
        cin >> d >> c;

        len += c;
        sum += d*c;
    }

    long long ans = (len - 1) + (sum - 1)/9;
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> P;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int N,D,A; cin >> N >> D>> A;
  vector<P> monsters(N);
  rep(i,N) {
    cin >> monsters[i].first >> monsters[i].second;
  }
  sort(monsters.begin(), monsters.end(), [](P a, P b){return a.first < b.first;});
  ll ans =0;
  ll tot = 0;
  queue<P> q;
  rep(i,N) {
    ll x = monsters[i].first; 
    ll h = monsters[i].second;
    while (q.size() && q.front().first < x) {
      tot -= q.front().second; q.pop();
    }
    h -= tot;
    if (h>0) {
      ll num = (h-1+A)/A ;
      ans += num;
      ll damage = num*A;
      tot += damage;
      q.emplace(x+2*D, damage);
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
ll minv;
ll maxv;

// ll gcd(ll a, ll b)
// {
// 	if (a % b == 0)
// 	{
// 		return (b);
// 	}
// 	else
// 	{
// 		return (gcd(b, a % b));
// 	}
// }

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

ll f(ll d)
{
	return (maxv / d - (minv - 1) / d);
	// return ((maxv - minv + 1) / d);
}

void Main()
{
	ll c, d;
	cin >> minv >> maxv >> c >> d;
	// for (ll i = 1; i < 20; i++)
	// 	cout << i << ": " << f(i) << endl;
	cout << (maxv - minv + 1) - (f(c) + f(d) - f(c / __gcd(c, d) * d)) << endl;
	// cout << (maxv - minv + 1) - (f(c) + f(d) - f(lcm(c, d))) << endl;
}
// END

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, m;
ll ans = 1e16;
void work() {
	if (m > 1) for (int i = 1; i < n; i++) {
		ll a = i*m, b = m/2*(n - i), c = n*m - a - b;
		ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
	}
	for (int i = 1; i <= n - 2; i++) {
		ll a =  i*m, b = (n - i)/2*m, c = n*m - a - b;
		ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
	}
}
int main() {
//	freopen("input", "r", stdin);
	cin >> n >> m;
	work();
	std::swap(n, m);
	work();
	cout << ans;
}

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

const int N = (int) 2e6 + 10 ;
const int inf = (int) 2e9 ;

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    long long n , x ; scanf("%lld %lld" , &n , &x ) ;
    long long g = 0 ;
    for( int i = 1 ; i <= n ; i ++ ) {
        long long p ; scanf("%lld" , &p ) ;
        long long d = abs(x - p) ;
        g = __gcd(g , d) ;
    }
    printf("%lld\n" , g) ;
    return 0 ;
}


Measured memory_bytes: 256
a = [int(input()) for i in range(6)]
if a[1]-a[0] > a[5] or a[2]-a[0] > a[5] or a[3]-a[0] > a[5] or a[4]-a[0] > a[5] or a[2]-a[1] > a[5] or a[3]-a[1] > a[5] or a[4]-a[1] > a[5] or a[3]-a[2] > a[5] or a[4]-a[2] > a[5] or a[4]-a[3] > a[5]:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
void solve(){
    int n,m,c; cin>>n>>m>>c;
    vi v(m);
    int ans=0;
    for(int i = 0; i < m; i++) cin>>v[i];
    for(int i = 0; i < n; i++){
        int sum=0;
        for(int j = 0; j < m; j++){
            int t; cin>>t;
            sum+=t*v[j];
        }
        sum+=c;
        if(sum>0) ans++;
    }
    cout<<ans;
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if(k == 1) {
        cout << 0 << endl;
    } else {
        cout << n - k << endl;
    }
}


Measured memory_bytes: 256
# スーパーウルトラ激ムズ200点
# A[i]...A[j]の累積和をB[j]-B[i-1]で表すと題意よりB[j]-B[i-1] = 0の箇所を数える
# よってB[j] = B[i-1]となるi,j(i<j)の組の組み合わせの総数となる
# これは適当に2つ選ぶ組み合わせなのでその数がP個あるならP*(P-1)/2でいける
n = int(input())
arr = list(map(int, input().split()))
d = {0: 1}
b = [0]
for i in range(n):
    b.append(b[i] + arr[i])
    if b[i + 1] in d:
        d[b[i + 1]] += 1
    else:
        d[b[i + 1]] = 1
ans = 0
for _, v in d.items():
    ans += (v * (v - 1)) // 2
print(ans)

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

bool checkMonth(string s){
  int n = stoi(s);
  if (n>=1&&n<=12) return true;
  else return false;
}

int main() {
  string s;
  cin >> s;
  bool a,b;
  a = checkMonth(s.substr(0,2));
  b = checkMonth(s.substr(2,4));
  string ans;
  if (a==true&&b==true) ans = "AMBIGUOUS";
  if (a==true&&b==false) ans = "MMYY";
  if (a==false&&b==true) ans = "YYMM";
  if (a==false&&b==false) ans = "NA";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "queue"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  ll X;
  cin >> X;
  ll sum = 0;

  ll ct = X / 500;
  sum += ct * 1000;
  X -= ct * 500;
  ll ct2 = X / 5;
  sum += ct2 * 5;

  cout << sum << endl;
  return 0;
}


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

int main(){
    int n,p;
    while(cin >> n >> p, n|p){
        int index = 0;
        int perNum[n] = {};
        int inNum = p;
        bool isEmpty = false;
        int ans;
        while(!isEmpty){
            if(inNum){
                inNum--;
                perNum[index]++;
            }else{
                inNum = perNum[index];
                perNum[index] = 0;
            }

            bool turnIsEmpty = true;
            for(int i =0; i < n; i++){
                if(perNum[i]) 
                    turnIsEmpty = false;
            }
            if(turnIsEmpty){
                isEmpty = true;
                ans = index;
            }

            if(index == n-1){
                index = 0;
            }else{
                index++;
            }
        }

        cout << ans << "\n";
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct MaxFlow {
  struct Edge {
    i64 v, c, f;
  };

  i64 n;
  vector<vector<i64>> g;
  vector<Edge> es;

  MaxFlow(i64 n) : n(n), g(n + 1) {}
  void add_edge(i64 u, i64 v, i64 c);
  i64 relax(int s, int t);
  i64 max_flow(int s, int t);
};

void MaxFlow::add_edge(i64 u, i64 v, i64 c) {
  g[u].push_back(es.size());
  es.push_back({ v, c, 0 });
  g[v].push_back(es.size());
  es.push_back({ u, 0, 0 });
}

i64 MaxFlow::relax(int s, int t) {
  queue<i64> q;
  vector<i64> route(n + 1, -1);
  q.push(s);
  route[s] = -2;
  while (!q.empty()) {
    i64 u = q.front();
    q.pop();
    for (i64 ei : g[u]) {
      const Edge& e = es[ei];
      if (route[e.v] == -1 && e.c - e.f > 0) {
        q.push(e.v);
        route[e.v] = ei;
        if (e.v == t) goto found;
      }
    }
  }
  return 0;
found:
  i64 mf = 1ll << 62;
  for (i64 u = t; u != s; ) {
    i64 ei = route[u], rei = ei ^ 1;
    const Edge& e = es[ei], &re = es[rei];
    mf = min(mf, e.c - e.f);
    u = re.v;
  }
  for (i64 u = t; u != s; ) {
    i64 ei = route[u], rei = ei ^ 1;
    Edge& e = es[ei], &re = es[rei];
    e.f += mf;
    re.f -= mf;
    u = re.v;
  }
  return mf;
}

i64 MaxFlow::max_flow(int s, int t) {
  i64 f = 0;
  while (true) {
    i64 x = relax(s, t);
    if (x == 0) break;
    f += x;
  }
  return f;
}

int h, w;
vector<string> a;
int main() {
  cin >> h >> w;
  read_n(a, h);

  MaxFlow mf(h + w + 2);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int u = 2 + i, v = 2 + h + j;
      if (a[i][j] == 'o') {
        mf.add_edge(u, v, 1);
        mf.add_edge(v, u, 1);
      }
      if (a[i][j] == 'S') {
        mf.add_edge(0, u, 1000000);
        mf.add_edge(0, v, 1000000);
      }
      if (a[i][j] == 'T') {
        mf.add_edge(u, 1, 1000000);
        mf.add_edge(v, 1, 1000000);
      }
    }
  }
  i64 ans = mf.max_flow(0, 1);
  if (ans >= 1000000) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2220
#import<stdio.h>
#import<queue>
int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(i=0;i++<h;f[i*22]=f[i*22-~w]=-1,getchar())for(j=0;j++<w;z-35?z>65?b=x:z>64?a=x:1:--f[x])f[j]=f[j-~h*22]=-1,f[x=i*22+j]=-2,z=getchar();f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-2)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;!z&!a&!p[i]&b==x&f[b]<0&&--a){x=b;for(z=i=0;!a&&p[i];f[b]>=0&&++z)++t,~f[j=b-54+"L65676 "[p[i++]-50]]?b=j:0,f[b]>=0&t>=f[b]?a=b:0;}printf(~a?"%d %d %d\n":"impossible\n",t,a/22-1,a%22-1);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int64_t N, K;
    cin >> N >> K;
    int64_t k = 1, count = 0;
    while(N >= k){
        k *= K;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256