akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

# 入力
n = str(input())

n1 = int(n[-1])
# print(str(n1))

if n1 in [2,4,5,7,9]:
  print("hon")
elif n1 in [0,1,6,8]:
  print("pon")
else:
  print("bon")


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

flavor = int(n*(l+(l+n-1))/2)

if (l<0):
  if l>=(-n+1):
  	print(flavor)
  elif l<(-n+1):
    print(flavor-(l+n-1))
    

else:
  print(flavor-l)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  cin >> n;
  int a[n];int cnt=1,k,ans=0;
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++){
    if(cnt==1) k=a[i];
    if(i!=n-1){
    if(k==a[i+1]) cnt++;
    if(k!=a[i+1]) {
      ans+=(cnt/2);
      cnt=1;
    }
    }
    else{
        ans+=(cnt/2);
        cnt=1;
      }
    }
  cout << ans<<endl;
}


Measured memory_bytes: 256
import math
D, G = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(D)]
p = [L[i][0] for i in range(D)]
q = [L[i][1] for i in range(D)]

#for l in L:
#   l.append(i*l[0]*100+l[1])
#   i += 1

M = [L[i][0]*(i+1)*100+L[i][1] for i in range(D)]
lis = []
for i in range(1 << D):
    s = [0, 0]
    for j in range(D):
        if ((i >> j) & 1) == 1:
            s[0] += p[j]
            s[1] += M[j]
    for j in range(D):
        if ((i >> j) & 1) == 0:
            lis.append(s+[j+1])
        else:
            lis.append(s+[0])
#print(lis)
ans = 1010
for l in lis:
    if G <= l[1]:
        ans = min(ans, l[0])
    elif G - l[1] <= l[2] * 100 * (p[l[2]-1]-1):
        ct = math.ceil((G-l[1]) / (l[2]*100))
        ans = min(ans, l[0]+ct)

