akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int a   = sc.nextInt();
            char op = sc.next().charAt(0);
            int b   = sc.nextInt();
            
            if(op == '?'){
                break;
            }
            
            switch(op){
            case '+':
                System.out.println(a + b);
                break;
            
            case '-':
                System.out.println(a - b);
                break;
            
            case '*':
                System.out.println(a * b);
                break;
            
            case '/':
                System.out.println(a / b);
                break;
            }
        }
    }
}


Measured memory_bytes: 26224
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
used = [False] * n
a.sort(key = lambda x: x[0], reverse = True)
b.sort(key = lambda x: x[0], reverse = True)
result = 0
for i in range(n):
  pj = -1
  miny = float('inf')
  for j in range(n):
    if used[j]:
      continue
    if a[i][0] < b[j][0] and a[i][1] < b[j][1]:
      if b[j][1] < miny:
        pj = j
        miny = b[j][1]
  if pj != -1:
    used[pj] = True
    result += 1
print(result)


Measured memory_bytes: 3064
from collections import defaultdict, deque, Counter
import sys
import heapq
import math

# input = sys.stdin.readline

sys.setrecursionlimit(1000000000)

MIN = -10 ** 9
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    # A, B = [int(a) for a in input().split()]
    # H = [int(a) for a in input().split()]
    # A = [
    #     [int(a) for a in input().split()]
    #     for _ in range(N)
    # ]

    print((N*(N-1))//2)


if __name__ == '__main__':
    main()


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

int main(){	
	int n;
	cin >> n;
	long long sum=0;
	for(int i=1;i<=n;i++){
		if(i%3 == 0 && i%5 == 0)
			continue;
		else if(i%3 == 0 || i%5 == 0)
			continue;
		else
			sum+=i;
	}
	cout << sum;
}

Measured memory_bytes: 3636
//#define sort(nums) sort(nums.begin(),nums.end())
#include <bits/stdc++.h>
using namespace std;

void jets(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}



int main(){
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    jets();
    int n,w;
    cin>>n>>w;
    vector<long long > arr(n),weights(n);
    long long  dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
    	cin>>weights[i]>>arr[i];
    }
    for(int i=0;i<n+1;i++){
    	for(int j=0;j<w+1;j++){
    		if (i==0)
    			dp[i][j]=0;
    		else if (j==0)
    			dp[i][j]=0;
    		else if (weights[i-1]>j)
    			dp[i][j]=dp[i-1][j];
    		else
    			dp[i][j]=max(dp[i-1][j],arr[i-1]+dp[i-1][j-weights[i-1]]);
    	}
    }
    cout<<dp[n][w];

    return 0;
}

Measured memory_bytes: 82396
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n;
    cin >> n;
    map<ll, ll> v;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d", &k);
        sum += k;
        v[sum]++;
    }
    ll ans = 0;
    for (auto &&x : v) if(x.second) ans += x.second * (x.second-1) / 2;
    ans += v[0];
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

struct Option
{
    int value;
    int changes;

    bool operator<(const Option &other) const
    {
        return changes < other.changes;
    }
};

pair<Option, Option> FindBest(const vector<int> &count, int total)
{
    Option first = {.value = -1, .changes = total};
    Option second = {.value = -1, .changes = total};

    for (size_t i = 1; i < count.size(); i += 1) {
        Option curr_option = {.value = (int)i, .changes = total - count[i]};
        if (curr_option < first) {
            second = first;
            first = curr_option;
        } else if (curr_option < second) {
            second = curr_option;
        }
    }
    return {first, second};
}

