akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define PI (3.14159265358979323846)
#define ld long double
#define int long long
#define MOD 998244353
#define w(x) int x; cin >> x; while(x--)
#define F first
#define S second
#define PB push_back
     
const char nl = '\n';
const int N = 1e5 + 5;
    


void solve(){

    int x; cin >> x;

    cout << !x << nl;
}


int32_t main(){
         
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    
    
     
    return 0;
    
             
}

Measured memory_bytes: 3608
#include<cstdio>

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

using namespace std;

int dx[4],dy[4];

int dfs(int y,int x,bool used[4][4]){
	if(y==4) return 1;
	if(x==4) return dfs(y+1,0,used);
	if(used[y][x]) return dfs(y,x+1,used);

	used[y][x]=true;

	int res=0;
	rep(i,4) rep(j,2) {
		int yy=y+(j?1:-1)*dy[i];
		int xx=x+(j?1:-1)*dx[i];
		if(0<=yy && yy<4 && 0<=xx && xx<4 && !used[yy][xx]){
			used[yy][xx]=true;
			res+=dfs(y,x+1,used);
			used[yy][xx]=false;
		}
	}

	used[y][x]=false;

	return res;
}

int main(){
	while(1){
		rep(i,4) scanf("%d%d",dx+i,dy+i);
		if(dx[0]>4) break;
		bool used[4][4]={};
		printf("%d\n",dfs(0,0,used));
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s; cin>>s;
    int n=sz(s);
    bool flag=1;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[(n/2)-1-i]) flag=0;
    }
    for(int i=0;i<(n/2);i++){
        if(s[n-1-i]!=s[i+(n/2)+1]) flag=0;
    }
    for(int i=0;i<n;i++){
        if(s[i]!=s[n-1-i]) flag=0;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
 
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }
 
using namespace std;
using ll = long long;
 
const int INF = 1001001001;
 
int main()
{
	int n, mx(-1), j(0);
	string s;
	cin>>n;
	map<string, int>mp;
	vector<string> vec(n);
	
	rep(i, n){
	    cin>>s;
	    mp[s]++;
	    mx = max(mx, mp[s]);
	}
	
	for(pair<string, int> p:mp){
	    if(p.second==mx){
	        vec[j]=p.first;
	        j++;
	        
	    }
	}
	
	sort(vec.begin(), vec.begin()+j);
	
	
	rep(i, j)cout<<vec[i]<<endl;
}