print(ans)


Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF 1e9+5
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(i,a,b) for(ll i=a;i<(ll)b;i++)
#define ff first
#define ss second
#define int long long
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	map<int,int>mp;
	for(int i=1;i<=n;i++)
	{
		mp[arr[i]]++;
	}
	map<int,int>::iterator itr;
	ll ans=0;
	for(itr=mp.begin();itr!=mp.end();itr++)
	{
		int k=itr->ss;
		ans+=((k-1)*k)/2;
	}
	for(int i=1;i<=n;i++)
	{
		int k=mp[arr[i]];
		ll temp=ans-(k*(k-1))/2;
		k--;
		if(k>0)
		temp+=(k*(k-1))/2;
		cout<<temp<<"\n";
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int ans=0;
	while(n>0){
		if(n%10==2){
          ans++;
        }
		n/=10;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],p=0,num=0,sum=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);a[n+1]=0;
	for(int i=1;i<=n+1;i++){
		if(a[i]==p)num++;
		else{
			if(num>=p)sum+=num-p;
			else sum+=num;			
			p=a[i];num=1;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;
    int ans = 0;
    FOR(i,a,b+1) {
        string s = to_string(i);
        bool b = true;
        FOR(j,1,3) if (s[2-j] != s[2+j]) b = false;
        if (b) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

void solve() 
{
    int k;cin>>k;
    queue<string>q;vector<ll>v;
    rep(i,1,10){
        q.push(to_string(i));
        v.push_back(i);
    }
    while(q.front().size()<11){
        string x=q.front();q.pop();
        char xx=x[x.size()-1];
        if(xx>'0'){
            string a=x;
            a.push_back(xx-1);
            q.push(a);
            v.push_back(stoll(a));
        }
        string a=x;
        a.push_back(xx);
        q.push(a);
        v.push_back(stoll(a));
        if(xx<'9'){
            string a=x;
            a.push_back(xx+1);
            q.push(a);
            v.push_back(stoll(a));
        }
    }
    sort(v.begin(),v.end());
    cout<<v[k-1]<<endl;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 34924
#include "bits/stdc++.h"
using namespace std;
     
int main()
{
    string s;
    cin>>s;
    long long int ans=0;
    	
    for(int i=0;i<s.size();i++)
    {
        ans+=s[i]-'0';
    }
    	
    long long x=(s.size()-1)*9;
    x+=s[0]-'0';
    x-=1;
    ans=max(ans,x);
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	str := sc.Text()
	var answer string
	if str[0] == str[1] && str[0] == str[2] {
		answer = "No"
	} else {
		answer = "Yes"
	}
	fmt.Println(answer)
}


Measured memory_bytes: 640
using System;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
           var a = int.Parse(System.Console.ReadLine());
            if(a%1000 ==0)
            {
                a = 0;
            }
            else
            {
                a =  (a / 1000 + 1)*1000 - a;
            }
            System.Console.WriteLine(  a );

        }
    }
}


Measured memory_bytes: 27520
#include <iostream>

using namespace std;

int main() {
    int k, a, b;
    cin >> k >> a >> b;

    for (int i = 1; i < 1000; ++i){
        if (a <= i*k && i*k <= b) {
            cout << "OK" << endl;
            return 0;
        }
    }
        
    cout << "NG" << endl;
    return 0;
}

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
// #define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
    ll h, w, o, soma = 0, res = 0;
    cin >> h >> w >> o;
    vector<vl> mat(h, vl(w));
    vl linhas(h);
    vl colunas(w);
    for(int i = 0; i < h; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < w; ++j){
            if(s[j] == '#'){
                mat[i][j] = 1;
                soma++;
            }
        }
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(mat[i][j] == 1){
                linhas[i]++;
                colunas[j]++;
            }
        }
    }
    for(ll i = 0; i < (1LL << h); ++i){
        for(ll j = 0; j < (1LL << w); ++j){
            ll aux = soma;
            ll aux1 = 0;
            ll aux2 = 0;
            ll aux3 = 0;
            for(ll k = 0; k < h; ++k){
                if((i & (1LL << k)) != 0){
                    aux1 -= linhas[k];
                    for(ll l = 0; l < w; ++l){
                        if((j & (1LL << l)) != 0){
                            aux2 += mat[k][l];
                        }
                    }
                }
            }
            for(ll k = 0; k < w; ++k){
                if((j & (1LL << k)) != 0){
                    aux3 -= colunas[k];
                }
            }
            if(aux + aux1 + aux2 + aux3 == o){
                // W(i, " | ")
                // W(j, "\n")
                // W(aux1, " | ")
                // W(aux2, " | ")
                // W(aux3, "\n")
                res++;
            }
        }
    } 
    cout << res << endl;
    
	return 0;
} 
// 1 2 3 4 6 12
// 0	1	2	3	4	5	6	7	8	9	10
// -	(	(	(	)	)	)	)	)	)	-
// 0	1	1	1	1	1	1	0	0	0	0
// 0	1	2	3	3	3	3	3	3	3	3
// 0	0	0	0	1	2	3	3	3	3	3
// 0	0	1	2	3	3	3	3	3	3	3



// 6 - 
// 5 - a
// 0 - ababba
// 2 - abba
// 4 - ba
// 1 - babba
// 3 - bba


// -$a
// -aa
// -aa
// -aa
// -a$

Measured memory_bytes: 3656
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <iostream>
using namespace std;
typedef long long ll;
const long long mod = 998244353;
int main() {
    int n;
    cin >> n;
    int k = n % 10;
    if (k == 3) {
        cout << "bon";
    }
    else if ((k == 0)||(k == 1)||(k == 6)||(k == 8)){
        cout << "pon";
    }
    else {
        cout << "hon";
    }
    return 0;
}

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

