akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int Ma = scanner.nextInt();
    int Mb = scanner.nextInt();
    int[] a = new int[N + 1];
    int[] b = new int[N + 1];
    int[] c = new int[N + 1];

    for (int i = 1; i <= N; i++) {
      a[i] = scanner.nextInt();
      b[i] = scanner.nextInt();
      c[i] = scanner.nextInt();
    }

    int INF = 1_000_000;
    int M = 400;
    int[][] dp1 = new int[M + 1][M + 1];
    int[][] dp2 = new int[M + 1][M + 1];
    for (int i = 0; i <= M; i++) for (int j = 0; j <= M; j++) dp1[i][j] = INF;
    dp1[0][0] = 0;
    for (int j = 0; j <= M; j++) System.arraycopy(dp1[j], 0, dp2[j], 0, M + 1);

    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= M; j++) {
        for (int k = 1; k <= M; k++) {
          if(j >= a[i] && k >= b[i]) {
            dp2[j][k] = Math.min(dp2[j][k], dp1[j - a[i]][k - b[i]] + c[i]);
          }
        }
      }
      for (int j = 0; j <= M; j++) System.arraycopy(dp2[j], 0, dp1[j], 0, M + 1);
    }

    //for (int i = 1; i <= M; i++) {
    //  for (int j = 1; j <= M; j++) {
    //    if (dp2[i][j] >= INF) System.out.print("∞ ");
    //    else System.out.printf("%d ", dp2[i][j]);
    //  }
    //  System.out.println();
    //}

    int min = INF;
    for (int i = 1; i <= M; i++)
      for (int j = 1; j <= M; j++)
        if (Ma * j == Mb * i) min = Math.min(min, dp2[i][j]);

    if (min >= INF) {
      System.out.println(-1);
    } else {
      System.out.println(min);
    }
  }
}


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

#define reps(i,j,k) for(int i=(j);i<(k);++i)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S, class T>
ostream &operator<<(ostream &out, const pair<S,T> &p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size())
		out << v[i] << ", ";
	return out << "}" << endl;
}


int bo[100][10];
int bo2[100][10];

int main(){
	int H;

	for(;;){
		int r;
		bool f;

		scanf("%d",&H);
		if(H==0)return 0;
		rep(i,100)rep(j,10)bo2[i][j]=bo[i][j]=0;
		rep(i,H)rep(j,5)scanf("%d",&bo[H-i-1][j]);

		r=0;
		for(;;){
			f=true;
			
			rep(i,H)rep(j,5)bo2[i][j]=bo[i][j];
			rep(i,H)rep(j,3)if(bo[i][j] != 0 && bo[i][j] == bo[i][j+1] && bo[i][j+1]==bo[i][j+2]){
				f=false;
				rep(k,3){
					r += bo2[i][j+k];
					bo2[i][j+k]=0;
				}
			}
			rep(i,H)rep(j,5)bo[i][j]=bo2[i][j];
			if(f)break;
			
			rep(j,5){
				rep(i,25){
					if(bo[i][j]==0){
						int k=i+1;
						for(;k<70;k++){
							if(bo[k][j]!=0)break;
						}
						//cerr << k << " ";
						rep(l,25){
							bo[i+l][j] = bo[k+l][j];
						}
					}
				}
			}
			/*
			cerr << "###############" <<endl;
			rep(i,H){
				rep(j,5) cerr << bo[i][j] <<" ";
				cerr << endl;
			}
			*/
		}

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

Measured memory_bytes: 3224
import Control.Monad

fill [x, _, 1] (xl, xr, yb, yt) = (max x xl, xr, yb, yt)
fill [x, _, 2] (xl, xr, yb, yt) = (xl, min x xr, yb, yt)
fill [_, y, 3] (xl, xr, yb, yt) = (xl, xr, max y yb, yt)
fill [_, y, 4] (xl, xr, yb, yt) = (xl, xr, yb, min y yt)

calc (xl, xr, yb, yt) = max 0 (xr-xl) * max 0 (yt-yb)


main = map read . words <$> getLine >>= \[w,h,n] -> (replicateM n (map read . words <$> getLine) >>= print . calc . foldr fill (0, w, 0, h))

Measured memory_bytes: 1020
N,M=map(int,input().split())
a=[list(map(int,input().split())) for i in range(N)]
b=[list(map(int,input().split())) for i in range(M)]
for i in range(N):
    dmin=abs(a[i][0]-b[0][0])+abs(a[i][1]-b[0][1])
    num=1
    for j in range(M):
        dist=abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1])
        if dmin>dist:
            dmin=dist
            num=j+1
    print(num)  