Measured memory_bytes: 27136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        ans+=min(2*x,2*m-2*x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    string s;
    cin >> s;
    vector<int> cnt(30, 0);
    for (char& c: s)
        cnt[c - 'a']++;
    for (int& c: cnt) {
        if (c % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    ll n;
    cin >> n;
    ll v[200010];
    ll freq[200010] = {0};
    for (int i = 1; i <= n; ++i) {
    	cin >> v[i];
    	freq[v[i]]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
    	ans += freq[i] * (freq[i] - 1) / 2;
    }
    for (int i = 1; i <= n; ++i) {
    	cout << ans - (freq[v[i]] - 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n,cnt=1;
	cin >> n;
	vector<int> d(n);
	for (int& x : d)cin >> x;
	
	sort(d.begin(), d.end());
	for (int i = 0; i < n-1; i++) {
		if (d[i] != d[i + 1])cnt++;
	}

	cout << cnt << endl;
} 


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

int main(){
  int N,M,A[N],vote=0,count=0;
  cin>>N>>M;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  
  for(int i=0;i<N;i++){
    vote+=A[i];
  }
  
  for(int i=0;i<N;i++){
    if(A[i]*4*M>=vote){
      count++;
    }
  }
  
  if(count>=M){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
gou=0
for i in range(1,n+1):
    on=0
    k=i
    while True:
        on += k%10
        k= k//10
        if k==0:
          break
    if on >= a and on <= b:
        gou = gou+i
print(gou)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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(){
    ll N,K; cin >> N >> K;
    vector <ll> A(N+1);
    for (ll i=0; i<=N; i++){
        A[i]=i;
    }
    
    vector <ll> left(N+1);
    left[0]=0;
    for (ll i=1; i<=N; i++){
        left[i]=left[i-1]+A[i];
        //cout << left[i] << endl;
    }
    
    vector <ll> right(N+1);
    right[0]=A[N];
    for (ll i=1; i<=N; i++){
        right[i]=right[i-1]+A[N-i];
        //cout << right[i] << endl;
    }
    
    ll ans=0;
    for (ll i=K-1; i<=N; i++){
        //cout << left[i] << " " << right[i] << endl;
        ans+=(right[i]-left[i])+1;
    }
    cout << ans%1000000007 << endl;
}

Measured memory_bytes: 7920
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n;
vector<int>g[200005];
int a[200005];
struct fraction{
	int x,y,ind;//(x/y)
	fraction(int a=0,int b=0,int c=0){
		x=a;y=b;ind=c;
	}
};
bool operator<(fraction a,fraction b){
	return a.x*b.y<a.y*b.x;
}
#define F fraction
int par[200005],pr[200005],used[200005];
F f[200005];
int find(int x){
	return x==par[x]?x:par[x]=find(par[x]);
}
signed main(){
	cerr<<"ok now"<<endl;
	cin>>n;
	for(int i=2;i<=n;i++){
		int p;cin>>p;
		g[p].push_back(i);pr[i]=p;
	}
	cerr<<"ok now"<<endl;
	for(int i=1;i<=n;i++)cin>>a[i],par[i]=i;
	multiset<F>s;
	for(int i=1;i<=n;i++){
		f[i]=F(a[i]==1?1ll:0ll,a[i]==0?1ll:0l,i);
		s.insert(f[i]);
	}
	cerr<<"ok now"<<endl;
	ll ans=0;
	while(!s.empty()){
		F x=*s.begin();s.erase(s.begin());
		if(x.x!=f[x.ind].x||x.y!=f[x.ind].y||used[x.ind])continue;
		if(find(x.ind)==1)continue;
		used[x.ind]++;
		int p=find(pr[x.ind]);
		par[x.ind]=p;
		ans+=(ll)x.y*f[p].x;
		cerr<<x.ind<<" "<<p<<" "<<x.y<<" "<<f[p].x<<endl;
		f[p]=F(f[p].x+f[x.ind].x,f[p].y+f[x.ind].y,p);
		s.insert(f[p]); 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 34688
#include<iostream>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
#include<cstring>
using namespace std;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
int main() {

	//B
	int n;
	int i;
	int counter = 0;
	long long int x, y;
	long long int d;
	cin >> n >> d;
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d * d)counter++;
	}
	cout << counter << endl;
	return 0;

	//C
	/*int k;
	cin >> k;
	
	if (7 % k == 0) {
		cout << 1 << endl;
		return 0;
	}
	if (k % 7 == 0)k = k / 7;
	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1 << endl;
		return 0;
	}
	if (k == 3) {
		cout << 3 << endl;
		return 0;
	}
	else if (k == 9) {
		cout << 9 << endl;
		return 0;
	}
	
	
	int i = 0;
	int j = 1;
	while (1) {
		i++;
		j = j * 10;
		j = j % k;
		if (j == 1) {
			if (k % 9 == 0) {
				i = i * 9;
			}
			else if (k % 3 == 0) {
				i = i * 3;
			}
			cout << i << endl;
			return 0;
		}

	}*/

	//D
	/*int n;
	string c;
	cin >> n;
	cin >> c;
	int sum = 0;
	int i, j;
	int s = 0;
	i = 0; j = n - 1;
	while (i < j) {
		if (c[i] == 'W') {
			if (c[j] == 'R') {
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
			else {
				while (c[j] != 'R') {
					j--;
					if (j < 0 || j <= i) {
						cout << sum << endl;
						return 0;
					}
				}
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
		}
		else {
			while (c[i] != 'W') {
				i++;
				if (i >= n || i >= j) {
					cout << sum << endl;
					return 0;
				}
			}
			if (c[j] == 'R') {
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
			else {
				while (c[j] != 'R') {
					j--;
					if (j < 0 || j <= i) {
						cout << sum << endl;
						return 0;
					}
				}
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
		}
	}

	cout << sum << endl;
	return 0;	
	*/
}

// a^n mod を計算する
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;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n,d; cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    rep(i,0,n) rep(j,0,d) cin>>x[i][j];
    int cnt=0;
    rep(i,0,n-1)
    rep(j,i+1,n){
        double ans=0;
        rep(k,0,d){
            ans+=abs((x[i][k]-x[j][k])*(x[i][k]-x[j][k]));
        }
        double a=ans;
        ans=(int)sqrt(ans);
        if(ans*ans==a) cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
#define N 2000
#define M 200
 
int solve(int,int);
 
int A[N];
int n;
 
int main(){
 
  int ans,q,i;
  int mi[M];
 
  scanf("%d",&n);
 
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
 
  scanf("%d",&q);
  for(i=0 ; i<q ; i++){
    scanf("%d",&mi[i]);
  }
 
 
  for(i=0 ; i<q ; i++){
    ans = solve(0,mi[i]);
    if(ans==1) printf("yes\n");
    else printf("no\n");
  }
 
  return 0;
}
 
int solve(int i, int m){
 
  int ans;
 
    if(m==0)return 1;
    if(i>=n)return 0;
 
    ans = solve(i+1,m) || solve(i+1,m-A[i]);
 
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const int W = 0; const int B = 1;
int n;
vector<vector<pair<int, int>>>M;
void dijkstra() {
	int minv;
	vector<int>d(n, INF), color(n, W);
	d[0] = 0;
	while (1) {
		minv = INF;
		int u = -1;
		rep(i, 0, n) {
			if (color[i] != B&&d[i] < minv) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = B;
		rep(v, 0, M[u].size()) {
			pair<int, int>t(M[u][v]);
			if (color[t.first] != B&&d[u] + t.second < d[t.first]) {
				d[t.first] = d[u] + t.second;
			}
		}
	}
	rep(i, 0, n) {
		cout << i << " " << d[i] << endl;
	}
}
signed main() {
	cin >> n; M = vector<vector<pair<int, int>>>(n, vector<pair<int, int>>());
	rep(i, 0, n) {
		int u, k; cin >> u >> k;
		rep(j, 0, k) {
			int v, c; cin >> v >> c;
			M[u].push_back(make_pair(v, c));
		}
	}
	dijkstra();
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s1,s2,s3;cin>>s1>>s2>>s3;
  char a=s1[0]-32;
  char b=s2[0]-32;
  char c=s3[0]-32;
  cout<<a<<b<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

li = [ri() for _ in range(5)]
lis = [math.ceil(i/10)*10 for i in li]
ans = inf
for i in range(5):
  ans = min(sum(lis[:i])+li[i]+sum(lis[i+1:]), ans)
print(ans)
  
    










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

int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  VV kai(10,vector<ll>());
  rep(i,n){
    kai[s[i]-'0'].push_back(i);
  }
  ll ans=0;
  rep(i,10){
    if(kai[i].size()==0)continue;
    rep(j,10){
      rep(k,10){
        if(kai[k].size()==0)continue;
        ll num=lower_bound(kai[j].begin(), kai[j].end(), kai[k][kai[k].size()-1])-upper_bound(kai[j].begin(), kai[j].end(), kai[i][0]);
        if(num>0)ans++;
      }
    }
  }
  cout<<ans<<endl;
}


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

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

  int a, b;
  while (true) {
    cin >> a;
    cin >> b;
    if (cin.eof()) { break; }
    cout << floor(log10(a + b)) + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 1296
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



ll euclidean_gcd(ll a, ll b) {
	if (a < b) return euclidean_gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}


signed main() {
	ll n;
	vector<ll>list;
	ll maxn = 0;

	cin >> n;

	for (ll i = 0; i < n; i++) {
		ll num;
		cin >> num;
		list.push_back(num);
	}

	if (n == 2) {
		cout << max(list[0], list[1]);
		return 0;
	}

	vector<ll>L, R;

	for (int i = 0; i < n; i++) {
		if (i == 0) {
			L.push_back(list[0]);
		}
		else {
			//L.push_back(euclidean_gcd(list[i - 1], list[i]));
			L.push_back(euclidean_gcd(L[i - 1], list[i]));
		}
	}

	for (int i = n - 1; i >= 0; i--) {
		if (i == n - 1) {
			R.push_back(list[n - 1]);
		}
		else {
			//R.push_back(euclidean_gcd(list[i + 1], list[i]));
			R.push_back(euclidean_gcd(R[R.size() - 1], list[i]));
		}
	}

	reverse(R.begin(), R.end());
	int l, r;
	vector<ll>ans;

	for (int i = 0; i < n; i++) {
		l = i - 1;
		r = i + 1;
		if (l < 0) {
			ans.push_back(R[r]);
		}
		else if (i == n - 1) {
			ans.push_back(L[l]);
		}
		else {
			ans.push_back(euclidean_gcd(L[l], R[r]));
		}
	}

	sort(ans.begin(), ans.end(), greater<ll>());

	cout << ans[0] << endl;


	return 0;
}

Measured memory_bytes: 4084
import java.util.Scanner

import scala.collection.immutable
import scala.collection.mutable.ArrayBuffer


object Main {

  class UnionFind(val n: Int) {

    sealed trait Node

    final case class Root(count: Int, rank: Int) extends Node

    final case class NonRoot(parentIndex: Int) extends Node

    private val nodes: ArrayBuffer[Node] = ArrayBuffer.fill(n)(Root(count = 1, rank = 0))

    private def rootNode(index: Int): (Int, Root) = {
      nodes(index) match {
        case root: Root => (index, root) // nodes(index) == root
        case nonRoot: NonRoot =>
          val (rootIndex, root) = rootNode(nonRoot.parentIndex)
          nodes(index) = NonRoot(parentIndex = rootIndex) // 経路圧縮
          (rootIndex, root)
      }
    }

    private def root(index: Int): Int = rootNode(index)._1

    def sameCount(x: Int): Int = rootNode(x)._2.count

    def same(x: Int, y: Int): Boolean = root(x) == root(y)


    def unite(x: Int, y: Int): Unit = {
      if (same(x, y)) return

      val (xRootIndex, xRoot) = rootNode(x)
      val (yRootIndex, yRoot) = rootNode(y)

      if (xRoot.rank < yRoot.rank) {
        // xRootの親をyRootとする
        nodes(xRootIndex) = NonRoot(parentIndex = yRootIndex)
        nodes(yRootIndex) = yRoot.copy(count = xRoot.count + yRoot.count)
      } else {
        // yRootの親をxRootとする
        nodes(yRootIndex) = NonRoot(parentIndex = xRootIndex)
        val nextXRootRank = xRoot.rank + (if (xRoot.rank == yRoot.rank) 1 else 0)
        nodes(xRootIndex) = Root(count = xRoot.count + yRoot.count, rank = nextXRootRank)
      }
    }

  }

  // A番目の島とB番目の島をつないだ橋
  case class Bridge(a: Int, b: Int)

  def read(): (Int, Int, immutable.IndexedSeq[Bridge]) = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val bridges = for (i <- 0 until m) yield {
      // 0-originにする
      val a = sc.nextInt() - 1
      val b = sc.nextInt() - 1
      Bridge(a, b)
    }
    (n, m, bridges)
  }

  def solve(n: Int, m: Int, bridges: IndexedSeq[Bridge]): IndexedSeq[Long] = {
    val reverseBridges = bridges.reverse
    val uf = new UnionFind(n)
    val numConnectedPairsDiff = for (bridge <- reverseBridges) yield {
      val diff =
        if (uf.same(bridge.a, bridge.b)) 0.toLong
        else uf.sameCount(bridge.a).toLong * uf.sameCount(bridge.b).toLong
      uf.unite(bridge.a, bridge.b)
      diff
    }
    val numConnectedPairs = numConnectedPairsDiff.scanLeft(0.toLong)(_ + _)
    numConnectedPairs.reverse.tail.map(x => n.toLong * (n.toLong - 1) / 2 - x)
  }

  def output(result: IndexedSeq[Long]): Unit = {
    for (elem <- result) {
      println(elem)
    }

  }

  def main(args: Array[String]): Unit = {
    val (n, m, bridges) = read()
    val result = solve(n, m, bridges)
    output(result)
  }
}

Measured memory_bytes: 116140
#include <stdio.h>
 int main() 
{
 	 int h,w,i,u=1,y,j,k;
 	 char a[150][150],b[150];
 	 for (j=0;j<=120;j++)
 	 for (k=0;k<=120;k++)
 	 a[j][k]='#';
 	 scanf("%d%d",&h,&w);
 	 getchar();
 	 for (y=1;y<=h;y++)
 	 {
 	 	gets(b);u++;
 	 	for (i=1;i<w+1;i++)
 	 	a[u][i]=b[i-1];
 	 }
 	 for(u=1;u<h+3;u++)
 	 {
 	 for(i=0;i<=w+1;i++)
 	 printf("%c",a[u][i]);
 	 printf("\n");
 	 }
      return 0; 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
using namespace std;

int main()
{
	ll t;
//	cin>>t;
	t=1;
	while(t--){
		ll n,x,t;
		cin>>n>>x>>t;
		ll ans=ceil(n*1.0/x)*t;
		cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
signed main()
{
    int n, m, combi = 0;
    cin >> n >> m;
    vvi bulbs(20, vi(20));
    vi k(20), p(20);
    for (int i = 0; i < m; i++)
    {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++)
            cin >> bulbs[i][j];
    }
    for (int i = 0; i < m; i++)
        cin >> p[i];
    for (int mask = 0; mask < pow(2, n); mask++)
    {
        vb switchon(n + 1);
        for (int i = 0; i < n; i++)
        {
            if (mask & (1 << i))
                switchon[i + 1] = true;
        }
        int cnt = 0;
        for (int i = 0; i < m; i++)
        {
            int flag = 0;
            for (int j = 0; j < bulbs[i].size(); j++)
            {
                if (switchon[bulbs[i][j]])
                    flag = (flag + 1) % 2;
            }
            if (flag == p[i])
                cnt++;
        }
        if (cnt == m)
            combi++;
    }
    cout << combi << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

    int prime_num_cnt = 0;
    int prime_prob_num = 2;

//    if ( n % 2 == 1 ) {
//        prime_prob_num = 2;
//    }
//    else {
//        prime_prob_num = 3;
//    }

    vector<int> prime_num;

    while ( 1 ) {
        if ( prime_prob_num > 55555 || prime_num_cnt == n ) {
            break;
        }
        for ( int pi = 2; pi <= prime_prob_num; ++pi ) {
            if ( pi == prime_prob_num && prime_prob_num % 5 == 1 ) {
                ++prime_num_cnt;
                prime_num.push_back(prime_prob_num);
            }
            if ( prime_prob_num % pi == 0 ) {
                break;
            }
        }
        ++prime_prob_num;
    }

    rep(i, n) {
        if ( i == n - 1 ) {
            printf("%d\n", prime_num[i] ); 
        }
        else {
            printf("%d ", prime_num[i]);
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
    int n,a[100005];
    bool vis[100005];
    while(scanf("%d",&n)!=EOF)
    {
        LL ans=0;
        memset(vis,false,sizeof(vis));
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
            if(a[i])vis[i]=true;
            ans+=a[i]/2;
            a[i]%=2;
        }
        for(int i=1; i<n; i++)
        {
            if(a[i]&&a[i-1])
            {
                a[i]=0;
                a[i-1]=0;
                ans++;
            }
            else if(a[i]==0&&a[i-1])
                if(vis[i]) a[i]++,a[i-1]--;
        }
        printf("%lld\n",ans);
    }
}


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

int main()
{

	
		
	string s , t ;
	cin >> s >> t ;
	//cout << s.size() <<" " << t.size();
	if(s.size() != (t.size() - 1))
	{
		cout<<"No";
		return 0 ;
	}
	for(int i = 0 ; i < s.size() ; ++i)
	{
		if(s[i] != t[i])
		{
			cout << "No";
			return 0 ;
		}
	}
	cout << "Yes" ;
	
	
	return 0 ;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n >> m;
    vpll v(n+1);
    for(int i=1; i<=n; i++){
        cin >> v[i].fi >> v[i].se;
    }
    ll dp[n+1][1000*n+1];
    memset(dp,0x3f,sizeof(dp));
    dp[0][0]=0;
    for(int i=1; i<=n; i++){
        for(int j=0; j<=n*1000; j++){
            if(j>=v[i].se){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i].se]+v[i].fi);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    a=0;
    for(int i=0; i<=1000*n; i++){
        if(dp[n][i]<=m)a=i;
    }
    cout << a << el;
    return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    REP(i, M) cin >> L[i] >> R[i];

    int start = L[0];
    int end   = R[0];
    FOR(i, 1, M) {
        chmax(start, L[i]);
        chmin(end, R[i]);
    }
    int ans = end - start + 1;

    std::cout << max(ans, 0) << '\n';

    return 0;
}

Measured memory_bytes: 1024
S = list(input())
S_divide = [S[0]+S[1],S[2]+S[3]]
S_divide = list(map(int, S_divide))
a = S_divide[0]
b = S_divide[1]
while True:
    if 1 <= a <= 12 and 1 <= b <= 12:
        print('AMBIGUOUS')
    elif 1 <= a <= 12:
        print('MMYY')
    elif 1 <= b <= 12:
        print('YYMM')
    else:
        print('NA')
    break


Measured memory_bytes: 3060
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;

int main(void)
{
	int N;
	cin >> N;
	
	vector<bool> flag(N, true); 
	for(int i=0; i<N; i++)
	{
		int p;
		cin >> p;

		if(p == i+1)
			flag[i] = false;
	}

	int ret = 0;
	for(int i=0; i<N-1; i++)
	{
		if(flag[i] == false)
		{
			flag[i] = flag[i+1] = true;
			ret++;
			i++;
		}
	}
	if(flag[N-1] == false)
		ret++;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
  
public class Main{
      
    public static void main(String[] args){
          
        Scanner sc = new Scanner(System.in);
          
        int first = sc.nextInt();
        int second = sc.nextInt();
        int third = sc.nextInt();
          
        int[] sort = {first,second,third};  
          
        Arrays.sort(sort);
          
        System.out.println(sort[0]+" "+sort[1]+" "+sort[2]);
    }
  
}

Measured memory_bytes: 26144
#include <stdio.h>

int prime[1000000];
int main(void)
{
	int i, j;
	int n;
	int s;
	
	for (i = 0; i < 1000000; i++){
		prime[i] = 1;
	}
	
	prime[0] = 0;
	prime[1] = 0;
	
	for (i = 2; (i * i) < 1000000; i++){
		if (prime[i] == 1){
			for (j = 2; (i * j) < 1000000; j++){
				prime[(i * j)] = 0;
			}
		}
	}	
	
	while (scanf("%d", &n) != EOF){
		s = 0;
		for (i = 2; i <= n; i++){
			if (prime[i] == 1){
				s++;
			}
		}
		printf("%d\n", s);
	}
	
	return (0);
}

Measured memory_bytes: 4496
n = input()
t = ["3","5","7"]
for i in range(8):
    s = []
    for j in t:
        s.append(j+"3")
        s.append(j+"5")
        s.append(j+"7")
    t += s
t = set(t)
t = list(t)
t.sort()
count = 0
for i in range(len(t)):
    if len(t[i]) > len(n):
        continue
    if int(t[i]) > int(n):
        continue
    if '3' in t[i] and '5' in t[i] and '7' in t[i]:
        count+=1
print(count)

Measured memory_bytes: 20076
n = int(input())
p = list(map(int,input().split()))
#print(n,p)
count = 0
for i in range(1,n-1):
#    print("i",i)
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        count = count + 1
print(count)

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

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

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

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

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

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

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

	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(s == u) {
		a--;
	}
	else {
		b--;
	}
	cout << a << " " << b;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int wMax=sc.nextInt();
    int[] w=new int[n];
    int[] v=new int[n];
    int sumV=0;
    for(int i=0;i<n;i++){
      w[i]=sc.nextInt();
      v[i]=sc.nextInt();
      sumV+=v[i];
    }
    long[][] dp=new long[n+1][sumV+1];
    for(int j=1;j<=sumV;j++){
      dp[0][j]=Integer.MAX_VALUE;
    }
    /*
      dp[i][j]:=i番目以上の品を使わずに価値jを実現する最小容量
      dp[i][0]=0
      dp[0][j]=inf
      dp[i][j]=MIN(dp[i-1][j-v[i]]+w[i],dp[i-1][j])
    */
    for(int i=1;i<=n;i++){
      for(int j=1;j<=sumV;j++){
        dp[i][j]=dp[i-1][j];
        if(j-v[i-1]>=0){
          dp[i][j]=Math.min(dp[i-1][j-v[i-1]]+w[i-1],dp[i][j]);
        }
      }
    }
    long ans=0;
    for(int i=sumV;i>=0;i--){
      if(dp[n][i]<=wMax){
        ans=i;
        break;
      }
    }
    System.out.println(ans);
    /*
    System.err.println(Arrays.toString(w));
    System.err.println(Arrays.toString(v));
    for(int i=0;i<=n;i++){
      for(int j=0;j<=sumV;j++){
        System.err.print(dp[i][j]==Integer.MAX_VALUE?"INF":dp[i][j]);
        System.err.print(" ");
      }
      System.err.println();
    }
    */
  }
}

Measured memory_bytes: 127292
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,sum=0;
  cin>>n>>m;
  long long x;
  while(m--){
   cin>>x;
   
    sum+=x;
  }
  
  if(n>=sum)
    cout<<n-sum<<"\n";
  else
    cout<<"-1"<<"\n";
  return 0;
}
    


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
const int INF=1e9+7;
const int mod=1e9+7;
struct poi{
	int X;int Y;int Z;
  bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
//ACACACACACACACACACACACAC//
//WAWAWAWAWAWAWAWAWAWAWAWA//
//CECECECECECECECECECECECE//
//RERERERERERERERERERERERE//
//TLETLETLETLETLETLETLETLE//
//
int main(){
	int D,L;
	cin>>D>>L;
	cout<<D/L+D%L<<endl;
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int d, score;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26)), pos(26);

int get_score(vector<int> t){
    vector<int> pos(26, 0);
    int ans = 0;
    rep(i, t.size()){
        int l = i + 1 - pos[t[i]];
        ans -= (l * (l-1) / 2) * c[t[i]];
        ans += s[i][t[i]];
        pos[t[i]] = i+1;
    }
    rep(i, 26){
        int l = t.size() + 1 - pos[i];
        ans -= (l * (l-1) / 2)* c[i];
    }
    return ans;
}

int main() {
    cin >> d;
    rep(i, 26)cin >> c[i];
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------// 
    vector<int> t, pos(26, 0);
    rep(i, d){
        int max_score = -mod;
        int best_j = -1;
        rep(j, 26){
            t.push_back(j);
            int score = get_score(t);
            if(max_score < score){
                best_j = j;
                max_score = score;
            }
            t.pop_back();
        }
        t.push_back(best_j);
    }
    while(clock() < 1950000){
        int D = rand() % d, q = rand() % 26;
        int old = t[D], olds = get_score(t);
        t[D] = q;
        if(get_score(t) < olds)t[D] = old;
    }
    rep(i, d)cout << t[i]+1 << endl;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std ;
 
int main() {
 
  int n; cin>>n;
  int a[n] ;
     
  int compXor = 0 ;
  
  for(int i=0; i<n; i++) 
    cin>>a[i], compXor ^= a[i] ; 
 
  int final[n] ;
  
  for(int i=0; i<n; i++)
    final[i] = compXor^a[i] ;
  
  for(int i=0; i<n; i++) cout<<final[i]<<' ';

  return 0;
}


Measured memory_bytes: 5100
import java.util.*;

public class Main {
 	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 1; i <= n; i++) {
		    arr[i] = sc.nextInt();
		}
		long[][][] dp = new long[n + 1][n + 1][n * 50 + 1];
		dp[0][0][0] = 1;
		for (int i = 1; i <= n; i++) {
		    for (int j = 0; j < i; j++) {
		        for (int k = 0; k <= j * 50; k++) {
		            dp[i][j][k] += dp[i - 1][j][k];
		            dp[i][j + 1][k + arr[i]] += dp[i - 1][j][k];
		        }
		    }
		}
		long total = 0;
		for (int i = 1; i <= n; i++) {
		    total += dp[n][i][i * a];
		}
	    System.out.println(total);
	}
}


Measured memory_bytes: 85284
n = int(input())
p = list(map(float,input().split()))

#dp[投げたコイン枚数][表のコイン枚数] 
dp = [[0]*(n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  dp[i][0] = dp[i-1][0]*(1-p[i-1])
  dp[i][i] = dp[i-1][i-1]*p[i-1]
  for j in range(1,i):
    dp[i][j] = dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
print(sum(dp[n][(n+1)//2:]))


Measured memory_bytes: 263432
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

#define SEARCHED_NODE 2
#define START_NODE 1
#define ROUTE_NODE 1
#define INIT_NODE 0

int _flag[1000];
vector<vector<int>> *_edge;
vector<int> *_invloop;
vector<int> *_nextinvloop;
int _startnode;
bool search(int c, int p)
{
    if( _flag[c] == SEARCHED_NODE) return false;
    _flag[c] = ROUTE_NODE;
    vecrep(itr, (*_edge)[c])
    {
        if( _flag[*itr] == ROUTE_NODE ) 
        {
            _flag[*itr] = START_NODE;
            _invloop->push_back(c);
            return true;
        }
    }

    vecrep(itr, (*_edge)[c])
    {
        if( search(*itr, c) ) 
        {
            if(  _flag[*itr] != ROUTE_NODE )
            {
                _flag[*itr] = INIT_NODE;
            } 
            else
            {
                _invloop->push_back(c);
            }
            return true;
        }
    }
    _flag[c] = SEARCHED_NODE;

    return false;
}

pair<int, int> checkloop()
{
    int ls = _invloop->size();
    rep(i, ls)
    {
        int next = i - 1;
        if( next < 0 ) next = ls + next;
        int node = (*_invloop)[i];
        int nextnode = (*_invloop)[next];
        vecrep(itr, (*_edge)[node])
        {
            if(  _flag[*itr] == ROUTE_NODE && *itr != nextnode ) return make_pair(node, *itr);
        }
    }
    return make_pair(-1, -1);
}

void resetflag(int n)
{
    rep(j, n) _flag[j] = 0;
    vecrep(itr, (*_invloop)) _flag[*itr] = ROUTE_NODE;
}

void newloop(int s, int e)
{
    int loopindex = 0;
    while((*_invloop)[loopindex] != s ) loopindex++;
    _nextinvloop->clear();

    while((*_invloop)[loopindex] != e )
    {
        _nextinvloop->push_back((*_invloop)[loopindex]);
        loopindex = (loopindex + 1) % _invloop->size();
    }
    _nextinvloop->push_back(e);
    swap(_invloop, _nextinvloop);
}

int main()
{
    int n, m; cin >> n >> m;
    vector<vector<int>> edge(n);
    _edge = &edge;
#if 1    
    rep(i, m)
    {
        int a, b; cin >> a >> b; a--; b--;
        edge[a].push_back(b);
    }
#else
    rep(i, m)
    {
        int a, b; cin >> a >> b; a--; b--;
        edge[0].push_back(i + 1);
    }
#endif
    vector<int> invloop; _invloop = &invloop;
    vector<int> nextinvloop; _nextinvloop = &nextinvloop;
    rep(j, n) _flag[j] = INIT_NODE;
    rep(i, n)
    {
        if( search(i, -1) )
        {
            while( true )
            {
                resetflag(n);
                pair<int, int> ret = checkloop();
                if( ret.first < 0 ) break;
                newloop(ret.first, ret.second);
            }
            sort(_invloop->begin(), _invloop->end());
            cout << _invloop->size() << endl;
            vecrep(itr, *_invloop) cout << *itr + 1 << endl;
            return 0;
        } 
    }
    cout << -1 << endl;
    return 0;    
}

Measured memory_bytes: 3740
# coding: utf-8
import sys
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
g=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    g[a].append(b)
    g[b].append(a)
color=[0 for i in range(n)]
def check(v,c):
    color[v]=c
    for i in range(len(g[v])):
        if color[g[v][i]]==c:
            return False
        if color[g[v][i]]==0 and not check(g[v][i],-c):
            return False
    return True

for i in range(n):
    if color[i]==0:
        if not check(i,1):
            print(int((n-1)/2*n)-m)
            break
else:
    x,y=0,0
    for i in range(n):
        if color[i]==1:
            x+=1
        else:
            y+=1
    print(x*y-m)
    exit()








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

#define EPS 10e-8

int main(void){
  int s[10], v[2];
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",s,s+1,s+2,s+3,s+4,s+5,s+6,s+7,s+8,s+9,v,v+1) != EOF){
    for(int i = 1; i < 10; i++) s[i] += s[i-1];
    double x = (1.0 * v[0] * s[9]) / (v[0] + v[1]);
    for(int i = 0; i < 10; i++){
      if(x <= s[i] + EPS){
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <cstring>
struct result {
	int A,B,C,R;
};
int a,b,c,N,P[300];
result Res[1000];
int main (int argc, char const* argv[])
{
	while(scanf("%d %d %d",&a,&b,&c),a) {
		memset(P,0,sizeof(P));
		scanf("%d",&N);
		for(int i=0;i<N;i++) {
			int A,B,C,R;
			scanf("%d %d %d %d",&A,&B,&C,&R);
			Res[i].A=A-1;
			Res[i].B=B-1;
			Res[i].C=C-1;
			Res[i].R=R;
		}
		for(int i=0;i<N;i++) {
			if(Res[i].R) {
				P[Res[i].A]=P[Res[i].B]=P[Res[i].C]=1;
			}
		}
		for(int i=0;i<N;i++) {
			if(!Res[i].R) {
				if(P[Res[i].A]==1&&P[Res[i].B]==1)P[Res[i].C]=2;
				if(P[Res[i].A]==1&&P[Res[i].C]==1)P[Res[i].B]=2;
				if(P[Res[i].B]==1&&P[Res[i].C]==1)P[Res[i].A]=2;
			}
		}
		for(int i=0;i<(a+b+c);i++) {
			if(P[i]==2)printf("0\n");
			if(P[i]==1)printf("1\n");
			if(P[i]==0)printf("2\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1028
S=input()
S=S.replace('BC','X')
S=S.replace('B','Y')
S=S.replace('C','Y')
S=S.split('Y')
#print(S)
ans=0
for s in S:
    if not s:
        continue
    l=len(s)
    C=[0]*l
    cnt=0
    for i in reversed(range(l)):
        if s[i]=='X':
            cnt+=1
        C[i]=cnt
    #print(C)
    for i in range(l):
        if s[i]=='A':
            ans+=C[i]
print(ans)

Measured memory_bytes: 50800
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long N = sc.nextLong();
        if(N<B){
            System.out.println(Math.floorDiv(A*N,B));
        }else{
            System.out.println(Math.floorDiv(A*(B-1), B));
        }
    }

}


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

int main()
{
	int a,b,ans=0;
    cin >> a >>b;
    for(int i=a;;i--)
        if(i==b)
        {
            ans++;
            cout<<ans<<endl;
            return 0;
        }
        else
        {
                ans++;
        }
        

	
	return 0;
}
	

Measured memory_bytes: 256
A[1000][1000],I[1000],u[999];i,j;d;F=2;main(N){for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);for(;F&2;)for(F=1,i=!++d;++i<N;)u[i]<d&&(j=A[I[i]][i]-1)>=0&&u[F&=2,j]<d&&A[I[j]][j]==i+1&&++I[u[i]=u[j]=d,++I[i],F=2,j];printf("%d",F*d-1);}

Measured memory_bytes: 4096
import java.util.*;


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

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

int main() {

  string str;
  cin >> str;

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) { 

    string s1;
    int start_, end_;
    cin >> s1 >> start_ >> end_;
    
    int count_ = end_ - start_ + 1;
    
    if (s1 == "replace") {
      string s_;
      cin >> s_;
      str = str.substr(0, start_) + s_ + str.substr(end_ + 1);
    } else if (s1 == "print"){
      cout << str.substr(start_, count_) << endl;
    } else {
      string s_ = str.substr(start_, count_);
      reverse(s_.begin(), s_.end());
      str = str.substr(0, start_) + s_ + str.substr(end_ + 1);
    }
  }

  return 0;

}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s;
  cin >> s;
  int ans = 114514;
  rep(i, 0, s.length() - 1) {
    if(s[i] != s[i + 1]) ans = min(ans, max((int)s.length() - 1 - i, i + 1));
  }
  if(ans == 114514) {
    cout << s.length() << endl;
  }else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 512
N = int(input())
S = (input())
d_hundred = [0] * 10
d_ten = set()
ans = set()
for i in range(N):
    S_i = int(S[i])

    for j in d_ten:
        kari = j*10+S_i
        ans.add(str(kari).zfill(3))

    for k in range(10):
        if d_hundred[k] == 1:
            d_ten.add(d_hundred[k] * k * 10 + S_i)
    d_hundred[S_i] = 1


print(len(ans))
# print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      {
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		if (a[0]<a[1]&&a[1]<a[2])
		Console.WriteLine("Yes");
		else Console.WriteLine("No");
		 }
	 }
 }

      
      

Measured memory_bytes: 9280