int main () {
  long long a , b ;
  cin >> a >> b ;
  if(a<=0&&b>=0) cout << "Zero" << endl ;
  else if(0 < a && a<= b ) cout << "Positive" << endl ;
  else {
    if((b-a+1)%2==0) cout << "Positive" << endl ;
    else cout << "Negative" << endl ;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
const int MOD=1000000007;

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

  vector<ll> r(K+1,1);

  ll ans=0;
  for(ll i=K;0<i;i--){
    ll t=K/i; t%=MOD;
    for(int j=0;j<20;j++){
      if((N>>j)&1){
	r[i]*=t; r[i]%=MOD;
      }
      t*=t; t%=MOD;
    }
    
    for(int j=2;i*j<=K;j++){
      r[i]-=r[i*j]; r[i]%=MOD;
    }
    ans+=r[i]*i; ans%=MOD;
    //    cout << i << " " << r[i] << endl;
  }

  cout << (ans+MOD)%MOD << endl;
      
  return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind
{
    vector<int> data;
    int ngroup;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    bool isRoot(int x)
    {
        return data[x] < 0;
    }
    int size(int x)
    {
        return -data[root(x)];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unionSet(a, b);
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (uf.isRoot(i))
        {
            ans++;
        }
    }
    ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(long long i=a;i>=b;i--)
#define adb(a) for(auto ii:a) cout << ii << " "; cout << endl
#define adp(a) for(auto ii:a) cout << ii.F << " " << ii.S << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define PI 3.14159265358979323846
const ll MAXN = 100007;
const ll p = 1000000007;
#define N 200003
#define INF INTMAX_MAX

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};


ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }

bool cmp(const pll &a, const pll &b)
{
    if (a.F != b.F) {
        return a.F > b.F;
    }
    else
        return a.S < b.S;
}


// bool check(ll i, ll j)
// {
//     if (i >= 0 && i < n && j >= 0 && j < m && a[i][j] != '#')
//         return true;
//     return false;
// }

int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        ll n, d;
        cin >> n >> d;
        ll ans = 0;
        REP(i, 0, n)
        {
            ll x, y;
            cin >> x >> y;
        }
        if (n >= 30)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
N, K = map(int, input().split())
H = list(map(int, input().split())) + [0] * K

INF = 10 ** 9
cost = [INF] * (N + 5 + K)
cost[0] = 0
for i in range(0, N):
    for j in range(1, K + 1):
        cost[i + j] = min(cost[i + j], cost[i] + abs(H[i] - H[i + j]))

# print (cost)
print (cost[N - 1])

Measured memory_bytes: 53216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
//#define MOD 1000000007
const int INF = 1LL<<30;

ll dp[110][2][5];

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

    int n=N.size();
    dp[0][0][0]=1;

    rep(dgt,n){
        rep(isless,2){
            rep(k,K+1){
                int c=N[dgt]-'0';
                rep(nxt,10){
                    if(c<nxt && isless==0) continue;

                    int dgt2=dgt+1;
                    int isless2=isless;
                    if(nxt<c) isless2=1;
                    int k2=k;
                    if(nxt!=0) k2++;

                    dp[dgt+1][isless2][k2]+=dp[dgt][isless][k];
                }
            }
        }
    }

    ll ans=dp[n][0][K]+dp[n][1][K];
    cout<<ans<<endl;
}

Measured memory_bytes: 3532
package main

import (
	"fmt"
	"math"
)

var R, G int

func main() {
	fmt.Scan(&R, &G)

	// (R+x)/2 = G
	fmt.Println(2*G - R)
}

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

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

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

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

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

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

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


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BProblemSet {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        multiset<int> S;
        REP(i, N){
            int d;
            in>>d;
            S.insert(d);
        }
        int M;
        in>>M;
        vc<int> T(M);
        for(auto& t : T) in>>t;
        for(auto& t : T){
            auto itr = S.find(t);
            if(itr==S.end()){
                out<<"NO\n";
                return;
            }
            S.erase(itr);
        }
        out<<"YES\n";
    }
};


int main() {
	BProblemSet solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long int ll;
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)