Measured memory_bytes: 3064
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort

h = Hash.new(0)

a.each do |i|
  
  h[i] += 1
  
end

h = h.sort_by {|k, v| v }

ans = 0

if K < h.size
  
  n = h.size - K
  
  n.times do |j|
    
    ans += h[j][1]
    
  end
end

puts ans

Measured memory_bytes: 41952
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a,b,c,d,sum1,sum2;
 cin>>a>>b>>c>>d;
 sum1=a*b;
 sum2=c*d;
 if(sum1<sum2)
 cout<<sum2<<endl;
 else if(sum2<sum1)
 cout<<sum1<<endl;
 else if(sum1==sum2) 
 cout<<sum1<<endl;
} 

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,100000){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int x;
int sosuu[100010] = {0};
int yakusu[1001] = {0};
ll mod = 1000000007;

ll calc(int i,int n){
  ll ans = 1;
  ll tmp = 1;
  while(i>0){
    tmp *= n;
    tmp %= mod;
    if(i%2==1){
      ans *= tmp;
      ans %= mod;
    }
    i/=2;
  }
  return ans;
}


int main(){
  scanf("%d",&x);
  gen_sosuu(sosuu);
  FOR(i,2,x+1){
    REP(j,i+1){
      if(sosuu[j]==true && i%j==0){
        int tmp = i;
        while(tmp%j==0){
          yakusu[j]++;
          tmp/=j;
        }
      }
    }
  }
  ll ans = 1;
  FOR(i,2,x+1){
    ans *= yakusu[i]+1;
    ans %= mod;
  }
  printf("%lld\n",ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
	ll a,b;
	cin>>a>>b;
	if(a>b) swap(a,b);
	
	if(a==1&&b==2) cout<<3<<endl;
	if(a==1&&b==3) cout<<2<<endl;
	if(a==2&&b==3) cout<<1<<endl;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
c = [tuple(map(int,input().split())) for i in range(N)]
DP = [[float('inf') for i in range(10**3*N+1)] for i in range(N+1)]
DP[0][0] = 0
for i in range(N):
    for v in range(10**3*N+1):
        if v-c[i][1] < 0:
            DP[i+1][v] = DP[i][v]
        else:
            DP[i+1][v] = min(DP[i][v-c[i][1]]+c[i][0],DP[i][v])

ans = 0
DP = DP[N]
for v in range(10**3*N,-1,-1):
    if DP[v] <= W:
        ans = v
        break
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int>h(n);
  for(int i=0; i<n; i++)cin >> h[i];
  h.push_back(0);
  int ret=0;
  bool flag=false;
  for(int i=1; i<=100; i++){
    for(int j=0; j<=n; j++){
      if(h[j]>=i && !flag){
        flag=true;
      }
      else if(h[j]<i && flag){
        flag=false;
        ret++;
      }
    }
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	int[][][] dp;

	int dp(int n, int k, int s) {
		if (s < 0) {
			return 0;
		}
		if (k == 0) {
			return s == 0 ? 1 : 0;
		}

		if (0 <= dp[n][k][s]) {
			return dp[n][k][s];
		}

		int res = 0;
		for (int i = 1; i <= n; i++) {
			res += dp(i - 1, k - 1, s - i);
		}
		return dp[n][k][s] = res;
	}

	void run() {
		MyScanner sc = new MyScanner();

		dp = new int[21][11][156];

		while (true) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int s = sc.nextInt();
			if ((n | k | s) == 0) {
				break;
			}

			for (int i = 0; i < 21; i++) {
				for (int j = 0; j < 11; j++) {
					Arrays.fill(dp[i][j], -1);
				}
			}
			System.out.println(dp(n, k, s));
		}
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
#define sysp system("pause")
//}

#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
inline long long digitsum(long long v){long long d=0;while(v){d+=v%10;v/=10;}return d;}
inline long long digitnumbersum(long long a){long long b=0;while(a){a/=10;b++;}return b;}
inline long long mysqrt(long long a){long long i=0;for(i=1;a>0;i++){a-=i*2+1;}return i-1;}
//}

long long n,ans,sum;
long long j=0;
long long b[1000000];

int main(){
	cin>>n;
	long long a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=0;i<n-1;){
		if(a[i]==a[i+1]){
			b[j]=a[i];
			i+=2;
			debug(b[j]);
			j++;
		}else{
			i++;
		}
	}
	if(b[1]){
	cout<<b[0]*b[1]<<endl;
	sysp;
	return 0;
	}
	cout<<0<<endl;
	sysp;
}
 

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;

    vector<int> taste(n);
    for (int i = 0; i < n; i++) cin >> taste[i];

    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            res += taste[i] * taste[j];
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
#define RG register
const int N = 1000000;

using namespace std;

inline int gi(){
	RG char ch=getchar();RG int x=0;
	while(ch<'0' || ch>'9') ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}

int main(){
	int x,n=gi(),mn=1e9,mx=-1e9;
	for (int i=1; i<=n; ++i){
		x=gi();
		mn=min(mn,x);
		mx=max(mx,x);
	}
	cout<<mx-mn;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;



int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif

	const int n = 5;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		if (x == 0)
		{
			cout << i + 1;
			return 0;
		}

	}
	return 0;
}

Measured memory_bytes: 3520
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]
B = [[0]*N for i in range(2)]
B[0][0] = A[0][0]
B[1][N-1] = A[1][N-1]
#print(A)
#print(B)
for i in range(1,N):
    #print(i)
    B[0][i] = B[0][i-1] + A[0][i]
    B[1][N-i-1] = B[1][N-i] + A[1][N-i-1]
    #print(B)
sumB = [B[0][i]+B[1][i] for i in range(N)]
print(max(sumB))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
   
int main()
{
	int n=0;
	char w[11],t[50];
	cin >> w >> t;
	for (int i = 0; i < 10; i++) {
		if (((int)w[i] >= 0x41)&&((int)w[i] <= 0x5a))
		w[i] = (char)((int)w[i]+32);
	}
	while (!(strstr(t,"END_OF_TEXT"))) {
		for (int i = 0; i < 50; i++) {
			if (((int)t[i] >= 0x41)&&((int)t[i] <= 0x5a))
			t[i] = (char)((int)t[i]+32);
		}
		if(strcmp(w,t)==0)
			n++;
		cin >> t;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 3050;

int mod = (int) 1e9 + 7;

long long binpow(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res = (res * x) % mod;
      p--;
    } else {
      x = (x * x) % mod;
      p /= 2;
    }
  }
  return res % mod;
}

long long inv(long long x) {
  return binpow(x, mod - 2) % mod;
}

long long f[MAXN], invF[MAXN];
long long t[MAXN];

long long cnk(long long n, long long k) {
  long long res = 1ll * f[n] * invF[k] % mod;
  res = res * invF[n - k] % mod;
  return res;
}

int subMod(int a, int b) {
  int res = a - b;
  return res < 0 ? res + mod : res;
}

int n;
long long dp[MAXN];
long long dp2[MAXN][MAXN];

int main() { 

  scanf("%d %d", &n, &mod);

  f[0] = 1; invF[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = 1ll * i * f[i - 1] % mod;
    invF[i] = inv(f[i]);
  }

  t[0] = 2;
  for (int i = 1; i <= n; i++) {
    t[i] = 1ll * t[i - 1] * t[i - 1] % mod;
  }

  dp2[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0) {
        dp2[i][j] = 1;
        continue;
      }
      dp2[i][j] = (dp2[i - 1][j] + dp2[i - 1][j - 1]) % mod;
      dp2[i][j] = (dp2[i][j] + 1ll * dp2[i - 1][j] * j % mod) % mod;
    }
  }

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      long long cur = dp2[i][j];
      cur = cur * binpow(2, j * (n - i)) % mod;
      cur = cur * t[n - i] % mod;
      dp[i] = (dp[i] + cur) % mod;
    }
  }

  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    long long cur = cnk(n, i) * dp[i] % mod;
    if (i % 2 == 0) {
      ans = (ans + cur) % mod;
    } else {
      ans = subMod(ans, cur) % mod;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70400
#define ll long long
#define MOD 1000000007 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin>>n;
  long double head[n+1],tail[n+1];
  for(int i=1;i<=n;i++)
  {
      cin>>head[i];
      tail[i]=1-head[i];
  }
  long double dp[n+1][n+1];
  for(int i=0;i<=n;i++)
  for(int j=0;j<=n;j++)
  dp[i][j]=0.0;
  dp[0][0]=1.0;  

  for(int i=1;i<=n;i++)
  {
      for(int j=0;j<=i;j++)
      {
          if(i==j)
          dp[i][j]=dp[i-1][j-1]*head[i];
          else
          {
              dp[i][j]=dp[i-1][j]*tail[i];
              if(j-1>=0)
              dp[i][j]+=dp[i-1][j-1]*head[i];
          }
      }
  }
  long double ans=0.0;
  for(int i=n;i>=n/2+1;i--)
  ans+=dp[n][i];
  cout<<setprecision(15)<<ans;

  return 0;
}

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    ll N; cin >> N;
    vector<pair<ll,ll>> edge[N];
    REP(i,N-1){
        ll u,v,w; cin >> u >> v >> w;
        u--; v--;
        edge[u].emplace_back(v,w);
        edge[v].emplace_back(u,w);
    }

    vector<ll> d(N,INT_INF), done(N,0);
    queue<P> q;
    q.push(P(0,0));
    while(q.size()){
        P p = q.front(); q.pop();
        ll c = p.first, node = p.second;
        if(done[node]) continue;
        done[node] = 1;

        chmin(d[node], c);
        for(auto pp : edge[node]){
            ll nxt = pp.first, cost = pp.second;
            q.push(P(c+cost, nxt));
        }
    }

    REP(i,N) cout << (d[i]%2 ? 1 : 0) << endl;
    return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string w; cin >> w;

    int a[30] = {};

    for (int i = 0; i < w.size(); ++i) {
        ++a[w[i] - 'a'];
    }

    for (int i = 0; i < 30; ++i) {
        if (a[i] % 2 != 0) {
            puts("No");
            return 0;
        }
    }

    puts("Yes");
}

