akhauriyash/Code-Regression huggingface dataset:
/**
 *  author: mahfuzz
 *  created: 28.03.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string s; cin >> s;
    
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return 0;
}


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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

using namespace std;
#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int h,n; cin>>h>>n;
    int tot=0;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        tot+=x;
    }
    if(tot>=h) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

using namespace std;
#define N 200200

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    int i;
    int ans = 0;
    for (i = 0; i < s.size(); ++i){
        if (s[i] == 'R'){
            ++cnt;
        }
        else{
            ans = max (cnt, ans);
            cnt = 0;
        }
    }
    ans = max (ans, cnt);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdlib.h>


void minkowski(int* x, int* y, int size, int p) {
	double distance = 0;
	for (int i = 0; i < size; i++) {
		distance += pow(abs(x[i] - y[i]), p);
	}
	distance = pow(distance, 1.0 / p);
	std::cout << std::setprecision(5) << std::fixed << distance << "\n";
}

void minkowskiInf(int* x, int* y, int size) {
	double max = abs(x[0] - y[0]);
	double diff; 

	for (int i = 1; i < size; i++) {
		diff = static_cast<double>(abs(x[i] - y[i]));
		max = (diff > max) ? diff : max;
	}
	std::cout << std::setprecision(5) << std::fixed << max << "\n";
}

int main()
{
	int size;
	std::cin >> size;
	int* x = new int[size];
	int* y = new int[size];
	for (int i = 0; i < size; i++) {
		std::cin >> x[i];
	}
	for (int i = 0; i < size; i++) {
		std::cin >> y[i];
	}


	minkowski(x, y, size, 1);
	minkowski(x, y, size, 2);
	minkowski(x, y, size, 3);
	minkowskiInf(x, y, size);
    return 0;
}




Measured memory_bytes: 3468
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	//printf("%c%c%c\n", a[0]+'A'-'a',b[0]+'A'-'a',c[0]+'A'-'a');
	cout << (a+b)*h/2 << endl;
	//printf((a == 'a' || a == 'i' || a == 'u'||a=='e'||a=='o') ? "vowel\n" : "consonant\n");
}

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

long long largeValue = 10e6;

int main(){
    int N,M;
    cin >>N>>M;
    vector<int> X(M);
    for(int i=0;i<M;i++){
        int x;
        cin >>x;
        X[i] = x;
    }
    if(N>=M){
        cout << 0<<endl;
        return 0;
    }
    sort(X.begin(),X.end());
    vector<long long> distance(M);
    long long ans = 0;
    for(int i=0;i<M;i++){
        if(i==0){
            distance[i] = largeValue;
        }
        else{
            distance[i] = X[i] -X[i-1];
        }
        
        ans += distance[i];

        
    }
    cerr << ans << endl;
    sort(distance.rbegin(),distance.rend());
    for(int i=0;i<N;i++){
        ans -=distance[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(ALL(A), greater<ll>());

    ll l1 = 0;
    ll l2 = 0;
    ll step = 1;
    for (ll i = 0; i < N; i += step) {
        step = 1;
        if (A[i] == A[i + 1]) {
            if (l1 == 0) {
                l1 = A[i];
                step = 2;
            } else if (l1 != 0 && l2 == 0) {
                l2 = A[i];
                step = 2;
            }
        }
    }
    cout << l1 * l2 << endl;

    return 0;
}


Measured memory_bytes: 3936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;


public class Main
{
	public static void main( String[] args ) throws IOException
	{
		Reader.init(System.in);
		int n = Reader.nextInt();
		int k = Reader.nextInt();
		int[] arey = new int[n];
		for ( int i2 = 0 ; i2 < n ; i2++ )
		{
			arey[i2] = Reader.nextInt();
		}
		Arrays.sort(arey);
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		for ( int i = 0 ; i < n ; i++ )
		{
			if ( map.containsKey(arey[i]) )
			{
				map.put(arey[i], map.get(arey[i])+1);
			}
			else
			{
				map.put(arey[i],1);
			}
		}

        Map<Integer, Integer> result2 = new LinkedHashMap<>();
        map.entrySet().stream()
                .sorted(Map.Entry.<Integer, Integer>comparingByValue())
                .forEachOrdered(x -> result2.put(x.getKey(), x.getValue()));

/*        for ( Entry<Integer, Integer> entry : result2.entrySet())
        {
        	Integer key = entry.getKey();
            Integer value = (Integer) entry.getValue();
            System.out.println(key+"  "+value);
        }*/

        int size = result2.size();
        if ( size <= k )
        {
        	System.out.println("0");
        }
        else
        {
        	int actual = size - k;
	        int count = 0;
	        int k2 = 0;
	        for ( Entry<Integer, Integer> entry : result2.entrySet())
	        {
	            Integer value = (Integer) entry.getValue();
	            count = count + value;
	            k2++;
	            if ( k2 == actual )
	            {
	            	break;
	            }
	        }
	        System.out.println(count);
        }
	}
}

