akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class DSquirrelMerchant {
        private static final int three = 3;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();
            int[] a = new int[three];
            for (int i = 0; i < three; i++)
                a[i] = in.nextInt();
            int[] b = new int[three];
            for (int i = 0; i < three; i++)
                b[i] = in.nextInt();

            n = solve(n, a, b);
            n = solve(n, b, a);

            out.println(n);
        }

        private long solve(long n, int[] first, int[] second) {
            int count = 1;
            for (int i = 0; i < three; i++)
                if (second[i] - first[i] > 0)
                    count++;
            int[] cost = new int[count];
            int[] val = new int[count];
            cost[0] = 1;
            val[0] = 1;
            for (int i = 0, index = 1; i < three; i++) {
                if (second[i] - first[i] > 0) {
                    val[index] = second[i];
                    cost[index] = first[i];
                    index++;
                }
            }

            long[] dp = new long[(int) (n + 1)];
            dp[0] = 0;
            for (int costUsed = 1; costUsed <= n; costUsed++) {
                for (int i = 0; i < count; i++) {
                    if (costUsed - cost[i] < 0)
                        continue;
                    dp[costUsed] = Math.max(dp[costUsed], dp[costUsed - cost[i]] + val[i]);
                }
            }

            return dp[(int) n];
        }

    }

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

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

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

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

    }
}



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

int main()
{
    ll n,q=1,x,y;
    double ans=0;
    cin>>n;
    for(int i=1;i<n;i++)q*=i;
    ll a[n][2];
    rep(i,n) cin>>a[i][0]>>a[i][1];
    rep(i,n)rep(j,n){
        x=(a[i][0]-a[j][0]);
        y=(a[i][1]-a[j][1]);
        ans+=sqrt(x*x+y*y)*q;
    }
    cout<<fixed<<setprecision(8)<<ans/(q*n)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
   ll n,h,sum=0;
   cin>>n>>h;
   for(int i=0;i<h;i++)
   {
       ll a;
       cin>>a;
       sum+=a;
   }
   if(n-sum<=0)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}

int main()
{

    //freopen("Input.txt","r",stdin);
    ios_base :: sync_with_stdio(false);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	// your code goes here
    	 stack<int> num;
      string str;
     
      while(cin >> str){
        if(str == "+" || str == "-" || str == "*"){
          int x = num.top();
          num.pop();
          int y=num.top();
          num.pop();
     
          if(str=="+"){
    	num.push(x+y);
          }
          else if(str=="-"){
    	num.push(y-x);
          }
          else if(str=="*"){
    	num.push(x*y);
          }
     
        }
        else{
          num.push(atoi(str.c_str()));
        }
      }
     
      cout << num.top() << endl;
    	return 0;
    }


Measured memory_bytes: 3144
#include<stdio.h>
int main()
{
    char A[3][4];
    int i,j, p, q;
    for(i=0; i<3; i++)
    {
        for(j=0;j<4;j++)
        {
            scanf("%c", &A[i][j]);
        }
    }

    for(p=0; p<3; p++)
    {
        printf("%c", A[p][p]);
    }

    return 0;

}


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


void dfs(string S, char max_char, int N){
  if(S.size()==N){
      cout << S << endl;
      return;
  }
  for(char c='a'; c<=max_char; c++){
    dfs(S+c, max_char, N);
  }
  max_char++;
  dfs(S+max_char, max_char, N);
}

int main(){
  int N;
  cin >> N;
  dfs("a", 'a', N);
  return 0;
}


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