Measured memory_bytes: 256
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

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

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     int i, j;
     cin >> n;
     int cnt = 0, cnt2 = 0;
     if (n % 2 == 0)
     {
          for (i = 5; n / i >= 1; i *= 5)
          {
               int x = n / i;
               cnt += x / 2;

          }
     }
     cout << cnt;

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	
	double sum = 0;
	double ans = 0;
	double cnt = 0;
	for (int i = 1; i <= N; i++)
	{
		sum = i;
		for (int j = i; j < K; j++) {
			if (sum == 0 || sum >= K) {
				break;
			}
			sum *= 2;
			cnt++;
		}
		ans += ((double)1 / N) * pow((double)1 / 2, cnt);
		cnt = 0;
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second
 
typedef long long ll;
 
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
 
int main(){ _
 
	ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
 
	bool ans = false;
	ll dist = abs(a-b);

	if(w >= v) ans = false;
	else ans = dist <= (v-w)*t;	
 
	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;
 
	return 0;
}


Measured memory_bytes: 3648
// ConsoleApplication74.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include<algorithm>
#include<iomanip>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
using namespace std;
int main()
{
	double r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++)
	{
		x = r * x - d;
		cout <<fixed<<setprecision(0)<< x << "\n";
	}
}


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

struct UnionFind{
  vector<int> p;
  UnionFind(int n){
    p.resize(n+1);
    for(int i=0; i<=n; i++)  p[i] = i;
  }
  int find(int x){
    if(x == p[x])  return x;
    return p[x] = find(p[x]);
  }
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x != y)  p[x] = y;
  }
};

