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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

clock_t time_p = clock();

void rtime() {
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float) 1000 * (time_p) / CLOCKS_PER_SEC << "\n";
}

#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF=1e15;
const int MOD=1e9+7;
const int N=2e5+10;

void solve() {
    int n;
    cin>>n;
    vector<int> v(n+1);
    map<int,int> v1,v2;
    for(int i=1;i<=n;i++) cin>>v[i];
    for(int i=1;i<=n;i++) {
        v1[i-v[i]]++;
    }
    for(int i=1;i<=n;i++) {
        v2[i+v[i]]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++) {
        ans+=v2[i-v[i]];
    }
    cout<<ans<<"\n";
}

signed main() {
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    IOS;
    int t = 1;
//    cin >> t;
    for(int i=1;i<=t;i++) {
//        cout<<"Case #"<<tc<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 39096
function main(final) {
  	let amount = 100;
  	let year = 0;
  	
  	while(amount < final) {
      amount = Math.floor(amount + (amount * 0.01));
      year++;
    }
  
  	console.log(year);
}
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

main(parseInt(input));


Measured memory_bytes: 29764
package main

import (
        "fmt"
)

func solution(n int, a []int) int {
        c := 0
        for i := range a {
                if a[a[i]-1] == i+1 {
                        c++
                }
        }
        return c / 2
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }
        fmt.Println(solution(n, a))
}

Measured memory_bytes: 6312
#include <stdio.h>

int main()
{
    long long int a, b, c, k, sum, mcard, res;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
    sum=a+b;
    if (sum>=k) {
        if (k<=a) printf("%lld\n", k);
        else printf("%lld\n", a);
    }
    else {
        mcard=k-sum;
        res=a-mcard;
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 900000000000000004
signed main(void){
    int n;cin>>n;
    int A[n];
    vector<P>V[n];
    rep(i,n){
        int a;cin>>a;A[i]=a;
        rep(j,a){
            int x,y;cin>>x>>y;
            V[i].push_back(make_pair(x-1,y));
        }
    }
    int ans=0;
    for(int tmp=0;tmp<(1<<(n+1));tmp++){
        bitset<20>s(tmp);
        bool judge=true;
        rep(i,n){
            if(s.test(i)){
                rep(j,A[i]){
                    int x=V[i][j].F,y=V[i][j].S;
                    judge&=(s.test(x)==y);
                }
            }
        }
        int count=0;
        rep(i,n){
            if(s.test(i))count++;
        }
        if(judge)ans=max(ans,count);
    }
    cout<<ans<<endl;
}
        


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;
ll expo(ll a,ll b,ll m = mod){
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%mod;
		b = (b*b)%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
//for(int i=0;i<n;i++)
int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
// 	cin>>t;
	while(t--)
	{
	    int l,r,d;
	    cin>>l>>r>>d;
	    cout<<r/d - (l-1)/d<<"\n";
	}
    return 0;
}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>
#include <random>
#include <cmath>
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define uid uniform_int_distribution<lli>
#define lli long long int
#define ff first
#define ss second
#define pb push_back
#define popf pop_front()
#define popb pop_back()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define forr(x,arr) for(auto& x:arr)
#define sz(x) (x.size())
#define mod 1000000007
#define INF 1000000000000000010
#define vi vector<int>
#define vlli vector<lli>
#define endl "\n"
#define ofk order_of_key
#define fbo find_by_order
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class my>
using indexed_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

template <class my>
inline my aabs (const my &a)   { return (a > 0)  ? a : -a;         }
inline lli gcd(lli a, lli b)   { return (b == 0) ? a : gcd(b,a%b); }
inline lli LSOne(lli k)        { return (k&(-k));                  }

inline int inv(lli o, int m = mod) {
  int b = m, u = 0, v = 1, t, a=o%m;
  while (a) {
    t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += m;
  return u;
}
inline int add(const int &a, const int &b, int m=mod) { return ( a + b ) % m;           }
inline int sub(const int &a, const int &b, int m=mod) { return ( a - b + m ) % m;       }
inline int mul(const int &a, const int &b, int m=mod) { return int ( 1LL * a * b % m ); }
inline int mpow(int a, int b, int m=mod) {
    int ans = 1;
    a=((a%m)+m)%m;
    while (b) {
        if (b & 1) ans = mul(ans, a, m);
        a = mul(a, a, m);
        b >>= 1;
    }
    return ans;
}

void tejas_919()
{
    lli n, k, m, q, u=0, v=0, temp=1, max1, max2, ans=0, a, b, val=0;
    cin>>n>>k;
    k*=2;
    k+=1;
    temp=(n+k-1)/k;
    cout<<temp<<endl;

}

int main()
{
    fastio cout<<endl;
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    while(t--)
        tejas_919();
}


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

int main(void){
	int w,h;
	int dx[] = {0,1,0,-1};
	int dy[] = {1,0,-1,0};

	while(cin>>w>>h && (w||h)){
		int x = 1, y = 1, d = 0;

		while(1){
			string s;
			cin>>s;
			if(s == "STOP") break;

			if(s == "FORWARD"){
				int t;
				cin>>t;
				x = x + t * dx[d];
				y = y + t * dy[d];
				if(x < 1) x = 1;
				if(x > w) x = w;
				if(y < 1) y = 1;
				if(y > h) y = h;
			}
			else if(s == "BACKWARD"){
				int t;
				cin>>t;
				x = x - t * dx[d];
				y = y - t * dy[d];
				if(x < 1) x = 1;
				if(x > w) x = w;
				if(y < 1) y = 1;
				if(y > h) y = h;
			}
			else if(s == "RIGHT"){
				d = (d+1) % 4;
			}
			else{
				d = (d+3) % 4;
			}
		}
		cout<<x<<" "<<y<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int search_b_cnt(const ll min, const ll max, const VL& b) {
    if(b.back() < min) return 0;
    if(b.front() >= max) return 0;
    // min探索
    int left_index = -1;
    int right_index = b.size();
    while(right_index - left_index > 1) {
        int mid = (right_index + left_index) / 2;
        if(b[mid] < min) left_index = mid;
        else right_index = mid;
    }
    int b_min_index = right_index;
    // max探索
    left_index = -1;
    right_index = b.size();
    while(right_index - left_index > 1) {
        int mid = (right_index + left_index) / 2;
        if(b[mid] < max) left_index = mid;
        else right_index = mid;
    }
    int b_max_index = left_index;
    return b_max_index - b_min_index + 1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VL a(n), b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    
    ll ans = 0;
    REP(k, 30) {
        ll cnt = 0;
        VL b_mod(n);
        REP(i, n) b_mod[i] = b[i] % (2 << k);
        sort(ALL(b_mod));
        REP(i, n) {
            ll mod_a = a[i] % (2 << k);
            cnt += search_b_cnt((1 << k) - mod_a, (2 << k) - mod_a, b_mod);
            cnt += search_b_cnt(3 * (1 << k) - mod_a, (4 << k) - mod_a, b_mod);
        }
        ans += (cnt % 2) << k;
    }
    cout << ans << endl;

    return 0;
}


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

vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        // その結果を push
        res.push_back({a, ex});
    }
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
/* vector<pair<ll,ll>>で受け取る！
例えば360=2^3*3^2*5は
{{2,3},{3,2},{5,1}}*/

int main() {
    ll n,p;
    cin >> n >> p;
    vector<pair<ll,ll>> s;
    s=prime_factorize(p);
    ll ans=1;
    for(int i = 0; i < s.size(); i++) {
        ll x=s[i].first,y=s[i].second;
        while(y>=n){
            ans *= x;
            y -= n;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int n, k; cin >> n >> k;
    int h[n];
    int c[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    k = min(k,n-1);

    for(int i=0;i<k+1;i++){
        c[i] = abs(h[i]-h[0]);
    }
    for(int i=k+1;i<n;i++){
        int MIN = 1e9;
        for(int j=1;j<=k;j++){
            MIN = min(MIN, c[i-j] + abs(h[i]-h[i-j]));
        }
        c[i] = MIN;
    }
    cout << c[n-1] << endl;
    return 0;
}

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

int main() {
    int H, W;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                cout << "#";
            }
            cout << "\n";
        }
        cout << "\n";
    }

    return 0;
}

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

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

    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;

    if(a%2==b%2 && b%2==c%2){
        int p=max(a,max(b,c));
        ans=(3*p-a-b-c)/2;
    }
    else if(b%2==c%2){
        int x=max(b,c);
        while(a<x){
            ans++;
            a+=2;
        }
        b=a-b;
        c=a-c;
        ans+=b/2+c/2+1;
    }
    else if(c%2==a%2){
        int x=max(a,c);
        while(b<x){
            ans++;
            b+=2;
        }
        a=b-a;
        c=b-c;
        ans+=a/2+c/2+1;
    }
    else{
        int x=max(a,b);
        while(c<x){
            ans++;
            c+=2;
        }
        a=c-a;
        b=c-b;
        ans+=a/2+b/2+1;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int dx[9]={0,0,0,1,1,1,2,2,2},dy[9]={0,1,2,0,1,2,0,1,2};
int main(){
  int fld[9][9];
  bool num[10],fldb[9][9];
  int n;
  cin>>n;
  for(int times=0;times<n;times++){
    if(times!=0)cout<<endl;
    memset(fldb,true,sizeof(fldb));
    REP(i,9)REP(j,9)cin>>fld[j][i];
    REP(i,9)REP(j,9)REP(k,9)if(fld[i][j]==fld[i][k]&&j!=k)fldb[i][j]=false;
    REP(i,9)REP(j,9)REP(k,9)if(fld[j][i]==fld[k][i]&&j!=k)fldb[j][i]=false;
    REP(i,3)REP(j,3){
      REP(k,9)REP(l,9){
        int nx=i*3,ny=j*3;
        if(fld[nx+dx[k]][ny+dy[k]]==fld[nx+dx[l]][ny+dy[l]]&&k!=l){
          fldb[nx+dx[k]][ny+dy[k]]=false;
        }
      }
    }
    REP(i,9){
      REP(j,9){
        if(fldb[j][i])cout<<" "<<fld[j][i];
        else cout<<"*"<<fld[j][i];
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        
        Scanner scan = new Scanner(System.in);
        int x,y;
        
        while(true){
            
            y = scan.nextInt();
            x = scan.nextInt();
            
            if(x == 0 || y == 0){
                break;
            }
            for(int j = 0;j < y;j++){
                for(int i = 0;i < x;i++){
                    if(i == 0 || i == x-1){
                        System.out.print("#");
                    }else if(j == 0 || j == y-1){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 34344
N = int(input())
T = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]

maxv = [0]
for t, v in zip(T, V):
    maxv[-1] = min(maxv[-1], v)
    for i in range(t * 2):
        maxv.append(v)
maxv[-1] = 0

for i in range(len(maxv) - 1):
    maxv[i + 1] = min(maxv[i + 1], maxv[i] + 0.5) 
    
for i in reversed(range(len(maxv) - 1)):
    maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
    
ans = 0
for i in range(len(maxv) - 1):
    ans += (maxv[i] + maxv[i + 1]) * 0.5 / 2
    
print(ans)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5+1;
const int inf=1e9;
int main(){
	int N,M;cin>>N>>M;
	if(N % 2 == 0){
		rep(i,1,M+1){
			if(N + 1 - 2 * i > N / 2) cout<<i<<" "<<N + 1 - i<<endl;
			else cout<<i<<" "<<N - i<<endl;
		}
	}else rep(i,1,M+1) cout<<i<<" "<<N + 1 - i<<endl;
}

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

int main()
{
	int n;
	cin >> n;
	unsigned long long sum = 0;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		sum += static_cast<unsigned long long >(a);
	}
	cout << sum/static_cast<unsigned long long>(n) << endl;
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int  main() {

	int n;
	cin >> n;

	int c[510] = { 0 }, s[510] = { 0 }, f[510] = { 0 };

	rep(i, n - 1)cin >> c[i] >> s[i] >> f[i];

	rep(i,n) {

		int ans = 0;
		ans += c[i] + s[i];

		for (int j = i + 1; j < n -1; j++) {
			if (ans <= s[j])ans = s[j];
			else if (ans % f[j] == 0);
			else ans += f[j] - ans % f[j];
			
			ans += c[j];
		}

		pr(ans);
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

using namespace std;

int main(){
   
    int n;
    int* a;
    
    cin >> n;
    
    a = new int [n];
    int ans=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        ans+=a[i];
    }
    int y;
    y=ans/n+1;
    ans/=n;
    int x=0;
    for(int i=0;i<n;i++){
        x+=(a[i]-ans)*(a[i]-ans);
    }
    int z=0;
    for(int i=0;i<n;i++){
        z+=(a[i]-y)*(a[i]-y);
    }
    
    if(x>z) cout << z;
    else cout << x;
   
    delete a;
    
    
    return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
string s;
void solve() {
    cin >> s;
    n = sz(s);

    ll ans = 0;
    rep(j, n + 1) {
        ll res = 0;
        if (j != n && s[j] == '0') continue;
        rep(i, j) res += s[i] - '0';
        if (j != n) res += s[j] - '0' - 1;
        res += 9LL * max(0, n - j - 1);
        maxs(ans, res);
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

using namespace std;

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

int main()
{
	int x;
	cin >> x;
	bool flag = false;

	for (int i = 1; i <= 100000; i++)
	{
		if (100 * i <= x && x <= 105 * i)
		{
			flag = true;
			break;
		}
	}

	if (flag)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N, K;
    cin >> N >> K;
    Vec<u32> A(N);
    Vec<f64> S(N + 1, 0.0);
    for (u32 i = 0; i < N; i++) cin >> A[i];
    for (u32 i = 1; i <= N; i++) {
        f64 x = A[i - 1];
        S[i] = S[i - 1] + x * (x + 1) / 2.0 / x;
    }
    f64 max = 0.0;
    for (u32 i = K - 1; i < N; i++) {
        f64 sum = S[i + 1] - S[i - (K - 1)];
        if (max < sum) max = sum;
    }
    cout << max << endl;

}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    cout << a*a*3 << endl;

    return 0;
}


Measured memory_bytes: 256
data_num = int(input())
data = [int(n) for n in input().split(' ')]

for i in range(0, data_num):
    v = data[i]
    j = i - 1
    while j >= 0 and data[j] > v:
        data[j + 1] = data[j]
        j -= 1
    data[j + 1] = v
    print(' '.join([str(n) for n in data]))

Measured memory_bytes: 7724
#include <stdio.h>

void merge_sort(long long x[], int n)
{
	static long long y[51] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

long long combination(int n, int k)
{
	if (k > n / 2) k = n - k;
	if (k == 0) return 1;
	
	int i, j, flag[51] = {};
	long long x;
	for (i = n, x = 1; i >= n - k + 1; i--) {
		x *= i;
		for (j = 2; j <= k; j++) {
			if (flag[j] == 0 && x % j == 0) {
				x /= j;
				flag[j] = 1;
			}
		}
	}
	return x;
}

int main()
{
	int i, N, A, B;
	long long v[51];
	scanf("%d %d %d", &N, &A, &B);
	for (i = 0; i < N; i++) scanf("%lld", &(v[i]));
	merge_sort(v, N);
	
	int j, k;
	long long sum = 0;
	for (i = N - 1; i >= N - A; i--) sum += v[i];
	printf("%.10Lf\n", (long double)sum / A);
	for (i = N - A + 1; i <= N - 1 && v[i] == v[i-1]; i++);
	for (j = N - A - 1; j >= 0 && v[j] == v[j+1]; j--);
	sum = combination(i - j - 1, i - N + A);
	if (v[N-A] == v[N-1]) {
		for (k = (i - j - 1 < i - N + B)? i - j - 1: i - N + B; k > i - N + A; k--) sum += combination(i - j - 1, k);
	}
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1752
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

A = [i+1 for i in range(N)]
all_permutation_list = list(itertools.permutations(A))
a = all_permutation_list.index(P)
b = all_permutation_list.index(Q)
print(abs(a - b))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int main(){
	
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	
	cout<<(char)(s1[0]+'A'-'a')<<(char)(s2[0]+'A'-'a')<<(char)(s3[0]+'A'-'a')<<endl;
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int rlist[2019];
int Pow(int a, int n, int mod) {
    if (n == 0) return 1;
    if (n % 2) return (a * Pow(a, n - 1, mod)) % mod;
    else {
        int k = Pow(a, n / 2, mod);
        return (k * k) % mod;
    }
}
int main() {
    string s;
    cin >> s;
    int len = s.size();
    for (int i = 0; i < 2019; i++) rlist[i] = 0;
    int now = 0;
    rlist[0]++;
    for (int i = len - 1; i >= 0; i--) {
        int keta = s[i] - 48;
        now = (now + keta * Pow(10, len - 1 - i, 2019)) % 2019;
        rlist[now]++;
    }
    ll ret = 0;
    for (int i = 0; i < 2019; i++) {
        if (rlist[i] >= 2) {
            ret += rlist[i] * (rlist[i] - 1) / 2;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<cstring>

using namespace std;

string in;

int main(){
  int num;
  cin >> num;
  getline(cin,in);
  while(num--){
    getline(cin,in);
    vector<int> V;
    V.push_back(-7);
    
    while(1){
      int n = in.find("Hoshino",V.back()+7);
      if(n != -1) V.push_back(n);
      else break;
    }

    for(int i = 1; i < V.size(); i++)
      in.replace(V[i],7,"Hoshina");
    
    cout << in << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

const int INF = 1e9;

int main(int argc, const char * argv[]) {
  ll N, M;
  cin >> N >> M;

  ll cnt = min(N, M /2);
  M -= cnt * 2;
  cnt += M / 4;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
# define M_PI           3.14159265358979323846
using namespace std;

int main()
{
    int R,D;
    float C;
    scanf("%d", &R);
    D=2*R;
    C=M_PI*D;
    printf("%.2f", C);
    return 0;

}


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

bool solve();

int main()
{
	if (solve()) puts("Yes");
	else puts("No");
	
	return 0;
}

bool solve()
{
	int N, M;
	scanf("%d%d", &N, &M);

	std::string s;
	std::cin >> s;

	std::vector<std::set<int>> edge(N);
	for (int i{}; i < M; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		edge[a].insert(b);
		edge[b].insert(a);
	}
	std::vector<int[2]> conseq_ab(N);
	for (int i{}; i < N; i++)
		for (auto& e: edge[i])
			conseq_ab[i][s[e] == 'B']++;


	std::queue<int> unavailable;
	for (int i{}; i < N; i++)
		if (conseq_ab[i][0] == 0 || conseq_ab[i][1] == 0)
			unavailable.push(i);
	while (!unavailable.empty())
	{
		int deleted{unavailable.front()};
		unavailable.pop();
		while (!edge[deleted].empty())
		{
			int conseq{*edge[deleted].begin()};
			edge[deleted].erase(edge[deleted].begin());
			conseq_ab[deleted][s[conseq] == 'B']--;
			if (deleted != conseq)
			{
				edge[conseq].erase(deleted);
				conseq_ab[conseq][s[deleted] == 'B']--;
			}
			if (conseq_ab[conseq][0] == 0 || conseq_ab[conseq][1] == 0)
				unavailable.push(conseq);
		}
	}

	for (auto& e: conseq_ab)
		if (e[0] || e[1])
			return true;
	return false;
}

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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	string s;
	cin >> s;
	int q, rev = 0;
	deque <char> d;
	for (int i = 0; i < s.size(); i++) {
		d.pb(s[i]);
	}
	cin >> q;
	while (q--) {
		int tp;
		cin >> tp;
		if (tp == 1) {
			rev ^= 1;
		}	else {
			int f;
			char c;
			cin >> f >> c;
			f--;
			if (f ^ rev) {
				d.pb(c);
			}	else {
				d.push_front(c);
			}
		}
	}
	if (rev) {
		while (!d.empty()) {
			cout << d.back();
			d.ppb();
		}
	}	else {
		while (!d.empty()) {
			cout << d.front();
			d.pop_front();
		}
	}
}


Measured memory_bytes: 976
n = int(input())
w = list(map(int, input().split()))

w_sort = sorted(w)
# print(w_sort)

min_abs = 9999999999
for i in range(1, n):
    w1 = w[0:i]
    w2 = w[i:]
    
    # print(w1)
    # print(w2)
    
    abs_w1w2 = abs(sum(w1) - sum(w2))
    if abs_w1w2 < min_abs:
        min_abs = abs_w1w2
        
print(min_abs)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#define N 2000002
using namespace std;
int n,m,a[N],b[N],c[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]==1)c[b[i]]=1;
		if(b[i]==1)c[a[i]]=1;
	}
	c[1]=1;
	for(int i=1;i<=m;++i){
		if(a[i]==n){
			if(c[b[i]]){
				printf("POSSIBLE");
				return 0;
		    }
		}
		if(b[i]==n){
			if(c[a[i]]){
				printf("POSSIBLE");
				return 0;
		    }
		}
	}
	printf("IMPOSSIBLE");
}

Measured memory_bytes: 9216
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  sb  = 0
  lab = [0] * n
  for i in range(n):
    a, b = map(int, input().split())
    sb += b
    lab[i] = a+b
  lab.sort(reverse=True)
  print(sum(lab[::2]) - sb)

if __name__=='__main__':
  main()



Measured memory_bytes: 7472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }

  int cou = 0;

  FOR(i,0,N-1){
    if(a[i]!=i+1) ++cou;
  }

  if(cou==0 || cou == 2) cout << "YES" << endl;
  else cout << "NO" << endl;

}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

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

num = 0
s = sum(al)/(4*m)
ans = 'No'

for a in al:
    if s <= a:
        num += 1

if num >= m:
    ans = 'Yes'

print(ans)

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

int main()
{
    int N;
    double sum = 0;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> u[i];
    }
    for (int i = 0; i < N; i++)
    {
        if (u[i] == "BTC")
        {
            sum += x[i] * 380000.0;
        }
        else
        {
            sum += x[i];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    string O;
    string E;
    cin >> O >> E;
    while(!(O.empty()&&E.empty())){
        if(!O.empty()){
            cout << O[0];
            O.erase(O.begin());
        }
        if(!E.empty()){
            cout << E[0];
            E.erase(E.begin());
        }
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#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 if (C == A) {
    cout << B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int i, j, n, k;
	while(1) {
		scanf("%d", &n);
		if(n == -1) break;
		if(n == 0) printf("0");
		for(j = 0; j < 32 && (n & (1 << 31) >> (31 - j)) != 0; ++ j);
		if(j % 2 == 0) j --;
		for(i = j; i > -1; i -= 2) {
			printf("%d", ((((n & (1 << i)) != 0) << 1) | ((n & (1 << (i - 1))) != 0)));
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll n, t;
    cin >> n >> t;
    VL a, b, b0;
    REP(i,n){
        ll x = in(), y = in();
        if (x == 0) b0.push_back(y);
        else {
            a.push_back(x);
            b.push_back(y);
        }
    }
    n = a.size();
    vector<PL> p(n);
    REP(i,n) p[i] = PL(a[i], b[i]);
    sort(ALL(p), [&](PL p1, PL p2)
    {
        return p1.first * (p2.second + 1) > p2.first * (p1.second + 1);
    });
    REP(i,n){
        a[i] = p[i].first;
        b[i] = p[i].second;
    }
    sort(ALL(b0));
    int m = 32;
    VL dp(m, t + 1);
    dp[0] = 0;
    REP(i,n) FORR(j,m-1,0){
        chmin(dp[j + 1], (a[i] + 1) * (dp[j] + 1) + b[i]);
    }
    int ans = 0;
    REP(i,m){
        if (dp[i] > t) continue;
        chmax(ans, i);
        ll s = dp[i];
        REP(j,b0.size()){
            ll x = b0[j];
            s += x + 1;
            if (s > t) break;
            chmax(ans, i + j + 1);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6756
import re

caesar_trans = str.maketrans("abcdefghijklmnopqrstuvwxyz", "zabcdefghijklmnopqrstuvwxy")

while True:
    try:
        i = input()
        while True:
            if re.search("(^| )(the|this|that)(\.| |$)", i) is not None:
                print(i)
                break
            i = i.translate(caesar_trans)
    except EOFError:
        break



Measured memory_bytes: 6500
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
		
#階乗#
lim = 10**6   #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod

X, Y = MAP()

a = (2*X - Y)/3
b = (2*Y - X)/3

if a%1 == b%1 == 0 and 0 <= a and 0 <= b:
	print(C(int(a+b), int(a)))
else:
	print(0)


Measured memory_bytes: 89516
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;

int solve(int cur, vector<vector<int> > &input) {
	int cnt = input[cur].size();
	
	if(cnt==0) return 0;
	
	vector<int> res;
	for(int i=0; i<input[cur].size(); i++) {
		int next = input[cur][i];
		res.push_back(solve(next, input));
	}
	sort(res.begin(), res.end());
	reverse(res.begin(), res.end());
	int ans = 1;
	
	for(int i=0; i<res.size(); i++) {
		ans = max(i+1+res[i], ans);
	}
	return ans;
}


int main() {
	int N;
	cin >> N;
	vector<vector<int> > input(N, vector<int> (0,0));
//	input.push_back(0);
	for(int i=1; i<N; i++ ) {
		int p;
		cin >> p;
		p--;
		input[p].push_back(i);
		
	}
	int ans = solve(0, input);
	cout << ans << endl;	
 	return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main(){
	int n; cin >> n;
	vector<vl> d(n, vl(3));
	mint ans = 1;
	rep(i,n){
		int x; cin >> x;
		int cnt = 0;
		rep(j,3){
			if (x == d[i][j]) cnt ++;
		}
		ans *= cnt;
		if(i<n-1){
			bool ok = true;
			rep(j,3){
				
				d[i+1][j] = d[i][j];
				if (x == d[i][j] && ok){
					d[i+1][j] ++;
					ok = false;
				}
			}
		}
		
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
	string A,B,C;
	cin >> A >> B >>C;
	if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
		cout << "YES" << endl;
	}else{
		cout << "NO"<< endl;
	}
}

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

using namespace std;

int main()
{
    int n, m, c, ans = 0;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<int> a(m);

    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        int total = 0;
        for (int j = 0; j < m; ++j) {
            cin >> a[j];
        }
        for (int j = 0; j < m; ++j) {
            total += a[j] * b[j];
        }
        total += c;
        if (total > 0) ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int k = sc.nextInt();
			int x = sc.nextInt();
			sc.close();
			for(int  i = x-k+1;i<x+k;i++) {
				System.out.print(i+" ");
			}
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
typedef long long ll;

int num[101];
ll dp[101][22] = {};
int N;

int main(){	
	cin >> N;
	for (int i = 0; i < N; i++) cin >> num[i];

	dp[0][num[0]] = 1;

	for (int i = 1; i < N - 1; i++){
		for (int n = 0; n < 21; n++){
			if (n + num[i] < 21) dp[i][n + num[i]] += dp[i-1][n];
			if (n - num[i] > -1) dp[i][n - num[i]] += dp[i-1][n];
		}
	}
	
	cout << dp[N - 2][num[N - 1]] << endl;
	return 0;
}

Measured memory_bytes: 1176
x,y = map(int,input().split())
l = [1,3,5,7,8,10,12]
a = [4,6,9,11]
b = [2]
if (x in l) and (y in l):
    print("Yes")
elif (x in a) and (y in a):
    print("Yes")
elif x == 2 and y == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;



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


//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}



int main() {

	long long ans;
	int a;
	string s, t;

	cin >> s >> t;

	int n;

	n = s.length();

	ans = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	cin >> ans;

	return 0;


}

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

int main(){
double a,b,x;
cin>>a>>b>>x;

if(x<a*a*b/2){
double ans= atan(a*b*b/x/2);
ans=ans*180/M_PI;
cout<<setprecision(8)<<ans<<endl;
}
else{
  double ans= atan((a*a*b-x)*2/(a*a*a));
  ans=ans*180/M_PI;
  cout<<setprecision(8)<<ans<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll INF = 1 << 29;
const ll MOD = 1e9 + 7;

int main()
{
    char X, Y;
    std::cin >> X >> Y;
    if (X < Y)
       std::cout << "<" << std::endl;
    else if (X > Y)
        std::cout << ">" << std::endl;
    else
        std::cout << "=" << std::endl;
}

Measured memory_bytes: 3664
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(long long N, std::vector<long long> P){
    // 自分より左にある数字を保存してく 
    int min_n = P[0];
    int res = 1;
    FOR(i, 1, N-1){
        if(min_n > P[i])  {
            min_n = P[i];
            res++;
        } 
    }

    cout << res << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 1e9
using namespace std;
typedef long long ll;

signed main() {
  // std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
  int n;
  cin >> n;

  int ans = 0;
  for(int i = 1; i <= n; i++){
    int digit = to_string(i).size();
    if (digit % 2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort()
while M != 0:
    x = bisect.bisect_left(A,A[-1]/2)
    if N-x <= M:
        M -= N-x
        for i in range(x,N):
            A[i] = A[i]/2
        A.sort()
    else:
        for i in range(N-M,N):
            A[i] = A[i]/2
        M = 0
        A.sort()

print(sum(map(int,A)))


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

int main(void) {
    long n;
    cin >> n;
    vector<long> a(n), b(n), c(n-1);
    for(auto &e: a) cin >> e, e--;
    for(auto &e: b) cin >> e;
    for(auto &e: c) cin >> e;

    long r = 0;
    for(long i=0; i<n; i++)
        r += b[a[i]], r += (i+1 < n && a[i+1] == a[i]+1 ? c[a[i]] : 0);
    cout << r << endl;
}


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

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

using ll = long long;
#define INF 1e9

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> a(H+2);
  REP(i, H){
    cin >> a[i+1];
  }
  a[0] = a[H+1] = string(W+2, '#');
  REP(i, H){
    a[i+1].push_back('#');
    a[i+1].insert(a[i+1].begin(), '#');
  }

  REP(i, H+2){
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
a = []

for i in range(N):
  a.append(list(map(int,input().split())))

a = sorted(a)

i = 0
num = 0
ans = 0
while i <= N - 1:
  ans += a[i][0] * a[i][1]
  num += a[i][1]
  if num > M:
    ans -= a[i][0] * (num - M)
    break
  i += 1
print(ans)  


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N + 1);
  vector<int> indices(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> P[i];
    indices[P[i]] = i;
  }
  set<int> s;
  s.insert(0);
  s.insert(N + 1);
  long long ans = 0;
  for (int p = N; p >= 1; p--) {
    int i = indices[p];
    auto lb = s.lower_bound(i);
    long long r1 = *lb;
    lb++;
    long long r2;
    if (lb == s.end()) {
      r2 = r1;
    } else {
      r2 = *lb;
    }
    lb--;
    lb--;
    long long l1 = *lb;
    long long l2;
    if (lb == s.begin()) {
      l2 = l1;
    } else {
      lb--;
      l2 = *lb;
    }
    ans += ((r2 - r1) * (i - l1) + (l1 - l2) * (r1 - i)) * p;
    s.insert(i);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,d;
    cin >> n >> d;
    ll ans=0;
    vector<pair<ll,ll>>a(n);
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        a[i] = make_pair(x,y);
        if(x*x+y*y <= d*d)ans++;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 6364
import itertools

N = int(input())
n = int(N ** (1/2))
C = itertools.combinations_with_replacement(range(1, n + 1), 3)
ans = [0 for i in range(N)] 

x, y, z = 1, 1, 1

def check(c):
  x, y, z = c
  global N
  t = x * x + y * y + z * z + x * y + y * z + z * x
  if t > N:
    return
  if x == y and y == z:
    ans[t - 1] += 1
  elif x == y and y != z or y == z and z != x or z == x and x != y:
    ans[t - 1] += 3
  else:
    ans[t - 1] += 6

for c in list(C):
  check(c)
for a in ans:
  print(a)


Measured memory_bytes: 21680