akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int last[40];
int s[400][400];
int c[26];
int d;
int calc(vector<int> &t){
    int ret = 0;
    
        rep(i,d){
            //use t[i];
            ret += s[i][t[i]-1];
            last[t[i]-1] = i+1;
            rep(j,26){
                ret -= c[j]*(i+1-last[j]);
            }
            
    
    
    
                    
        }
        return ret;

}
signed main(){
    cin >> d;
    rep(i,26)cin >> c[i];
    vector<int> ans(d);
    vector<int> t(d);
    rep(i,d)rep(j,26)cin >> s[i][j];
    int cnt = 0;
    int res = 0;
    int mx[400];
    rep(i,d){
        P v = P(0,0);
        rep(j,26){
            v = max(v,P(s[i][j],j));
        }
        mx[i] = v.second + 1;
    }
    while(cnt < 10000){
        rep(i,d){
            if((cnt+i)%41 == 0)t[i] = mx[i];
            else t[i] = (cnt+i)%26+1;
        }
        
        if(res < calc(t)){
            res = max(res,calc(t));
            rep(i,d)ans[i] = t[i];
        }
        cnt++;
    }
    rep(i,d)cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;
ll pwr[12];
string str = "";

bool check(ll mid,ll n)
{
        if(((pwr[mid]-1)*26LL)<=n)
        return 1;
        
        return 0;
}

vector<char> v = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n',
                  'o','p','q','r','s','t','u','v','w','x','y','z'};

void getAns(ll x,ll n)
{
        if(x==0)
        {
         str.pb(v[n]);
         return;
        }
          
        ll p = n/pwr[x];
        ll q = n%pwr[x];
        
        str.pb(v[p]);
        getAns(x-1,q);
}