int main(){
  int n, m;  cin >> n >> m;
  UnionFind uf(n);
  while(m--){
    int a, b;  cin >> a >> b;
    uf.unite(a, b);
  }

  vector<int> table(n+1, 0);
  for(int i=1; i<=n; i++)
    table[uf.find(i)]++;

  int ans = 0;
  for(int i=1; i<=n; i++)
    ans = max(ans, table[i]);

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


Measured memory_bytes: 11080
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>

#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    n=abs(n);
    m=abs(m);
    if(n*m==0)return max(n,m);
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main() {
    string s;cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int d = a/b;
      int r = a%b;
      double f = (double)a/b;
      System.out.print(d+" "+r+" "+String.format("%.8f", f));
  }
}



Measured memory_bytes: 26580
#include <iostream>
using namespace std;
int main()
{
  int X, A, B;
  cin >> X >> A >> B;
  if (B<=A) {
    cout << "delicious" << endl;
  }
  else if ((B-A) <= X) {
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
  return 0;
}


Measured memory_bytes: 3552
#include <stdio.h>

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

	int i = 1;
	int max_total = 0;		// i未満の数値の合計値の最大
	while (max_total + i < N){
		max_total += i;
		i++;
	}

	printf("%d\n", i);
	int rest = N - i;
	while (rest != 0) {
		i--;
		if (rest >= i) {
			printf("%d\n", i);
			rest -= i;
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    string S;
    cin >> S;
    cout << "ABC" << S << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(void) {
  long long x;
  cin >> x;
  
  int amari = x%11;
  long long seisuu = (long) (x/11);
  long long ans;
  if (amari > 6) {ans = seisuu*2+2;}
  else if (amari == 0){ans = seisuu *2;}
  else {ans = seisuu* 2+1;}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

vector<vector<int> > G;
vector<int> vi;

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    G.resize(3*N);
    for (int m = 0; m < M; ++m) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        G[u].push_back(v+N);
        G[u+N].push_back(v+2*N);
        G[u+2*N].push_back(v);
    }
    int S, T;
    cin >> S >> T;
    --S; --T;
    
    vi.resize(3*N, -1);
    vi[S] = 0;
    queue<int> Q;
    Q.push(S);
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        for (int v: G[u]) {
            if (vi[v] != -1) {
                continue;
            }
            vi[v] = vi[u] + 1;
            Q.push(v);
        }
    }
    cout << (vi[T] > 0 ? vi[T]/3 : -1) << endl;

    return 0;
}


Measured memory_bytes: 17792
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair

using namespace std;
int const N = 1000000;



int main()
{
    ll k, n;
    ll maxdif = 0;
    cin >> k >> n;
    ll last; cin >> last;  ll first = last;
    for (int i = 1; i < n; i++) {
        ll a;
        cin >> a;
        maxdif = max(maxdif, a - last);
        last = a;
    }
    maxdif = max(maxdif, first + (k - last));
    cout << k - maxdif;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
typedef long long ll;
const int mod=1e9+7;
int dp(int n,vector<int> a,vector<int> b,vector<int> c)
{
    int table[n][3];
    table[0][0]=a[0];table[0][1]=b[0];table[0][2]=c[0];
    fore(i,1,n)
    {
        table[i][0]=max(table[i-1][1]+a[i],table[i-1][2]+a[i]);
        table[i][1]=max(table[i-1][0]+b[i],table[i-1][2]+b[i]);
        table[i][2]=max(table[i-1][1]+c[i],table[i-1][0]+c[i]);
    }
    return maxe(table[n-1][0],table[n-1][1],table[n-1][2]);
}
int main()
{
    fastio;
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    fore(i,0,n)
    cin>>a[i]>>b[i]>>c[i];
    print(dp(n,a,b,c));
}

Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#define int long long
using namespace std;

map<int, int>a;
signed main() {
	int b; cin >> b;
	int T; cin >> T;
	for (int c = 0; c < b; c++) {
		int d, e; cin >> d >> e;
		a[d] += e;
	}
	int sum = 0;
	for (auto i : a) {
		sum += i.second;
		if (sum >= T) {
			cout << i.first << endl;
			break;
		}
	}
}

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

using namespace std;

typedef long long ll;

int main()
{
	ll l, r;
	cin >> l >> r;

	bool a = false;

	for (ll i = 2019; i <= 2000000000; i += 2019) {
		if (i - l >= 0 && r - i >= 0)  a = true;
	}

	if (a) {
		cout << 0 << endl;
	}
	else {
		ll a = 2018 * 2017;
		for (ll i = l; i <= r - 1; i++) {
			for (ll j = l + 1; j <= r; j++) {
				a = min((i * j) % 2019, a);
			}
		}
		cout << a << endl;
	}

}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

char a;

signed main() {
    cin >> a;
    cout << (char)(a+1) << endl;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) cout << (x) << endl;
#define outs(x) for(auto i : x) cout << i << " ";
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main() {
  int n,m; cin >> n >> m;
  map<int,vector<int>> ab;
  int a,b;
  rep(i,m){
    cin >> a >> b;
    ab[a].pb(b);
  }

  function<void(int,int)> dfs = [&](int point,int cnt){
    if(cnt == 2){
      if(point == n){
        out("POSSIBLE");
        exit(0);
      }
      return;
    }

    for(int i : ab[point])
      dfs(i,cnt + 1);
  };

  dfs(1,0);
  out("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 19320
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = s; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  if (s == "SSS") cout << 0 << endl;
  else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") cout << 1 << endl;
  else if (s == "RRS" || s == "SRR") cout << 2 << endl;
  else cout << 3 << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

#define int long long

//

signed main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> table(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> table[i][j];
    rep(i, h) rep(j, w) {
        int cnt = 0;
        if (table[i][j] == '.') {
            if (j > 0) {
                if (table[i][j - 1] == '#')
                    cnt++;
                if (i < h - 1)
                    if (table[i + 1][j - 1] == '#')
                        cnt++;
                if (i > 0)
                    if (table[i - 1][j - 1] == '#')
                        cnt++;
            }
            if (j < w - 1) {
                if (table[i][j + 1] == '#')
                    cnt++;
                if (i < h - 1)
                    if (table[i + 1][j + 1] == '#')
                        cnt++;
                if (i > 0)
                    if (table[i - 1][j + 1] == '#')
                        cnt++;
            }
            if (i > 0)
                if (table[i - 1][j] == '#')
                    cnt++;
            if (i < h - 1)
                if (table[i + 1][j] == '#')
                    cnt++;
            cout << cnt;
        }
        else
            cout << '#';
        if (j == w - 1)
            cout << endl;
    }
}

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

int N;
string S, T;

int main()
{
  scanf("%d", &N);
  cin >> S >> T;

  string P;
  for(int i = 0; i < N; i++) P += S[i], P += T[i];

  cout << P << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<algorithm>
using namespace std;

int n,m,odd;
int a[101000];

int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>a[i];
		if(a[i]&1)
		{
			odd++;
		}
	}
	if(odd>2)
	{
		cout<<"Impossible"<<endl;
		return 0;
	}
	if(m==1)
	{
		if(n==1)
			cout<<1<<endl<<1<<endl<<1<<endl;
		else
			cout<<n<<endl<<2<<endl<<1<<" "<<n-1<<endl;
		return 0;
	}
	for(int i=1;i<=m;i++)
	{
		if(a[i]&1)
		{
			swap(a[1],a[i]);
			break;
		}
	}
	for(int i=2;i<=m;i++)
	{
		if(a[i]&1)
		{
			swap(a[m],a[i]);
			break;
		}
	}
	for(int i=1;i<=m;i++)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
	if(a[1]==1)
		cout<<m-1<<endl;
	else
		cout<<m<<endl<<a[1]-1<<" ";
	for(int i=2;i<m;i++)
	{
		cout<<a[i]<<" ";
	}
	cout<<a[m]+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int x[maxn],xx[maxn],w[maxn];
int i,j,k,l,r,s,t,n,m;
ll c; 
int main(){
	scanf("%d%d%d",&n,&l,&t);
	fo(i,1,n) scanf("%d%d",&x[i],&w[i]);
	fo(i,1,n){
		if (w[i]==2) w[i]=-1;
		r=x[i]+w[i]*t;
		if (r>0) (c+=r/l)%=n;
		else if (r<0) (c+=(r+1)/l-1)%=n;
		xx[i]=(r%l+l)%l;
	}
	sort(xx+1,xx+n+1);
	c=(c+n)%n;
	fo(i,c+1,n) printf("%d\n",xx[i]);
	fo(i,1,c) printf("%d\n",xx[i]);
}

Measured memory_bytes: 2304
#include<iostream>

using namespace std;

int main(void)
{
  int a,b,c;
  cin>>a>>b>>c;
  
  if((a!=b)&&(b==c)){cout<<a<<endl;}
  else if((b!=c)&&(c==a)){cout<<b<<endl;}
  else if((c!=a)&&(a==b)){cout<<c<<endl;}
  
  return 0;
}

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

int main() {
    int a, b;
    while(cin >> a >> b, a) {
        vector<vector<int>> dp(a, vector<int>(b, -1));
        dp[0][0] = 1;
        int n;
        cin >> n;
        for(int i=0; i<n; ++i) {
            int x, y; cin >> x >> y;
            x--; y--;
            dp[x][y] = 0;
        }
        for(int i=0; i<a; ++i) {
            for(int j=0; j<b; ++j) {
                if(dp[i][j] == -1) {
                    dp[i][j] = 0;
                    if(i > 0) {
                        dp[i][j] += dp[i-1][j];
                    }
                    if(j > 0) {
                        dp[i][j] += dp[i][j-1];
                    }
                }
            }
        }
        cout << dp[a-1][b-1] << endl;
    }
}


Measured memory_bytes: 3020
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
string A;
const ll MOD=1e9+7;
ll qexp(ll x, ll e){
	if(e==0)return 1;
	ll half=qexp(x,e/2);
	half*=half;half%=MOD;
	if(e&1)half*=x,half%=MOD;
	return half;
}
void five() {
	ll co=0;
	for(ll i=0;i<=5;++i){
		for(ll j=0;j<=5;++j){
			if(i+j<=5&&(i+j)==(i^j)){
				// cerr<<i<<' '<<j<<'\n';
				co++;
			}
		}
	}
	cerr<<"ans: "<<co<<'\n';
}
int main()
{
	FAST
	cin>>A;
	ll ones=0,ans=0;
	FOR(i,0,A.size())if(A[i]=='1'){
		ans+=(qexp(2,ones) * qexp(3,siz(A)-i-1))%MOD;
		ans%=MOD;
		++ones;
	}	
	ans+=qexp(2,ones);ans%=MOD;
	cout<<ans<<'\n';
	// five();
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N;
    cin >> N;
    int A[N] = {};
    int min1 = INT_MAX;
    rep(i,N){
        cin >> A[i];
        if(A[i] == 1) min1 = min(min1,i);
    }
    if(min1 == INT_MAX){
        cout << -1 << endl;
        return 0;
    }
    int res=0;
    int index=min1+1;
    int target=2;
    while(index < N){
        //cout << target << " " << A[index] << " " << index << " " << N << endl;
        if(target == A[index]){
            target++;
        }else{
            res++;
        }
        index++;
    }
    cout << min1 + res << endl;
 
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn],a[maxn],b[maxn];
int main() {
    double a,b,h,m;cin>>a>>b>>h>>m;
    double thetah=360.0/12*(h+m/60),thetam=360.0/60*m;
    double theta=abs(thetah-thetam);
    theta=min(theta,360-theta);
    theta=theta/180*acos(-1);
    printf("%.15f\n",sqrt(a*a+b*b-2*a*b*cos(theta)));
    return 0;
}

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

ll n,k;
int arr[200005];
vector<int> pos[200005];
int nxt[200005];

vector<int> fin;
bool used[200005];

int norm(int i){
	while (i<=0) i+=n;
}

int main(){
	cin>>n>>k;	
	
	for (int x=0;x<n;x++){
		cin>>arr[x];
		pos[arr[x]].push_back(x);
	}
	
	for (int x=0;x<200005;x++){
		for (int y=0;y<pos[x].size();y++){
			nxt[pos[x][y]]=pos[x][(y+1)%pos[x].size()];
		}
	}
	
	int period=1;
	int curr=0;
	
	while (curr!=n){
		if (nxt[curr]<=curr) period++;
		curr=nxt[curr];
		
		curr++;
	}
	
	k%=period;
	
	if (k==0) return 0;
	
	curr=0;
	while (k>1){
		if (nxt[curr]<=curr) k--;
		curr=nxt[curr]+1;
	}
	
	for (int x=curr;x<n;x++){
		if (used[arr[x]]){
			while (used[arr[x]]){
				used[fin.back()]=false;
				fin.pop_back();
			}
		}
		else{
			fin.push_back(arr[x]);
			used[arr[x]]=true;
		}
	}
	
	for (auto &it:fin) cout<<it<<" ";
}

Measured memory_bytes: 15096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<long long> divisor(long long n) {
  vector<long long> res;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (n / i != i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  set<int> st;
  rep(i, n) {
    if (i < n-1 && a[i] == a[i+1]) {
      st.insert(a[i]);
      continue;
    }
    auto div = divisor(a[i]);
    bool flag = true;
    for (auto e : div) {
      if (st.find(e) != st.end())
        flag = false;
    }
    if (flag)
      ans++;
    st.insert(a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13460
import sys

N = int(input())
nums = list(map(int, input().split(' ')))

output = 1

if 0 in nums:
  print(0)
  sys.exit()
  
else:
  for x in nums:
    output *= x

    if output > 10**18:
      print(-1)
      sys.exit()

  print(output)

Measured memory_bytes: 21704
#include <stdio.h>
#include <vector>
#include <queue>

#define lli long long int
#define pb push_back

using namespace std;

int main() {
	lli q, t, a, b, sum1 = 0, sum2 = 0, sz1 = 0, sz2 = 0, k = 0, ans;
	priority_queue<lli> pq1;
	priority_queue<lli, vector<lli>, greater<lli> > pq2;
	scanf("%lld", &q);
	while (q--) {
		scanf("%lld", &t);
		if (t < 2) {
			scanf("%lld %lld", &a, &b);
			k += b;
			if (sz1 < 1) {
				pq1.push(a);
				sz1++;
				sum1 += a;
			}
			else if (sz1 > sz2) {
				b = pq1.top();
				if (a < b) {
					pq1.pop();
					pq1.push(a);
					sum1 += (a - b);
					pq2.push(b);
					sum2 += b;
				}
				else {
					pq2.push(a);
					sum2 += a;
				}
				sz2++;
			}
			else {
				b = pq2.top();
				if (b < a) {
					pq2.pop();
					pq2.push(a);
					pq1.push(b);
					sum1 += b;
					sum2 += (a - b);
				}
				else {
					pq1.push(a);
					sum1 += a;
				}
				sz1++;
			}
		}
		else {
			ans = k;
			a = pq1.top();
			b = sz1 * a;
			ans += (b - sum1);
			b = sz2 * a;
			ans += (sum2 - b);
			printf("%lld %lld\n", a, ans);
		}
	}
	return 0;
}

Measured memory_bytes: 3828