int main() {
	FASTIO;
	string S, T;
	int ans = 1001;
	cin >> S >> T;
	FOR(i, 0, S.size() - T.size()) {
		int cnt = 0;
		FOR(j, 0, T.size() - 1) {
			if (S[i + j] != T[j])
				cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
      
       Scanner scan = new Scanner(System.in);
       
       int S = scan.nextInt();
       
       System.out.print(S / 3600);
       System.out.print(":");
       System.out.print(S % 3600 / 60);
       System.out.print(":");
       System.out.println(S % 3600 % 60 );
   }
}


Measured memory_bytes: 26236
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long int a, b, c, max, ans;
	scanf("%lld %lld %lld", &a, &b, &c);
	if(a >= b && a >= c)
	{
		max = a;
		ans = (a - a / 2) * b * c - (a / 2) * b * c;
		printf("%lld\n", ans);
		return 0;
	}
	if(b >= a && b >= c)
	{
		max = b;
		ans = (b - b / 2) * a * c - (b / 2) * a * c;
		printf("%lld\n", ans);
		return 0;
	}
	if(c >= a && c >= b)
	{
		max = c;
		ans = (c - c / 2) * a * b - (c / 2) * a * b;
		printf("%lld\n", ans);
		return 0;
	}

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll MOD = 998244353;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

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

	int N; cin >> N;
	vector<ll> D(N);
	rep(i, N) cin >> D[i];
	map<ll, ll> mp;
	rep(i, N) {
		ll d = D[i];
		mp[d] += 1;
	}
	if (mp[0] != 1 || D[0] != 0) {
		cout << 0 << endl;
	} else {
		ll ans = 1;
		for(const auto& m: mp) {
			// cout << m.first << endl;
			if (m.first < 1) continue;
			ans *= modpow(mp[m.first-1ll], m.second, MOD);
			ans %= MOD;
		}
		cout << ans % MOD << endl;
	}
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll ans=0;
 vector<ll> vec(5);
  for(ll i=0;i<5;i++) {
cin>>vec[i];
    ans+=vec[i];
  }
  
  vector<ll> R(5);
  for(ll i=0;i<5;i++) {
if(vec[i]%10==0) {
R[i]=0;
}
    else {
R[i]=10-vec[i]%10;
    }
  }
  
  sort(all(R));
  for(ll i=0;i<4;i++) {
ans+=R[i];
  }
  
  cout<<ans<<endl;
}
  
 