/** Class for buffered reading int and double values */
class Reader
{
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input)
    {
        reader = new BufferedReader(new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() )
        {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}

Measured memory_bytes: 56992
#include <stdio.h>
void print_array(int a[], int n){
int i = 0;
    for(i = 0; i<n-1; i++)
        printf("%d ",a[i]);
    printf("%d\n",a[i]);
}

void bubble_sort(int a[], int n){
    int res = 0;
    for(int i = 0; i<n; i++){
        for(int j=n-1; j>=i+1;j--){
            if(a[j] < a[j-1])
            {
                int temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
                res++;
            }
        }
    }
    print_array(a,n);
    printf("%d\n",res);
}
//bubble sort
int main()
{
    int n = 0;
    scanf("%d",&n);
    int a[n+1];
    for(int i = 0; i<n; i++){
        scanf("%d",&a[i]);
    }
    //print_array(a,n);
    bubble_sort(a,n);

    return 0;
}


Measured memory_bytes: 2752
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
constexpr int64_t INF = 100000000010000;
int64_t N;
int64_t a[1001];
int64_t sum[2][1001];
bool used[1001][1002];
int64_t dp[1001][1002];
//[beg,end)
int64_t func(int64_t beg, int64_t end)
{
	if (beg == end) { return -INF; }
	if (used[beg][end]) { return dp[beg][end]; }
	used[beg][end] = true;

	int64_t res = std::max(func(beg + 1, end), func(beg, end - 1));
	if (beg + 1 != end) {
		if ((end - beg) % 2 == 1) {
			res = std::max(res,
				(sum[beg & 1][end - 1] - sum[beg & 1][beg - 1])
			);
		}
	}
	else {
		res = a[beg];
	}
	return dp[beg][end] = res;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int64_t i = 1; i <= N; i++)
	{
		in >> a[i];
	}
	if (std::all_of(a+1, a + N+1, [](int64_t v) {return v <= 0; })) {
		auto iter = std::max_element(a + 1, a + N + 1);
		out << *iter << endl;
		out << N - 1 << endl;
		int32_t num = N;
		auto i = a + 1;
		while (i != iter) {
			out << 1 << '\n';
			++i;
			--num;
		}
		++i;
		while (i != a+N+1) {
			out << num << '\n';
			++i;
			--num;
		}
		return 0;
	}
	for (int64_t i = 1; i <= N; i++)
	{
		sum[i & 1][i] += std::max<int64_t>(0,a[i]);
		sum[0][i] += sum[0][i - 1];
		sum[1][i] += sum[1][i - 1];
	}

	out << func(1, N + 1) << endl;
	std::vector<int64_t> ope;
	int64_t beg = 1, end = N + 1;
	int64_t res = func(1, N + 1);
	for (;;)
	{
		if (res == func(beg + 1, end)) {
			ope.push_back(1);
			++beg;
			continue;
		}
		if (res == func(beg, end - 1)) {
			ope.push_back(end - beg);
			--end;
			continue;
		}
		if (beg + 1 == end) {
			break;
		}
		for (int64_t i = beg + 1; i < end; i += 2)
		{
			if (a[i + 1] >= 0) {
				ope.push_back(2);
			}
			else {
				ope.push_back(3);
			}
		}
		break;
	}
	out << ope.size() << endl;
	for (auto& i : ope)
	{
		out << i << '\n';
	}
	out << std::flush;

	return 0;
}
#endif


