akhauriyash/Code-Regression huggingface dataset:
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

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


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) < (n); (i)++)

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

    if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R') {
        cout << "3" << endl;
        exit(0);
    }
    else if ((S[0] == 'R' && S[1] == 'R') || (S[1] == 'R' && S[2] == 'R')) {
        cout << "2" << endl;
        exit(0);
    }
    else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R') {
        cout << "1" << endl;
        exit(0);
    }
    else {
        cout << "0" << endl;
    }


}


Measured memory_bytes: 3624
# coding: utf-8
# author: ismdeep
# dateime: 2019-02-09 20:19:18
# filename: c.py
# blog: https://ismdeep.com

(k, a, b) = map(int, input().split())

if a + 1 < b:
    k = k - (a - 1)
    ans = a
    ans += int(k / 2) * (b - a)
    ans += (k % 2)
    print(ans)
else:
    print(k + 1)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int w[105],ans=10000000;
int main(){
    int n,sum=0,cursum=0;cin>>n;for(int i=1;i<=n;i++){cin>>w[i];sum+=w[i];}
    for(int i=1;i<=n;i++){
        cursum+=w[i];
        ans = min(ans,abs(2*cursum-sum));
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
const int N=1e6;
vector<int>edges[N];
bool flag[N];
int cnt=0;

void dfs(int x){
    cnt++;
    flag[x]=true;

    for(int i : edges[x]){
        if(!flag[i])dfs(i);
    }
}

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

    int n, m;
    cin >> n >>m;
    
    for(int i=0;i<m;i++){
        int u,v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
   int mx=0; 
    for(int i=1;i<=n;i++){
        if(!flag[i]){
            cnt=0;
            dfs(i);
        }
        mx=max(mx,cnt);
    }
    cout<<mx<<endl;
    
}



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c;
int x, y;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> s >> t;
  cin >> a >> b;
  string q;
  cin >> q;

  if (s == q)
    a--;
  if (t == q)
    b--;
  cout << a << " " << b;
}

Measured memory_bytes: 3584
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		long N = scn.nextLong();
		long P = scn.nextLong();
		ArrayList<Pair> A = new ArrayList<Pair>();
		for(int i = 2;i <= Math.sqrt(P);i++) {
			int num = 0;
			while(P%i == 0) {
				num++;
				P/=i;
			}
			A.add(new Pair(i,num));
		}
		A.add(new Pair(P,1));
		
		long ans = 1;
		for(int i = 0;i < A.size();i++) {
			long buf;
			Pair p = A.get(i);
			buf = (long)Math.pow(p.getx(), p.getNum()/N );
			if(buf!=0)ans *= buf;
		}
		System.out.println(ans);
	}
}

class Pair{
	long x;
	long num;
	Pair(long x,long num){
		this.x = x;
		this.num = num;
	}

	long getNum() {
		return num;
	}

	long getx() {
		return x;
	}
}


Measured memory_bytes: 50644
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int h = int.Parse(Console.ReadLine());
			long h = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long ans = 0;
			long n = 1;
			for (long i = h; i > 0; i /= 2) {
				//System.Diagnostics.Debug.WriteLine($"HP:{i} N={n}");
				ans += n;
				n *= 2;
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include <algorithm>
#include<iomanip>
#include<cmath>
using std::cin; using std::string;
using std::cout; using std::endl;
using std::sort;
#define rep(X,Y) for(int (X)=0;(X)<(Y);++(X))
#define rept(X,Y,Z) for(int (X)=(Y);(X)<(Z);++(X))
#define repr(X,Y) for(int (X)=(Y);(X)>=0;--(X))
const double pi=3.141592653589793283462;
int main(){
	int n;
	int i=0;
	while(1){
		cin>>n;
		if(n==0)
			break;
	while(1){
		if(n==1)
			break;
		if(n%2==0)
			n=n/2;
		else
			n=n*3+1;
		i++;
	}
	cout<<i<<endl;
	i=0;
	}
	return 0;
}      

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

int main(){
    int n,m;
    cin>>n>>m;
    long long mod=1e9+7;
    long long ans=1;
    if(abs(n-m)>=2){
        cout<<0<<endl;
    }else if(abs(n-m)==1){
        for(int i=1;i<=m;i++){
            ans*=i;
            ans%=mod;
        }
        for(int i=1;i<=n;i++){
            ans*=i;
            ans%=mod;
        }
        cout<<ans<<endl;
    }else if(abs(n-m)==0){
        for(int i=1;i<=n;i++){
            ans*=i;
            ans%=mod;
        }
        ans=2*ans*ans;
        ans%=mod;
        cout<<ans<<endl;
    }
    return 0;
}

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

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

    int ans = 0;
    for(int j = 0; j <= 4; ++j){
        int r = 0;
        for(int i = 0; i <= 10; ++i){
            if((7 * i + j + 9) % 11 == (5 * k) % 11){
                r = i;
            }
        }
        ans += (n - 3) / 11;
        if((n - 3) % 11 >= r) ++ans;
    }
    cout << ans << endl;
}

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

