akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5;
typedef long long ll;

ll x[MAXN];
ll a[MAXN];
ll d[MAXN];
ll p[MAXN];

ll tmp_mult[MAXN];
void mult(ll *ar, ll *perm, ll sz)
{
    for (int i = 1; i <= sz; i++)
        tmp_mult[i] = ar[perm[i]];

    for (int i = 1; i <= sz; i++)
        ar[i] = tmp_mult[i];
}

ll tmp_pw[MAXN];
void pw(ll *perm, ll x, ll sz)
{
    if (x == 1)
    {
        for (ll i = 1; i <= sz; i++)
            tmp_pw[i] = perm[i];
        return;
    }

    pw(perm, x/2, sz);
    mult(perm, perm, sz);
    if (x&1) mult(perm, tmp_pw, sz);
}

int main()
{
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++)
        cin >> x[i];

    ll m, k;
    cin >> m >> k;

    for (ll i = 0; i < m; i++)
        cin >> a[i];

    d[0] = 0;
    for (ll i = 1; i <= n; i++)
        d[i] = x[i] - x[i-1];

    for (ll i = 1; i <= n; i++)
        p[i] = i;

    for (ll i = 0; i < m; i++)
        swap(p[a[i]], p[a[i]+1]);

    pw(p, k, n);

    mult(d, p, n);

    ll pref = 0;
    for (ll i = 1; i <= n; i++)
    {
        pref += d[i];
        cout << pref << endl;
    }
}


Measured memory_bytes: 5888
t_hp ,t_atack ,a_hp ,a_atack = map(int, input().split())

