akhauriyash/Code-Regression huggingface dataset:
n,x,y=map(int, input().split())
es=[[] for _ in range(n)]
for i in range(n):
    if i<n-1:
        es[i].append([1,i+1])
    if i>0:
        es[i].append([1,i-1])
    es[x-1].append([1,y-1])
    es[y-1].append([1,x-1])

import heapq

def dijkstra_heap(s):
    d = [float("inf")] * n
    used = [True] * n
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in es[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in es[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

from collections import defaultdict, Counter
from copy import deepcopy
dist=dijkstra_heap(0)
distx=dijkstra_heap(x-1)
disty=dijkstra_heap(y-1)
counts=[]
for i in range(n-1):
    if i<x-1:
        tmp=[d-i for d in dist[i:]]
        counts.append(Counter(tmp))
    elif x-1<=i<y-1:
        tmp=[min(distx[i]+distx[d], disty[i]+disty[d], abs(d-i)) for d in range(i,n)]
        counts.append(Counter(tmp))
    else:
        tmp=[disty[d]-disty[i] for d in range(i,n)]
        counts.append(Counter(tmp))
ans=defaultdict(int)

for i in range(n-1):
    keys=counts[i].keys()
    for kk in keys:
        ans[kk]+=counts[i][kk]

for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 237192
#include<bits/stdc++.h>
using namespace std;
int main(){
     long double a,b;
    cin>>a>>b;
    long double temp=(unsigned long long)pow(b,1/a);
    unsigned long long kq=1;
    for(unsigned long long i=temp;i>=2;i--){
        unsigned long long dem=0,j=b;
        
        while(j%i==0){
            dem++;
            j=j/i;
        }
        if(dem>=a){
            kq=i;
            break;
        }
    }
    cout<<kq;
    //cout<<temp<<endl;
}

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

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


long long a[200010];

long long sum(int s,int e){
    return a[e] - a[s];
}

vector< vector<long long> > cand(int a,int b){
    int l = a + 1, r = b - 1;
    while( l != r ){
        int m = (l+r) / 2;
        if( sum(a, m) - sum(m, b) >= 0  ){
            r = m;
        }else{
            l = m + 1;
        }
    }
    vector< vector<long long> > res = {
            {sum(a, l),     sum(l, b)},
            {sum(a, l - 1), sum(l - 1, b)}
    };
    return res;
};

int main(){
    int N;
    cin >> N;
    for(int i = 0 ; i < N ; i++) {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }
    long long ans = 1e18;
    for(int i = 2 ; i <= N - 2 ; i++){
        auto X = cand(0, i);
        auto Y = cand(i, N);
        for( auto x : X ){
            for( auto y : Y ){
                vector<long long> t = x;
                t.insert(t.end(), y.begin(), y.end());
                sort(t.begin(), t.end());
                ans = min(ans, abs(t[3] - t[0]));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, n0, n1, n2, n3, c;
  cin >> N;
  c = 1;
  n0 = N % 10;
  N = N /10;
  n1 = N % 10;
  N = N /10;
  n2 = N % 10;
  N = N /10;
  n3 = N % 10;
//  cout << c << endl;
  if (n0 == n1 || c>= 3) {
    c = c + 1;
  } else {
    c = 1;
  }
//  cout << c << endl;
  if (n1 == n2 || c>= 3) {
    c = c + 1;
  } else {
    c = 1;
  }
//  cout << c << endl;
  if (n2 == n3 || c>= 3) {
    c = c + 1;
  } else {
    c = 1;
  }
//  cout << c << endl;
  if (c >= 3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

typedef long long ll;

const int Z = 1e9+7;

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

    int n, k;
    cin >> n >> k;

    ll ans = 0;
    for (int i = k; i <= n + 1; i++) {
        ans += 1ll * (n - i + 1 + n) * i / 2 - 1ll * (i - 1) * i / 2 + 1;
    }

    cout << ans % Z << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
int n,x;
cin>>n>>x;int m,minm;
cin>>m;minm=m;x-=m;
for(int i=1;i<n;i++){
    cin>>m;minm=min(m,minm);x-=m;
}
cout<<x/minm +n;

return 0;
}


Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
    for(ll i=1;i<=n;i++)
    {
        ll val=floor(i*1.08);
        if(val==n)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<":(";
    return 0;
}


//252908XL

Measured memory_bytes: 256
// verified at https://judge.yosupo.jp/submission/3400
#ifndef Union_find_hpp
#define Union_find_hpp

#include <cassert>
#include <cstddef>
#include <vector>

class union_find
{
    std::vector<int> link;

public:
    explicit union_find(const size_t n) : link(n, -1) {}

    size_t find(size_t x)
    {
        assert(x < size());
        while(link[x] >= 0)
        {
            if(link[link[x]] >= 0) link[x] = link[link[x]];
            x = link[x];
        }
        return x;
    }

    size_t size() const { return link.size(); }

    size_t size(const size_t x)
    {
        assert(x < size());
        return -link[find(x)];
    }

    bool same(const size_t x, const size_t y)
    {
        assert(x < size() && y < size());
        return find(x) == find(y);
    }

    bool unite(size_t x, size_t y)
    {
        assert(x < size() && y < size());
        x = find(x), y = find(y);
        if(x == y) return false;
        if(link[x] > link[y]) std::swap(x, y);
        link[x] += link[y];
        link[y] = x;
        return true;
    }
}; // class union_find

#endif

#include <iostream>
#include <tuple>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);

    int n,h,w; cin>>n>>h>>w;
    vector<vector<pair<int,int>>> cards(100000);
    for(int i=n,r,c,a; i--; )
    {
        cin>>r>>c>>a; --r,--c;
        cards[a].emplace_back(r,c+h);
    }
    union_find uf(h+w);
    long long ans{};
    vector<bool> ext(h+w);
    for(int i=100000; i; --i)
    {
        for(auto&& e:cards[i])
        {
            int r,c; tie(r,c)=e;
            int fr=uf.find(r),fc=uf.find(c);
            if(fr!=fc)
            {
                if(ext[fr] and ext[fc]) continue;
                bool extor=ext[fr]||ext[fc];
                uf.unite(fr,fc);
                ext[uf.find(fr)]=extor;
                ans+=i;
            }
            else if(!ext[fr])
            {
                ext[fr]=true;
                ans+=i;
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 5504
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    ll i = 1,ans = 1;
    if (s[0] == t[0]) ans = 3;
    else{
        i = 2;
        ans = 6;
    }
    while(i < n){
        if (s[i] == t[i]){
            if (s[i-1] == t[i-1]) (ans *= 2)%=MOD;
            i += 1;
        }
        else{
            if (s[i-1] == t[i-1]) (ans *= 2)%=MOD;
            else (ans *= 3)%=MOD;
            i += 2;
        }
    }
    PRINT(ans);
}


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

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

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

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

const int MAX_K = 5000;
int k;
ll d[MAX_K];

int main() {
    fastio();

    int q;
    cin >> k >> q;
    forn(i, k) {
        cin >> d[i];
    }

    while (q--) {
        ll n, x, m;
        cin >> n >> x >> m;

        ll s = 0;
        ll c = 0;
        forn(i, k) {
            s += d[i] % m;
            if (d[i] % m == 0) c++;
        }

        ll xn_1 = x + (n - 1) / k * s;
        c = (n - 1) / k * c;
        for (int i = 0; i < (n - 1) % k; i++) {
            xn_1 += d[i] % m;
            if (d[i] % m == 0) c++;
        }

        cout << (n - 1) - (xn_1 / m - x / m) - c << endl;
    }

    return 0;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> prime(0);//i番目の素数
vector<bool> is_prime(0);//iは素数か
//n以下の素数の数
int hurui(int n){
    is_prime.resize(n+1,true);
    is_prime[0]=0; is_prime[1]=0;
    int p=0;
    REP(i,2,n+1){
        if(is_prime[i]){
            prime.emplace_back(i);
            p ++;
            for(int j=2*i; j<=n; j +=i){
                is_prime[j]=false;
            }
        }
    }
    return p;
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int q;
    cin>>q;
    hurui(1e5);
    vector<int> dp(1e5+1,0);//dp[i]=i以下の似た素数の数
    REP(i,2,1e5+1){
        if(is_prime[i] && is_prime[(i+1)/2]) dp[i]=dp[i-1]+1;
        else dp[i]=dp[i-1];
    }
    int x,y;
    rep(i,q){
        cin>>x>>y;
        cout<<dp[y]-dp[x-1]<<endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int n,k;
int a[N],cnt;
int main() {
	scanf("%d%d",&n,&k) ;
	for(int i=1;i<=n;++i) 
		scanf("%d",&a[i]);
	cnt++;
	n-=k;
	cnt+=ceil((double)n/(k-1));
	cout<<cnt<<endl;
	return 0;
}


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

int main() {
  int n,k; cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int t=0;
  rep(i,n) {
    if(a[i]==1) {
      t=i;break;
    }
  }
  ll ans = 100000000;
  rep(i, k) {
    int j=k-1-i;
    ll tmp=1;
    if(t-i>0) {
      tmp += (t-i+(k-2))/(k-1);
    }
    if(n-t-1>0) {
      tmp += (n-t-1-j+(k-2))/(k-1);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
S = input()

d = {
    'R': list(),
    'G': list(),
    'B': list()
}


for i, c in enumerate(S):
    d[c].append(i+1)

all = len(d['R']) * len(d['G']) * len(d['B'])

for c in 'RGB':
    d[c] = sorted(d[c])


# decide twice
for c in 'RGB':
    s = set([2 * x for x in d[c]])
    cs = [x for x in 'RGB' if x != c]

    for i in d[cs[0]]:
        for j in d[cs[1]]:
            if (i+j) in s:
                all -= 1

print(all)

Measured memory_bytes: 68164
N=int(input())
A=[int(x) for x in input().split()]
mod=10**9+7
A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[1]==1 and A[i]-2==A[i-2] for i in range(2,N,2)):
        print((2**(N//2))%mod)
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i-1] and A[i]-2==A[i-2] and A[-1]==N-1 for i in range(2,N,2)):
        print((2**(N//2))%mod)
    else:
        print(0)


Measured memory_bytes: 13880
N, M = map(int, input().split())
ans = 0
for i in range(1, int(M**0.5)+1):
    if M % i == 0:
        if i * N <= M:
            ans = max(ans, i)
        if (M // i) * N <= M:
            ans = max(ans, M // i)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <bitset>
#include <cmath>

#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
using namespace std;
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;}
int main(){
    int n,k; cin >> n >> k;
    int h[n];
    int ans=0;
    rep(i,n){
        cin >> h[i];
        if(h[i]>=k) ans++;
    }
    cout << ans;
    
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

int h, w;
vector<string> s;
int cntw, cntb;
int ans = 0;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
void dfs(int x, int y, bool white){
    s[y][x] = ',';
    if(white) cntw++;
    else cntb++;

    REP(i, 4){
        if(x+dx[i] >= 0 && x+dx[i] < w && y+dy[i] >= 0 && y+dy[i] < h &&
           s[y+dy[i]][x+dx[i]] == (white ? '#' : '.')) {
            dfs(x + dx[i], y + dy[i], !white);
        }
    }
}

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

    cin >> h >> w;
    s.resize(h);
    REP(i, h) cin >> s[i];

    REP(i, h) REP(j, w) if(s[i][j] != ','){
        cntb = 0; cntw = 0;
        dfs(j, i, s[i][j] == '.');
        ans += cntb * cntw;
    }
    cout << ans << endl;
}

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

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

	int K;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	string S;
	vector<int> given;

	cin >> K >> S;

	if(K<S.size()){
		for(i=0;i<K;i++){
			cout << S[i];
		}
		cout << "..." << endl;
	}else{
		cout << S << endl;
	}

	return 0;
}



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

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        HashSet<char> list = new HashSet<char>(Console.ReadLine());
        list.Remove(' ');
        Console.WriteLine(list.Count() == 4 ? "Four" : "Three");
    }
}

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

int main(){
	
	int x,n,r=0; cin >> x >> n;
	bool vis[110]={0};
	
	for (int i=0 ; i<n ; i++){
		int a; cin >> a;
		vis[a] = 1;
	}
	
	for (int i=0 ; i<x ; i++){
		if (!vis[x-i]){
			r = x-i; break;
		}
		else if (!vis[x+i]){
			r = x+i; break;
		}
	}
	
	cout << r << "\n";
	
	return 0;
}

Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(2000)

N = int(input())

mod = 1000000007

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

a = power(10, N)
b = power(9, N)
c = power(8, N)

print(((a%mod)-(b%mod)-(b%mod)+(c%mod))%mod)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main() {
  int k, n, md(0);
  cin >> k >> n;
  int arr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    if (i) md = max(md, arr[i] - arr[i-1]);
  }
  md = max(md, arr[0] + k - arr[n-1]);
  cout << k - md << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

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

	for(int i = 0; i <= N; i+=4){
		if((N - i) % 7 == 0){
			cout << "Yes" << '\n';
			return 0;
		}
	}

	cout << "No" << '\n';

	return 0;
}


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

using namespace std;

int main() {
  int N;
  while (cin >> N) {
    int p[N];
    for (int i = 0; i < N; i++) {
      cin >> p[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (i - 1 < 0 || i + 1 == N) {
        continue;
      }
      vector<int> v;
      for (int j = i - 1; j <= i + 1; j++) {
        v.push_back(p[j]);
      }
      sort(v.begin(), v.end());
      if (v[1] == p[i]) {
        ans++;
      }
    }
    cout << ans << endl;
  }
}


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

#define int long long
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,M,a,b,c,sum;
map<int,int> m;

signed main() {
    cin >> n >> M;
    rep(i,n) cin >> a,m[a]++;
    rep(i,M) {
        cin >> b >> c;
        m[c] += b;
    }
    auto itr = m.end();--itr;
    while(1) {
        if (itr->se < n) sum += itr->se*itr->fi, n -= itr->se;
        else {
            sum += itr->fi*n;
            break;
        }
        --itr;
    }
    cout << sum << endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n;
  cin >> n;
  ll a,b;
  cin >> a >> b;

  ll cyc;
  cyc = n/(a+b);
  n -= (a+b)*cyc;
  ll ans = a*cyc + min(a, n);
  cout << ans << endl;


  
  return 0;
    

}


Measured memory_bytes: 256
n = int(input())
ans = 0
i = 1
for i in range(1,n+1):
    eight = 0 
    if i % 2 == 1:
        for j in range(1,i+1):
            if i % j == 0:
                eight += 1

    if eight == 8:
        ans += 1

print(ans)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
struct vertex{
	double x,y,r;
	int type; //1:circle 0:point
	vertex(){}
	vertex(double x,double y,double r,int t):x(x),y(y),r(r),type(t){}
};
double D(vertex a,vertex b){
	int s = a.type+b.type;
	double k = sqrt(sq(a.x-b.x)+sq(a.y-b.y));
	if(s==0){
		return k;
	}else if(s==1){
		if(a.type<b.type)swap(a,b);
		return max(0.0,k-a.r);
	}else{
		return max(0.0,k-a.r-b.r);
	}
}
int N;
vertex v[1010];
double dist[1010];
bool used[1010];
int main(){
	for(int i=0;i<2;i++){
		scanf("%lf %lf",&v[i].x,&v[i].y);
		v[i].r = -1;
		v[i].type = 0;
	}
	scanf("%d",&N);
	for(int i=2;i<N+2;i++){
		scanf("%lf %lf %lf",&v[i].x,&v[i].y,&v[i].r);
		v[i].type = 1;
	}
	N+=2;
	for(int i=0;i<N;i++)dist[i]=1e50;
	dist[0]=0.0;
	for(int i=0;i<N;i++){
		int id = -1;
		double val = 1e50;
		for(int j=0;j<N;j++){
			if(!used[j]&&dist[j]<val){
				val = dist[j];
				id = j;
			}
		}
		used[id]=true;
		for(int j=0;j<N;j++){
			double d = D(v[id],v[j]);
			if(dist[j]>dist[id]+d){
				dist[j] = dist[id]+d;
			}
		}
	}
	printf("%.12f\n",dist[1]);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

  int mat[5][5];
  int sumrow[5];
  int sumcol[5];
  int dummy, dum2;

  for (int i = 0; i < 3; i++)
    for (int j = 0; j< 3; j ++)
      cin >> mat[i][j];

  for (int i = 0; i < 3; i++) {
    int dummy = 0;
    for (int j = 0; j< 3; j ++) {
      dummy += mat[i][j];
    } 
    sumrow[i] = dummy;
  }
  for (int i = 0; i < 3; i++) {
    int dummy = 0;
    for (int j = 0; j < 3; j ++) {
      dummy += mat[j][i];
    } 
    sumcol[i] = dummy;
  }

  bool isit = true;

  if (((sumrow[0]-sumrow[1])%3) || ((sumrow[1]-sumrow[2])%3) || ((sumrow[2]-sumrow[0])%3))
    isit = false;
  if (((sumcol[0]-sumcol[1])%3) || ((sumcol[1]-sumcol[2])%3) || ((sumcol[2]-sumcol[0])%3))
    isit = false;

  if (isit)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
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; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};

int n;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vii t, a(n), b;
  rep(i, 0, 31) t.pb(1 << i);
  map<int, int> cnt;
  rep(i, 0, n) {
    cin >> a[i];
    b.pb(a[i]);
    cnt[a[i]]++;
  }
  sort(ALL(b));
  b.erase(unique(ALL(b)), b.end());
  reverse(ALL(b));
  int ans = 0;
  rep(i, 0, b.size()) {
    int p = 0;
    rep(j, 0, t.size()) {
      if (b[i] < t[j]) {
        p = t[j] - b[i];
        break;
      }
    }
    if (b[i] == p) {
      ans += cnt[b[i]] / 2;
    } else {
      int tmp = min(cnt[b[i]], cnt[p]);
      cnt[b[i]] -= tmp;
      cnt[p] -= tmp;
      ans += tmp;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 20596
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int ans = 0, mx = -1;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    int num = i;
    while (true) {
      if (num % 2 != 0) break;
      cnt++;
      num /= 2;
    }
    if (mx < cnt) {
      mx = cnt;
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
#include <list>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

int proc(int pos, std::string& str, int dir) {
    if (pos == -1 || pos == str.size()) {
        return pos;
    }

    if (str[pos] == 'A') {
        str[pos] = 'B';
        return proc(pos - dir, str, -dir);
    } else {
        str[pos] = 'A';
        return proc(pos + dir, str, dir);
    }
}

int N, K;
std::string S;

int main(int argc, char **argv) {
    std::cin >> N >> K;
    std::cin >> S;

    /*
    for (int i = 1; i <= K; i++) {
        int ret = proc(0, S, 1);
        std::cout << S << " " << ret << std::endl;
    }
    */
    std::list<int> change;
    int org = 0;
    bool top = S[0] == 'A';
    int change_size = 0;
    for (int i = 0; i < S.size() - 1; i++) {
        if (S[i] != S[i+1]) {
            change.push_back(i);
            change_size++;
        }
    }

    while (true) {
        if (top) {
            if (*change.begin() == org) {
                change.pop_front();
                top = false;
                change_size--;
            } else {
                change.push_front(org);
                top = false;
                change_size++;
            }
        } else {
            bool last_A = change_size % 2 == 1;
            if (*change.begin() == org) {
                change.pop_front();
                change_size--;
            } else {
                top = true;
            }
            org++;
            if (last_A) {
                change.push_back(org+S.size() - 2);
                change_size++;
            }
        }
        K--;
        if (K == 0 || S.size() <= org) {
            break;
        }
    }

    if (K == 0) {
        int begin = org;
        int num = 0;
        for (auto itr = change.begin(); itr != change.end(); ++itr) {
            for (int i = begin; i <= *itr; i++) {
                std::cout << (top ? "A" : "B");
                num++;
                if (num == S.size()) {
                    std::cout << std::endl;
                    return 0;
                }
            }
            begin = (*itr) + 1;
            top = !top;
        }
        while (num < S.size()) {
            std::cout << (top ? "A" : "B");
            num++;
        }
        std::cout << std::endl;
        return 0;
    } else {
        if (S.size() % 2 == 1) {
            if (K % 2 == 1) {
                top = !top;
            }
            std::cout << (top ? "A" : "B");
        }
        for (int i = 0; i < S.size()/2; i++) {
            std::cout << "BA";
        }
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 6916
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,m;
    cin>>n>>m;
    vl v;
    ll total=0;
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
        total+=c;
    }
    sort(all(v));
    ll cnt=0;
    for(auto it:v)
    {
        if((it*4*m)>=total)
            cnt++;
    }
    if(cnt>=m)
        cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12032
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    int N,M;cin >> N >> M;
    vector<bool> red(N,false);
    red.at(0) = true;
    vector<int> ball(N,1);
    for(int i = 0;i<M;i++){
        int from,to;cin >> from >> to;from--;to--;
        ball.at(from)--;
        ball.at(to)++;
        if(red.at(from)) red.at(to) = true;
        if(ball.at(from) == 0){
            red.at(from) = false;
        }
        
        
    }
    int ans = 0;
    for(bool V : red) if(V) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 640
mod=10**9+7
s=input()
n=len(s)
dp=[[0]*4 for i in range(n+1)] # A B C ABC
dp[0][0]=1
for i in range(1,n+1):
    if s[i-1]=="A":
        dp[i][0]=dp[i-1][0]
        dp[i][1]=(dp[i-1][1] + dp[i-1][0]) % mod
        dp[i][2]=dp[i-1][2]
        dp[i][3]=dp[i-1][3]
    elif s[i-1]=="B":
        dp[i][0]=dp[i-1][0]
        dp[i][1]=dp[i-1][1]
        dp[i][2]=(dp[i-1][2] + dp[i-1][1]) % mod
        dp[i][3]=dp[i-1][3]
    elif s[i-1]=="C":
        dp[i][0]=dp[i-1][0]
        dp[i][1]=dp[i-1][1]
        dp[i][2]=dp[i-1][2]
        dp[i][3]=(dp[i-1][3] + dp[i-1][2]) % mod
    else:
        dp[i][0]=dp[i-1][0]*3 % mod
        dp[i][1]=(dp[i-1][1]*3 + dp[i-1][0]) % mod
        dp[i][2]=(dp[i-1][2]*3 + dp[i-1][1]) % mod
        dp[i][3]=(dp[i-1][3]*3 + dp[i-1][2]) % mod
print(dp[-1][-1]% mod)

Measured memory_bytes: 27612
program main
      implicit none
      integer :: l 
      character(11) :: s, t

     read *, s
     read *, t
     
     l = len_trim(t)
     if( s ==  t(1:l-1) ) then
       print *, 'Yes'
     else
       print *, 'No'
     end if

      
end program main


Measured memory_bytes: 2852
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	if (n%k == 0)
	{
	cout << 0;
	return 0;
	}
	while(n>=k)
	{
		n %= k;
	}
	if(abs(n-k) > n)
	cout << n;
	else
	cout << abs(n-k);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define inp(a) int a; cin>>a;
#define inpa(a,n) vector<int>a(n+1); FOR(i,1,n) cin>>a[i];
#define PI 3.141592653589793238
#define QUICK ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vec(x) vector<x>
#define pii pair<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define FOR(i,j,n) for(int i= j; i<=n; i++)
#define srt(a); sort(a.begin(), a.end())
#define CASE int t; cin>>t; while(t--)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define print(x) for(auto c : x) cout << c << " ";
#define dbg(x) cerr << #x << " :: "<< x << endl;
#define dbg2(x,y) cerr << #x << " :: "<<x <<"\t" << #y << " :: "<<y <<endl;
#define upcase(s)  transform(s.begin(), s.end(), s.begin(), ::toupper)
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define int ll
const int INF = 1e9 + 7;
const int SIZE = 1e9 + 5;
const int MOD = 1e9 + 7; 
//////////// template ends here //////////////////////////


void solve(){	

	inp(n); inp(w);
	vec(int)wt(n+1, 0), val(n+1,0);

	FOR(i,1,n){
		cin>>wt[i] >> val[i];
	}

	const int maxn = 1e5+ 5; 	
	vec(vec(int))dp(n+1, vec(int)(maxn+1, INF));

	dp[1][0] = 0;
	dp[1][val[1]] = wt[1];

	FOR(i,2,n){
		FOR(j, 0 ,maxn){
			dp[i][j] = dp[i-1][j];
			if(j-val[i] >= 0)
				dp[i][j] = min(dp[i][j], dp[i-1][j-val[i]] + wt[i]);
		}
	}

	

	for(int i = maxn; i>=0; i--){

		if(dp[n][i] <= w){
			cout << i << endl;
			break;
		}
	}
	dbg(dp[n][16])

}



int32_t main(){
	#ifndef ONLINE_JUDGE 
		freopen ("input.txt","r",stdin);
		freopen ("output.txt","w",stdout);
	#endif	
	QUICK;
	//CASE{
		solve();
	//}
	printclock;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

// 12 -> 1,2,6,3,4
vector<ll> factor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != 1 && i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N, M;
  scanf("%lld %lld", &N, &M);

  auto factors = factor(M);
  factors.emplace_back(M);

  ll ans = -1;
  for (ll i = 0; i < factors.size(); i++) {
    ll v = factors[i];
    ll d = M / v;
    if (d >= N) {
      ans = max(ans, v);
    }
  }
  cout << (ans) << endl;
}


Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cfenv>
#include <cmath>

using namespace std;

int main() {
  int x,y;
  cin>>x>>y;

  int a=2;
  int b = 4;
  bool flag = false;
  for(int i = 0;i<=x;i++){
    int an = a*i + b*(x-i);
      if(an == y) flag = true;
  }
  if(flag)
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return 0;
}

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

//使用する配列の最大要素数
#define MAX_SIZE_N 2000
//使用する変数の宣言と初期化
int a=0,b=0,c=0,n;
int L[MAX_SIZE_N]={0};
int result=0;

int main()
{
  cin >> n;
  for(int i=0;i<n;++i) cin >> L[i];
  sort(L, L + n);

  //処理
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(L[i]<L[j]+L[k] && L[j]<L[k]+L[i] && L[k]<L[i]+L[j] ) result++;
        else break;
      }
    }
  }    
  
  cout << result;
    
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define inf 1e17

using namespace std;

ll dp[410][410],arr[410],n,pre[410];


int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
	for(int j=1;j<=n;j++)
	{
		dp[i][j]=inf;
	}
}

for(int i=1;i<=n;i++)
{
    cin>>arr[i];
    dp[i][i]=0;
}

for(int i=1;i<n;i++)
{
  dp[i][i+1]=arr[i]+arr[i+1];
}

pre[0]=0;
for(int i=1;i<=n;i++)
{
 pre[i]=pre[i-1]+arr[i];
}


for(int i=n;i>=1;i--)
{

	for(int j=i+1;j<=n;j++)
	{
		for(int k=i;k<j;k++)
		{
			dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]-pre[i-1]+pre[j]);
		}
	}
}
cout<<dp[1][n]<<endl;


}

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

int main(){
  string s;
  int sum=0;
  cin >> s;

  for (int i =0; i<s.size(); i++){
    if ( s.at(i) == '+') sum ++;
    if ( s.at(i) == '-') sum --;
  }
  cout << sum << endl;
  
			 
    

  return 0;
}


Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n = int(input())
ans = []
for _ in range(n):
    ans.append(input())
ans = list(set(ans))
print(len(ans))

Measured memory_bytes: 36892
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    vector<int> d(5);
    int ans=0;
    int min=10;
    
    REP(i,5){
        cin >> d[i];
    }
    
    REP(i,5){
        ans += ceil((double)d[i]/10)*10;
        if(d[i]%10<min && d[i]%10!=0){
            min=d[i]%10;
        }
    }
    if(min!=10){
        ans -= (10-min);
    }
    cout << ans << endl;

    return 0;   
}

Measured memory_bytes: 888
k=[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]
s=int(input())
s=s-1
print(k[s])

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll N;
    cin >> N;
    print((N+1)/2);
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, h[100010], q, l, r;
int cost[100010];
bool v[100010];
int32_t main(){
INIT
cin>>n>>k;
for(int i=1; i<=n; i++){
    cin>>h[i];
}

for(int i=2; i<=n; i++){
    cost[i]=((int)1000000000000000);
    for(int j=1; (j<=k) && (i-j)>=1; j++ ){
        cost[i]=min(cost[i-j]+abs(h[i-j]-h[i]), cost[i]);
    }
}
cout<<cost[n];




return 0;
}



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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



const int MOD = 1E9 + 7;
void _main() {
        int n; cin >> n;
        vector<int> a(n); cin >> a;
        vector<ll> suf(n);
        suf.back() = a.back();
        for (int i = n - 2; i >= 0; i--) {
                suf[i] = a[i] + suf[i + 1];
                suf[i] %= MOD;
        }

        ll ans = 0;
        for (int i = 0; i < n - 1; i++) {
                ans += a[i] * suf[i + 1] % MOD;
                ans %= MOD;
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 5556
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

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

    int ans = (n+1)/2;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
N  = int(input())

from collections import defaultdict
ansd = defaultdict(int)

def calc(x,y,z):
    return x**2 + y**2 + z **2 + x*z + y*z + y*x

for x in range(1,100):
    for y in range(1, 100):
        for z in range(1,100):
            ansd[calc(x,y,z)] += 1

for k in range(1, N+1):
    print(ansd[k])

Measured memory_bytes: 11828
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
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)++)
 
int main(){
    string s;
    cin>>s;
    if((s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0')-2019<0){
        cout<<"Heisei"<<endl;
        return 0;
    }else if((s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0')-2019==0&&(s[5]-'0')*10+(s[6]-'0')-4<0){
        cout<<"Heisei"<<endl;
        return 0;
    }else if((s[5]-'0')*10+(s[6]-'0')-4==0){
        cout<<"Heisei"<<endl;
        return 0;
    }else {
        cout<<"TBD"<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
using System;

namespace ABC141
{
    class Program
    {
        static void Main()
        {
            var S = Console.ReadLine();
            var isOk = true;
            for (int i = 0; i < S.Length; i++)
            {
                if ((i + 1) % 2 == 0)
                {
                    if (!(S[i] == 'L' || S[i] == 'U' || S[i] == 'D')) isOk = false;
                }
                else if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D')) isOk = false;
            }

            Console.WriteLine(isOk ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N;
vector<int> B;
vector<int> A;
int ANS = 0;
int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int b;
		cin >> b;
		B.push_back(b);
	}
	int tmp = B[0];
	A.push_back(tmp);
	for (int i = 0; i <= N - 3; i++) {
		tmp = min(B[i], B[i + 1]);
		A.push_back(tmp);
	}
	tmp = B[N - 2];
	A.push_back(tmp);

	for (int i = 0; i < N; i++) {
		ANS += A[i];
	}
	cout << ANS << endl;
	return 0;

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

const mod = 2019

func main() {
	sc.Split(bufio.ScanWords)
	
	 l,r := scanInt(),scanInt()

	ans := 2019

	if r-l+1 > 2019 {
		fmt.Println(0)
		return
	}

	for i := l; i < r+1; i++ {
		for j := i+1; j < r+1; j++ {
			if i*j%mod < ans {
				ans = i*j%mod
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640