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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

ll digit(ll x){
    ll ret = 0;
    while(x){
        ret++; x /= 10;
    }
    return ret;
}

long double S(ll x){
    long double ret = 0;
    while(x){
        ret += x%10; x /= 10;
    }
    return ret;
}

void Main(){
    ll K; cin >> K;
    ll x = 1;
    VL p(19,1); REP(i,18) p[i+1] = p[i]*10;
    REP(_,K){
        cout << x << en;
        x++;
        ll d = digit(x);
        long double mn = 1e17;
        REP(i,d){
            long double n = (x/p[i]+1)*p[i]-1;
            if(chmin(mn, n/S(n))) x = (ll)round(n);
        }
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll d = 0;
  cin >> d;
  vector<ll> c(26);
  //ll min = 0;
  //min = pow(10,18);
  //ll mini = 0;
  for(int i = 0;i < 26;i++){
    cin >> c[i];
    //if(min > c[i])min = c[i],mini = i;
  }
  vector<vector<ll>> s(d,vector<ll>(26));
  /*vector<ll> last(26);
  for(int i = 0;i < 26;i++)last[i] = -1;
  for(int i = 0;i < d;i++){
    ll now = 0;
    ll nowi = 0;
    for(int j = 0;j < 26;j++){
      cin >> s[i][j];
      s[i][j] += c[j] * (i - last[j]) * (d - i);
      if(now < s[i][j]){
        now = s[i][j];
        nowi = j;
      }
    }
    last[nowi] = i;
    cout << nowi + 1 << endl;
  }*/
  ll score = 0;
  for(int i = 0;i < d;i++)for(int j = 0;j < 26;j++)cin >> s[i][j];
  vector<ll> res(365);
  
  for(int i = 0;i < 26;i++){
    for(int j = 0;j < 26;j++){
      for(int k = 0;k < 26;k++){
        
        vector<ll> last(26);
        for(int l = 0;l < 26;l++)last[l] = -1;
        vector<ll> now(365);
        last[i] = 0,now[0] = i;
        last[j] = 1,now[1] = j;
        last[k] = 2,now[2] = k;
        for(int l = 3;l < d;l++){
          ll max = 0;
          ll maxi = 0;
          for(int m = 0;m < 26;m++){
            s[l][m] += c[m] * (l - last[m]) * (d - l);
            if(max < s[l][m]){
              max = s[l][m];
              maxi = m;
            }
          }
          last[maxi] = l;
          now[l] = maxi;
        }
        
        vector<ll> lastm(26);
  		for(int l = 0;l < 26;l++)lastm[l] = -1;
  		ll nowres = 0;
  		for(int l = 0;l < d;l++){
    		/*ll nowin = 0;
    		cin >> nowin;
    		nowin--;*/
    		lastm[now[l]] = l;
    		nowres += s[l][now[l]];
    		for(int m = 0;m < 26;m++){
      			nowres -= c[m] * (l - lastm[m]);
    		}
    		//cout << res << endl;
 		 }
        
        if(nowres > score){
          for(int l = 0;l < 365;l++)res[l] = now[l];
          //cout << score << endl;
        }

      }
    }
  }
  for(auto i:res)cout << i + 1 << endl;
  //for(int i = 0;i < 365;i++)cout << mini + 1 << endl;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    int ans=0;

    if(N>=10) ans+=9;else ans+=N;
    if(N>=1000) ans+=900;
    else if (N>=100) ans+= N-99;
    if(N>=100000) ans+=90000;
    else if (N>=10000) ans+=N-9999;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int p[200005];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	int max = 0, now = 0, num = 0;
	for (int i = 0; i < n; i++) {
		if (num < k) {
			now += p[i];
			max += p[i];
			num++;
		}
		else {
			now = now + p[i] - p[i - k];
			max = (max > now) ? max : now;
		}
	}
	double ans = (double)(max + k) / 2;
	printf("%lf", ans);
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
     Scanner angi=new Scanner(System.in);
     int a[]=new int[10];
    for(int cont=0;cont<10;cont++){
        a[cont]=angi.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[9]);
    System.out.println(a[8]);
    System.out.println(a[7]);
    }
    
}

