akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

Q = int(input())
SUM = sum(A)
for q in range(Q):
    b, c = map(int, input().split())
    SUM -= C[b] * b
    SUM += C[b] * c
    C[c] += C[b]
    C[b] = 0
    print(SUM)


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


int main()
{
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace  std;

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

    sort(A.begin(), A.end());

    vector<bool> check(A[N-1]+1, true);

    int ans = 0;
    A.push_back(0);
    for(int i = 0; i < N; i++){
        if(check[A[i]] == true && A[i] != A[i+1])  ans++;
        for(int j = A[i]; j <= A[N-1]; j += A[i]){
            check[j] = false;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int ans=0;
	int cool =0;
	for(int i=1;i<=n;i++)
	{
		ans=0;
	for(int j=1;j<=i/2;j++)
	{
		if((i&1)&&(i%j==0)){ans++;}
	}
	ans+=1;
	
	if(ans==8){cool++;}
	}
	cout<<cool;
}

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

int main() {
  int N;
  cin >> N;
  int sum;
  
  for(int i = 0;i < N;i++) {
    int l,r;
    cin >> l >> r;
    
    sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1000;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<max({a,b,c})-min({a,b,c})<<endl;
}

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

int main() {
  int n;
  int w;
  while (cin >> n) {
    vector<int> v;
    w = 512;
    while (n) {
      if (n >= w) {
        v.push_back(w);
        n -= w;
      }
      w /= 2;
    }
    int i;
    for (i = v.size() - 1; i >= 0; i--) {
      cout << v[i];
      if (i) {
        cout << ' ';
      }
    }
    cout << endl;
  }
  return 0;
}



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inp = Console.ReadLine().Split(' ');
            int a = int.Parse(inp[0]);
            int b = int.Parse(inp[1]);

            if (a > 9 || b > 9)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(a * b);
            }

        }
    }
}


Measured memory_bytes: 13140
S = input()
S1 = S[::2]
S2 = S[1::2]
if len(S1) == len(S2):
    if S1.count('0') >= S2.count('0'):
        ans = S1.count('1') + S2.count('0')
    else:
        ans = S1.count('0') + S2.count('1')
else:
    if S1.count('0') < S1.count('1'):
        ans = S1.count('0') + S2.count('1')
    else:
        ans = S1.count('1') + S2.count('0')
print(ans)

Measured memory_bytes: 3188
/*
                         ----------------------------
                              Ankur Kumar Singh    
                         ----------------------------
*/


#include <bits/stdc++.h>
using namespace std;
# define ll  long long  int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
# define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define trace1(x)                cerr << #x << ": " << x << "\n";
# define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
# define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
# define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";

int  main()
{
   // #ifndef ONLINE_JUDGE
   // freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
   // #endif
   IOS;
   ll x,y;
   cin>>x>>y;
   ll r=x/y;
   if(x%y!=0)
      r++;
    cout<<r;
   

}


Measured memory_bytes: 256
using System;

class Program
{
 static void Main(String[] args)
 {
   var total = 0;
   var cnt = 0;
   var max = 0;
   var dansu = 0;

   total = int.Parse(Console.ReadLine());
   
   int[] mochiCM = new int[total];
   
   for( cnt = 0; cnt < total; cnt++ )
   {
     mochiCM[cnt] = int.Parse(Console.ReadLine());
   }

   Array.Sort(mochiCM);
   
   foreach( var mochi in mochiCM )
   {
     if( max < mochi )
     {
       max = mochi;
       dansu++;
     }
   }
   
   Console.WriteLine(dansu);
 }
}

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

void dfs(int node, vector<int> adj[], bool vis[], int dp[]){
    vis[node] = true;
    for (int i = 0; i < adj[node].size(); i++){
        if (!vis[adj[node][i]]) dfs(adj[node][i], adj, vis, dp);
        dp[node] = max(dp[node], dp[adj[node][i]] + 1);
    }
}

