akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_123
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            long n = ReadLong();
            long[] transport = new long[5];
            for(int i = 0; i < 5; i++)
            {
                transport[i] = ReadLong();
            }
            long time = 0;
            for(int i = 0; i < 5; i++)
            {
                long remain = n - (time - i) * transport[i];
                if (remain <= 0) time++;
                else
                {
                    time += remain / transport[i];
                    if (n % transport[i] > 0) time++;
                }
            }
            WriteLine(time);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
int main(){
ll n,r;
  cin>>n>>r;
  if(n>=10){
    cout<<r;
  }
  else{
    cout<<r+100*(10-n);
  }
  return 0;
 
}
 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(char a, char b) {
	return a > b;
}

int kuraiwa(int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

bool kaibun(int n) {
	int a[5];
	for (int i = 0;i < 5;i++) {
		a[i] = n % 10;
		n /= 10;
	}
	if (a[0] == a[4] && a[1] == a[3]) {
		return true;
	}
	else {
		return false;
	}
}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(){
    string s;
    int Zindex=0, Aindex=0;

    cin >> s;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'A'){
            Aindex = i;
            break;
        }
    }
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'Z'){
            Zindex = max(i, Zindex); 
        }
    }

    cout << Zindex - Aindex +1 << endl;
}

Measured memory_bytes: 832
import sys
input = sys.stdin.readline

n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
a.sort(reverse=True)
# 1-indexed
cumsum = [0] * (n + 1)
for i in range(n):
    cumsum[i+1] = cumsum[i] + a[i]
coef = [0] * (n + 1)
for i in range(n + 1):
    coef[i] = (2 + i) ** 2 - (1 + i) ** 2
coef[0] += 2

ans = 10**18
for trip in range(1, n+1):
    collected = 0
    to_take = (n + trip - 1) // trip
    score = k * trip + k * n
    for i in range(to_take):
        val = cumsum[min((i+1) * trip, n)] - cumsum[i * trip]
        score += val * coef[i]
    ans = min(ans, score)
print(ans)

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

int n;

int main(void){
  // Here your code !
  scanf("%d", &n);

  if (1000 <= n && n <= 1998) {
    printf("ABD\n");
  }
  else {
    printf("ABC\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

static
void printfRep(int *array, int num)
{
  int i;
  for (i = 0; i < num; i++)
    printf(" %d", array[i]);

    printf("\n");
}

static
void printfSP(void)
{
  int i;
  for (i = 0; i < 20; i++) 
    printf("#");

  printf("\n");
}

int main(int argc, char *argv[])
{
  int i, j, num;
  int cells[4][3][10] = {0};

  scanf("%d", &num);

  for (i = 0; i < num; i++) {
    int b, f, r, v;
    scanf("%d %d %d %d", &b, &f, &r, &v);

    cells[b - 1][f - 1][r - 1] += v;
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++)
      printfRep(cells[i][j], 10);
    
    if (i != 3)
      printfSP();
  }

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	string items[101];
	int p[101];
	int n,m,i,j,k,l;
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		for(i=0;i<n;i++)
		{
			cin >> items[i] >> p[i] ;
		}
		
		cin >> m ;
		for(i=0;i<m;i++)
		{
			int s_p=0;
			string item,s_item;
			int nm;
			cin >> item >> nm ;
			for(k=0;k<n;k++)
			{
				if(items[k]==item)
					break;
			}
			for(j=0;j<nm;j++)
			{
				cin >> s_item;
				for(l=0;l<n;l++)
				{
					if(s_item==items[l])
					{
						s_p+=p[l];
						break;
					}
				}
			}
			p[k]=min(p[k],s_p);
		}
		string last;
		cin >> last;
		for(i=0;i<n;i++)
		{
			if(items[i]==last)
			{
				cout << p[i] << endl;
				break;
			}
		}
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string O, E;
  cin >> O >> E;
  for(int i = 0; i < E.size(); i++) {
    cout << O[i] << E[i];
  }

  if(O.size() != E.size()) { cout << O[O.size() - 1]; }
  cout << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++){
    cin >> W.at(i);
  }
  vector<int> diff(N);
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (j < i + 1){
        diff.at(i) -= W.at(j);
      }
      else{
        diff.at(i) += W.at(j);
      }
    }
    if (diff.at(i) < 0){
      diff.at(i) = diff.at(i) * -1;
    }
  }
  sort(diff.begin(), diff.end());
  cout << diff.at(0) << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
