akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, k, a[100005], ilosc = 0;
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(a[i] >=k) {
            ilosc++;
        }
    }
    cout << ilosc;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

static int MAX = 500;
static int INFTY = (1<<21);

int main(){
  int r, i, j, e, sum;
  int X[MAX][MAX];
  int u, v;
  int minv;
  int d[MAX];
  int K[MAX];
  int vis[MAX];

  scanf("%d", &r);

  for ( i = 0; i< r; i++ ){
    for ( j = 0; j < r; j++ ){
      scanf("%d", &e);
      X[i][j] = (e==-1)?INFTY:e;
    }
  }

  for ( i = 0; i < r; i++ ) {
    d[i] = INFTY;
    K[i] = -1;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < r; i++ ){
      if ( minv > d[i] && !vis[i] ){
	u = i;
	minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < r; v++ ){
      if ( !vis[v] && X[u][v] != INFTY ){
	if ( d[v] > X[u][v] ){
	  d[v] =  X[u][v];
	  K[v] = u;
	}
      }
    }
  }

  sum = 0;

  for ( i = 0; i < r; i++ ){
    if ( K[i] != -1 ) sum += X[i][K[i]];
  }

  printf("%d\n", sum);

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   std::vector<std::pair<long, long>> graph[112345];
   void solve() {
      long n; scan(n);
      for(long i = 0; i < n - 1; ++i) {
         long a, b, c; scan(a, b, c);
         graph[a].push_back(std::make_pair(b, c));
         graph[b].push_back(std::make_pair(a, c));
      }
      long q, k; scan(q, k);
      LI dist(n+1, (1LL << 53));
      dist[k] = 0;
      std::priority_queue<std::pair<long, long>> pq;
      pq.push(std::make_pair(0, k));
      while( not pq.empty() ) {
         long d, a;
         std::tie(d, a) = pq.top(); pq.pop();
         for(auto bc : graph[a]) {
            long b, c; std::tie(b, c) = bc;
            long nd = -d + c;
            if( nd < dist[b] ) {
               dist[b] = nd;
               pq.push(std::make_pair(-nd, b));
            }
         }
      }
      for(long i = 0; i < q; ++i) {
         long x, y; scan(x, y);
         printf("%ld\n", dist[x] + dist[y]);
      }
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}


Measured memory_bytes: 11376
#include<iostream>
using namespace std;
int main(){
int s[10], s2[10];
int sum1=0, sum2=0;
for (int i = 0 ; i < 10 ; i++) {
  cin >> s[i];
}
for (int i = 0 ; i < 10 ; i++) {
  cin >> s2[i];
}
for (int i = 0 ; i < 10 ; i++) {
  for (int j=i+1 ; j<10 ; j++){
    if (s[j]>s[i]){
      int t = s[i];
      s[i] = s[j];
      s[j] = t;
    }
  }
}
for (int i = 0 ; i < 10 ; i++) {
  for (int j=i+1 ; j<10 ; j++){
    if (s2[j]>s2[i]){
      int t = s2[i];
      s2[i] = s2[j];
      s2[j] = t;
    }
  }
}
for (int i = 0 ; i < 3 ; i++) {
  sum1+=s[i];
}
for (int i = 0 ; i < 3 ; i++) {
  sum2+=s2[i];
}
cout << sum1 << " " << sum2 <<endl;
}



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

int main()
{
    int A, B;
    int i = 10000, t = 10, num = 0;

    cin >> A >> B;

    while (B - A >= 0)
    {
        if (A / i != A % t)
        {
            A++;
            continue;
        }else if (A % i / (i / 10) != A % (t * 10) / t)
        {
            A++;
            continue;
        }else
        {
            num++;
            A++;
        }
    }

    cout << num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N - 1);
  
  for(int i; i < N; i++){
    int x;
    cin >> x;
    a.at(i) = x;
  }
  
  for(int i; i < N; i++){
    int x;
    cin >> x;
    b.at(i) = x;
  }
  
  for(int i; i < N - 1; i++){
    int x;
    cin >> x;
    c.at(i) = x;
  }
  
  int answer = 0;
  
  for(int i; i < N; i++){
    answer += b.at(i);
    
    if(i != 0){
      if(a.at(i) == a.at(i - 1) + 1){
        answer += c.at(a.at(i) - 2);
      }
    }
  }
  
  cout << answer << endl;
  
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(n - 1):
  cnt = 0
  X = s[0:i + 1]
  Y = s[i + 1:]
  X = set(X)
  Y = set(Y)
  for x in X:
    if x in Y:
      cnt += 1
  ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.util.Collections;
public class Main {
	public static void main(String[] args){	
      Scanner sc = null;
      sc = new Scanner(System.in);
      long N = sc.nextLong();
      String ans = "";
     
      while(N-- > 0){
        ans = (char)('a' + (N%26)) + ans;
        N /= 26;
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 39140
#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
using namespace std;


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

/* vector<int> A(N); */
/* xの二乗
 pow(x, 2.0) */
 
int main() {
  
  int H,A, count;
  cin >> H >> A;
  
  count = H/A;
  
  if ( H%A != 0 ) count++;
  
  cout << count << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> p(N);
    rep(i, N) {
        cin >> p[i];
        p[i]--;
    }

    int ans = 0;
    rep(i, N - 1) {
        if (p[i] == i) {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }

    if (p.back() == N-1) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 640
def main():
    n = int(input())
    a = list(map(int,input().split()))
    mod = 10**9+7
    S = sum(a)
    ans = 0
    for i in range(n):
        ans += (a[i] * (S-a[i]))
    print(ans//2%mod)

if __name__ == "__main__":
    main()


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

using namespace std;

#define NUM_CITY 500

int rootcnt[NUM_CITY + 1][NUM_CITY + 1] = {0};

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

    for(int i = 0; i < m; i++)
    {
        int tmpl, tmpr;
        cin >> tmpl >> tmpr;
        for(int j = 1; j <= tmpl; j++)
        {
            rootcnt[j][tmpr]++;
        }
    }
    
    for(int i = 0; i < q; i++)
    {
        int tmpl, tmpr;
        cin >> tmpl >> tmpr;
        int ans = 0;
        for(int j = 1; j <= tmpr; j++)
        {
            ans += rootcnt[tmpl][j];
        }
        cout << ans << endl;        
    }

}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h,w,n;
    cin>>h>>w>>n;
    ll p=max(h,w);
    ll d=ceil(n/double(p));
    cout<<d;

    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 L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();
		int count = 0;
		for(int i = L;i <= R;i++) {
			if(i % d == 0) {
				count++;
			}
		}
		System.out.println(count);
  }
}

Measured memory_bytes: 35532
#include <cstdio>

using namespace std;

int main(void)
{
    char c[6];
    scanf("%s", c);
    int i, count;
    count = 0;
    for(i=0;i<6;i++)
    {
        if(c[i] == '1') count++;
    }
    printf("%d\n", count);
    fflush(stdout);
}

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

using namespace std;

int gcd(int a, int b) {
    if(a < b) {
        swap(a, b);
    }
    int c = a % b;
    if(c == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    int k, g = 0;

    scanf("%d", &k);

    for(int a = 1; a <= k; a++) {
        for(int b = 1; b <= k; b++) {
            for(int c = 1; c <= k; c++) {
                g += gcd(gcd(a, b), c);
            }
        }    
    }

    printf("%d\n", g);

    return 0;
}

Measured memory_bytes: 3816
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    int A,B;
    cin >> A >> B;
    
    if(A==2 || B==2) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<int> check(m,-1);
    vector<int> a;
    int t = 0;
    ll total = 0;
    while (check[x] == -1) {
        a.push_back(x);
        check[x] = t;
        t++;
        total += x;
        x = (x * x) % m;
    }
    int c = t - check[x];
    ll s = 0;
    for (int i = check[x]; i < t; ++i){
        s += a[i];
    }
    ll ans = 0;
    if (n <= t) {
        rep(i, n){
            ans += a[i];
        }
    }
    else {
        ans += total;
        n -= t;
        ans += s * (n / c);
        n %= c;
        rep(i, n){
            ans += a[check[x] + i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4036
// OURL: https://atcoder.jp/contests/abc124/tasks/abc124_a
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b;
  cin >> a >> b;
  if (a == b) {
    cout << a * 2 << endl;
  } else {
    cout << max(a,b) * 2 - 1 << endl;
  }
  return 0;
}


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

using namespace std;

int main(){
	string s;
	cin>>s;
	if(s=="SSS"){cout<<0;return 0;}
	if(s=="SSR"){cout<<1;return 0;}
	if(s=="SRS"){cout<<1;return 0;}
	if(s=="SRR"){cout<<2;return 0;}
	if(s=="RSS"){cout<<1;return 0;}
	if(s=="RSR"){cout<<1;return 0;}
	if(s=="RRS"){cout<<2;return 0;}
	if(s=="RRR"){cout<<3;return 0;}
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main() {
    int number_of_test_case, number_of_correct_answer;

    cin >> number_of_test_case >> number_of_correct_answer;

    if(number_of_test_case == number_of_correct_answer) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int C[50],V[50];
signed main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += max(0LL, V[i]-C[i]);
  }
  cout << ans << endl;
}


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

#define int long long

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    vs S(3); REP(i, 3) cin >> S[i];
    vi i(3);
    int t = 0;
    while(i[t] < (int)S[t].length())
    {
        int n = S[t][i[t]] - 'a';
        i[t]++;
        t = n;
    }
    cout << (char)('A' + t) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), B(N);
    map<ll, vector<ll>> work;
    rep(i, N){
        cin >> A.at(i) >> B.at(i);
        work[A.at(i)].push_back(B.at(i));
    }
    priority_queue<ll> app;
    ll ans = 0;
    rep(i, M){
        rep(j, sz(work[i+1])){
            app.push(work[i+1].at(j));
        }
        if(!app.empty()){
            ans += app.top();
            app.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15540
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(5); rep (i, a.size()) cin >> a[i];
    rep (i, 5) {
        if (a[i] == 0) {
            cout << i + 1;
            return 0;
        }
    } 
    return 0;
}

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

int main()
{
    int n, k, q; cin >> n >> k >> q;
    vector<int> answer(n, 0);
    for (int i = 0; i < q; i++) {
        int a; cin >> a; a--;
        answer[a]++;
    }

    for (int i = 0; i < n; i++) {
        cout << ((k - q + answer[i] > 0) ? "Yes" : "No") << endl;
    }
    return 0;
}

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

int main() {
  map<char, int> d;
  string w;
  cin >> w;
  for(int i = 0; i < w.size(); i++){
    char s = w.at(i);
    if(d.count(s)){
      d.at(s)++;
    }else{
      d[s] = 1;
    }
  }
  bool flag = true;
  for(auto itr = d.begin(); itr != d.end(); itr++){
    if(itr->second % 2 != 0){
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}

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

int main(){
    int n; cin >> n;
    vector<ll> v(n);
        for(int i=0; i<n; i++) v.at(i) = i;
    vector<pair<ll, ll>> city(n);
    for(int i=0; i<n; i++)
        cin >> city.at(i).first >> city.at(i).second;
        
    int cnt=0;
    double sum=0;
    do{
        for(int i=0; i<v.size()-1; i++){
            double x = pow(city.at(v[i]).first-city.at(v[i+1]).first, 2.0);
            double y = pow(city.at(v[i]).second-city.at(v[i+1]).second, 2.0);
            sum += sqrt(x+y);
        }
        cnt += 1;
    }while(next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(15) << sum/cnt <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define sci(x) scanf("%d",&x)
#define scs(s) scanf("%s",s)
#define scc(c) scanf("%c",c)
#define scd(d) scanf("%lf",&d)
#define scld(ld) scanf("%Lf",&ld)
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;

typedef pair<int, int> i_i;

//********************************************
//Error tracking
#define show(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}
//********************************************

const int NMAX = 200005;

int n,k,l;

struct union_find
{
    vector<int>v,comp;
    union_find(int n): v(n + 1, -1), comp(n + 1, 1) {}
    int Find(int x)
    {
        if (v[x] == -1) return x;
        return v[x] = Find(v[x]);
    }

    void Union(int x, int y)
    {
        x = Find(x); y = Find(y);
        if (x == y) return ;
        if (comp[x] > comp[y])
        {
            comp[x] += comp[y];
            v[y] = x;
        }
        else 
        {
            comp[y] += comp[x];
            v[x] = y;
        }
    }
};  

int main()
{
    int i;

 //   freopen("input","r",stdin);
 //   freopen("output","w",stdout);
    cin.sync_with_stdio(false);

    cin >> n >> k >> l;

    union_find u1(n), u2(n);

    while (k--)
    {
        int x,y;
        cin >> x >> y;
        u1.Union(x, y);
    }

    while (l--)
    {
        int x,y;
        cin >> x >> y;
        u2.Union(x, y);
    }

    map<i_i, int> mp;
    for (i = 1; i <= n; i++)
    {
        int x = u1.Find(i), y = u2.Find(i);
        mp[i_i(x,y)]++;
    }

    for (i = 1; i <= n; i++)
    {
        int x = u1.Find(i), y = u2.Find(i);
        cout << mp[i_i(x,y)] << " ";
    }
    return 0;   
}

Measured memory_bytes: 15104
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
if N == 1:
    print(1)
    sys.exit()

for i in range(N,-1,-1):
    for j in range(1,int(N**0.5)+1):
        for k in range(2,11):
            if j**k == i:
                print(i)
                sys.exit()


Measured memory_bytes: 10316
import numpy

H, W = map(int,input().split())
board = [list(map(int,input().split())) for l in range(H)]

board = numpy.reshape(board,(H,W))
cboard = board.copy()

move = []

for i in range(H):
    for j in range(W-1):
        if board[i,j] % 2 == 1:
            board[i,j+1] += 1
            board[i,j] += -1
            move.append([i+1,j+1,i+1,j+2])
            
for i in range(H-1):
    if board[i,W-1] % 2 == 1:
        board[i,W-1] += -1
        board[i+1,W-1] +=1
        move.append([i+1,W,i+2,W])
        
print(len(move))
for m in move:
    print(*m)

Measured memory_bytes: 40904
import sys

n, m = map(int, input().split())

ans = []
for _ in range(n):
    ans.append('a')

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] == 'a' or ans[s-1] == str(c):
        ans[s-1] = str(c)
    else:
        print(-1)
        sys.exit()

if ans[0] == '0' and len(ans) != 1:
    print(-1)
    sys.exit()
elif len(ans) == 1:
    if ans[0] == 'a':
        print(0)
        sys.exit()
    else:
        print(int(ans[0]))
        sys.exit()

ans = ''.join(ans).replace('a', '0')

if ans[0] == '0':
    ans = ans.replace('0', '1', 1)

print(int(ans))


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

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

  int A[n], B[n], C[n];

  for(int i=0; i<n; ++i){
    cin >> A[i];
    --A[i];
  }

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

  for(int i=0; i<n-1; ++i){
    cin >> C[i];
  }
  int ans = 0;
  int sum = 0;
  for(int i=0; i<n; ++i){
    ans =+ B[A[i]];
    if(A[i-1]+1 == A[i] && 0 < i){
      ans += C[A[i-1]];
    }
    sum += ans;
  }
  cout << sum;
}
          

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int x,y;
	scanf("%d%d",&x,&y);
	int ans1=a*x+b*y;
	int ans2=0;
	int temp=min(x,y);
	ans2=temp*2*c+(x-temp)*a+(y-temp)*b;
	int ans3=c*2*max(x,y);
	printf("%d\n",min(ans1,min(ans2,ans3)));
	return 0;
}

Measured memory_bytes: 256
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<LL, LL> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = (1 << 19) + 47;

int G[MAX][2];
int X[MAX];
int W[MAX];
vector<PII> S[MAX];


void DFS(int v, int x)
{
    if (X[v] == 0)
    {
        S[v].PB(MP(0, 0));
        return ;
    }
    
    DFS(G[v][0], x);
    DFS(G[v][1], x);
    
    FOR(it, 0, 2)
    {
        int l = G[v][0];
        int r = G[v][1];
        int idx = 0;
        
        FOR(i, 0, SZ(S[l]))
        {
            int old = idx;
            while(idx < SZ(S[r]) && S[l][i].second + W[l] + W[r] + S[r][idx].first <= x)
                ++idx;
            if (idx != old)
            {
                S[v].PB(MP(S[l][i].first + W[l], S[r][idx-1].second + W[r]));
            }
        }
        swap(G[v][0], G[v][1]);
    }
    sort(ALL(S[v]));
}

int main()
{
    
    //freopen("in.txt", "r", stdin);
    //ios::sync_with_stdio(false); cin.tie(0);
    
    int n;
    scanf("%d", &n);
    FOR(i, 1, n)
    {
        int x;
        scanf("%d%d", &x, W + i);
        G[x-1][X[x-1]++] = i;
    }
    
    LL L = -1, R = 1e12;
    while(R - L > 1)
    {
        int M = (L + R) / 2;
        
        FOR(i, 0, n)
            S[i].clear();
        
        DFS(0, M);
        
        if (S[0].empty())
            L = M;
        else
            R = M;
    }
    printf("%lld\n", R);
    
    
}





Measured memory_bytes: 41460
#include<iostream>
#include<queue>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	long long c,k,t[n],ans=0;
	cin>>c>>k;
	queue<int> que;
	rep(i,n)cin>>t[i];
	sort(t,t+n);
	rep(i,n){
		que.push(t[i]);
		while(!que.empty() && que.front()+k<t[i]){
			ans++;
			int cnt=0;
			while(que.size()>1 && cnt<c){
				que.pop();
				cnt++;
			}
		}
	}
	cout<<ans+(que.size()+c-1)/c<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    int n; cin >> n;
    int ball[10];
    for(int i = 0; i < n; i++){
        bool can = true;
        for(int j = 0; j < 10; j++){
            cin >> ball[j];
        }
        int k = ball[0];
        int l = 0;
        for(int j = 1; j < 10; j++){
            if(ball[j]>k){
                k=ball[j];
            }else{
                if(l>ball[j]){
                    can = false;
                    break;
                }else{
                    l = ball[j];
                }
            }
        }
        if(can) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
// #define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
// const int inf = 1ll << 60;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int n;
int h[16], w[16];
int c[4][4];
int dp[1 << 16];

bool valid(int i, int j, int k, int state){
    vi cnt(3);
    rep2(ii, max(0, i - h[k] + 1), min(i + 1, 4)) {
        rep2(jj, max(0, j - w[k] + 1), min(j + 1, 4)) {
            if ((state >> (4*ii+jj)) & 1) cnt[c[ii][jj]]++;
        }
    }
    int cnt_positive = (int)(cnt[0] > 0) + (int)(cnt[1] > 0) + (int)(cnt[2] > 0);
    return cnt_positive == 1;
}

int stamp(int i, int j, int k, int state) {
    rep2(ii, max(0, i - h[k] + 1), min(i + 1, 4)) {
        rep2(jj, max(0, j - w[k] + 1), min(j + 1, 4)) {
            state = (state & ((1 << 16) - 1 - (1 << (4*ii+jj))));
        }
    }
    return state;
}

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

    cin >> n;
    rep(i, n) cin >> h[i] >> w[i];
    rep(i, 4) rep(j, 4) {
        char x;
        cin >> x;
        if (x == 'R') c[i][j] = 0;
        if (x == 'G') c[i][j] = 1;
        if (x == 'B') c[i][j] = 2;
    }

    fill(dp, dp + (1 << 16), inf);
    queue<int> que;
    int s = (1 << 16) - 1;
    que.emplace(s);
    dp[s] = 0;
    while (!que.empty()) {
        int state = que.front(); que.pop();
        rep(k, n) {
            rep(i, 7) {
                rep(j, 7) {
                    if (valid(i, j, k, state)) {
                        int nstate = stamp(i, j, k, state);
                        if (nstate == 0) {
                            cout << dp[state] + 1 << endl;
                            return 0;
                        }
                        if (dp[nstate] == inf) {
                            dp[nstate] = dp[state] + 1;
                            que.push(nstate);
                        }
                    }
                }
            }
        }
    }

}

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

int main() {
    int32_t n;
    cin >> n;
    int32_t l[2 * n];
    for (int32_t i = 0; i < n * 2; i++) {
        cin >> l[i];
    }
    sort(l, l + 2 * n);

    int32_t answer = 0;
    for (int32_t i = 0; i < n * 2; i += 2) {
        answer += l[i];
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
WA = [0] * N
AC = [0] * N

for i in range(M):
  p,s = input().split()
  p = int(p)
  if AC[p-1] == 0:
    if s == "AC":
      AC[p-1] = 1
    else:
        WA[p-1] += 1
        
wa = 0
for j in range(N):
  if AC[j] == 1:
    wa += WA[j]
print(sum(AC),wa)

Measured memory_bytes: 4724
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        long[] points = new long[N];
        for (int i = 0; i < points.length; i++) {
            points[i] = sc.nextLong();
        }
        long[][] dp = new long[N + 1][N + 1];
        // dp[i][j] stores the optimal value for whatever player is playing,
        // having played until we've shrunk the bounds to [i + 1, N - j - 1]
        // WRONG: dp[i][j] should store the optimally played value of X - Y
        // Note, if Taro maxes X - Y, and can onyl control X, it's just picking
        // optimal to get highest score
        // If Jiro minimizes X - Y, and can only control Y, he's just
        // trying to maximize the end score of Y.
        // Also, just keep in mind, this is a VALUE DP.
        // The values are huge (10^9), but N is small...

        // So, try all transitions
        for (int i = N - 1; i >= 0; i--) {
            for (int j = i; j < N; j++) {
                if (i == j) {
                    dp[i][j] = points[i];
                }
                else {
                    long takeLeft = -dp[i + 1][j] + points[i];
                    long takeRight = -dp[i][j - 1] + points[j];
                    dp[i][j] = Math.max(takeLeft, takeRight);
                }
            }
        }
        out.println(dp[0][N - 1]);
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException { return br.readLine(); }

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

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

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

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

using namespace std;

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);

    for(int i=0; i<N; i++){
        cin >> A.at(i);
        if(i > 0)
        A.at(i) = gcd(A.at(i),A.at(i-1));
    }

    cout << A.at(N-1) << endl;
    return 0;
}

Measured memory_bytes: 3784
import java.awt.geom.Point2D;
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        new Main(); 
    }
 
    public Main() {
    	while(sc.hasNext()){
    		new aoj0036().doIt();
    	}
    }
    class aoj0036{
    	String check(int a[][],int y,int x,String s){
    		if(a[y][x]+a[y][x+1]+a[y+1][x]+a[y+1][x+1] == 4){
    			return "A";
    		}else if(a[y][x]+a[y+1][x]+a[y+2][x]+a[y+3][x] == 4){
    			return "B";
    		}else if(a[y][x]+a[y][x+1]+a[y][x+2]+a[y][x+3] == 4){
    			return "C";
    		}else if(a[y][x+1]+a[y+1][x]+a[y+1][x+1]+a[y+2][x] == 4){
    			return "D";
    		}else if(a[y][x]+a[y][x+1]+a[y+1][x+1]+a[y+1][x+2] == 4){
    			return "E";
    		}else if(a[y][x]+a[y+1][x]+a[y+1][x+1]+a[y+2][x+1] == 4){
    			return "F";
    		}else if(a[y][x+1]+a[y][x+2]+a[y+1][x]+a[y+1][x+1] == 4){
    			return "G";
    		}
    		return s;
    	}
    	void doIt(){
    		int a[][] = new int [12][12];
    		String s = "";
    		for(int i = 0;i < 8;i++){
    			String str = sc.next();
    			char ctr[] = str.toCharArray();
    			for(int j = 0;j < 8;j++){
    				a[i][j] = Integer.parseInt(""+ctr[j]);
    			}
    		}
    		for(int i = 0;i < 8;i++){
    			for(int j = 0;j < 8;j++){
    				s = check(a,i,j,s);
    			}
    		}
    		System.out.println(s);
    	}
    }
}

Measured memory_bytes: 27608
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int i,cnt,len;
	char s[100001];
	scanf("%s",s);
	len=strlen(s);
	cnt=0;
	for(i=1;i<len;i++)	{
		if(s[i]!=s[i-1])	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lson root<<1,l,midd
#define rson root<<1|1,midd+1,r
#define pb push_back
typedef long long ll;
const int M=1e6+6;
const int mod=1e9+7;
vector<int>g[M];
ll facn=1;
int n;
ll ans[M],sz[M],mul[M],fac[M];
ll ksm(ll a,ll b){
    a%=mod;
    ll t=1;
    while(b){
        if(b&1)
            t=t*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return t;
}
void dfs1(int u,int fa){
    sz[u]=mul[u]=1;
    for(auto v:g[u]){
        if(v!=fa){
            dfs1(v,u);
            sz[u]+=sz[v];
            mul[u]=mul[u]*mul[v]%mod;
        }
    }
    mul[u]=mul[u]*sz[u]%mod;
}
void dfs2(int u,int fa,ll last){
    ll tmp=last;
    for(auto v:g[u])
        if(v!=fa)
            tmp*=mul[v],tmp%=mod;
    ans[u]=facn*ksm(tmp,mod-2)%mod;
    for(auto v:g[u])
        if(v!=fa)
            last*=mul[v],last%=mod;
    for(auto v:g[u])
        if(v!=fa)
            dfs2(v,u,last*ksm(mul[v],mod-2)%mod*(n-sz[v])%mod);
}
int main(){
    scanf("%d",&n);
    for(ll i=2;i<n;i++)
        facn*=i,facn%=mod;
    for(int u,v,i=1;i<n;i++){
        scanf("%d%d",&u,&v);
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs1(1,0);
    dfs2(1,0,1);
    for(int i=1;i<=n;i++)
        printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 45556
#include <stdio.h>

int judge(int a, int b, int c)
{
    for (int i = 0; i < a; ++i) {
        if ((b*i + c) % a == 0) {
            return 1;
        }
    }
    return 0;
}

int main(int argc, char **argv)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    puts(judge(a, b, c) ? "YES": "NO");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return (int)a;
}

signed main(){

    int N; cin >> N;
    string s; cin >> s;
    int mod = 1000000007;

    mat dp(N + 1, vec(N + 2, 0));
    dp[0][0] = 1;
    REP(n, N){
        dp[n + 1][0] = (dp[n][0] + dp[n][1]) % mod;
        FOR(k, 1, n + 2) dp[n + 1][k] = (dp[n][k - 1] * 2 + dp[n][k + 1]) % mod;
    }
    int ans = dp[N][s.size()];
    int a = fastpow(2, s.size(), mod);
    ans *= fastpow(a, mod - 2, mod);
    ans %= mod;
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 195968
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 ll k,a,b;
  cin>>k>>a>>b;
  
  if(b<=a+2){
    cout<<k+1<<endl;
    return 0;}
  
  ll ans=0;
  if(k-a+1<=1){
    cout<<k+1<<endl;
    return 0;}
  
  if((k-a+1)%2==0){
    ans=a+(k-a+1)/2*(b-a);}
  else{
    ans=a+1+(k-a+1)/2*(b-a);}
  
  cout<<ans<<endl;
  return 0;
  
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
a = list(map(int, input().split()))

dp = [[0 for i in range(2)] for i in range(n + 1)]
dp[0][1] = float('inf') * -1

for i in range(n):
    dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i])
    dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i])
print(dp[n][0])

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

namespace Heap {
	class Program {
		private static int _H;
		private static int[] _A = new int[2000000];

		static void Main(string[] args) {
			_H = int.Parse(Console.ReadLine());
			var line = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
			foreach (var item in line.Select((v, ix) => new { v, ix })) _A[item.ix + 1] = item.v;

			for (int i = _H / 2; i >= 1; i--) maxHeapify(i);
			foreach (var item in _A.Skip(1).Take(_H)) {
				Console.Write(" {0}", item);
			}
			Console.WriteLine();
		}

		private static void Swap<T>(ref T lhs, ref T rhs) {
			T temp;
			temp = lhs;
			lhs = rhs;
			rhs = temp;
		}

		private static void maxHeapify(int i) {
			int l, r, largest;
			l = 2 * i;
			r = l + 1;

			// 左の子、自分、右の子で値が最大のノードを選ぶ
			if (l <= _H && _A[l] > _A[i]) largest = l;
			else largest = i;
			if (r <= _H && _A[r] > _A[largest]) largest = r;

			if(largest != i) {
				Swap<int>(ref _A[i], ref _A[largest]);
				maxHeapify(largest);
			}
		}
	}
}



Measured memory_bytes: 57172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1 << 18;

typedef pair <int, int> pii;
#define x first
#define y second

int val[sz], wet[sz];
vector <int> g[sz];
vector <pii> cmbs[sz];

int main()
{
   int n;
   cin >> n;
   for(int i=1; i<=n; i++) scanf("%d %d", &val[i], &wet[i]);

   int db = min(n, 1 << 12);
   cmbs[0].emplace_back(0, 0);
   for(int i=1; i<=db; i++) {
      int j = i >> 1;
      cmbs[i] = cmbs[j];
      for(auto p : cmbs[j]) {
         cmbs[i].emplace_back(p.x + wet[i], p.y + val[i]);
      }
      sort(cmbs[i].begin(), cmbs[i].end());
      for(int k=0, v=0; k<cmbs[i].size(); k++) {
         v = max(v, cmbs[i][k].y);
         cmbs[i][k].y = v;
      }
   }

   int q;
   cin >> q;
   for(int i=1; i<=q; i++) {
      int v, mxw;
      scanf("%d %d", &v, &mxw);
      vector <pii> up;
		up.emplace_back(0, 0);
		while(v > db) {
			int z = up.size();
			for(int j=0; j<z; j++) {
				auto p = up[j];
				up.emplace_back(p.x + wet[v], p.y + val[v]);
			}
			v >>= 1;
		}
		int ans = 0;
		for(auto p : up) {
			if(p.x <= mxw) {
				int k = upper_bound(cmbs[v].begin(), cmbs[v].end(), make_pair(mxw - p.x, INT_MAX)) - cmbs[v].begin() - 1;
				ans = max(ans, cmbs[v][k].y + p.y);
			}
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 105372
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L> T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++){
    d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}}
L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
L S(L x,L i){for(x=G(x)-M(i+1)+M(i++);i<1<<17;B[i]+=x,i+=i&-i);}
L W(){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}
main(){for(cin>>n>>k;++p<n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;
       for(cin>>a;cin>>s>>a>>b;*s&2?W():A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33480
N,K=map(int, input().split())
C=[0]*(N+1)
for _ in range(K):
    d=int(input())
    *A,=map(int, input().split())
    for a in A:
        C[a]+=1
ans=0
for i in range(1,N+1):
    if C[i]==0: ans+=1
print(ans)

Measured memory_bytes: 67756
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

const int maxn=30010;
int a[maxn], ban[maxn];
int n;
int sum;
int tot;

void print(){
	for(int i=1;i<=tot;i++) if(!ban[ a[i] ]) printf("%d ", a[i]);
	exit(0);
}
void add(int x,int now){
	a[++tot]=x;
	(sum+=x)%=6;
	if(tot==n){
		if(sum==0);
		else if(sum==2) ban[8]=1, a[++tot]=now*6+6;
		else if(sum==5) ban[9]=1, a[++tot]=6*now+4;
		else if(sum==3) ban[9]=1, a[++tot]=6*now+12;
		print();
	}
}

int main(){

	scanf("%d", &n);
	if(n==3){ puts("2 5 63"); return 0; }
	if(n==4){ puts("2 5 20 63"); return 0; }
	if(n==5){ puts("2 3 4 6 9"); return 0; }
	int tot=0;
	for(int i=0;i<5000;i++){
		add(6*i+2,i), add(6*i+3,i);
		add(6*i+4,i), add(6*i+6,i);
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

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

    for (int i = 1; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            if (i * j == n) {
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }

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


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

void judge(vector<ll>&p2, int exp, int K, ll ans) {
	//cout << exp << " " << ans << endl;
	vector<ll>p;
	if (exp == 0) {
		cout << ans << endl;
		return;
	}
	int x = 0;
	int tmp = 0;
	rep(j, p2.size()) {
		if (p2[j] % (1ll << exp) >= (1ll << exp-1)) {
			tmp++;
			p.push_back(p2[j]);
		}
	}
	if (K <= tmp)judge(p,exp-1,K,ans+(1ll << exp - 1));
	else judge(p2,exp-1,K,ans);
}

int main() {
	cin.sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<ll>a(N);
	rep(i, N)cin >> a[i];
	vector<ll>p;
	rep(i, N) {
		ll tmp = 0;
		rep(j, N) {
			tmp += a[i + j];
			p.push_back(tmp);
			if (i + j == N - 1)break;
			
		}
	}
	judge(p, 40, K, 0);



	
	return 0;

}

Measured memory_bytes: 11244
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

int main() {
  int n;
  string s;
  cin >> n >> s;
  s = string(" ") + s;
  if (n & 1) return !printf("No\n");
  n /= 2;
  for (int i = 1; i <= n; ++i) {
    if (s[i] != s[i + n]) return !printf("No\n");
  }
  printf("Yes\n");
}


Measured memory_bytes: 256