akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

template <std::uint_fast64_t Modulus>
class ModInt {
  using u64 = std::uint_fast64_t;

 public:
  u64 x;

  constexpr ModInt(const u64 x = 0) noexcept : x(x % Modulus){};

  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    x += rhs.x;
    if (x >= Modulus) x -= Modulus;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (x < rhs.x) x += Modulus;
    x -= rhs.x;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    x = x * rhs.x % Modulus;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    u64 n = Modulus - 2;
    while (n) {
      if (n & 1) *this *= rhs;
      rhs *= rhs;
      n /= 2;
    }
    return *this;
  }
  constexpr ModInt operator++(int) noexcept {
    ModInt y = *this;
    x += 1;
    return y;
  }
  constexpr ModInt operator--(int) noexcept {
    ModInt y = *this;
    x -= 1;
    return y;
  }
  constexpr bool operator==(const ModInt rhs) noexcept { return x == rhs.x; }
  constexpr bool operator!=(const ModInt rhs) noexcept { return x != rhs.x; }

  friend std::istream &operator>>(std::istream &is, ModInt &rhs) {
    is >> rhs.x;
    return is;
  }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &rhs) {
    os << rhs.x;
    return os;
  }
};

template <typename T>
class Combination {
 public:
  vector<T> f, invf;

  Combination(int n) : f(n + 1, 1), invf(n + 1, 1) {
    for (int i = 1; i < n + 1; i++) {
      f[i] = f[i - 1] * i;
    }
    invf[n] /= f[n];
    for (int i = n; i > 0; i--) {
      invf[i - 1] = invf[i] * i;
    }
  }

  T fact(int n) const { return f[n]; }
  T inv_fact(int n) const { return invf[n]; }

  // nCr
  T comb(int n, int r) const {
    if (r < 0 || n < r) return 0;
    return f[n] * invf[r] * invf[n - r];
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  // B + i, A + i, min(H - A, W - B)
  using mint = ModInt<1000000007>;
  Combination<mint> comb(H + W);
  mint res = 0;
  for (int i = B; i < W; i++) {
    res += comb.comb(H - A - 1 + i, i) * comb.comb(W - 1 - i + A - 1, A - 1);
  }
  cout << res << '\n';
  return 0;
}


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

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

using psi = pair<string, int>;
using psii = pair<psi, int>;

inline void Main() {
  // code
  int r,d;
  long long x;
  cin>>r>>d>>x;
  rep(i, 10) {
    x = r*x-d;
    cout << x << endl;
  }
}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="SUN")
  cout<<"7";
  else if(s=="MON")
  cout<<"6";
   else if(s=="TUE")
  cout<<"5";
   else if(s=="WED")
  cout<<"4";
   else if(s=="THU")
  cout<<"3";
   else if(s=="FRI")
  cout<<"2";
  else
  cout<<"1";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

struct uf{
  private:
    vi par, rank, size;
  public:
    uf(i64 n){ init(n); }
    void init(i64 n){
      par.resize(n);
      rank.resize(n,0);
      size.resize(n,1);
      rep(i,n) par[i] = i;
    }
    i64 root(i64 x){
      if(par[x] == x) return x;
      return par[x] = root(par[x]);
    }
    bool same(i64 x, i64 y){ return root(x) == root(y); }
    void unite(i64 x, i64 y){
      x = root(x), y = root(y);
      if(x==y) return;
      if(rank[x]==rank[y]) rank[x]++;
      if(rank[x]<rank[y]) swap(x,y);
      par[y] = x;
      size[x] += size[y];
    }
    i64 num(i64 x){ return size[root(x)]; }
};

