akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define ll long long
using namespace std;


int main(){
  ll n;
  cin>>n;
  ll rest=0;
  ll cnt=0;
  for(int i=0;i<n;i++){
    ll temp;
    cin>>temp;
    if(temp%2==1){
      if(rest==1){
        cnt+=temp/2+1;
        rest=0;
      }else{
        cnt+=temp/2;
        rest=1;
      }
    }else{
      if(temp==0){
        rest=0;
      }else{
        cnt+=temp/2;
      }
    }
  }
  cout<<cnt;
  
}

Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, ll M, std::vector<ll> A) {
  ll sum = 0;
  rep(i, M) { sum += A.at(i); }
  if (sum > N) {
    cout << -1 << endl;
  } else {
    cout << N - sum << endl;
  }
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll M;
  scanf("%lld", &M);
  std::vector<ll> A(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, M, std::move(A));
  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
using namespace std;
long long dp[55][3000][55];

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

    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N*A; j++) {
            for (int k = 0; k <= N; k++) {
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+x[i]][k+1] += dp[i][j][k];
            }
        }
    }
    long long ans = 0;
    for (int k = 1; k <= N; k++) ans += dp[N][A*k][k];
    cout << ans << endl;
}

Measured memory_bytes: 66560
#include <cstdio>

const int maxn = 4010, mod = 1e9 + 7;

int n, ans, f[maxn][maxn], c[maxn << 1][maxn], g[maxn][maxn];

int main() {
	c[0][0] = 1;
	for (int i = 1; i < (maxn << 1); ++i) {
		c[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			if(j >= maxn) {
				break;
			}
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}
	scanf("%d", &n);
	while(n--) {
		int a, b;
		scanf("%d%d", &a, &b);
		++f[2000 - a][2000 - b];
		++g[2000 + a][2000 + b];
		(ans -= c[a + a + b + b][a + a]) %= mod;
	}
	for (int i = 0; i <= 4000; ++i) {
		for (int j = 0; j <= 4000; ++j) {
			if(i) {
				(f[i][j] += f[i - 1][j]) %= mod;
			}
			if(j) {
				(f[i][j] += f[i][j - 1]) %= mod;
			}
		}
	}
	for (int i = 2000; i <= 4000; ++i) {
		for (int j = 2000; j <= 4000; ++j) {
			ans = (1ll * f[i][j] * g[i][j] + ans) % mod;
		}
	}
	ans += ((ans >> 31) & mod);
	if(ans & 1) {
		ans += mod;
	}
	printf("%d\n", ans >> 1);
	return 0;
}

Measured memory_bytes: 220544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

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

int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
 
  double r;
  cin >> r;
  printf("%.10f\n", 2 * PI * r);
  return 0;
}


Measured memory_bytes: 3804
n, l = map(int, input().split())

total = 0
for i in range(n):
    total += l+i

if l <= 0 and l+n-1 >= 0:
    print(total)

elif l+n-1 < 0:
    print(total-l-n+1)

