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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int NN = 222;
int N;
char B[1111][1111];

void print() {
   rep (i, NN) {
      rep (j, NN) {
         cout << B[i][j];
      }
      puts("");
   }
}

bool f(int y, int x) {
   for (int i = y; i >= 0; i--) {
      for (int j = x; j >= 0; j--) {
         if (B[i][j] == 'R') {
            B[i][j] = '.';
            return true;
         }
      }
   }
   return false;
}

int main() {
   rep (i, NN) rep (j, NN) B[i][j] = '.';
   cin >> N;
   rep (i, N) {
      int a, b;
      cin >> a >> b;
      B[a][b] = 'R';
   }
   rep (i, N) {
      int c, d;
      cin >> c >> d;
      B[c][d] = 'B';
   }

   int ans = 0;
   rep (j, NN) {
      rep (i, NN) {
         if (B[i][j] == 'B') {
            if (f(i, j)) {
               B[i][j] = '.';
               ans++;
            }
         }
      }
   }
   cout << ans << endl;

   return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

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

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b;
    cin>>a>>b;
    if(a<=8&&b<=8)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
#define VAL 100000
#define ll long long
const int MAX=2e6+10000;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);/
	//#endif
	int a, b, c;
	cin>>a>>b>>c;
	swap(a, b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;

}

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