void Main()
{
  bool direc = true;
  string P;
  string M = "";

  cin >> P;

  i64 Q;
  char q;
  char c;
  cin >> Q;
  rep(i,Q){
    cin >> q;
    if(q=='1') direc = !direc;
    else{
      cin >> q;
      cin >> c;
      if((q=='1')==direc) M += c;
      else P += c;
    }
  }
  string ans = "";
  if(direc){
    rep(i,sz(M)) ans += M[sz(M)-i-1];
    ans += P;
  }else{
    rep(i,sz(P)) ans += P[sz(P)-i-1];
    ans += M;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 1360
import heapq


N = int(input())

P = list(map(int,input().split()))


Llis = []
Rlis = []

for i in range(N):

    Llis.append([N,N])
    Rlis.append([N,N])
    P[i] -= 1


LQ1 = []
LQ2 = []

for i in range(N):

    while len(LQ2) > 0 and LQ2[0][0] < P[i]:
        Llis[LQ2[0][1]][1] = i
        heapq.heappop(LQ2)

    while len(LQ1) > 0 and LQ1[0][0] < P[i]:
        Llis[LQ1[0][1]][0] = i
        heapq.heappush(LQ2,LQ1[0])
        heapq.heappop(LQ1)

    heapq.heappush(LQ1,[P[i],i])

P.reverse()
LQ1 = []
LQ2 = []

for i in range(N):

    while len(LQ2) > 0 and LQ2[0][0] < P[i]:
        Rlis[LQ2[0][1]][1] = i
        heapq.heappop(LQ2)

    while len(LQ1) > 0 and LQ1[0][0] < P[i]:
        Rlis[LQ1[0][1]][0] = i
        heapq.heappush(LQ2,LQ1[0])
        heapq.heappop(LQ1)

    heapq.heappush(LQ1,[P[i],i])





Rlis.reverse()
#print (Llis,Rlis)

ans = 0
P.reverse()

for i in range(N):

    Llenge = Llis[i][1] - Llis[i][0]
    Rlenge = 1 + max(0,i - (N - Rlis[i][0]))

    ans += (P[i]+1) * Llenge * Rlenge
    #print (P[i] , Llenge , Rlenge)

P.reverse()
Rlis.reverse()
Llis.reverse()

for i in range(N):

    Rlenge = Rlis[i][1] - Rlis[i][0]
    Llenge = 1 + max(0,i - (N - Llis[i][0]))

    ans += (P[i]+1) * Llenge * Rlenge
    #print (P[i],Llenge,Rlenge)

print (ans)


    
        


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

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

  vector<ll> v(n);
  REP(i, n) {
    cin >> v[i];
  }

  SORT(v);

  ll ans = 1;
  REP(i, n) {
    ll tmp = v[i];
    if (tmp == 0) {
      ANS(0);
      return 0;
    }

    ll next = 1000000000000000000 / ans;
    if (tmp > next) {
      ANS(-1);
      return 0;
    }
    ans *= tmp;
  }

  ANS(ans);
  return 0;
}


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

const int MAXD = 160*80+1;
bool dp[80][80][MAXD];

int main() {
  int H, W;
  cin >> H >> W;
  int A[H][W], B, ans = 0;
  for (int i=0; i<H; i++)
    for (int j=0; j<W; j++)
      cin >> A[i][j];
  for (int i=0; i<H; i++)
    for (int j=0; j<W; j++) {
      cin >> B;
      A[i][j] = abs(A[i][j]-B);
    }

  dp[0][0][A[0][0]] = true;

  for (int i=1; i<H; i++) {
    int d = A[i][0];
    for (int j=0; j<MAXD; j++) {
      if (!dp[i-1][0][j])
        continue;
      dp[i][0][j+d] = true;
      dp[i][0][abs(j-d)] = true;
    }
  }
  for (int i=1; i<W; i++) {
    int d = A[0][i];
    for (int j=0; j<MAXD; j++) {
      if (!dp[0][i-1][j])
        continue;
      dp[0][i][j+d] = true;
      dp[0][i][abs(j-d)] = true;
    }
  }
  for (int i=1; i<H; i++)
    for (int j=1; j<W; j++) {
    int d = A[i][j];
      for (int k=0; k<MAXD-d; k++) {
        if (!(dp[i-1][j][k] || dp[i][j-1][k]))
          continue;
        dp[i][j][k+d] = true;
        dp[i][j][abs(k-d)] = true;
      }
    }

  while (!dp[H-1][W-1][ans])
    ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 79360
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();

		Set<Long> set = new HashSet<>();
		BigInteger bn = BigInteger.valueOf(n);
		for (long j = 2; j * j <= n; j++) {
			for (int i = 1; i <= 40; i++) {
				BigInteger bj = BigInteger.valueOf(j).pow(i);
				if (bj.compareTo(bn) <= 0) {
					if (bn.mod(bj).compareTo(BigInteger.ZERO) == 0) {
						long t = bn.divide(bj).longValueExact() - 1;
						if (t % j == 0) {
							set.add(j);
							break;
						}
					}
				} else {
					break;
				}
			}
		}
		List<Long> list2 = divList(n - 1);
		set.addAll(list2);
		set.add(n);

		long s = (long) Math.sqrt(n);
		s -= 5;
		List<Long> list3 = divList(n);
		for (long l : list3) {
			if (l >= s) {
				long t = n / l - 1;
				if (t % l == 0) {
					set.add(l);
				}
			}
		}

		set.remove(1L);
		System.out.println(set.size());
	}

	static List<Long> divList(long n) {
		List<Long> list = new ArrayList<>();
		long end = (long) Math.sqrt(n);
		for (int i = 1; i <= end; i++) {
			if (n % i == 0) {
				list.add((long) i);
			}
		}
		int i = end * end == n ? list.size() - 2 : list.size() - 1;
		for ( ; i >= 0; i--) {
			list.add(n / list.get(i));
		}
		return list;
	}
}


