akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template<int MOD>
struct ModInt {
  ll x;
  ModInt():x(0){}
  ModInt(ll x):x((x%MOD+MOD)%MOD){}
  int getMod() { return MOD; }
  ModInt operator-() const { return ModInt(0) - *this;}
  ModInt& operator+=(const ModInt& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator-=(const ModInt& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator*=(const ModInt& a){ (x*=a.x)%=MOD; return *this;}
  ModInt operator+(const ModInt& a)const{ return ModInt(*this) += a;}
  ModInt operator-(const ModInt& a)const{ return ModInt(*this) -= a;}
  ModInt operator*(const ModInt& a)const{ return ModInt(*this) *= a;}
  bool operator<(const ModInt& a)const{ return x < a.x;}
  bool operator==(const ModInt& a)const{ return x == a.x;}
  ModInt pow(ll t) const {
    if (!t) return 1;
    ModInt a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  friend istream & operator >> (istream & in, ModInt & v) {
    ll x;
    in >> x;
    v.x = x;
    return in;
  }
  friend ostream & operator << (ostream & out, ModInt<MOD> const & v) {
    out << v.x;
    return out;
  }
};
const int MOD = 998244353;
using mint = ModInt<MOD>;

template<class T> struct BiCoef {
  vector<T> fact_, inv_, finv_;
  constexpr BiCoef() {}
  constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
    init(n);
  }
  constexpr void init(int n) noexcept {
    int MOD = fact_[0].getMod();
    fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
    for(int i = 2; i < n; i++){
      fact_[i] = fact_[i-1] * i;
      inv_[i] = -inv_[MOD%i] * (MOD/i);
      finv_[i] = finv_[i-1] * inv_[i];
    }
  }
  constexpr T perm(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return com(n, k) * fact(k);
  }
  constexpr T com(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return fact_[n] * finv_[k] * finv_[n-k];
  }
  constexpr T fact(int n) const noexcept {
    if (n < 0) return 0;
    return fact_[n];
  }
  constexpr T inv(int n) const noexcept {
    if (n < 0) return 0;
    return inv_[n];
  }
  constexpr T finv(int n) const noexcept {
    if (n < 0) return 0;
    return finv_[n];
  }
};


int main() {
  ll n,m,k; cin >> n >> m >> k;
  BiCoef<mint> bc(2*n);
  mint ans = 0;
  loop(i,0,k+1) {
    ans += mint(m) * mint(m-1).pow(n-i-1) * bc.com(n-1, i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12672
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint N,D;
    cin >> N >> D;
    lint d[N];
    rep(i,N) cin >> d[i];
    lint dis[N+1]={};
    dis[0]=D;
    for(int i=1;i<=N;i++) dis[i]=min(dis[i-1],llabs(dis[i-1]-d[i-1]));
    lint able[N+1]={};
    able[N]=1;
    for(int i=N-1;i>=0;i--){
        if(able[i+1]<=d[i]/2) able[i]=able[i+1];
        else able[i]=able[i+1]+d[i];
    }
    int Q;
    cin >> Q;
    rep(i,Q){
        int q;
        cin >> q;
        if(able[q]<=dis[q-1]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 13696
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <iomanip>
using namespace std;

const int MAX_N = 1e2 + 2, MAX_K = 1e5 + 5;
int n, k;
int a[MAX_N];
bool dp[MAX_K];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 1; i <= k; i++) {
		for (int j = 0; j < n; j++)
			if (a[j] <= i && !dp[i - a[j]])
				dp[i] = true;
	}

	if (dp[k])
		cout << "First\n";
	else
		cout << "Second\n";
	return 0;
}

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

using namespace std;

long long a, b, c, k;

int main()
{
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	if(k%2==0) printf("%lld", a-b);
	else printf("%d", b-a);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    int n;
    int a[100000+100];
    int b[100000+100];
    while(cin>>n){
        memset(b,-1,sizeof(b));
        for(int i=1;i<=n;i++){
            cin>>a[i]; b[i]=0;
        }
        int flag=0; int k=0;
        int i=1;
        while(1){
            if(b[i]==0){
                b[i]=1; k++;
                i=a[i];
                if(i==2){
                  flag=1; break;
                }
            }
            else if(b[i]==1){
                flag=0; break;
            }
        }
        if(flag==0)
            cout<<-1<<endl;
        else
            cout<<k<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
n,k = map(int, input().split())
tele = [0] + list(map(int, input().split()))
move = [-1]*(n+1)
move[1] = 0
now = 1
cnt = 0

while True:
    cnt += 1#移動回数
    now = tele[now] #移動した先

    if move[now] != -1:#探索済みなら周期を計算しbreak
        cycle = cnt - move[now]
        break
    else:
        move[now] = cnt#未探索ならこれまでの移動回数を記録
#この時cntに格納されている数は周期が起こった直後    
notCycle = move[now]
#ループが発生する前の場合
if notCycle > k:
    now = 1
    for i in range(k):
        now = tele[now]
#ループが発生する場合
else:
    loop = (k-notCycle)%cycle#ループが起こった余り
    for i in range(loop):
        now = tele[now]
print(now)

Measured memory_bytes: 32300
#include <cstdio>
#include <algorithm>

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

using namespace std;

int n;
bool x[30][50];
int dp[31][50][50];

int main(){
	while(scanf("%d", &n), n){
		rep(i, n){
			int f;
			scanf("%d", &f);
			rep(j, f){
				int a;
				scanf("%d", &a);
				x[a - 1][i] = true;
			}
		}

		rep(a, 31){
			rep(i, n){
				rep(j, n){
					dp[a][i][j] = -1;
				}
			}
		}
		rep(i, n){
			dp[0][i][i] = 0;	
		}

		for(int a = 1; a <= 30; ++a){
			rep(i, n){
				rep(j, n){
					if((dp[a][i][j] = dp[a - 1][i][j]) != -1){
						continue;
					}
					rep(k, n){
						if(dp[a][i][j] == -1 && dp[a - 1][i][k] != -1 && x[a - 1][k] && x[a - 1][j]){
							dp[a][i][j] = a;
							break;
						}
					}
				}
			}
		}

		int ans = 31;
		rep(i, n){
			int t = 0;
			rep(j, n){
				if(dp[30][j][i] != -1){
					t = max(dp[30][j][i], t);
				}
				else{
					t = 31;
					break;
				}
			}
			ans = min(t, ans);
		}
		printf("%d\n", ans != 31 ? ans : -1);

		rep(i, 30){
			rep(j, n){
				x[i][j] = false;
			}
		}
	}
	return 0;
}

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

ll abs(ll a, ll b){
    if (a>b) return a-b;
    else return b-a;
}


int main(){
    ll x,y;cin >>x>>y;
    if (abs(x,y)>=2) cout << "Alice"<<"\n";
    else cout << "Brown"<<"\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

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

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll X,Y;cin >> X >> Y;
  if(X%Y==0)cout << -1 << endl;
  else if(Y==998244353) cout << 2*X << endl;
  else cout << X*998244353 << endl;
  return 0;
}


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

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

    int first = stoi(s.substr(0,2));
    int second = stoi(s.substr(2));

    if (0<first && first <=12) {
        if (0 < second && second <= 12)
            cout << "AMBIGUOUS" << endl;
        else
            cout << "MMYY" << endl;
    }
    else {
        if (0 < second && second <= 12)
            cout << "YYMM" << endl;
        else
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
//#include <cstdio>
//#include <map>
//#include <cmath>
#include <vector>
using  namespace std;
int main() {
    int  m,n;
    cin>>m>>n;
    if(m==n)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int k;
string s;

int main()
{
    _FastIO;

    cin >> k;
    int a = k / 2;
    int b = a + k % 2;
    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3616
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()
L = LI()
L.sort()

print('Yes' if L[-1] < sum(L[:-1]) else 'No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll solve(ll n)
{
    ll ans = 0;
    while(n!=0)
    {

        ans += n%10;
        n/=10;
    }
    return ans;
}
int main()
{
    string s;
    cin>>s;
    int cnt = 0;
    for(int i =0;i<3;i++)
    {
        if(s[i]=='1') cnt++;
    }
    cout<<cnt;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  /////入力部/////
  int N; //総数
  int POINT=1; //POINT
  int sum_norm; //金額の合計
  
  cin >> N >> sum_norm; //総数と金額を代入
  
  for(int i=0;i<N+1;i++){ //一万円のところ
    if(sum_norm<10000*i)break;
    int sum_ans=0;
    for(int j=0;j<N+1;j++){ //五千円のところ
      ///// 計算部 /////
      sum_ans = 10000*i + 5000*j + 1000*(N-i-j);
      
      //cout<< sum_ans <<endl;
      ///// 判定部と出力部 /////
      if(sum_ans == sum_norm and N>=i+j){
        cout << i<<" " << j<<" " << (N-i-j) << endl;//正解のみ
        POINT =0;
        break;
      }
      if(i+j>N)break;//間違っているときのみ
    }
  
  if(POINT!=1){
    break;
  }
    
  }
  if(POINT) cout << -1<<" " << -1<<" " << -1 << endl;
}
      
      
    
  


Measured memory_bytes: 3612
import java.util.Scanner;

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

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            int v = A[i];
            int j = i - 1;
            while (j >= 0 && A[j] > v) {
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = v;

            println(A);
        }

        sc.close();
    }

    private static void println(int[] A) {
        int N = A.length;
        String[] sb = new String[N];
        for (int i = 0; i < N; i++) {
            sb[i] = String.valueOf(A[i]);
        }
        System.out.println(String.join(" ", sb));
    }
}


Measured memory_bytes: 29192
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll N,M,K;
  cin>>N>>M;
  K=pow(2,M);
  cout<<(N*100+M*1800)*K<<endl;
  return 0;
}

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

typedef long long ll;

ll X;
const ll L = 300;

int main() {
  cin >> X;
  for (ll a = -L; a <= L; ++a) {
    for (ll b = -L; b <= L; ++b) {
      if (a * a * a * a * a - b * b * b * b * b == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3628
n,x = map(int,input().split())
a = list(sorted(list(map(int,input().split()))))
ans = 0
for i in range(n+1):
  if i == n:
    if x > 0:
      ans -= 1
  elif x > a[i]:
    x -= a[i]
    ans += 1
  elif x == a[i]:
    ans += 1
    x -= a[i]
  else:
    break
print(ans)

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

const int MOD = 1000000007;
int fact[2005] = {1, 1};

int mul(int a, int b, int m)
{
	int r = 0;
	a %= m, b %= m;
	while (b) {
		if (b&1) r = (r+a)%m;
		a = (a<<1)%m;
		b >>= 1;
	}
	return r;
}

int pwr(int b, int e, int m)
{
	if (e == 0) return 1;
	if (e == 1) return b%m;
	return mul(pwr(mul(b, b, m), e/2, m), (e&1)?b:1, m);
}

int inv(int a, int m)
{
	return pwr(a, m-2, m);
}

int add(int a, int b, int m)
{
	a %= m, b %= m;
	return (a+b)%m;
}

int sub(int a, int b, int m)
{
	a %= m, b %= m;
	return (a-b+m)%m;
}

int main()
{
	int s;
	scanf("%d", &s);
	for (int i = 2; i <= s; ++i) fact[i] = mul(i, fact[i-1], MOD);
	int a = 0;
	for (int i = 1; i*3 <= s; ++i) a = add(a, mul(fact[s-2*i-1], mul(inv(fact[s-3*i], MOD), inv(fact[i-1], MOD), MOD), MOD), MOD);
	printf("%d\n", a);
}

Measured memory_bytes: 3812
import java.util.*;
import java.util.stream.*;
import java.io.*;

class Ele {
  int ori;
  int idx;

  Ele(int ori, int idx){
    this.ori = ori;
    this.idx = idx;
  }
}

class Graph {
  public ArrayList< ArrayList<Integer> > adjacency;

  Graph(int n){
    adjacency = new ArrayList< ArrayList<Integer> >();
    for(int i = 0; i < n; i++){
      adjacency.add(new ArrayList<Integer>());
    }
  }

  public void add_edge(int from, int to, boolean is_directed){
    adjacency.get(from).add(to);
    if(!is_directed){
      adjacency.get(to).add(from);
    }
  }
}


public class Main {
  
  static final int INF = 1000000001;

  static int n;
  static int[] a, lis, ans;
  static boolean[] seen;

  static Deque<Ele> st = new ArrayDeque<>();

  static Graph g;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);

    g = new Graph(n);

    in = br.readLine().split(" ");
    a = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    for(int i = 0; i < n-1; i++){
      in = br.readLine().split(" ");
      g.add_edge(Integer.parseInt(in[0]) - 1, Integer.parseInt(in[1]) - 1, false);
    }

    br.close();

    lis = new int[n+1];
    ans = new int[n];
    seen = new boolean[n];

    Arrays.fill(lis, INF);
    lis[0] = -INF;

    dfs(0, 0);

    PrintWriter out = new PrintWriter(System.out);

    for(int i = 0; i < n; i++){
      out.println(ans[i]);
    }
    out.flush();
  }

  static int binarySearch(int x, int maxIdx){
    int left = 0; int right = maxIdx + 1;
    while(right - left > 1){
      int mid = (right + left) / 2;
      if(lis[mid] < x) left = mid;
      else right = mid;
    }
    st.push(new Ele(lis[right], right));
    lis[right] = x;
    
    return right;
  }

  static void dfs(int now, int idx){
    
    idx = Math.max(idx, binarySearch(a[now], idx));

    ans[now] = idx;
    seen[now] = true;

    for(int nex : g.adjacency.get(now)){
      if(seen[nex]) continue;
      dfs(nex, idx);
    }

    Ele forRet = st.poll();
    lis[forRet.idx] = forRet.ori;
    
    return;
  }

}

Measured memory_bytes: 113520
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
bool isPrime(ll x) {if (x == 2) return true;if (x < 2 || x % 2 == 0) return false;ll i = 3;while (i <= sqrt(x)) {if (x%i == 0) return false;i += 2;}return true;}

void solve() {
	string S;
	cin >> S;
	set<string> box;
	REP(i, S.size()) {
		string up = S.substr(0, i + 1);
		string down = S.substr(i + 1);
		string rup = up, rdown = down;
		reverse(beginend(rup));
		reverse(beginend(rdown));
		box.insert(up + down);
		box.insert(up + rdown);
		box.insert(down + up);
		box.insert(rdown + up);
		box.insert(rup + down);
		box.insert(rup + rdown);
		box.insert(down + rup);
		box.insert(rdown + rup);
	}
	out(box.size());
}

int main() {
	int m;
	cin >> m;
	REP(i, m) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3192
def East(a,b,c,d,e,f):
    return [d, b, a, f, e, c]
def West(a,b,c,d,e,f):
    return [c, b, f, a, e, d]
def South(a,b,c,d,e,f):
    return [e, a, c, d, f, b]
def North(a,b,c,d,e,f):
    return [b, f, c, d, a, e]
def Rot(a,b,c,d,e,f):
    return [a,d,b,e,c,f]



def Judge(change, change_after):
    flag=0
    for idx in range(0, 5):
        change=South(*change)
        #print(change)
        if change==change_after:
            flag=flag+1
        for idx2 in range(0,4):
            change=Rot(*change)
            #print(change)
            if change==change_after:
               flag=1+flag
               
    for idx in range(0, 5):
        change=West(*change)
        #print(change)
        if change==change_after:
            flag=flag+1
        for idx2 in range(0,4):
            change=Rot(*change)
            #print(change)
            if change==change_after:
               flag=1+flag
    return flag
    
n=int(input())
matrix=[]
for i in range(0, n):
    change=list( map(int,input().split()))
    matrix.append(change)
    #change_after=list( map(int,input().split()))

judge_number=0
for i in range(0, n-1):
    change=matrix[i]
    for j in range(i+1, n):
        change_after=matrix[j]
        judge_number=Judge(change, change_after)+judge_number
       

if judge_number==0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5608
N, M = gets.split.map(&:to_i)

a = Array.new(N + 1, 0)
pt, pn = 0, 0
M.times do
  p, s = gets.split
  p = p.to_i
  next if a[p] == -1
  if s == 'AC'
    pn += a[p]
    pt += 1
    a[p] = -1
  elsif s == 'WA'
    a[p] += 1
  end
end
puts "#{pt} #{pn}"

Measured memory_bytes: 2556
import java.util.*;
 
class Main {
  
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer moti[] = new Integer[N];
        int co = 1;
      
      for(int i=0;i<N;i++){
        moti[i] = Integer.parseInt(sc.next());
      }
		Arrays.sort(moti, Collections.reverseOrder());
      
      for(int i= 1;i<N;i++){
        if(moti[i-1]>moti[i]){co++;}
      }

		System.out.print(co);
    }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;
int const N_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  if (!po[n]) {
    po[0] = 1;
    FOR(i, 1, n + 1) po[i] = po[i - 1] * i % MOD;
  }
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int N, M;
int s[11][11];
int k[11];
int ps[11];

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

  rep(i, M) {
    scanf("%d", &k[i]);
    rep(j, k[i]) {
      scanf("%d", &s[i][j]);
    }
  }
  rep(i, M) scanf("%d", &ps[i]);

  int p = pow(2, N);
  ll count = 0;
  FOR(i, 1, p + 1) {
    bool ok = true;
    rep(j, M) {
      int ks = k[j];
      int cnt = 0;
      rep(l, ks) {
        if (i & (1 << (s[j][l] - 1))) cnt++;
      }
      int pv = ps[j];
      if (cnt % 2 != pv) {
        ok = false;
        break;
      }
    }
    if (ok) count++;
  }
  printf("%lld\n", count);
}


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

int main() {
    int n; cin >> n;
    vector<int> data(1<<n);
    for (int i = 0; i < (1<<n); i++) cin >> data[i];
    sort(data.begin(), data.end());
  
    vector<int> check;
    check.push_back(*data.rbegin());
    multiset<int> mst;
    for (int i = 0; i < (1<<n) - 1; i++) mst.insert(data[i]);
    for (int i = 0; i < n; i++) {
        vector<int> add;
        for (int j = 0; j < (1<<i); j++) {
            int ch = check[j];
            auto iter = mst.lower_bound(ch);
            if (iter == mst.begin()) {
                cout << "No" << endl;
                return 0;
            }
            iter = prev(iter);
            add.push_back(*iter);
            mst.erase(iter);
        }
        for (int j = 0; j < (1<<i); j++) check.push_back(add[j]);
        sort(check.begin(), check.end(), greater<int>());
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 16732
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
 cout<<n*n;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
 //  cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,M;
  cin>>A>>B>>M;
  vector<int> a(A);
  for(int i=0;i<A;i++)
    cin>>a.at(i);
  vector<int> b(B);
  for(int i=0;i<B;i++)
    cin>>b.at(i);
  vector<vector<int>> c(M,vector<int>(3));
  for(int i=0;i<M;i++){
    for(int j=0;j<3;j++)
      cin>>c.at(i).at(j);
  }
  long long min=a.at(0)+b.at(0);
  for(int i=0;i<M;i++){
    if(a.at(c.at(i).at(0)-1)+b.at(c.at(i).at(1)-1)-c.at(i).at(2)<min)
      min=a.at(c.at(i).at(0)-1)+b.at(c.at(i).at(1)-1)-c.at(i).at(2);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(a.at(0)+b.at(0)<min)
    min=a.at(0)+b.at(0);
  cout<<min<<endl;

}


Measured memory_bytes: 9596
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn abc(n: usize, k: usize, x: Vec<i64>) -> i64 {
    let mut result = 1 <<60;
    for i in (0..n-k+1) {
        let left = x[i];
        let right = x[i+k-1];
        let tmp1 = (left - 0).abs() + (left - right).abs();
        let tmp2 = (right - 0).abs() + (left - right).abs();
        result = min(result, min(tmp1, tmp2));
    }
    return result;
}


fn main() {
    /*
    assert_eq!(abc(), "Yes");
    assert_eq!(abc(101), "No");
    assert_eq!(abc(999999999), "Yes");
    */
    input!{
        n: usize,
        k: usize,
        x: [i64; n],
    }
    let result = abc(n, k, x);

    println!("{}", result);
}



Measured memory_bytes: 4352
#include<stdio.h>

void maxHeapify(int);

int h[200000000],n;
int main(){
  int i;

  scanf("%d",&n);

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

  for(i=n/2;i>=1;i--){
    maxHeapify(i);
  }

  for(i=1;i<=n;i++){
    printf(" %d",h[i]);
  }

  printf("\n");

  return 0;
}

void maxHeapify(int i){
  int l,r,largest,temp;

  l=i*2;
  r=i*2+1;

  if(l<=n&&h[i]<h[l])largest=l;
  else largest=i;
  if(r<=n&&h[largest]<h[r])largest=r;

  if(largest!=i){
    temp=h[i];
    h[i]=h[largest];
    h[largest]=temp;
    maxHeapify(largest);
  }
}
  



Measured memory_bytes: 3700
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
    cnt = 1
else :
    for i in range(A):
        for j in range(A):
            if  S - (i + j) <= K :
                if 0 <= S - (i + j): 
                    cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int a, b;
 cin >> a >> b;
 if(a<=9&&b<=9) cout << a*b;
 else cout << -1;
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            String S = in.next();

            int[][] dp = new int[3][1000];
            for (int i = 0; i < N; i++) {
                int c = S.charAt(i) - '0';
                for (int j = 0; j < 100; j++) {
                    dp[2][j * 10 + c] = dp[1][j];
                }
                for (int j = 0; j < 10; j++) {
                    dp[1][j * 10 + c] = dp[0][j];
                }
                dp[0][c] = 1;
            }

            int ans = 0;
            for (int i = 0; i < 1000; i++) {
                ans += dp[2][i];
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24260
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
x, y = M()
if x < y:
    print('<')
elif x > y:
    print('>')
else:
    print('=')

Measured memory_bytes: 73948
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
#define MOD 1000000007
using namespace std;

int main() {
	int n;
	int ans = 0;
	cin >> n;
	vector<int>l(2 * n);
	REP(i, 2 * n) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	REP(i, n) {
		ans += l[2 * i];
	}
	cout << ans << endl;
	return 0;
}

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

const int INF = 1 << 28;

int main ()
{
    int n, m, s, g1, g2;
    while (cin >> n >> m >> s >> g1 >> g2, n + m + s + g1 + g2) {
        vector<vector<int> > d(n + 1, vector<int>(n + 1, INF));
        for (int i = 0; i <= n; i++) {
            d[i][i] = 0;
        }
        for (int i = 0; i < m; i++) {
            int gx, gy, c;
            cin >> gx >> gy >> c;
            d[gx][gy] = c;
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                for (int  k = 1; k <= n; k++) {
                    d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
                }
            }
        }

        int res = INF;
        for (int i = 1; i <= n; i++) {
            res = min(res, d[s][i] + d[i][g1] + d[i][g2]);
        }

        cout << res << endl;
    }

    return 0;
}

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

int main()
{
    int i, j;
    int n;

    cin >> n;
    vector<int> v(n);

    rep(i, n) cin >> v[i];
    int average = round(accumulate(v.begin(), v.end(), 0) / (float)n);

    int answer = 0;
    rep(i, n) answer += (int)pow(v[i] - average, 2);

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;int l;
int main()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	private static boolean isPalindrome(String s){
		int n = s.length();
		for(int i=0;i<n/2;i++){
			if(s.charAt(i) != s.charAt(n-i-1)) return false;
		}
		return true;
	}

	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(br.ready()){
			String s = br.readLine().toUpperCase().replaceAll("[^A-Z]","");
			int n = s.length();
			TreeSet<String> set = new TreeSet<String>();
			HashSet<String> bad = new HashSet<String>();
			boolean[][] flg = new boolean[n][n];

			for(int i=n;i>=3;i--){
				for(int j=0;j<=n-i;j++){
					if(flg[j][j+i-1]) continue;
					String sub = s.substring(j,j+i);
					if(isPalindrome(sub) && !bad.contains(sub)){
						set.add(sub);
						for(int k=0;k<i/2;k++){
							flg[j+k][j+i-k-1] = true;
							bad.add(sub.substring(k,i-k));
						}
					}
				}
			}

			System.out.println(set.toString().replaceAll("\\[|\\]|,",""));
		}
	}
}

Measured memory_bytes: 10000
import numpy as np

N = input()
N = int(N)
p = input().split()
p_l = [int(s) for s in p]
p_def = np.array(p_l)
p_sort = np.sort(p_def)

comp = p_def == p_sort
diff = len((np.where(comp==False))[0])
if diff <= 2:
    print("YES")
else:
    print("NO")

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

int main() {
    string s1, s2;
    cin>>s1;
    for(int i=0;i<s1.size();++i) {
        if(s1[i]=='B') {
            if(s2.size()) s2.pop_back();
        }
        else s2.push_back(s1[i]);
    }
    cout<<s2<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

s = input()
t = input()

tset = set(t)
slen = len(s)

if len(tset - set(s)) != 0:
    print(-1)
    sys.exit()

s2t = [i - ord('a') for i in (s + s).encode('ascii')]
lut = [[-1 for _ in range(slen)] for _ in range(26)]
for c in tset:
  b = ord(c) - ord('a')
  j = 0
  for i in range(slen * 2 - 1, -1, -1):
    if s2t[i] == b:
      j = 0
    else:
      j += 1
    if i < slen:
      lut[b][i] = j

p = 0
for c in t:
  b = ord(c) - ord('a')
  p += lut[b][p % slen] + 1
print(p)


Measured memory_bytes: 119640
def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    

N = int(input())
p = InputToInt()

c = 0
for i in range(N):
    if p[i] != i+1:
        c += 1

if c <= 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
using namespace std;
 
int main(){
  bool bingo = false;
  vector<vector<bool>> field(3,vector<bool>(3,false));
  vector<vector<int>> A(3,vector<int>(3));
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++){ 
    cin >> b[i];
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 3; k++){
        if (b[i] == A[j][k]){
          field[j][k] = true;
        }
      }
    }
  }
  
  //縦のビンゴ
  for (int i = 0; i < 3; i++){
    bool t = true;
    for (int j = 0; j < 3; j++){
      if(!field[j][i]) t = false;
    }
    if(t) bingo = true;
  }
  
  //横のビンゴ
  for (int i = 0; i < 3; i++){
    bool t = true;
    for (int j = 0; j < 3; j++){
      if (!field[i][j]) t = false;
    }
    if(t) bingo = true;
  }
  
  //斜めのビンゴ
  bool t = true;
  for (int i = 0; i < 3; i++){
    if (!field[i][i]) t = false;
  }
  if(t) bingo = true;
  
  t = true;
  for (int i = 0; i < 3; i++){
    if(!field[i][2-i]) t = false;
  }
  if(t) bingo = true;
  
  
  if (bingo) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = []
Bs = []
for _ in range(N):
    A, B = mapint()
    As.append(A)
    Bs.append(B)
As.sort()
Bs.sort()

if N%2==1:
    left = As[N//2]
    right = Bs[N//2]
else:
    left = (As[N//2]+As[N//2-1])
    right = (Bs[N//2]+Bs[N//2-1])

print(right-left+1)

Measured memory_bytes: 97044
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

void DebugPrint(double a[], int n)
{
#ifdef DEBUG_MODE
	for (int i = 0; i < min(20, n); ++i) {
		cout << a[i] << ",";
	}
	cout << endl;
#endif
}

double dp[2999 / 2 + 2][2999 + 1];

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  

	int n;
	cin >> n;

	vector<double> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}

	dp[0][0] = 1.0;

	for (int i = 0; i < n / 2 + 1; ++i) {
		for (int j = i; j < n; ++j) {
			dp[i][j + 1] += dp[i][j] * p[j];
			dp[i + 1][j + 1] = dp[i][j] * (1.0 - p[j]);
		}
		DebugPrint(dp[i], n + 1);
	}

	double sum = 0.0;
	for (int i = 0; i < n / 2 + 1; ++i) {
		sum += dp[i][n];
	}

	cout << fixed << setprecision(10) << sum << endl;
	return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<bitset>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int N;
ll mpow(ll x, ll n,ll mod){
    ll ans = 1;
    while(n){
        if(n % 2){
            ans = ans * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

int func(ll n,ll wari){
    int count = 1;
    while(n % wari != 0){
        ll amari = n % wari;
        n = amari;
        wari = bitset<64>(amari).count();
        count++;
    }
    return count;
}

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N;cin>>N;
    string X; cin>>X;
    ll bit = 0;
    ll popcount = 0;
    ll popminus = 0;
    REP(i,X.length()){
        if(X[i] == '1')bit++;
    }
    REP(i,N){
        if(X[i] == '1'){
            popcount = (popcount + mpow(2,N-i-1,bit+1))%(bit+1);
            if(bit > 1) popminus = (popminus + mpow(2,N-i-1,bit-1))%(bit-1);
        }
    }
    vector<ll> ans(N,0);

    if(bit <= 1){
        ll x;
        REP(i,N){
            if(X[i] == '0'){
                x =(popcount + mpow(2,N-1-i,bit+1)%(bit+1));
                ans[i] = func(x,bit+1);
            }
            else{
                ans[i] = 0;
            }
        }
        REP(i,N){
            cout<<ans[i]<<endl;
        }
        return 0;
        
    }
    else{
        REP(i,N){
        ll x;
        if(X[i] == '0'){
            x = popcount + mpow(2,N-1-i,bit+1);
            ans[i] = func(x,bit+1);
        }
        else{
            x = (popminus + (bit-1) - mpow(2,N-1-i,bit-1)) % (bit-1);
            ans[i] = func(x,bit-1);
        }  
    }

    REP(i,N){
        cout<<ans[i]<<endl;
    }
    }
    

}

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

int main(){
  int N, K;
  cin >> N >> K;
  int sum = 0;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    if(x <= K - x){
      sum += 2 * x;
    }
    if(x >K - x){
      sum +=2 * (K - x);
    }
  }cout << sum << endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
using ll = long long;
int main(){
	ll n, m;
	cin >> n >> m;
	if(n == 1|| m == 1)
	cout << 1 << endl;
	else {
		if(( n * m) & 1) cout << (n * m) / 2 + 1 << endl;
		else cout << (n * m) / 2 << endl;
	}
	return 0;
}

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

int main(){
  int n;cin >> n;
  vector<int> a(n);
  vector<int> sota(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  sota = a;
  sort(sota.begin(),sota.end());
  for(int i=0; i<n; i++){
    if(a.at(i)==sota.at(sota.size()-1))cout << sota.at(sota.size()-2) << endl;
    else cout << sota.at(sota.size()-1) << endl;
  }
}
      

Measured memory_bytes: 3200
package main

import "fmt"

func main() {
	var a,b,c,d int
	fmt.Scan(&a,&b,&c,&d)
	max := a*c
	max = hoge(a*d, max)
	max = hoge(b*d, max)
	max = hoge(b*c, max)
	fmt.Println(max)
}

func hoge(n, max int) int {
	if n > max {
		max=n
	}
	return max
}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;cin>>S;
    int ans=0;
    for(int i=0;i<S.size();i++){
        ans+=S[i]-'0';
    }
    ans=max(ans,(int)((S[0]-'1')+9*S.size()-9));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//B - Minesweeper: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int h, w;

char solve(int i , int j, vector<string> &tab) {
    int a = 0;
    if(j-1 >= 0 and tab[i][j-1] == '#') a++;
    if(i-1 >= 0 and tab[i-1][j] == '#') a++;
    if(j+1 < w and tab[i][j+1] == '#') a++;
    if(i+1 < h and tab[i+1][j] == '#') a++;
    if(i+1 < h and j+1 < w and tab[i+1][j+1] == '#') a++;
    if(i+1 < h and j-1 >= 0 and tab[i+1][j-1] == '#') a++;
    if(i-1 >= 0 and j+1 < w and tab[i-1][j+1] == '#') a++;
    if(i-1 >= 0 and j-1 >= 0 and tab[i-1][j-1] == '#') a++;
    return a + '0';
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> h >> w;
    vector<string> tab(h);
    vector<string> ans(h, "");
    loop(i, 0, h) cin >> tab[i];
    loop(i, 0, h) {
        loop(j, 0, w) {
            if(tab[i][j] == '#') ans[i].pb('#');
            else ans[i].pb(solve(i, j, tab));
        }
    }
    for(auto x : ans) cout << x << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<<29)

int dist[100][100];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)dist[i][j]=INF;
	for(int i=0;i<n;i++)dist[i][i]=0;
	for(int i=0;i<n;i++){
		int r,k,t;
		cin>>r>>k;
		for(int j=0;j<k;j++){
			cin>>t;
			dist[r-1][t-1]=1;
		}
	}
	for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)
		dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
	int p;
	cin>>p;
	for(int i=0;i<p;i++){
		int s,d,v;
		cin>>s>>d>>v;
		if(dist[s-1][d-1]<v)cout<<dist[s-1][d-1]+1<<endl;
		else cout<<"NA\n";
	}
	return 0;
}

Measured memory_bytes: 1204