Measured memory_bytes: 9216
K = int(input())
x = (K+1) * K//2
num_devisible_three = (3+3*(K//3))*(K//3)//2
num_devisible_five = (5+5*(K//5))*(K//5)//2
num_devisible_fifteen = (15+15*(K//15))*(K//15)//2
print(x-num_devisible_three-num_devisible_five+num_devisible_fifteen)

Measured memory_bytes: 9180
from itertools import permutations
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

# smallで作った数列のチェック
def check_s(res, ngi):
    if res[0] == ngi: return False
    for i in range(len(res) - 1):
        if res[i + 1] == ng[res[i]]:
            return False
    return True

# nが小さいときの全探索用
def small(remain, ngi):
    for res in permutations(remain):
        if check_s(res, ngi): return res
    return [-2]

# 使った数を消しながら最小の数を返す
def delpop():
    while 1:
        i = heappop(hp)
        if not used[i]: return i

# 次の数を選ぶ
def next_i(ngi, cr):
    i = delpop()
    if i == ngi:
        ii = delpop()
        heappush(hp, i)
        i = ii
    ngj = ng[i]
    if used[ngj]: return i
    if indeg[ngj] < cr - 1: return i
    heappush(hp, i)
    return ngj

def main():
    # 頂点iを追加しても、残りの頂点でハミルトンパスが存在するかチェックしながら
    # 残りが4点になるまで小さい順に頂点を選んでいく
    ans = []
    ngi = -1
    cnt_remain = n
    for _ in range(n - 4):
        i = next_i(ngi, cnt_remain)
        ans.append(i)
        used[i] = True
        cnt_remain -= 1
        ngi = ng[i]
        indeg[ngi] -= 1
    # 4点以下の残りについては愚直に探す
    remain = []
    while hp:
        i=heappop(hp)
        if used[i]:continue
        remain.append(i)
    ans += small(remain, ngi)
    ans = [x + 1 for x in ans]
    print(*ans)

n = II()
ng = LI1()
hp = list(range(n))
heapify(hp)
used = [False] * n
indeg = [0] * n
for k in ng: indeg[k] += 1
main()


Measured memory_bytes: 17044
import Data.Functor( (<$>))

main = do
    ls <- takeWhile ("0 0"/=) . lines <$> getContents
    let
	nxs = (read <$>) <$> words <$> ls
	
	pick [n,x] = [ (a,b,c)	| a<-[1..n-2] 
				, b<-[a+1..n-1] 
				, c<-[b+1..n]
				, a+b+c==x	]

    (print . length . pick) `mapM_` nxs



Measured memory_bytes: 4640
#include <stdio.h>

int main(void){

	char str[20];
	int i, j;

	scanf("%s",str);

	for(i=0; i<=20; i++){
		if(str[i] == '\0'){
			break;
		}
	}
	i = i - 1;

	for(j=i; j>=0; j--){
		printf("%c",str[j]);
	}
	printf("\n");
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 4e-4;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    double d;
    cin >> d;
    double res = d * sqrt(2);
    double y = floor(d);
    if (sqrt(1+y*y) >= d) res = max(res, y+1);
    cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 3280
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 205000;

int n;
long long a[MAXN], b[MAXN];
long long aa[MAXN], bb[MAXN];
long long ans = 0;

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &b[i]);
  }

  for (int i = 0; i <= 28; i++) {
    long long p = 1 << i;
    long long mask = p * 2 - 1;
    for (int j = 0; j < n; j++) {
      aa[j] = a[j] & mask;
      bb[j] = b[j] & mask;
    }
    sort(aa, aa + n);
    sort(bb, bb + n);

    long long cur = 0;

    long long from = p, to = p * 2 - 1;
    // cerr << from << " " << to << endl;

    int p1 = 0, p2 = 0;
    for (int j = n - 1; j >= 0; j--) {
      while (p1 + 1 < n && aa[j] + bb[p1] < from) {
        p1++;
      }
      while (p2 + 1 < n && aa[j] + bb[p2 + 1] <= to) {
        p2++;
      }
      // cerr << j << " " << p1 << " " << p2 << endl;
      if (aa[j] + bb[p1] >= from && aa[j] + bb[p2] <= to) {
        cur += p2 - p1 + 1;
      }
    }

    from = p + p * 2; to = p * 4 - 1;
    // cerr << from << " " << to << endl;
    p1 = 0, p2 = 0;
    for (int j = n - 1; j >= 0; j--) {
      while (p1 + 1 < n && aa[j] + bb[p1] < from) {
        p1++;
      }
      while (p2 + 1 < n && aa[j] + bb[p2 + 1] <= to) {
        p2++;
      }
      // cerr << j << " " << p1 << " " << p2 << endl;
      if (aa[j] + bb[p1] >= from && aa[j] + bb[p2] <= to) {
        cur += p2 - p1 + 1;
      }
    }

    // cerr << "Cur " << i << " " << cur << endl;
    if (cur & 1) {
      ans += p;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int m,n,d;
pair<int,int> Free[505][505];

int main()
{
    cin>>m>>n>>d;
    int ii=n,jj=1;
    for(int i=1; i<=m; i++)
    {
        int iii=ii,jjj=jj;
        for(int j=1; j<=n; j++)
        {
            Free[i][j]=make_pair(iii,jjj);
            iii--;
            jjj++;
        }
        ii++;
        jj++;
    }
    for(int i=1; i<=m; i++)
    {
        for(int j=1; j<=n; j++)
        {
            int bi=(Free[i][j].first-1)/d%2,bj=(Free[i][j].second-1)/d%2;
            if(bi==0&&bj==0)
                cout<<'R';
            if(bi==0&&bj==1)
                cout<<'Y';
            if(bi==1&&bj==0)
                cout<<'G';
            if(bi==1&&bj==1)
                cout<<'B';
        }
        cout<<"\n";
    }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ll long long
using namespace std;
double EPS = 1e-9;

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    int n;
    ll c;
    scanf("%d %lld", &n, &c);
    pair<ll, int> sush[n];// dist, nut
    for(int i = 0;i < n;i++){
        scanf("%lld %d", &sush[i].first, &sush[i].second);
    }
    sort(sush, sush+n);
    ll sum_right[n];
    ll max_right[n];
    ll sum_left[n];
    ll max_left[n];
    sum_right[0] = sush[0].second - sush[0].first;
    max_right[0] = sum_right[0];
    for(int i = 1;i < n;i++){
        sum_right[i] = sush[i].second + sum_right[i-1] - (sush[i].first - sush[i-1].first);
        max_right[i] = max(sum_right[i], max_right[i-1]);
    }
    sum_left[n-1] = sush[n-1].second - (c - sush[n-1].first);
    max_left[n-1] = sum_left[n-1];

    for(int i = n-2;i >= 0;i--){
        sum_left[i] = sush[i].second + sum_left[i+1] + (sush[i].first - sush[i+1].first);
        max_left[i] = max(sum_left[i], max_left[i+1]);
    }
    ll res = max(0ll, sum_right[n-1]);
    for(int i = 0;i < n-1;i++){
        res = max(res, sum_right[i] + max(0ll, (max_left[i+1]) - sush[i].first));
    }
    res = max(res, sum_left[0]);
    for(int i = 0;i < n - 1;i++){
        res = max(res, sum_left[n - 1 - i] + max(0ll, (max_right[n-2-i]) - (c - sush[n - 1 - i].first)));
    }
    printf("%lld", res);


    return 0;
}



Measured memory_bytes: 4992
#define lop(i, n) for (int i = n-1; i >= 0; i--)
#define loop(i, x) for (int i = 0; i < x; i++)
#define loopf(i, x, n) for (int i = x; i < n; i++)
#define loopr(i, x, n) for (int i = x - 1; i >= n; i--)
#define ain(arr, n) for (int i = 0; i < n; i++) cin>>arr[i]
#define aout(arr, n) for (int i = 0; i < n; i++) cout<<arr[i]<<" "
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)
#define bit(i) (1<<(i))

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fe first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef complex<int> ci;

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	int x[n], y[n], t[n];
	loop(i, n)
	{
		cin>>t[i]>>x[i]>>y[i];
	}
	int s = 0, e = 0, t0 = 0;
	loop(i, n)
	{
		int tt = abs(x[i] - s) + abs(y[i] - e);
		if (t0 + tt > t[i] || ((t[i] - t0 - tt)%2))
		{
			cout<<"No"<<"\n";
			return 0;
		}
		s = x[i], e = y[i], t0 = t[i];
	}
	cout<<"Yes"<<"\n";
	return 0;
}


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

int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if(a+b<c+d) cout << "Right" << endl;
  else if(a+b>c+d) cout << "Left" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int dp[500][500];

int dpp(int l, int r, std::vector<int>& pre) {
	if (dp[l][r] != -1) return dp[l][r];
	if (l >= r) return 0;
	dp[l][r] = 1e16;
	for (int i = l; i < r; ++i) dp[l][r] = min(dpp(l, i, pre) + dpp(i + 1, r, pre) + pre[r] - pre[l - 1], dp[l][r]);
	return dp[l][r];
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	memset(dp, -1, sizeof(dp));
	vector<int> a(n + 1); for (int o = 0; o < n; o++) { cin >> a[o + 1]; }
	std::vector<int> pre(n + 1, 0);
	for (int i = 1; i <= n; ++i)
		pre[i] = pre[i - 1] + a[i];
	int res = dpp(1, n, pre);
	cout << res;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <limits>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define lli long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define um unordered_map
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define mem(data_structure, val) memset(data_structure, val, sizeof(data_structure))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl "\n"
const ll mod = 1e9+7;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
um<pii, int, hash_pair> map_with_pair{};
priority_queue <int, vector<int>, greater<int> > pq_desc; // decreasing order


int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	lli r;
	cin >> r;
	cout << 3*r*r << endl;
	return 0;
}

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


void solve(long long X, long long Y){
    vector<long long> res;
    long long a, cnt = 1;
    res.push_back(X);
    a = X*2;
    while (a <= Y){
        cnt ++;
        a *= 2;
    }
    cout << cnt << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{

    int a, b;
    int cnt=0;
    cin >> a >> b;


    for(int i=a; i<=b; i++){
        if(i%10!=0){
            if(i/10000 == i%10){
                if((i/1000)%10 == (i%100)/10) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;


}


Measured memory_bytes: 256
from heapq import heappush, heappop
x, y, z, k = map(int, input(). split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
hp = []
heappush(hp, (-(a[0] + b[0] + c[0]), 0, 0, 0))
used = {(0, 0, 0):1}
for _ in range(k):
    ans, d, e, f = heappop(hp)
    print(-ans)
    if(d + 1 < x and not (d + 1, e, f) in used):
        heappush(hp, (-(a[d + 1] + b[e] + c[f]), d + 1, e, f))
        used[(d + 1, e, f)] = 1
    if(e + 1 < y and not (d, e + 1, f) in used):
        heappush(hp, (-(a[d] + b[e + 1] + c[f]), d, e + 1, f))
        used[(d, e + 1, f)] = 1
    if(f + 1 < z and not (d, e, f + 1) in used):
        heappush(hp, (-(a[d] + b[e] + c[f + 1]), d, e, f + 1))
        used[(d, e, f + 1)] = 1

Measured memory_bytes: 4780
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# 0!~n!をmodしつつ求める
def fact_all(n,M=mod):
    f = [1]*(n+1)
    ans = 1
    for i in range(1,n+1):
        ans = (ans*i)%M
        f[i] = ans
    return f

# inv(0!)~inv(n!)をmodしつつ求める
def fact_inv_all(fact_all,M=mod):
    N = len(fact_all)
    finv = [0]*N
    finv[-1] = pow(fact_all[-1],M-2,M)
    for i in range(N-1)[::-1]:
        finv[i] = finv[i+1]*(i+1)%M
    return finv

# nCkをmodしつつ返す
def nCk(n,k,fact_list=[],inv_list=[],M=mod):
    # a!をmodしつつ求める
    def fact(a,M=mod):
        ans = 1
        for i in range(2,a+1):
            ans = (ans*i)%M
        return ans

    # 互いに素なa,bについて、a*x+b*y=1の一つの解[x,y]を出力
    def extgcd(a,b):
        r = [1,0,a]
        w = [0,1,b]
        while w[2] != 1:
            q = r[2]//w[2]
            r2 = w
            w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
            r = r2
            w = w2
        return [w[0],w[1]]

    # aの逆元(mod M)を求める（aとMは互いに素）
    def mod_inv(a,M=mod):
        x = extgcd(a,M)[0]
        return (M+x%M)%M
    
    if fact_list and inv_list:
        return (((fact_list[n]*inv_list[k])%M)*inv_list[n-k])%M
    else:
        x = fact(n,M)
        y1 = mod_inv(fact(k,M),M)
        y2 = mod_inv(fact(n-k,M),M)
        return ((x*y1)%M*y2)%M


def g(r,c):
    retval = 0
    for i in range(r+1):
        retval += nCk(i+c+1,c,fact_list,inv_list)
        retval %= mod
    return retval

r1,c1,r2,c2 = LI()
fact_list = fact_all(r2+c2+1)
inv_list = fact_inv_all(fact_list)

print((g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1))%mod)

Measured memory_bytes: 71920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e1+10;
ll a[N];
int main()
{
    ll n;
    for(int i=0;i<4;i++)cin>>a[i];
    cin>>n;
    for(int i=1;i<4;i++)if(a[i-1]*2<a[i])a[i]=2*a[i-1];
    cout<<(n/2)*a[3]+(n%2)*a[2];
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int[] x = new int[N];
        int[] y = new int[N];
        double sum = 0;
        int x_sum = 0;
        int y_sum = 0;
        for(int i=0;i<N;i++){
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<N-1;i++){
            for(int j=i+1;j<N;j++){
                x_sum = (x[i]-x[j])*(x[i]-x[j]);
                y_sum = (y[i]-y[j])*(y[i]-y[j]);
                sum+=Math.sqrt(x_sum+y_sum);
            }
        }

        System.out.println(sum*2/N);
        System.out.flush();
    }
}

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

int main()
{
	ll N,K;
	cin >> N >> K;
	cout << min(N%K,K-(N%K)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const ll INF = 1e18;

ll intfloor(ll a, ll b){
	if(a < 0) return (a-b+1)/b;
	else return a/b;
}

ll intceil(ll a, ll b){
	if(a > 0) return (a+b-1)/b;
	else return a/b;
}

int main(){
	ll n, k;
	cin >> n >> k;
	vector<int> A(n);
	for(int i = 0; i < n ; i++){
		cin >> A[i];
	}
	sort(all(A));
	ll ok = INF, ng = -INF - 1;
	while(ok - ng > 1){
		ll mid = (ok + ng) / 2;
		ll num = 0;
		for(int i = 0; i < n; i++){
			if(A[i] == 0){
				if(mid >= 0) num += i;
			}
			else if(A[i] > 0){
				num += upper_bound(A.begin(), A.begin() + i, intfloor(mid, A[i])) - A.begin();
			}
			else{
				num += A.begin() + i -lower_bound(A.begin(), A.begin() + i, intceil(-mid, -A[i]));
			}
		}
		if(num >= k) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){

 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++){
    cin>>a[i];
    if(i!=0){
        a[i]=a[i]+a[i-1];
    }
 }
 int m;
 for(int i=0;i<n-1;i++){
   if(i==0){
    m=(abs(a[n-1]-2*a[i]));
   }
   else{
    if(abs(a[n-1]-2*a[i])<m){
        m=(abs(a[n-1]-2*a[i]));
    }
   }
 }
 cout<<m<<endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m;
    for (int i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            if (m / i >= n)
                ans = max(i, ans);
            if (i >= n)
                ans = max(m / i, ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
n = int(input())
a = [int(x) for x in input().split()]

def update(a):
    na = [0] * n
    for i in range(len(a)):
        v = a[i]
        if v % 2 != 0:
            return False
        else:
            na[i] = v / 2
    return na

k = 0
while True:
    a = update(a)
    if not a:
        break
    k += 1
print(k)


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

int main(){
  int N,T,A;
  cin>>N>>T>>A;
  vector<double>Temp(N);
  for(int i=0;i<N;i++){
    double h;
    cin>>h;
    Temp.at(i)=T-h*0.006;

  }

  double min_det=100000;
  double min_ind;

  for(int i=0;i<N;i++){
    if(abs(Temp.at(i)-A)<min_det){
      min_det=abs(Temp.at(i)-A);
      min_ind=i+1;
    }
  }

 cout<<min_ind<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}
int keta(int a) {
	return to_string(a).size();
}
int p[100010];
string s[100010];
bool b[100010];
int t[100010];
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		cin >> p[i] >> s[i];
	}
	rep(i, m) {
		if (s[i] == "AC") {
			b[p[i]] = true;
		}
		if (s[i] == "WA" && b[p[i]] == false) {
			t[p[i]]++;
		}
	}
	int sum = 0,ans=0;
	Rep(i, n) {
		if (b[i]) {
			sum++;
			ans += t[i];
		}
	}
	cout << sum << ' ' << ans << endl;
}


Measured memory_bytes: 7296
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int f = 0;
		int tmp = N;
		while (0 < tmp) {
			f += tmp % 10;
			tmp /= 10;
		}
		if (N % f == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22740
#include<cstdio>
#include<cstring>
#include<cmath>
int main()
{
    char a[102],b[102],str[202];
    int len,sum;
    double c,d;
    while(~scanf("%s %s",a,b))
    {
        strcpy(str,a);
        strcat(str,b);
        len=strlen(str);
        sum=0;
        for(int i=0;i<len;i++)
        {
            sum=sum*10+(str[i]-'0');
        }
        c=sqrt(sum);
        d=(int)c;
        //printf("%d,%lf,%lf",sum,c,d);
        if(c==d)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

var N, M, ans int

func main() {
	fmt.Scan(&N, &M)
	cost := [51][51]int{}
	dp := [51][51]int{}

	for i := 0; i < 51; i++ {
		for j := 0; j < 51; j++ {
			cost[i][j] = 99999999
			dp[i][j] = 99999999
		}
	}
	var a = make([]int, M)
	var b = make([]int, M)
	for i := 0; i < M; i++ {

		fmt.Scan(&a[i])
		fmt.Scan(&b[i])

		cost[a[i]][b[i]] = 1
		cost[b[i]][a[i]] = 1
	}

	// 50以下
	for index := 0; index < M; index++ {

		dp = cost
		dp[a[index]][b[index]] = 99999999
		dp[b[index]][a[index]] = 99999999

		// ワーシャルフロイドで全探索
		for k := 1; k <= N; k++ {
			for i := 1; i <= N; i++ {
				for j := 1; j <= N; j++ {
					dp[i][j] = min(dp[i][k]+dp[k][j], dp[i][j])
				}
			}
		}

		var flag bool = false
		for i := 1; i <= N; i++ {
			for j := i + 1; j <= N; j++ {
				if dp[i][j] == 99999999 {
					flag = true
					break
				}
			}
		}
		if flag == false {
			ans++
		}
	}
	fmt.Println(M - ans)
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}
type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 640
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum1 = sum(B)

for i in range(N-1):
    if (A[i]+1) == A[i+1]:
        sum1 = sum1 + C[A[i]-1]
    else:
        sum1 = sum1
    

print(sum1) 


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
main(){
    int N;
    int num[200000];
    scanf("%d",&N);
    long long sum = 0;
    for(int i = 0;i < N;i++){
        scanf("%d",&num[i]);
        sum += num[i];
    }
    long long min = 100000000000000;
    long long tsum = 0;
    for(int i = 0;i < N-1;i++){
        tsum += num[i];
        long long x = tsum;
        long long y = sum - tsum;
        if(llabs(x-y) < min){
            min = llabs(x-y);
        }
    }
    printf("%d\n",min);
}

Measured memory_bytes: 896
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
diff = [a[i]-b[i] for i in range(n)]
if sum(diff) < 0:
  print(-1)
else:
  diff.sort()
  count = 0
  ans = 0
  for i in diff:
    if i<0:
      count += i
      ans += 1
    else:
      break
  for i in diff[::-1]:
    if count>=0:
      break
    else:
      count += i
      ans += 1
  print(ans)
  

Measured memory_bytes: 24128
import itertools

N, M = map(int, input().split())
K_A = []
A = []
X = []
ans = 0

for _ in range(N):
    K_A.append(list(map(str, input().split())))

for _ in range(N):
    A.append(K_A[_][1:])

A = list(itertools.chain.from_iterable(A))

for m in range(1, M+1):
    count = A.count(str(m))
    if count == N:
        ans += 1

print(ans)

Measured memory_bytes: 3064
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n,m,C; R(n,m);
    R(C);
    VI B(m);
    REP(i,m)R(B[i]);
    int an=0;
    REP(i,n){
        LL v=C;
        REP(j,m){
            int x;R(x);
            v+=x*B[j];
        }
        an+=(v>0);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N=200005;
int a[N],b[N],c[N],d[N];
int n,ans=0;
int pows=1;
int main() {
  scanf("%d",&n);
  for (int i=1;i<=n;++i) scanf("%d",&a[i]);
  for (int i=1;i<=n;++i) scanf("%d",&b[i]);
  for (int i=0;i<=28;++i) {
    for (int j=1;j<=n;++j) {
      c[j]=a[j];
      d[j]=b[j];
      c[j]%=(pows<<1);
      d[j]%=(pows<<1);
    }
    int sum=0;
    sort(c+1,c+1+n);sort(d+1,d+1+n);
    for (int j=1;j<=n;++j) {
      sum+=(lower_bound(d+1,d+1+n,2*pows-c[j])-d)-(lower_bound(d+1,d+1+n,pows-c[j])-d);
      sum+=(lower_bound(d+1,d+1+n,4*pows-c[j])-d)-(lower_bound(d+1,d+1+n,3*pows-c[j])-d);
    }
    if(sum&1) ans|=1<<i;
    pows<<=1;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 6940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	string s;
	cin >> s;
	ll q;
	cin >> q;
	vector<int> t(q);
	bool check = true;

	rep(i, q) {
		cin >> t.at(i);
		if (t.at(i) == 1) {
			if (check == true) {
				check = false;
				continue;
			}
			if (check == false) {
				check = true;
				continue;
			}
		}
		if (t.at(i) == 2) {
			int f;
			string c;
			cin >> f;
			cin >> c;
			if (check) {
				if (f == 1) {
					s.insert(0, c);
				}
				else if (f == 2) {
					s.insert(s.size(), c);
				}
			}
			else {
				if (f == 2) {
					s.insert(0, c);
				}
				else if (f == 1) {
					s.insert(s.size(), c);
				}
			}
		}
	}
	if (check == false) {
		reverse(s.begin(), s.end());
	}

	cout << s << endl;
	

	
	return 0;
}

Measured memory_bytes: 1796
while True :
  a, b = map(int, input().split())
  if(a == b and b == 0) :
    break
  else :
    S = ["A", "B", "C", "D", "E"]
    shop = list()
    shop.append(a + b)
    for i in range(4) :
      a, b = map(int, input().split())
      shop.append(a + b)
    win = max(shop)
    Shop = shop.index(win)
    print(S[Shop], win)
  
  


Measured memory_bytes: 5604
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	long long int a[n]={};
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	std::sort(a,a+n);
	if(n==2){
		printf("%lld %lld",a[1],a[0]);
	}else{
	int m;
	for(int i=0;i<n-1;i++){
		if(a[i]>a[n-1]/2){
			m=i;
			break;
		}
	}
	if(a[m]*2-a[n-1]>a[n-1]-a[m-1]*2){
		printf("%lld %lld",a[n-1],a[m-1]);
	}else{
		printf("%lld %lld",a[n-1],a[m]);
	}}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007;
#define MOD2 998244353;
#define INF ((1<<30)-1);
#define LINF (1LL<<60);
#define EPS (1e-10);
typedef long long Int;
typedef pair<Int, Int> P;

struct Matrix {
    Int val[50][50];
    Matrix() {
        for (int i = 0; i < 50; i++) {
            for (int j = 0; j < 50; j++) {
                val[i][j] = 0;
            }
        }
    }
};

Matrix operator*(Matrix a, Matrix b) {
    Matrix c;
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            for (int k = 0; k < 50; k++) {
                c.val[i][j] += a.val[i][k] * b.val[k][j] % MOD;
                c.val[i][j] %= MOD;
            }
        }
    }
    return c;
}

Matrix E;
Int n, k;
Matrix matrix_power(Matrix a, Int b) {
    if (b == 0) return E;
    Matrix res = matrix_power(a, b/2);
    res = res * res;
    if (b % 2 == 1) res = res * a;
    return res;
}

int main() {
    for (int i = 0; i < 50; i++) E.val[i][i] = 1;
    cin >> n >> k;
    Matrix A;
    rep(i,n) rep(j,n) cin >> A.val[i][j];
    Matrix A_k = matrix_power(A, k);
    Int ans = 0;
    rep(i,n) rep(j,n) {
        ans += A_k.val[i][j];
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    long long b,c;
	cin >> n;
    vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin>>a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  b = 0;
  c = 0;
  for(int i = 0; i < n-1; i++){
    if(a[i]==a[i+1]){
      if(b==0){
        b = a[i];
        ++i;
      }
         else{
        c = a[i];
        break;
      }
     }
    }
  cout << b*c << endl;
}
        
        
  
  

Measured memory_bytes: 1024
n = int(input())
A = list(map(int, input().split()))

flag = True
for i in range(n-1, 0, -1):
    if A[i-1] >= A[i] + 2:
        flag = False
        break
    elif A[i-1] == A[i] + 1:
        A[i-1] -= 1

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
n, k = map(int, input().split())
A = [int(i) for i in input().split()]

ans = 10 ** 5 * n
for i in range(n-k+1):
    l = A[i]
    r = A[i+k-1]
    route1 = abs(l) - l + r
    route2 = abs(r) + r - l
    temp = min(route1, route2)
    ans = min(ans, temp)
    
print(ans)

Measured memory_bytes: 14568