Measured memory_bytes: 272280
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
int n;
P a[200005];
ll xma,xmi=1000000000,yma,ymi=1000000000,ans;
int main(void){
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cin>>a[i].F>>a[i].S;
        if(a[i].F>a[i].S)swap(a[i].F,a[i].S);
        xma=max(xma,a[i].F);
        yma=max(yma,a[i].S);
        xmi=min(xmi,a[i].F);
        ymi=min(ymi,a[i].S);
    }
    ans=(xma-xmi)*(yma-ymi);
    sort(a,a+n);
    ll r=yma-xmi,l=1000000000;
    ll ma=0,mi=1000000000;
    ma=max(ma,a[0].S);
    mi=min(mi,a[0].S);
    n--;
    for(int i=0;i<n;i++){
        a[i].S=a[i+1].F;
        a[i].F=a[i+1].S;
    }
    sort(a,a+n,greater<P>());
    ma=max(ma,a[0].S);
    mi=min(mi,a[0].S);
    n--;
    for(int i=0;i<n;i++){
        a[i].S=a[i+1].F;
        a[i].F=a[i+1].S;
    }
    sort(a,a+n);
    l=max(ma,a[n-1].F)-min(mi,a[0].F);
    for(int i=0;i<n;i++){
        mi=min(mi,a[i].S);
        ma=max(ma,a[i].S);
        if(i+1<n)l=min(l,max(ma,a[n-1].F)-min(mi,a[i+1].F));
        else l=min(l,max(ma,a[n-1].F)-mi);
    }
    cout<<min(ans,r*l)<<endl;
}

Measured memory_bytes: 3328
n, k = list(map(int, input().split()))
t = list(map(int, input().split()))

visited = [False]*(2*10**5 + 10)
val = 1
count = 0
hold = k
while hold > 0 :
    if visited[val - 1] or val == t[val - 1]:
        break
    visited[val - 1] = True
    val = t[val - 1]
    # print('a', val)
    count += 1
    hold -= 1
# print(hold)
if hold == 0:
    print(val)
    exit(0)
if val == t[val - 1]:
    print(val)
    exit(0)
count0 = count
count = 1
newval = val
start = t[newval - 1]
while start != newval:
    count += 1
    start = t[start - 1]
# print('count', count, 'count0', count0)
if t[val - 1] == t[0]:
    temp = k
else:
    temp = k - count0
# print('temp', temp)
jump = (temp) % (count)
# print('jump', jump)
# print('val', val)
ans = val
for i in range(jump):
    ans = t[ans - 1]
    # print('b', ans)
print(ans)

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

int main(void){
    string s;
    cin >> s;
    
    int sum = 0;
    int i = 0;
    size_t len = s.length();
    while (i < len && (i + 1) < len) {
        const char before = s[i];
        const char after  = s[i + 1];
        if (before != after) {
            sum += 2;
            len -= 2;
            s.erase(i, 2);
            if (i != 0) {
                i--;
            }
            continue;
        }
        i++;
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    if A * N < B:
        print(A*N)
    else:
        print(B)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


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

namespace arc095_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] y = new int[n];
            for (int i = 0; i < n; i++) y[i] = x[i];
            Array.Sort(x);
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(x[n / 2 - 1] < y[i] ? x[n / 2 - 1] : x[n / 2]);
            }
        }
    }
}

Measured memory_bytes: 37448
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = 0x3f3f3f3f;