else:
    print(total-l)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  int N,i,max=0,sum=0;
  scanf("%d",&N);
  int L[N];
  for(i=0;i<N;i++){
    scanf("%d",&L[i]);
  }
  max=L[0];
  for(i=1;i<N;i++){
    if(L[i]>max){
      max=L[i];
    }
  }
  for(i=0;i<N;i++){
    sum=sum+L[i];
  }
  sum=sum-max;
  if(max>=sum){
    printf("No");
  }
  else{
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <fstream>
using namespace std;

int main()
{
	string S;
	cin>>S;

	int ans = 0;
	for(int i=0; i<S.size(); i++)
	{
		if(S[i]=='A' || S[i]=='T' || S[i]=='C' ||S[i]=='G')
		{
			int count = 1;
			while(true)
			{
				i++;
				if(S[i]!='A' && S[i]!='T' && S[i]!='C' && S[i]!='G')
				{
					break;
				}
				count++;
			}
			if(count>ans)
			{
				ans = count;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def main(S):
    
    words = ["dream",  "dreamer",  "erase",  "eraser"]

    idx = 0
    while idx <= len(S) - 1:
        f = False
        for word in words:
            if idx != 0 and word == S[-len(word) - idx : -idx]:
                idx += len(word)
                f = True
            elif idx == 0 and word == S[-len(word) - idx : ]:
                idx += len(word)
                f = True             

        if not f:
            return False
    return True
        

if __name__ == "__main__":
    S = input()
    if main(S):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3188
// ------------------------------------
// Date:2018/ 2/18
// Problem:ABC 086 1_21 b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int main()
{
  int a,b,t,d;
  cin >> a >> b;
  d = b;
  t = 0;
  while (d>0) {
    d /= 10;
    ++t;
  }
  REP(i,t) {
    a *= 10;
  }
  a += b;
  REP(i,500) {
    if (i*i>a) break;
    if (i*i == a) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    map<string,intl> mp;
    string s[n];
    cin(i,s);
    cin >> m;
    string t[m];
    cin(i,t);
    rep(i,n)mp[s[i]] = 0;
    rep(i,m)mp[t[i]] = 0;
    rep(i,n){
        mp[s[i]]++;
    }
    rep(i,m){
        mp[t[i]]--;
    }
    intl max = 0;
    for(auto i: mp){
        max = max(max,i.second);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
res = len(t)
for i in range(0, len(s) - len(t) + 1):
    si = s[i:i + len(s)]
    tmp = len(t)
    for i in range(len(t)):
        if si[i] == t[i]:
            tmp -= 1
    res = min(res, tmp)

print(res)


Measured memory_bytes: 9112
from collections import defaultdict

N = int(input())
A = tuple(map(int, input().split()))
dic = defaultdict(int)

for a in A:
  dic[a] += 1
    
Q = int(input())

base = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  tmp = dic[B]
  dic[B] = 0
  dic[C] += tmp
  base += (C-B)*tmp
  print(base)

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef tuple<ll,ll,ll> ti;
typedef vector<ti> vti;
typedef vector<ii> vii;
const ll INF = 1e14;
const double PI = acos(-1.0);
const int T = 1e3 + 2;
vti v;

int main() {
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;

    for(int i = 0; i < n; i++) {
        ll x,y,z; cin >> x >> y >> z;
        v.eb(x,y,z);
    }

    ll ans = 0;

    for(int i = 0; i < 8; i++) {
        sort(v.begin(), v.end(), [&] (const ti &a, const ti &b) {
                ll ax,ay,az;
                ll bx,by,bz;
                tie(ax,ay,az) = a;
                tie(bx,by,bz) = b;
                if(i&1) ax = -ax, bx = -bx;
                if(i&2) ay = -ay, by = -by;
                if(i&4) az = -az, bz = -bz;
                return (ax+ay+az > bx+by+bz);

        });
        ll x = 0, y = 0, z = 0;
        for(int j = 0; j < m; j++) {
            x += get<0>(v[j]);
            y += get<1>(v[j]);
            z += get<2>(v[j]);
        }
        ans = max(ans, abs(x) + abs(y) + abs(z));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def dpcalc():
    global n, w
    dp = [0] * (w + 1)      # 初期値は０　範囲は0〜wまで

    for i in range(n):      # 品物0からn-1までを評価
        wt, vl = map(int, input().split())
        for j in range(w, wt - 1, -1):
            tmp = dp[j - wt] + vl
            if tmp > dp[j]:
                dp[j] = tmp
    return dp[w]


if __name__ == "__main__":
    
    n, w = map(int, input().split())
    print(dpcalc())

Measured memory_bytes: 9772
#include <bits/stdc++.h>
using namespace std;
int stringtoint(string st){
	stringstream ss;
	int x;
	ss<<st;ss>>x;
	return x; 
}
int year,month,day;
int main(){
	string st;
	cin>>st;
	int p=0;
	for(int i=0;i<st.size();i++){
		if(st[i]=='/'){
			if(year==0){
				year=stringtoint(st.substr(p,i-p));
				p=i+1;
			}
			else if(month==0){
				month=stringtoint(st.substr(p,i-p));
				p=i+1;
			}
			else{
				break;
			}
		}
	}
	day=stringtoint(st.substr(p,st.size()-p));
	if(year<=2019&&month<=4&&day<=30){
		cout<<"Heisei";
		return 0;
	}
	cout<<"TBD";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> a[100010];
int ans = 0;
int depth[100010];
void dfs(int u, int p){
	if(a[u].empty()){
		depth[u] = 0;
	} else{
		for(int v : a[u]){
			dfs(v, u);
			depth[u] = max(depth[u], depth[v] + 1);
		}
	}
	if(depth[u] == k - 1){
		if(u == 1) return;
		if(p != 1) ans++;
		depth[u] = -1;
	}
}
int main(){
	// freopen("in.in","r",stdin);
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		if(i == 1 && x != 1) ans++;
		if(i > 1){
			a[x].push_back(i);
		}
	}
	dfs(1, 0);
	cout << ans << "\n";
}

Measured memory_bytes: 12288
#include <stdio.h>
int main(void) {
	int H, W, m, n;
	while ((H=!0)||(W!=0))
	{
		scanf("%d%d", &H, &W);
		if (H == 0 || W == 0)
		{
			break; 
		}
		m = n = 1;
		while (m <= H && n <= W)
		{
			if (m != 1 && m != H && n != 1 && n != W) 
			{
				printf("."); n++; continue;
			}
			printf("#");
			if (n == W)
			{
				printf("\n"); n = 1; m++;
			}
			else 
			{ 
				n++; 
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
s = gets.chomp.chars

a = Hash.new(0)

s.each do |ss|
  a[ss] += 1
end

if a.count == 2 && a.to_a[0][1] == 2 && a.to_a[1][1] == 2 
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  int cnt[N];
  fill(cnt, cnt + N, 0);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      A--;
      cnt[A]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (cnt[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
var m = [-1, 2, 3, 5, 7, 11, 13];
function p(n) {
    if (m[n])
        return m[n];

    var found = m.length - 1;
    var foundP = m[found];
    for (var i = foundP + 2;; i += 2) {
        if (isPrime(i)) {
            found++;
            m[found] = i;
            if (found == n)
                return i;
        }
    }
}

function isPrime(num) {
    if (num % 3 == 0) return false;
    var limit = Math.round(Math.sqrt(num));
    var i = 1;
    while(i * 6 - 1 <= limit) {
        if (num % (i * 6 - 1) == 0 || num % (i * 6 + 1) == 0) return false;
        i++;
    }
    return true;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
 
var line;
while (line = lines.shift()) {
    var num = +line;
    if (num == 0)
        break;

    var s = 0;
    for (var i = num; i > 0; i--) {
        s += p(i);
    }
    console.log(s);
}

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//###################################################################
int n,W;
int val[101],w[101];
ll mem[101][100009];
ll solve(int ind,int rm){
    if(rm==0)return 0;
    if(rm<0||ind>=n)return 1000000000000000;
    
    if(mem[ind][rm]!=-1)return mem[ind][rm];
    return mem[ind][rm]=min(solve(ind+1,rm),w[ind]+solve(ind+1,rm-val[ind]));

}

int main(){
    n=D(),W=D();
    for(int i=0;i<n;i++){
        w[i]=D(),val[i]=D();
    }
    ll ans=0;
    memset(mem,-1,sizeof(mem));
    for(int i=0;i<=100009;i++){
        if(solve(0,i)<=W)ans=i;
    }
    cout<<ans;
}


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

const long inf = LLONG_MAX / 3;
void solve()
{
  int N, M;
  cin >> N >> M;

  long ans = inf;
  vector<long> dp(1 << N, inf);
  dp[0] = 0;
  
  vector<int> A(M);
  vector<int> B(M);
  rep(i,M){
    cin >> A[i] >> B[i];
    int z = 0;
    rep(j,B[i]){
      int x;
      cin >> x;
      x--;
      z |= 1 << x;
    }
    vector<long> next(1 << N, inf);
    rep(j, dp.size()){
      if(dp[j]==inf)continue;
      next[j|z]=min(next[j|z],dp[j]+A[i]);
      next[j] = min(next[j],dp[j]); 
    }
    swap(next, dp);
  }

  if(dp[(1<< N)-1] == inf){
    cout << -1 << endl;
  }
  else{
    cout << dp[(1<<N)-1] << endl;
  }
    
  
  
  
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(11);
  solve();
  return 0; 
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n;
  std::cin >> n;
  vi vec;
  int sum = 0;
  REP(i, n) {
    int s = read();
    sum += s;
    if (s % 10)
      vec.PB(s);
  }
  if (sum % 10) {
    print(sum);
    return 0;
  }
  int ans = 0;
  REP(i, vec.size()) { chmax(ans, sum - vec[i]); }
  if (ans % 10)
    print(ans);
  else
    print(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> vec(K);
  vector<vector<int>> trick(K,vector<int>(N));
  for(int i=0;i<K;i++){
    cin>>vec.at(i);
    for(int j=0;j<vec.at(i);j++){
      int a;
      cin>>a;
      trick.at(i).at(a-1)=a;
    }
  }
  int Count=0;
  for(int i=0;i<N;i++){
    int count=0;
    for(int j=0;j<K;j++){
      if(trick.at(j).at(i)!=0){
        break;
      }
      else{
        count++;
      }
    }
    if(count==K){
      Count++;
    }
  }
  cout<<Count<<endl;
}

Measured memory_bytes: 3668
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, sum, last, cnt, ans, a;
string str,ss;
struct Edge { LL to, cost; };
vector<LL>v;
Pll f[8];
char c;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		LL x;
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
	cout << v.size() << endl;
	return 0;
}

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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) cerr<<#a<<"="<<a<<"."
#define d2(a,b) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<"."
#define d3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"."
#define d4(a,b,c,d) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d<<"."
#define da(arr,N) {{rep(i,N){if(arr[i]==INF)cerr<<"INF ";else cerr<<arr[i]<<" ";} cerr<<endl;}}
#define da2(arr,N,M) {rep(i,N){rep(j,M){if(arr[i][j]==INF)cerr<<" INF";else fprintf(stderr," %3d",arr[i][j]);}cerr<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};
//--------------------------------------//
int n[100][100];
int a,b,c;
void solve(){
	rep(i,100) rep(j,100) n[i][j]=max(i,j);
	if(a+b==c||b+c==a||a+c==b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main(){
	cin>>a>>b>>c;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

vector <int> linsieve(int n){
	vector <int> v(n + 1,-1), p;
	for(int i = 2;i <= n;++i){
		if(v[i] == -1){
			v[i] = i;
			p.push_back(i);
		}
		for(int j = 0;j < p.size() and p[j] * i <= n and p[j] <= v[i];++j){
			v[p[j] * i] = p[j];
		}
	}
	return v;
}

void solve(){
	int n;
	cin >> n;
	vector <int> a(n);
	for(int i = 0;i < n;++i) cin >> a[i];
	vector <bool> hash(1e6 + 1,0);
	bool flag1 = 1;
	vector <int> v = linsieve(1e6);
	for(int i = 0;i < n;++i){
		if(a[i] == 1) continue;
		set <int> s;
		int num = a[i];
		while(num > 1){
			if(s.find(v[num]) != s.end()){
				num = num / v[num];
				continue;
			}
			if(hash[v[num]]){
				flag1=0;
				break;
			}
			hash[v[num]] = 1;
			s.insert(v[num]);
			num = num / v[num];
		}
		if(!flag1) break;
	}
	if(flag1){
		cout << "pairwise coprime" << newl;
		return;
	}
	bool flag2 = 0;
	int g = __gcd(a[0],a[1]);
	for(int i = 2;i < n;++i){
		g = __gcd(g,a[i]);
	}
	if(g == 1){
		cout << "setwise coprime" << newl;
	}
	else cout << "not coprime" << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


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

using namespace std;
struct ok
{
    int x, y, z;
};
int main()
{
    //freopen("test.inp","r",stdin);
    int i, n, res;
    ok a[100001] = {0}, b[100001] = {0};
    cin >> n;
    for (i = 1; i <= n; i++) cin >> a[i].x >> a[i].y >> a[i].z;
    for (i = 1; i <= n; i++)
    {
        b[i].x = max(b[i-1].y, b[i-1].z) + a[i].x;
        b[i].y = max(b[i-1].x, b[i-1].z) + a[i].y;
        b[i].z = max(b[i-1].x, b[i-1].y) + a[i].z;
        res = max(b[i].x, max(b[i].y, b[i].z));
    }
    cout << res;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), B(M), C(M);
    REP(i, N) cin >> A[i];
    REP(i, M) cin >> B[i] >> C[i];

    sort(ALL(A));
    vector<pair<ll, ll>> cb;
    REP(i, M) cb.push_back(make_pair(C[i], B[i]));
    sort(ALL(cb));
    reverse(ALL(cb));
    vector<ll> D;
    REPV(iter, cb)
    {
        if (D.size() < N) REP(i, (*iter).second) D.push_back((*iter).first);
        else break;
    }

    REP(i, N) 
    {
        if (A[i] < D[i]) A[i] = D[i];
        else break;
    }
    ll ans = 0;
    REP(i, N) ans += A[i];
    cout << ans << endl;
}


Measured memory_bytes: 7280
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <list>
#include <climits>
#include <bitset>
#include <fstream>
#include <algorithm>
#include <functional>
#include <stack>
#include <string>
#include <cmath>
#define fi first
#define se second
#define re register
#define ls i << 1
#define rs i << 1 | 1
#define pb push_back
#define pii pair<int,int>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
int tt;
inline int rd(){
  int x = 0, f = 1; char ch = getchar();
  while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
  while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}

void out(int a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) out(a / 10);
  putchar(a % 10 + '0');
}

void solve() {
  int n = rd(), d = rd();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = rd(), y = rd();
    if (sqrt(x*x+y*y) <= d) ans++;
  }
  cout << ans << '\n';
}

signed main(){
//  for (tt = rd(); tt--; )
  solve();
  return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
const int N = 10050,P = 1e9 + 7,M = 1000050;
int inv[M],sum1,sum2;
int n,a[N];
bool vis[M],b[M];
int main(){
	int i,j;
	for (inv[0] = inv[1] = 1,i = 2; i <= 1000005; ++i) inv[i] = (LL)(P-P/i) * inv[P%i] % P;
	for (i = 2; i <= 1000000; ++i) if (!vis[i])
	for (j = i+i; j <= 1000000; j += i) vis[j] = 1;
	n = read();
	for (sum1 = 0,i = 1; i <= n; ++i) a[i] = read(),sum1 = (sum1 + inv[a[i]]) % P;
	for (i = 1; i <= n; ++i) b[a[i]] = 1;
	for (i = 1000000; i >= 1; --i) if (!b[i]){
		for (j = i+i; j <= 1000000; j+=i) if (b[j]) {b[i]=1; break;}
	//	printf("%d\n",i);
	}
	
	
	sum2 = 1;
	LL v; int vv;
	for (i = 2; i <= 1000000; ++i) if (!vis[i]){
		vv = 1;
		for (v = 1; v <= 1000000; v *= i) if (b[v]) vv = v;
		sum2 = (LL)sum2 * vv % P;
	}
	cout << (LL)sum1 *sum2 % P << endl;
    return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>
#define maxn 5010
#define LL long long
int d[maxn],a[maxn],zero[maxn];
LL sum[maxn];
int main(){
	int k,q,n,x,m,i,ans,t,z;
	scanf("%d%d",&k,&q);
	for(i=0;i<k;i++)scanf("%d",&d[i]);
	while(q--){
		scanf("%d%d%d",&n,&x,&m);
		x%=m,sum[0]=0,zero[0]=0;
		for(i=0;i<k;i++){
			a[i]=d[i]%m;
			sum[i+1]=sum[i]+a[i];
			zero[i+1]=zero[i]+(a[i]==0);
		}
		z=(n-1)/k*zero[k]+zero[(n-1)%k];
		t=((n-1)/k*sum[k]+sum[(n-1)%k]+x)/m-x/m;
		ans=(n-1)-z-t;
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>  // abs() for integer
 
int main()
{
    long A, V, B, W, T, a_position, b_position;
    std::cin >> A >> V;
    std::cin >> B >> W;
    std::cin >> T;
    if (W >= V) {
        std::cout << "NO";
        return 0;
    }
 
    if (A < B) {
        a_position = A + V * T;
        b_position = B + W * T;
    } else {
        a_position = A - V * T;
        b_position = B - W * T;
    }
    
    if ((A > B && a_position <= b_position) || (A < B && a_position >= b_position)) {
        std::cout << "YES";
    } else {
        std::cout << "NO";
    }
}

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

int main() {
	// your code goes her
	int x;
	cin>>x;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int g=100005;
	int h=0;
	for(int i=-200;i<=200;i++){
		if(!(binary_search(a, a+n, i))){
		if(abs(x-i)<g){
			g=abs(x-i);
			h=i;
		}
		}
		//g=min(abs(x-i),g);
	}
	cout<<h;
	return 0;
}

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

int main()
{
    vector<int> x(5);
    int res = -1;
    for(int i=0; i<5; i++){
        cin >> x[i];
        if(x[i] == 0) res = i + 1;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void) {
	int n;
	scanf("%d", &n);
	int a;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		sum = sum + a - 1;
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
S = [int(input()) for _ in range(n)]
S.sort()
if sum(S) % 10 != 0:
    print(sum(S))
else:
    for s in S:
        if s % 10 != 0:
            print(sum(S) - s)
            break
    else:
        print(0)


Measured memory_bytes: 3060
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define mn 100005
#define inf 4444444444444444444
#define mod 1000000009
#define FLN "test" 
#define pii pair <int, int>
#define XX first
#define YY second

int n, A[mn];

bool checkAll0()
{
    for (int i=1; i<=n; i++) if (A[i]!=0) return 0;
    return 1;
}

bool checkValid()
{
    int a=A[1], b=A[n/3+1], c=(n/3*2+1);
    for (int i=1; i<=n/3; i++) if (A[i]!=A[1]) return 0;
    for (int i=n/3+1; i<=n/3*2; i++) if (A[i]!=A[n/3+1]) return 0;
    for (int i=n/3*2+1; i<=n; i++) if (A[i]!=A[n/3*2+1]) return 0;
    return 1;
}

signed main()
{
#ifdef lowie
    freopen(FLN".inp", "r", stdin);
    freopen(FLN".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for (int i=1; i<=n; i++) cin>>A[i];
    if (n%3!=0)
    {
        if (checkAll0()) cout<<"Yes";
        else cout<<"No";
    }
    else
    {
        sort(A+1, A+n+1);
        int a=A[1], b=A[n/3+1], c=A[n/3*2+1];
        if(!checkValid()) 
        {
            cout<<"No";
            return 0;
        }

        if ((a^c)==b) cout<<"Yes";
        else cout<<"No";
    }
    
}

// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Code by low_
// Contact me via mail: dung.totuan01@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie_review/

Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int N = 1e5+5;
vector<int>edge[N];
int h[N];
int main() {
	FIO;
	int n,m;cin>>n>>m;
    _for(i,1,n+1)cin>>h[i];
    _for(i,0,m){
        int x,y;cin>>x>>y;
        edge[x].PB(y),edge[y].PB(x);
    }
    int ans = 0;
    _for(i,1,n+1){
        int flag = 1;
        _sfor(it,edge[i]){
            if(h[it]>=h[i]){
                flag = 0;
                break;
            }
        }
        if(flag)++ans;
    }
    cout<<ans;
	return 0;
}



Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e6;
int inf=1e9+7;
int main()
{	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;cin>>s;
	ll ans=0;ll cur=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'){
			cur++;
		}else{
			ans+=cur;
		}
	}
	cout<<ans<<ln;	
}

Measured memory_bytes: 720
(defun low-elements (n p)
  (let ((ans 0) 
        (min n) 
        (buff)) 
    (dotimes (i n) 
      (setf buff (pop p)) 
      (when (<= buff  min)
        (setf min buff)
        (incf ans))) 
    ans)) 


(defun create-data () 
  (let ((n (read)) 
        (p)) 
    (dotimes (i n) 
      (push (read) p)) 
    (values n (reverse p))))

(multiple-value-bind (n p) (create-data) 
  (format t "~D~%" (low-elements n p))) 


Measured memory_bytes: 59752
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
int main(){
	string table[10] = {
		" ",
		"',.!?",
		"abcABC",
		"defDEF",
		"ghiGHI",
		"jklJKL",
		"mnoMNO",
		"pqrsPQRS",
		"tuvTUV",
		"wxyzWXYZ"
	};
	string str;
	while(cin >> str){
		str += "E";
		string ret = "";
		char nowchar = 'S';
		int count = -1;
		for(int i=0;i<str.length();i++){
			if(str[i] != nowchar){
				if(nowchar != 'S' && nowchar != '0'){
					ret += table[nowchar-'0'][count%table[nowchar-'0'].length()];
				}
				nowchar = str[i];
				count = 0;
			}else{
				if(nowchar == '0'){
					ret += ' ';
				}
				count++;
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

    int N;
    string S;

    cin >> N >> S;

    int i;
    int count = 0;
    for(i=0; i<N-2; i++){
        
        if(S.substr(i, 3) == "ABC") count++;
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    string A[N], B[M];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N - M + 1; i++) {
        for (int j = 0; j < N - M + 1; j++) {
            int idx = i;
            string subStr;
            do {
                if (idx - i >= M) {
                    cout << "Yes" << endl;
                    return 0;
                }
                subStr = A[idx].substr(j, M);
                idx++;
            } while (subStr == B[idx - i - 1]);
        }
    }
    cout << "No" << endl;
    return 0;
}

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

bool cmp(int a,int b){
	return a>b;
}

int main(){
	int n,k,i,s=0,x;
	
	cin>>n>>k;
	
	int a[200000+5]={0};
	
	for(i=1;i<=n;i++){
		cin>>x;
		
		a[x]++;
	}
	
	sort(a+1,a+200000+1,cmp);
	
	for(i=k+1;i<=200000;i++){
		s+=a[i];
	}
	
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
/************************************************************
	> File Name: b.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Mon 09 Dec 2019 06:03:34 PM CST
************************************************************/

#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
char ch[MAXN];
int main(void){
	while(~scanf("%s",ch)){
		int len = strlen(ch);
		int ans = 0;
		for(int i = 0,j = len-1;i < j;i++,j--)
			if(ch[i]!=ch[j])
				ans++;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  map<int, int> M;
  for (auto &a : A) {
    M[a] += 1;
  }

  int cnt = 0;
  for (auto &m : M) {
    if (m.first < m.second) {
      cnt += m.second - m.first;
    } else if (m.first > m.second) {
      cnt += m.second;
    }
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 7712
#include<stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int x = 0;
    if (a + b == c)
        x++;
    if (a + c == b)
        x++;
    if (b + c == a)
        x++;
    if (x > 0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

    class Program
    {
        static void Main()
        {
            decimal[] input = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            decimal X = Math.Ceiling((input[2] - input[1]) / input[1]);
            decimal Y = Math.Ceiling(input[0] / input[3]);

            Console.WriteLine(X<Y? "Yes":"No");
        }
    }

Measured memory_bytes: 28200
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
	int N;
	cin>>N;
	int A[N+1],B[N+1];
	int i,j;
	A[0] = 0;
	B[0] = 0;
	for(i=1;i<=N;i++){
		cin>>A[i];
	}
	for(i=1;i<=N;i++){
		cin>>B[i];
		}
	int ame[N+1];
	rep(i,N+1) ame[i] = 0;
	for(i=1;i<=N;i++){
		for(j=1;j<=N;j++){
			if(i<j){
				ame[j] += A[i];
			}
			else if(i == j){
				ame[j] += A[i]+B[i];
			}
			else{
				ame[j] += B[i];
			}
		}
	}
	int amemax;
	amemax = 0;
	for(i=1;i<=N;i++){
		if(amemax<ame[i]){
			amemax = ame[i];
		}
	}
	cout<<amemax<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
    int X;
    cin >> X;
    if (X == 7 || X == 5 || X == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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



int main() {
    int n;
    cin>>n;
    int height[n];
    for (int i=0;i<n;i++) cin>>height[i];
    int sum = 0;
    int max = 0;
    int j = 0;
    while(j<n){
        if (height[j]>=max) {
            max = height[j];
            sum ++;
        }
        j++;
    }
    cout<<sum<<endl;
}


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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;

int p[MAXN], n, p1[MAXN];
int bio[MAXN];

int main() {
  scanf("%d",&n);
  REP(i, n) scanf("%d",&p[i]);
  REP(i, n) {
    scanf("%d",&p1[i]);
    p[i] -= p1[i];
  }
  vector <pii> poz;
  vector <int> neg;
  REP(i, n) {
    if (p[i] > 0) poz.push_back({p[i], i});
    else if (p[i] < 0) neg.push_back(p[i]);
  }

  sort(all(poz));
  sort(all(neg));
  reverse(all(neg));
  int sol = (int)neg.size();
  while (!neg.empty() && !poz.empty()) {
    int a = poz.back().fi;
    int b = neg.back();
    if (a >= -b) {
      bio[poz.back().sec]++;
      poz.back().fi += b;
      neg.pop_back();
    }
    else {
      neg.back() += a;
      bio[poz.back().sec]++;
      poz.pop_back();
    }
    if (a == 0) poz.pop_back();
    if (b == 0) neg.pop_back();
  }

  REP(i, n) if (bio[i]) sol++;
  if (!neg.empty()) {
    puts("-1");
  }
  else printf("%d\n",sol);
  return 0;
}



Measured memory_bytes: 2296
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,b,u,x[101],h[101],y[101],H;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d%d",&x[i],&y[i],&h[i]); 
        if(h[i]!=0)u=i;
    }
    for(int xi=0;xi<=100;++xi)
      for(int yi=0;yi<=100;++yi)
        {
            H=h[u]+abs(x[u]-xi)+abs(y[u]-yi);
            for(int i=1;i<=n;++i)
            {
                if(h[i]!=max(H-abs(x[i]-xi)-abs(y[i]-yi),0)) break;
                if(i==n)
                {
                    printf("%d %d %d\n",xi,yi,H);
                    return 0;
                }
            }
        }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,t,a,b,n,c,d,y,temp,m,r,sum,count,k,l,ans;
    t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n>>k;
        long arr[n],brr[n];
        memset(brr,0,sizeof(brr));
        for(i=0;i<n;i++)
        {
            cin>>arr[i];
            brr[arr[i]]++;
        }
        sort(brr,brr+n);
        reverse(brr,brr+n);
        ans=0;
        for(i=0;i<k;i++)
        ans+=brr[i];
        cout<<n-ans;
        
    }
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
int main()
{
    char s[100005];
    scanf("%s", s);
    int n = strlen(s);
    int i;
    for(i=0;i<n-1;i++)
        if (s[i] == s[i + 1])
        {
            printf("%d %d\n", i + 1, i + 2);
            return 0;
        }
    for(i=0;i<n-2;i++)
        if (s[i] == s[i + 2])
        {
            printf("%d %d\n", i + 1, i + 3);
            return 0;
        }
    printf("-1 -1\n");
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int h,w;
    cin>>h>>w;
    string arr[h+2];
    string s;
    arr[0]="";
    for (int i=0;i<w+2;i++){
        arr[0]+='.';
    }arr[h+1]="";
    for (int i=0;i<w+2;i++){
        arr[h+1]+='.';
    }
    for (int i=0;i<h;i++){
        cin>>s;
        arr[i+1]="."+s+".";
    }int x;
    for (int i=1;i<=h;i++){
        for (int j=1;j<=w;j++){
            x=0;
            if (arr[i][j]=='.'){
                if (arr[i-1][j-1]=='#')x++;
                if (arr[i-1][j]=='#')x++;
                if (arr[i-1][j+1]=='#')x++;
                if (arr[i][j-1]=='#')x++;
                if (arr[i][j+1]=='#')x++;
                if (arr[i+1][j-1]=='#')x++;
                if (arr[i+1][j]=='#')x++;
                if (arr[i+1][j+1]=='#')x++;
                cout<<x;
            }else cout<<"#";
        }cout<<endl;
    }

    return 0;
}


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

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


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

int main () {
    string s;
    cin >> s;
    int max = 0, min = 999999;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'A' && min > i) {
            min = i;
        }
        if (s.at(i) == 'Z' && max < i) {
            max = i;
        }
    }
    cout << max - min + 1 << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python
# coding: utf-8

# In[24]:


N = int(input())


# In[25]:


ans = 0
if N > 9:
    ans += 9
    if N > 999:
        ans += 900
        if N > 99999:
            ans += 90000
        elif N > 9999:
            ans += N - 9999
    elif N > 99:
        ans += N - 99
else:
    ans = N


# In[26]:


print(ans)


# In[ ]:






Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;
  int len = s.size();
  deque<char> d(len);
  for (int i = 0; i < len; i++) {
    d[i] = s[i];
  }

  ll ans = 0;
  while (!d.empty()) {
    char f = d.front();
    char b = d.back();

    if (f == b) {
      d.pop_front();
      if (!d.empty()) {
        d.pop_back();
      }
    } else {
      if (f == 'x') {
        d.pop_front();
        ans++;
      } else if (b == 'x') {
        d.pop_back();
        ans++;
      } else {
        ans = -1;
        break;
      }
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 512
n=int(input())
A=list(map(int,input().split()))
flag=1
count=0
while flag==1:
    flag=0
    for i in range(n-1,0,-1):
        if A[i]<A[i-1]:
            A[i],A[i-1]=A[i-1],A[i]
            flag=1
            count+=1
for i in range(n-1):
    print(A[i],end=" ")
print(A[n-1])
print(count)


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

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


Measured memory_bytes: 256
#include<cstdio>//输入输出要用的文件。 
#include<cmath>//sqrt要用的文件。 
using namespace std;
long long n,ans;//10的10次方超int。 
int s;
int main(){
    scanf("%lld",&n);//long long的scanf要用lld。 
    for(int i=sqrt(n);i>0;--i) //从平方根开始搜索，用n除以搜到的第一个数，计算出它的位数就是答案。 
        if(n%i==0){
            ans=n/i;
            break;
        }
    while(ans>0){//计算位数。 
        ++s;
        ans/=10;
    }
    printf("%d\n",s);//s为int型变量。 
    return 0;
}//完美结束。 

Measured memory_bytes: 128
def resolve():
    x, n = map(int, input().split())
    P = []
    while 1:
        try:
            k = map(int, input().split())
            P.extend(k)
        except EOFError:
            break

    if P == []:
        print(x)
        return

    P = set(P)

    diff = 0

    while True:
        if not (x - diff in P):
            print(x - diff)
            return
        if not (x + diff in P):
            print(x + diff)
            return
        diff += 1

resolve()

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)cout<<"No"<<endl;
	else if(a!=b&&b!=c&&a!=c)cout<<"No"<<endl;
	else	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
def CrossPoint(p1,p2,p3,p4):
	(x1,y1),(x2,y2),(x3,y3),(x4,y4)=p1,p2,p3,p4
	a1,b1,c1=y1-y2,x2-x1,x1*y2-x2*y1
	a2,b2,c2=y3-y4,x4-x3,x3*y4-x4*y3
	det=a1*b2-a2*b1
	if abs(det)<eps:return None # parallel
	return ((b1*c2-b2*c1)/det,(a2*c1-a1*c2)/det) # (X,Y)

import sys
eps=sys.float_info.epsilon
input = sys.stdin.buffer.readline
ans=[]
for _ in range(int(input())):
	m=map(int,input().split())
	ans.append("{} {}".format(*CrossPoint(*[(x,y)for x,y in zip(*[iter(m)]*2)])))
print(*ans,sep="\n")



Measured memory_bytes: 5728