Measured memory_bytes: 17328
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3==0 && i%5==0)
            continue;
        else if(i%3==0)
            continue;
        else if(i%5==0)
            continue;
        else
            sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3612
#include<stdio.h>

void same_check(int *map, int *x, int *y){
    if(map[*x]==map[*y])printf("1\n");
    else printf("0\n");
}

void unite(int *n, int *map, int *x, int *y){
    int i;
    int target = map[*y];
    for(i=0;i<*n;i++)if(map[i]==target)map[i]=map[*x];
}

int main(){
    int i, j;
    int n, q, com, x, y;

    scanf("%d%d", &n, &q);
    int map[n];
    for(i=0;i<n;i++)map[i]=i;

    for(i=0;i<q;i++){
        scanf("%d%d%d", &com, &x, &y);
        if(com){
            same_check(map, &x, &y);
        }else{
            unite(&n, map, &x, &y);
        }
    }

    return 0;
}


Measured memory_bytes: 2140
x = int(input())

if x <= 6:
  ans = 1
else:
  if x % 11 == 0:
    ans = x // 11 * 2
  elif x % 11 <= 6:
    ans = x // 11 * 2 + 1
  else:
    ans = x // 11 * 2 + 2

print(ans)

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

using namespace std;

int main(int argc, char *argv[]) {
    int n;
    cin >> n;
    int o = n % 10;
    if (o == 2 || o == 4 || o == 5 || o == 7 || o == 9) {
        cout << "hon" << endl;
    } else if (o == 0 || o == 1 || o == 6 || o == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


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

  int L=S.size(),ans=0;

  for(int i=L-2;i>0;i-=2){
    if(S.substr(0,i/2)==S.substr(i/2,i/2)){
      ans=i; break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b) swap(a,c);
	else if(a==c) swap(a,b);
	printf("%d",a);
	return 0;
} 

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

using namespace std;

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

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

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

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

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

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

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> v(h, vector<char>(w, ' '));
    rep(y, h) rep(x, w) cin >> v[y][x];

    auto mix_row = [&](int y) {
        set<char> st;
        rep(x, w) st.insert(v[y][x]);
        return st.find('#') != st.end();
    };

    vector<vector<char>> v2;
    rep(y, h) {
        if (!mix_row(y)) continue;
        v2.push_back(v[y]);
    }

    auto mix_col = [&](int x) {
        set<char> st;
        rep(y, h) st.insert(v[y][x]);
        return st.find('#') != st.end();

    };

    vector<vector<char>> v3(v2.size());
    rep(x, w) {
        if (!mix_col(x)) continue;
        rep(y, v2.size()) {
            v3[y].push_back(v2[y][x]);
        }
    }

    rep(y, v3.size()) {
        rep(x, v3[y].size()) cout << v3[y][x];
        cout << endl;
    }

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>

int main()
{
  using namespace std;

  int cnt[26];
  int sum;

  for (int i = 0; i < 26; i++) {
    cnt[i] = 0;
  }

  for (int i = 0; i < 4; i++) {
    char c;
    cin >> c;
    cnt[c - 'A']++;
  }

  sum = 0;
  for (int i = 0; i < 26; i++) {
    if (cnt[i] != 0 && cnt[i] != 2) {
      cout << "No" << endl;
      return 0;
    }
    sum += cnt[i];
  }

  if (sum == 4) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);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);
    int r,g;
    cin >> r >> g;
    cout << g*2 - r << "\n";

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;
typedef tuple<int, int, int> T;

int n;
vector<T> ts;

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		int a[3];
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		ts.push_back(T(a[0], a[1], a[2]));
	}
	sort(ts.begin(), ts.end());
	ts.erase(unique(ts.begin(), ts.end()), ts.end());
	
	cout << n - ts.size() << endl;
	return 0;
}


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

