akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m=mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}



void solve() {
	int d, t, s; cin >> d >> t >> s;
	if (d <= s * t) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(15);
	init_f(); 
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


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

int main(void){
	
	int a,b;
	long p;
	cin >> a >> b ;

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

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int>a(n);
    forn(i,n)
    {
        scanf("%d",&a[i]);
    }
    int cnt=1,i=0;
    while(i<n)
    {
        if(a[i]!=cnt)i++;
        else
        {
            cnt++;
            i++;
        }
//        printf("%d %d %d\n",i,cnt,a[i-1]);
    }
    if(cnt==1)printf("-1\n");
    else printf("%d\n",n-cnt+1);
    return 0;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000; // 2*(10^5)
vvec g(nmax);

typedef vector<vector<P> > Graph;
Graph G(nmax),S(nmax);

vector<int> dijkstra(int s, Graph &G){
  priority_queue<P,vector<P>,greater<P>> que;
  int n = G.size();
  vector<int> dist(n);
  dist.assign(n,INF);
  dist[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.sc;
    REP(i,G[v].size()){
      if(dist[G[v][i].fs] > dist[v]+G[v][i].sc){
        dist[G[v][i].fs] = dist[v]+G[v][i].sc;
        que.push(P(dist[G[v][i].fs],G[v][i].fs));
      }
    }
  }
  return dist;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    s--;t--;
    rep(i,m){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;b--;
        S[a].eb(b,c);
        S[b].eb(a,c);
        G[a].eb(b,d);
        G[b].eb(a,d);
    }
    vec dists=dijkstra(s,S);
    vec distt=dijkstra(t,G);
    ll ans=INF;
    vec kari;
    for(int i=n-1;i>=0;i--){
        chmin(ans,dists[i]+distt[i]);
        kari.pb(ans);
    }
    reverse(all(kari));
    rep(i,n){
        cout<<1000000000000000-kari[i]<<endl;
    }
}

Measured memory_bytes: 30968
import sys
K=int(input())

def f(x):
    a=str(x)
    num=0
    for s in a:
        num+=int(s)
    return x/num
L=[1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99,199,299,399,499,599,699,799,899,999]
L=set(L)
for i in range(4,16):
    for j in range(10,1000):
        s=str(j)+'9'*(i-2)
        L.add(int(s))
L=list(L)
#print(len(L))
L.sort()
for j in range(len(L)):
    flag=True
    for k in range(j+1,len(L)):
        if L[k]/L[j]>20:
            break
        if f(L[j])>f(L[k]):
            flag=False
            break
    if flag:
        print(L[j])
        K=K-1
    if K==0:
        sys.exit()


Measured memory_bytes: 48124
#[allow(dead_code)]
fn main() {
    let (n, m, x) = i::u3();
    let mut c = Vec::new();
    let mut a = Vec::new();
    for _ in 0..n {
        let c_i = i::u();
        let a_i = i::uv(m);
        c.push(c_i);
        a.push(a_i);
    }

    let mut case = (0..n).fold(1, |x, _| x * 2);
    let mut ans = 1_000_000_000;

    'case: for i in 0..case {
        let mut cost = 0;
        let mut current = vec![0; m];

        for j in 0..n {
            if (i >> j) % 2 == 0 {
                continue;
            }
            cost += c[j];
            for k in 0..m {
                current[k] += a[j][k];
            }
        }
        for cur in current {
            if cur < x {
                continue 'case;
            }
        }
       // dbg!(&cost);
        ans = min(ans, cost);
    }
    if ans == 1_000_000_000 {
        println!("{}", -1);
        return;
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2140
def binary(s, t):
    c = 0
    left = 0
    right = len(s)
    while left < right:
        m = int((left + right)/2)
        if s[m] == t:
            c = 1
            return c
        elif s[m] > t:
            right = m
        else:
            left = m+1
    return c


n = int(input())
count = 0

s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
for i in range(q):
    count += binary(s, t[i])
print(count)


Measured memory_bytes: 16716
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  int c=N;
  int t=0;
  while(c>0){
    t += c%10;
    c /= 10;
  }
  cout<< (N%t==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
a, b ,c = gets.split(" ").map(&:to_i)
count = []

def total_of_degit(n)
  sum = 0
  while n > 0
    sum += n % 10
    n /= 10
  end
  sum
end

(1..a).each do |x|
  if total_of_degit(x).between?(b, c)
    count << x
  end
end

puts count.inject(:+)

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

int main () {
    int n;
    cin >> n;
    for (int i=3;i<=n;i++) {
        // 3の倍数判定
        if ( i%3==0 || i%30==0 || i%300==0 || i%3000==0 ) {
                cout << " " << i;
        } else {
            string str;
            str = to_string(i);
            if ( str.length()==2 && ( str.at(1)==51 || str.at(0)==51) ) {   // 2桁の時
                cout << " " << i;
            } else if ( str.length()==3 && ( str.at(2)==51 || str.at(1)==51 || str.at(0)==51) ) {     //3桁の時
                cout << " " << i;
            } else if ( str.length()==4 && ( str.at(3)==51 || str.at(2)==51 || str.at(1)==51 || str.at(0)==51) ) {      //4桁の時
                cout << " " << i;
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3208
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()
A = A[::-1] / A.sum()
# print(f'{A=}')

ans = 'Yes' if A[M - 1] >= 1 / 4 / M else 'No'
print(ans)


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;
    int2(a, b);
    bool funamiyuichannhakawaiinaa = false;
    if (st[0] == 'F') {
        funamiyuichannhakawaiinaa = true;
    }

    vi dx(0), dy(0);
    int cnt = 0, hop = 0;
    rep(i, st.size()) {
        if (st[i] == 'T') {
            if (hop) {
                if (cnt % 2) {
                    dy.pb(hop);
                } else {
                    dx.pb(hop);
                }
                hop = 0;
            }
            cnt++;
        } else {
            hop++;
        }
    }
    if (hop) {
        if (cnt % 2) {
            dy.pb(hop);
        } else {
            dx.pb(hop);
        }
    }
    /*
    rep(i, dx.size()) cout << dx[i] << " ";
    cout << endl;

    rep(i, dy.size()) cout << dy[i] << " ";
    cout << endl;
    */

    set<int> funami;
    if (dx.size() != 0 && funamiyuichannhakawaiinaa) {
        funami.insert(dx[0]);
    } else {
        funami.insert(0);
    }
    for (int i = (funamiyuichannhakawaiinaa) ? 1 : 0; i < dx.size(); i++) {
        set<int> kyoko;
        for (auto j = funami.begin(); j != funami.end(); j++) {
            kyoko.insert(*j+dx[i]);
            kyoko.insert(*j-dx[i]);
        }
        funami = kyoko;
    }
    if (funami.find(a) == funami.end()) {
        cout << "No" << endl;
        return 0;
    }

    funami = set<int>();
    funami.insert(0);
    rep(i, dy.size()) {
        set<int> kyoko;
        for (auto j = funami.begin(); j != funami.end(); j++) {
            kyoko.insert(*j+dy[i]);
            kyoko.insert(*j-dy[i]);
        }
        funami = kyoko;
    }
    if (funami.find(b) == funami.end()) {
        cout << "No" << endl;
        return 0;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}






Measured memory_bytes: 640
#include <iostream>
using namespace std;
string s;
int n, mn;
int main() {
	cin>>s;
	mn = n = s.size();
	for(int i=1; s[i]; i++) if(s[i]!=s[i-1]) mn = min(mn, max(i, n-i));
	cout<<mn;
	return 0;
}

Measured memory_bytes: 512
import sys
N = int(input())
A = list(map(int, input().split()))
C = []
t = 0
for i in range(N, -1, -1):
    t += A[i]
    C.append(t)
C = C[::-1]

zanki = 1
ans = 1
for i in range(N+1):
    zanki -= A[i]
    if zanki < 0:
        print(-1)
        sys.exit()
    if zanki == 0 and i != N:
        print(-1)
        sys.exit()
    zanki *= 2
    if i < N and zanki >= C[i+1]:
        zanki = C[i+1]
    ans += zanki
print(ans)

Measured memory_bytes: 84500
N, T = map(int, input().split())
cost = 1000+1
T_ika_count = 0
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        T_ika_count = T_ika_count+1
        if c < cost:
            cost = c
if T_ika_count == 0:
    print('TLE')
else:
    print(cost)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int distance(int a,int b,int w);
int main(void) {
    int num,a,b,c,d,i,min=200,temp;
    scanf("%d %d %d %d %d",&num,&a,&b,&c,&d);
    for (i=1; i<=num; i++) {
        temp = distance(a-1,b-1,i)+distance(c-1,d-1,i);
        if (temp<min) min=temp;
    }
    printf("%d\n",min);
    return 0;
}

int distance(int a,int b,int w) {
    return abs(a/w-b/w)+abs(a%w-b%w);
}

Measured memory_bytes: 596
package main

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

type MyScanner struct {
	sc *bufio.Scanner
}

type MyWriter struct {
	stdout io.Writer
}

type MyPut interface{}

func getScanner(fp io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 500001), 500000)
	return sc
}

func getHugeScanner(fp io.Reader, size int) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, size), size)
	return sc
}

func (mysc *MyScanner)String() string {
	mysc.sc.Scan()
	return mysc.sc.Text()
}

func (mysc *MyScanner)Int() int {
	i, _ := strconv.Atoi(mysc.String())
	return i
}

func (mysc *MyScanner)Int64() int64 {
	i, _ := strconv.ParseInt(mysc.String(), 10, 64)
	return i
}

func (mysc *MyScanner)Float64() float64 {
	i, _ := strconv.ParseFloat(mysc.String(), 64)
	return i
}

func (mw MyWriter)Puts(v MyPut) {
	_, _ = fmt.Fprintf(mw.stdout, "%v\n", v)
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := MyScanner{getHugeScanner(stdin, 100008)}
	mw := MyWriter{stdout}

	n := sc.Int()
	k := sc.Int()
	s := sc.String()

	var l []int

	var b uint8 =  'X'

	for i := 0; i < n; i++ {
		if s[i] == b {
			l[len(l) - 1]++
		} else {
			l = append(l, 1)
		}
		b = s[i]
	}

	if k < len(l) / 2 {
		ans := 0
		for i := 0; i < len(l); i++ {
			ans += l[i] - 1
		}
		ans += k * 2
		mw.Puts(ans)
	} else {
		mw.Puts(n - 1)
	}

}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
	
	static int sum;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		sum = 0;
		int nElems = 0;
		int[] strlong = new int[3];
		
		strlong[0] = sc.nextInt();
		strlong[1] = sc.nextInt();
		strlong[2] = sc.nextInt();
		
		for(int j = 0; j < strlong.length; j++){
			sum += strlong[j];
			if(strlong[j] == 5){
				nElems++;
			}
		}
		if(nElems == 2){
			ans();
		}else{
			System.out.println("NO");
		}
	}
	
	public static void ans(){
		if(sum == 17){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 9680
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;

vector<ll> v;

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

ll vec_gcd()
{
  vector<ll>::iterator itr = v.end()-1;
  while(itr!=v.begin())
  {
    *(itr-1) = gcd(*itr,*(itr-1));
    itr--;
  }
  return *itr;
}

int main()
{
  ll n;
  cin >> n;
  for (ll i = 0; i < n; i++)
  {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  cout << vec_gcd() << endl;
  return 0;
}

Measured memory_bytes: 1400
import math
N = int(input())
A = list(map(int, input().split()))

sumA = sum(A)
halfA = math.ceil(sumA / 2)
bitset = 1
for a in A:
  bitset |= bitset << a

bitset >>= halfA
i = 0
while i < halfA:
  if bitset & 1:
    print(i+halfA)
    exit()
  bitset >>= 1
  i += 1
print(i+halfA)

Measured memory_bytes: 5456
implicit none
character(50) :: o,e
integer :: no, ne, io, ie

read *, o
read *, e

no = len_trim(o)
ne = len_trim(e)

io = 0
ie = 0
do while (io < no) 
   io = io + 1
   write(6,'(1a)',advance='no') o(io:io)

   if (ie < ne) then
      ie = ie + 1
      write(6,'(1a)',advance='no') e(ie:ie)
   endif
enddo

write(6,'(a)') ''
end


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

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

  while ( n-- ) {
    string ord, mes;
    cin >> ord >> mes;

    int l = (int)mes.size();    
    for ( int i = (int)ord.size()-1; i >= 0; i-- ) {      
      if ( ord[i] == 'J' ) {
	int c = mes[l-1];
	for ( int i = l-1; i > 0; i-- ) mes[i] = mes[i-1];
	mes[0] = c;	
      } else if ( ord[i] == 'C' ) {
	int c = mes[0];
	for ( int i = 0; i < l-1; i++ ) mes[i] = mes[i+1];
	mes[l-1] = c;	
      } else if ( ord[i] == 'E' ) {
	string a = "", b = "", c = "";	
	for ( int i = 0; i < l; i++ ) {
	  if ( l%2 && i == l/2 ) b += mes[i];
	  else if ( i < l/2 ) c += mes[i];
	  else a += mes[i];	  
	}
	mes = a+b+c;	
      } else if ( ord[i] == 'A' ) {
	reverse(mes.begin(), mes.end());	
      } else if ( ord[i] == 'P' ) {	
	for ( int i = 0; i < l; i++ ) {
	  if ( mes[i] == '0' ) mes[i] = '9';
	  else if ( isdigit(mes[i]) ) mes[i]--;	  
	}	  
      } else {
	for ( int i = 0; i < l; i++ ) {
	  if ( mes[i] == '9' ) mes[i] = '0';
	  else if ( isdigit(mes[i]) ) mes[i]++;	  
	}
      }      
    }

    cout << mes << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3144
#include <stdio.h>

int main(void){
  int d;
  int ans,i;

  while( 1 ){
    if( scanf("%d ",&d)==EOF )
      break;

    ans = 0;
    for( i=d;i<600;i+=d ){
      ans += (i*i);
    }
    ans*=d;
    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		sc.close();

		int ans = 0;
		if(op.equals("+")) ans = a + b;
		else ans = a - b;

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define L long long
#define pl pair<L,L>
#define aa first
#define bb second
using namespace std;
int n,w[3000],q,p;
L a[100010];
pl x[100010],y;
map<pl,int> f;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	for(i=2;i<=2155;i++)
	  {
	   for(j=2;j*j<=i;j++)
	     if(i%j==0)
	       break;
	   if(j*j>i)
	     w[++q]=i;
	  }
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  {
	   scanf("%lld",&a[i]);
	   x[i].aa=x[i].bb=1;
	   for(j=1;j<=q && w[j]<=a[i];j++)
	     if(a[i]%w[j]==0)
	       {
		    for(k=0;a[i]%w[j]==0;k++,a[i]/=w[j]);
		    if(k%3==1)
		      x[i].aa*=w[j];
		    if(k%3==2)
		      x[i].bb*=w[j];
		   }
	   if(a[i]>1)
	     {
		  k=sqrt(a[i])-2;
		  for(j=k;j<=k+4;j++)
		    if(a[i]==(L)j*j)
		      break;
		  if(j<=k+4)
			x[i].bb*=j;
		  else if(a[i]>2155*2155)
		    {
		     p++;
		     continue;
			}
		  else
		    x[i].aa*=a[i];
		 }
	   f[x[i]]++;
	  }
	for(i=1;i<=n;i++)
	  if(x[i].aa==1 && x[i].bb==1)
	    {
		 if(f[x[i]])
		   p++;
		 f[x[i]]=0;
		}
	  else
	    {
		 y.aa=x[i].bb;
		 y.bb=x[i].aa;
		 p+=max(f[x[i]],f[y]);
		 f[x[i]]=f[y]=0;
		}
	printf("%d\n",p);
	return 0;
}


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

int main()
{
  int rem, happ, quo, quo2, amt;
  cin>>amt;
  quo = amt/500;
  rem = amt%500;
  quo2 = rem/5;
  happ = quo*1000 + quo2*5;
  cout<<happ;
  return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    s = sum(A)
    if A[M-1] >= s/(4*M):
        return True
    return False
if main():
    print('Yes')
else:
    print('No')


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

int N;
int Q;
bool binary_search(int *array, int target){
    int left = 0;
    int right = N;
    int mid;
    while(left < right){
        mid = (left+right)/2;
        if(array[mid] == target) return true;
        else if(array[mid] < target) left = mid+1;
        else right = mid;
    }
    
    return false;
}

int main(void){
    // Your code here!
    
    cin >> N;
    int arr[N];
    for(int i =0;  i < N; i++) cin >> arr[i];
    cin >> Q;
    int S[Q];
    for(int i = 0; i < Q; i++) cin >> S[i];
    
    int ans = 0;
    for(int i = 0; i < Q; i++) {
        bool result = binary_search(arr, S[i]);
        if(result) ans++;
    }
    cout << ans << endl;
    
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k; cin >> n >> k;
  vector<vector<ll>> ncr(n+1,vector<ll>(n+1));
  ncr[0][0] = 1;
  rep(i,n){
    rep(j,i+1){
      ncr[i][j] %= MOD;
      ncr[i+1][j] += ncr[i][j];
      ncr[i+1][j+1] += ncr[i][j];
    }
  }
  rep(i,k){
    cout << ncr[n-k+1][i+1]*ncr[k-1][i]%MOD << endl;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 34608
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	if(A==B) cout<<A*2<<endl;
	else cout<<max(A,B)*2-1<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()
    from collections import Counter
    c = Counter(A)
    if 0 in c.keys() and c[0] == N:
        return print("Yes")
    elif N % 3 == 0 and 0 in c.keys() and c[0] == N//3 and\
            len(c.keys()) == 2:
        return print("Yes")
    elif N % 3 == 0 and len(c.keys()) == 3 and \
            all(N//3 == v for v in c.values()):
        ans = 0
        for k in c.keys():
            ans ^= k
        if ans != 0:
            return print("No")
        else:
            return print("Yes")
    else:
        return print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 60784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			B();
		}

	

		public static void B()
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			Hoge[] values = new Hoge[n];
			string[] s = new string[n];
			int[] p = new int[n];
			for (int i = 0; i < n; i++) {

				string ss = cin.Next();
				int pp = cin.Int();
				values[i] = new Hoge {
					Name = ss,
					P = pp,
					index = i + 1,
				};

			}

			var comp = new HogeComparerRule();
			var temps = values.OrderBy(x => x, comp).ToArray();
			for (int i = 0; i < n; i++) {
				Console.WriteLine(temps[i].index);
			}
		}

		public struct Hoge
		{
			public string Name;
			public int P;
			public int index;
		}

		class HogeComparerRule : IComparer<Hoge>
		{

			public int Compare(Hoge x, Hoge y)
			{

				if (x.Name.CompareTo(y.Name) == 0) {
					return x.P.CompareTo(y.P) * -1;
				}  else {
					return x.Name.CompareTo(y.Name);
				}
			}
		}
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11488
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe





int s(int n){
	int sum=0;
	while(n!=0){
		sum+=n%10; 
		n=n/10;
	}
	return sum;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int n[3],k,ans=0;
cin >> n[0] >> n[1] >> n[2];
cin >> k;
sort(n,n+3);
ans=n[0]+n[1]+n[2]*pow(2,k);
cout << ans << endl; 
///////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
ll n,m;
cin>>n>>m;
ll p=n%m;
cout<<min(p,m-p)<<"\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections


def solve(n: int, S: "List[str]"):
    S = [collections.Counter(s) for s in S]

    A = ''
    for c in range(ord('a'), ord('z')+1):
        mn = 1e12
        for s in S:
            if chr(c) in s.keys():
                mn = min(mn, dict(s.items())[chr(c)])
            else:
                mn = 0
                break
        A += ''.join([chr(c) for _ in range(mn)])
    print(A)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(n) ]  # type: "List[str]"
    solve(n, S)

if __name__ == '__main__':
    main()


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr ll MOD = 1000000007;

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll memo[2005][2005];

ll comb(int i, int j) {
  if (memo[i][j] > 0) return memo[i][j];

  ll l = (i > 0 && i > j) ? comb(i - 1, j) : 0;
  ll r = (i > 0 && j > 0) ? comb(i - 1, j - 1) : 0;

  return memo[i][j] = (l + r) % MOD;
}

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);

  memo[0][0] = 1;

  rep(i, 1, K + 1) {
    ll ans = (comb(N - K + 1, i) * comb(K - 1, i - 1)) % MOD;
    cout << ans % MOD << endl;
  }

  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 30208
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

H, W = LI()

print(1 if H == 1 or W == 1 else math.ceil(H*W/2))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> num(n, 1);
  for (int i=0; i<k; i++){
    int d;
    cin >> d;
    for (int j=0; j<d; j++){
      int a;
      cin >> a;
      if (num.at(a-1) == 1){
        num.at(a-1) = 0;
      }
    }
  }
  int ans=0;
  for (int i=0; i<n; i++){
    ans += num.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
def search(n, m, i)
  return 0 if i == m

  y = 9 * ((m - 1) - i)

  if n[i] == 0 then
    return y
  end

  return [
    n[i] + search(n, m, i + 1),
    (n[i] - 1) + y
  ].max
end

def main(argv)
  n = gets.chomp.split('').map{|c| c.ord - '0'.ord}
  m = n.size

  puts search(n, m, 0).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        if(k <= a){
            System.out.println(k);
        } else if (k <= (a + b)){
            System.out.println(a);
        } else {
            System.out.println(a - (k - a - b));
        }
    }
}

Measured memory_bytes: 35724
#include <iostream>
using namespace std;
 
int main(void){
  int N, K;
  long long int ans = 0;
 
  cin >> N >> K;
  
  int l[N] = {0};
  int counter = 0;
  for(int i = 0; i < K; ++i){
    if((2*i) % K == 0){
      l[counter] = i;
      ++counter;
    } else {
      
    }
  }
  
  for(int i = 0; i < counter; ++i){
    long d1[counter] = {0};
    long d2[counter] = {0};
    long temp1 = 0;
    long temp2 = 0;
 
    while(l[i] + K*temp1 <= 0){
 
      ++temp1;
    }
    while(l[i] + K*d1[i] <= N){
 
      ++d1[i];
    }
    while(K - l[i] + K*temp2 <= 0){
      ++temp2;
    }
    while(K - l[i] + K*d2[i] <= N){
 
      ++d2[i];
    }
    if((d1[i] > temp1) && (d2[i] > temp2)){
      
    ans += (d1[i] - temp1)*(d1[i] - temp1)*(d2[i] - temp2);
    } else {
      
    }
 
    temp1 = temp2 =  0;
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
N=int(input())
count=0
L=list(map(int,input().split()))
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]<L[j]+L[k] and L[j]<L[k]+L[i] and L[k]<L[i]+L[j]:
                if L[i]!=L[k] and L[i]!=L[j] and L[k]!=L[j]:
                    count+=1
print(count)

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




int main()
{
	string S;
	cin >> S;

	if (S == "Sunny") cout << "Cloudy" << endl;
	else if (S == "Cloudy") cout << "Rainy" << endl;
	else if (S == "Rainy") cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 768
n, a, b, c, d = gets.chomp.split.map(&:to_i)
s = gets.chomp
if s[b..d-2].include?("##") || s[a..c-2].include?("##")
  puts "No"
  exit
end
if c < d
  puts "Yes"
else
  if s[b-2..d].include?("...")
    puts "Yes"
    exit
  end
  puts "No"
end


Measured memory_bytes: 2428
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
import java.util.*;

public class Main {
	//////
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	//////

	public static void main(String[] args) throws IOException {

		FastReader scan = new FastReader();
	
		int N=scan.nextInt();
		int A=scan.nextInt();
		int B=scan.nextInt();
		
		System.out.println(Math.min(N*A,B));
		
	}		
}



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

int main(){
    ll n; cin >> n; ll ans = 0;
    vector<ll> l(n); vector<ll> r(n);
    REP(i,n) cin >> l[i] >> r[i];
    l.push_back(0); r.push_back(0);
    sort(l.rbegin(),l.rend()); sort(r.begin(),r.end());
    REP(i,n) if (l[i]>r[i]) ans += l[i]-r[i];
    cout << ans*2 << endl;
}

Measured memory_bytes: 2560
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

int main() {
	int m = input(), d = input(), tot = 0;
	for(int i = 4; i <= m; i ++)
		for(int x = 2; x <= i and x < 10; x ++)
			if(not (i % x) and 2 <= i / x and i / x < 10 and x * 10 + i / x <= d)
				tot ++;
	printf("%d\n", tot);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int[] f = {a,b,c,d,e};
        int time = 0;
        int max = 0;
        for (int n: f) {
            if (n%10 == 0) {
                time += n;
            } else {
                time += n + (10-n%10);
                if (max < (10-n%10)) {
                    max = 10-n%10;
                }
            }
        }
        System.out.println(time-max);
    }
}


Measured memory_bytes: 21972
S = input()
N = len(S)
MOD = 10**9+7
dp = [[0]*(14) for i in range(100010)]
dp[0][0] = 1

for i in range(N):
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])
        
    for j in range(10):
        if c != -1 and c != j:
            continue
        else:
            for k in range(13):
                dp[i+1][(k*10+j)%13] += dp[i][k]
        
    for j in range(13):
        dp[i+1][j] %= MOD
        
print(dp[N][5])

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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

const int maxn = 1e5+1;
ll arr[maxn];
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
	string s;
	cin >> s;
	ll ans =0;
	ll cnt=0;
	for (int i=0;i<s.size();i++) {
		if (s[i] == 'R') cnt++;
		else cnt=0;
		ans=__max(ans,cnt);
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
using namespace std;
int main()
{
	int N;
	string S;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		cin >> S;
		set<string>ans;
		for(int j=1;j<S.length();j++){
			string S1,S2;
			for(int k=0;k<j;k++){
				S1+=S[k];
			}
			for(int k=j;k<S.length();k++){
				S2+=S[k];
			}
			ans.insert(S1+S2);
			ans.insert(S2+S1);
				S1="";S2="";
			for(int k=j-1;k>=0;k--){
				S1+=S[k];
			}
			for(int k=j;k<S.length();k++){
				S2+=S[k];
			}
			ans.insert(S1+S2);
			ans.insert(S2+S1);
			S1="";S2="";
			for(int k=j-1;k>=0;k--){
				S1+=S[k];
			}
			for(int k=S.length()-1;k>=j;k--){
				S2+=S[k];
			}
			ans.insert(S1+S2);
			ans.insert(S2+S1);
			S1="";S2="";
			for(int k=0;k<j;k++){
				S1+=S[k];
			}
			for(int k=S.length()-1;k>=j;k--){
				S2+=S[k];
			}
			ans.insert(S1+S2);
			ans.insert(S2+S1);
		}
		printf("%d\n",ans.size());
	}
}

Measured memory_bytes: 1344
A,B,C,X,Y=map(int,input().split())
if 2*C <= A+B:
  price= 2*C
else:
  price = A+B
maxN = max(X,Y)
miniN = min(X,Y)
res = miniN * price
residue = maxN - miniN
if residue == 0:
  print(res)
elif X > Y:
  res+= min(residue*A, residue*2*C)
  print(res)
elif Y > X:
  res +=  min(residue*B, residue*2*C)
  print(res)

Measured memory_bytes: 9140
N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]
ans = []
for i, s in enumerate(S):
    if s == "AB":
        if A == 0:
            A += 1
            B -= 1
            ans.append("A")
        elif B == 0:
            A -= 1
            B += 1
            ans.append("B")
        else:
            if i + 1 == N or S[i + 1] == "AB":
                A += 1
                B -= 1
                ans.append("A")
            else:
                if S[i + 1] == "BC":
                    A -= 1
                    B += 1
                    ans.append("B")
                else:
                    A += 1
                    B -= 1
                    ans.append("A")

        if A < 0 or B < 0:
            print("No")
            exit()
    elif s == "BC":
        if B == 0:
            B += 1
            C -= 1
            ans.append("B")
        elif C == 0:
            B -= 1
            C += 1
            ans.append("C")
        else:
            if i + 1 == N or S[i + 1] == "BC":
                B += 1
                C -= 1
                ans.append("B")
            else:
                if S[i + 1] == "AB":
                    B += 1
                    C -= 1
                    ans.append("B")
                else:
                    B -= 1
                    C += 1
                    ans.append("C")

        if B < 0 or C < 0:
            print("No")
            exit()
    else:
        if C == 0:
            C += 1
            A -= 1
            ans.append("C")
        elif A == 0:
            C -= 1
            A += 1
            ans.append("A")
        else:
            if i + 1 == N or S[i + 1] == "AC":
                A += 1
                C -= 1
                ans.append("A")
            else:
                if S[i + 1] == "AB":
                    A += 1
                    C -= 1
                    ans.append("A")
                else:
                    A -= 1
                    C += 1
                    ans.append("C")

        if A < 0 or C < 0:
            print("No")
            exit()
print("Yes")
for x in ans:
    print(x)

Measured memory_bytes: 17108
from math import sqrt

def cal_factors(num):
    factors = {}
    maxmod = int(sqrt(num)) + 1
    for mod in range(2, maxmod):
        i = 0
        while True:
            d, q = divmod(num, mod)
            if q == 0:
                num = d
                i += 1
                factors[mod] = i
            else:
                break

    if num > 1:
        factors[num] = 1

    return factors


def comb(n, r, mod):
    result = 1
    r = min(r, n-r)
    for i in range(n, n-r, -1):
        result *= i
    for i in range(2, r+1):
        result //= i

    return result % mod


n, m = [int(v) for v in input().split()]

mod = 1000000000 + 7
factors = cal_factors(m)
ans = 1
for v in factors.values():
    ans *= comb(v + n - 1, v, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 3064