dp = [[0, 0, 0] for _ in range(n+1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][j] = max(dp[i+1][j], dp[i][k]+a[i][j])
print(max(dp[n]))

Measured memory_bytes: 76248
#pragma once
#include <vector>

class disjoint_set {
public:
	disjoint_set(int n) : data(n, -1)
	{}

	bool unite(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y) {
			return false;
		}
		if (data[y] < data[x]) {
			std::swap(x, y);
		}
		data[x] += data[y];
		data[y] = x;
		return true;
	}

	bool same(int x, int y)
	{
		return root(x) == root(y);
	}

	int root(int x)
	{
		if (data[x] < 0) {
			return x;
		}
		data[x] = root(data[x]);
		return data[x];
	}

	int size(int x) {
		return -data[root(x)];
	}

private:
	std::vector<int> data;
};


#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	disjoint_set ds(N);
	for (int i = 0; i < M; ++i) {
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		ds.unite(A, B);
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans = max(ans, ds.size(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 4044
//#define TEST

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	/* 入力の受け取り */
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i], a[i]--;

	/* inv[i] : a[j] == iなるj */
	vector<int> inv(N);
	for (int j = 0; j < N; j++) inv[a[j]] = j;

	/* i = 0,1,2,...について、iがminになる区間が何個あるか */
	vector<ll> count(N);
	set<int> st{ -1,N }; // i未満のindexを格納しておく
	for (int i = 0; i < N; i++) {
		int ind = inv[i];
		auto it = st.lower_bound(ind);
		int r = *it;
		int l = *(--it);
#ifdef TEST
		cout << i + 1 << " : " << l << " " << r;
#endif
		st.insert(ind);
		count[i] = (r - (ll)ind) * (ind - l);
#ifdef TEST
		cout << " " << count[i] << endl;
#endif
	}

	/* 答えの計算 */
	ll ans = 0;
	for (ll i = 0; i < N; i++) {
		ans += (i + 1) * count[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h,w;
  cin >> h >> w;
  if(h==1 || w==1){
    cout << 1 << endl;
  }
  else if(h*w%2==0){
    cout << h*w/2 << endl;
  }
  else{
    cout << h*w/2+1 << endl;
  }
}


Measured memory_bytes: 3572
#include<stdio.h>
#include<stdlib.h>
 
int top,S[10000];
 
void push(int x){
  S[++top]=x;
}
 
int pop(){
 return S[top--];
}
 
int main(){
  int a,b;
  char s[50];
  top=0;
   
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      b=pop();
      a=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      b=pop();
      a=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(1e5 + 10); const long long INF(1e16);
template <typename T> inline void chkmin(T &x, const T &y) { if (x > y) x = y; }
int n, m, id[N], rnk[N], fa[N];
long long f[N], sum[N], a[N], b[N], c[N];
std::vector<int> G[N], T[N];
int cmp(int x, int y) { return c[x] < c[y]; }
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void dfs(int x)
{
	sum[x] = b[x], f[x] = INF;
	if (T[x].empty()) return (void) (f[x] = b[x] + c[x]);
	for (auto i : T[x]) dfs(i), sum[x] += sum[i];
	for (auto i : T[x]) chkmin(f[x], sum[x] - sum[i] + std::max(c[x], f[i]));
}

int main()
{
	n = read(), m = read();
	for (int i = 1; i <= n; i++) fa[i] = id[i] = i;
	for (int i = 1; i <= n; i++)
		a[i] = read(), b[i] = read(), c[i] = std::max(a[i] - b[i], 0ll);
	for (int i = 1, x, y; i <= m; i++)
		x = read(), y = read(), G[x].push_back(y), G[y].push_back(x);
	std::sort(id + 1, id + n + 1, cmp);
	for (int i = 1; i <= n; i++) rnk[id[i]] = i;
	for (int i = 1, t; i <= n; i++) for (auto j : G[id[i]])
		if ((t = find(j)) != id[i] && rnk[j] < i)
			fa[t] = id[i], T[id[i]].push_back(t);
	dfs(id[n]); printf("%lld\n", f[id[n]]);
	return 0;
}


Measured memory_bytes: 20092
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
string en = "abcdefghijklmnopqrstuvwxyz";
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int ans = 0;
  FOR(i,0,3) ans += s[i] == '1';
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<vector<bool>> e(n, vector<bool>(n));
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		e[u][v] = true;
		e[v][u] = true;
	}
	int res = 0;
	vector<int> p(n - 1);
	iota(p.begin(), p.end(), 1);
	do {
		int last = 0;
		bool g = true;
		for (int x : p) {
			if (!e[last][x]) {
				g = false;
				break;
			}
			last = x;
		}
		if (g) {
			res++;
		}
	} while (next_permutation(p.begin(), p.end()));
	cout << res << '\n';

	return 0;
}



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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  if (n % 2 == 1) {
    std::cout << 0 << std::endl;
  } else {
    n /= 2;
    int64_t ans = 0;
    int64_t c = 5;

    while (c <= n) {
      ans += n / c;
      c *= 5;
    }
    std::cout << ans << std::endl;
  }
  return 0;
}


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

const int INF = 1<<29;
int dp[400][400]; //dp[i]:=長さiのメロディで得られる最大得点.

int main(){
    int n, m;
    int point[393]={0}, w[393]={0};
    bool can = true;

    cin >> n;
    for(int i=0; i<n; i++){
        int l, r, p;
        cin >> l >> r >> p;
        for(int j=l; j<=r; j++) point[j] = max(point[j], p);
    }

    cin >> m;
    for(int i=0; i<m; i++) cin >> w[i];

    for(int i=0; i<m; i++){ //main loop

        for(int j=1; j<=w[i]; j++){
            for(int k = j; k <= w[i]; k++){
				if(k-j == 0 || dp[i][k-j]  != 0){
					dp[i][k] = max(dp[i][k],dp[i][k-j]+point[j]);
				}
			}
        }
        if(dp[i][w[i]] == 0){
            can = false;
            break;
        }
    }
    if(can){
        for(int i=0; i<m; i++) cout << dp[i][w[i]] << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3704
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=list(S())

  l1=[0]*n
  for i in range(n):
    if l[i]=='E':
      l1[i]+=1

  for i in range(1,n):
    l1[i]+=l1[i-1]

  l2=[]
  for i in range(n):
    l2.append(i+1-l1[i])

  mn=inf
  for i in range(n):
    if l[i]=='W':
      a=l2[i]-1
    else:
      a=l2[i]
    mn=min(mn,l1[-1]-l1[i]+a)

  return mn

print(main())


Measured memory_bytes: 32000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    cout<<n/3<<endl;
}

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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

// --------------------------------------

int n;
vector<int> c, v;

void input()
{
  cin >> n;
  c.resize(n);
  v.resize(n);

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

int calcMaxXY(int nowX, int nowY, int i)
{
  if(i == 0)
  {
    return nowX - nowY;
  }

  return max(
    calcMaxXY(nowX + v[i-1], nowY + c[i-1], i-1),
    calcMaxXY(nowX, nowY, i-1)
  );
}

void solve()
{
  cout << calcMaxXY(0, 0, n);
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int ans = std::numeric_limits<int>::max();
int N, M, X;

void dfs(int item_idx, vector<int> skills, int cost, const vector<int>& C, const vector<vector<int>>& A){
    if(item_idx==N+1){
        int min = *std::min_element(skills.begin(), skills.end());
        if(min>=X){
            ans=std::min(ans, cost);
        }
        return;
    }

    dfs(item_idx+1, skills, cost, C, A);
    REP(i, M){
        skills[i] += A[item_idx-1][i];
    }
    cost+=C[item_idx-1];
    dfs(item_idx+1, skills, cost, C, A);
}

int main(){
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    REP(i,N){
        cin>>C[i];
        REP(j,M){
            cin>>A[i][j];
        }
    }

    dfs(1, vector<int>(M,0), 0, C, A);

    if(ans!=std::numeric_limits<int>::max())
        cout << ans << endl;
    else
        cout<<-1<<endl;

}


Measured memory_bytes: 3612
N=int(input())
A=sorted(map(int,input().split()))

ans=0
dp=[True]*(10**6+1)
for i in range(N):
    if not dp[A[i]]:
        continue
    if i==N-1:
        ans+=1
    elif i<N-1 and A[i+1]!=A[i]:
        ans+=1
    for j in range(1,10**6//A[i]+1):
        dp[A[i]*j]=False
print(ans)

Measured memory_bytes: 96756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N, T; cin >> N >> T;
    vector<ll> a(N);
    for(int i=0; i<N; ++i) cin >> a[i];

    vector<ll> b(N);
    ll minv = a[0], maxv = -1;
    for(int i=1; i<N; ++i){
        b[i] = a[i]-minv;
        minv = min(minv, a[i]);
        maxv = max(maxv, b[i]);
    }

    int ans = 0;
    for(int i=1; i<N; ++i) if(b[i] == maxv) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int n;
vector<vector<int>> e;
vector<bool> used;

vector<int> cur;

void dfs(int v) {
  if (used[v]) return;
  used[v] = true;
  cur.push_back(v);
  for (int u : e[v]) {
    dfs(u);
  }
}

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
  freopen("d.out", "w", stdout);
#endif

  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    e = vector<vector<int>>(n);
    vector<int> cost(n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &cost[i]);
    }
    for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      e[a].push_back(b);
      e[b].push_back(a);
    }

    used = vector<bool>(n);

    ll ans = 0;
    int k = 0;
    vector<int> all;

    for (int i = 0; i < n; i++) {
      if (!used[i]) {
        cur.clear();
        dfs(i);
        sort(cur.begin(), cur.end(), [&cost](int a, int b) { return cost[a] < cost[b]; });
        ans += cost[cur[0]];
        k++;
        for (int j = 1; j < (int)cur.size(); j++) {
          all.push_back(cost[cur[j]]);
        }
      }
    }
    if (k == 1) {
      printf("0\n");
    } else if ((int)all.size() < k - 2) {
      printf("Impossible\n");
    } else {
      sort(all.begin(), all.end());
      for (int i = 0; i < k - 2; i++) {
        ans += all[i];
      }
      printf("%lld\n", ans);
    }
  }

  return 0;
}


Measured memory_bytes: 7292
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 100001
 
typedef struct{
  char mark;
  int num;
  int sta;
} card;
 
int partition(card *,int,int);
void quicksort(card *,int,int);
 
int main(){
  int n,i,flag=0;
  card A[MAX];
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&A[i].mark,&A[i].num);
    A[i].sta=i;
  }
 
  quicksort(A,0,n-1);
 
  for(i=0;i<n;i++){
    if(A[i].num==A[i+1].num){
      if(A[i].sta>A[i+1].sta){
    flag=1;
      }
    }
  }
 
  if(flag==0){
    printf("Stable\n");
  }else{ 
    printf("Not stable\n");
  }
 
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].mark,A[i].num);
  }
 
  return 0;
}
 