busterd = 0

for i in range(N):
    if A[i] > B[i]:
        busterd += B[i]
    else:
        busterd += A[i]
        addition = B[i] - A[i]

        if addition > A[i+1]:
            addition = A[i+1]

        # print(addition)

        busterd += addition
        A[i+1] -= addition


# for i in range(N):
#     vital = B[i]
#     first_monsters = A[i]
#     second_monsters = A[i+1]
#
#     dead = False
#
#     for d in range(first_monsters):
#         if first_monsters == 0:
#             break
#
#         first_monsters -= 1
#         vital -=1
#         busterd += 1
#
#         if vital == 0:
#             dead = True
#             break
#         if first_monsters == 0:
#             break
#
#     if dead:
#         break
#     else:
#         for z in range(second_monsters):
#             second_monsters -= 1
#             vital -= 1
#             busterd += 1
#
#             if vital == 0:
#                 A[i+1] = second_monsters
#                 dead = True
#                 break
#             if second_monsters == 0:
#                 A[i+1] = 0
#                 break


print(busterd)





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

ll binpow(ll a, ll b){
    ll res = 1;
    while(b){
        if(b&1){
            res = res*a;
            b--;
        }
        else{
            a *= a;
            b /= 2;
        }
    }
    return res;
}

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

    //good luck kittu!
    ll a, b, x; cin>>x;
    for(a = -200; a<=200; a++){
        for(b = -200; b<=200; b++){
            if(binpow(a, 5)-binpow(b, 5)==x){
                return cout<<a<<" "<<b<<"\n", 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3656
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

string s;
inline void solve(){
  IN(s);
  s[5]=' ';
  s[13]=' ';
  OUT(s);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
if __FILE__ == $0
  tyohoukei = 0
  hishigata = 0
  while line = gets
    a, b, c = line.split(',').map{|i| i.to_i}
    if Math.sqrt(a**2 + b**2) == c
      tyohoukei += 1
    elsif a == b
      hishigata  += 1
    end
  end
  puts tyohoukei
  puts hishigata
end

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int a,b,h=0;
    cin>>a>>b;
    for(;;)
    {
        h++;
        a=a*2;
        if(a>b)  break;
    }
    cout<<h<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
const ll INF = 1ll << 62;

int main() {
    int N;
    cin >> N;
    vector<int> nums(N);
    for (int& n : nums)
        cin >> n;

    int marg = 1 + N % 2;

    vector<array<ll, 3>> dp(N);
    for (auto& a : dp)
        a.fill((-INF));
    for (int i = 0; i <= marg; i++)
        dp[i][marg - i] = nums[i];
    for (int i = 2; i < N; i++) {
        for (int j = 0; j <= marg; j++) {
            for (int k = 0; j + k <= marg; k++) {
                if (i - 2 - k >= 0)
                    dp[i][j] = max(dp[i][j], dp[i - 2 - k][j + k] + nums[i]);
            }
        }
    }
    ll ans = -INF;
    for (int i = N - 1 - marg; i < N; i++) {
        ans = max(ans, dp[i][N - 1 - i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8800
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int X,A,B;
  cin>>X>>A>>B;
  if(A>=B)cout<<"delicious"<<endl;
  else if(B-A<=X)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
using namespace std;
//mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int a[1005];
int main() {
    int n,k;
    cin>>n>>k;
    ii cin>>a[i];
    sort(al(a));
    int ans=0;
    for(int i=1;i<=k;++i) ans+=a[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1000007;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;

int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (cin >> n)
	{
		if (n >= 30)puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 3616
n = int(input())
coin_list = [ float(v) for v in input().split() ]
probability_list = [1]

for i in coin_list:
    l = len(probability_list)
    new_probability_list = [0] * (l+2)
    for j in range(l):
        new_probability_list[j] += probability_list[j] * (1-i)
        new_probability_list[j+2] += probability_list[j] * i
    probability_list = new_probability_list

print(sum(probability_list[l//2+2:]))

Measured memory_bytes: 53980
import java.text.DecimalFormat;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			String a = sc.next();
			int l = sc.nextInt();
			if( a.equals("0") && l == 0 ) break;
			String dec = "";
			for(int i=0;i<l;i++) dec += "0";
			DecimalFormat df = new DecimalFormat(dec);
			int[] ans = new int[21];
			ans[0] = Integer.parseInt(a);
			for(int i=1;i<21;i++) {
				a = df.format(Integer.parseInt(a));
				char[] ca = a.toCharArray();
				sort(ca);
				int min = Integer.parseInt( String.valueOf(ca) );
				rev(ca);
				int max = Integer.parseInt( String.valueOf(ca) );
				ans[i] = max - min;
				a = String.valueOf(max - min);
			}
			int sel1 = -1, sel2 = -1, val = -1;;
			for(int i=1;i<21;i++) for(int j=0;j<i;j++) {
				if( ans[i] == ans[j] && sel1 == -1 ) {
					sel1  = j; 
					sel2 = i-j;
					val = ans[i];
				}
			}
			
			System.out.println(sel1 + " " + val + " " + sel2);
		}
	}
	
	void rev(char[] c) {
		int n = c.length;
		for(int i=0;i<n/2;i++) {
			char tmp = c[i];
			c[i] = c[n-i-1];
			c[n-i-1] = tmp;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll a,b,c,k,sum=0;
  cin>>a>>b>>c>>k;
  if(k<=a)
  sum+=k;
  else 
  {
      sum+=a;
      k-=a;
      if(k<=b)
      sum+=k*0;
      else
      {
          k=k-b;
          sum-=k;
      }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using ll = long long;
ll n, m, w;
std::string s, t;
std::map<ll, char> ma;

ll lcm(ll a, ll b) {
    ll g = std::__gcd(a, b);
    return a / g * b;
}

int main() {
    std::cin >> n >> m;
    std::cin >> s >> t;
    w = lcm(n, m);
    for (int i = 0; i < n; i++) {
        ll p = i * (w / n) + 1;
        ma[p] = s[i];
    }
    
    for (int j = 0; j < m; j++) {
        ll e = j * (w / m) + 1;
        if (ma[e] != '\0' && ma[e] != t[j]) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    std::cout << w << std::endl;
}


Measured memory_bytes: 10880
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        List<PriorityQueue<Integer>> list = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            PriorityQueue<Integer> set = new PriorityQueue<>();
            list.add(set);
        }

        for(int i = 0; i < n; i++) {
            int u = sc.nextInt() - 1;
            int k = sc.nextInt();
            for(int j = 0; j < k; j++) {
                list.get(u).add(sc.nextInt() - 1);
            }
        }

        int[] dist = new int[n];
        for(int i = 0; i < n; i++) {
            dist[i] = -1;
        }

        Queue<Integer> task = new ArrayDeque<>();
        task.add(0);
        dist[0] = 0;
        while(!task.isEmpty()) {
            int i = task.poll();
            while(!list.get(i).isEmpty()) {
                int j = list.get(i).poll();
                if(dist[j] < 0) {
                    dist[j] = dist[i] + 1;
                    task.add(j);
                }
            }
        }

        for(int i = 0; i < n; i++) {
            System.out.printf("%d %d\n", i + 1, dist[i]);
        }

        sc.close();
    }
}



Measured memory_bytes: 29416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
using ll=long long int;
using ppi=pair<ll,ll>;
using pql =priority_queue<ll, vector<ll>, greater<ll>>;
using pq=priority_queue<ll>;

int main()
{
    int n;
    cin>>n;
    ll m=9223372036854775807;
    ll p;
    ll ans=0;
    rep(i,n){
        cin>>p;
        m=min(m,p);
        ans+=(m==p);
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  long long cnt = A.at(0);
  int a, b = 0;
  if(N%2 == 1) {
    for(int i = 1; i <=(N-2)/2; i++) {
      cnt += 2*A.at(i);
    }
    cnt += A.at(N/2);
  }
  else {
    for(int i = 1; i <=(N-2)/2; i++) {
      cnt += 2*A.at(i);
    }
  }
  cout << cnt << endl;
}


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

int main(){
  int i;
  int j;
  int change;
  int num = 0;
  int count = 0;
  int flag = 1;
  int *data;

while(1){
scanf("%d",&num);
if(1 <= num && num <= 100){
  break;
}
}
data = (int *)malloc(sizeof(int)*num);

for(j = 0;j < num;j++){
  while(1){
  scanf("%d",&data[j]);
  if(data[j] >= 0 && data[j] <= 100){
    break;
  }
}
}

  while(flag){
    flag = 0;

for(i = num - 1;i > 0;i--){
  if(data[i] < data[i - 1]){
    change = data[i];
    data[i] = data[i - 1];
    data[i - 1] = change;
    flag = 1;
    count++;
  }
  }
}

for(i = 0;i < num-1;i++){
  printf("%d ",data[i]);
}
printf("%d",data[num - 1]);
printf("\n");
printf("%d",count);
printf("\n");
return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define MAXN	200005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
vector <int> a[MAXN];
int n, f[MAXN], tmp[MAXN], tnp[MAXN];
int nowtype, sg[MAXN], mark[MAXN];
bool visited[MAXN], circle[MAXN], finished[MAXN];
void dfs(int pos) {
	for (unsigned i = 0; i < a[pos].size(); i++)
		dfs(a[pos][i]);
	nowtype++;
	for (unsigned i = 0; i < a[pos].size(); i++)
		mark[sg[a[pos][i]]] = nowtype;
	int ans = 0;
	while (mark[ans] == nowtype) ans++;
	sg[pos] = ans;
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(f[i]);
	int pos = 1;
	while (!visited[pos]) {
		visited[pos] = true;
		pos = f[pos];
	}
	while (!circle[pos]) {
		circle[pos] = true;
		pos = f[pos];
	}
	for (int i = 1; i <= n; i++)
		if (!circle[i]) a[f[i]].push_back(i);
	for (int i = 1; i <= n; i++)
		if (circle[i]) dfs(i);
	int last = pos;
	finished[pos] = true;
	tmp[pos] = sg[pos] + 1;
	tnp[pos] = sg[pos];
	pos = f[pos];
	while (!finished[pos]) {
		tmp[pos] = sg[pos] + (sg[pos] == tmp[last]);
		tnp[pos] = sg[pos] + (sg[pos] == tnp[last]);
		finished[pos] = true;
		last = pos; pos = f[pos];
	}
	if (sg[pos] == tmp[last] || tnp[pos] != tnp[last]) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

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

const int MOD = 998244353;
int main() {
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    vector<vector<long long>> dp(N+1, vector<long long>(S+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= S; ++j) {
            dp[i+1][j] += dp[i][j] * 2 % MOD;
            if (j-A[i] >= 0) dp[i+1][j] += dp[i][j-A[i]];
            dp[i+1][j] %= MOD;
        }
    }
    cout << dp[N][S] << endl;
}

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

inline int rd() {
  int x = 0;
  bool f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}

int a[N], ans, tmp[4];

inline int calc(int a, int b, int c) {
  tmp[1] = a;
  tmp[2] = b;
  tmp[3] = c;
  sort(tmp + 1, tmp + 4);
  return (tmp[1] + tmp[2] > tmp[3]);
}

int main() {
  int n = rd();
  for (int i = 1; i <= n; ++i) a[i] = rd();
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (a[i] != a[j])
        for (int k = j + 1; k <= n; ++k)
          if (a[i] != a[k] && a[j] != a[k]) ans += calc(a[i], a[j], a[k]);
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	string s;

	cin >> s;

	ll ans = 700;

	REP(i, 3) {
		if (s[i] == 'o') {
			ans += 100;
		}
	}

	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))

const double pi=acos(-1);
const int maxn=1e6+10;
const int mod=1e9+7;
map<int,int> a;
int main()
{
    int n;
    sint(n);
    int flag=0;
    for(int i=0;i<n;i++)
    {
        int b;
        sint(b);
        if(a[b])
            flag=1;
        a[b]++;
    }
    if(flag)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

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

	int ans = 0;
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			rotate(s[i].begin(), s[i].begin() + 1, s[i].end());
		}
		bool fl = true;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				fl &= (s[i][j] == s[j][i]);
			}
		}

		ans += fl;

	}

	cout << ans * n << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

#include <iostream>
#include <vector>
using namespace std;

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}

int main(void)
{
 ll n;
 cin >> n;
 n = n%10;
 if(n == 0 || n == 1 || n == 6 || n == 8){
   cout << "pon" << endl;
 }else if(n == 3){
   cout << "bon" << endl;
 }else{
   cout << "hon" << endl;
 }
 return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
	
	Stack<String> math = new Stack<String>();
	ArrayList<Object> equation = new ArrayList<Object>();
	
	public int evaluate() {
		Scanner in = new Scanner(System.in);
		String line = in.nextLine();
		in = new Scanner(line);
		String operators = "+-/*";
		while(in.hasNext()) {
			if(in.hasNextInt()) {
				equation.add(in.nextInt());
			}
			else {
				equation.add(in.next());
			}
		}
		in.close();
		for(int i = 0 ; i <equation.size(); i++) {
			if(equation.get(i).getClass().equals(Integer.class)) {
				math.push(String.valueOf(equation.get(i)));
			}
			else {
				int first =  Integer.valueOf(math.pop());
				int second = Integer.valueOf(math.pop());
				if(equation.get(i).equals(operators.substring(0,1))) {
					int ans = second + first;
					math.push(String.valueOf(ans));
				}
				else if(equation.get(i).equals(operators.substring(1,2))) {
					int ans = second - first;
					math.push(String.valueOf(ans));
				}
				else if(equation.get(i).equals(operators.substring(2,3))) {
					int ans = second / first;
					math.push(String.valueOf(ans));
				}
				else if(equation.get(i).equals(operators.substring(3,4))){
					int ans = second * first;
					math.push(String.valueOf(ans));;
				}
			}
		}
		return Integer.valueOf(math.pop()); 
	
	}
	
	public static void main(String[] args) {
		Main a = new Main();
		System.out.println(a.evaluate());
		
	}
}


Measured memory_bytes: 26692
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll ans=0;
    ll now=100;
    while(now<x){
        ans++;
        now+=now/100;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3652
/* ***********************************************
Author        :yang12138
Created Time  :2017/8/8 15:47:04
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

const int N=1e5+10;

void solve(){
	int n;
	scanf("%d",&n);

	int cnt[3]={};
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x%4==0) cnt[0]++;
		else if(x%2==0) cnt[1]++;
		else cnt[2]++;
	}

	if(cnt[0]>=n/2) printf("Yes\n");
	else{
		if(cnt[2]>cnt[0]+1) printf("No\n");
		else if(cnt[2]==cnt[0]+1){
			if(cnt[1]) printf("No\n");
			else printf("Yes\n");
		}
		else printf("Yes\n");
	}
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 256
class Main {

	public static void main(String[] a) {
		for (int i = 1 ; i <= 9 ; i++) {
			for (int j = 1; j <= 9; j++) {
				int ans = i * j;
				System.out.println(i + "x" + j + "=" + ans);				
			}	
		}		
	}

}



Measured memory_bytes: 24152
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


void max_u(int&m, int v)
{
	if(m<v) m=v;
}


int main(void)
{
	int n, t;

	while(scanf("%d%d", &n, &t)==2)
	{
		vi dp(t, -1);
		vi a(n), b(n);
		vpii ab(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d%d", &a[i], &b[i]);
			ab[i]=make_pair(a[i], -b[i]);
		}
		sort(ab.begin(), ab.end());
		for(int i=0;i<n;i++)
		{
			a[i]=ab[i].first;
			b[i]=-ab[i].second;
		}

		int ans=0;
		dp[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j=t-1;j>=0;j--)
			{
				if(dp[j]<0) continue;
				int c=dp[j]+b[i];

				if(j+a[i]<t) max_u(dp[j+a[i]], c);
				else max_u(ans, c);
			}
		}

		for(int i=0;i<t;i++) max_u(ans, dp[i]);

		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int H,N,i,T,I;
 
	scanf("%d%d",&H,&N);

	T=0;
	 for(i=0;i<N;i++){
		 scanf("%d",&I);
		 T=T+I;}

	if(H<=T)printf("Yes\n");
	else    printf("No\n");

      return 0;

 }

Measured memory_bytes: 128
using System;

class quiz
{
    public int solve(int a, int b, int h)
    {
        return (a + b) * h / 2;
    }

    public int[] ParseIntBySpace(string str)
    {
        int[] array = new int[str.Length];
        int lastloc = 0, spaceloc = -1;

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == ' ')
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc - 1));
                spaceloc = i;
            }
            else if (i == str.Length - 1)
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc));
            }
        }

        Array.Resize(ref array, lastloc);

        return array;
    }
}

class Example
{
    static void Main()
    {
        quiz ex = new quiz();

        //while (true)
        //{
            Console.WriteLine(ex.solve(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()),int.Parse(Console.ReadLine())));
        //}
    }
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLineIntSpilit();
            var re = 0;
            while(n[0] > 0) {
                n[0] /= n[1];
                re++;
            }

            Console.WriteLine(re);
            ReadLine();
        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


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

int main(){
  using ll=long long;
  int N; cin >> N;
  ll count=0;
  vector<ll> va(N+1);
  vector<ll> vb(N);
  for (int i=0;i<N+1;i++){
    cin >> va.at(i);
  }
  for (int i=0;i<N;i++){
    cin >> vb.at(i);
  }
  for (int i=0;i<N;i++){
    if(vb.at(i)<=va.at(i))
      count+=vb.at(i);
    else if(vb.at(i)>va.at(i) && vb.at(i)<=va.at(i)+va.at(i+1)){
      count+=vb.at(i);
      va.at(i+1)=va.at(i)+va.at(i+1)-vb.at(i);
    }
    else{
      count+=va.at(i)+va.at(i+1);
      va.at(i+1)=0;
    }
  }
  cout << count << endl;
  
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    int t,n,a,b,c,i,j,d,sum=0,ar[10000];
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
    scanf("%d",&ar[i]);
    sum=sum+ar[i];
        }
   scanf("%d",&a);
    for(j=1;j<=a;j++)
    {
        scanf("%d %d",&b,&c);
        d=sum-ar[b-1]+c;
        printf("%d\n",d);
    }
    return 0;
    }
        

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

struct Line {
  int64 m, b;
};

// will maintain lower hull for minimum
struct Envelop {
  vector<Line> a;
  int ptr = 0;
  bool bad(int x, int y, int z) {
    return (a[z].b - a[x].b) * (a[x].m - a[y].m) <
      (a[y].b - a[x].b) * (a[x].m - a[z].m);
  }
  void insert(int64 m, int64 b) {
    a.push_back(Line{m, b});
    while (a.size() >= 3 && bad(a.size() - 3, a.size() - 2, a.size() - 1)) {
      a.erase(a.end() - 2);
    }
  }
  int64 eval(int64 x) {
    ptr = min(ptr, (int)a.size() - 1);
    while (ptr < a.size() - 1 &&
           a[ptr + 1].m * x + a[ptr + 1].b < a[ptr].m * x + a[ptr].b) ++ptr;
    return a[ptr].m * x + a[ptr].b;
  }
};

int main() {
  int n;
  int64 C;
  scanf("%d%lld", &n, &C);
  vector<int64> h(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &h[i]);
  }
  vector<int64> dp(n);
  Envelop E;
  dp[0] = 0;
  E.insert(-2 * h[0], h[0] * h[0] + dp[0]);
  for (int i = 1; i < n; ++i) {
    dp[i] = E.eval(h[i]) + h[i] * h[i] + C;
    E.insert(-2 * h[i], h[i] * h[i] + dp[i]);
  }
  printf("%lld\n", dp[n - 1]);
  return 0;
}


Measured memory_bytes: 9456
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String X =s.next();
    if(X.equals("AAA")||X.equals("BBB")) {
    	System.out.println("No");
    }else {
    	System.out.println("Yes");
}}}

Measured memory_bytes: 23764
class Integer
  def divisor_list
    require 'prime'

    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

N = gets.to_i

ans = 0

N.divisor_list.each do |k|
  next if k == 1

  n = N

  while n % k == 0
    n = n / k
  end

  ans += 1 if n % k == 1
end

ans += ((N - 1).divisor_list - [1]).size

puts ans


Measured memory_bytes: 14476
N=gets.to_i

h=Hash.new(0)
s = gets.chomp
('a'..'z').each do |c|
    h[c] = s.count(c)
end
(N-1).times do
    s = gets.chomp
    ('a'..'z').each do |c|
        h[c] = [s.count(c),h[c]].min
    end
end

s = ''
h.each do |k,v|
    s += k*v
end

puts s.chars.sort.join

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	int dp[n];
	dp[1]=abs(a[0]-a[1]);
	dp[2]=min(abs(a[0]-a[2]),dp[1]+abs(a[1]-a[2]));
	for(int i=3;i<n;i++)
	{
	    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {

	string s;
	cin >> s;
	ll ans = 0;

	for (int bit = 0; bit < (1 << ((int)s.size() - 1)); bit++) {
		ll num = s[0] - '0';
		ll sum = 0;

		for (int i = 0; i < (int)s.size() - 1; i++) {
			if (bit & (1 << i)) {

				sum += num;
				num = 0;
			}

			num = num * 10 + s[i + 1] - '0';

		}
		sum += num;
		ans += sum;

	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

#define N 10000
#define Q 10000

int main(){
  int i, j, n, m, a[N], b[Q], f = 0, g = 0;

  scanf("%d", &n);

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

  scanf("%d", &m);

  for(i = 0; i < m; i++){
    scanf("%d", &b[i]);
  }

  for(j = 0; j < m; j++){
    for(i = 0; i < n; i++){
      if(a[i] == b[j]){
	f++;
	break;
      }
    }
    g += f;
    f = 0;
  }


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

  return 0;
}




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

int n, arr[100000];

int solve(int i,int m) {
	if(m==0) return true;
	if(i>=n) return false;
  int res= solve(i+1, m) || solve(i+1, m-arr[i]);
	return res;
}

int main() {
	int key ,q;
	cin >> n ;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	cin >> q;
	for (int j = 0; j < q; j++) {
			cin >> key;
			if(solve(0,key)) cout << "yes" << endl;
			else cout << "no" << endl;
		}	
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
ll a[100010];
ll sum=0;
bool nula=false;
int neg=0;

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

	cin>>n;
	for(int i=0;i<n;i++)
        cin>>a[i];
    ll mini=abs(a[0]);
    for(int i=0;i<n;i++)
    {
        sum+=abs(a[i]);
        if(a[i]<0) neg++;
        if(a[i]==0) nula=true;
        mini=min(mini,abs(a[i]));
    }
    if(nula || neg%2==0)
        cout<<sum;
    else
        cout<<sum-2*mini;

	return 0;
}


Measured memory_bytes: 1024