int main() {
  int a, b;
    cin >> a >> b;
  if ( (a % 2) == 1 && (b % 2) ==1){
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,u,v;cin>>N>>u>>v;
  vector<vector<int>>A(N);
  for(int i=0;i<N-1;i++){
    int a,b;cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  queue<int>q1;q1.push(u-1);
  vector<int>D1(N,-1);D1[u-1]=0;
  while(q1.size()){
    int f=q1.front();q1.pop();
    for(int a:A[f])if(D1[a]==-1){D1[a]=D1[f]+1;q1.push(a);}
  }
  queue<int>q2;q2.push(v-1);
  vector<int>D2(N,-1);D2[v-1]=0;
  while(q2.size()){
    int f=q2.front();q2.pop();
    for(int a:A[f])if(D2[a]==-1){D2[a]=D2[f]+1;q2.push(a);}
  }
  
  vector<int>NG(N,0);int M=0,Mi=-1;
  for(int i=0;i<N;i++){
    NG[i]=(D2[i]-D1[i]<0);
    if((!NG[i])&&M<D2[i]){M=D2[i];Mi=i;}
  }
  
  
  //for(int i=0;i<N;i++)cout<<D1[i]<<" "<<D2[i]<<" "<<NG[i]<<endl;
  if(NG[u-1]){cout<<0;return 0;}
  
  //cout<<D1[Mi]<<D2[Mi]<<endl;
  //cout<<D1[Mi]+1<<endl;
  cout<<D1[Mi]+(D2[Mi]-D1[Mi])-1;
}

Measured memory_bytes: 7040
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int int64_t
#define double long double
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << endl;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int >prime_factor(int64_t n){map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
    
    int a,b,c; cin >> a >> b >> c;
    if(a+b+c>=22) out("bust")
    else out("win")

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(abs(c - a) + abs(c - b), min(abs(a - b) + abs(a - c), abs(a - b) + abs(b - c)));
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int[] ans = new int[n];
		int up = 0;
		while (s.contains("RL")) {
			int rl = s.indexOf("RL");
			for (int i = 0; i <= rl; i++) {
				if ((rl - i) % 2 == 0) {
					ans[up + rl]++;
				} else {
					ans[up + rl + 1]++;
				}
			}
			int now = rl + 1;
			while (now < s.length() && s.charAt(now) == 'L') {
				if ((now - rl) % 2 == 0) {
					ans[up + rl]++;
				} else {
					ans[up + rl + 1]++;
				}
				now++;
			}
			up += now;
			s = s.substring(now);
		}
		for (int i = 0; i < n - 1; i++) {
			System.out.print(ans[i] + " ");
		}
		System.out.println(ans[n - 1]);
	}
}

Measured memory_bytes: 347320
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1
#define MOD(x, m) ((x) % (m) + (m)) % (m)

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

template <typename T>
void join(vector<T>& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    string T;
    cin >> T;
//    FOR(i,1,T.size()-1){
//        if(i==0 && T[1]=='D'){
//            T[1] = 'P';
//        }
//        if(T[i] == '?'){
//            if(T[i-1] == 'P' && T[i+1] == 'P'){
//                T[i] = 'D';
//            }
//            else if(T[i-1] == 'D'){
//                T[i] = 'D';
//            }
//        }
//    }
    FOR(i,0,T.size()){
        if(T[i] == '?'){
                T[i] = 'D';

        }
    }
    cout << T;
}

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

    return 0;
}