t_death_sum = -(-t_hp // a_atack)
a_death_sum = -(-a_hp // t_atack)


if (t_death_sum < a_death_sum):
  print("No")
else :
  print("Yes")

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

tuple<int64, int64> BinarySearch(
    int64 min_value, int64 max_value, function<bool(int64)> is_r_fn) {
  int64 l = min_value;
  int64 r = max_value;
  while (r - l >= 2) {
    int64 m = (l + r) / 2;
    if (is_r_fn(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  return make_tuple(l, r);
}

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

  int n;
  int64 k;
  cin >> n >> k;

  vector<int64> xs(n);
  vector<int64> ys(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> ys[i];
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());
  reverse(ys.begin(), ys.end());

  const auto is_r_fn = [&](int64 c) {
    int64 sum = 0;
    for (int i = 0; i < n; i++) {
      int64 x = c / ys[i];
      if (x < xs[i]) {
        sum += xs[i] - x;
      }
    }
    return sum <= k;
  };

  if (is_r_fn(0)) {
    cout << 0 << endl;
    return 0;
  }
  
  int64 l, r;
  tie(l, r) = BinarySearch(0, 1E12, is_r_fn);
  cout << r << endl;
}

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

const int Nmax = 100;
const int cake = 4;
const int donut = 7;

int main(){

  int N;
  cin >> N;

bool flag = false;

  for(int i = 0; i < Nmax/cake; ++i){
    for(int j = 0; j < Nmax/donut; ++j){
        if(cake * i + donut * j == N) flag = true;
    }
  }

  if(flag == true) cout << "Yes";
  else cout << "No";


  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

template<typename T> 
struct Edge {
    int src, dst; T w;
    Edge() {};
    Edge(int src, int dst, T w): src(src), dst(dst), w(w){}
    bool operator<(const Edge &e)const{return w != e.w ? w > e.w : (src != e.src ? src < e.src : dst < e.dst);}
    bool operator==(const Edge &e){return src == e.src && dst == e.dst;}
};

template<typename T> 
class Graph : public vector<vector<Edge<T>>> {
public:
    T inf;
    Graph(int n, T inf=numeric_limits<T>::max()): inf(inf){(*this).resize(n);}
    void direct(int s, int t, T w){(*this)[s].push_back(Edge<T>(s,t,w));}
    void undirect(int s, int t, T w){direct(s,t,w);direct(t,s,w);}
    /*
    s : start point
    cost : O(|V||E|)
    first : is negative cycle ?
    second : distances
    */
    pair<bool,vector<T>> bellman_ford(int s=0){
        const int n = (*this).size();
        vector<T> dist(n, inf);
        dist[s] = 0;
        for(int i=0;i<n-1;i++) {
            // bool update = false;
            for(int v=0;v<n;v++) for(auto e : (*this)[v]) {
                if (dist[v] != inf && dist[e.dst] > dist[v] + e.w) {
                    dist[e.dst] = dist[v] + e.w;
                    // update = true;
                    // if(i==ln-1) return make_pair(true, dist);
                }
            }
            // if(!update) break;
        }
        for(int i=0; i<n; i++) {
            for(int v=0;v<n;v++) for(auto e : (*this)[v]) {
                if (dist[e.src] != inf && dist[e.dst] > dist[e.src] + e.w) {
                    dist[e.dst] = -inf;
                }
            }
        }
        return make_pair(false, dist);
    }
};

int main() {
    ll N, M, P;
    cin >> N >> M >> P;
    Graph<ll> G(N, 1LL<<60);
    ll A, B, C;
    REP(i, M) {
        cin >> A >> B >> C;
        G.direct(--A, --B, -C+P);
    }
    auto ans = G.bellman_ford(0);
    ll cost = -ans.second[N-1];
    cost = cost < 0 ? 0 : cost;
    if(cost >= G.inf)
        cout << -1 << endl;
    else
        cout << cost << endl;
	return 0;
}

Measured memory_bytes: 640
use std::io::Read;
 
fn main() {
    let mut buf = String::new();
 
    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();
 
    // 値段
    let n: usize = iter.next().unwrap().parse().unwrap();
    // 嫌いな数字の数
    let q: usize = iter.next().unwrap().parse().unwrap();
    
    // 嫌いな数字配列
    let lrt: Vec<char> = (0..q)
        .map(|_| {
                iter.next().unwrap().parse().unwrap()
        }).collect();

    let mut result = 0;
    for i in n..99999 {
        let chars = &i.to_string().chars().collect::<Vec<char>>();
        let mut ok = true;
        for c in chars.iter() {
            if lrt.contains(&c) {
                ok = false;
                break;
            }
        }

        if ok {
            result = i;
            break;
        }
    }
    print!("{}", result);
  
}


Measured memory_bytes: 2180
n, m, k = map(int, input().split())

mod = 998244353
inv_t = [0]+[1]
inv_te = [0 for i in range(n+1)]
inv_te[0] = 1
inv_te[1] = 1
for i in range(2,n+1):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]
  inv_te[i] = (inv_te[i-1] * inv_t[i]) % mod

n_minus1_mod = 1
for i in range(2,n):
    n_minus1_mod *= i
    n_minus1_mod %= mod

ans = 0

for i in range(k+1):
    ans_plus = (m * pow((m-1), (n-i-1), mod)) % mod
    ans_plus = (ans_plus * n_minus1_mod) % mod
    ans_plus *= inv_te[i]
    ans_plus %= mod
    ans_plus *= inv_te[n-1-i]
    ans_plus %= mod
    ans += ans_plus
    ans %= mod

print(ans)


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

using namespace std;


int main()
{


	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
*/
	int a , b;
	cin >> a >> b;
	int cnt = 0;

	int c = 1;


	while (c  < b)
	{
		cnt++;
		c += a-1;
	}

	cout << cnt;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n;cin>>n;
    rep(a,1,10){
        ll b = n/a;
        if(n % a == 0 && b < 10){
            cout << "Yes" << ednl;
            return 0;
        }
    }
    cout << "No" << ednl;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n;
int a[MAXN];

int dir; // 0=from end of c to start of c to start of b to end of b, 1=opposite
int b[MAXN],nb;
int c[MAXN],nc;
int ret[MAXN],nret;


void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);
	nb=nc=dir=0;
	REP(i,n) {
		if(dir==0) b[nb++]=a[i]; else c[nc++]=a[i]; dir=1-dir;
	}
	nret=0;
	if(dir==0) { for(int i=nc-1;i>=0;--i) ret[nret++]=c[i]; REP(i,nb) ret[nret++]=b[i]; }
	if(dir==1) { for(int i=nb-1;i>=0;--i) ret[nret++]=b[i]; REP(i,nc) ret[nret++]=c[i]; }
	REP(i,nret) { if(i!=0) printf(" "); printf("%d",ret[i]); } puts("");
}

int main() {
	run();
	return 0;
}


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

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

using namespace std;
using lint = long long;

int main(void)
{
    int K, X;
    cin >> K  >> X;
    for(int i = X-K+1; i < X+K; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

public class ABC150C {
  public static void Main(string[] args) {
    var str = Console.ReadLine();
    int n = int.Parse(str);
    int[] p = new int[n];
    int[] q = new int[n];
    var str2 = Console.ReadLine().Split();
    var str3 = Console.ReadLine().Split();
    int order_p = 0;
    int order_q = 0;
    int count_p = 0;
    int count_q = 0;
    
    for (int i = 0; i < n; i++) {
      p[i] = int.Parse(str2[i]);
      q[i] = int.Parse(str3[i]);
    }
    
    for (int i = 0; i < n; i++) {
      count_p = p[i] - 1;
      count_q = q[i] - 1;
      for (int j = 0; j < i; j++) {
        if (p[i]-1 >= p[j]) {
          count_p--;
        }
        if (q[i]-1 >= q[j]) {
          count_q--;
        }
      }
      order_p += count_p * Num(n-i-1);
      //Console.WriteLine(order_p);
      order_q += count_q * Num(n-i-1);
      //Console.WriteLine(order_q);
      //Console.WriteLine();
    }
    
    
    
    
    Console.WriteLine(Math.Abs(order_p - order_q));
  }
    
  public static int Num(int n) {
    if (n <= 1) {
      return n;
    }else {
      return n * Num(n - 1);
    }
  }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>

#define MOD 1000000007

long long fact(long long n)
{
    long long i,ans = 1;
    for (i = 1; i <= n; i++)
    {
        ans *= i;
        ans = ans % MOD;
    }
    return ans;
}

int main()
{
    long long m,n,i,j;
    scanf("%lld %lld",&n,&m);

    if(abs(n - m) > 1)
    {
        printf("0");
    }
    else if(abs(n - m) == 0)
    {
        printf("%lld",(((fact(n) * fact(m)) % MOD) * 2) % MOD);
    }
    else
    {
        printf("%lld",(fact(n) * fact(m)) % MOD);
    }
    
}

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

int main() {
    int A, B;
    cin >> A >> B;

    if( A<=8 && B<=8){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string S; cin >> S;
    string T; cin >> T;
    bool ans = true;
    if (T.size() +1 == S.size()) ans = false;
    REP(i,S.size()) {
        if (S[i] != T[i]) ans = false;
    }

    ATYN(ans)

    return 0;
}

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

typedef long long ll;

int main ()
{
	int n;
  	cin >> n;
  	ll sum = 0;
  	for (int i = 0; i < n + 1; i++)
    {
    	if (i % 3 != 0 && i % 5 != 0)
        {
        	sum += i;
        }
    }
  	cout << sum << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int ans = 0;
    while (!(b > g && g > r)) {
        if (g <= r) {
            g *= 2;
        } else {
            b *= 2;
        }
        ans++;
    }
    int k;
    cin >> k;
    cout << (ans <= k ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3596
N = int(input())
A = list(map(int, input().split()))
ans = r = x = 0
for l in range(N):
    while r < l or r < N and x ^ A[r] == x + A[r]:
        x ^= A[r]
        r += 1
    ans += r - l
    x ^= A[l]
print(ans)

Measured memory_bytes: 23560
#include <bits/stdc++.h>
    using namespace std;
    const long long INF = 1LL <<60;
    const long long Mo=1000000007;
         
    long long gcn(long long x,long long y){
      if(x%y==0){
        return y;  
      }
      else{
        return gcn(y,x%y);
      }
    }
     
    long long modpow(long long a, long long n, long long mod) {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }
     
    int main(void){
      long long tmp;
      long long l[2];
      long long n,k;
      long long x=0;
      long long i,j;
      long double res=0.0;
      
      cin>>n;
      tmp=0;
      for(i=0;i<n;i++){
        cin>>l[0]>>l[1];
        if(l[0]==l[1]){
          tmp++;
        }
        else{
          tmp=0;
        }
        if(tmp==3){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
      
      cout<<"No"<<endl;

      //cout<<setprecision(15)<<res<<endl;
      //cout<<res<<endl;
      
      return 0;
    }

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int K, N;
  cin >> N >> K;
  int l[N - 1];
  for (int i = 0; i < N; ++i) {
    cin >> l[i];
  }
  sort(l, l + N); // array

  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += l[N - i - 1];
  }
  cout << sum << endl;

  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 100000+10;
const ll mod = 1000000000+7;
vi graph[maxn];
ll dp[maxn][2];
ll dp2[maxn];
int N;

void dfs(int u,int p){
	dp[u][0] = 1;
	dp[u][1] = 1;
	vi nodes;
	for(auto &v : graph[u]){
		if(v == p)continue;
		nodes.pb(v);
		dfs(v,u);
	}
	if(nodes.empty())return;
	for(auto &v : nodes){
		dp[u][0] = ((dp[u][0]%mod)*(dp[v][1]%mod))%mod;
	}
	int v = nodes[0];
	dp2[0] = ((dp[v][0]%mod)+(dp[v][1]%mod))%mod;
	forn(i,1,nodes.size()){
		int v = nodes[i];
		ll tmp1 = ((dp[v][0]%mod)+(dp[v][1]%mod))%mod;
		ll tmp2 = ((tmp1%mod)*(dp2[i-1]%mod))%mod;
		dp2[i] = tmp2;
		if(dp2[i] < 0)dp2[i] += mod;
	}
	dp[u][1] = dp2[nodes.size()-1];
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	forn(i,0,N-1){
		int u,v; cin >> u >> v; u--; v--;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	dfs(0,0);
	ll res = ((dp[0][0]%mod)+(dp[0][1]%mod))%mod;
	if(res < 0)res += mod;
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 17024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int X,A,B;
    cin >> X >> A >> B;
    cout << (X-A)%B << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [None] * N
B = [None] * N
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

A.sort()
B.sort()

if N % 2 == 0:
    b = (B[N // 2] + B[(N - 1) // 2]) / 2
    a = (A[N // 2] + A[(N - 1) // 2]) / 2
    print(int((b - a) * 2 + 1))
else:
    print(B[N // 2] - A[N // 2] + 1)


Measured memory_bytes: 25448
#include<bits/stdc++.h>
using namespace std;
int n, k, v[50];

long long sum(vector<int> h, int st){
  long long s = 0;
  for ( int i = st; i < h.size(); i++){
    s += h[i];
  }
  return s;
}

int reidx(int idx){
  return idx >= 0 ? idx % n : n + idx;
}

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

  long long ans = 0;
  for ( int i = k; i >= k/2 + 1; i--){
    for ( int j = 0; j <= min(n,i); j++){
      vector<int> h;
      int st = reidx(j-1);
      for ( int l = 0; l < min(i,n); l++){
        h.push_back(v[reidx(st-l)]);
      }

      sort(h.begin(), h.end());
      int ss = 0;
      while ( k - i > ss && h[ss] < 0){
        ss++;
      }
      long long sumV = sum(h,ss);
      ans = max(ans, sumV);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
# 2019/10/10

n,k=map(int,input().split())
s=list(input())+[None]

cnt=1
ss=[]
if s[0]=='0':ss.append(0)

i=1
while i<=n:
    if s[i]==s[i-1]:
        cnt+=1
    else:
        ss.append(cnt)
        cnt=1
        
    i+=1

if s[-2]=='0':ss.append(0)
nn=len(ss)
k=min(nn//2,k)
res=sum(ss[:k*2+1])
cnt=res
l=0
for r in range(k*2+2,nn,2):
    cnt-=(ss[l]+ss[l+1])
    cnt+=(ss[r]+ss[r-1])
    res=max(res,cnt)
    l+=2

print(res)



Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

vector<ll> mkprimes(ll N) {
    vector<bool> isprime(N + 1);
    vector<ll> primes;
    for (ll i = 0; i <= N; i++) {
        isprime[i] = true;
    }
    isprime[0] = false;
    isprime[1] = false;

    for (ll i = 2; i <= N; i++) {
        if (isprime[i]) {
            primes.push_back(i);
            for (ll j = 2 * i; j <= N; j += i) {  // 素数iの倍数は素数ではない
                isprime[j] = false;
            }
        }
    }
    return primes;
}

set<ll> primefact(ll n, vector<ll> &primes, vector<set<ll>> &cache) {
    if (n<=1){
      set<ll> s;
      return s;
     }
    if (cache[n].size() > 0) {
       return cache[n];
    }
    for (ll p = 0; p < primes.size(); p++) {
        ll pr = primes[p];
        if (n % pr == 0) {
            set<ll> s = primefact(n/pr,primes,cache);
            s.insert(pr);
            cache[n] = s;
            return cache[n];
        }
    }
}

                

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll pmax = 1000002;
    auto primes = mkprimes(pmax);
    //vector<bool> isprime(pmax+1, false);
    vector<set<ll>> cache(pmax+1);
    for (auto ppr: primes) {
      //isprime[ppr] = true;
      cache[ppr].insert(ppr);
    }
    vector<vector<ll>> factors(N);
    vector<ll> usedprimes(pmax+1, 0);
    for (ll i = 0; i < N; i++) {
        ll n = A[i];
        for (ll pf : primefact(n, primes,  cache)) {
           usedprimes[pf]++;
        }
    }
    ll maxused = 0;
    for (auto u : usedprimes) {
        maxused = max(u, maxused);
    }
    if (maxused == N) {
        print("not coprime");
    } else if (maxused >= 2) {
        print("setwise coprime");
    } else {
        print("pairwise coprime");
    }
}


Measured memory_bytes: 223608
# classを使うのをやめてlistで実施する
# dfsを再帰でなくstackを用いて書く
from collections import deque
import sys
input = sys.stdin.readline

def dfs():
    stk1 = deque([0])
    stk2 = deque([])
    while stk1:
        v = stk1.pop()
        visited[v] = True
        stk2.append(v)
        for i in range(len(AL[v][CHILDREN])):
            u = AL[v][CHILDREN][i]
            if visited[u]:
                AL[v][CHILDREN][i] = None
                continue
            stk1.append(u)

    for i in range(n - 1, -1, -1):
        v = stk2[i]
        for u in AL[v][CHILDREN]:
            if u is None:  continue
            AL[v][SIZE] += AL[u][SIZE]

def anaaki(v):
    ret = pow(2, n - 1, p) - 1
    for ch in AL[v][CHILDREN]:
        if ch is None: continue
        ret -= pow(2, AL[ch][SIZE], p) - 1
        ret %= p
    ret -= pow(2, n - AL[v][SIZE], p) - 1
    ret %= p
    return ret

n = int(input())
SIZE = 0
CHILDREN = 1
AL = [[1, []] for _ in range(n)]
visited = [False] * n
p = 10 ** 9 + 7

for i in range(n - 1):
    a, b = [int(x) - 1 for x in input().split()]
    AL[a][CHILDREN].append(b)
    AL[b][CHILDREN].append(a)

dfs()
numer = 0
for i in range(n):
    numer += anaaki(i)
    numer %= p

denom = pow(2, n, p)
print(numer * pow(denom, p - 2, p) % p)

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

namespace AtCoder
{
    class ABC043
    {
        static void Main(string[] args) {
            var s = Console.ReadLine();
            string res = "-1 -1";
            for(int i = 1; i < s.Length; i++) {
                if(s[i] == s[i - 1]) {
                    res = i + " " + (i + 1);
                    goto END;
                }
            }
            for (int i = 2; i < s.Length; i++) {
                if (s[i] == s[i - 2]) {
                    res = (i - 1)+ " " + (i + 1);
                    goto END;
                }
            }
        END:; Console.WriteLine(res);
        }
}
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    ll mini = 0;
    ll maxi = 0;
    for (int z=0;z<k;z++){
        mini += z;
        maxi += n-z;
    }
    ll ans = 0;
    for (int z=k;z<=n+1;z++){
        ans += maxi-mini+1;
        mini += z;
        maxi += n-z;
        ans %= mod;
        mini %= mod;
        maxi %= mod;
        if (ans < 0) ans += mod;
        if (mini < 0) mini += mod;
        if (maxi < 0) maxi += mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
n, d=gets.split.map(&:to_i)
x=Array.new(n)
y=Array.new(n)
n.times do |i|
    x[i],y[i]=gets.split.map(&:to_f)
end

count=0
dist=0
n.times do |i|
    dist=(x[i]**2+y[i]**2)**0.5
    if dist<=d
        count+=1
    end
end
puts count


Measured memory_bytes: 18032
def is_ok(a,b,c):
    return L[a] < L[b] + L[c]
def meguru_bisect(ng, ok, a, b):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, b, mid):
            ok = mid
        else:
            ng = mid
    return ok
N = int(input())
L = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for a in range(N):
    for b in range(a+1, N):
        ans += meguru_bisect(N,b,a,b)-b
print(ans)


Measured memory_bytes: 74748
n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
dp = [[[0]*(x_max*n+1) for k in range(n+1)] for i in range(n+1)]
ans = 0
dp[0][0][0] = 1
for i in range(n):
    for j in range(i+2):
        for k in range(x_max*n+1):
            if k>= x[i]:
                dp[i+1][j][k] = dp[i][j-1][k-x[i]] + dp[i][j][k]
            else:
                dp[i+1][j][k] = dp[i][j][k]
            
for k in range(x_max*n+1):
    for j in range(1,n+1):
        if a*j == k:
            ans += dp[n][j][k]
print(ans)

Measured memory_bytes: 94940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	int h;
	cin >> h;
	int ans = 0, cur = 1;
	while(h > 0) {
		ans += cur;
		cur *= 2;
		h /= 2;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= n; i+=2){
            HashSet<Integer> set = new HashSet<>();
            int max = (int)Math.sqrt(i);
            for(int j = 1; j <= max; j++){
                if(i % j == 0){
                    set.add(j);
                    set.add(i/j);
                }
            }
            if(set.size() == 8) ans++;
        }
        pw.println(ans);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25544
S = input()
S = S[::-1]

divide = ["dream", "dreamer", "erase", "eraser"]
for i in range(len(divide)):
    divide[i] = divide[i][::-1]

i = 0
can = True
while(i < len(S)):
    can_local = False
    for j in range(4):
        d = divide[j]
        if S[i:i+len(d)] == d:
            can_local = True        
            i += len(d)
            
    if not can_local:
        can = False
        break

if can:
    s = "YES"
else:
    s = "NO"
print(s)

Measured memory_bytes: 3188
import java.util.Scanner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main{
    public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
      		String str = sc.nextLine();
      		for(int i=str.length()-1; i>=0; i--){
              System.out.print(str.charAt(i));
            }
              System.out.println();
    }
}



Measured memory_bytes: 26044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll b,c=0,d=0,e=0,i,j,k;
    scanf("%lld",&b);
    for(i=1; i<=b; i++)
    {
        for(j=1; j<=b; j++)
        {
            for(k=1; k<=b; k++)
            {
                c+=__gcd(i,__gcd(j,k));
            }
        }
    }
    printf("%lld\n",c);
    return 0;
}


Measured memory_bytes: 3756
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a = iterator.next().unwrap();
    let b = iterator.next().unwrap();
    let c = iterator.next().unwrap();

    if a.chars().rev().next().unwrap() == b.chars().next().unwrap()
        && b.chars().rev().next().unwrap() == c.chars().next().unwrap() {
        "YES".to_string()
    } else {
        "NO".to_string()
    }
}


Measured memory_bytes: 2084
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

ans=[0 for i in range(n)]

for i in a:
  i-=1
  ans[i]+=1

for i in ans:
  print(i)

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

vector<pe> prime_factorize(ll num)
{
    vector<pe> result;

    for (ll i = 2; i * i <= num; i++)
    {
        if (num % i != 0)
            continue;
        ll e = 0;

        while (num % i == 0)
        {
            e++;
            num /= i;
        }

        result.push_back({i, e});
    }

    if (num != 1)
        result.push_back({num, 1});
    return result;
}


int main(void)
{
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i+=2)
    {
        vector<pe> result = prime_factorize(i);
        ll count = 1;
        for(auto elem : result){
            count *= (elem.second + 1);
        }

        if(count == 8) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3616
O = input()
E = input()
Answer = ''
for i in range(len(O)-1):
  Answer = Answer + O[i]
  Answer = Answer + E[i]
if len(E)==len(O):
  Answer = Answer + O[len(O)-1]
  Answer = Answer + E[len(E)-1]
else:
  Answer = Answer + O[len(O)-1]

print(Answer)


Measured memory_bytes: 3060
import heapq

N, M, S = map(int, input().split(" "))
# (city i, silver: S) -> S * N + i
edges = {i: [] for i in range(2501 * N - 1)}

for i in range(M):
    U, V, A, B = map(int, input().split(" "))
    edges[U - 1].append((V - 1, A, B))
    edges[V - 1].append((U - 1, A, B))

exchange_edges = {}
for i in range(N):
    C, D = map(int, input().split(" "))
    exchange_edges[i] = (C, D)

dist = [[-1 for _ in range(2501)] for _ in range(N)]
que = []
heapq.heappush(que, (0, 0, min(S, 2500)))

while que:
    time, now, s = heapq.heappop(que)
    if dist[now][s] != -1:
        continue
    dist[now][s] = time
    # normal edge
    for (to, a, b) in edges[now]:
        if a > s or dist[to][s - a] != -1:
            continue
        heapq.heappush(que, (time + b, to, s - a))

    # exchange_edge
    (silv, t) = exchange_edges[now]
    if s + silv <= 2500 and dist[now][silv + s] == -1:
        heapq.heappush(que, (time + t, now, s + silv))

for i in range(1, N):
    print(min(dist[i]))

Measured memory_bytes: 121608
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] a = new int[n], x = new int[m], y = new int[m];
        for(int i = 0; i < n; i++) a[i] =sc.nextInt()-1;
        UnionFindTree uft = new UnionFindTree(n);
        for(int i = 0; i < m; i++){
            uft.union(sc.nextInt()-1, sc.nextInt()-1);
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(uft.same(i, a[i])) ans++;
        }
        System.out.println(ans);
    }
}
class UnionFindTree
{
    int[] parent, rank;
    public UnionFindTree(int size)
    {
        this.parent= new int[size];
        this.rank = new int[size];
        for(int i = 0; i < size; i++){
            parent[i] = i;
            rank[i] = 0;
        }
    }
    public void union(int x, int y){
        int xRoot = find(x);
        int yRoot = find(y);

        if(rank[xRoot] > rank[yRoot]) parent[yRoot] = xRoot;

        else if(rank[xRoot] < rank[yRoot]) parent[xRoot] = yRoot;

        else if(xRoot != yRoot){
            parent[yRoot] = xRoot;
            rank[xRoot]++;
        }
    }
    public int find(int i){
        if(i != parent[i]) parent[i] = find(parent[i]);
        return parent[i];
    }
    public boolean same(int x, int y){
        return find(x) == find(y);
    }
}

Measured memory_bytes: 94924
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	int n = s.size();
	//two possibilities: start with 1 or 0
	int ans0 = (s[0] == '1');
	int ans1 = (s[0] == '0');
	repn(i, 1, n){
		if(i % 2 == 0){
			ans0 += (s[i] == '1');
			ans1 += (s[i] == '0');
		}
		else{
			ans1 += (s[i] == '1');
			ans0 += (s[i] == '0');
		}
	}
	cout << min(ans0, ans1) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 512
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let n = scanner.NextI32()
    let h = scanner.NextI64()
    let arrAB = [|for _ in 0..n-1 -> (scanner.NextI64(), scanner.NextI64())|]
    let maxs = Array.maxBy (fun (x, _) -> x) arrAB |> fst
    let lstB =
        arrAB
        |> Array.map snd
        |> Array.where (fun x -> x > maxs)
        |> Array.toList
        |> List.sortDescending

    let rec f1 target v c =
        function
        | [] -> c, v
        | (x::xs) -> 
            let nx = v + x
            if target <= nx
            then
                (c + 1L), nx
            else
                f1 target nx (c + 1L) xs
    
    let rec f2 target x =
        let y = target / x
        if target % x = 0L then y else y + 1L

    let (a1, v1) = f1 h 0L 0L lstB

    if v1 >= h
    then a1
    else f2 (h - v1) maxs |> (+) a1
    |> printfn "%i"

    0


Measured memory_bytes: 36416
#include<stdio.h>
int main()
{
	long long tc,sum = 1;
	int flagO = 1,flag = 1;
	scanf("%lld",&tc);
	long long input[tc+1];
	for(int i = 0;i<tc;i++)
	{
		scanf("%lld",&input[i]);
		if(input[i] == 0) flagO =0;
	}
	for(int i = 0;i<tc;i++)
	{
		if(input[i] > 1000000000 && sum > 1000000000)
		{
			flag = 0;
			break;
		}
		if(sum > 1000000000000000000 || sum < 0 || sum * input[i] > 1000000000000000000) 
		{
			flag = 0;
		}
		sum*= input[i];
	}
	if(flagO == 0) printf("0\n");
	else if(flag == 0) printf("-1\n");
	else printf("%lld\n",sum);
	
}

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

int main() {
    int A, B, C; cin >> A >> B >> C;

    if(A == B) {
        cout << C << endl;
    } else if(B == C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		String[] strs1 = scan.nextLine().split(" ");
		String[] strs2 = scan.nextLine().split(" ");
		int n = Integer.parseInt(strs1[0]);
		int k = Integer.parseInt(strs1[1]);
		int[] p = Arrays.stream(strs2).mapToInt(str -> Integer.parseInt(str)).toArray();

		int sum = Arrays.stream(Arrays.copyOfRange(p, 0, k)).sum();
		int max = sum;
		for (int i = 0; i < n - k; i++) {
			sum = sum - p[i] + p[i + k];
			max = Math.max(sum, max);
		}
		double exp = (max + k) / 2.0;

		System.out.println(String.valueOf(exp));
		scan.close();
	}
}

Measured memory_bytes: 52016
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  int x3 = y1 - y2 + x2, y3 = x2 - x1 + y2;
  cout << x3 << " " << y3 << " " << y2 - y3 + x3 << " " << x3 - x2 + y3 << '\n';
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=n;i>=0;i--){
		if(s.substr(n-i,i)==t.substr(0,i)){
			cout<<2*n-i<<endl;
			return 0;
		}
	}	
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			int temp=sc.nextInt();
			temp+=sc.nextInt();
			int count=0;
			//System.err.println(temp);
			while(temp>0){
				temp/=10;
				count++;
			}
			System.out.println(count);
		}
		
	}
}

Measured memory_bytes: 20372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    ll s = 0, minB = 1e18;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        if (A[i] > B[i]) minB = min(minB, B[i]);
        s += A[i];
    }
    cout << (minB == 1e18 ? 0 : s - minB) << endl;
    return 0;
}

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

long long kaijo(long long num) {
  if (num == 1) return 1;
  return num * kaijo(num - 1) % 1000000007;
}

int main() {
  int n;
  cin >> n;
  cout << kaijo(n) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   string s;
   int w;
   cin >> s >> w;
   int k = 0;
   while (k < s.size()){
      cout << s[k];
      k += w;
   }
   puts("");
}


Measured memory_bytes: 888
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string s[3];
	cin >> s[0] >> s[1] >> s[2];

	int t = 0;
	while(1)
	{
		if(s[t].size() == 0)
		{
			cout << (char)(t+'A');
			return 0;
		}

		char ch = s[t][0];
		s[t].erase(s[t].begin());
		t = ch-'a';
	}
	return 0;
}

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

int main(void) {

  int n;
  cin >> n;
  vector<pair<int, int>> xy(n);
  rep (i, n) cin >> xy[i].first >> xy[i].second;

  vector<int> mawasi(n);
  rep (i, n) mawasi[i] = i;

  vector<double> hozon;
  int kaisuu = 0;
  do {
    kaisuu++;
    vector<pair<int,int>> tmp;
    double kyori = 0;
    for (auto x : mawasi) {
      tmp.push_back(xy[x]);

      //cout << xy[x].first << " " << xy[x].second<< endl;
    }
    rep (i, tmp.size() - 1) {
      kyori +=pow( pow((tmp[i].first - tmp[i + 1].first), 2) + pow((tmp[i].second - tmp[i + 1].second), 2) , 0.5);
    }

    //cout << kyori << endl;

    hozon.push_back(kyori);
  }while (next_permutation(mawasi.begin(), mawasi.end()));

  double ans = 0;
  rep (i, hozon.size()) {
    ans += hozon[i];
  }
  ans /= kaisuu;

  //cout << endl;
  //cout << kaisuu << endl;

  printf("%.12f",ans);

  return 0;
}


Measured memory_bytes: 1276