int partition(card *A,int p,int r){
  int x,i,j;
  card tmp1,tmp2;
 
  x=A[r].num;
  i=p-1;
 
  for(j=p;j<=r-1;j++){
    if(A[j].num<=x){
      i=i+1;
      tmp1=A[i];
      A[i]=A[j];
      A[j]=tmp1;
    }
  }
 
  tmp2=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp2;
 
  return i+1;
}
 
void quicksort(card *A,int p,int r){
  int q;
   
  if(p<r){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}

Measured memory_bytes: 1780
A = int(input())
B = int(input())

if A == 1 and B == 2:
  print(3)
if A == 2 and B == 1:
  print(3)
if A == 1 and B == 3:
  print(2)
if A == 3 and B == 1:
  print(2)
if A == 2 and B == 3:
  print(1)
if A == 3 and B == 2:
  print(1)


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

typedef pair<int, int> pii; typedef vector<int> vi;
typedef long long ll; typedef vector<long long> vll;
const int MOD = 1'000'000'007, MOD2 = 1'000'000'009;
const int INF = 0x3f3f3f3f; const ll BINF = 0x3f3f3f3f3f3f3f3fLL;

struct DSU {
	int n;
	vector<int> p;
	DSU(int sz) : n(sz), p(sz) {
		iota(p.begin(), p.end(), 0);
	}
	int fi(int x) {return p[x] = p[x] - x ? fi(p[x]) : x;}
	inline void un(int u, int v) {p[fi(u)] = p[fi(v)];}
};

int solve() {
	int n, m; cin >> n >> m;
	vi op(m), x(m), y(m), z(m);
	vector<vector<pii>> g(n);
	for (int i=0;i<m;i++) {
		cin >> op[i];
		if (op[i] == 0) {
			cin >> x[i] >> y[i] >> z[i];
			g[x[i]].emplace_back(y[i], z[i]);
			g[y[i]].emplace_back(x[i], -z[i]);
		} else {
			cin >> x[i] >> y[i];
		}
	}
	vi val(n), vis(n);
	const function<void(int)> dfs = [&g, &val, &vis, &dfs](int u) {
		for (auto p : g[u]) {
			int v = p.first;
			if (!vis[v]) {
				val[v] = val[u] + p.second;
				vis[v] = 1;
				dfs(v);
			}
		}
	};
	for (int i=0;i<n;i++) if (!vis[i]) {
		val[i] = 0;
		dfs(i);
	}
	DSU dsu(n);
	for (int i=0;i<m;i++) {
		int gx = dsu.fi(x[i]), gy = dsu.fi(y[i]);
		if (op[i] == 0) {
			if (gx != gy) dsu.un(gx, gy);
		} else {
			if (gx == gy)
				cout << val[y[i]] - val[x[i]] << endl;
			else
				cout << '?' << endl;
		}
	}
	return 0;
}

int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 18816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,ans=0;cin>>n>>m;
  lvector A(n,0);rep(i,n) cin>>A[i];
  ll num_of_2=0,tmp;
  while(A[0]%2==0) {num_of_2++;A[0]/=2;}
  bool isok=true;
  for(ll i=1;i<n;++i) {
    tmp=0;
    while(A[i]%2==0) {tmp++;A[i]/=2;}
    if(num_of_2!=tmp) {isok=false;break;}
  }
  if(isok) {
    sort(ALL(A));
    ll lcm=A[0];
    for(ll i=1;i<n;++i) lcm=(lcm*A[i])/__gcd(lcm,A[i]);
    rep(i,num_of_2-1) lcm*=2;
    ans+=(m/lcm+1)/2;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,ans=1;
	cin>>x>>y;
	for(int i=2;i<=x&&i<=y;i++){
		age:;
		if(x%i==0&&y%i==0){
			x/=i;y/=i;ans*=i;
			goto age;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3092
#include<stdio.h>
int main()
{
    int r,pie=3.1416,a,b,c;
    scanf("%d",&r);
    if(1<=r && r<=100)
    {
        a=2*pie*r*r;

        b=2*pie*1*1;

        c=a/b;

    printf("%d",c);

    }

    return 0;
}
//UG02-50-19-024

Measured memory_bytes: 128
n = int(input())
s = {}
cnt = 0
for i in range(n):
    ss = input()
    t = []
    
    for j in ss:
        t.append(j)
    # print(t)
    # print(t.sort)
    t = sorted(t)
    # print(t)
    # u = []
    # for q in t:
    #     u.append(q)
    # print(u)
    u = "".join(t)
    # print(u)
    if u in s.keys():
        s[u] += 1
    else:
        s[u] = 1
# print(s)
for i in s.values():
    cnt += i * (i-1) // 2
print(cnt)

Measured memory_bytes: 17892
N = int(input())
s = []
for i in range(N):
  n, t = input().split()
  s.append([n, int(t)])
X = input()
cnt = 0
f = False
for i in range(N):
  if f:
    cnt += s[i][1]
  if s[i][0] == X:
    f = True
print(cnt)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int a, n, i;

    scanf("%d", &n);

    for(i = 1; i <= n; i++)
    {
        a  = i;

        if(a % 3 == 0)
        {
            printf(" %d", i);
        }

        else if(a % 10 == 3)
        {
            printf(" %d", i);
        }

        else
        {
            while(a != 0)
            {
                a /= 10;

                if(a % 10 == 3)
                {
                    printf(" %d", i);
                    break;
                }
            }
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define MAX 10001
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main()
{
  int n;
  double a[MAX];
  while(cin>>n && n){
    double m=0;
    int ans=0;
    FOR(i,0,n){
      cin>>a[i];
      m+=a[i]/n;
    }
    FOR(i,0,n)
      if(m-a[i]>-eps)ans++;
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define MOD 1000000007
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
using namespace std;
typedef vector<int> vi;
typedef list<int> li;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename P> P dectobin(P a){if(a==0)return 0; else return(a%2 + 10*dectobin(a/2));}
template<typename Y> Y bintodec(Y a){int ans=0,b=1,t=a; while (t){int ld=t%10; t/=10;ans+=ld* b;b=b*2;} return ans; }
template<typename H> H modExp(H x, H n){ int r=1; while(n>0){if(n%2==1){r=(r*x)%MOD;}x=(x*x)%MOD;n/=2;}return r;}
template<typename T> T isPowerOfTwo(T x){return x && (!(x & (x - 1)));}	
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
//template<typename T> T extendedEuclid(T A,T B){if(B==0){d=A; x=1;y=0;}else{ extendedEuclid(B,A%B);int temp=x; x=y; y=temp-(A
//B)*y;}}
int32_t main(){
	boost;osit;
	int n,sum=0;
	cin>>n;
	vii v;
	rep(i,0,n){
		int x,y; 
		cin>>x>>y;
		v.pb(mp(y,x));
 	} sort(all(v));
 	rep(i,0,n){
 		sum+=v[i].s;
 		if(sum>v[i].f){
 			cout<<"No";
 			return 0;
 		}
 	} cout<<"Yes";
	return 0;
}

Measured memory_bytes: 6256
#include<stdio.h>

#define MAX_S 10000
#define MAX_T 500


int linearSearch(){
  int i,j,count,k,l;
  int s[MAX_S],t[MAX_T];

  count = 0;
  
  scanf("%d",&k);
  for(i = 0; i < k; i++)
    scanf("%d",&s[i]);
  
  scanf("%d",&l);
  for(i = 0; i < l; i++)
    scanf("%d",&t[i]);

    for(i = 0; i < l; i++)
      for(j = 0; j < k; j++)
	if(t[i] == s[j]){
	  count++;
	  break;
	}
    
  return count;
}

int main(){
  
  printf("%d\n",linearSearch());
  
  return 0;
}



Measured memory_bytes: 2108
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include <vector>

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

using namespace std;

int main(){
	int N;
	long long A[200000],sum[200001] = { 0 }, ans = 0;

	scanf("%d", &N);
	REP(i, N){
		scanf(" %lld", &A[i]);
		sum[i + 1] = sum[i] + A[i];
	}
	sort(sum, sum + N + 1);
	int left = 0;
	REP(i, N){
		if (sum[i] != sum[i + 1]){
			ans += ((long long)i - (long long)left + 1)*((long long)i - (long long)left) / 2;
			left = i + 1;
		}
		else {
			if (i == N - 1){
				ans += ((long long)i + 1 - (long long)left + 1)*((long long)i + 1 - (long long)left) / 2;
			}
		}
	}

	printf("%lld\n", ans);

	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n,m,ans=0;
    cin>>n>>m;
    bool ls[30][30];
    for(int i = 0; i < 30; i++)
    {
        for(int j = 0; j < 30; j++)
        {
            ls[i][j]=false;
        }
        
    }
    
    for(int person = 0; person < n; person++)
    {
        int k;
        cin>>k;
        for(int i = 0; i < k; i++)
        {
            int a;
            cin>>a;
            a--;
            ls[person][a]=true;
        }        
    }
    
    for(int food = 0; food < m; food++)
    {
        bool ok = true;
        for(int person = 0; person < n; person++)
        {
            if(ls[person][food]==false)
            {
                ok=false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  //std::vector<int> v(5);
  int nmax = 0;
  int nmin = 10000;
  int num;
  rep(i,5) {
    cin >> num;
    if (num < nmin) {
      nmin = num;
    }
    if (num > nmax) {
      nmax = num;
    }
  }
  int k; cin>>k;
  cout << ((nmax - nmin) <= k ? "Yay!" : ":(" ) << endl;
}


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

int main(void){
  int x,y;
  cin >> x >> y;
  int res = abs(abs(x) - abs(y));
  if(abs(x) == abs(y)){
    if(x != y)++res;
  }else if(abs(x) < abs(y)){
    if(x < 0)++res;
    if(y < 0)++res;
  }else{
    if(x > 0)++res;
    if(y > 0)++res;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX / 5
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

signed main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>>A(H, vector<char>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> A[i][j];
		}
	}
	vector<vector<int>>dp(H, vector<int>(W));
	rep(i, H) {
		rep(j, W) {
			if (A[i][j] == '#') {
				dp[i][j] = 0;
			}
			else {
				if (i == 0 && j == 0) {
					dp[i][j] = 1;
				}
				else if (i == 0) {
					dp[i][j] = dp[i][j - 1];
				}
				else if (j == 0) {
					dp[i][j] = dp[i - 1][j];
				}
				else {
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				}
			}
			dp[i][j] %= MOD;
		}
	}
	cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 12140
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2E5 + 5;
const int mod = 998244353;
 
int dp[N];
 
void solve(){
 
    int n, k;
    scanf("%lld %lld",&n, &k);
    pair<int, int> p[15];
 
    for(int i = 0;i < k; i++){
        int x, y;
        scanf("%lld %lld",&x, &y);
        p[i] = make_pair(x, y);
    }
 
    dp[1]=1;
 
    for(int i = 2;i <= n; i++){
 
        dp[i] = 0;
 
        for(int j = 0; j < k; j++){
 
            int l = max(1LL, i - p[j].second);
            int r = i - p[j].first;
 
            if(l <= r) {
                dp[i] += dp[r] - dp[l - 1];
                dp[i] %= mod;
                dp[i] += mod;
                dp[i] %= mod;
            }
        }
 
        dp[i] += dp[i - 1];
        dp[i] %= mod; 
    }
 
    printf("%lld\n",((dp[n] - dp[n - 1]) + mod) % mod);
}
 
int32_t main() 
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif 
  ios::sync_with_stdio(0); 
  cin.tie(0); cout.tie(0);
   
  solve();
 
  return 0;
}

Measured memory_bytes: 5344
#include <iostream>
#include <tuple>
#include <queue>
#include <algorithm>
using namespace std;
typedef tuple<int, int, int> tiii;
const int INF = 1 << 29;
int N, M;
int A[101][101];
int a, b, c;
queue<tiii> q;
int main(void) {
	cin >> N >> M;
	fill_n(A[0], 101 * 101, INF);
	for (int i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		--a; --b;
		A[a][b] = A[b][a] = c;
		q.push(tiii(a, b, c));
	}
	for (int k = 0; k < N; ++k) for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
		A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
	}
	int ans = M;
	while (!q.empty()) {
		tie(a, b, c) = q.front(); q.pop();
		if (A[a][b] == c) --ans;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int v(char c) {
    return c - '0';
}

int main() {
    string s;
    while (cin >> s) {
        int sz = s.size();
        while (--sz != 0)
            for (int i = 0; i < sz; i++)
                s[i] = (v(s[i]) + v(s[i + 1])) % 10 + '0';

        cout << s[0] << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  ui N{}, M{}; std::cin >> N >> M;
  int C{}; cin >> C;

  vector<int> B(M);
  rep(0, M) cin >> B[i];

  ui ans{};
  rep_uj(0, N)
  {
    ll res{};
    rep(0, M)
    {
      int tmp{}; cin >> tmp;
      res += tmp * B[i];
    }
    res += C;
    if(res > 0)
      ++ans;
  }

  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: usize,
        s: [Chars;n],
    }

    let mut dic = HashSet::new();

    for i in 0..n {
        dic.insert(&s[i]);
    }

    println!("{}", dic.len());
}


Measured memory_bytes: 27800
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int k, n; cin >> k >> n;
    vector<ll> a(n, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<ll> dist(n, 0);
    for (int i = 1; i < n; i++) {
       dist[i-1] = a[i] - a[i-1];
    }
    dist[n-1] = k - a[n-1] + a[0];

    sort(dist.begin(), dist.end());
    ll sum = 0;
    for (int i = 0; i < n - 1; i++) {
        sum += dist[i];
    }
    cout << sum << endl;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

LL max_prime = 100003;

int main(){
    LL x;

    cin>>x;

    REP2(i,x,max_prime+1){
        bool isPrime = true;
        REP2(j,2,i){
            if(i%j==0){
                isPrime = false;
                break;
            }
        }
        if(!isPrime) continue;
        cout<<i<<endl;
        break;
    }

    return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

vector<int> g[maxn];
int visited[maxn], dist[maxn], pa[maxn];

void bfs(int src) {
    memset(dist, -1, sizeof dist);
    queue<int> q;
    q.push(src);
    visited[src] = true;
    dist[src] = 0;

    while (!q.empty()) {
        int node = q.front();
        q.pop();
        for (auto x : g[node])
            if (!visited[x]) {
                dist[x] = 1 + dist[node];
                q.push(x);
                pa[x] = node;
                visited[x] = true;
            }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;

        g[a].push_back(b);
        g[b].push_back(a);
    }
    bfs(1);
    for (int i = 2; i <= n; i++)
        if (dist[i] == -1) {
            cout << "No";
            return;
        }
    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++)cout << pa[i] << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

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

Measured memory_bytes: 14540
A, B = map(int, input().split())
prA = [1]
count = 1
i = 2
while i*i <= A:
  while A%i == 0:
    A//=i
    prA.append(i)
  i += 1
if A>1:
  prA.append(A)
#prA = prime_decomposition(A)
#prB = prime_decomposition(B)
prA = set(prA)
prB = [1]
i = 2
flag = 0
while i*i <= B:
  while B%i == 0:
    B//=i
    if i in prA and flag == 0:
      count += 1
      prB.append(i)
      flag = 1
  i += 1
  flag = 0
if B>1:
  prB.append(B)
  if B in prA:
    count += 1

print(count)

Measured memory_bytes: 40044
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  int a,b,c; cin >>a>>b>>c;
  if (a==b && b!=c) cout << "Yes" << endl;
  else if (a==c && b!=c) cout << "Yes" << endl;
  else if (b==c && a!=c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
for i in range(1, 100000):
    if (a <= i * 0.08 and i * 0.08 < a + 1) and (b <= i * 0.1 and i * 0.1 < b + 1):
        print(i)
        exit()
    else:
        continue

print(-1)



Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {

	ll A,B;
        in(A);
        in(B);
        outn((3*A+B)/2);

	return 0;
}


Measured memory_bytes: 256