Measured memory_bytes: 3488
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
  
n,m = map(int,input().split())
chk = factorization(m)

def make_array_for_comb(N, mod=10**9+7):
    fact = [1,1]
    fact_inv = [1,1]
    inv = [0,1]
    for i in range(2, N+1):
        fact.append((fact[-1]*i) % mod)
        inv.append((-inv[mod%i] * (mod//i)) % mod)
        fact_inv.append((fact_inv[-1]*inv[i]) % mod)
    return fact, fact_inv

def comb(n, r, mod=10**9+7):
  if (r < 0) or (n < r):
      return 0
  r = min(r, n - r)
  return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

mod = 10**9+7
ans = 1
for i in chk:
  fact, fact_inv = make_array_for_comb(i[1]+n-1,mod)
  ans *= comb(i[1]+n-1,i[1],mod)
  ans %= mod
if m == 1:
  ans = 1
print(ans)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, a, b;
  while (cin >> n >> a >> b) {
    unless (a <= b) cout << 0 << endl;
    else if (n == 1 && a != b) cout << 0 << endl;
    else {
      lli mn = a * (n - 1) + b;
      lli mx = b * (n - 1) + a;
      cout << mx - mn + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int ss = in.nextInt();
      	int na = in.nextInt();
      	int con = 0;
      	int cnt = 1;
      
      if(na==1){System.out.print(0);
               System.exit(0);
               }
      else if(ss>=na){
        			System.out.print(1);
                     System.exit(0);
                     }
      else{
        con += ss;
      	for(int i = 0;i < na; i++){
			con = (con-1)+ss;
          	cnt++;
          	if(con>=na){break;}
        }
      }
      System.out.print(cnt);
	}
}

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

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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

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

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

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

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


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

    ll n;
    cin >> n;
    ll t[n];
    rp(i,n) cin >> t[i];
    ll m;
    cin >> m;
    ll p[m],x[m];
    rp(i,m) cin >> p[i] >> x[i];
    ll sum = 0;
    rp(i,n){
        sum +=t[i];
    }
    rp(i,m){
        ll cur = p[i]-1;
        cout << sum - t[cur] + x[i]<<endl;
    }
    cout << endl;
    return 0;
}

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


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

int main() {
  int n;
  cin >> n;
  vector<float> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end() );
 
  for (int i = 0; i < n - 1; i++) {
  	A[i + 1] = (A[i] + A[i + 1]) / 2;
  }
  cout << A[A.size() - 1] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vll A(N), B(N);
	REP(i, N)
	{
		cin >> A[i];
	}
	REP(i, N)
	{
		cin >> B[i];
	}
	ll pA = 0;
	ll pB = 0;
	REP(i, N)
	{
		if (A[i] < B[i])
		{
			pA += (B[i] - A[i]) / 2;
		}
		if (A[i] > B[i])
		{
			pB += (A[i] - B[i]);
		}
	}
	if (pA >= pB)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
//need to think of a base line for example cost of one litre for each of the different
//bottle dimensions. 
#include<bits/stdc++.h>
using namespace std;
int main(){

	int q,h,s,d;cin>>q>>h>>s>>d;
  long long n;cin>>n;
  int fourth,half,one,two;
  fourth = q;
  half = min(h,2*fourth);
  one = min(s,2*half);
  two = min(d,2*one);
  if(n%2==0)cout<<n/2*two;
  else cout<<n/2*two+one;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>

using namespace std;

struct Point {
    bool u, r;
    Point() { u = r = true; }
};

int main()
{
    int t;

    cin >> t;
    while (t--) {
        int x, y, p;

        cin >> x >> y >> p;
        Point map[y + 1][x + 1];

        for (int i = 0; i < p; ++i) {
            int x1, y1, x2, y2;

            cin >> x1 >> y1 >> x2 >> y2;
            if (x1 == x2)
                map[min(y1, y2)][x1].u = false;
            else
                map[y1][min(x1, x2)].r = false;
        }

        long long dp[y + 1][x + 1];
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for (int i = 1; i <= x; ++i)
            if (map[0][i - 1].r && dp[0][i - 1] == 1)
                dp[0][i] = 1;
        for (int i = 1; i <= y; ++i)
            if (map[i - 1][0].u && dp[i - 1][0] == 1)
                dp[i][0] = 1;
        dp[0][0] = 0;

        for (int i = 1; i <= y; ++i)
            for (int j = 1; j <= x; ++j) {
                if (map[i][j - 1].r)
                    dp[i][j] += dp[i][j - 1];
                if (map[i - 1][j].u)
                    dp[i][j] += dp[i - 1][j];
            }

        if (dp[y][x] == 0)
            cout << "Miserable Hokusai!\n";
        else
            cout << dp[y][x] << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n,num[999999] = {0},i,j,ans;

    while(cin >> n){
        ans = 0;
        for(i = 0;i <= n;i++){
            num[i] = 1;
        }

        for(i = 2;i <= sqrt(n);i++){
            if(num[i]){
                for(j = 0;i * (j + 2) <= n;j++){
                    num[i * (j + 2)] = 0;
                }
            }
        }

        for(i = 2;i <= n;i++){
            if(num[i]){
                ans++;
            }
        }

        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6992
#include<bits/stdc++.h>
#define int long long
using namespace std;
int solve(vector<int> &v, int l, int r, int lc, int rc){
    if (r-l<0) return 0;
    if (r-l==0){
        return (lc+rc)*v[l];
    }
    int ans = 1e18;
    for (int i=l; i <= r; i++){
        int tetl = lc, tetr=lc+rc;
        int kekl = lc+rc, kekr = rc;
        ans = min(ans, solve(v, l, i-1, tetl, tetr) + solve(v, i+1, r, kekl, kekr) + (lc+rc)*v[i]);
    }
    return ans;
}
main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    cout << solve(v, 1, n-2, 1, 1)+v[0]+v.back();
    return 0;
}

Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))

temp=0
S=[0]
for i in range(N):
    S.append(S[i]+A[i])
S.sort()

D={}
for j in range(N):
    if S[j]==S[j+1]:
        if S[j] in D:
            D[S[j]]+=1
        else:
            D[S[j]]=2

ans=0
for d in D:
    if D[d]>1:
        ans+=D[d]*(D[d]-1)//2
print(ans)

Measured memory_bytes: 26136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		if (n % 2 == 0) {
			System.out.println(n / 2 - 1);
		} else {
			System.out.println(n / 2);
		}
	}
}


Measured memory_bytes: 22996
#include <stdio.h>

void solve(void)
{
	int n;
	int x0, y0, t0;
	int x1, y1, t1;
	int i;
	char ngTxt[] = "No", okTxt[] = "Yes", *pTxt = okTxt;
	
	x1 = y1 = t1 = 0;
	
	scanf("%d", &n);
	for(i=0;i<n;++i){
		int d;
		x0 = x1;
		y0 = y1;
		t0 = t1;
		
		scanf("%d %d %d", &t1, &x1, &y1);
		d = (x1>x0 ? x1-x0 : x0-x1) + (y1>y0 ? y1-y0 : y0-y1);
		if( d > t1 - t0 ){
			pTxt = ngTxt;
			break;
		}
		if( (t1-t0-d)%2 == 1 ){
			pTxt = ngTxt;
			break;
		}
	}
	printf("%s\n", pTxt);
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


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

int main() {
    int n , m , s;
    cin >> n >> m >> s;
    for (int i = 0 ; i <= n ; ++ i) {
        for (int j = 0 ; j <= m ; ++ j) {
            int p = i * (m - j) + j * (n - i);
            if (p == s) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}


Measured memory_bytes: 256
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a>b>=0:
  if a-v*t<=b-w*t:
    print("YES")
  else:
    print("NO")
elif b>a>=0:
  if v*t+a>=w*t+b:
    print("YES")
  else:
    print("NO")
elif a>=0 and b<0:
  if a-v*t<=b-w*t:
    print("YES")
  else:
    print("NO")  
elif a<0 and b>=0:
  if a+v*t>=b+w*t:
    print("YES")
  else:
    print("NO")  
elif a<b<=0:
  if a+v*t>=b+w*t:
    print("YES")
  else:
    print("NO")  
elif b<a<=0:
  if a-v*t<=b-w*t:
    print("YES")
  else:
    print("NO")
elif a==b:
  print("YES")

Measured memory_bytes: 9088
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    ll N, D;
    cin >> N >> D;
    ll cnt = 0;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        if (D * D >= a * a + b * b)
            cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  long long x, N, K;
 
  scanf("%lld %lld", &N, &K);
 
  x = N % K;
  if (x > K - x)
    x = K - x;
 
  printf("%lld\n", x);
  
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

char dir[5] = "RUDL";
int64 rid[256]={};
int64 dx[4] = {1, -1, 1, -1};
int64 dy[4] = {1, 1, -1, -1};


vector<int64> calc(int64 x) {
	int64 xx = abs(x);
	int64 sgn = x < 0 ? 1 : 0;
	vector<int64> v;
	int64 bef = 0;
	for (int64 i = 38; i >= 0; i--) {
		if (bef) {
			v.push_back(1-sgn);
		} else {
			v.push_back(sgn);
		}
		if (xx >> i & 1) {
			bef = 0;
		} else {
			bef = 1;
		}
	}
	return v;
}

PLL topoint(const vector<int64>& d, string& s) {
	PLL p(0, 0);
	REP(i, s.size()) {
		if (s[i] == 'L') p.fs -= d[i];
		if (s[i] == 'R') p.fs += d[i];
		if (s[i] == 'U') p.sc += d[i];
		if (s[i] == 'D') p.sc -= d[i];
	}
	return p;
}

int main(void) {
	int64 N;
	cin >> N;
	vector<int64> X(N), Y(N);
	vector<int64> U(N), V(N);
	int64 parity = -1;
	REP(i, N) {
		cin >> X[i] >> Y[i];
		if (parity != -1 && parity != abs(X[i]+Y[i])%2) {
			cout << -1 << endl;
			return 0;
		} else {
			parity = abs(X[i]+Y[i])%2;
		}
		U[i] = X[i]-Y[i]; V[i] = X[i]+Y[i];
	}
	vector<int64> d(39, 0);
	string res = "";
	REP(i, 39) d[i] = 1LL << i;
	if (parity == 0) {
		d.push_back(1);
		res = "D";
		REP(i, N) {
			U[i] += -1;
			V[i] += 1;
		}
	}
	cout << d.size() << endl;
	REP(i, d.size()) cout << d[i] << " ";
	cout << endl;
	REP(i, N) {
		string ret = res;
		auto du = calc(U[i]);
		auto dv = calc(V[i]);
		REP(j, 39) {
			ret = dir[du[j] | (dv[j] << 1)] + ret;
		}
		// cout << U[i] << " " << V[i] << endl;
		// for (int64 j = 32; j >= 0; j--) {
		// 	cout << "(" << du[j] << " " << dv[j] << ") ";
		// }
		// cout << endl;
		// if (PLL(x, y) != topoint(d, ret)) {
		// 	cout << x << " " << y << endl;
		// }
		cout << ret << endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  double P,a,b;
  if(N%2 == 0){
    P = (double)1/(double)2;
  }
  if(N%2 == 1){
   a = N+1;
   b = 2*N;
   P = a/b;
  }
  cout << P << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
bool valid[maxn];
int n,k,c,minn[maxn],maxx[maxn];
void init(bool data[],int res[])
{
	int now=0,cur=-c;
	while(cur<n&&now<k)
	{
		for(int i=cur+c+1;i<=n;i++)
			if(data[i])
			{
				res[++now]=i;
				cur=i;
				break;
			}
	}
	return;
}
void fl()
{
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}
int main()
{
//	  fl();
	scanf("%d%d%d",&n,&k,&c);
	char s;
	scanf("%c",&s);
	for(int i=1;i<=n;i++)
	{
		scanf("%c",&s);
		valid[i]=(s=='o');
	}
	init(valid,minn);
	reverse(valid+1,valid+n+1);
	init(valid,maxx);
	reverse(maxx+1,maxx+k+1);
	for(int i=1;i<=k;i++)
		if(minn[i]==n-maxx[i]+1)
			printf("%d\n",minn[i]);
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> Pii;
const int INF = 193499;
int main(){
    vector<int> data;
    int n;
    cin >> n ;
    rep(i,n){
        int a;
        cin >> a;
        data.push_back(a);
    }
    sort(data.begin(),data.end());
    vector<pair<int,int>> pairs;
    rep(i,n-1){
        REP(j,i+1,n){
           int tmp;
           tmp = data[i] + data[j]  ;
           pairs.emplace_back(tmp,j);
        }
    }
    lli ans = 0;
    rep(i,n*(n-1)/2){
        ans += lower_bound(data.begin() + pairs[i].second+1,data.end(),pairs[i].first) - data.begin() -pairs[i].second -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18676
function main(arg) {
	var x = arg.split("\n")[0]
	var g = ['A','C','G','T']
	var h = ['T','G','C','A']
	var ans = ''
	for (var i = 0; i < g.length; i++) {
		if (g[i] == x) {
			ans = h[i]
		}
	}
	console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define int long long
using namespace std;
long long k=1000000007;


signed main(){
  int H,W;
  while(cin>>H>>W,H) {
    int r=H*H+W*W;
    int f=1;
    while(1){
      for(int h=1;h<r;h++) {
	if (f&&h<=H)continue;
	int X=r-h*h; // X=w*w
	if (X>h*h) // satisfies w>h ?
	  for(int i=0;i*i<=X;i++)
	    if (i*i==X) { // is sqrt ?
	      cout<<h<<' '<<i<<endl;
	      goto wwwww;
	    }
      }
      r++;
      f=0;
    }
  wwwww:;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

pair < int, int > a[4];
double n, cost[4];
pair < int, int > b[4];

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	int q, h, s, d; cin >> q >> h >> s >> d;
	cin >> n;
	a[0] = mp(q, 8); a[1] = mp(h, 4); a[2] = mp(s, 2); a[3] = mp(d, 1);
	rep(i, 0, 3) b[i] = mp(a[i].first * a[i].second, i);
	sort(b, b + 4);
	cost[0] = 0.25, cost[1] = 0.5, cost[2] = 1, cost[3] = 2;
	ll res = 0ll;
	rep(i, 0, 3) {
		ll cnt = n / cost[b[i].second];
		if(!cnt) continue;
		res += cnt * 1ll * a[b[i].second].first;
		n -= cost[b[i].second] * 1ll * cnt;
	}
	cout << res << nxtl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

   int a;
   int b;
   char op;
    
   while (1) {
       scanf("%d %c %d", &a, &op, &b);
       switch (op) {
       case '+':
           printf("%d\n", a + b);
           break;
       case '-':
           printf("%d\n", a - b);
           break;
       case '*':
           printf("%d\n", a * b);
           break;
       case '/':
           printf("%d\n", a / b);
           break;
       default:
           return 0;
       }
        
        
   }

   return 0;
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f

int main()
{
	double a,b,h,m;cin>>a>>b>>h>>m;
	double x=(h*60+m)*1.0/720;
	double y=m/60;
	double z=abs(x-y);
	if(z>0.5)
	z=abs(1-z);
	printf("%.20lf\n",sqrt(a*a+b*b-2*a*b*cos(z*3.1415926535898*2)));
}




Measured memory_bytes: 4212
let n = stdin.ReadLine() |> int

let t =
  [ for _ in 1 .. n -> stdin.ReadLine() |> int64 ]

let lcm m n =
  let rec gcd (m: int64) (n: int64) =
    if m < n then
      gcd n m
    else
      let mutable a = m, n

      while (snd a) <> 0L do
        let m = fst a
        let n = snd a
        a <- n, (m % n)

      fst a

  (m / (gcd m n)) * n

let ans =
  t
  |> List.fold lcm 1L

ans |> stdout.WriteLine

Measured memory_bytes: 11348
N, A, B = map(int, input().split())

# 各位の和
sum_digit = 0
# 各位の和がA以上B以下の数の和
sum = 0

for i in range(N + 1):
    s = str(i) # 数値iを文字列sに変換
    for j in range(len(s)):
        sum_digit += int(s[j])
    if sum_digit >= A and sum_digit <= B:
        sum += i
    # sum_digitの初期化
    sum_digit = 0

print(sum)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  map<ll,ll>ma;
  rep(i,n)
  {
    ll a,b;cin>>a>>b;
    ma[a]+=b;
  }
  for(auto tp:ma)
  {
    k-=tp.second;
    if(k<=0){
      cout<<tp.first<<endl;
      return 0;
    }
  }
  

  return 0;

}


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

#define F(i, a, n) for(int i=a;i<n;i++)
#define REP(i, n) F(i, 0, n)
#define REP1(i, n) for(int i=1;i<=n;i++)
#define MOD 1000000007

typedef long long ll;

const int MAX = 2e6 + 5;

int n,m,a[50],b[50];
map<int,int> r;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>m;
	REP(i, m){
		cin>>a[i]>>b[i];
		r[a[i]]++; r[b[i]]++;
	}
	REP1(i, n){
		cout<<r[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
	int n, i;
	int sum=0, min=INT_MAX;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		int s;
		scanf("%d", &s);
		sum += s;
		if(s%10!=0 && s<min) min=s;
	}
	if(sum%10==0){
		printf("%d\n", min==INT_MAX?0:sum-min);
	}else{
		printf("%d\n", sum);
	}
}


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

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

    vector<int> l(Q);
    vector<int> r(Q);

    for(int i = 0; i < Q; i++) cin >> l[i] >> r[i];

    int left = *min_element(l.begin(), l.end());
    int right = *max_element(r.begin(), r.end());

    vector<int> x(right + 1);

    for(int i = 3; i < right + 1; i++) {
        x[i] += x[i - 1]; 
        bool checker = false;
        for(int j = 2; j * j <= i; j++) {
            if(i % j == 0) {
                checker = true;
                break;
            }
        }
        if(checker) continue;
        for(int j = 2; j * j <= (i + 1) / 2; j++) {
            if((i + 1) / 2 % j == 0) {
                checker = true;
                break;
            }
        }
        if(checker) continue;
        x[i]++;
    }

    for(int i = 0; i < Q; i++) cout << x[r[i]] - x[l[i] - 1] << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

bool topologicalSort(const vector<vector<int> >& edges, vector<int>& node)
{
    int n = edges.size();
    node.resize(n);

    vector<int> restEdges(n, 0);
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges[i].size(); ++j){
            ++ restEdges[edges[i][j]];
        }
    }

    int restNodes = n;
    queue<int> q;
    for(int i=0; i<n; ++i){
        if(restEdges[i] == 0){
            node[n-restNodes] = i;
            q.push(i);
            -- restNodes;
        }
    }

    while(restNodes > 0){
        if(q.empty()){
            node.clear();
            return false;
        }
        int i = q.front();
        q.pop();

        for(unsigned j=0; j<edges[i].size(); ++j){
            int k = edges[i][j];
            -- restEdges[k];
            if(restEdges[k] == 0){
                node[n-restNodes] = k;
                q.push(k);
                -- restNodes;
            }
        }
    }

    return true;
}

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

    vector<vector<int> > to(n);
    vector<vector<int> > cost(n);
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        to[a].push_back(b);
        cost[a].push_back(c);
    }

    vector<int> node;
    topologicalSort(to, node);

    vector<int> dp(n, 0);
    for(int i=0; i<n; ++i){
        int a = node[i];
        for(int j=0; j<to[a].size(); ++j){
            int b = to[a][j];
            dp[b] = max(dp[b], dp[a] + cost[a][j]);
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1268
N = int(input())
L = [list(input().split()) for k in range(N)]
for k in range(N):
    L[k][1] = int(L[k][1])
    L[k].append(k+1)
L = sorted(L,key=lambda x:(x[0],-x[1]))
for l in L:
    print(l[2])

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

int main(void){
  int n, now = 1, cnt = 0, tmp;
  scanf("%d", &n);
  int a[n];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }

  while (true) {
    if (a[now] == -1) {
      printf("-1");
      return 0;
    }
    tmp = a[now];
    a[now] = -1;
    now = tmp;
    cnt++;
    if (now == 2) {
      printf("%d", cnt);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

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


Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5 3
1 2 2 4 5
'''

def solve(l,k):
	n = len(l)
	pre = [l[0]]
	for i in range(1,n):
		pre.append(pre[i-1] + l[i])
	maxx = 0
	index = -1
	for i in range(k-1,n):
		summ = 0
		if(i == k-1):
			summ = pre[i]
		else:
			summ = pre[i] - pre[i-k]
		if(maxx < summ):
			maxx = summ
			index = i
	startIndex = index - k + 1
	optimalSub = l[startIndex:index+1]
	# print(optimalSub)
	ans = 0
	for i in optimalSub:
		curr = i*(i+1)/2
		ans += curr/i
	return ans

N,K = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print("%.10f"%ans)


Measured memory_bytes: 26600
S = list(input())
black = 0
white = 0

# 先頭を黒(0)として色をぬるケース
for i, n in enumerate(S):
    if i % 2 == 0:
        if n == '1':
            black += 1
    else:
        if n == '0':
            black += 1

# 先頭を城(1)として色をぬるケース
for i, n in enumerate(S):
    if i % 2 == 0:
        if n == '0':
            white += 1
    else:
        if n == '1':
            white += 1

print(min(black, white))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

// 傾きが講義単調増加であることを仮定
using P = pair<ll,ll>;
struct CHTrick{
	deque<P> lines;
	bool isMonoticX = false;
	CHTrick(bool flag=true){
		isMonoticX = flag;
	}
	// check whether line l2 is useless
	// maybe overflow
	bool check(P l1, P l2, P l3){
		return (__int128)(l3.second-l2.second)*(l2.first-l1.first) >= (__int128)(l2.second-l1.second)*(l3.first-l2.first);
	}
	// add line(y=ax+b)
	void add(ll a, ll b){
		if(lines.size()>0 && lines.back().first==a){
			// for maximum val, replace min to max
			b = max(b, lines.back().second);
			lines.pop_back();
		}
		P line(a,b);
		while(lines.size()>=2 && check(*(lines.end()-2),lines.back(),line)){
			lines.pop_back();
		}
		lines.push_back(line);
	}
	// return the value of f_i(x)
	ll f(int i, ll x){
		return lines[i].first*x + lines[i].second;
	}
	ll f(P line, ll x){
		return line.first*x + line.second;
	}
	// minimum -> (lv>=rv), maximum ->(lv<=rv)
	bool comp(ll lv, ll rv){
		return lv <= rv;
	}
	// return the minimum(maximum) values among lines
	ll get(ll x){
		if(isMonoticX){
            if(lines.empty()) return -INF;
			while(lines.size()>=2 && comp(f(0,x),f(1,x))){
				lines.pop_front();
			}
			return f(0,x);
		}else{
			int low = -1, high = lines.size()-1;
			while(high-low>1){
				int mid=(high+low)/2;
				if(comp(f(mid,x),f(mid+1,x))) low = mid;
				else high = mid;
			}
			return f(high,x);
		}
	}
};

int main(){
    int n,T;
    scanf(" %d %d", &n, &T);

    vector<int> t(n),p(n),f(n);
    vector<pair<int,int>> v(n);
    rep(i,n){
        scanf(" %d %d %d", &t[i], &p[i], &f[i]);
        v[i] = {f[i], i};
    }
    sort(all(v));

    ll ans = 0;
    vector<CHTrick> cht(T+1);
    rep(i,n){
        int idx = v[i].se;

        vector<ll> dp(T+1, -INF);
        dp[t[idx]] = p[idx];
        rep(j,T+1){
            int nj = j+t[idx];
            if(nj<=T){
                ll vv = cht[j].get(f[idx]) + p[idx] - f[idx]*f[idx];
                dp[nj] = max(dp[nj], vv);
            }

            if(dp[j] > -INF) cht[j].add(2*f[idx], dp[j]-f[idx]*f[idx]);
            ans = max(ans, dp[j]);
        }
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 7716
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n; cin >> n;
    int x = 9 * 9;
    int z = 0;
    vector<int> kk(x);
    string ans;

    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            kk[z++] = i * j;
        }
    }
    
    auto res = find(kk.begin(), kk.end(), n);
    if (res != kk.end()) ans = "Yes";
    else ans = "No";

    cout << ans << endl;

    return 0;
}
    

Measured memory_bytes: 256