int main()
{
    int s,w;

    cin >> s >> w;

    if( w>=s)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin>>s>>t;
    sort(all(s));
    sort(rall(t));
    if (s<t){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


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

void db(int a, int b, int c) {
  cout << "a=" << a <<",b=" << b << ",c=" << c << endl;
}

int main(int argc, char **argv) {
  int N;
  cin >> N;

  vector<int> L(N);
  int x;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end(), greater<int>());

  int cnt = 0;
  int a, b, c;
  for (int i = 0; i < N - 2; i++) {
    c = L[i];
    for (int j = i + 1; j < N - 1; j++) {
      b = L[j];
      for (int k = j + 1; k < N; k++) {
        a = L[k];

        if (c < a + b) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    std::vector<ll> v;
    ll n,m;
    cin >> n>>m;
    ll a[m],b[m];
    rp(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    rp(i,n){
        v.pb(0);
    }
    rp(i,m) {
        v[a[i]]++;
        v[b[i]]++;
    }
    rp(i,n) {
        cout << v[i]<<endl;
    }

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = set(input())
    bl = False
    if S=={'E', 'W', 'N', 'S'}:
        bl = True
    if S=={'E', 'W'}:
        bl=True
    if S=={'N', 'S'}:
        bl = True
    print('Yes' if bl else 'No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String x = scan.next();
		if(x.matches("^[a-z]*$"))System.out.println('a');
		else if(x.matches("^[A-Z]*$")) System.out.println('A');
		scan.close();
	}

}


Measured memory_bytes: 35664
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int Q;
    cin >> Q;

    priority_queue<int, vector<int>, less<int>> first;
    priority_queue<int, vector<int>, greater<int>> second;

    ll sum = 0;

    rep(i, 0, Q)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int a, b;
            cin >> a >> b;

            if (!first.empty() && (a < first.top()))
            {
                sum += abs(a - first.top());
            }
            else if (!second.empty() && (a > second.top()))
            {
                sum += abs(a - second.top());
            }
            sum += b;

            first.push(a);
            second.push(a);

            if (first.top() > second.top())
            {
                const int firstTop = first.top();
                const int secondTop = second.top();
                first.pop();
                second.pop();
                first.push(secondTop);
                second.push(firstTop);
            }
        }
        else
        {
            cout << first.top() << " " << sum << endl;
        }
    }
}


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

using ll=long long;

int main() {
    ll i,N,K,sa=0,t,m,l=-1,r=1e12;
    cin >> N >> K;
    vector<ll> A(N), F(N);

    for(i=0; i<N; i++) {
        cin >> A.at(i);
        sa += A.at(i);
    }
    for(i=0; i<N; i++)
        cin >> F.at(i);

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<>());

    while(r-l != 1) {
        m = (l+r)/2;

        t=0;
        for(i=0; i<N; i++)
            t += min(A.at(i), m/F.at(i));
        
        if(sa-t <= K)
            r = m;
        else
            l = m;
    }

    cout << r << endl;
}

Measured memory_bytes: 3328
def submit():
    s = input()
    n = len(s)
    # 右方向にR基準の距離を格納する
    # 左方向にL基準の距離を格納する
    dist = [-1 for _ in range(n)]
    curr_r = 0
    curr_l = 0
    for i in range(1, n):
        cr = s[i]
        curr_r += 1
        if cr == "L":
            dist[i] = -curr_r
        else:
            curr_r = 0

        cl = s[n - i - 1]
        curr_l += 1
        if cl == "R":
            dist[n - i - 1] = curr_l
        else:
            curr_l = 0 
        
    count = [0 for _ in range(n)]
    for i in range(n):
        if dist[i] % 2 == 0:
            # xxxRxのR or xLxxxのLで止まる
            count[i + dist[i]] += 1
        else:
            if s[i] == 'R':
                # xxxRLxのRで止まるはず
                count[i + dist[i] - 1] += 1
            else: 
                # xRLxxxのLで止まるはず
                count[i + dist[i] + 1] += 1
    print(" ".join(map(str, count)))
    
submit()

    

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

int calculate_divisor_count(int x) {
    int cnt = 1; 

    int y = 2;
    while(true) {
        int z = 1;
        while(x % y == 0) {
            x /= y;
            z++;
        }
        cnt *= z;
        if (x == 1) break;
        y++;
    }
    return cnt;
}

int main() {
    int N; cin >> N;
    int ans = 0;
    for(int x = 3; x <= N; x += 2) if (calculate_divisor_count(x) == 8) ans++; 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3010][3010];
int main()
{
    ios::sync_with_stdio(false);
    string a,b;
    int i,j;
    cin>>a>>b;
    int lena=a.size(),lenb=b.size();
    memset(dp,0,sizeof dp);
    for(i=1;i<=lena;i++)
    {
        for(j=1;j<=lenb;j++)
        {
            if(a[i-1]==b[j-1])dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
//    cout<<dp[lena][lenb]<<endl;
    i=lena,j=lenb;
    string ans="";
    while(i>0&&j>0)
    {
        if(dp[i][j]==dp[i-1][j])i--;
        else if(dp[i][j]==dp[i][j-1])j--;
        else
        {
            ans+=a[i-1];
            i--;
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


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

using namespace std;

int main(int argc,char* argv[]){
	int N,M;
	cin >> N >> M;
	long long int x[N],y[N],z[N];
	long long int a[8][N],sum[8],max=0;
	for(int i=0;i<8;i++) for(int j=0;j<N;j++) a[i][j] = 0;
	for(int i=0;i<N;i++) {
		cin >> x[i] >> y[i] >> z[i];
		a[0][i] = x[i]+y[i]+z[i];
		a[1][i] = x[i]+y[i]-z[i];
		a[2][i] = x[i]-y[i]+z[i];
		a[3][i] = -1*x[i]+y[i]+z[i];
		a[4][i] = x[i]-y[i]-z[i];
		a[5][i] = -1*x[i]-y[i]+z[i];
		a[6][i] = -1*x[i]+y[i]-z[i];
		a[7][i] = -1*x[i]-y[i]-z[i];
	}
 	for(int i=0;i<8;i++) sort(&a[i][0],&a[i][0]+N);
	for(int i=0;i<8;i++) sum[i] = 0;
	for(int i=1;i<=M;i++) for(int j=0;j<8;j++) sum[j]+=a[j][N-i];
	for(int i=0;i<8;i++) {
		if(max < sum[i]) max = sum[i];
	}
	cout << max << endl;
	return 0;
}

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

int main(void){
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> P(N, K - Q);
    for(int i = 0; i < Q; i++){
        int A;
        cin >> A;
        P[A - 1]++;
    }
    for(int i = 0; i < N; i++){
        if(P[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
use std::str::FromStr;
use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let (a, b) = i.read2::<u32, u32>();

    fn is_palindrome(mut x: u32) -> bool {
        let mut xs = [0; 5];
        for i in 0..5 {
            xs[i] = x % 10;
            x /= 10;
        }
        xs[0] == xs[4] && xs[1] == xs[3]
    }
    let c = (a..b + 1).filter(|&x| is_palindrome(x)).count();

    writeln!(o, "{}", c).unwrap();
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(v1: T1, v2: T2) }
    }

    fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


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

#define int long long
#define MOD 1000000007

int H, W, A, B;
int _fact[200000];

int pow_mod(int x, int k) {
  int a = 1;
  while (k > 0) {
    if (k & 1LL) a = (a*x) % MOD;
    x = (x*x) % MOD;
    k >>= 1;
  }
  return a;
}

int inv(int x) {
  return pow_mod(x, MOD-2);
}

int fact(int x) {
  if (_fact[x] != -1) return _fact[x];
  return _fact[x] = (x * fact(x-1)) % MOD;
}

int nCr(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return (fact(n) * inv((fact(k) * fact(n-k)) % MOD)) % MOD;
}

int comb(int x, int y) {
  return nCr(x+y, x);
}

signed main() {
  cin >> H >> W >> A >> B;

  for (int i=0; i<200000; i++) _fact[i] = -1;
  _fact[0] = 1;

  int s = 0;
  for (int i=0; i<=H-A-1; i++) {
    s += (comb(B-1, i) * comb(W-B-1, H-1-i)) % MOD;
    s %= MOD;
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 4864
import bisect

_ = input()
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort()
C.sort()

ans = 0
for b in B:
    a = bisect.bisect_left(A, b)
    c = len(C) - bisect.bisect_right(C, b)
    ans += a * c
else:
    print(ans)

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

typedef unsigned long long int ulli;

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

	ulli n, ans = 0;
	cin >> n;
	map<int, int> m;
	for (int i = 1; i <= n; i++) {
		int temp;
		cin >> temp;
		ans += m[i-temp];
		m[i+temp]++;
	}
	cout << ans;
}

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

using namespace std;
long long int  gcd(long long int a, long long int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}
int main()
{
    long long int num,num_1;
    long long int sum;
    cin>>num;cin>>num_1;
    sum=((num*num_1)/gcd(num,num_1));
    cout<<sum<<endl;
    return 0;
}


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

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

constexpr int MOD = 1e+9 + 7;

// Greatest Common Multiple (GCD)
// 2数の最大公約数 by ユークリッド互助法
template <typename T>
T gcd(T a, T b)
{
    if(b == 0) return a;
    else return gcd<T>(b, a % b);
}

// 繰り返し二乗法(Exponentiation by squaring)
// n^8 = ((n^2)^2)^2 を利用する
template <typename T>
T pow_mod(T n, T p, T m)
{
    if(p == 0) return 1;
    if(p%2 == 1) return pow_mod<T>(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod<T>(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

int main()
{
    int N;
    cin >> N;
    map<pair<long long,long long>, pair<int,int>> P;
    int num_zeros = 0;
    REP(i, N){
        long long A, B;
        cin >> A >> B;
        if(A == 0 and B == 0){ // (0, 0) は全てのイワシと仲が悪い
            ++num_zeros;  
            continue;
        }
        // A/B の組を記録
        long long GCD = gcd<long long>(A, B);  // (正, 負) の gcd は負になるので注意
        A /= GCD;
        B /= GCD;
        if(B < 0){  // A < 0 となるようにする
            A = -A;  
            B = -B;
        }
        // A の正負で first, second を分類
        if(A > 0) P[make_pair(A, B)].first++;
        else P[make_pair(B, -A)].second++;
    }

    long long ans = 1;
    for(auto p: P){
        int num_i = p.second.first;
        int num_j = p.second.second;
        long long num_pairs = pow_mod<long long>(2, num_i, MOD) + pow_mod<long long>(2, num_j, MOD) - 1;
        ans *= num_pairs%MOD;
        ans %= MOD;
    }
    cout << (ans+num_zeros-1+MOD)%MOD << endl;

    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    
    bool f = true;

    if (s[0] != 'A') {
        f = false;
    }

    if (s[1] <= 'Z') {
        f = false;
    }

    bool f1 = false;
    for (int i = 2; i <= s.length() - 2; i++) {
        if (s[i] == 'C') {
            if (f1) {
                f = false;
                break;
            } else {
                f1 = true;
            }
        } else if (s[i] <= 'Z') {
            f = false;
            break;
        }
    }
    f = f && f1;

    if (s[s.length() - 1] <= 'Z') {
        f = false;
    }

    cout << (f ? "AC" : "WA") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
string s;

int go (int i, int j) {
    while (i < j) {
        if (s[i] == s[j]) {
            i++;
            j--;
        }
        else {
            return 0;
        }
    }
    return 1;
}

void testCase() {
   // string s;
    cin >> s;
    int n = s.size();
    int ok = 1;
    ok = go (0, n-1);
    if (ok == 0) {
        cout << "No" << endl;
        return;
    }
    ok = go (0, (n-1)/2-1);
    if (ok == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// Segment Tree
template <typename T>
class SegTree {
public:
  SegTree(int _n) {
    n = 1;
    while (n < _n) { n *= 2; }
    dat = vector<T>(2 * n - 1, 0);
  }

  // void update(int k, T a) {
  //   k += n - 1;
  //   dat[k] = a;
  //   while (k > 0) {
  //     k = (k - 1) / 2;
  //     dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
  //   }
  // }

  void add(int k, T a) {
    k += n - 1;
    dat[k] += a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
    }
  }

  // Calculate the sum of [a, b)
  T query(int a, int b) {
    return _query(a, b, 0, 0, n);
  }

  // Calculate the sum of [a, b)
  // k is the index (dat[k]). This is matched to [l, r)
  T _query(int a, int b, int k, int l, int r) {
    // The intersection of [a, b) and [r, l) is blank.
    if (r <= a || b <= l) { return 0; }

    if (a <= l && r <= b) {  // [r, l) is completely included in [a, b)
      return dat[k];
    } else {
      int vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);
      int vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
      return vl + vr;
    }
  }

private:
  int n; // The size of source data. The power of 2.
  vector<T> dat; // The data. The size if 2*n-1. The last n elements(dat[n..2*n-2]) are leaves(source data). The first n-1 elements are nodes.
};

// int main(int argc, char** argv) {
//   int arr[] = { 1, 3, 2, 7, 9, 11 };
//   int n = 6;
//
//   SegTree<int> st(n);
//   rep(i, n) {
//     st.add(i, arr[i]);
//   }
//
//   cout << st.query(1, 5) << endl; // 21
//   cout << st.query(0, 4) << endl; // 13
//   cout << st.query(3, 5) << endl; // 16
//
//   st.add(4, 10);
//   cout << st.query(3, 5) << endl; // 26
// }

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) {
    cin >> L[i];
  }
  sort(all(L)); // Now, L is sorted

  // Here, we want to calculate the count of c < a + b. c is the largest number.
  // This is calculated by BIT.
  // add(a+b, 1).
  // sum(MAXA + MAXB) - sum(c).

  ll ans = 0;
  SegTree<int> tree(2010);
  tree.add(L[0] + L[1], 1);

  for (int i = 2; i < N; ++i) {
    int c = L[i];
    // For Debug
    // cout << "L["<<i<<"]: "<< L[i] << endl;
    // cout << tree.query(c+1, 2010) << endl;

    ans += tree.query(c+1, 2010); // The count of c < a + b
    rep(j, i) { // 0, 1, .. i-1.
      tree.add(L[j] + c, 1);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

var (
	n     int
	h, dp []int
)

func main() {
	fmt.Scan(&n)

	h = make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	dp = make([]int, n)
	for i := range dp {
		dp[i] = -1
	}

	fmt.Println(recDp(n - 1))
}

func recDp(i int) int {
	if i == 0 {
		return 0
	}
	if dp[i] != -1 {
		return dp[i]
	}
	var res int
	if i-2 < 0 {
		res = recDp(i-1) + abs(h[i]-h[i-1])
	} else {
		res = min(
			recDp(i-1)+abs(h[i]-h[i-1]),
			recDp(i-2)+abs(h[i]-h[i-2]),
		)
	}
	dp[i] = res
	return res
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 12672
# keyence2019C - Exam and Wizard
def main():
    N, *AB = map(int, open(0).read().split())
    ans, shortage, pos = 0, 0, []
    for i, j in zip(AB[:N], AB[N:]):
        x = i - j
        if x >= 0:
            pos.append(x)
        else:
            ans += 1
            shortage += x
    for i in sorted(pos, reverse=1):
        if shortage >= 0:
            break
        ans += 1
        shortage += i
    flg = shortage >= 0
    print(ans if flg else -1)  # -1: shoratage still remains


if __name__ == "__main__":
    main()

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

int main() {
  int k, x; cin >> k >> x;
  if (500 * k >= x) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  ll N,K,Q;
  cin>>N>>K>>Q;
  vector<ll> A(N,K-Q);
  for(int i=0;i<Q;i++){
    ll a;
    cin>>a;
    a--;
    A[a]++;
  }
  ll cnt=0;
  for(auto &I:A){
    if(I>0){cnt++;}
  }
  for(auto &I:A){
    cout<<(I>0?"Yes":"No")<<endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<cstdlib>
#include<cmath>
using namespace std;
int d[1000001];
int l[1000001];
int main()
{
   int d=0;
   int c=1;
   int n,x;
   cin>>n>>x;
   for(int i=0; i<n; i++)
   {
       int l;
       cin>>l;
       d=d+l;
       if(d<=x)c++;
   }
   cout<<c<<endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long[] arr = new long[n];
      int negCnt = 0;
      long sum = 0;
      long min = Long.MAX_VALUE;
      for(int i = 0; i < n; i++) {
        long num = sc.nextLong();
        if(num < 0) negCnt++;
        arr[i] = Math.abs(num);
        sum += arr[i];
        min = Math.min(min, arr[i]);
      }
      if(negCnt % 2 == 1) {
        sum -= min*2;
      }
      System.out.println(sum);
  }
}

Measured memory_bytes: 52464
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
        int N;
        Scanner in=new Scanner(System.in);
        N=in.nextInt();
        int[] a=new int[N];
        int[] b=new int[N];
        int[] c=new int[N];
        for(int i=0;i<N;i++){
            a[i]=in.nextInt();
            b[i]=in.nextInt();
            c[i]=in.nextInt();
        }
        int[][] dp=new int[N+1][3];
        dp[1][0]=a[0];
        dp[1][1]=b[0];
        dp[1][2]=c[0];
        for(int i=1;i<N;i++){
            dp[i+1][0]=a[i]+Math.max(dp[i][1],dp[i][2]);
            dp[i+1][1]=b[i]+Math.max(dp[i][0],dp[i][2]);
            dp[i+1][2]=c[i]+Math.max(dp[i][0],dp[i][1]);
        }
        System.out.println(Math.max(Math.max(dp[N][0],dp[N][1]),Math.max(dp[N][1],dp[N][2])));
    }
}

Measured memory_bytes: 96104
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
using namespace std;

#define LL long long

const int CP=110;
const int CE=CP*CP*20;

const LL INF=0x3f3f3f3f3f3f3f3f;

LL read(){
	LL s=0,ne=1; char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') ne=-1;
	for(;c>='0'&&c<='9';c=getchar()) s=(s<<1)+(s<<3)+c-'0';
	return s*ne;
}

class fs{
  public:
  	int from,to,nxt; LL cap,flow;
  	void init(int f,int t,int n,LL c,LL fl)
  	{from=f;to=t;nxt=n;cap=c;flow=fl;}
}E[CE];
int hd[CP],ecnt=1;
void add(int x,int y,LL z){
	E[++ecnt].init(x,y,hd[x],z,0);
	hd[x] = ecnt;
	E[++ecnt].init(y,x,hd[y],0,0);
	hd[y] = ecnt;
}

//v define
int n;
LL a[CP];
void copy(int *a,int *b,int pos,int sz){
	for(int i=pos;i<pos+sz;i++) b[i] = a[i];
}

//dinic
int dep[CP];
bool build(int s,int t){ //构造分层图 
	memset(dep,0,sizeof(dep));
	dep[s] = 1;
	
	queue<int> Q;
	Q.push(s);
	
	while(!Q.empty()){
		int u = Q.front();
		Q.pop(); 
		
		for(int k=hd[u]; k; k=E[k].nxt){
			int v = E[k].to;
			if(!dep[v] && E[k].cap-E[k].flow>0){
				dep[v] = dep[u]+1;
				Q.push(v);
			}
		}
	}
	
	return dep[t];
}
LL augment(int u,int t,LL rst){ //多路增广 
	if(u == t) return rst;
	
	LL used = 0;
	for(int k=hd[u]; k; k=E[k].nxt){
		fs &e = E[k];
		
		if(dep[e.to] == dep[u]+1){
			LL a = augment(e.to,t, min(rst-used,e.cap-e.flow));
			if(a){
				used += a;
				E[k].flow += a;
				E[k^1].flow -= a;
				if(used == rst) return rst;
			}
		}
	}
	
	return used;
}
LL mf(int s,int t){
	LL _mf = 0;
	while(build(s,t))
		_mf += augment(s,t,INF);
	return _mf;
}

int main()
{
	n = read();
	for(int i=1;i<=n;i++)
	    a[i] = read();
		
	for(int i=1;i<=n;i++)
	    for(int k=2;i*k<=n;k++)
		    add(i,i*k,INF);
	int s = n+1,t = n+2;
	for(int i=1;i<=n;i++)
	    if(a[i] > 0) add(i,t,a[i]);
		    else add(s,i,-a[i]);
	
	LL sum = 0,sigma = 0;
	for(int i=1;i<=n;i++) //求负权的绝对值之和 
	    if(a[i] < 0) sigma -= a[i];
	for(int i=1;i<=n;i++)
	    sum += a[i];
	
	printf("%lld",sum+(sigma-mf(s,t)));	
		    
	return 0;
}

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

int n,c[N][2],l[N][2];
vector<pair<int,int> > f[N];

bool cmp(pair<int,int> x,pair<int,int> y){
	return x.second<y.second;
}

bool check(int k){
	for (int z=n;z>=1;z--){
		if (!c[z][0]){
			f[z].clear();
			f[z].push_back(make_pair(0,0));
			continue;
		}
		
		f[z].clear();int x=c[z][0],y=c[z][1];
		for (int i=0;i<(int)f[x].size();i++)
			f[x][i].first+=l[z][0],f[x][i].second+=l[z][0];
		for (int i=0;i<(int)f[y].size();i++)
			f[y][i].first+=l[z][1],f[y][i].second+=l[z][1];
		if (f[x].size()>f[y].size()) swap(x,y);
			
		sort(f[x].begin(),f[x].end(),cmp);
		sort(f[y].begin(),f[y].end());
		for (int i=(int)f[x].size()-1,j=0,t=1<<30;i>=0;i--){
			while (j<(int)f[y].size()&&f[x][i].second+f[y][j].first<=k)
				t=min(t,f[y][j].second),j++;
			if (j) f[z].push_back(make_pair(f[x][i].first,t));
		}
			
		sort(f[x].begin(),f[x].end());
		sort(f[y].begin(),f[y].end(),cmp);
		for (int i=(int)f[x].size()-1,j=0,t=1<<30;i>=0;i--){
			while (j<(int)f[y].size()&&f[y][j].second+f[x][i].first<=k)
				t=min(t,f[y][j].first),j++;
			if (j) f[z].push_back(make_pair(t,f[x][i].second));
		}
	}
	return !f[1].empty();
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=2;i<=n;i++){
		int x=read(),y=read();
		if (!c[x][0]) c[x][0]=i,l[x][0]=y;
		else c[x][1]=i,l[x][1]=y;
	}
	int ans=-1;
	for (int k=1<<30;k;k/=2)
		if (!check(ans+k)) ans+=k;
	printf("%d\n",ans+1);
	return 0;
}

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

int main() {
  int N, M;
  cin >> N;
  vector<string> blue(N);
  for (int i=0; i<N; i++) cin >> blue.at(i);
  cin >> M;
  vector<string> red(M);
  for (int i=0; i<M; i++) cin >> red.at(i);
  int maxs=0, s;
  for (int i=0; i<N; i++) {
    s = 1;
    for (int j=i+1; j<N; j++)
      if (blue.at(i) == blue.at(j)) s++;
    for (int j=0; j<M; j++)
      if (blue.at(i) == red.at(j)) s--;
    if (maxs < s) maxs = s;
  }
  cout << maxs << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi 3.141592653589793238
int main()
{
	int a,b,n,k;
	cin>>a>>b>>n>>k;
	double f=k*6;
	double h=n*30+k/2.0;
	double  m=1.0*(f-h)*pi/180;
	double ans=a*a+b*b-2*a*b*cos(m);
	printf("%.20f\n",sqrt(ans));
 } 


Measured memory_bytes: 4184
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll v[10] = {0,2,5,5,4,5,6,3,7,6};  // v[i] : 数字iを作るのに必要なマッチの本数
 
int main() {
    ll n, m;
    cin >> n >> m;

    vl a(m);
    rep(i, m) {
        cin >> a[i];
    }
    sort(rall(a));

    vl dp(n+100, -INF);  // dp[i] : i本で作れる桁数の最大値
    dp[0] = 0;
    rep(i, n) {
        rep(j, m) {
            chmax(dp[i + v[a[j]]], dp[i] + 1);
        }
    }

    ll cnt = n;  // 残りのマッチの本数
    while(cnt != 0) {
        rep(j, m) {
            if(cnt >= v[a[j]] && dp[cnt] == dp[cnt - v[a[j]]] + 1) {
                cout << a[j];
                cnt -= v[a[j]]; 
                break;
            }
        }
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>
using namespace std;
int main() {
    int n;
    cin >> n;
    set<string> st;
    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}

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

int D;
vector<int> c(26); 
vector<vector<int>> s(365, vector<int>(26));

int cal_score(vector<int> t){
    int satis = 0;
    vector<int> last(26, 0);
    rep(d, D){
        satis += s[d][t[d] - 1];
        last[t[d] - 1] = d + 1;
        rep(i, 26){
            satis -= c[i] * (d - last[i] + 1);
        }
    }
    return satis;
}

int ch_sch(vector<int> t, int d, int q, int score){
    // change t[d - 1] -> q
    // calculate the score
    int old = t[d - 1];
    score -= s[d - 1][old - 1];
    score += s[d - 1][q - 1];

    int last_old = 0, last_new = 0;
    rep(i, D){
        if(t[i] == old ) last_old = i + 1;
        else if(t[i] == q) last_new = i + 1;
        score += c[old - 1] * (i - last_old + 1);
        score += c[q - 1] * (i - last_new + 1);
    }

    t[d - 1] = q;

    last_old = 0, last_new = 0;
    rep(i, D){
        if(t[i] == old) last_old = i + 1;
        else if(t[i] == q) last_new = i + 1;
        score -= c[old - 1] * (i - last_old + 1);
        score -= c[q - 1] * (i - last_new + 1);
    }
    return score;
}

int main(){
    srand((unsigned)time(NULL));

    // input 
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D){
        rep(j, 26){
            cin >> s[i][j];
        }
    }

    // greedy
    vector<int> last(26, 0);
    vector<int> res(D);

    rep(d, D){
        int max_plus = -10000;
        int use = -1;
        rep(i, 26){
            int tmp = s[d][i] + c[i] * (d - last[i] + 1);
            if(max_plus < tmp){
                max_plus = tmp;
                use = i;
            }
        }
        last[use] = d + 1;
        res[d] = use + 1;
    }

    int cur_score = cal_score(res);
    //int ch_d = 1;
    //int cnt = 0;

    while((clock() / (double)CLOCKS_PER_SEC) <= 1.98){
        // cnt++;
        int ch_d = rand() % D + 1;
        int ch_c = rand() % 26 + 1;
        // int ifch = rand() % 100;
        int new_score = ch_sch(res, ch_d, ch_c, cur_score);
        if(cur_score < new_score){
            cur_score = new_score;
            res[ch_d - 1] = ch_c;
            // ch_d--;
            // if(ch_d == 0) ch_d = D;
        }
    }

    rep(i, D){
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3708
// RK's Template
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef long double ld; 
typedef unsigned long long ull;

int main(){
	char s[4];
	int n=0;
	cin >> s; 
	for(int i=0;i<3; i++){
		if(s[i] == '1') n++;
	}
	cout << n << endl;
}


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

int main() {
	string s;
	cin >> s;
	int flag = 0;
	for(int i = 0;i < s.length();i++){
		if(!flag && s[i] == 'C') flag++;
		else if(flag == 1 && s[i] == 'F') flag++;
	}
	if(flag == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nab = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        if (nab[1] > nab[2]) { WriteLine(0);return; }
        if (nab[0] == 1 && nab[1] == nab[2]) { WriteLine(1);return; }
        else if (nab[0] == 1) { WriteLine(0);return; }

        WriteLine((long)(nab[0] - 2) * (nab[2] - nab[1]) + 1);
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
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; }
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
string s;

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

  cin >> s;

  int ans = 700;

  rep(i, s.size()) {
    char a= s[i];
    if (a == 'o') ans+=100;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

void test_case()
{
    int h1,s1,h2,s2;
    cin>>h1>>s1>>h2>>s2;

    while(h1>0 && h2>0)
    {
        h2-=s1;
        if(h2<=0){
            printf("Yes\n");
            return;
        }
        h1-=s2;
        if(h1<=0){
            puts("No");
            return;
        }
    }
}

int main()
{
        test_case();

    return 0;
}


Measured memory_bytes: 3604
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import math
import itertools as itr


l = []
for i in range(5):
  l.append(int(input()))

l_p = list(itr.permutations(l))
ans = 643
for l in l_p:
  ret = 0
  for t in l[:-1]:
    ret += math.ceil(t/10)*10
  ret += l[-1]
  ans = min(ret, ans)

print(ans)


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

int used[100005];

int main(void){
    int N; cin >> N;
    vector<pair<long long, pair<int, int>>> A(N);
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        A[i] = {a+b, {a, b}};
    }
    long long Tsum = 0;
    long long Asum = 0;
    sort(A.begin(), A.end(), greater<pair<long long, pair<int, int>>>());
    for (int i = 0; i < N; i++) {
        if (i % 2) {
            Asum += A[i].second.second;
        } else {
            Tsum += A[i].second.first;
        }
    }
    cout << Tsum - Asum << endl;
}


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()ss		
#define debug system("pause")				//デバッグ用


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

	double n, k;
	cin >> n >> k;
	vector<double> t(n);

	double tmp;
	double kakuritu = 0;
	double toku;
	for (int i = 1; i <= n; i++)
	{
		tmp = 1.0 / n;
		toku = i;
		while (toku<k)
		{
			toku *= 2;
			tmp *=(0.5);
		}
		kakuritu += tmp;
	}

	cout << std::setprecision(12)<<kakuritu << endl;

}

Measured memory_bytes: 1024
N, M, L = map(int, input().split())

INF = 10 ** 18
dist1 = [[INF] * N for _ in range(N)]
for i in range(N):
    dist1[i][i] = 0

for _ in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    dist1[A][B] = C
    dist1[B][A] = C

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist1[i][j] = min(dist1[i][j], dist1[i][k] + dist1[k][j])

dist2 = [[INF] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if dist1[i][j] <= L:
            dist2[i][j] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j])

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    if dist2[s][t] >= INF:
        print (-1)
    else:
        print (dist2[s][t] - 1)

Measured memory_bytes: 60504
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	string s = ReadLine();
    int a = int.Parse(s.Substring(0,2));
    int b = int.Parse(s.Substring(2,2));
    bool ma=false;
    bool mb=false;
    if (0<a & a<13)
      ma=true;
    if(0<b & b<13)
      mb=true;
    if(ma){
      if(mb)
      	WriteLine("AMBIGUOUS");
    	else
          WriteLine("MMYY");
    }
    else if(mb)
      WriteLine("YYMM");
    else
      WriteLine("NA");
  }
}


Measured memory_bytes: 13140
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int x;
    rep(i, n){
        cin >> a[i];
    }
    int ans = (n-1) / (k-1);
    if((n-1) % (k-1) != 0){
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
def main():

    N = int(input())
    ans = [0] * (N + 1)

    for x in range(1, int(N ** 0.5) + 2):
        for y in range(1, int(N ** 0.5) + 2):
            for z in range(1, int(N ** 0.5) + 2):
                n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if n > N:
                    continue

                ans[n] += 1
    print(*ans[1:], sep="\n")


if __name__ == '__main__':
    main()

Measured memory_bytes: 9640
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int A, B, C;
  int X;
  cin >> A >> B >> C >> X;
  int ans = 0;

  for (int i = 0; i <= A; i++){
    for (int j = 0; j <= B; j++){
      for (int k = 0; k <= C; k++){
        int tmp = i * 500 + j * 100 + k * 50;
        if(tmp == X) ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,i,a[1000009],p;
int main() {
  cin>>n>>k;
 for(i=0;i<=n;i++)
 cin>>a[i];
for(i=0;i<=n;i++)
 if(a[i]>=k)
 p++;
 cout<<p;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int r=n%10;
    if(r==3){printf("bon");}
    else if(r==0||r==1||r==6||r==8)
    {printf("pon");}
    else printf("hon");
    return 0;
}

Measured memory_bytes: 1732
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		
		StringBuffer S = new StringBuffer(sc.next());
		StringBuffer T = new StringBuffer(sc.next());
		
		T.delete(S.length(), S.length()+1);
		//p(T.toString());
		if(S.toString().equals(T.toString())) {
			p("Yes");
		}else p("No");
		
		
	}
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 35728