int FindCost(const pair<Option, Option> &odd, const pair<Option, Option> &even)
{
    if (odd.first.value != even.first.value) {
        return odd.first.changes + even.first.changes;
    }
    return min(odd.first.changes + even.second.changes,
               odd.second.changes + even.first.changes);
}

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

    constexpr int kMaxVal = 1e5;
    vector<int> count_odd(kMaxVal + 1, 0);
    vector<int> count_even(kMaxVal + 1, 0);

    for (int i = 0; i < n; i += 1) {
        int num;
        cin >> num;

        if (i % 2 == 0) {
            count_even[num] += 1;
        } else {
            count_odd[num] += 1;
        }
    }

    auto best_odd = FindBest(count_odd, n / 2);
    auto best_even = FindBest(count_even, (n + 1) / 2);

    auto res = FindCost(best_odd, best_even);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()

using ll = long long;

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  
  cout << a+b+c - max({a,b,c}) << endl;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,k,a[101];
int dp[101][100005];
int pre[101][100005];
void solve(){
    cin>>n>>k;
    rep(i,1,n+1) cin>>a[i];
    dp[0][0]=1;
    rep(i,0,k+1) pre[0][i]=1;
    rep(i,1,n+1){
        rep(j,0,k+1){
            dp[i][j]=(pre[i-1][j]-(j-a[i]-1>=0?pre[i-1][j-a[i]-1]:0)+hell)%hell;
            pre[i][j]=(dp[i][j]+(j?pre[i][j-1]:0))%hell;
        }
    }
    cout<<dp[n][k]<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 79232
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
/* contest template */
unsigned long long a[86];

int main()
{
	int n;
	cin >> n;
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i <= n; i++) {
		a[i] = a[i-2] + a[i-1];
	}
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    char w[n][101];
    for(int i = 0; i < n; i++){
        scanf("\n%s",w[i]);
    }

    bool check = true;
    for(int i = 0; i + 1 < n; i++){
        if(w[i][strlen(w[i]) - 1] != w[i + 1][0]){
            check = false;
            break;
        }
    }
    if(check == false){
        printf("No\n");

        return 0;
    }

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(strcmp(w[i],w[j]) == 0){
                check = false;
            }
        }
    }

    if(check == true){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;
using namespace __gnu_pbds;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "  ";
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
    ll n,k;
    cin>>n>>k;

    vector<ll> v;

    for(ll i=1;i<=n;i++)
    {
        ll temp=i;
        ll cnt=0;
        while(temp<k)
        {
            cnt++;
            temp*=2;
        }
        v.push_back(cnt);
    }

    double ans=0;
    for(ll i=0;i<v.size();i++)
    {
        if(v[i]==0)
            ans++;
        else
        {
            ll t= (pow(2,v[i]) + 0.4);
            ans += (double)((double)1/(double)t);
        }
    }
    ans = (double)((double)ans/(double)n);
    cout<<fixed<<setprecision(12);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
 
 
using namespace std;
 
 
int main() {
	string enki;
	cin >> enki;
	if (enki == "A") cout << "T" << endl;
	if (enki == "T") cout << "A" << endl;
	if (enki == "C") cout << "G" << endl;
	if (enki == "G") cout << "C" << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long  ll;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> vec(n);
  for(int  i=0; i<n; i++){
    int h;
    cin>>h;
    vec.at(i).push_back(h);
  }
  for(int  i=0; i<m; i++){
  int a,b;
  cin>>a>>b;
    vec.at(a-1).push_back(b-1);
    vec.at(b-1).push_back(a-1);
  }
  int count=0;
  for(int  i=0; i<n; i++){
    if(vec.at(i).size()==1)count++;
    for(int j=1 ;j<vec.at(i).size(); j++){
      int l=vec.at(i).at(j);
      if(vec.at(i).at(0)<=vec.at(l).at(0)){
        break;}
      else if(j==vec.at(i).size()-1
              &&vec.at(i).at(0)>vec.at(vec.at(i).at(j)).at(0)){
                count++;}
    }
  }
  cout<<count;
}

Measured memory_bytes: 9336
/*input
20 40 6

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
// #define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 250001

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(ll a, ll b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(ll a, ll b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(ll a, ll b) {return (a * 1ll * b) % mod;}
inline int pwr(ll x, ll y) {
  int ans = 1 % mod;
  while (y) {
    if (y & 1) ans = mul(ans, x);
    x = mul(x, x);
    y >>= 1;
  }
  return ans;
}
inline int inv(int a) {return pwr(a, mod - 2);}


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

  int n, k;
  cin >> n >> k;
  string str;
  cin >> str;
  vector <int> vec;
  int c = 0;
  int s = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == '0') {
      c = 0;
      s++;
      while (i < n && str[i] == '0') {
        c++;
        i++;
      }
      while (i < n && str[i] == '1') {
        c++;
        i++;
      }
      if (i < n) {
        i--;
      }
      vec.pb(c);
    }
  }
  // for (auto it : vec) {
  //   cout << it << " ";
  // }
  // cout << endl;
  k = min(k, s);
  vector <int> psum;
  psum.pb(0);
  for (auto it : vec) {
    psum.pb(psum[psum.size() - 1] + it);
  }
  if (vec.size() == 0) {
    cout << n << endl;
    return 0;
  }
  int ans = psum[k];
  // for (auto it : psum) {
  //   cout << it << " ";
  // }
  // cout << endl;
  // debug(k);
  s = (str[0] == '0');
  for (int i = 0; i < n; i++) {
    if (str[i] == '1') {
      c = 0;
      while (i < n && str[i] == '1') {
        c++;
        i++;
      }
      // debug(c);
      // debug(s);
      ans = max(ans, c + psum[min((int)psum.size() - 1, s + k)] - psum[s]);
      s++;
    }
    //debug(ans);
  }
  cout << ans << endl;

  return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 110;
const int MV = 100010;
const ll INF = 1e18;

ll dp[MN][MV];

int main() {
    int N, W; cin >> N >> W;
    rep(i, MN) {
        rep(j, MV) dp[i][j] = INF;
    }

    dp[0][0] = 0;

    rep(i, N) {
        int w, v;
        cin >> w >> v;
        rep(j, MV) {
            if (dp[i][j] != INF) {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]); 
                dp[i+1][j + v] = min(dp[i+1][j + v], dp[i][j] + w);
            }
        }
    }

    int ans = 0;
    rep(j, MV) if (dp[N][j] <= W) {
        ans = j;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 86144
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <limits>
#include <set>
#include <utility>

namespace n91 {

void main_() {
  usize n;
  std::cin >> n;
  if (n == 1_z) {
    std::cout << 1_z << std::endl;
    return;
  }
  std::set<std::pair<i64, i64>> set;
  for (const auto i : rep(0_z, n)) {
    i64 x, y;
    std::cin >> x >> y;
    set.emplace(x, y);
  }
  usize ans = std::numeric_limits<usize>::max();
  for (const auto a : set) {
    for (const auto b : set) {
      if (a == b) {
        continue;
      }
      const i64 p = a.first - b.first;
      const i64 q = a.second - b.second;
      usize cur = 0_z;
      for (const auto e : set) {
        if (set.find({e.first - p, e.second - q}) == set.end()) {
          ++cur;
        }
      }
      ans = std::min(ans, cur);
    }
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , m , k ;
    cin >> n >> m >> k ;
    vector<vector<char> > g(n, vector<char>(m)) ;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> g[i][j] ;
        }
    }
    debug() << imie(g) ;
    int ans = 0 ;
    for(int i = 0; i < (1 << n); i++){
        vector<vector<char> > v = g;
        debug() << imie(v) ;
        for(int c = 0; c < n; c++){
            if ( i & (1 << c) ){
                for(int t = 0; t < m; t++) {
                    v[c][t] = '$' ;
                    debug() << imie(i) ;
                }
            }
        }
        for(int j = 0; j < (1 << m); j++){
            vector<vector<char> > vv = v;
            for(int c = 0; c < m; c++){
                if ( j & (1 << c) ){
                    for(int t = 0; t < n; t++) {
                        vv[t][c] = '$' ; 
                        debug() << imie(j) ;
                    }
                }
            }
            debug() << "test" imie(vv) ;
            int cnt = 0 ;
            for(int ii = 0; ii < n; ii++){
                for(int jj = 0; jj < m; jj++){
                    if ( vv[ii][jj] == '#' ) cnt++ ;
                }
            }
            if ( cnt == k ) ans++ ;
        }
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3656
#pragma GCC optimize("Ofast","-funroll-loops","-fdelete-null-pointer-checks")
#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx","popcnt")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define endl '\n'

const ll MOD = 1e9 + 7;

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> tab(101);
	for(int i = 0; i < k; i++) {
		int ki;
		cin >> ki;
		while(ki --) {
			int x;
			cin >> x;
			tab[x] ++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(! tab[i])
			ans++;
	}
	cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll t=1;
	for(ll tt=1; tt <= t; tt++) {
		//cout << "case #" << tt << ":\n";
		solve();
	}

	return 0;
}



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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-11;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int K,R,L;
double P,E,T;

double dfs(double l,double r,double p,int n){
	if(T-E<=l&&r<=T+E)
		return p;
	if(r<T-E||T+E<l)
		return 0;
	double m=(l+r)/2.0;
	if(n==K){
		if(T-E<=m&&m<=T+E)
			return p;
		else
			return 0;
	}
	double res=0.0;
	if(m<=T){
		res+=dfs(m,r,p*(1.0-P),n+1);
		res+=dfs(l,m,p*P,n+1);
	}else{
		res+=dfs(l,m,p*(1.0-P),n+1);
		res+=dfs(m,r,p*P,n+1);
	}
	return res;
}

int main(void){
	cin >>  K >> R >> L;
	cin >>  P >> E >> T;
	double ans=dfs(R,L,1.0,0);
	cout.precision(9);
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s, t;
	cin>>s>>t;
	t.pop_back();
	if(s==t){
		cout<<"Yes";
	}
	else cout<<"No";
}

Measured memory_bytes: 3544
#include <iostream>

using namespace std;
int s1[200],s2[200],i,v1[200],v2[200],n,Max;
int main()
{
    cin>>n;
    for(int i = 1;i<=n;i++)
    {
        cin>>v1[i];
        s1[i] = s1[i-1] + v1[i];
    }
    for(int i = 1;i<=n;i++)
    {
        cin>>v2[i];
    }
    for(i = n; i>=1;i--){
        s2[i] = s2[i+1] + v2[i];
    }

    for(i=1;i<=n;i++){
        Max = max(Max,s1[i]+s2[i]);
    }
    cout<<Max;

    return 0;
}


Measured memory_bytes: 256
N, x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]

a = sorted(a)

pointer = 0
score = 0
while(x>=0 and pointer<N):
    x = x-a[pointer]
    score+=1
    pointer+=1

if(x!=0):
    score-=1
print(score)


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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
   int n;cin>>n;
   map<ll,ll> m;
   ll l;
   FOR(i,0,n){
       cin>>l;
       m[l]++;
   }
   ll ans=0;
   for(auto i:m){
       for(auto j:m){
           if(j.ff>i.ff){
               for(auto k:m){
                   if(k.ff>j.ff && k.ff>i.ff && i.ff+j.ff > k.ff){
                       ans += (i.ss*j.ss*k.ss);
                   }
               }
           }
       }
   }
   cout<<ans<<"\n";
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3656
N=int(input())
a=[int(i) for i in input().split()]
M = max(a)
m = min(a)
print(2*N-1)
if abs(M) > abs(m):
  Mi = a.index(M)
  for i in range(N):
    print(Mi+1,i+1)
  for i in range(N-1):
    print(i+1,i+2)
else:
  mi = a.index(m)
  for i in range(N):
    print(mi+1,i+1)
  for i in range(N-1)[::-1]:
    print(i+2,i+1)

Measured memory_bytes: 9216
def main():
    h, w = map(int, input().split())
    grid = []
    for height in range(0, h):
        grid.append(list(input()))

    dx = [0, 0, 1, 1, 1, -1, -1, -1]
    dy = [1, -1, 1, -1, 0, 1, -1, 0]

    for height in range(0, h):
        for width in range(0, w):
            if grid[height][width] == '#':
                continue
            else:
                grid[height][width] = 0

            for i in range(0, 8):
                if (height + dy[i] < 0) or (height + dy[i] >= h) or (width + dx[i] < 0) or (width + dx[i] >= w):
                    continue
                if (grid[height + dy[i]][width + dx[i]]) == '#':
                    grid[height][width] += 1

    for height in range(0, h):
        for width in range(0, w):
            print(grid[height][width], end='')
        print()


if __name__ == "__main__":
  main()


Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a[3][3], n, b[10];

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> a[i][j];
    }
  }
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> b[i];
  }

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < n; k++)
      {
        if (a[i][j] == b[k])
        {
          a[i][j] = -1;
        }
      }
    }
  }

  bool flag;
  for (int i = 0; i < 3; i++)
  {
    flag = true;
    for (int j = 0; j < 3; j++)
    {
      if (a[i][j] != -1) flag = false;
    }
    if (flag)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

  for (int i = 0; i < 3; i++)
  {
    flag = true;
    for (int j = 0; j < 3; j++)
    {
      if (a[j][i] != -1) flag = false;
    }
    if (flag)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

  flag = true;
  for (int i = 0; i < 3; i++)
  {
    if (a[i][i] != -1) flag = false;
  }
  if (flag)
  {
    cout << "Yes" << endl;
    return 0;
  }

  flag = true;
  for (int i = 0; i < 3; i++)
  {
    if (a[i][2 - i] != -1) flag = false;
  }
  if (flag)
  {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " is " << endl

int main()
{
    string N;
    cin >> N;
    if (N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3596
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

struct Node {
	vector<int> neighbors;
	bool visited = false;
};

int N, M;
Node nodes[100000];

map<int, int> signs; // 道しるべ

void bfs(int start) {
	nodes[start].visited = true;

	queue<int> search_queue;
	search_queue.push(start);

	while(!search_queue.empty()) {
		// キューから探索対象のノードのインデックスを取り出す
		int i = search_queue.front();
		search_queue.pop();

		for (int n : nodes[i].neighbors) {
			if (nodes[n].visited) {
				continue; // 探索済みならキューに入れない
			}

			nodes[n].visited = true;
			signs[n] = i;
			search_queue.push(n);
		}
	}
}

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

	int A, B;
	for (int i=0; i<M; i++) {
		cin >> A >> B;
		A--;
		B--;
		nodes[A].neighbors.push_back(B);
		nodes[B].neighbors.push_back(A);
	}

	bfs(0);

	cout << "Yes" << endl;

	for (auto itr = signs.begin(); itr != signs.end(); itr++) {
		cout << itr->second + 1<< endl;
	}

	return 0;
}

Measured memory_bytes: 15396
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<map>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN   10001
#define MOD 1000000007
#define X first
#define Y second
ll t,n,i,j;
int main()
{
    cin>>n;
    vector <ll > v(n);
    for(i=0;i<n;i++)
        cin>>v[i];
    v[0]-=1;
    for(i=1;i<n;i++){
        if(v[i]>v[i-1])
            v[i]-=1;
        else if(v[i]<v[i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/


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

    int N, K;
    cin >> N >> K;

    vector<int> candy(N, 0);
    int d;
    int A;

    REPinit(i, 0, K) {
        cin >> d;
        REPinit(j, 0, d) {
            cin >> A;
            candy.at(A - 1)++;
        }
    }

    int ans = 0;
    REPinit(i, 0, N) {
        if (candy.at(i) == 0) ans++;
    }

    cout << ans << endl;


    return 0;
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int N,M;
  string a,b,an;
  cin >> a >> b >> N >> M >> an;
  if(an == a){
    N--;
  }else{
   M--;
  }
  cout << N << " " << M << endl;

return 0;
}

Measured memory_bytes: 3580
class BIT():
    def __init__(self,n):
        self.BIT=[0]*(n+1)
        self.num=n

    def query(self,idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx&(-idx)
        return res_sum

    #Ai += x O(logN)
    def update(self,idx,x):
        while idx <= self.num:
            self.BIT[idx] += x
            idx += idx&(-idx)
        return

import sys

input=sys.stdin.readline

N,M=map(int,input().split())
q={i:[] for i in range(1,M+1)}
imos=[0 for i in range(M+2)]
for i in range(N):
    l,r=map(int,input().split())
    q[l].append(r)
    imos[l]+=1
    imos[r+1]-=1
for i in range(1,M+1):
    imos[i]+=imos[i-1]
res={i:imos[i*(M//i)] for i in range(1,M+1)}

query={i:[] for i in range(1,M+1)}
for i in range(1,M+1):
    for j in range(1,M//i):
        query[i*j].append(i*j+i)

bit=BIT(M)
for i in range(1,M+1):
    for r in q[i]:
        bit.update(r,1)
    for r in query[i]:
        res[r-i]+=bit.query(r-1)-bit.query(i-1)

for i in range(1,M+1):
    print(res[i])

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


int main(){
  int N;
  cin >> N;
  int a[N];
  
  for (int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a, a+N);
  int min_a=a[0], max_a=a[N-1];
  
  int retval = 0, cnt;
  for (int X=min_a;X<=max_a;X++){
    cnt = lower_bound(a,a+N,X+2)-lower_bound(a,a+N,X-1);
    retval = max(retval, cnt);
  }

  cout << retval << endl;
}
 

Measured memory_bytes: 640
#include <iostream>
using namespace std;
constexpr int M = 1000000007;

int main() {
    int n, m; cin >> n >> m;
    int s[n], t[m];
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];
    long long dp[2][n+1];
    int cur = 0, prev = 1;
    fill(dp[prev], dp[prev]+n+1, 1);
    dp[cur][0] = 1;
    for (int j = 0; j < m; j++) {
        for (int i = 0; i < n; i++) {
            dp[cur][i+1] = dp[cur][i] + dp[prev][i+1] - dp[prev][i] + M;
            if (s[i] == t[j]) dp[cur][i+1] += dp[prev][i];
            dp[cur][i+1] %= M;
        }
        swap(cur, prev);
    }
    cout << dp[prev][n] << endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a,b,c = readline() |> split |> parseMap
	println((c-a-b)^2>4*a*b&&a<=c&&b<=c?"Yes":"No")
end

main()

Measured memory_bytes: 166872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const double INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1);
int n;
double r, a;
int x[20], y[20];
double dis[20][20][10010];
double cost[20][20];
bool reach[20][20][20];

bool canReach(int pre, int cur, int nxt) {
  int cpx = x[pre]-x[cur], cpy = y[pre]-y[cur];
  int cnx = x[nxt]-x[cur], cny = y[nxt]-y[cur];
  double tmp = cpx*cnx + cpy*cny;
  tmp /= hypot(cpx, cpy);
  tmp /= hypot(cnx, cny);
  tmp = PI - acos(tmp);
  return tmp <= a;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n >> r >> a;
  a = a / 180 * PI;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cost[i][j] = hypot(x[i]-x[j], y[i]-y[j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (i == j || j == k || k == i) continue;
        reach[i][j][k] = canReach(i, j, k);
      }
    }
  }
  int ans = 0;
  fill_n((double*)dis, 20*20*10010, INF);
  dis[0][0][0] = 0.0;
  using P = tuple<double, int, int, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  que.emplace(0.0, 0, 0, 0);
  while (!que.empty()) {
    double d;
    int cur, pre, num;
    tie(d, cur, pre, num) = que.top(); que.pop();
    if (dis[cur][pre][num] < d || r < d) continue;
    if (d <= r) ans = max(ans, num);
    for (int i = 0; i < n; i++) {
      if (i == cur) continue;
      if (cur == pre || reach[pre][cur][i]) {
        if (dis[i][cur][num+1] > dis[cur][pre][num]+cost[cur][i]) {
          dis[i][cur][num+1] = dis[cur][pre][num]+cost[cur][i];
          que.emplace(dis[i][cur][num+1], i, cur, num+1);
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 34932
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define rep(i,a,b) for (long long i=a; i<b; i++)
#define pb push_back
#define vvi vector<vector<long long>> 
#define vi vector<long long>
#define vb vector<bool>
#define vvb vector<vector<bool>> 

vector<long long> total, visit;
void dfs_visit(vvi & adj, long long i, long long atual) {
	visit[i] = 1;
	total[i] += atual;
	for (long long j : adj[i]) {
		if (!visit[j]) {
			dfs_visit(adj, j, total[i]);
		}
	}
}

void dfs(vvi & adj, long long n) {
	dfs_visit(adj, 1, 0);
}

int main() {
	long long n, q;
	cin >> n >> q;

	vvi adj;
	vi lista;
	lista.clear();
	adj.assign(n+1, lista);
	for (long long i=1; i<=n-1; i++) { 
		long long x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	vector<long long> p(q), x(q);
	for(long long i=0; i<q; i++) {
		cin >> p[i] >> x[i]; 
	}

	total.assign(n+1, 0);
	visit.assign(n+1, 0);
	for(long long i=0; i<q; i++) {
		total[p[i]] += x[i];
	}

	dfs(adj, n);

	for(long long i=1; i<=n; i++) {
		cout << total[i] << " "; 
	}
	cout << endl;

   return 0;

}


Measured memory_bytes: 28928
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(a - b > c) cout << 0 << endl;
    else cout << c - (a-b) << endl;
}

Measured memory_bytes: 256
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    H, W, N = [ii(), ii(), ii()]
    print(math.ceil(N/max(H, W)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9396
module ABC124

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_C

  ! constants for this <module>
  integer(kind=INT32), parameter, private :: len_string_max = 100000_INT32

  ! variables for this <module>
  character(len=len_string_max, kind=1) :: given_string
  character(len=len_string_max, kind=1) :: reference_0, reference_1
  integer  (kind=INT32)                 :: len_string
  integer  (kind=INT32)                 :: num_operations(0:1)

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! variables for this <subroutine>
    integer(kind=INT32) :: itr

    ! STEP.01
    ! read out the given string
    read(unit=INPUT_UNIT, fmt='(A)') given_string

    ! STEP.02
    ! count up the number of operations
    len_string     = len_trim(given_string)
    num_operations = 0_INT32

    do itr = 1_INT32, len_string, 2_INT32
      if (given_string(itr:itr) .ne. '0') num_operations(0) = num_operations(0) + 1_INT32
      if (given_string(itr:itr) .ne. '1') num_operations(1) = num_operations(1) + 1_INT32
    end do

    do itr = 2_INT32, len_string, 2_INT32
      if (given_string(itr:itr) .ne. '1') num_operations(0) = num_operations(0) + 1_INT32
      if (given_string(itr:itr) .ne. '0') num_operations(1) = num_operations(1) + 1_INT32
    end do

    ! STEP.04
    ! output the result
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') minval(num_operations(:))

    ! STEP.END
    return

  end subroutine task_C

end module ABC124

program main

  ! <module>s to import
  use, non_intrinsic :: ABC124

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void update(double& a, double b){
  a = min(a, b);
}

int main(){
  int N;
  while(cin >> N && N){
    vector<double> a(N + 1, 0);
    double b, r, v, e, f;
    REP(i, N) cin >> a[i + 1];
    cin >> b >> r >> v >> e >> f;
    double dp[101][101] = {}; // checkpoint i を終えた時間 (最後のタイヤ交換は checkpoint j)
    REP(i, N + 1) REP(j, N + 1) dp[i][j] = INF;
    dp[0][0] = 0;
    double time[10001] = {};
    for(int x = 0; x < 10000; x++){
      time[x + 1] = time[x] + (x >= r ? (1.0 / (v - e * (x - r))) : (1.0 / (v - f * (r - x))));
    }
    for(int i = 0; i < N; i++){
      for(int j = 0; j <= i; j++){
        int d1 = a[i] - a[j];
        int d2 = a[i + 1] - a[j];
        update(dp[i + 1][i + 1], dp[i][j] + time[d2] - time[d1] + b);
        update(dp[i + 1][j], dp[i][j] + time[d2] - time[d1]);
      }
    }
    double ans = INF;
    for(int i = 0; i <= N; i++) ans = min(ans, dp[N][i]);
    printf("%.12lf\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys


def solve(N: int):
    x = [0] * 100

    for i in range(1, N+1):
        a = i%10
        b = int(str(i)[0])
        x[a + b*10] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1,10):
            if i == j:
                ans += x[i*11] ** 2
                continue
            ans += x[i*10 +j] * x[j*10 + i]
    print(ans)
    return



# Generated by 1.1.6 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
    solve(N)

if __name__ == '__main__':
    main()


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

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

    string s; cin >> s;

    if (s == "ABC") cout << "ARC" << "\n";
    else cout << "ABC" << "\n";
    

    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll ans_min = 2*n;
    ll i, ans, i_min;
    for(i=sqrt(n); i>0; i--){
        if(n%i == 0){
             ans = i + (n/i);
             ans_min = min(ans, ans_min);
        }
    }
    cout  << ans_min-2 << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)
	
	nums := []int{a,a-1,b,b-1}
	
	sort.Sort(sort.Reverse(sort.IntSlice(nums)))
	
	fmt.Println(nums[0]+nums[1])
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int n; cin >> n;
    vector<ll> a(n);
    FOR(i, 0, n) cin >> a[i];

    vector<ll> sum(n+1, 0);
    map<ll, ll> nums;
    FOR(i, 0, n) sum[i+1] = sum[i] + a[i];
    FOR(i, 0, n+1) nums[sum[i]]++;

    ll res = 0;
    for (auto it : nums) {
        ll num = it.second;
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
}

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

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll x(n);
  rep(i, n) {
    cin >> x[i];
  }

  sort(all(x));

  ll ans = INF;
  REP(p, 101) {
    ll sum = 0;
    FORm(it, x) {
      sum += (*it - p) * (*it - p);
    }
    chmin(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def mklist(B,D,V):
    min = 10000
    for key,val in enumerate(B):
        D[val] = key
        V[val] = 0
        if min > val:
            min = val
    return min

def solve(A,V,D,min):
    cost = 0
    for key, val in enumerate(A):
        if V[val] != 0:
            continue
        W = []
        wmin = 10000
        tw = 0
        k1 = key
        v = val
        while(1):
            k2 = D[v]
            if V[v] == 1:
                break
            W.append(v)
            V[v] = 1
            if wmin > v:
                wmin = v
            tw += v
            #print("key={} k1={} k2={} v={} Vv={}".format(key,k1,k2,v,V[v]))
            k1 = k2
            v = A[k1]
        n = len(W)
        t1 = tw + ((n - 2) * wmin)
        t2 = tw + wmin + ((n + 1) * min)
        if t1 < t2:
            cost += t1
        else:
            cost += t2
    return cost

def main():
    num = int(input())
    A = list(map(int,input().split()))
    B = sorted(A)
    D = {}
    V = {}
    min = mklist(B,D,V)
    cost = solve(A,V,D,min)
    print(cost)

if __name__ == '__main__':
    main()

Measured memory_bytes: 8016