Measured memory_bytes: 3620
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n,k,c;cin>>n>>k>>c;
    dump(n, k, c);
    string s;cin>>s;
    dump(s);

    set<int> st;
    rep(i, n){
        if (s[i]=='o'){
            st.insert(i);
        }
    }
    dump(st);

    vector<int> dp(n);
    int M = -1;
    rep(i, n){
        if (s[i]=='o'){
            if (i-c-1>=0) dp[i] = dp[i-c-1]+1;
            else dp[i] = 1;
        }
        else{
            if (i-1>=0) dp[i] = dp[i-1];
            else dp[i] = 0;
        }
        chmax(M, dp[i]);
    }

    vvi a(M+1);
    dump(dp);
    map<int, int> d;
    rep(i, n){
        if (s[i]=='x') dp[i] = -1;
        else{
            d[dp[i]]++;
        }

        if(dp[i]!=-1) a[dp[i]].pb(i);
    }
    dump(dp);
    dump(d);
    dump(a);

    map<int, int> first_pos;
    rrep(i, n){
        first_pos[dp[i]] = i;
    }

    vi rs(M+1, -1);
    rs[M] = a[M].back();
    rrep(m, 1, M){
        int r = rs[m+1];
        rrep(i, sz(a[m])){
            dump(m, i, a[m][i] + c + 1, r);
            if (a[m][i] + c + 1 <= r){
                rs[m] = a[m][i];
                break;
            }
        }
    }
    dump(rs);

    dump(M);
    if (M>k){
    }
    else if (M==k){
        rep(m, 1, M+1){
            if (a[m][0]==rs[m]) {
                cout << a[m][0]+1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 50196
#include "iostream"
using namespace std;

int main(){
	int X, A, B;
	cin >> X >> A >> B;
	if (B<=A){
		cout << "delicious" << endl;
	}
	else{
		if (B - A <= X){
			cout << "safe" << endl;
		}
		else{
			cout << "dangerous" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int count = 0;
    repd(i, 1, n + 1) {
        string temp = to_string(i);
        if (temp.size() % 2 == 1) {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

const int MAXN = 1e3 + 5;
int N;
char A[MAXN][MAXN];

void solve(int n, int k) {
    if(N == 3) {
        string s = ".aaa..a..";
        rep(i, 3) rep(j, 3) {
            A[i][j] = s[i*3+j];
        }
    } else if(n == 4) {
        string s = "aacdbbcdcdaacdbb";
        rep(i, 4) rep(j, 4) {
            A[k + i][k + j] = s[i * 4 + j];
        }
    } else if(n == 5) {
        string s = "aabbab.ccabc..bac..babbaa";
        rep(i, 5) rep(j, 5) {
            A[k + i][k + j] = s[i * 5 + j];
        }
    } else if(n == 6) {
        string s = ".aabbca..e.ca..eddbbc.aae.ca..edda..";
        rep(i, 6) rep(j, 6) {
            A[k + i][k + j] = s[i * 6 + j];
        }
    } else if(n == 7) {
        string s = "..aabc.cc..bc.bb.dd.aa.d...aa.d..bb.cb..cc.cbaa..";
        rep(i, 7) rep(j, 7) {
            A[k + i][k + j] = s[i * 7 + j];
        }
    } else {
        string s = "aacdbbcdcdaacdbb";
        rep(i, 4) rep(j, 4) {
            A[k + i][k + j] = s[i * 4 + j];
        }
        solve(n - 4, k + 4);
    }
}

int main() {
    FAST_IO();
    cin >> N;
    rep(i, N) rep(j, N) A[i][j] = '.';
    if(N == 2) {
        cout << "-1\n";
    } else {
        solve(N, 0);
        rep(i, N) {
            rep(j, N) {
                cout << A[i][j];
            }
            cout << "\n";
        }
    }
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
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(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#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 Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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 ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;


int main(void) {

    int n;
    cin>>n;
    vll v(n);
    rep(i,n)cin>>v[i];
    ll ans=LLINF;
    ll a=v[0];
    ll b=0;
    for(int i=1;i<n;i++)b+=v[i];
    ans=min(ans,abs(a-b));
    for(int i=1;i<n-1;i++){
        a+=v[i];
        b-=v[i];
        ans=min(ans,abs(a-b));
    }
    fin(ans);
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

sum_A = 0
S = []

for i in range(1,N):
    sum_A += A[-1*i]
    S.append(sum_A)

ans = 0

for i in range(N-1):
    tmp = A[N-2-i] * S[i]
    ans += tmp

ans = ans % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 31556
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
N=int(input())
count = 0
A=prime_factorize(N)
if A==0:print(0)
else:
  B=collections.Counter(A)
  C=list(B.values())
  for i in C:
    for j in range(1,N+1):
      if j*(j+1)//2 <= i < (j+1)*(j+2)//2:
        count +=j
        break
print(count)

Measured memory_bytes: 9464
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=100010;
int lim;
int r[N];
int lb,hb;
int tim=0;
lint mn=0,cur=0,mx=0;
inline int go(int x,int d,int t){
	return max(0ll,min((lint)lim,(lint)d*t+x));
}
inline void workto(int d,int t){
	int del=t-tim;
	tim=t;
	lb=go(lb,d,del),hb=go(hb,d,del);
	cur+=(lint)d*del;
	apmin(mn,cur);
	apmax(mx,cur);
}
inline int ask(int x){
	if(x<=-mn)return lb;
	else if(x>=lim-mx)return hb;
	else return x+cur;
}
int main(){
	lb=0,lim=hb=ni;
	int n=ni;
	r[0]=0;
	for(int i=1;i<=n;i++){
		r[i]=ni;
	}
	int d=-1;
	for(int i=1,tot=ni;tot--;){
		int tim=ni;
		for(;i<=n&&r[i]<=tim;workto(d,r[i]),d=-d,i++);
		workto(d,tim);
		printf("%d\n",ask(ni));
	}
	return 0;
}

Measured memory_bytes: 1536
from functools import lru_cache
import sys

sys.setrecursionlimit(1000000)

H, N = map(int, input().split())

AB = []
for i in range(N):
    A, B = map(int, input().split())
    AB.append((A, B))

AB.sort(key=lambda ab: (ab[0] / ab[1], -ab[0]), reverse=True)


@lru_cache(maxsize=None)
def solve(h):
    if h <= 0:
        return 0
    best = float("inf")
    for a, b in AB:
        val = b + solve(h - a)
        if val < best:
            best = val
        else:
            break
    return best


print(solve(H))


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int four=0,two=0,odd=0;
    for(int i=0,a;i<n;i++){
        cin >> a;
        if(!(a%4)){
            four++;
        }
        else if(!(a%2)){
            two++;
        }
        else{
            odd++;
        }
    }
    if(four>=odd){
        cout << "Yes" << endl;
    }
    else{
        if(two==0 && four==odd-1){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int a, b, d, cnt = 0;
    cin >>a>>b >> d;
    for (int i = a; i <= b; i++) {
        if (i % d == 0)cnt++;
    }
    cout << cnt << endl;
}


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

int main() {
    string s;
    cin >> s;
    int x = s.size();
    int i = 0;
    int j = 0;

    for(i = 0; i < x; i++) {
        if(s[i] == 'A') {
            break;
        }
    }

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

    for(j = 0; j < x; j++) {
        if(s[j] == 'Z') {
            break;
        }
    }

    cout << x - (i+j);

    cout << endl;
    return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
a = [int(input()) for _ in range(n)]
b = [0] * n
for _ in range(m):
    v = int(input())
    for i in range(n):
        if a[i] <= v:
            b[i] += 1
            break
print(b.index(max(b)) + 1)


Measured memory_bytes: 5620
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  int a,c=0,e=0;cin>>a;
  string b;cin>>b>>c;
  for(int i=1;i<a;i++){
    c=0;
    for(char d='a';d<='z';d++){
          bool l=false,r=false;
          rep(j,i)if(b[j]==d)l=true;
          rep(j,a-i)if(b[j+i]==d)r=true;
          if(l&&r)c++;
    }
    e=max(c,e);
  }
  cout<<e;
  }


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

int A, B, C, D, E, F, w, s;

int main() {
    scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
    // Go through every possible starting value of water
    for (int a = 0; a <= F; a += A * 100) {
        for (int b = 0; a + b <= F; b += B * 100) {
            for (int c = 0; a + b + c <= F; c += C) {
                for (int d = 0; a + b + c + d <= F; d += D) {
                    // Check if sugar can dissolve in beaker
                    if (a == 0 && b == 0) continue;
                    if ((c + d) * 100 > (a + b) * E) continue;
                    if (w == 0 || s * 1.0 / (w + s) < (c + d) * 1.0 / (a + b + c + d)) {
                        w = a + b;
                        s = c + d;
                    }
                }
            }
        }
    }
    printf("%d %d\n", w + s, s);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main(void){
  int n,k;
  int s[111];
  while(cin >> n >> k && n){
    for(int i = 0; i < k; i++){
      cin >> s[i];
    }
    for(int j = 0; j < n; j++){
      for(int i = 0; i < k; i++){
	int b;
	cin >> b;
	s[i] -= b;
      }
    }
    bool f = true;
    for(int i = 0; i < k; i++){
      if(s[i] < 0){
	f = false;
	cout << "No" << endl;
	break;
      }
    }
    if(f) cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

bool solve()
{
  vector<vector<int>> M(3, vector<int>(3));
  cin >> M;
  REP(i, 3) REP(j, 3) {
    if (M[i][j] + M[0][0] != M[i][0] + M[0][j]) return false;
  }
  return true;
}
int main()
{
  cout << (solve() ? "Yes" : "No") << endl;
}



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

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++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int X,Y;

	cin >> X >> Y;

	cout << X+Y/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	string N;
	int K;
	cin >> N >> K;
	int i,j,k;
	ll dp[N.size()][2][4];
	int tmp=int(N[0])-48;
	for(k=0;k<=3;k++){
		dp[0][0][k]=0;
		dp[0][1][k]=0;
	}
		dp[0][1][0]=1;
		dp[0][0][1]=1;
		dp[0][1][1]=tmp-1;
	for(i=1;i<N.size();i++){
		tmp=int(N[i])-48;
		dp[i][0][0]=0;
		dp[i][1][0]=1;
		for(k=1;k<4;k++){
			if(tmp==0)dp[i][0][k]=dp[i-1][0][k];else dp[i][0][k]=dp[i-1][0][k-1];
			if(tmp==0)dp[i][1][k]=9*dp[i-1][1][k-1]+dp[i-1][1][k];
			else dp[i][1][k]=9*dp[i-1][1][k-1]+dp[i-1][1][k]+(tmp-1)*dp[i-1][0][k-1]+dp[i-1][0][k];
		}
	}
	cout << dp[N.size()-1][0][K]+dp[N.size()-1][1][K];
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int max=1e9+100;
const ll  MAX=1e18+500;
const int sz=2e5+100;
int mark[sz];
vector<int> test;
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        test.clear();
        memset(mark,0,sizeof mark);
        int ara[n+2];
        for(i=1;i<=n;i++) cin>>ara[i];
 
        int ct=0;
        for(i=n;i>=1;i--){
            p=mark[i];
            x=0;
            if(p%2 != ara[i]) ++x,++ct,test.pb(i);
            if(x>0){
                int sq=sqrt(i);
                for(j=1;j<=sq;j++){
                    if(i%j==0){
                        ++mark[j];
                        if(j*j != i) ++mark[i/j];
                    }
                }
            }
        }
        reverse(test.begin(),test.end());
        cout<<ct<<endl;
        if(test.size()>0){
        for(auto xx: test) cout<<xx<<" ";
        cout<<endl;
        }
      
        
    }
 
 
 
 
 
}

Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct MinimumCostFlow {
	using Flow = int;
	using Cost = int;
	struct Edge {
		int to, rev;
		Flow cap;
		Cost cost;
		Edge() {}
		Edge(int to, int rev, Flow cap, Cost cost) :to(to), rev(rev), cap(cap), cost(cost) {}
	};
	int n;
	vector<vector<Edge>> g;
	vector<int> dist;
	vector<int> prevv, preve;
	MinimumCostFlow(int n) :n(n), g(n), dist(n), prevv(n), preve(n) {}
	void addArc(int from, int to, Flow cap, Cost cost) {
		g[from].emplace_back(to, (int)g[to].size(), cap, cost);
		g[to].emplace_back(from, (int)g[from].size() - 1, 0, -cost);
	}
	// s??????t????????????f???????°??????¨???
	// ??????????????´?????? -1
	Cost minimumCostFlow(int s, int t, Flow f) {
		Cost total = 0;
		while (f > 0) {
			// Bellman-Ford
			fill(dist.begin(), dist.end(), INF);
			dist[s] = 0;
			bool update = true;
			while (update) {
				update = false;
				for (int v = 0; v < n; v++) {
					if (dist[v] == INF)continue;
					for (int i = 0; i < g[v].size(); i++) {
						Edge &e = g[v][i];
						if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i;
							update = true;
						}
					}
				}
			}
			// ????????\???????????????
			if (dist[t] == INF)
				return -1;
			// ?????????????????£??????????????????
			int d = f;
			for (int v = t; v != s; v = prevv[v])
				d = min(d, g[prevv[v]][preve[v]].cap);
			f -= d;
			total += d*dist[t];
			for (int v = t; v != s; v = prevv[v]) {
				Edge &e = g[prevv[v]][preve[v]];
				e.cap -= d;
				g[v][e.rev].cap += d;
			}
		}
		return total;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> p(n); rep(i, 0, n) {
		cin >> p[i];
	}
	MinimumCostFlow mcf(n + n + 2);
	int s = n + n, t = s + 1;
	rep(i, 0, n) {
		mcf.addArc(s, i, 1, 0);
		mcf.addArc(n + i, t, 1, 0);
	}
	rep(i, 0, n) {
		rep(j, 0, n) {
			if (j == p[i] - 1)continue;
			mcf.addArc(i, n + j, 1, p[i] * abs(i - j));
		}
	}
	cout << mcf.minimumCostFlow(s, t, n) << endl;
	return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    
    int mina = INT_MAX, minb = INT_MAX;
    for (int i=0; i<A; ++i) {
        cin >> a[i];
        mina = min(mina, a[i]);
    }
    for (int i=0; i<B; ++i) {
        cin >> b[i];
        minb = min(minb, b[i]);
    }

    int mn = mina + minb;
    for (int i=0; i<M; ++i) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        mn = min(mn, a[x] + b[y] - c);
    }
    cout << mn << endl;
    
    return 0;
}

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

using namespace std;

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

    int N, K;
    cin >> N >> K;
    if (K > (N - 1) * (N - 2) / 2) {
        cout << "-1\n";
        return 0;
    }
    vector<pair<int, int>> e;
    for (int i = 2; i <= N; ++i) {
        e.emplace_back(1, i);
    }
    int curk = (N - 1) * (N - 2) / 2;
    for (int u = 2; curk > K && u <= N; ++u) {
        for (int v = u + 1; curk > K && v <= N; ++v) {
            e.emplace_back(u, v);
            --curk;
        }
    }
    cout << e.size() << "\n";
    for (const auto &p : e) {
        cout << p.first << " " << p.second << "\n";
    }

    return 0;
}

Measured memory_bytes: 384
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rgL2kk@5WGjqANJCc6oZ1)N>v0s^nlb;A3#x+#7<(>*x)#U{=VzlC8n?^XJ#@xyLPSB4ytd{DmmX5x)6d1sQ7NLw1K@YWW(a9wj#mHYTg;j)tPUYsoFvl6mn^50v$6$+2i5!?S1{aM!-<jn>eZ{t3fE)Y@RZ##TKXst-)rI`Pu^h9!K6MalaF|@H~rCZ-Korl1x&Ns^KD!BfvUSC4mZ7kU99+a=~EXMYc*L{Uk{`!n{Ui36IY?l$sS^BV*kvc)%bqMa>K~j?~QbT0-S>4T@7JC{1h%PJY9jE<?IB9F{APK_t52TbQok6vVOL9PVMpgLOjJ@0|UO;ho_B=p0@k3wm|d*ftD%&Bk8AU|q0qX_sJ^PT(*eaZ0?dp1=@CM{e4SP_@$N%B6o-iA;019$e#sIE(bQ^pFOL&0oI}>aU^U8p10zxqqz5<WA5JIU&C*98$bSd+5_Z&qT*u#NI_5ko*DG!`1i")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 16720
n, m = map(int, input().split())
p=list(map(int, input().split()))

par=[-1]*n

def find(x):
    if par[x]<0:
        #自分が親
        return x
    else:
        #再帰的に辿って、行き着いた先が親
        par[x]=find(par[x])
        return par[x]

def union(x, y):
    p,q=find(x), find(y)
    if p==q:
        return
    if p > q:
        p,q=q,p
    par[p]+=par[q]
    par[q]=p

def same(x,y):
    return find(x)==find(y)

for i in range(m):
    x, y = map(int,input().split())
    x-=1
    y-=1
    union(x,y)

ans=0

for i in range(n):
    if p[i]==i+1:
        ans+=1
        continue
    if same(i, p[i]-1):
        ans+=1

print(ans)

Measured memory_bytes: 20456
n,m,X,Y=map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))
judge=0
for i in range(X+1, Y+1):
    xc=0
    yc=0
    for j in range(n):
        if x[j]<i:
            xc+=1
    for k in range(m):
        if y[k]>=i:
            yc+=1
    if xc==n and yc==m:
        judge+=1
        break
if judge==0:
    print("War")
else:
    print("No War")

Measured memory_bytes: 8960