void solve()
{
  ll n;
  cin>>n;
  
  if(n<=26)
  {
          char ch = n-1+'a';
          cout<<(ch);
          return;
  }
 
  n*=25LL;
  
  pwr[0] = 1;
  for(int i=1;i<=11;i++)
  {
          pwr[i] = pwr[i-1]*26LL;
  }
  
  ll st = 1;
  ll end = 11;
  
  ll ans = 0;
  while(st<=end)
  {
          ll mid = (st+end)>>1;
          if(check(mid,n))
          {
                  ans = mid;
                  st = mid+1;
          }
          else
          {
                  end = mid-1;
          }
  }
  
  ll k = ((pwr[ans]-1)*26LL);
  if(k==n)
  {
          for(int i=0;i<ans;i++)
          cout<<"z";
          return;
  }
 
  k/=25;
  
  n/=25;
  n-=k;
  n--;
  
  //cout<<n<<" ";
  getAns(ans,n);
  
  cout<<str;
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3620
program main
  integer :: n, i
  character(100) :: s, t
  read(*,*) n
  read(*,*) s(1:n), t(1:n)

  do i = 1, n
    write(*,'(a,a)', advance='no') s(i:i), t(i:i)
  end do
  write(*,*)


end program main

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Complex = complex<double>;
const double PI = acos(-1);

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    for (int i = 0; i < N; ++i) {
        cin >> s[i] >> t[i];
        if (i > 0)
            t[i] += t[i - 1];
    }
    string X;
    cin >> X;
    for (int i = 0; i < N; ++i) {
        if (s[i].length() != X.length())
            continue;
        bool issame = true;
        for (int j = 0; j < X.length(); ++j) {
            if (s[i][j] != X[j]) {
                issame = false;
                break;
            }
        }
        if(issame){
            cout << t[N - 1] - t[i] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int r = 0;
	int c = 0;
	scanf("%d %d", &r, &c);

	int v = 0;
	int sum = 0;
	int data[101][101] = { 0 };
	for (int i = 0; i < r; i++) {
		sum = 0;
		for (int j = 0; j < c; j++) {
			scanf("%d", &v);
			data[i][j] = v;
			sum += v;
		}
		data[i][c] = sum;
	}

	int sum2 = 0;
	for (int j = 0; j < c; j++) {
		sum = 0;
		for (int i = 0; i < r; i++) {
			sum += data[i][j];
		}
		data[r][j] = sum;
		sum2 += sum;
	}
	data[r][c] = sum2;

	for (int i = 0; i <= r; i++) {
		for (int j = 0; j < c; j++) {
			printf("%d ", data[i][j]);
		}
		printf("%d\n", data[i][c]);
	}

	return 0;
}

Measured memory_bytes: 1804
#include<cstdio>
#include<list>
#include<iostream>

using namespace std;

int main(void){
  list<long long> b;
  long long n,tmp;
  scanf("%lld",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&tmp);
    if(i%2){
      b.push_front(tmp);
    }else{
      b.push_back(tmp);
    }
  }
  if(n%2){
    b.reverse();
  }
  for(int i=0;i<n;i++){
    //long long value;
    list<long long>::iterator value = b.begin();
    cout << *value << ' ';
    b.pop_front();
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 9080
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	char grade;
	int m, f, r;
	int s;

	while (true)
	{
		scanf("%d %d %d\n", &m, &f, &r);
		if (m == -1 && f == -1 && f == -1)
			break;

		s = m + f;
		if (m == -1 || f == -1)
			grade = 'F';
		else if (s >= 80)
			grade = 'A';
		else if (s >= 65)
			grade = 'B';
		else if (s >= 50 || (s >= 30 && r >= 50))
			grade = 'C';
		else if (s >= 30)
			grade = 'D';
		else
			grade = 'F';

		printf("%c\n", grade);
	}

	return 0;
}

Measured memory_bytes: 604
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N,K,a[100];
LL dp[101][100001] = {};
LL wa[101][100002] = {};
const LL MOD = 1000000007;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> a[i];

	dp[0][0] = 1;
	for(int i=0; i<=K; i++) wa[0][i+1] = 1;
	for(int i=1; i<=N; i++){
		for(int j=0; j<=K; j++){
			dp[i][j] = wa[i-1][j+1]+2*MOD - wa[i-1][max(0,j-a[i-1])];
			dp[i][j] %= MOD;
			wa[i][j+1] = wa[i][j] + dp[i][j];
			wa[i][j+1] %= MOD;
		}
	}
	/*for(int i=0; i<=K; i++){
		for(int j=0; j<=N; j++){
			cout << dp[j][i] << " ";
		}
		cout << endl;
	}
	for(int i=0; i<=K+1; i++){
		for(int j=0; j<=N; j++){
			cout << wa[j][i] << " ";
		}
		cout << endl;
	}*/
	cout << dp[N][K] << endl;

	return 0;
}

Measured memory_bytes: 158080
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()

def main():
    R, C, K = map(int, input().split())
    R, C = C, R
    items = [[0] * R for _ in range(C)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        items[r - 1][c - 1] = v

    dp = [[0] * R for _ in range(4)]
    for i in range(1, 4):
        dp[i][0] = items[0][0]
        for r in range(1, R):
            dp[i][r] = max(dp[i][r - 1], dp[i - 1][r - 1] + items[0][r])

    for c in range(1, C):
        dp2 = [[0] * R for _ in range(4)]
        for i in range(1, 4):
            dp2[i][0] = max(dp[1][0], dp[2][0], dp[3][0]) + items[c][0]
            for r in range(1, R):
                upper = max(dp[1][r], dp[2][r], dp[3][r]) + items[c][r]
                dp2[i][r] = max(upper, dp2[i][r - 1], dp2[i - 1][r - 1] + items[c][r])
        dp = dp2

    print(dp[3][R - 1])



if __name__ == "__main__":
    main()


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

using namespace std;
using LL = long long;

int main(){
    int N,M;cin >> N >> M;
    vector<pair<LL,LL>> vec;
    for(int a = 0;a < M;a++){
        int L,R;cin >> L >> R;
        vec.push_back({L-1,R-1});
    }
    vector<LL> wa(N+1);
    for(int a = 0;a < M;a++){
        wa.at(vec.at(a).first)+=1;
        wa.at(vec.at(a).second+1)-=1;

    }
    vector<LL> ruiseki;
    ruiseki.push_back(0);
    for(int a = 0;a < N;a++){
        ruiseki.push_back(ruiseki.back() + wa.at(a));
    }
    LL ans = 0;
    for(int a = 0;a < N+1;a++){
     //   cout<<ruiseki.at(a)<<endl;
        if(ruiseki.at(a) == M)ans++;

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


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

const int MAX_N = 2e5+10;
int N;
ll A[MAX_N],B[MAX_N];

void solve()
{
	sort(A,A+N);
	sort(B,B+N);
	if(N&1){
		cout<<B[N/2]-A[N/2]+1<<'\n';
	}else{
		ll lo=A[N/2-1]+A[N/2];
		ll hi=B[N/2-1]+B[N/2];
		cout<<hi-lo+1<<'\n';
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i=0;i<N;++i) cin >> A[i] >> B[i];
	solve();
	return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	int X, Y;
	cin >> X >> Y;
	if (Y % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	rep(i, X+1) {
		int a = i * 2;
		int b = (X - i) * 4;
		if (a+b == Y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
h, w, k = map(int, input().split())
c = [input() for x in range(h)]

ans = 0

for i in range(2**h):
    for j in range(2**w):
        count = 0
        for m in range(h):
            for n in range(w):
                if (((i >> m) & 1) == 0 and ((j >> n) & 1) == 0 and c[m][n] == "#"):
                    count += 1
        if count == k:
            ans += 1
print(ans)

Measured memory_bytes: 9080
#include <stdio.h>  
  
int main(int argc, char* argv[])  
{  
  int nBinary = 0;  
  int nDigital = 1;  
  int nTemp = 0;  
  int nMark = 0;  
  int nNumber = 0;  
  int nNumberArrayOne[10000] = {0};  
  int nNumberArrayTwo[10000] = {0};  
  
  nNumberArrayOne[0] = 2;  
  nNumberArrayTwo[0] = 1;  
  
  scanf("%d", &nNumber);  
  
  for (int i = 1; i < nNumber; i++)  
  {  
    if (nMark == 0)  
    {  
      for (int j = 0; j < nDigital; j++)  
      {  
        nTemp = nNumberArrayOne[j] + nNumberArrayTwo[j] + nBinary;  
        nNumberArrayOne[j] = nTemp % 10;  
        nBinary = nTemp / 10;  
      }  
      while(nBinary)  
      {  
        nDigital++;  
        nNumberArrayOne[nDigital - 1] = nBinary % 10;  
        nBinary = nBinary / 10;   
      }  
      nMark = 1;  
    }  
    else  
    {  
      for (int j = 0; j < nDigital; j++)  
      {  
        nTemp = nNumberArrayOne[j] + nNumberArrayTwo[j] + nBinary;  
        nNumberArrayTwo[j] = nTemp % 10;  
        nBinary = nTemp / 10;  
      }  
      while(nBinary)  
      {  
        nDigital++;  
        nNumberArrayTwo[nDigital - 1] = nBinary % 10;  
        nBinary = nBinary / 10;   
      }  
      nMark = 0;  
    }  
  }  
  
  if (nMark == 0)  
  {  
    for (int k = nDigital - 1; k >= 0; k--)  
    {  
      printf("%d", nNumberArrayTwo[k]);  
    }  
    puts("");  
  }  
  else  
  {  
    for (int k = nDigital - 1; k >= 0; k--)  
    {  
      printf("%d", nNumberArrayOne[k]);  
    }  
    puts("");  
  }  
  
  return 0;  
}  


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

int main(){
    long long N, M;
    cin >> N >> M;
    long long Ans = 0;
  
    vector<double> A(N);
    priority_queue<double> P;
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }

    for(int i = 0; i < N; i++){
        P.push(A.at(i));
    }



    for(int i = 0; i < M; i++){
        double t = P.top()/2;
        P.push(t);
        P.pop();
        }

    for(int i = 0; i < N; i++){
        Ans += floor(P.top());
      P.pop();
    }

    cout << Ans << endl;

}

Measured memory_bytes: 2168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0002
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (line == null) break;

                int[] items = Array.ConvertAll(line.Split(' '), e => int.Parse(e));
                Console.WriteLine((items[0] + items[1]).ToString().Length);
            }       
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    cin >> a;
    MSG(a + a*a + a*a*a)
}


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

int main()
{
	int a,b,c;
	int i = 0;
	int count = 0;

	cin >> a >> b >> c;

	while ((a + i) <= b) {
		if (c % (a + i) == 0) {
			count++;
		}
		else {
			//何もしない
		}
		i++;
	}

	cout << count << '\n';

	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
int main(void){
    int i,x,n;
    scanf("%d",&n);
    for(i=1; i<=n; ++i){
        x=i;
    if(x%3==0){
        printf(" %d",i);
    }else{
    do{
        if(x%10==3){
            printf(" %d",i);
            break;
        }else
            x/=10;
    }while(x);
        }
    }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 600
import java.io.PrintWriter
import java.util.NoSuchElementException

var ret = Array(100){CharArray(100)}
var base = '#'
var accent = '.'

fun main(args: Array<String>) = IO().exec {
    var a = int()
    var b = int()
    if (a < b) {
        accent = base.apply { base = accent }
        a = b.apply { b = a }
    }
    for (i in 0 until 100) ret[i].fill(base)
    b--
    for (y in 0 until 100 step 4)
        for (x in 0 until 100 step 4)
            if (a-- > 0) insert(y, x, b-- > 0)
    println("100 100")
    for (y in 0 until 100) {
        for (x in 0 until 100) print(ret[y][x])
        println("")
    }
}

fun insert(y: Int, x: Int, isHole: Boolean) {
    for (i in 0..2) for (j in 0..2) ret[y+i][x+j] = accent
    if (isHole) ret[y+1][x+1] = base
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

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

int main()
{
    int N, K;
    int val = 1;
    cin >> N >> K;

    for(int i = 0; i < N; i++) {
        if(val > K) val += K;
        else val *= 2;
    }

    cout << val << endl;

    return (0);
}

Measured memory_bytes: 256
// in the name if Allah
// YA Ali!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll INF = 1<<30 ;
const ll N= 1e6 ;
#define f first
#define s second
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC optimize("O4")
#pragma GCC optimize("O5")
#pragma GCC optimize("O6")
#pragma GCC optimize("O7")
#pragma GCC optimize("O8")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
ll n ;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n ;
cout << 3 * (n * n) ;
    return 0;
}
 /*
              _     _   __
        /_\  (_    (_)  __)
       /   \  _) . (_) (__
 */


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
q=int(input())
ql=[]
for i in range(q):
  ql.append(list(map(int,input().split())))

cnt={}
for i in a:
  if i in cnt:
    cnt[i]+=1
  else:
    cnt[i]=1
s=0
for i in cnt:
  s+=i*cnt[i]
  
for i in ql:
  if i[0] in cnt:
    s+=(i[1]-i[0])*cnt[i[0]]
    if i[1] in cnt:
      cnt[i[1]]+=cnt[i[0]]
    else:
      cnt[i[1]]=cnt[i[0]]
    cnt[i[0]]=0
  print(s)

Measured memory_bytes: 99976
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class UnionFind {
private:
	vector<P> par; // 親（根の時は自分自身）
	vector<int> rank; // ランク
public:
	UnionFind(int n) {
		for (int i = 0;i < n;i++) {
			par.push_back(P(i, 1));
			rank.push_back(0);
		}
	}
	int root(int x) {
		if (par[x].first == x) return x;
		else return par[x].first = root(par[x].first);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[y].second += par[x].second;
			par[x] = par[y];
		}
		else {
			par[x].second += par[y].second;
			par[y] = par[x];
		}
		if (rank[x] == rank[y]) rank[x]++;
	}
	int get(int x) {
		x = root(x);
		return par[x].second;
	}
};

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

	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	vector<UnionFind> uf_w(H, UnionFind(W));
	vector<UnionFind> uf_h(W, UnionFind(H));
	
	REP(i, H) {
		cin >> S[i];
		FOR(j, 1, W) {
			if (S[i][j] == '.' && S[i][j - 1] == '.') {
				uf_w[i].unite(j, j - 1);
			}
		}
	}
	
	REP(j, W) {
		FOR(i, 1, H) {
			if (S[i][j] == '.' && S[i - 1][j] == '.') {
				uf_h[j].unite(i, i - 1);
			}
		}
	}
	int res = 0;
	REP(i, H) {
		REP(j, W) {
			res = max(res, uf_w[i].get(j) + uf_h[j].get(i));
		}
	}
	cout << res - 1 << endl;

	return 0;
}


Measured memory_bytes: 98560
lst1 = list(input())
lst2 = list(input())
new_lst1 = []
new_lst2 = []

for i in range(3):
    new_lst1.extend(lst2[2-i])
    new_lst2.extend(lst1[2-i])
if new_lst1==lst1 and new_lst2==lst2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
  string o;
  string e;
  cin >> o >> e;
  for(int i = 0; i < o.size(); i++){
    cout << o[i];
    if(i < e.size()) cout << e[i];
  }
  cout << endl;
  return 0;
}


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

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef map<int, int> MII;

const int SZ = 112345;
const int MOD = 1e9 + 7;

string s, t, u;

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


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

int main() {
	int n, k, x, ans = 0; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x;
		ans += min(x, k - x);
	}
	cout << ans * 2 << endl;
}

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

int main() {
  int n;
  int a[2][110];

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

  int sum = a[0][0];
  for (int i=0; i<n; i++) {
    sum += a[1][i];
  }
  int ans = sum;

  for (int i=1; i<n; i++) {
    sum += a[0][i] - a[1][i-1];
    ans = max(sum,ans);
  }

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

Measured memory_bytes: 256
map{/ /,push@{$`},$' for<>;map$q[$_]+=$q[$N]/@$N,@{$N=$_}}++$q[1]..<>;while(--$N){$s=0;$s+=$_ for@E=@e[@$N];$e[$N]=1+$s/@$N;$a<($t=$q[$N]*=$#$N&&($s-(sort@E)[-1])/$#$N-$s/@$N)or$a=$t}print"@e"+$a

Measured memory_bytes: 42368
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <functional>
using namespace std;

typedef long long ll;
const ll InF = 1e15;
const int IntInf = 1e5;

string d[3] = {"3","5","7"};

ll dfs(string s, ll N) {
  if (stoll(s) > N) return 0;
  ll ret;
  ret = 0;
  bool flag3,flag5,flag7;
  flag3 = flag5 = flag7 = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i]=='3') flag3 = true;
    if (s[i]=='5') flag5 = true;
    if (s[i]=='7') flag7 = true;
  }
  if (flag3 && flag5 && flag7) ret++;
  for (int i = 0; i < 3; i++) ret += dfs(s+d[i],N);
  return ret;
}

int main() {
  ll N;
  cin>>N;
  ll ans = dfs("0",N);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}

object Main {
  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ) {
      val y = readInt.toDouble
      val rate = {
        for(i <- 1 to n) yield {
          val s = readLine.split(" ")
          if(s(2).toInt ==1) (s(0),1+y*s(1).toDouble/100)
          else (s(0), Math.pow(1+s(1).toDouble/100,y))
        }
      }.toList.maxBy(_._2)
      println(rate._1)
    }
  }
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

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

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// 参考: https://drken1215.hatenablog.com/entry/2019/06/29/182300

class UnionFind{
private:
  vector<int> Parent; 
public:  
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    
    if(size(A) < size(B)) swap(A, B);
    
    Parent[A] += Parent[B];
    Parent[B] = A;
    
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,k,l; cin>>n>>k>>l;
  
  UnionFind uf1(n), uf2(n);
  rep(i,k){
    int a,b; cin>>a>>b; a--,b--;
    uf1.connect(a,b);
  }
  rep(i,l){
    int a,b; cin>>a>>b; a--,b--;
    uf2.connect(a,b);
  }
  
  map<pii, int> m;
  rep(i,n){
    // ある2頂点について道路側のグループの根と線路側のグループの根が一致する -> 道路でも線路でも連結
    pii p(uf1.root(i), uf2.root(i)); 
    m[p]++;
  }
  rep(i,n){
    pii p(uf1.root(i), uf2.root(i));
    cout<<m[p];
    if(i==n-1) cout<<endl;
    else cout<<" ";
  }
}


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vll>;
df data(n, vll(m));
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/range/algorithm.hpp> // boost::sort(arr)
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
using boost::algorithm::join; // string s = join(arr, "");
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

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


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline


def main():
    H, W = map(int, readline().split())
    S = read().split()

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    U = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]

    for i in range(H):
        c = 0
        for j in range(W):
            if S[i][j] == '#':
                c = 0
            else:
                L[i][j] = c
                c += 1
        c = 0
        for j in range(W - 1, -1, -1):
            if S[i][j] == '#':
                c = 0
            else:
                R[i][j] = c
                c += 1

    for j in range(W):
        c = 0
        for i in range(H):
            if S[i][j] == '#':
                c = 0
            else:
                U[i][j] = c
                c += 1
        c = 0
        for i in range(H - 1, -1, -1):
            if S[i][j] == '#':
                c = 0
            else:
                D[i][j] = c
                c += 1

    ans = 0
    for i in range(H):
        l, r, u, d = L[i], R[i], U[i], D[i]
        for j in range(W):
            if ans < l[j] + r[j] + u[j] + d[j] + 1:
                ans = l[j] + r[j] + u[j] + d[j] + 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 203820
#include <iostream>
#include <vector>
#define INF 1e+9
using namespace std;

int main(){
	int w,h,n;
	vector<int> vec[100010];
	cin >> w >> h >> n;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		vec[x].push_back(y);
	}
	int ma = 0,mi = INF;
	for(int i = w - 1;i >= 0;i--){
		mi = min(mi,ma + i);
		for(int v : vec[i]) ma = max(ma,v);
	}
	cout << mi << endl;
	return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 998244353;
const int INF = 1e8;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

int k, n;
int a[MAXN];

int main() {
	setIO();

    cin >> k >> n;
    FOR(i, 0, n-1) cin >> a[i];

    int ans = 1e9;
    FOR(i, 0, n-2) ans = min(ans, k-(a[(i+1)%n]-a[i]));
    ans = min(ans, k - (k-a[n-1]+a[0]));
    cout << ans;

	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
	int N,M;
  get(N,M);
	vector<vector<int>> dist(N,vector<int>(N,1<<29));
    vector<vector<int>> used(N,vector<int>(N));
  FOR(i,M){
    int a,b,c;
    get(a,b,c);
    a--;b--;
    dist[a][b]=c;
    dist[b][a]=c;
    used[a][b]=1;
    used[b][a]=1;
  }
  vector<vector<int>> next(N,vector<int>(N));
  FOR(i,N){
    FOR(j,N){
      next[i][j]=j;
    }
  }
  FOR(k,N){
    FOR(i,N){
      FOR(j,N){
        if(dist[i][j]>dist[i][k]+dist[k][j]){
          dist[i][j]=dist[i][k]+dist[k][j];
          next[i][j]=next[i][k];
        }
      }
    }
  }debug(dist,next);

  FOR(i,N){
    FOR(j,N){
      if(i==j)continue;
      int s;
      for(s=i;next[s][j]!=j;s=next[s][j]){
        debug(i,j,s);
        used[s][next[s][j]]=0;
        used[next[s][j]][s]=0;
      }
      used[s][next[s][j]]=0;
      used[next[s][j]][s]=0;
    }
  }
  int ans=0;
  FOR(i,N){
    FOR(j,N){
      if(used[i][j])ans++;
    }
  }
  print(ans/2);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  while(x!=0 || y!=0){
    if(x>=y)
      cout<<y<<" "<<x<<"\n";
    else
      cout<<x<<" "<<y<<"\n";
    cin>>x>>y;
  }
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
	public static void main (String[] args){
		
		int big=0, min=0, half=0;
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		if(a>b && a>c){
			big = a;
			if(b>c){
				half = b;
				min = c;
			}else{
				half = c;
				min = b;
			}
		}
		if(a<b && b>c){
			big = b;
			if(a>c){
				half = a;
				min = c;
			}else{
				half = c;
				min = a;
			}
		}
		if(a<c && c>b){	
			big = c;
			if(a>b){
				half = a;
				min = b;
			}else{
				half = b;
				min = a;
			}
		}
		System.out.println(min+" "+half+" "+big);
	}
}

Measured memory_bytes: 17228
n = int(input())

p = list(map(float, input().split( )))

dp = [[0]*(n+1) for _ in range(n)]
#０が裏、1が表
#dp[枚数][表の枚数]
dp[0][0] = 1-p[0]
dp[0][1] = p[0]

for i in range(1,n):
    for d in range(i+2):###+2
        dp[i][d] = p[i]*dp[i-1][d-1]+(1-p[i])*dp[i-1][d]
   
ans = sum(dp[n-1][n//2+1:])

print(ans)

Measured memory_bytes: 262536
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;

    public static void main(String[] args) {
        int N = nint();
        long[] T = nlongs(1, N, 1);
        long[] A = nlongs(1, N, 1);
        T[N + 1] = T[N];
        A[0] = A[1];
        
        long ans = 1;
        for (int i = 1; i <= N; i++) {
            if (T[i-1] < T[i] && A[i] < T[i]) {
                System.out.println(0);
                return;
            }
            
            if (A[i] > A[i+1] && A[i] > T[i]) {
                System.out.println(0);
                return;
            }
            
            if (T[i-1] < T[i] || A[i] > A[i+1]) {
                // 山iの高さは1通り
                
            } else {
                ans *= min(T[i], A[i]);
                ans %= MOD;
            }
        }
        System.out.println(ans);
    }

    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(0, N, 0);
    }

    @Deprecated
    private static int[] nints(int padL, int N, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(0, N, 0);
    }

    static long[] nlongs(int padL, int N, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(0, N, 0);
    }

    static double[] ndoubles(int padL, int N, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 88820
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,c=0;
    char s[10];
    scanf("%s",s);
    for(i=0;i<2;i++)
    {
        if(s[i]==s[i+1]||s[i]==s[i+2])
        {
            c++;
        }
    }
    if(c==1)
    {
        printf("Yes\n");
    }
    else printf("No\n");
}


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

using pll=pair<long long,long long>;
bool cmp(pll a,pll b){
    return a.second<b.second;
}

int N;
vector<pll> v;

int main(){
    cin>>N;
    v.resize(N);
    for (int i=0;i<N;i++)cin>>v[i].first>>v[i].second;
    sort(v.begin(),v.end(),cmp);
    bool ok=true;
    long long sum=0;
    for(int i=0;i<N;i++){
        sum+=v[i].first;
        if(sum>v[i].second)ok=false;

    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    string lh = s.substr(0, n), rh = s.substr(n, n);
    reverse(rh.begin(), rh.end());

    using P = tuple<string, string>;
    vector<P> ss;
    rep(i, 1 << n)
    {
        string a, b;
        rep(j, n)
        {
            if (((i >> j) & 1) == 1) {
                a.push_back(rh[j]);
            } else {
                b.push_back(rh[j]);
            }
        }
        ss.push_back(P(a, b));
    }
    sort(ss.begin(), ss.end());

    int64_t result = 0;
    rep(i, 1 << n)
    {
        string a, b;
        rep(j, n)
        {
            if (((i >> j) & 1) == 1) {
                a.push_back(lh[j]);
            } else {
                b.push_back(lh[j]);
            }
        }
        P key = P(a, b);
        result += upper_bound(ss.begin(), ss.end(), key) - lower_bound(ss.begin(), ss.end(), key);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 35820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX_N = 200010;

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

vector<int> par;
vector<int> rnk;

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

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) par[x] = y;
    else{
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}


typedef pair<int, int> P;
P group[MAX_N];
map<P, int> cnt;

int main(){
    int n, k, l;
    cin >> n >> k >> l;
    
    init(n);
    for (int i = 0; i < k; i++){
        int p, q;
        cin >> p >> q;
        unite(p - 1, q - 1);
    }

    for (int i = 0; i < n; i++){
       group[i].first = find(i); 
    }

    init(n);
    for (int i = 0; i < l; i++){
        int r, s;
        cin >> r >> s;
        unite(r - 1, s - 1);
    }

    int i;
    REP(i, n) group[i].second = find(i);

    REP(i, n) cnt[group[i]]++;

    REP(i, n){
        if (i != 0) cout << " ";
        cout << cnt[group[i]];
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 15136
n,k=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort(reverse=True)
F.sort()
ng=-1
ok=10**12
while ok-ng>1:
    mid=(ok+ng)//2
    temp=0
    flag=0
    for i in range(n):
        a=mid//F[i]
        if a>A[i]:
            continue
        else:
            temp+=A[i]-a
    if temp>k:
        flag=1
    if flag:
        ng=mid
    else:
        ok=mid

print(ok)

Measured memory_bytes: 119500
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int m;
  cin>>m;
  vector<Int> b(m);
  for(Int i=0;i<m;i++) cin>>b[i];
  cout<<(a<b)<<endl;
  return 0;
}



Measured memory_bytes: 3088
a, b = map(int, input().split())
n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)])
line = [0]*1010
line[a] += 1
line[b] -= 1
for a, b in l:
    line[a] += 1
    line[b] -= 1
for i in range(1006):
    line[i+1] += line[i]
if line.count(2):
    print(1)
else:
    print(0)


Measured memory_bytes: 5612