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

int LinearSearch(int S[], int n, int t){
    S[n] = t;
    int i = 0;
    while(S[i] != S[n]) i++;
    return (i != n);
}

int main(void){
    int n, q, t;
    int c = 0;
    cin >> n;
    int S[n];
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    cin >> q;
    int same_number[q];
    bool second_time;
    for(int i = 0; i < q; i++){
        cin >> t;
        second_time = false;
        for(int j = 0; j < c; j++){
            if(same_number[j] == t) second_time = true;
        }
        if(LinearSearch(S, n, t) && !second_time){
            same_number[c] = t;
            c++;
        }
    }
    cout << c << endl;
    return 0;
}


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



int a[120];
int main(){
	int n;
	cin >> n;
	double sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		sum += 1.0 / a[i];
	}	
	printf("%lf\n",1.0 / sum);
    return 0;  
}


Measured memory_bytes: 256
var data = [];
function init(n) {
    for (var i = 0; i < n * 2 - 1; i++) data[i] = 0;
}
function getSum(s, t, k, l, r) {
    if (r <= s || t <= l) return 0;
    if (s <= l && r <= t) return data[k];

    var mid = Math.floor((l + r) / 2);
    var lv = getSum(s, t, k * 2 + 1, l, mid);
    var rv = getSum(s, t, k * 2 + 2, mid, r);

    return lv + rv;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');

var items = lines.shift().trim().split(' ');
var n = +items[0];
var q = +items[1];

var m = 1;
while (m < n) m *= 2;

function add(i, x) {
    i += m - 1;
    data[i] += x;
    while (i > 0) {
        i = Math.floor((i - 1) / 2);
        var c1 = data[i * 2 + 1];
        var c2 = data[i * 2 + 2];
        data[i] = c1 + c2;
    }
}

init(m);

var line;
while (line = lines.shift()) {
    var com = line.trim().split(' ').map(function(n){return +n;});
    if (com[0] == 0) {
        add(com[1] - 1, com[2]);
    } else {
        console.log(getSum(com[1] - 1, com[2], 0, 0, m));
    }
}

Measured memory_bytes: 56680
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int cnt = 0;
    ll N; cin >> N;
    while (N > 0) {
        N /= 2; cnt++;
    }
 
    cout << (1ll << cnt) - 1 << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343
 

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

int main(void){
    std::string a;
    int length;
    std::cin>>a;
    length=a.size();
    int tap=0;
    for(int i=0;i<length;i++){
        if(i%2==1 & (a.substr(i,1)== "L" | a.substr(i,1)== "U" |a.substr(i,1)== "D")){
            tap++;
        }
        if(i%2==0 & (a.substr(i,1)== "R" | a.substr(i,1)== "U" |a.substr(i,1)== "D")){
            tap++;
        }   
    }

    if(tap==length){
        std::cout<<"Yes";
    }
    else{
        std::cout<<"No";
    }

    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;
 
 
 
 
int main(){
  int x, y;
  cin >> x >> y;
  for (int i = -1 * x + 1; i < x-1; i++){
    cout << i + y << " ";
  }
  cout << x + y - 1 << endl;
}

Measured memory_bytes: 256
from fractions import gcd
T,*L = map(int, open(0).read().split())
for a,b,c,d in zip(*[iter(L)]*4):
  if b>d:
    print('No')
    continue
  if a<b:
    print('No')
    continue
  if c>b:
    print('Yes')
    continue
  g = gcd(b,d)
  x = a-b
  M = ((c-x)//g+1)*g+x
  if M>=b:
    print('Yes')
  else:
    print('No')


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,K;
ll ans;
int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>K;

if(K==0){
	cout<<N*N<<endl; return 0;
}

for(ll b=K+1; b<=N; b++){
	ll add1=(N/b)*(b-K);
	ll add2=N%b-(K-1);
	ans+=add1;
	if(N%b>=K) ans+=add2;
}

cout<<ans<<endl;



}
	


Measured memory_bytes: 256
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

WEATHER = ["Sunny", "Cloudy", "Rainy"]

def next_weather(s):
    return WEATHER[(WEATHER.index(s)+1)%len(WEATHER)]

def main():
    s = input()
    print(next_weather(s))

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import numpy as np
N = int(input())
mod = 10**9 + 7

logs = np.zeros((N+1, 4, 4, 4))
logs[0,3,3,3] = 1

for length in range(1, N+1):
#    tmp_for_debug = logs[length-1,:,:,:]
#    print(tmp_for_debug)
#    print("\n\n\n")
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                if logs[length-1, c1, c2, c3] == 0:
                    continue
                for n in range(4):
                    if n == 2 and c1 == 1 and c2 == 0:  continue
                    if n == 1 and c1 == 2 and c2 == 0:  continue
                    if n == 2 and c1 == 0 and c2 == 1:  continue
                    if n == 2 and c2 == 1 and c3 == 0:  continue
                    if n == 2 and c1 == 1 and c3 == 0:  continue
                    
                    logs[length, n, c1, c2] += logs[length - 1, c1, c2, c3]
                    logs[length, n, c1, c2] %= mod

M = int(np.sum(logs[N])) % mod
print(M)


Measured memory_bytes: 12508
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e4 + 50;
const int mod = 1e9+7;
int a[2005];
ll pre[2005]={0},net[2005]={0};
ll cal(ll k){
	return (1+k)*k/2%mod;
}
int main(){
	ll N,K;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		sfi(a[i]);
	}
	ll mul=cal(K),mul1=(mul-K+mod)%mod;
	for(int i=0;i<N;i++){
		for(int j=0;j<i;j++){
			if(a[j]<a[i]) pre[i]++;
		}
		for(int j=i+1;j<N;j++){
			if(a[j]<a[i]) net[i]++;
		}
	}
	ll ans=0;
	for(int i=0;i<N;i++){
		ans=(ans+net[i]*mul%mod)%mod;
		ans=(ans+pre[i]*mul1%mod)%mod;
	}
	ans=(ans+mod)%mod;
	pfl(ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    vector<int> a(n), b(m);
    for(int i=0; i<n; i++) scanf("%d", &a[i]);
    for(int i=0; i<m; i++) scanf("%d", &b[i]);
    auto c=convolution(a, b);
    for(int i=0; i<n+m-1; i++){
        printf("%d ", c[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 19040
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    map<int,int> m;
    LL ans = 0;
    REP(i,0,n) {
        if (m.count(i-a[i]) > 0) ans += m[i-a[i]];
        m[i+a[i]]++;
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 13848
def main():
    num = list(map(int, input().split()))
    tmp = [num[1]+num[2], num[0]+num[2], num[0]+num[1]]
    if num[3] % 2 == 1:
        print(tmp[0]-tmp[1])
    else:
        print(num[0]-num[1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pf push_front
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

// city, coins
int dp[51][2501];
int c[51], d[51];

#define piii pair<int, pii>

vector<piii> adj[51];
vector<pii> ex(51);

void solve(){
    int n, m, s; cin>>n>>m>>s;
    if(s > 2500){
        s = 2500;
    }
    For(i, 0, m){
        int u, v, a, b; cin>>u>>v>>a>>b;
        adj[u].pb({v, {a, b}});
        adj[v].pb({u, {a, b}});
    }
    For(i, 1, n+1){
        cin>>c[i]>>d[i];
    }
    For(i, 0, 51){
        For(j, 0, 2501){
            dp[i][j]=INF;
        }
    }
    deque<pii> q;
    dp[1][s]=0;
    q.pb({1, s});
    while(!q.empty()){
        pii p = q.front();
        q.pop_front();
        int u = p.F;
        int coins = p.S;
        for(piii p: adj[u]){
            int v = p.F;
            int cost = p.S.F;
            int tim = p.S.S;
            if(cost <= coins){
                if(dp[v][coins-cost]>dp[u][coins]+tim){
                    q.pf({v, coins-cost});
                    dp[v][coins-cost]=dp[u][coins]+tim;
                }
            }
        }
        if(coins+c[u]<=2500){
            if(dp[u][coins+c[u]]>dp[u][coins]+d[u]){
                dp[u][coins+c[u]]=dp[u][coins]+d[u];
                q.pb({u, coins+c[u]});
            }
        }
    }
    For(i, 2, n+1){
        int ans = INF;
        For(j, 0, 2501){
            ans = min(ans, dp[i][j]);
        }
        cout<<ans<<"\n";
    }
}

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    solve();
    return 0;
}






Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

long long shakutori(vector<long long> a, long long n) {
    long long res = 0;

    int right = 0, sum = 0;
    for (int left = 0; left < n; left++) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum += a[right];
            right++;
        }

        res += (right - left);

        if (right == left) right++;
        else {
            sum -= a[left];
        }
    }

    return res;
}

int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    cout<<shakutori(a, n)<<endl;
    return 0;
}


Measured memory_bytes: 3328
module Main where

import           Data.Maybe                     ( fromJust )
import           Data.List
import qualified Data.ByteString.Char8         as BS


bytestr2Int = fst . fromJust . BS.readInt
getIntL_H = map bytestr2Int . BS.words <$> BS.getLine


main :: IO ()
main = do
    [x, y] <- getIntL_H
    print $ cucable x y

cucable x y = if x < 10 && y < 10 then x * y else (-1)


Measured memory_bytes: 380
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    if(N < 1000) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define mod 1000000007
    using namespace std;
    #define LL long long int
    int main() 
    {
     LL N;
        cin >> N;
        vector< bool > v;
        for(LL i=0;i<N;i++)
        {
            LL x;
            LL y;
            cin >> x >> y;
            v.push_back(x==y);
        }
        bool  flag=false;
        for(LL i=0;i<=N-3;i++)
        {
     
            if(v[i]==true and v[i+1] and v[i+2])
            {
                flag=true;
                break;
            }
        }
        if(flag)
            cout<<"Yes";
        else
            cout<<"No";
    }

Measured memory_bytes: 3624
#include <cstdio>

int a[40] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    // freopen("a.in", "r", stdin);

    int k; scanf("%d", &k);
    printf("%d\n", a[k - 1]);
    
    return 0;
}

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


int main() {
	

   ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int a, b; cin >> a >> b; 
   if(a * 500 >= b) cout << "Yes" << endl;
   else cout << "No" << endl;
    	
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.io.IOException;
import java.util.NoSuchElementException;
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;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskB {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int n = sc.nextInt();
			HashSet<String> set = new HashSet<>();
			for (int i = 0; i < n; i++) {
				set.add(sc.next());
			}

			out.println(set.size() == 3 ? "Three" : "Four");

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			byte b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

	}
}



Measured memory_bytes: 21588
#include <stdio.h>
int main(){

  int tou,H,W,add,n,i,j,k,m=0;
  int p[4][3][10]={0};

  

  scanf("%d",&n);

  for (m = 0; m < n; m++){

    scanf("%d %d %d %d",&tou,&H,&W,&add);

    p[tou-1][H-1][W-1]=p[tou-1][H-1][W-1]+add;

  }

  

  for (k = 0; k < 3; k++){

    for (j = 0; j < 3; j++){
      
      for (i = 0; i < 10; i++){
	
	printf(" %d",p[k][j][i]);
	
      }
      
      printf("\n");
      
    }

    printf("####################\n");

  }
  
  for (j = 0; j < 3; j++){
    
    for (i = 0; i < 10; i++){
      
      printf(" %d",p[3][j][i]);
      
    }
    
    printf("\n");
    
  }

  return 0;

}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

  string N;
  cin>>N;
  int a;
  a=N.size();
  int b,c,d;
  int answer=0;
  rep(i,a){
    b=N[i]-48+d;
    if(i!=a-1){
      c=N[i+1]-48;
      if(b<=4||(b==5&&c<=4)){
        d=0;
        answer+=b;
      }
      else{
        d=1;
        answer+=10-b;
      }
    }
    else{
      if(b<=5)
        answer+=b;
      else 
        answer+=10-b+1;
    }
  }
  cout<<answer;
         
  
}

Measured memory_bytes: 1412
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    int a, b;
    char s[12];

    scanf("%d %d %s", &a, &b, s);
    int isCheck = 1;
    for (int i = 0; i < strlen(s); i++) {

        //printf("%c", s[i]);

        if (i == a) {
            if (s[i] != '-') {
                isCheck = 0;
                break;
            }
        } else {

            if (!((s[i] - '0') >= 0 && (s[i] - '0') <= 9)) {
                isCheck = 0;
                break;
            }

        }

    }

    printf("%s", (isCheck == 1 ? "Yes" : "No"));

    return 0;

}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
int n , a[85];
int main() {
    abdelrahman010
    cin >> n;
    for(int i = 0;i < n;i++)
        cin >> a[i];
    ll k = 1000 , s = 0;
    int cur = 0;
    for(int i = 0;i < n;i++) {
        int j = i + 1;
        if(!cur) {
            while(j < n && a[j] < a[j - 1])
                j++;
            j--;
            if(j != n - 1)
                s += k / a[j] , k %= a[j];
        } else {
            while(j < n && a[j] > a[j - 1])
                j++;
            j--;
            k += s * a[j] , s = 0;
        }
        cur ^= 1 , i = j;
    }
    cout << k;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int K;
    string S;
    cin >> K >> S;
    if(S.length() <= K) {
        cout << S << endl;
    }
    else {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
//#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long


using namespace std;

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


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[9] = { 0, 0,0,1,1,1,-1,-1,-1 };
int dyy[9] = { 0, 1,-1,0,1,-1,0,1,-1 };

const int MOD = 1e9 + 7;


int x[100010], y[100010];
signed main() {
	int N, M; cin >> N >> M;
	REP(i, N)cin >> x[i];
	REP(i, M)cin >> y[i];
	int res1 = 0, res2 = 0;
	REP(i, N) {
		res1 += (1 - N + 2 * i)*x[i] % MOD;
		res1 %= MOD;
	}
	REP(i, M) {
		res2 += (1 - M + 2 * i)*y[i] % MOD;
		res2 %= MOD;
	}
	ll ans = res1 * res2%MOD;
	print(ans);
}




Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define mod 1000000007

ll n,k;
ll a[212345];
char z;

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

int main(){
  scanf("%lld%lld",&n,&k);

  
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);}
  
  
  sortup(a,n);
  
  ll right=n-1,left=0;
  ll count=k;
  ll ans=1;
  if(a[right]>=0 || k%2==0){
    //printf("right\n");
  while(count>0){
    if(count>=2){
      if(a[right]*a[right-1]>a[left]*a[left+1] && !(k%2==1 && a[right-2]<=0)){
	ans = ans*a[right]%mod*a[right-1]%mod;
	right-=2;}
      else{
	ans = a[left]*a[left+1]%mod*ans%mod;
	left+=2;}
      count-=2;}
    else{
      ans = (ans*a[right]+mod)%mod;
      right--;
      count--;}
  }
  }
  else{
    //printf("left\n");
    while(count>0){
      if(count>=2){
	ans = a[right]*a[right-1]%mod*ans%mod;
	right-=2;
	count-=2;}
      else{
	ans*=a[right];
	right--;
	ans=(ans+mod)%mod;
	count--;}
    }}
  ans = (ans+mod)%mod;
    
  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 4636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    string s;
    cin >> s;
    

    string ans = "Yes";
    if (s.size()<4) ans="No";
    else if (s.substr(0,4)!="YAKI") ans = "No" ;
    cout << ans<< endl; 

   return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            int val = 0;
            foreach (var d in N)
            {
                val += int.Parse(d.ToString());
            }

            if (val %9 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 32888
#include <cstdio>
int main(){int n,r,i;while(scanf("%d",&n)&&n){r=-n;for(i=1;i*i<=n;i++)if(n%i==0){r+=i+n/i;if(i==n/i)r-=i;}printf("%s",n>r?"deficien":n<r?"abundan":"perfec");puts("t number");}}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char **argv)
{
    int N, K;
    cin >> N >> K;
    int h[N];
    for (int i = 0; i < N; ++i) cin >> h[i];

    int dp[N + K + 1];
    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        int minCost = 1000000000;
        for (int j = 0; j < K && (i - 1 - j) >= 0; ++j) {
            int tmp = dp[i - 1 - j] + abs(h[i - 1 - j] - h[i]);
            if (minCost > tmp) minCost = tmp;
        }
        dp[i] = minCost;
    }

    cout << dp[N - 1];

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
# define M_PI 3.14159265358979323846
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 4;
const ll MOD = 998244353;
bool visited[N];
vector<int> edge[N];
vector<int> conc[N];
int c = 0, f = 1;

ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % MOD;
        exponent = exponent >> 1;
        base = (base * base) % MOD;
    }
    return result;
}

ll Inv(ll x){
    return POW(x, MOD - 2);
}

void DFS(int src){
    visited[src] = 1;
    conc[c].pb(src);
    for(auto i : edge[src]){
        if(!visited[i]) DFS(i);
    }
}

int main(){
    int n, m;
    cin>>n>>m;
    int h[n + 1];
    rep(i, 1, n + 1) cin>>h[i];
    vector<int> edge[n + 1];
    rep(i, 0, m){
        int x, y;
        cin>>x>>y;
        edge[x].pb(y);
        edge[y].pb(x);
    }
    int c = 0;
    rep(i, 1, n + 1){
        int f = 1;
        for(auto j : edge[i]){
            if(h[j] >= h[i]){
                f = 0;
                break;
            }
        }
        if(f) c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 18540
/* kadai3_4
   reo012 */

#include<stdio.h>

int main(void){
  int num;
  // 整数numを取得
  scanf("%d", &num);

  // numが1のときは"Yes"と出力、2以上のときは9~2で割って
  // 割り切れたとき商が1~9であるかを確認
  int i=9;
  int check=0;
  if(num==1){
    check=1;
  }else{
    while(i>=2){
      if(num%i==0 && 1<=num/i && num/i<=9){
        check=1;
        break;
      }
      i--;
    }
  }
  // check==0で"No",check==1で"Yes"を出力
  if(check==0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# Here your code !

while True:
    x,y = list(map(int, input().split()))
    
    if x == 0 and y == 0:
        break
    
    if x < y:
        print(str(x) + " " + str(y))
    else:
        print(str(y) + " " + str(x))

Measured memory_bytes: 7560
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
using namespace std;
//--------------------

int main() {
	long X; cin >> X;
	long res = 2;
	while (X) {
		res += 1;
		res *= 2;
		X--;
	}
	cout << res << endl;
}

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

/*
 * Point
 * - a以上b以下の整数のうち，条件を満たすものの個数を求める系問題では
 *   f(n) := 0以上n以下の整数のうち条件を満たすものの個数
 *   という関数を定義しておくことでf(b) - f(a-1)で求められる．ただしa = 0のとき
 *   f(-1)が呼ばれることに注意すること．
 */

using ull = unsigned long long;

ull a, b, x;

ull f(ull p) {
    if (p == -1) {
        return (ull)0;
    } else {
        return (ull)p/x + (ull)1;
    }
}

int main() {
    cin >> a >> b >> x;
    cout << f(b) - f(a-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=1000+19;
const int p=1e9+7;

int Pow(int a,ll b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p) if (b&1) res=1ll*res*a%p;
	return res;
}

char s[N][N],t[N][N];
int n,m,cnt,v1,v2,chk1,chk2;
ll k;

struct Matrix{
	int s[3][3];
} F,A;

Matrix operator * (Matrix A,Matrix B){
	Matrix C;
	For(i,0,3) For(j,0,3){
		C.s[i][j]=0;
		For(k,0,3) C.s[i][j]=(C.s[i][j]+1ll*A.s[i][k]*B.s[k][j])%p;
	}
	return C;
}
Matrix Pow(Matrix A,ll b){
	Matrix res;
	For(i,0,3) For(j,0,3) res.s[i][j]=(i==j);
	for (;b;b>>=1,A=A*A) if (b&1) res=res*A;
	return res;
}

int main(){
	n=IN(),m=IN();
	cin>>k;
	if (k<=1){
		puts("1");
		return 0;
	}
	For(i,1,n+1) scanf("%s",s[i]+1);
	For(i,1,m+1) if (s[1][i]=='#'&&s[n][i]=='#') chk1=1;
	For(i,1,n+1) if (s[i][1]=='#'&&s[i][m]=='#') chk2=1;
	For(i,1,n+1) For(j,1,m+1) if (s[i][j]=='#') cnt++;
	if (!chk1&&!chk2){
		printf("%d\n",Pow(cnt,k-1));
		return 0;
	}
	if (chk1&&chk2){
		puts("1");
		return 0;
	}
	if (chk1){
		For(i,1,n+1) For(j,1,m+1) t[j][i]=s[i][j];
		memcpy(s,t,sizeof(t));
		swap(n,m);
	}
	For(i,1,n+1) For(j,1,m) if (s[i][j]=='#'&&s[i][j+1]=='#') v1++;
	For(i,1,n+1) if (s[i][1]=='#'&&s[i][m]=='#') v2++;
	F.s[0][0]=1;
	F.s[0][1]=0;
	F.s[0][2]=1;
	A.s[0][0]=cnt;
	A.s[1][1]=cnt;
	A.s[2][1]=v1;
	A.s[2][2]=v2;
	F=F*Pow(A,k-1);
	printf("%d\n",(F.s[0][0]-F.s[0][1]+p)%p);
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		vector<int> w(n), sum(n);
		for (int i = 0; i < n; i++) {
			cin >> w[i];
			sum[i] = i ? sum[i - 1] + w[i] : w[i];
		}
		vector<vector<int>> DP(n + 1, vector<int>(n + 1));
		for (int i = 0; i + 1 <= n; i++) {
			DP[i][i + 1] = 0;
		}
		for (int i = 0; i + 2 <= n; i++) {
			DP[i][i + 2] = abs(w[i] - w[i + 1]) <= 1 ? 2 : 0;
		}
		for (int k = 3; k <= n; k++) {
			for (int i = 0; i + k <= n; i++) {
				for (int j = i + 1; j + 1 <= i + k; j++) {
					if (k % 2 == 0 && DP[i + 1][i + k - 1] == k - 2 && abs(w[i + k - 1] - w[i]) <= 1) DP[i][i + k] = DP[i + 1][i + k - 1] + 2;
					else DP[i][i + k] = max(DP[i][i + k], DP[i][j] + DP[j][i + k]);
				}
			}
		}
		cout << DP[0][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3244
N = int(input())
p_l = [0] + [int(i) for i in input().split()] + [0]
s0 = 0
ans = ''

for i in range(N+1):
	s0 += abs(p_l[i+1] - p_l[i])

for i in range(1, N+1):
	s = s0 - abs(p_l[i+1]-p_l[i]) - abs(p_l[i]-p_l[i-1]) + abs(p_l[i+1]-p_l[i-1])
	ans += str(s)+'\n'

print(ans[:-1])

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define M 1000000007
ll mod(ll x){
return ((x%M + M)%M);
}
ll add(ll a,ll b){
return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b){
return mod(mod(a)*mod(b));
}

// ....................................................................................
int dp[100001];
int fun(int a[],int i){
    if(i==0)
    return 0;
    if(dp[i]!=-1)
    return dp[i];

   if(i-2>=0){
        return dp[i] = min(abs(a[i]-a[i-1])+fun(a,i-1),abs(a[i]-a[i-2])+fun(a,i-2));
   }
    return dp[i] = abs(a[i]-a[i-1])+fun(a,i-1);
}
int main()
{
    FIO
    ll t;
    t=1;
    // cin>>t;
    while(t--)
    {
     int n;
     cin>>n;
     int a[n];
     fo(0,n)
     cin>>a[i];
     memset(dp,-1,sizeof(dp));
     dp[0]=0;
     cout<<fun(a,n-1)<<endl;
    }
}

Measured memory_bytes: 8268
N,K = map(int,input().split())
#サイコロが出た面を１から計算
ans = 0
for i in range(1,N+1):
    num = 0
    # iに２の何乗を掛けるとKを超えるか
    j = 0
    while True:
        if i * 2 ** j >= K:
            num = j
            break
        j += 1
    ans += (1/N) * (1/2) ** num
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  int k[n+1]={0};
  REP(i,m){
    int a;
    scanf("%d",&a);
    k[a] = 1;
  }
  ll dp[n+1]={0};
  dp[0] = 1;
  for(int now=0; now < n; ++now){
    for(int next=now+1; next <= min(n, now+2); ++next){
      if(1 - k[next]){
        dp[next] += dp[now];
        dp[next] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
}

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

using namespace std;

int main(){
    int n=0;
    vector<int> s;
    int inputS;
    int sum;
    bool tf=false;
    int search=0;

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>inputS;
        s.push_back(inputS);
    }

    for(int i=0;i<n;i++){
        if(s[i]%10==0){
            search++;
        }
    }
    if(search==n){
        tf=true;
    }

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

    for(int j=0;j<n;j++){
        if(j==0){
            for(int i=0;i<n;i++){
                sum+=s[i];
            }
        }
        
        if(sum%10==0){
            if(s[j]%10!=0||tf){
                sum-=s[j];
            }
        }
        else{
            break;
        }
    }

    cout<<sum<<endl;

    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a,b,c;
  cin>>a>>b>>c;
  ll cnt=0;
  while(a%2==0&&b%2==0&&c%2==0){
    if(a==b&&b==c){
      cnt=-1;
      break;
    }
    
    ll ta=a;
    ll tb=b;
    ll tc=c;
    a=(tb+tc)/2;
    b=(ta+tc)/2;
    c=(ta+tb)/2;
    cnt++;
  }
  
  cout<<cnt<<endl;
  
}

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

using namespace std;

int main(){

  int i;
  string S,T,U;
  
  //cin>>S>>T;
  cin>>S;
  //cin>>U;

  //  cout<<S<<endl;
  
    for(i=0;i<S.length();i++){
      //     cout<<i<<S[i]<<endl;
  }
    for(i=0;i<S.length()-1;i++){
  if(S[i]!=S[i+1]){
    cout<<"Yes"<<endl;
    return 0;
  }
  }
  cout<<"No"<<endl;
  return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B; 
    string s,t = "";
    int res=0;
    for (int i=A; i<=B; i++) {
        s = to_string(i);
        t = to_string(i);
        reverse(s.begin(), s.end());
        if (s==t) res++;
    }
    cout << res;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

map<string,int> dp;
int dir[4]={-4,4,-1,1};//上下左右
void bfs()
{
    queue<string> que;
    dp["01234567"]=0;
    que.push("01234567");

    while(!que.empty())
    {
        string now=que.front();que.pop();
        int p=0;
        for(int i=0;i<8;i++)
        {
            if(now[i]=='0')
            {
                p=i;
                break;
            }
        }

        for(int i=0;i<4;i++)
        {
            int t=p+dir[i];
            if(t<=7&&t>=0&&!(p==3&&i==3)&&!(p==4&&i==2))
            {
                string next=now;
                swap(next[p],next[t]);
                if(dp.find(next)==dp.end())
                {
                    que.push(next);
                    dp[next]= dp[now]+1;
                }
            }
        }
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    bfs();
    string line;
    while (getline(cin, line))
    {
        line.erase(remove(line.begin(), line.end(), ' '), line.end());
        cout << dp[line] << endl;
    }
    return 0;
}



Measured memory_bytes: 5196
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n, k, a;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a;
	cout << (n - 2) / (k - 1) + 1 << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys

x = input().split(" ")
ans = 0

n = int(x[0])
b = int(x[1])
r = int(x[2])

set = n // (b + r)
ama = n % (b + r)

ans = set * b

if ama < b :
    ans = ans + ama
else :
    ans = ans + b

print(ans)

Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String[] tmpArray = br.readLine().split(" ");
		
		int a[] = new int[n + 1];
		int b[] = new int[n];
		
		for(int i = 0; i < n + 1; i++){
			a[i] = Integer.parseInt(tmpArray[i]);
		}

		tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			b[i] = Integer.parseInt(tmpArray[i]);
		}
		
		long result = 0;
		//左から倒すだけ？
		for(int i = n - 1; i >= 0; i--){
			int right = Math.min(a[i + 1], b[i]);
			
			result += right;
			b[i] -= right;
			
			int left = Math.min(a[i], b[i]);
			
			result += left;
			a[i] -= left;
		}
		
		System.out.println(result);
	}

}


Measured memory_bytes: 56688
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main() {
  int N;
  cin>>N;
  if(N%2==0) cout<<0.5<<endl;
  else{
    double M=N,ans=N+1;
    ans=ans/(2*N);
    printf("%.6f",ans);
  }
}



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

using namespace std;

int main(void){

  double n;
  while( cin >> n ){

    double ans = n;
    for( int i = 2 ; i <= 10 ; i++ ){
      if( i % 2 == 0 ){
	n *= 2;
	ans += n;
      }
      else {
	n /= 3; 
	ans += n;
      }
    }
    printf("%.8f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1232
n = int(input())
l =[]
for i in range(n):
  l.append(list(input().split()))
  l[i][1] = int(l[i][1])
  l[i].append(i+1)
l.sort(key=lambda x:(x[0],-x[1]))
#l.sort(key=lambda x:x[1],reverse=True)
for i in range(n):
  print(l[i][2])

Measured memory_bytes: 38384
n,y = map(int,input().split())
for a in range(n+1):
    for b in range(n+1):
        if 10000*a + 5000*b + 1000*(n-(a+b)) == y and n-(a+b) >= 0:
            print(a,b,n-(a+b))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
    int n;
    int m[3001];
    long long dp[3001][3001][2];
    long long solve(int start,int end,int k)
    {
        //System.out.println(start+" "+end+" "+k);
        if(start>end)
            return 0;
        if(dp[start][end][k]!=-1)
            return dp[start][end][k];
        if(k==0)
        {
            dp[start][end][k]=max(solve(start+1,end,1)+m[start],solve(start,end-1,1)+m[end]);
        }
        else
        {
            dp[start][end][k]=min(solve(start+1,end,0)-m[start],solve(start,end-1,0)-m[end]);
        }
        return dp[start][end][k];
    }
    int main()
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        cin>>m[i];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
            {
                for(int k=0;k<=1;k++)
                    dp[i][j][k]=-1;
            }
        }
        cout<<solve(1,n,0)<<endl;
        return 0;
    }


Measured memory_bytes: 141056
#include<iostream>
#include<cstdio>
using namespace std;
int a[300005];
int b[2][300005];
char c[300005];
int main()
{
	int n;
	cin>>n;
	cin>>c;
	for(int i=0;i<n;i++)
	{
		b[0][i+1]=b[0][i];
		if(c[i]=='W') b[0][i+1]++;
	}
	for(int i=n-1;i>=0;i--)
	{
		b[1][i+1]=b[1][i+2];
		if(c[i]=='E') b[1][i+1]++;
	}
	int ans=1e9;
	for(int i=1;i<=n;i++)
	{
		ans=min(ans,b[0][i-1]+b[1][i+1]);
	}
	cout<<ans;
	return 0;
}

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

//
int n;
vector<int>a;
vector<int>dp;
//

bool F(int k)
{
	if (k == 0)
		return 0;
	if (dp[k] != -1)
		return dp[k];
	for (auto it : a)
	{
		if (it <= k)
		{
			if (!F(k - it))
				return (dp[k] = 1);
		}
	}
	return (dp[k] = 0);
}

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

	cin >> n; int k; cin >> k;
	a = vector<int>(n);
	dp = vector<int>(k + 1, -1);
	for (auto &it : a)
		cin >> it;
	cout << (F(k) ? "First" : "Second");

	return 0;
}

Measured memory_bytes: 8264
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int N,M,X,C[15],A[15][15],ans=1e9;

int main() {
	cin>>N>>M>>X;
	for(int i=0;i<N;i++){
		cin>>C[i];
		for(int j=0;j<M;j++)cin>>A[i][j];
	}
	for(int i=1;i<(1<<N);i++){
		int prg[15]={},cst=0;
		for(int j=0;j<N;j++){
			if(i&(1<<j)){
				cst+=C[j];
				for(int k=0;k<M;k++)prg[k]+=A[j][k];
			}
		}
		bool flg=true;
		for(int i=0;i<M;i++)if(prg[i]<X)flg=false;
		if(flg)ans=min(ans,cst);
	}
	if(ans==1e9)ans=-1;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3636
from collections import Counter

def factors(n: int):
    l = []
    for i in range(2, int(n**0.5) + 1):
        #prime factorization
        while n % i == 0:
            n //= i
            l.append(i)
    if n > 1:
        l.append(n)
    return l

c = Counter(factors(int(input())))
ans = 0
for items,values in c.items():
    cnt = 1
    while cnt <= values:
        values -= cnt
        ans += 1
        cnt += 1
print(ans)


Measured memory_bytes: 66372