int jew[55];
int ans=0;
int n, k;
void ask(int l, int r)
{
    int s=0;
    vector<int> v;
    for(int i=1; i<=l; i++)
    {
        s+=jew[i];
        if(jew[i]<0) v.push_back(jew[i]);
    }
    for(int i=n; i>n-r; i--)
    {
        s+=jew[i];
        if(jew[i]<0) v.push_back(jew[i]);
    }
    sort(v.begin(), v.end());
    for(int i=0; i<k-l-r&&i<v.size(); i++)
    {
        s-=v[i];
    }
    ans=max(ans, s);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    cin >> n >> k;
    for(int i=1; i<=n; i++)
    {
        cin >> jew[i];
    }
    int x = min(n, k);
    for(int i=0; i<=x; i++)
    {
        for(int j=0; i+j<=x; j++)
        {
            ask(i, j);
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  rep(i,b){
    rep(j,a) cout << 0;
    rep(j,w-a) cout << 1;
    cout << endl;
  }
  rep(i,h-b) {
    rep(j,a) cout << 1;
    rep(j,w-a) cout << 0;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-

from math import ceil,floor

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

# def func(a):
#    return tmp

N = int(input())
S,T = input().split()

ans = S[0]+T[0]

for i in range(1,N):
    ans = ans + S[i]+T[i]

print(ans)


Measured memory_bytes: 38740
package main

import (
	"fmt"
	"math"
)

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	m := max(a, max(b, c))
	p := m * int(math.Pow(2, float64(k)))

	fmt.Println(a + b + c + p - m)
}


Measured memory_bytes: 512
// BFS
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

using namespace std;
using P = pair<int, int>;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{
    // input
    int h, w;
    cin >> h >> w;
    int si, sj;
    cin >> si >> sj;
    int ti, tj;
    cin >> ti >> tj;
    --si; --sj; --ti; --tj;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    const int INF = 1e9;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<P> q;
    dist[si][sj] = 0;
    q.emplace_back(si, sj);
    while (!q.empty()) {
        int i = q.front().first;
        int j = q.front().second;
        int d = dist[i][j];
        q.pop_front();
        if (dist[i][j] != d) continue;
        rep(v, 4) {
            int ni = i+di[v], nj = j+dj[v];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (s[ni][nj] == '#') continue;
            if (dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        for (int ei = -2; ei <= 2; ++ei) {
            for (int ej = -2; ej <= 2; ++ej) {
                int ni = i+ei, nj = j+ej;
                if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if (s[ni][nj] == '#') continue;
                if (dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 9588
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;
int main(){
  char str[1000], cmd[7], p[1000];
  int a, b, q;
  string OUT;
  scanf("%s", str);
  string STR = str;
  scanf("%d", &q);
  for(int i = 0; i < q; i++){
    scanf("%s %d %d", cmd, &a, &b);
    string CMD = cmd;
    if(CMD == "replace"){
      scanf("%s", p);
      string P = p;
      STR.replace(a, b - a + 1, P);
    }
    else if(CMD == "reverse"){
      string R;
      for(int j = b; j >= a; j--){
	R += STR[j];
      }
      STR.replace(a, b - a + 1, R);
    }
    else if(CMD == "print"){
      for(int k = a; k <= b; k++){
	OUT += STR[k];
      }
      OUT += "\n";
    }
  }
  char* out;
  out = (char*)malloc(OUT.length() + 1);
  sprintf(out, "%s", OUT.c_str());
  printf("%s", out);
  free(out);
  return 0;
}

Measured memory_bytes: 1124
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cstring>
#include <map>
#include <unordered_set>
#include <cmath>
#include <iomanip>

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define linebreak "\n"
#define space " "
#define PI atan(1)*4
#define E 10
#define ACCURATE cout << fixed << setprecision(20)
#define MAX 1e9
#define MOD (int)(998244353 )
#define vi vector<int>
#define N (int)(1e7)
#define _DEBUG
using namespace std;


int main() {
#ifdef _DEBUG // place in cmake-build-debug folder
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    IO;
    int n  ;
    cin >> n ;
    bool ok = true ;
    for(int i = 0;  i< n; i++) {
        int t ;
        cin >> t ;
        if(t%2 == 0 ){
            if(!(t%3 == 0) && !(t%5 == 0) )
                ok = false ;
        }
    }
    if(ok ) cout <<"APPROVED" << endl ; else cout << "DENIED" <<endl ;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
    
    int s[5];
    int i,k;
    int tmp;
    
    for(i=0; i < 5 ; i++)
    {
        cin >> s[i];
    }
    
    for(i=0; i<4;i++)
    {
        for(k=i+1; k<5;k++)
        {
            if(s[i]< s[k])
            {
                tmp = s[k];
                s[k] = s[i];
                s[i] = tmp;
            }
        }
    }
    
    i = 0;
    while(1)
    {
        cout << s[i++];
        
        if(i==5)
            break;
            
        cout << " ";
    }
    
    cout << endl;
    
}



Measured memory_bytes: 3092
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	
	int N,M;
	cin>>N>>M;
	pair<int,int> ab[100001];
	int tmp1,tmp2;
	for(int i=0;i<M;i++){
		cin>>tmp1>>tmp2;
		ab[i].second=tmp1;
		ab[i].first=tmp2;
	}
	sort(ab,ab+M);
	int ans=0;
	int last=0;
	for(int i=0;i<M;i++){
		int a=ab[i].second;
		int b=ab[i].first;
		if(a>=last){
			last=b;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 100000;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

int dp[2][1<<20][2];

int main(){
    int h,w;
    cin >> h >> w;
    string flag[20];
    string f = "JOI";
    REP(i,h){
	cin >> flag[i];
    }
    dp[0][0][0] = 1;

    int cur = 0, next = 1;
    REP(i,h){
	REP(j,w){
	    CLR(dp[next]);
	    REP(bit,1 << w) REP(p,2) if(dp[cur][bit][p]){
		REP(k,3){
		    if(flag[i][j] != '?' && flag[i][j] != f[k]) continue;
		    if(( bit & 1 << j) && k == 2) continue;
		    int nbit = bit & ~(1 << j), np = k == 0;
		    if(p && k == 1) nbit |= 1 << j-1;
		    dp[next][nbit][np] += dp[cur][bit][p];
		    if (dp[next][nbit][np] >= MOD) dp[next][nbit][np] -= MOD;
		}
	    }
	    swap(cur,next);
	}

	REP(bit,1<<w){
	    dp[cur][bit][0] += dp[cur][bit][1];
	    if(dp[cur][bit][0] >= MOD) dp[cur][bit][0] -= MOD;
	    dp[cur][bit][1] = 0;
	}

    }
    int ans = 1;
    REP(i,h)REP(j,w) if(flag[i][j] == '?') ans = (ans * 3) % MOD;
    REP(i,1<< w) ans = (ans + MOD - dp[cur][i][0]) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17612
#include<iostream>
using namespace std;
int main()
{
    int n, a, ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        for(int j = 0; ; j++){
            if(a % 2 != 0){
                ans += j;
                break;
            }
            a /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def findProductSum(A, n): 
      
    # calculating array sum (a1 + a2 ... + an) 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = array_sum * array_sum 
  
    # calcualting a1^2 + a2^2 + ... + an^2 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return (array_sum_square - 
            individual_square_sum) //2
n=int(input())
M = 1000000007
lst=list(map(int,input().split()))
x=findProductSum(lst,n)
print(x%M)

Measured memory_bytes: 31620
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

struct edge{
  int src,dst,cost;
  edge(int src,int dst,int cost):src(src),dst(dst),cost(cost){}
};

struct state{
  int cur;
  long long cost;
  state(int cur, long long cost):cur(cur),cost(cost){}
  bool operator>(const state &t)const{
    return cost > t.cost;
  }
};

typedef vector<edge> edges;
typedef vector<edges> graph;
const int N = 3010;
const long long inf = 1LL<<58;

void dijkstra(const graph &g, int k, int shop[], long long A[])
{
  priority_queue<state,vector<state>,greater<state> > q;
  for(int i = 0; i < k; ++i){
    state init(shop[i],0);
    q.push(init);
  }

  while(!q.empty()){
    state cst = q.top();
    q.pop();

    for(int i = 0; i < (int)g[cst.cur].size(); ++i){
      // int src = g[cst.cur][i].src;
      int dst = g[cst.cur][i].dst;
      int w   = g[cst.cur][i].cost;
      if( A[dst] > cst.cost + w ){
        A[dst] = cst.cost + w;
        q.push( state( dst, cst.cost + w ) );
      }
    }
  }
}

int main()
{
  int n,m,k;
  while(cin>>n>>m>>k){
    if(n==0&&m==0&k==0)break;

    long long A[N];
    graph g(n);
    static int adj[N][N];
    for(int i = 0; i < n; ++i){
      A[i] = inf;
      for(int j = 0; j < n; ++j){
        adj[i][j] = 0;
      }
    }
    for(int i = 0; i < m; ++i){
      int a,b,c;
      cin >> a >> b >> c;
      --a;--b;
      adj[a][b] = adj[b][a] = c;
      g[a].push_back(edge(a,b,c));
      g[b].push_back(edge(b,a,c));
    }
    int shop[N];
    for(int i = 0; i < k; ++i){
      cin >> shop[i];
      --shop[i];
      A[shop[i]] = 0;
    }

    dijkstra(g,k,shop,A);

    double res = 0;
    for(int i = 0; i < n; ++i){
      for(int j = i+1; j < n; ++j){
        if( adj[i][j] > 0 ){
          int a = A[i];
          int b = A[j];
          if( b < a ) swap(a,b);
          //cout << i << ' ' << j << ' ' << a << ' ' << b << ' ' << ((adj[i][j]+ a -b)/2. + b) << endl; 
          res = max( res, (adj[i][j]+ a -b)/2. + b);
        }
      }
    }
    
    printf("%.0lf\n", res+0.499999999);
    
    
  }
  return 0;
}

Measured memory_bytes: 39000
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

int dp[105][2][5];

signed main() {
    string str;
    int K;
    cin >> str >> K;
    int N = str.size();

    dp[0][0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k <= K; k++) {
                for (int n = 0; n < 10; n++) {
                    int num = str[i] - '0';
                    if (j == 0 && n > num) continue;
                    dp[i+1][j || n < num][(n == 0) ? k : k+1] += dp[i][j][k];
                }
            }
        }
    }

    int ret = 0;
    for (int j = 0; j < 2; j++) {
        ret += dp[N][j][K];
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from itertools import groupby,accumulate
n,k = map(int,stdin.readline().rstrip().split())
s = stdin.readline().rstrip()
li = []
for key, value in groupby(s):
    li.append((key,len(list(value))))
#とりあえず逆立ちしている人（透明人間含）でサンドイッチしていることにする
if li[0][0] != "1":
    li = [("1",0)]+li
if li[-1][0] != "1":
    li.append(("1",0))
lin = [i[1] for i in li]
if len(lin)//2 < k:
    k = len(lin)//2
lin = [0,0]+list(accumulate(lin))
ma = lin[2]#とりうる最大の人数
for i in range((k+1)*2,len(lin),2):
    ma = max(ma,lin[i]-lin[i-(k+1)*2+1])
print(ma)

Measured memory_bytes: 16144
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<int> v;
	int n;
	cin>>n;
	int s[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		sum+=s[i];
		if(s[i]%10==0) v.push_back(s[i]);
	}
	if(v.size()==n)
	{
		cout<<"0";
		return 0;
	}
	else if(sum%10!=0)
	{
		cout<<sum;
		return 0;
	}
	else
	{
		sort(s,s+n);
		for(int i=0;i<n;i++)
		{
			if(s[i]%10!=0)
			{
				sum-=s[i];
				cout<<sum;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int x;
   cin >> x;
   int lc = lcm(360,x);
   cout << lc/x << '\n';   
   return 0;
} 

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
using namespace std;
int N,A[100002],all=0;
int main(void){
	cin>>N;
	A[0]=0;
	A[N+1]=0;
	for(int i=1;i<=N;i++){
		cin>>A[i];
		all+=abs(A[i]-A[i-1]);
	}
	all+=abs(A[N]);
	for(int i=1;i<=N;i++)cout<<all-(abs(A[i]-A[i-1]))-(abs(A[i]-A[i+1]))+(abs(A[i+1]-A[i-1]))<<endl;
	return 0;
}


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

int n,a[205];

int main() {
    cin>>n;
    for(int i=1;i<=2*n;i++) cin>>a[i];
    sort(a+1,a+2*n+1);
    int ans =0 ;
    for(int i=1;i<=n;i++) ans+=min(a[i*2-1],a[i*2]);
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}

int upperBound(int data[], int n, int key) {
	int l = 0, r = n - 1;

	while (l <= r) {
		int m = (l + r) / 2;

		if (data[m] > key)
			r = m - 1;
		else
			l = m + 1;
	}

	return l;
}

int a[300000], b[300000];
long long c[300000], sum[300001];

int main(void) {
	int i;
	int n, m;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", a + i);
	scanf("%d", &m);
	for (i = 0; i < m; i++)
		scanf("%d", b + i);
	for (i = 0; i < m; i++)
		scanf("%lld", c + i);

	qsort(a, n, sizeof(int), &compare);

	for (i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + a[i - 1];

	for (i = 0; i < m; i++)
		puts(sum[upperBound(a, n, b[i])] >= c[i] ? "Yes" : "No");

	return 0;
}

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

using namespace std;

int howManyMount(long long p,int w[], int size){
    long long sum = 0;
    int k = 1;
    for(int i = 0; i < size; i++){ 
        if(sum + w[i] <= p){
            sum += w[i];
        }else{
            if(p < w[i]) return 900000;
            sum = w[i];
            k++;
        }
    }
    return k;
}

int solve(int k,int w[], int size){
    long long right = 10000000000;
    long long left = 0;
    long long mid = 0;
    int temp;
    while(left + 1 < right){
        mid = (right + left) / 2;
        temp = howManyMount(mid, w, size);
        if(k < temp){
            left = mid;
        }else{
            right = mid;
        }
    }
    return right;
}

int main(void){
    int n, k; cin >> n >> k;
    int w[n];
    for(int i = 0; i < n; i++) cin >> w[i];
    cout << solve(k,w,n) << endl;
    return 0;
}


Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b,c,d,e;cin >> a >> b >> c >> d >> e;
    cout << (c-a)*60 + (d-b) - e << endl;
    return 0;
}

Measured memory_bytes: 3564
s = list(input())
n = len(s)
s.append('<')
mini = 0
maxi = 0
p = 0

for i in range(n):
    if s[i] == '<':
        mini += 1
    else:
        maxi += 1
        if s[i+1] == '<':
            m = max(mini,maxi)
            p += (1 + m) * m // 2
            m = min(mini,maxi) - 1
            p += (1 + m) * m // 2
            mini = 0
            maxi = 0

if mini != 0:
    print(p + ((1+mini) * mini // 2))
else:
    print(p)

Measured memory_bytes: 13260
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
numbers = list()
for i in range(N):
    numbers.append(int(input()))

bingo = False
for a in A:
    if a not in numbers:
        break
else:
    bingo = True

for b in B:
    if b not in numbers:
        break
else:
    bingo = True

for c in C:
    if c not in numbers:
        break
else:
    bingo = True

columnA = [A[0],B[0],C[0]]
for i in columnA:
    if i not in numbers:
        break
else:
    bingo = True

columnB = [A[1],B[1],C[1]]
for i in columnB:
    if i not in numbers:
        break
else:
    bingo = True

columnC = [A[2],B[2],C[2]]
for i in columnC:
    if i not in numbers:
        break
else:
    bingo = True

diagA = [A[0],B[1],C[2]]
for i in diagA:
    if i not in numbers:
        break
else:
    bingo = True

diagB = [A[2],B[1],C[0]]
for i in diagB:
    if i not in numbers:
        break
else:
    bingo = True

print("Yes" if bingo else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;

int N,tmp=0,ans=0;
int cnt[100010];

signed main() {
    IOS();
    cin>>N;
    vint a(N);
    rep(i,0,N){
        cin>>a[i];
        tmp^=a[i];
        int t=0;
        while(a[i]%2==0){
            t++;
            a[i]/=2;
        }
        cnt[t]++;
    }
    rrep(i,0,31){
        if(cnt[i]==0&&((1ll<<i)&tmp)){
            cout<<-1<<endl;
            return 0;
        }
        if(cnt[i]==0||(((1ll<<i)&tmp)==0))continue;
        tmp^=(1ll<<i);
        tmp^=(1ll<<i)-1;
        ans++;
        if(tmp==0)break;
    }
    if(tmp){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		int[]ar=split();
		int a=ar[0];
		int b=ar[1];
		boolean bool=true;
		for(int i=0;i<=1250;i++)
		{
			int x=(i*8)/100;
			int y=i/10;
			if(x==a && y==b)
			{
				bool=false;
				System.out.println(i);
				break;
			}
		}
		if(bool)
			System.out.println(-1);
	}
}


Measured memory_bytes: 32756
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/* eslint-env es6, mocha, node */
/* eslint-extends: eslint:recommended */
'use strict';



// Import modules
import fs = require("fs");


// Read stdin
const data = fs.readFileSync("/dev/stdin", "utf-8");


// Main
const [a, b] = data.split(" ").map((v) => Number(v));


// Output
if (a + b === 15) {
    console.log("+");
} else if (a * b === 15) {
    console.log("*");
} else {
    console.log("x");
}



/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * c-hanging-comment-ender-p: nil
 * End:
 */

Measured memory_bytes: 7372
from collections import defaultdict
S = input()
MOD = 2019

cnt = [0] * MOD
cnt[0] = 1

now = 0
ans = 0
for d, n in enumerate(map(int, S[::-1])):
    now = (n * pow(10, d, MOD) + now) % MOD
    ans += cnt[now]
    cnt[now] += 1

print(ans)


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

bool table[110];
int N;

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

  for(int i=1;i<=9;++i){
      for(int j=1;j<=9;++j){
          table[i*j] = true;
      }
  }

  std::cin >> N;

  if(table[N]){
      std::cout << "Yes" << std::endl;
  }else{
      std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
i = a.index(min(a))
def solve(x, y):
    q1 = (x+k-2)//(k-1)
    r = ((k-1)-x%(k-1))%(k-1)
    q2 = max(0, y+k-2-r)//(k-1)
    return q1+q2
x = i
y = n-i-1
print(min(solve(x, y), solve(y, x)))

Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;
ll N;
vector<vector<vector<double>>> dp(310, vector<vector<double>>(310, vector<double> (310,-1.0)));
double F(ll i, ll j, ll k){
    if(dp[i][j][k]>=0){return dp[i][j][k];}
    if(i==0&&j==0&&k==0){return dp[0][0][0]=0.0;}
    double ans=0.0;
    if(i>0){ans+=F(i-1,j,k)*(double)i;}
    if(j>0){ans+=F(i+1,j-1,k)*(double)j;}
    if(k>0){ans+=F(i,j+1,k-1)*(double)k;}
    ans+=(double)N;
    ans*=1.0/(double)(i+j+k);
    return dp[i][j][k]=ans;
}

int main(){
    cin >> N;
    ll c1=0,c2=0,c3=0;
    for(ll i=0;i<N;i++){
        ll k;
        cin >> k;
        if(k==1)c1++;
        else if(k==2)c2++;
        else if(k==3)c3++;
    ;}
    cout << fixed << setprecision(14);
    cout<<F(c1,c2,c3)<<endl;
    return 0;
}


Measured memory_bytes: 237568
import sys
import numpy as np
from collections import Counter


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    max = A[-1]
    count = Counter(A)
    S = list(count.keys())
    C = []
    for s in S:
        if count[s] > 1:
            continue
        else:
            C.append(s)

    is_prime = np.ones(max + 1, np.bool)
    for a in A:
        if is_prime[a]:
            is_prime[a * 2 :: a] = 0
        else:
            continue
    answer = 0
    for c in C:
        if is_prime[c]:
            answer += 1
        else:
            continue
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 52856
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[200005];
int n;
int main (){
	ll s=0;
	int i;
	ll ans=10000000000000000ll;
	scanf ("%d",&n);
	for (i=1;i<=n;i++)
	{scanf ("%lld",&a[i]);}
	for (i=1;i<=n;i++){a[i]=a[i-1]+a[i];}
	for (i=1;i<n;i++)
	{ans=min(ans,abs(a[n]-2*a[i]));}
	printf ("%lld\n",ans);
	return 0;
}
	

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

int n, h[100000], ans = 0, cnt = 0;

int main() {
  cin >> n;
  rep(i,n) cin >> h[i];
  
  rep(i,n-1) {
    if (h[i] >= h[i+1]) cnt++;
    else cnt=0;
    ans = max(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
program pr1
  implicit none
  integer :: a, b, c, k, btmp, ctmp
  integer :: i, j
  read(*,*) a,b,c
  read(*,*) k

  do i = 0, k
     do j = 0, i
        btmp = b*(2**j)
        ctmp = c*(2**(i-j))
        if ( a < btmp .and. btmp < ctmp ) then
           write(*,'(a)') 'Yes'
           stop
        end if
     end do
  end do
  write(*,'(a)') 'No'
  
  stop
end program pr1


Measured memory_bytes: 2932
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

int dx[6] = {-1, -1, 0, 1, 1, 0};
int dy[6] = {0, -1, -1, 0, 1, 1};
bool issearched[140][140];

int t, n;
int islandmap[140][140];
int tesu[140][140];
int start_x, start_y;

void search(int a, int b);

int main()
{
    while(1){
        cin >> t >> n;
        if(t == 0 && n == 0) break;
        for(int i = 0; i < 140; i++){
            for(int j = 0; j < 140; j++){
                islandmap[i][j] = 0;
                issearched[i][j] = false;
                tesu[i][j] = 0;
            }
        }
        int obstacle_x, obstacle_y;
        for(int i = 0; i < n; i++){
            cin >> obstacle_x >> obstacle_y;
            islandmap[obstacle_x + 70][obstacle_y + 70] = -1;
        }
        cin >> start_x >> start_y;
        issearched[start_x + 70][start_y + 70] = true;
        search(start_x + 70, start_y + 70);
        int ans = 1;
        for(int i = start_x + 70 - t; i < start_x + 71 + t; i++){
            for(int j = start_y + 70 - t; j < start_y + 71 + t; j++){
                if(tesu[i][j] < t + 1 && tesu[i][j] > 0) ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

void search(int a, int b)
{
    int x, y, nx, ny;
    queue<pair < int, int> > qu;
    qu.push(make_pair<int, int>(a, b));
    while(!qu.empty()){
        x = (qu.front()).first;
        y = (qu.front()).second;
        for(int i = 0; i < 6; i++){
            nx = x + dx[i];
            ny = y + dy[i];
            if(nx < start_x + 70 - t|| ny < start_y + 70 - t|| nx > start_x + 71 + t|| ny > start_y + 71 + t) continue;
            if(islandmap[nx][ny] != -1 && issearched[nx][ny] == false){
                tesu[nx][ny] = tesu[x][y] + 1;
                qu.push(make_pair<int, int>(nx, ny));
                issearched[nx][ny] = true;
            }
        }
        qu.pop();
    }
    return;
}

Measured memory_bytes: 1392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;

int main() {
    int K, S;
    cin >> K >> S;

    int res = 0;
    for (int x = 0; x <= K; x++) {
        if (x > S) break;
        for (int y = 0; y <= K; y++) {
            if (x + y > S) break;
            if (S - x - y <= K) res++;
        }
    }

    print(res);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    string s;
    cin >> s;
    
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
"""
四隅に仮想の原点をつくり、各座標からその原点へのマンハッタン距離を計測する。
"""

N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

def measure(originX,originY):
    origin = [originX,originY]
    XY.sort(key=lambda x: abs(x[0]-origin[0])+abs(x[1]-origin[1]))
    return abs(XY[-1][0]-origin[0])+abs(XY[-1][1]-origin[1])-(abs(XY[0][0]-origin[0])+abs(XY[0][1]-origin[1]))

ans = 0
ans = max(ans,measure(1,1))
ans = max(ans,measure(1,10**9))
ans = max(ans,measure(10**9,1))
ans = max(ans,measure(10**9,10**9))
print(ans)

Measured memory_bytes: 136344
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

void solve(){
    
    int n;
    cin>>n;
    int a[n];
    for(int i =0;i<n;i++)
    cin>>a[i];
    ll sum = 0;
    for(int i =1;i<n;i++){
        if(a[i]<a[i-1]){
        sum+=max((a[i-1]-a[i]),0);
        a[i] = a[i-1];
        }
    }
    cout<<sum<<'\n';
}
int main(){
    IOS;
    int tt;
    tt = 1;
    // cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 4416
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let mut  abc = read_vec::<i32>();
    let k = read::<i32>();
    abc.sort();
    for i in 0..k {
        abc[2] = abc[2] * 2;
    }
    let ans:i32 = abc.iter().sum();
    println!("{}",ans);    
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int d = a;
    while (a < 100000000) {
        if (c == (a % b) ) {
            cout << "YES" << endl;
            return 0;
        }
        if (a % b == 0) {
            cout << "NO" << endl;
            return 0;
        }
        a+=d;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << "\n";
}

Measured memory_bytes: 256
import itertools
import sys
input = sys.stdin.readline


def main():
    def warshall_floyd(D, n):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    D[i][j] = min(D[i][j], D[i][k]+D[k][j])


    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))
    D = [[float('inf')]*N for _ in range(N)]
    for i in range(N):
        D[i][i] = 0
    for _ in range(M):
        a, b, c = map(int, input().split())
        D[a-1][b-1] = c
        D[b-1][a-1] = c

    warshall_floyd(D, N)

    ans = float('inf')
    for P in itertools.permutations(r):
        cost = 0
        for i in range(R-1):
            cost += D[P[i]-1][P[i+1]-1]
        ans = min(ans, cost)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 55388
#include <stdio.h>
int main(){
  int a,ans;
  scanf("%d",&a);
  ans = a / 2;
  
  if(a % 2 == 1){
  printf("%d\n",ans + 1);
  }
  
  else {
    printf("%d\n",ans);
  }
  
  return 0;
}

Measured memory_bytes: 128