int findLongest(vector<int> adj[], int n){
    bool vis[n];
    int dp[n];
    memset(vis, false, sizeof(vis));
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < n; i++) if (!vis[i]) dfs(i, adj, vis, dp);
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
    return ans;
}

int main(){
    int n, e;
    cin >> n >> e;
    vector<int> adj[n];

    int a, b;
    for (int i = 0; i < e; i++){
        cin >> a >> b;
        a--;b--;
        adj[a].push_back(b);
    }
    cout << findLongest(adj, n) << endl;
}

Measured memory_bytes: 9600
void main() {
	auto N = ri;
	auto A = readAs!(int[]);
	A.reduce!gcd.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 4348
#include "bits/stdc++.h"
using namespace std;
bitset<10001> a;
int main()
{
	int n;
	scanf("%d", &n);
	a.set(0);
	for(int i = 0, j; i < n; ++i)
	{
		scanf("%d", &j);
		a |= a << j;
	}
	for(int i = 10000; i >= 0; --i)
	{
		if(i % 10 && a.test(i))
		{
			printf("%d\n", i);
			return 0;
		}
	}
	printf("0\n");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

int n,q;
int s[100100];
int t[100100];
int bs(int x){
    // 条件を満たす最小を求める
    ll ok = n-1;  //解が存在する値
    ll ng = -1;  //解が存在しない値 

    while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(s[mid] >= x){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return s[ok];
}


/*----------------------------------------------------------------*/
signed main(){

    
    cin >> n;
    rep(i,n)cin >> s[i];
    cin >> q;
    rep(i,q)cin >> t[i];

    int ans = 0;
    rep(i,q){
        if(bs(t[i]) == t[i])ans++;
    }
    cout << ans << endl;



    
    
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc145.contest.atcoder.jp/tasks/abc145_c


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

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

    // K回の操作の内取り出す回数iで全探索
    int ans = 0;
    for (int i = 0; i <= min(K, N); ++i) {
        // 操作Aの回数で全探索
        for (int j = 0; j <= i; ++j) {
            int res = 0;
            vector<int> vec;
            for (int k = 0; k < N; ++k) {
                if(k < j || k >= N+j-i){
                    res += V[k];
                    if(V[k] < 0) vec.push_back(V[k]);
                }
            }
            sort(vec.begin(), vec.end());
            for (int k = 0; k < K - i; ++k) {
                if(k < vec.size()) res -= vec[k];
            }
            ans = max(ans, res);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  contest
//
//  Created by TmpGuest on 2020/4/18.
//  Copyright © 2020 TmpGuest. All rights reserved.
//

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
int main() {
ios_base::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    if(t.length()!=s.length()+1)
        cout<<"No\n";
    else {
        for(int i=0;i<s.length();i++) {
            if(s[i]!=t[i]) {
                cout<<"No\n";
                return 0;
            }
                
        }
        
            cout<<"Yes\n";
        
    }
    
    
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    for (auto &&c : s)
    {
        c += n;
        if ((int)c > 90)
            c -= 26;
    }

    cout << s << endl;

    return 0;
}

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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 100005;


integer main(){
    ios_base::sync_with_stdio(false);

    int n, k, s;
    cin >> n >> k >> s;
    vector<int> ar(n);
    for (int i = 0; i < k; i++){
        ar[i] = s;
        cout << ar[i] << ' ';
    }
    for (int i = k; i < n; i++){
        ar[i] = (s == 1000000000 ? 1 : s + 1);
        cout << ar[i] << ' ';
    }


}


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

string s;
bool decided[501][501];
bool dp[501][501];

//s[l, r)???cat??????true?????????
bool isCat( int l, int r ){
	if( decided[l][r] ){
		return dp[l][r];
	}
	if( l == r ){
		dp[l][r] = true;
		decided[l][r] = true;
		return true;
	}
	if( s[l] != 'm' ){
		dp[l][r] = false;
		decided[l][r] = true;
		return false;
	}
	if( s[r-1] != 'w' ){
		dp[l][r] = false;
		decided[l][r] = true;
		return false;
	}
	for( int i = l + 1; i < r - 1; i++ ){
		if( s[i] == 'e' ){
			if( isCat(l + 1, i) && isCat(i + 1, r - 1) ){
				dp[l][r] = true;
				decided[l][r] = true;
				return true;
			}
		}
	}
	dp[l][r] = false;
	decided[l][r] = true;
	return false;
}

int main()
{
	cin >> s;
	if( isCat(0, s.length()) ){
		cout << "Cat" << endl;
	}
	else{
		cout << "Rabbit" << endl;
	}
	return 0;
}

Measured memory_bytes: 1676
numbers = gets.chop.split.map(&:to_i)

ans = 0



even_num = []
odd_num = []

numbers.each { |elem|
  if elem.even?
    even_num << elem
  else
    odd_num << elem
  end
}

if even_num.size == 3 || odd_num.size == 3
  max_num = numbers.max

  numbers.each{ |elem|
    ans += max_num-elem
  }
  puts ans/2

elsif even_num.size == 2
  for i in 0..1
    even_num[i] += 1
  end

   numbers = odd_num + even_num

   max_num = numbers.max

   numbers.each{ |elem|
     ans += max_num-elem
   }

   puts ans/2 + 1


elsif odd_num.size ==2
  for i in 0..1
    odd_num[i] += 1
  end

   numbers = odd_num + even_num

   max_num = numbers.max

   numbers.each{ |elem|
     ans += max_num-elem
   }

   puts ans/2 + 1
end


Measured memory_bytes: 1916
n, m = map(int, input().split())
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]
par = [-1]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    unite(a, b)
ans = 0
for i in range(1,n+1):
    ans = max(ans, size(i))
print(ans)

Measured memory_bytes: 78776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  long long int fizbuzz=0;
  for(int i=1; i<=n; i++){
    if(i%3!=0 && i%5!=0)fizbuzz+=i;
  }
  cout<<fizbuzz<<endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 200005;
int bit[MAX_N+1];
int nn = MAX_N; //　1-index
const ll INF = 1002003004005006001;

void adds(int a, int w){
    for(int x = a; x <= nn; x += x & -x) bit[x] += w;
}
int sums(int a){ // bit[1,a]の和を返す.
    int ret = 0;
    for(int x = a; x > 0; x -= x & -x) ret += bit[x];  
    return ret;
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    ll a[n+1] = {};
    ll sum[n+1] = {};
    srep(i,1,n+1){
        cin >> a[i];
        a[i] -= k;
        sum[i] = sum[i-1] + a[i];
    }

    ll ans = 0;

    vector<P> c;
    c.push_back(P(-INF,0));
    srep(i,1,n+1){
        c.push_back(P(sum[i], i));
    }
    sort(c.begin(), c.end());
    int f[n+1];
    rep(i,n+1){
        f[c[i].second] = i;
    }
    srep(i,1,n+1)adds(i, 1);

    rep(i,n){
        auto ite = lower_bound(c.begin(), c.end(), P(sum[i], 0));
        ans += sums(n) - sums(ite - c.begin() - 1);
        adds(f[i+1], -1);
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 9584
#include <stdio.h>
#include <string.h>
int main(void)
{
int n,l,i,j;
char s[100][200],tmp[200];
scanf("%d %d",&n,&l);
for(i=0;i<n;i++)
  scanf("%s",s[i]);
for(i=1;i<n;i++){
  for(j=1;j<n;j++){
    if(strcmp(s[j-1],s[j])>0){
      strcpy(tmp,s[j-1]);
      strcpy(s[j-1],s[j]);
      strcpy(s[j],tmp);
    }
  }
}
for(i=0;i<n;i++)
  printf("%s",s[i]);
  return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    char b;
    std::cin >> b;
    char ret;
    if (b == 'A') ret = 'T';
    else if (b == 'T') ret = 'A';
    else if (b == 'C') ret = 'G';
    else ret = 'C';
    std::cout << ret << std::endl;

    return 0;
}


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

int main(){
  string s;
  char color;
  int  section = 0; 
  cin >> s;
  color = s.at(0);
  for(int i=1;i<s.size();i++){
    if(color != s.at(i)){
      section++;
      color = s.at(i);
    }
  }
  cout << section << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int ans = ab[0] + ab[1];
            ans = Math.Max(ans, ab[0] - ab[1]);
            ans = Math.Max(ans, ab[0] * ab[1]);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;

template <class T>
void Prt(const std::list<T>& ls)
{
  for (const T& x : ls) {
    std::cout << x << '\n';
  };
}


signed main(){
    cin >> n;
    list<int> lst={};
    auto itr = lst.begin();
    int tmp = 0;
    REP(i,n){
        int q;
        cin >> q;
        if(q == 0){
            int x;
            cin >> x;
            itr = lst.insert(itr,x);
        }
        else if(q==1){
            int d;
            cin >> d;
            advance(itr,d);
        }
        else if(q==2){
            itr = lst.erase(itr);
        }
        else{
            return 0;
        }
        //Prt(lst);
    }
    Prt(lst);
    //Debug(lst);


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";

int N, D;
vector<vector<double>> X(10, vector<double>(10, 0));

bool ok (int X1, int X2) {
    double d2 = 0;
    for (int i = 0; i < D; i++) {
        d2 += (X[X1][i] - X[X2][i]) * (X[X1][i] - X[X2][i]);
    }
    double d2sqrt = floor( sqrt(d2) );
    // cout << d2 << " " << d2sqrt << "\n";
    if ( d2 == d2sqrt * d2sqrt ) {
        return true;
    }
    return false;
}

int main() {

    cin >> N >> D;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            double temp;
            cin >> temp;
            X[i][j] = temp;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (ok(i, j)) {
                ans++;
            }
        }
    }

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

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

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll n;
vector<ll> a;

int main() {
  cin >> n;
  a = vector<ll>(n);
  REP(i, n) cin >> a[i];

  ll money = 1000;
  REP(i, n - 1) {
    if (a[i] < a[i + 1]) {
      ll lot = money / a[i];
      money -= lot * a[i];
      money += lot * a[i + 1];
    }
  }
  print(money);
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>

using namespace std;

int n,m;
struct bill{
	int b,x,y;
	bill(int b,int x,int y):b(b),x(x),y(y){};
};
vector<bill> bi;
map<int,int> bn;
map<int,int> bnb;
typedef pair<double,int> P;
double d[10000];
int pr[10000];
double INF=10000000;

double sqr(int num){
	return sqrt((double)num);
}

int po2(int l){
	return l*l;
}

void dijk(int f,int t){
	fill(d,d+n+1,INF);
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0.0,f));
	d[f]=0.0;
	while(que.size()){
		P p=que.top();
		que.pop();
		double c=p.first;
		int v=p.second;
		if(d[v]<c)continue;
		for(int i=0;i<n;i++){
			double k=sqr(po2(abs(bi[v].x-bi[i].x))+po2(abs(bi[v].y-bi[i].y)));
			if(k<=50.0 && d[i]>c+k){
				d[i]=c+k;
				pr[i]=v;
				que.push(P(c+k,i));
			}
		}
	}
}

void rc(int f,int t){
	vector<int> prev;
	while(f!=t){
		prev.push_back(bnb[t]);
		t=pr[t];
	}
	prev.push_back(bnb[t]);
	reverse(prev.begin(),prev.end());
	for(int i=0;i<prev.size();i++){
		if(i!=0)printf(" ");
		printf("%d",prev[i]);
	}
	printf("\n");
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		bi.clear();
		bn.clear();
		bnb.clear();
		for(int i=0;i<n;i++){
			int b,x,y;
			scanf("%d%d%d",&b,&x,&y);
			bi.push_back(bill(b,x,y));
			bn[b]=i;
			bnb[i]=b;
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			int f,t;
			scanf("%d%d",&f,&t);
			dijk(bn[f],bn[t]);
			if(d[bn[t]]!=INF)rc(bn[f],bn[t]);
			else printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top=0, S[1000];

void push(int x);
int pop(void);

int main() 
{
	int far, sec, x, sol=0;
	char fm[100];
	while(scanf("%s",fm) != EOF) {
		if(fm[0] == '+') {
			far = pop();
			sec = pop();
			sol = far + sec;
			push(sol);
		} else if (fm[0] == '-') {
			sec = pop();
			far  = pop();
			sol = far - sec;
			push(sol);
		} else if (fm[0] == '*') {
			far = pop();
			sec = pop();
			sol = far*sec;
			push(sol);
		} else {
			x = atoi(fm);
			push(x);
		}
	}
	printf("%d\n", pop());

	return 0;
}

void push(int x){
   ++top;
   S[top] = x;
}

int pop(){
	top--;
	return S[top+1];
}


Measured memory_bytes: 2056
import fractions
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[0]*n
if k>max(a):
    print("IMPOSSIBLE")
    exit()
g=a[0]
for i in range(1,n):
    g=fractions.gcd(g,a[i])
for i in range(n):
    b[i]=a[i]%g
if k%g in b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

int n, m, l, r1, r2, c1, c2, sx, sy;
string s, t;
char c;

int main(){
    cin >> n >> m >> l >> sx >> sy;
    r1 = r2 = sx; c1 = c2 = sy;
    cin >> s >> t;
    for (int i=0; i<l; i++){
        if (s[i] == 'U') r1--;
        else if (s[i] == 'L') c1--;
        else if (s[i] == 'R') c2++;
        else r2++;
        if (r1 < 1 || r2 > n || c1 < 1 || c2 > m) rc("NO");
        if (t[i] == 'U') r2--;
        else if (t[i] == 'L') c2--;
        else if (t[i] == 'R') c1++;
        else r1++;
        r1 = smin(r1, n); r2 = smax(r2, 1);
        c1 = smin(c1, m); c2 = smax(c2, 1);
    }
    rc("YES");
}


Measured memory_bytes: 776
h, w, k = map(int, input().split())
c=[input() for i in range(h)]

ans = 0
from itertools import product
for i in product(range(2), repeat=h):
  for j in product(range(2), repeat=w):
    temp = 0
    for a in range(h):
      for b in range(w):
        if i[a]==1 and j[b]==1 and c[a][b]=="#":
          temp+=1
    if temp == k:
      ans+=1
print(ans)
        

Measured memory_bytes: 9192
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int K, N;
int h[101010];

int main()
{
    cin >> N >> K;
    rep(i, 0, N)
    {
        cin >> h[i];
    }
    sort(h, h + N);
    int ans = inf;
    rep(i, 0, N - K + 1)
    {
        chmin(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    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: 3600
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    double v[50];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v, v + n);
    for (int i = 0; i < n - 1; i++) {
        v[i+1] = (v[i] + v[i+1]) / 2.0;
    }
    cout << v[n - 1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,m;
  int a[10000];
  int x=0;
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d",&a[i]);
    x = x += a[i];
  }
  if(n-x>=0){
    printf("%d\n",n-x);
  }else{
    printf("-1");
  }
  return 0;
}

Measured memory_bytes: 1760
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,budget;
int table[10];

bool FLG;
int ans[6],TMP[6];

void recursive(int num,int count,int rest){

	if(FLG)return; //最速で到達するのが最適

	if(num == 10){

		if(count == N){

			for(int i = 0; i < N; i++){

				ans[i] = TMP[i];
			}

			FLG = true;
		}
		return;
	}

	if(count < N && table[num] <= rest){

		//買う
		TMP[count] = num;
		recursive(num,count+1,rest-table[num]);

	}
	//買わない
	recursive(num+1,count,rest);
}

int main(){

	scanf("%d %d",&N,&budget);

	for(int i = 0; i <= 9; i++){

		scanf("%d",&table[i]);
	}

	FLG = false;

	recursive(0,0,budget);

	if(!FLG){

		printf("NA\n");

	}else{

		for(int i = 0; i < N; i++){
			printf("%d",ans[i]);
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> T(M, "");
    vector<tuple<int, int, int>> S(M);
    for (int i = 0; i < M; i++) {
        cin >> get<0>(S.at(i)) >> get<1>(S.at(i));
        get<2>(S.at(i)) = i;
    }
    sort(ALL(S));
    int count = 1;
    for (int i = 0; i < M; i++) {
        if (i == 0) {
            int K = get<0>(S.at(i)), cn = 0;
            while(K > 0) {
                cn++;
                K /= 10;
            }
            for (int j = 0; j < 6 - cn; j++) {
                T.at(get<2>(S.at(i))) += "0";
            }
            string R = to_string(get<0>(S.at(i)));
            T.at(get<2>(S.at(i))) += R;
            T.at(get<2>(S.at(i))) += "000001";
            continue;
        }
        if (get<0>(S.at(i)) == get<0>(S.at(i - 1))) {
            count++;
        }
        else {
            count = 1;
        }
        int K = get<0>(S.at(i)), cn = 0;
        while(K > 0) {
            cn++;
            K /= 10;
        }
        for (int j = 0; j < 6 - cn; j++) {
            T.at(get<2>(S.at(i))) += "0";
        }
        string R = to_string(get<0>(S.at(i)));
        T.at(get<2>(S.at(i))) += R;
        int cn2 = 0, L = count;
        while (L > 0) {
            cn2++;
            L /= 10;
        }
        for (int j = 0; j < 6 - cn2; j++) {
            T.at(get<2>(S.at(i))) += "0";
        }
        string F = to_string(count);
        T.at(get<2>(S.at(i))) += F;
    }
    for (int i = 0; i < M; i++) {
        cout << T.at(i) << endl;
    }
}


Measured memory_bytes: 9728
#include<iostream>
using namespace std;
const int MAX=2e5+5;
int sl[MAX];


int main()
{
    int n;
	cin >> n;
        for(int i=1;i<=n;++i)   
        {
            cin>>sl[i];
        }
        if(n % 2 != 0) // ji
        {
            cout<<sl[n];
            for(int i=n-2;i>=1;i-=2)
                cout<<" "<<sl[i];
            for(int i=2;i<=n-1;i+=2)
                cout<<" "<<sl[i];
            cout<<endl;
        }else		  //ou
        {
            cout<<sl[n];
            for(int i=n-2;i>=2;i-=2)
                cout<<" "<<sl[i];
            for(int i=1;i<=n-1;i+=2)
                cout<<" "<<sl[i];
            cout<<endl;
        }

    return 0;
}

Measured memory_bytes: 2944
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	vector<vector<int>> cs(3, vector<int>(3));
	REP(i, 3) REP(j, 3) cin >> cs[i][j];
	bool isYes = true;
	REP(i, 3) REP(j, 3)
	{
		if (cs[i][j] - cs[i][(j + 1) % 3]
			!= cs[(i + 1) % 3][j] - cs[(i + 1) % 3][(j + 1) % 3])
			isYes = false;
		if (cs[i][j] - cs[(i + 1) % 3][j]
			!= cs[i][(j + 1) % 3] - cs[(i + 1) % 3][(j + 1) % 3])
			isYes = false;
	}
	cout << (isYes ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3620
import Data.List

main = do
  [a,b,c] <- fmap (sort . map read . words) getLine
  print (solve a b c)

solve :: Int -> Int -> Int -> Int
solve a b c =
  op1 + op2 + 2*r
  where
    op1     = c-b
    (op2,r) = (b-a)`divMod`2

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

#define lint long long
#define P pair<int, int>


int main() {
    int N, K;

    cin >> N >> K;

    double ans = 0;

    for(int i = 1; i <= N; ++i){
        if(i >= K){
            ans += (double)1 / N;
        } else {
            int tmp = i;
            double pro = (double)1 / N;
            while(tmp < K){                
                tmp *= 2;
                pro /= 2;
            }
            ans += pro;
        }
    }

    cout << setprecision(12) << ans << endl; 
}


Measured memory_bytes: 256
n=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
cnt=0
for i in range(1,n+1,2):
    if len(make_divisors(i))==8:
        cnt+=1
print(cnt)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;

signed main() {
  int n; cin >> n;
  vector<tuple<string, int, int> > vec(n);

  for(int i = 0; i < n; i++) {
      string s;
      int p;
      cin >> s >> p;
      vec[i] = make_tuple(s, -p, i);
  }
  sort(vec.begin(), vec.end());
  for(int i = 0; i < n; i++) {
      cout << get<2>(vec[i])+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000005
#define mod 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i = 0; i < (n); ++i) /*0からn-1までのrep*/
#define rrep(i,n) for(int i = 1; i <= (n); ++i) /*1からnまでのrep*/
#define drep(i,n) for(int i = (n)-1; i >= 0; --i) /*n-1から0までのrep*/
#define srep(i,s,t) for (int i = s; i < t; ++i) /*sからt-1までのrep*/
#define each(a,b) for(auto& (a): (b)) /*よくわからん*/
#define all(v) (v).begin(),(v).end() /*全選択*/
#define sz(v) (int)(v).size() /*大きさ*/
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) /*重複削除*/
#define cmx(x,y) x=max(x,y) /*最大値*/
#define cmn(x,y) x=min(x,y) /*最小値*/
#define rev(v) reverse((v).begin(),(v).end()); /*逆順*/
#define so(v) sort((v).begin(), (v).end()); /*ソート*/
#define yn {puts("Yes");}else{puts("No");} /*はい・いいえ*/
#define fi first
#define se second
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vp = vector<P>;
using vs = vector<string>; 

int main() {
    string s;
    cin >> s;
    cout << s.at(0) << s.at(1) << s.at(2) << endl;
    return 0;
}

Measured memory_bytes: 3616
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    while 1:
        n,m=MI()
        if n==0:break
        aa=[II() for _ in range(n)]
        sa=sum(aa)
        sb=0
        bb=set()
        for _ in range(m):
            b=II()
            sb+=b
            bb.add(b)
        d=sa-sb
        if d%2:
            print(-1)
            continue
        d//=2
        for a in aa:
            if a-d in bb:
                print(a,a-d)
                break
        else:
            print(-1)

main()



Measured memory_bytes: 6036
use proconio::input;

fn eval(days: u32, cs: Vec<i32>, sats: Vec<Vec<i32>>, ts: Vec<u32>) {
    let mut score = 0;

    let mut lasts = vec![0; 26];

    for day in 0usize..(days as usize) {
        score += sats[day][ts[day as usize] as usize - 1] as i32;
        dbg!(score);

        lasts[ts[day as usize] as usize - 1] = day + 1;

        for i in 0..26 {
            score -= (cs[i] as usize * (1 + day - lasts[i])) as i32;
        }
        println!("{}", score);
    }
}

fn main() {
    input! { days: u32 };
    let mut cs = vec![0; 26];

    for i in 0..26 {
        input! {
            x: i32
        };

        cs[i] = x;
    }

    let mut sats = vec![vec![0; 26]; days as usize];
    for d in 0..days {
        for i in 0..26 {
            input! {
                s: i32
            };

            sats[d as usize][i as usize] = s;
        }
    }

    let mut ts = vec![0u32; days as usize];
    for i in 0..days as usize {
        input! {
            x: u32
        };

        ts[i] = x;
    }

    eval(days, cs, sats, ts);
}


Measured memory_bytes: 2252
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n;
ll c;
ll x[MAX_N + 2];
ll v[MAX_N + 2];
ll r[MAX_N + 2];
ll l[MAX_N + 2];

int main() {
    fastio();

    cin >> n >> c;
    forn1(i, n) cin >> x[i] >> v[i];

    ll total = 0;
    forn1(i, n) {
        total += v[i];
        r[i] = max(r[i - 1], total - x[i]);
    }

    total = 0;
    for (int i = n; i >= 1; i--) {
        total += v[i];
        l[i] = max(l[i + 1], total - (c - x[i]));
    }

    ll ans = 0;

    total = 0;
    forn1(i, n) {
        total += v[i];
        ll temp = total - x[i];
        chmax(ans, max(temp, temp - x[i] + l[i + 1]));
    }

    total = 0;
    for (int i = n; i >= 1; i--) {
        total += v[i];
        ll temp = total - (c - x[i]);
        chmax(ans, max(temp, temp - (c - x[i]) + r[i - 1]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    
    ll r = 0;
    ll m = min(a, b);
    m = min(m, c);
    m = min(m, d);
    m = min(m, e);
    r = ceil((double)n / m) +4;
    
    mes(r);
    
        
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3512
n = int(input())
h = list(map(int, input().split()))
a = h[0]-1
if n == 1:
    print("Yes")
    exit()
for i in range(1, n):
    if a > h[i]:
        print("No")
        exit()
    elif a < h[i]:
        a = h[i]-1
print("Yes")

Measured memory_bytes: 14396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultiplication2 solver = new BMultiplication2();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultiplication2 {
        private static final long MAX = 1_000_000_000_000_000_000L;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = in.readLongArray(n);

            for (long x : a) {
                if (x == 0) {
                    out.println(0);
                    return;
                }
            }

            BigInteger answer = BigInteger.ONE;
            for (long x : a) {
                answer = answer.multiply(BigInteger.valueOf(x));
                if (answer.compareTo(BigInteger.valueOf(MAX)) > 0) {
                    out.println(-1);
                    return;
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] x = new long[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextLong();
            }
            return x;
        }

    }
}



Measured memory_bytes: 48896
num, K = input().split()
num = int(num)
K = int(K)

ans = 0

for n in range(num):
    x, y = input().split()
    x = int(x)
    y = int(y)
    # print(x)
    if x*x + y*y <= K*K:
        ans += 1

print(ans)


Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int (i)=0;(i)<(N);(i)++)
#define REPR(i,N) for(int (i)=(N);i>=0;i--)
#define FOR (i,m,n) for(int (i)=m;(i)<(n);(i)++)

int main(){
  int all_num, add, ans=1;
  cin >> all_num >> add;

  REP(i,all_num){
    if(ans*2<ans+add) ans*=2;
    else ans+=add;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>

using namespace std;

long double pro[3000][3000];

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

    pro[0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        long double p;
        cin >> p;

        for (int j = 0; j < N; ++j) {
            pro[i][j + 1] += pro[i - 1][j] * p;
            pro[i][j] += pro[i - 1][j] * (1 - p);
        }
    }

    long double ans = 0;
    for (int i = N; i > N - i; --i) {
        ans += pro[N][i];
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 140800
#include <iostream>
#include <vector>
#include <algorithm>

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

int main()
{
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, long long> > v;
  REP(i, n) {
    long long a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  while(k > 0) {
    k -= v[cnt].second;
    cnt++;
  }
  cout << v[cnt - 1].first << endl;
}


Measured memory_bytes: 2420
// AOJ 2101 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2101)
#include<cstdio>

int divS( int n )
{
	int ret = 0;

	for( int i = 1; i*i <= n; ++i ) if( n % i == 0 )
	{
		ret += i;

		if( i != n/i )
			ret += n/i;
	}

	return ret-n;
}

int main()
{
	int N;
	while( scanf( "%d", &N ), N )
	{
		int S = divS(N);

		puts( N==S?"perfect number":N>S?"deficient number":"abundant number" );
	}

	return 0;
}

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

int main() {
  int a[4][3][10] = {0};

  int num;
  cin >> num;

  int b,f,r,v;
  while (cin >> b >> f >> r >> v) {
    if (a[b-1][f-1][r-1] == 0) { 
      a[b-1][f-1][r-1] = v;
      num--;
    } else {
      a[b-1][f-1][r-1] += v;
    }
    if (num == 0) break;
  }
  
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
	cout << " " << a[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) cout << "####################" << endl;
  }

}  
    

Measured memory_bytes: 1160
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int r,w;
	if(n==1) r=1;
	else r=n-2;
	if(m==1) w=1;
	else w=m-2;
	long long ans=(long long)r*w;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256