int main(){
  string S;
  cin >> S;
  long long ans = 0;
  for(int s = 0;s < (1 <<(S.size()-1));s++){
  	string conn = "";
    conn += S[0];
    for(int i = 0;i < S.size()-1;i++){
      if(s & (1 << i)) conn += "+";
      conn += S[i + 1];
    }
    long long sum = 0;
    int pos = 0;
    while(conn.find("+",pos) != string::npos){
      int nextpos = conn.find("+", pos);
      sum += stoll(conn.substr(pos, nextpos - pos));
      pos = nextpos+1;
    }
    sum += stoll(conn.substr(pos));
    ans += sum;
  }
  cout << ans << endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,X;
    cin>>N>>X;
    int ans=N;

    int a=X,b=N-X;
    while(true){
        if(a>b)swap(a,b);
        if(a==0)break;
        int tmp=b/a;
        ans+=tmp*2*a;
        int t=a;
        a=b%a;
        b=t;
    }
    cout<<ans-b<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 0
b = {}
for i in range(n):
    l = a[i] + (i+1)
    r = (i+1) - a[i]
    if r in b:
        ans += b[r]
    if l in b:
        b[l] += 1
    else:
        b[l] = 1

print(ans)

Measured memory_bytes: 111544
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
	string s;
	cin >> s;
	if(s == "SUN") cout << 7 << endl;
	else if(s == "MON") cout << 6 << endl;
	else if(s == "TUE") cout << 5 << endl;
	else if(s == "WED") cout << 4 << endl;
	else if(s == "THU") cout << 3 << endl;
	else if(s == "FRI") cout << 2 << endl;
	else if(s == "SAT") cout << 1 << endl;
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>


#define SIZEMAX 100007

using namespace std;
using ll = long long int;

ll N, M, S, T;

vector<set<ll>> graph(SIZEMAX);

struct entry {
  ll cost;
  ll node;
  ll div3;

  bool operator>(const entry &a) const {
    return cost > a.cost;
  }
};

struct hoge {
  ll node;
  ll div3;

  bool operator<(const hoge &a) const {
    return node < a.node || (node == a.node && div3 < a.div3);
  }

  bool operator==(const hoge &a) const {
    return node == a.node && div3 == a.div3;
  }
};

ll bfs(ll from, ll to) {
  set<hoge> open;
  priority_queue<entry, vector<entry>, greater<entry>> queue;

  open.insert(hoge {from, 0 });
  queue.push(entry {0, from, 0} );

  while (!queue.empty()) {
    entry e = queue.top();
    queue.pop();

//    cout << e.node << ": " << e.cost << "," << e.div3 << endl;

    if (e.node == to && e.div3 == 0) {
      return e.cost;
    }

    for (ll next : graph[e.node]) {
      ll ndiv3 = (e.div3 + 1) % 3;
      if (open.count({hoge { next, ndiv3 }}) > 0) {
        continue;
      }

      open.insert({hoge { next, ndiv3 }});
      queue.push(entry { e.cost + 1, next, ndiv3 });
    }
  }

  return -1;
}

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

  for (int i = 0; i < M; i++) {
    ll u, v;
    cin >> u >> v;

    graph[u].insert(v);
  }

  cin >> S >> T;
  ll result = bfs(S, T);

  if (result != -1) {
    cout << result / 3 << endl;
  } else {
    cout << -1 << endl;
  }


  return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


int N;

void solve()
{
    cin >> N;
    cout << 800 * N - 200 * (N / 15) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

long int gcd(long int a, long int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

void Ok()
{
    long long int a[1013],b[1013],c,d,e,f,g,h,t,i,j = 0,k,l1,l2,m,n,x,y,sum,ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag,div,rcv,temp;
    long double aa,bb,cc,dd,ee,ff,gg;
    char aaa[1013],bbb[1013],ccc[1013],alpbt;
    string spc;

    cin>>n;
    if(n%2==0)
    {
        ans_1 = n/2;
        cout<<ans_1<<endl;
    }
    else
    {
        n += 1;
        ans_1 = n/2;
        cout<<ans_1<<endl;
    }

    return;
}

int main()
{
    Ok();

    return 0;
}


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

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	vector<int64_t> sum(n + 1);
	sum[0] = 0;
	for (int i = 0; i < n; i++)
	{
		sum[i + 1] = sum[i] + as[i];
	}
	vector<int64_t> ss;
	for (int i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
		{
			ss.emplace_back(sum[j + 1] - sum[i]);
		}
	}
	sort(ss.begin(), ss.end());
	set<int64_t> st;
	for (auto &s : ss)
	{
		st.insert(s);
	}
	int64_t ans = 0;
	for (int i = 40; 0 <= i; i--)
	{
		int count = 0;
		set<int64_t> puni;
		for (auto &s : st)
		{
			if (s & (1LL << i))
			{
				count++;
				puni.insert(s);
			}
		}
		if (k <= count)
		{
			bool f = true;
			for (auto &x : puni)
			{
				f &= st.find(x) != st.end();
			}
			if (f)
			{
				ans += (1LL << i);
				st = puni;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 32880
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
using namespace std;

typedef long long LL;
 
const int OO = 1e9;
const int MOD = 1e9 + 7;

class Task {
public:

	void solve() {
		int h, w, n;
		cin >> h >> w >> n;
		int x, y;
		cin >> x >> y;
		string s, t;
		cin >> s >> t;
		
		int r, c;
		
		c = y;
		for (int j = 0 ; j < n; ++j) {
			if (s[j] == 'R') {
				c++;
			}
			if (c > w) {
				cout << "NO\n";
				return;
			}
			if (t[j] == 'L' && c > 1) {
				--c;
			}
		}
		
		c = y;
		for (int j = 0 ; j < n; ++j) {
			if (s[j] == 'L') {
				c--;
			}
			if (c < 1) {
				cout << "NO\n";
				return;
			}
			if (t[j] == 'R' && c < w) {
				++c;
			}
		}
		
		r = x;
		for (int j = 0 ; j < n; ++j) {
			if (s[j] == 'U') {
				r--;
			}
			if (r < 1) {
				cout << "NO\n";
				return;
			}
			if (t[j] == 'D' && r < h) {
				++r;
			}
		}
		
		r = x;
		for (int j = 0 ; j < n; ++j) {
			if (s[j] == 'D') {
				r++;
			}
			if (r > h) {
				cout << "NO\n";
				return;
			}
			if (t[j] == 'U' && r > 1) {
				--r;
			}
		}
		
		cout << "YES\n";
	}
};
 
int32_t main() {
//~ #ifndef ONLINE_JUDGE
	//~ freopen("input.txt", "r", stdin);
//~ #endif
 
	Task *task = new Task();
	task->solve();
	return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll dp[1002][1002]; char a[1002][1002];
signed main() {
	ll n, m; cin >> n >> m;
	rep2(i, n) {
		rep2(j, m) {
			cin >> a[i][j];
		}
	}
	dp[1][1] = 1;
	rep2(i, n) {
		rep2(j, m) {
			if (a[i][j] != '#') {
				dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % mod;
			}
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}

Measured memory_bytes: 12372
#include <stdio.h>
#include <stdlib.h>
#include <string.h>



int main(){
    int K,y,i=0;
    char S[100];
    scanf("%d",&K);
    scanf("%s",S);

    y = strlen(S);

    for(i;i<K;i++){
      if(i<y){printf("%c",S[i]);} 
    }
    
    if(y>K){
        printf("...\n");
    }



return 0;

}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;
int par[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
    }
}

int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
}

void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x!=y)  par[x]=y;
    return;
}

bool check(int x,int y){
    return root(x)==root(y);
}
 
int main(){
    
    int N,Q;cin>>N>>Q;

    init(N);

    for(int i=0;i<Q;i++){
        int a,b,c;cin>>a>>b>>c;
        if(a==0) unite(b,c);
        if(a==1){
            if(check(b,c)) cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
}



Measured memory_bytes: 3256
#include <iostream>
#include <string>
#include <queue>
#include <cstring>

using namespace std;

const int INF = 9999999;

int w, h;
string b[20];
int d[20][20];

char dx[] = {-1,1,0,0};
char dy[] = {0,0,-1,1};

void dist(int sx, int sy){
	for(int i=0;i<20;i++)
		for(int j=0;j<20;j++)
			d[i][j] = INF;
	queue< pair<int,int> > qu;
	qu.push(make_pair(sx,sy));
	d[sy][sx] = 0;
	while(!qu.empty()){
		pair<int, int> p = qu.front(); qu.pop();
		int x = p.first, y = p.second;
		for(int i=0;i<4;i++){
			int nx = x + dx[i], ny = y + dy[i];
			if(nx<0||nx>=w||ny<0||ny>=h||b[ny][nx]=='x') continue;
			if(d[ny][nx] != INF) continue;
			d[ny][nx] = d[y][x] + 1;
			qu.push(make_pair(nx,ny));
		}
	}
}

int main(){
	int c[11][11];
	int x[11], y[11];
	int ans[1<<11][11];
	while(cin >> w >> h){
		if(!(w||h)) break;
		int num = 1;
		for(int i=0;i<h;i++){
			cin >> b[i];
			for(int j=0;j<w;j++){
				if(b[i][j]=='o') x[0] = j, y[0] = i;
				if(b[i][j]=='*') x[num] = j, y[num++] = i;
			}
		}
		bool flag = false;
		memset(c,0,sizeof(c));
		dist(x[0],y[0]);
		for(int i=1;i<num;i++){
			c[0][i] = d[y[i]][x[i]];
			if(c[0][i] == INF) flag = true;
		}
		if(flag) { cout << -1 << endl; continue; }
		for(int i=1;i<num;i++){
			dist(x[i],y[i]);
			for(int j=0;j<num;j++){
				if(i==j) continue;
				c[i][j] = d[y[j]][x[j]];
			}
		}
		for(int i=0;i<(1<<num);i++) for(int j=0;j<num;j++) ans[i][j] = INF;
		ans[1][0] = 0;
		for(int i=0;i<(1<<num);i++){
			for(int j=0;j<num;j++)
				if((i>>j)&1)
					for(int k=0;k<num;k++)
						ans[i|(1<<k)][k] = min(ans[i|(1<<k)][k],ans[i][j]+c[j][k]);
		}
		int cost = INF;
		for(int i=1;i<num;i++) cost = min(cost, ans[(1<<num)-1][i]);
		cout << cost << endl;
	}
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int n;
	cin >> n;
	vll a(n);
	vll sum(n); // sum[i] = sum of a[0] to a[i] 
	rep(i,n) {
		cin >> a[i];
		if(i==0) sum[i] = a[i];
		else sum[i] = sum[i-1] + a[i];
	}
	ll ans = LLONG_MAX;
	rep3(i,0,n-2){
		ans = min(ans, abs(sum[n-1]-2*sum[i]));
    }
	cout << ans << endl;  
	return;
}

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

Measured memory_bytes: 3456
#include <iostream>
using namespace std;
int main()
{
    string s,t;cin>>s>>t;
    if(s==t) cout<<"Yes";
    else{
            char tmp;
            string w=s;
            int l=0;
            for(int j=0;j<w.size();j++){
            tmp=s[s.size()-1];
            char change;
            for(int i=s.size()-1;i>0;i--){
                    change=s[i];
                    s[i]=s[i-1];
                    s[i-1]=change;
            }
            s[0]=tmp;
            if(s==t){cout<<"Yes";break;l=1;}
            }
            if(s!=t){
                cout<<"No";
            }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int; 
 
#define ff              first
#define ss              second
// #define ll 				long long int
#define dd             double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define modp            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl 			'\n'
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
// void aks()
// {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
// }


void solve()
{
	int n; cin >> n;
	cpp_int a[n];cpp_int res = 1;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a+n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		res = res*a[i];
		if(res > 1000000000000000000)
		{
			cout << -1 << endl;
			return;
		}
	}
	cout << res << endl;

}
 
int32_t main()
{
	FIO
    //aks();
    //w(t)
    {
    	solve();
    }
    return 0;
}
	

Measured memory_bytes: 6828
import sys

n = sys.stdin.readline().rstrip()
l = len(n)

def main():
    cnt = 0
    for i in range(0, l, 2):
        if i < l-1:
            cnt += 10 ** (i + 1) - 10 ** i
        else:
            cnt += int(n) - (10 ** i - 1)

    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int N, L[55] = {}, K, max = 0;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L, L + N, greater<int>());
	for (int i = 0; i < K; i++) {
		max += L[i];
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int a,b,tambah=0,kurang=0,kali=0;
	scanf("%d %d",&a,&b);
	tambah=a+b;
	kurang=a-b;
	kali=a*b;
	if(tambah >= kurang && tambah >= kali){
		printf("%d\n",tambah);
	}
	else if(kurang >= tambah && kurang >= kali){
		printf("%d\n",kurang);
	}
	else printf("%d\n",kali);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli dfs(lli k,vector<vector<lli>> &graph,lli now,lli from){

	lli can_use_color_num;
	if(from==-1){
		can_use_color_num = k-1;
	}
	else{
		can_use_color_num = k-2;
	}

	if(k<graph[now].size()){
		return 0;
	}

	lli case_num = 1;
	for(auto e:graph[now]){
		if(e == from)continue;

		case_num *= can_use_color_num;
		can_use_color_num--;
		case_num %= MOD;
	}
	for(auto e:graph[now]){
		if(e==from)continue;
		case_num *= dfs(k,graph,e,now);
		case_num %= MOD;
	}
	return case_num;
}

signed main(){

	lli n,k;
	cin>>n>>k;
	vector<vector<lli>> graph(n);
	REP(i,0,n-1){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	cout<<k*dfs(k,graph,0,-1)%MOD<<endl;

	return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>
int main(void){
	double r = 0.0;
	double area = 0, length = 0;
	double pai = 3.141592653589;

	scanf("%lf", &r);

	area = r * r * pai;
	length = r * 2 * pai;

	printf("%f %f\n", area, length);
}

Measured memory_bytes: 2640
n = int(input())
ans = [0]*10001

for i in range(1, 101):
    for j in range(1, 101):
        for z in range(1, 101):
            aaa = i**2+j**2+z**2+i*j+j*z+z*i
            if aaa <= 10**4:
                ans[aaa] += 1
for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 9360
use std::io;
use std::io::{BufRead, Write};
use std::ops::Sub;

fn abs_sub<T: Sub + Ord>(lhs: T, rhs: T) -> <T as Sub>::Output {
    if lhs < rhs {
        rhs - lhs
    } else {
        lhs - rhs
    }
}

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let _n: usize = buf.trim_right().parse().unwrap();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let x: Vec<usize> = buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
    let max = x.iter().cloned().max().unwrap();
    let alt = x.iter().cloned().filter(|&x|x!=max).min_by_key(|x| abs_sub(x * 2, max)).unwrap();
    writeln!(output, "{} {}", max, alt).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "5
6 9 4 2 11
",
            "11 6\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "2
100 0
", "100 0\n",
        );
    }
}


Measured memory_bytes: 6396
#include<iostream>
#include<string>
#define LL long long
#define INF 0x3f3f3f3f
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int N=2e5+100;
using namespace std;	
int main()
{
	
	string s;
	while(cin>>s)
	{
		int n=s.length();
		LL ans=0;
		LL tmp=0;
		for(int i=0;i<(1<<(n-1));i++)
		{
			tmp=0;
			for(int j=0;j<n;j++)
			{
				tmp=tmp*10+(int)(s[j]-'0');
				if((i>>j)&1||j==n-1)
				{
					ans+=tmp;
					tmp=0;
				}
			}
		}
		cout<<ans<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
_ = "_"


def solve(f):
    if _ in f:
        a = solve(f.replace(_, '+', 1))
        b = solve(f.replace(_, '-', 1))
        if a is not None:
            return a
        if b is not None:
            return b
    else:
        if eval(f) is 7:
            return f
        else:
            return None


s = _.join(input())
print(solve(s) + '=7')


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

using namespace std;

int main(){
    int n;
    cin >> n;bool flag = false;
    for(int i = 1;i < 10 && flag == false;i++){
        for(int j = i;j < 10;j++){
            if(i*j == n){
                flag = true;
                break;
            }
        }
    }
    if(flag){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	vector<vector<int>> dp(n+1,vector<int>(m+1,0));
	rep(i,n)rep(j,m){
		if(s[i]==t[j]){
			dp[i+1][j+1]=dp[i][j]+1;
		}else{
			dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
		}
	}
	string ans;
	int r=n,l=m,now=dp[n][m];
	/*cout<<dp<<endl;
	cout<<now<<endl;*/
	while(now){
		//cout<<ans<<' '<<now<<' '<<r<<' '<<l<<endl;
		if(s[r-1]==t[l-1] && dp[r-1][l-1]==now-1){
			ans.push_back(s[r-1]);
			r--,l--,now--;
		}else if(l-1>=0 && dp[r][l-1]==now){
			l--;
		}else if(r-1>=0 && dp[r-1][l]==now){
			r--;
		}else{
			l--,r--;
		}
	}
	reverse(begin(ans),end(ans));
	cout<<ans<<endl;
}

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

#ifdef _DEBUG
#define ASSERT(x) assert(x)
#define DLOG(x) cout << __LINE__ << ": " << x << endl;
#else
#define ASSERT(x)
#define DLOG(x)
#endif
#define DLOG_V(x) DLOG(#x << ": " << x)

using namespace std;

constexpr static auto none{numeric_limits<int>::min()};

struct Tree {
  void print() const {
    doInOrder(rootIdx, [](auto&& i) { cout << " " << i; });
    cout << endl;
    doPreOrder(rootIdx, [](auto&& i) { cout << " " << i; });
    cout << endl;
  }

  void insert(int val) {
    size_t idx = rootIdx;
    while (true) {
      auto cur = tryGet(idx);
      if (cur == none) {
        vals_[idx] = val;
        return;
      } else {
        idx = val < cur ? leftIdx(idx) : rightIdx(idx);
      }
    }
  }

 private:
  constexpr static size_t rootIdx = 1;

  static size_t leftIdx(size_t idx) { return idx * 2; }
  static size_t rightIdx(size_t idx) { return idx * 2 + 1; }

  int tryGet(size_t idx) const {
    auto it = vals_.find(idx);
    if (it == vals_.end()) {
      return none;
    } else {
      return it->second;
    }
  }

  void doInOrder(size_t idx, const function<void(int)>& f) const {
    if (tryGet(idx) == none) {
      return;
    }
    doInOrder(leftIdx(idx), f);
    f(tryGet(idx));
    doInOrder(rightIdx(idx), f);
  }

  void doPreOrder(size_t idx, const function<void(int)>& f) const {
    if (tryGet(idx) == none) {
      return;
    }
    f(tryGet(idx));
    doPreOrder(leftIdx(idx), f);
    doPreOrder(rightIdx(idx), f);
  }

  mutable unordered_map<size_t, int> vals_;
};

int main() {
  int num;
  cin >> num;
  Tree tree;
  for (int i = 0; i < num; ++i) {
    string cmd;
    cin >> cmd;
    if (cmd == "insert") {
      int val;
      cin >> val;
      tree.insert(val);
    } else if (cmd == "print") {
      tree.print();
    }
  }
}



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

const int N=2e5+5;
int n,nn;
int a[N],b[N],db[N];
int da[N*2],f[N*2];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) scanf("%d",b+i);
	for(int i=1;i<n;i++) da[i]=a[i]^a[i+1];
	for(int i=1;i<n;i++) db[i]=b[i]^b[i+1];
	da[n]=a[n]^a[1];
	for(int i=n+1;i<2*n;i++) da[i]=da[i-n];
	nn=2*n-1;
	for(int i=2;i<=nn;i++){
		int x=f[i-1];
		while(x!=0&&da[x+1]!=da[i]) x=f[x];
		if(da[x+1]==da[i]) f[i]=x+1;
		else f[i]=0;
	}
	for(int i=1,j=1;i<nn;i++){
		while(da[i]!=db[j]&&j>1) j=f[j-1]+1;
		if(da[i]==db[j]){
			if(j==n-1){
//				printf("%d %d\n",i,j);
				int x=i-(n-1)+1;
				printf("%d %d\n",x-1,a[x]^b[1]);
				j=f[j];
			}
			j++;
		}
	}
	return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    
    for (ll tc=1;tc<=tt;tc++){
        ll k,n;
        string s;
        
        cin>>k>>s;
        n=s.size();
        
        if (n<=k){
            cout<<s<<"\n";
        }
        else{
            s=s.substr(0,k);
            s+="...";
            cout<<s<<"\n";
        }
    }
    
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define yes() cout << "Yes"<< endl;
#define no() cout << "No"<< endl;

int main() {
	int a,b;
	cin >> a>>b;
	if (a <= b*2 ) {
		cout << 0 << endl;
	}
	else {
		cout << a-2*b << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n; string s; cin >> s;
    int res = 0;
    for(int i=0; i<=s.size()-3; i++) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            res++; i+=2;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef complex<double> C;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    while (m--) {
        string s;
        cin >> s;
        int n = s.size();
        set<string> S;
        for (int i = 1; i < n; i++) {
            string t = s.substr(0, i);
            string u = s.substr(i, n-i);
            string rt = t;
            string ru = u;
            reverse(rt.begin(), rt.end());
            reverse(ru.begin(), ru.end());
            S.insert(t+u);
            S.insert(t+ru);
            S.insert(rt+u);
            S.insert(rt+ru);
            S.insert(u+t);
            S.insert(u+rt);
            S.insert(ru+t);
            S.insert(ru+rt);
        }
        cout << S.size() << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n, s = 0, a;
	cin >> n;
	for (a = n; a > 0; a /= 10) s += a % 10;
	cout << (n % s == 0 ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

int main(){
    int x,y;
    cin >> x >> y;

    int a=4*x-y;
    int b=y-2*x;

    if(a>=0 && b>=0 && a%2==0 && b%2==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

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

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}


Measured memory_bytes: 256
A = [int(input()) for _ in range(5)]
ans = 0
temp2 = 10

for i in range(5):
    if A[i] % 10 == 0:
        ans += A[i]
    else:
        temp = (A[i]//10)*10 + 10
        ans += temp
        if temp2 > A[i] % 10:
            temp2 = A[i] % 10


temp2 = 10 - temp2
ans = ans - temp2
print(ans)


Measured memory_bytes: 3060
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop = do
  { [n, x] <- getInts
  ; if n == 0 && x == 0 then return ()
    else print (length (filter ((x ==) . sum) (comb [1..n] 3))) >> loop
  }

comb :: [a] -> Int -> [[a]]
comb ns 0 = [[]]
comb ns k
  | length ns == k = [ns]
  | otherwise      = map (head ns :) (comb (tail ns) (k - 1))
                     ++ comb (tail ns) k

--     
getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDoubles

showDoubles :: Double -> String
showDoubles d = showFFloat Nothing d ""





Measured memory_bytes: 5684
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

#define ld long double


int main(){
	fastio;
	cout.precision(10);
	ll n;
	cin>>n;
	vv<ld> p(n);
	for(ll i=0; i<n; i++){
		cin>>p[i];
	}

	vv<ld> dp(n+1, 0);
	//dp[i] get exaclty i heads till now
	//note ini with 0 but with 0 elem its certain that we hav 0 head
	dp[0]=1;
	for(ll i=0; i<n; i++){
		for(ll j=n; j>0; j--){
			dp[j]= dp[j]*(1-p[i]) + dp[j-1]*p[i];
		}
		dp[0]*= 1-p[i];	
		// LG(i)	
		// for(ll i=0; i<=n; i++){
		// 	LG(i,dp[i])
		// }
		
	}


	ld ans=0;
	for(ll i=n; i> n/2; i--){
		ans+= dp[i];
	}
	cout<<ans;
}

Measured memory_bytes: 3820
import sys
while True:
    ans = []
    flag=0
    n = int(input())
    if n==0: break
    a=[[i for i in input().split()] for i in range(n)]
    m = int(input())
    for i in range(m):
        ch = input().strip()
        for j in range(n):
            if ch==a[j][0]:
                ans.append(a[j][1])
                flag=1
        if flag!=1:
            ans.append(ch)
        flag=0
            
    for i in range(len(ans)):
        sys.stdout.write(ans[i])
    print()
        

Measured memory_bytes: 8920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll kai[(1<<18)];
ll mod = 1e9 + 7;

void init() {
    kai[0] = 1;
    kai[1] = 1;
    for (ll i = 2; i < (1 << 18); i++) {
        kai[i] = kai[i - 1] * i % mod;
    }
}

ll mp(ll a, ll b) {
    if (b == 0) return 1LL;
    ll ret = mp(a,b/2);
    ret *= ret;
    ret %= mod;
    if (b&1) ret *= a;
    return ret % mod;
}

ll inv(ll k) {
    return mp(k,mod-2);
}

ll C(ll n, ll k) {
    if (k == 0) return 1;
    if (n == k) return 1;
    return kai[n] * inv(kai[k]) % mod * inv(kai[n-k]) % mod;
}

int main() {
    ll n,m;
    cin >> n >> m;
    init();
    vector<ll> v;
    ll ans = 1;
    for (ll i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            ll cnt = 0;
            while (m % i == 0) {
                m /= i;
                cnt++;
            }
            v.push_back(cnt);
        }
    }
    if (m > 1) v.push_back(1);
    for (int i = 0; i < v.size(); i++) {
        ans *= C(v[i]+n-1,v[i]);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5656
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

int main(){


    int H, A;
    cin >> H >> A;

    int iatt = 0;
    while( H > 0 ){
        iatt++;
        H = H - A;
    }

    cout << iatt << endl;

}

Measured memory_bytes: 256
s = int(input())
if s == 1 or s == 2 or s == 4:
    print(4)
else:
    a = [s]
    for i in range(1001000):
        if a[i] % 2 == 0:
            a.append(a[i] / 2)
        else:
            a.append(a[i] * 3 + 1)
        if a[i + 1] == 4:
            print(i + 5)
            break


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int n;
char s1[1000000],s2[1000000];
int main()
{
    cin>>s1>>s2;
    n=strlen(s1);
    for(int i=0;i<n;i++)
    {
        if(s1[i]!=0)
            cout<<s1[i];
        if(s2[i]!=0)
            cout<<s2[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

using namespace std;

int mod=100000;

int dp[110][110][4];

int main()
{
	int W,H;
	while(true)
	{
		scanf("%d%d",&W,&H);
		if(W==0&&H==0) break;
		memset(dp,0,sizeof(dp));
		for(int i=0;i<W;i++) for(int j=0;j<H;j++)
		{
			if(i==0) dp[i][j][3]=1;
			if(j==0) dp[i][j][0]=1;
		}
		for(int i=1;i<W;i++) for(int j=1;j<H;j++)
		{
			dp[i][j][0]=dp[i-1][j][0]+dp[i-1][j][1];
			dp[i][j][1]=dp[i-1][j][3];
			dp[i][j][2]=dp[i][j-1][0];
			dp[i][j][3]=dp[i][j-1][2]+dp[i][j-1][3];
			for(int k=0;k<4;k++) dp[i][j][k]%=mod;
		}
		int ans=0;
		for(int k=0;k<4;k++) ans+=dp[W-1][H-1][k];
		printf("%d\n",ans%mod);
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int N, Q;
vector<int> G[200010];
int ans[200010], sum[200010];
void dfs(int n, int count){
  ans[n]=count;
  rep(i,G[n].size()){
    int next=G[n][i];
    if(ans[next]!=-1) continue;
    dfs(next,count+sum[next]);
  }
}

int main(){
  cin >> N >> Q;
  rep(i,N-1){
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  rep(i,Q){
    int p, x;
    cin >> p >> x;
    p--;
    sum[p]+=x;
  }
  rep(i,N) ans[i]=-1;
  dfs(0,sum[0]);
  rep(i,N-1) cout << ans[i] << " ";
  cout << ans[N-1] << endl;

  return 0;
}


Measured memory_bytes: 24064
#include<stdio.h>
int main(){
  int a,b=0,c,d=0;
  scanf("%d",&a);
  for(int i=0; i<a; i++){
    scanf("%d",&c);
    d+=c;
    if(b<c){b=c;}
  }
  printf("%d",d-b/2);
  return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<long long>> all(M, vector<long long>());
    for (int i = 0; i < N; ++i) {
        long long A, B;
        cin >> A >> B;
        if (A > M) continue;
        all[A-1].push_back(B);
    }
    long long res = 0;
    priority_queue<long long> que;
    for (int d = 0; d < M; ++d) {
        for (auto v : all[d]) que.push(v);
        if (!que.empty()) {
            res += que.top();
            que.pop();
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 8328