akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define N 100100
#define INF 1e9+7
ll MOD=1e9+7;

ll n,m;
int a[N],b[N];
main(){
    n=in();m=in();
    rep(i,n)a[i]=in();
    rep(i,m)b[i]=in();
    sort(a,a+n);
    sort(b,b+m);
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout<<0;return 0;
        }
    }
    rep(i,m-1){
        if(b[i]==b[i+1]){
            cout<<0;return 0;
        }
    }
    ll ans=1;
    rep3(i,n*m,1){
        int xx=lower_bound(a,a+n,i)-a;
        int x=n-xx;
        int yy=lower_bound(b,b+m,i)-b;
        int y=m-yy;
        if(a[xx]==i&&b[yy]==i)continue;
        if(a[xx]==i){
            ans=ans*y%MOD;
            continue;
        }
        if(b[yy]==i){
            ans=ans*x%MOD;
            continue;
        }
        ll now=x*y;
        now=now-(n*m-i);
        if(now<=0){
            cout<<0;return 0;
        }
        else{
            ans=(ans*now)%MOD;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K, A, B = [int(x) for x in input().split()]

    if B - A <= 2 or K <= A:
        print(K + 1)
        return
    ans = A
    K -= (A - 1)
    ans += (K // 2) * (B - A)
    ans += K % 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;

	if (a * 4 < b || a*2 > b || b%2) {
		printf("No");
	} else {
		printf("Yes");
	}

	return 0;
}



Measured memory_bytes: 3760
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VS s(n);
    REP(i,0,n) cin >> s[i];
    set<string> se;
    REP(i,0,n) se.insert(s[i]);
    cout << se.size() << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 25092
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	if(a + b == c){
			System.out.println("Yes");
        }else if(a + c == b){
			System.out.println("Yes");
        }else if(b + c == a){
			System.out.println("Yes");
        }else{
          	System.out.println("No");
        }
     }
}


Measured memory_bytes: 35784
//omajinai c++ atcoder
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<cmath>
#include<iomanip>
#include<type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
#define yes() printf("Yes\n")
#define no() printf("No\n")
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;

int main() {
    int n,k;
   cin>>n>>k;
   vector<long int> a(n);
   rep(i,n){
       cin>>a[i];
   }
/*
  //logsum=0;

   long double p=1;
     long double  now;
   for(int i=k;i<n;i++){
      now=a[i]/a[i-k];
       if(p<now){
           yes();
       }
       else{
           no();
       }
       p=now;
   }
}
*/
  
  for(int i=k;i<n;i++){
    if(a[i-k]<a[i]){
      yes();
    }
    else{
      no();
    }
  }
}

Measured memory_bytes: 4836
#include<iostream>
#include<stdio.h>
using namespace std;


int bubbleSort(int A[],int N){
    int flag=1,j;
    int sw=0;
    while(flag){
        flag=0;
        for(j=N-1;j>=1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                sw++;
                flag=1;
            }
        }
    }
return sw;
}

int main(){
    int A[100],N,sw;
    cin>>N;
    for(int i=0;i<N;i++) cin>>A[i];
    
    sw=bubbleSort(A,N);

    for(int i=0;i<N;i++){
        if(i) cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    cout<<sw<<endl;
    
    return 0;
}




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

int main () {
  long long N,P;
  cin >> N >> P;
  
  if (N == 1){
    cout << P << endl;
    return 0;
  }
  
  long long M = 1;
  
  for (long long i = 2; i <= 1000000; i++) {
    if (P % i == 0){
      int count = 0;
      for (int j = 0; j < 40; j++) {
        if (P % i == 0){
          count++;
          P /= i;
        }
        else {
          for (int k = 0; k < count/N; k++) {
            M *= i;
          }
          break;
        }
      }
    }
  }
  cout << M << endl;
}
        
      
    
    

Measured memory_bytes: 3588
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define Yy cout<<"Yes"
#define Nn cout<<"No"
#define yy cout<<"yes"
#define nn cout<<"no"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x%MOD*x%MOD)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll tt=1;

//	   cin>>tt;
	      while(tt--)
{
/*
cabacc
abc*/
ll n,m,j,k,l,i;
string s,t;
cin>>s>>t;
ll ans=0,mi=MOD;
for(i=0;i<=s.length()-t.length();i++)
{ll c=0;
	for(j=0;j<t.length();j++)
	{
		if(s[i+j]!=t[j])
		c++;
	}
	mi=min(mi,c);
}
cout<<mi;
ee;
	
	
}
return 0;
}



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

int digsum(int n) {
	int sum = 0;
	while(true) {
		sum += n % 10;
		n = (int)(n / 10);
		if(n <= 0) return sum;
	}
}

int main() {
	int n;
	cin >> n;
	int min;
	for(int i = 1; i < n; i++) {
		int j = n - i;
		int sum = digsum(i) + digsum(j);
		if(i == 1 || min > sum) min = sum;
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Integer N;
	static int[][] dp;
	static Node[] v;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		N = Integer.parseInt(sc.next());
		Integer M = Integer.parseInt(sc.next());
		v = new Node[N];
		for(int i=0;i<N;i++) v[i] = new Node(i);
		for(int i=0;i<M;i++) {
			int a = Integer.parseInt(sc.next())-1;
			int b = Integer.parseInt(sc.next())-1;
			v[a].edges.add(b);
			v[b].edges.add(a);
		}
		dp = new int[1<<N][N];
		for(int i =0;i<(1<<N);i++) for(int j=0;j<N;j++) dp[i][j] = -1;
		int result = dp(1,0);
		out.println(result);
		out.flush();
	}

	public static int dp(int i,int j) {
		Node st=v[j];
		if(i==(1<<N)-1) return dp[i][j] = 1;
		if(dp[i][j] >= 0) return dp[i][j];
		dp[i][j]=0;
		for(int id : st.edges){
			if((i & (1<<id)) == 0) {
				dp[i][j]+= dp(i+(1<<id),id);
			}
		}
		return dp[i][j];
	}
}

class Node{
	int id;
	ArrayList<Integer> edges = new ArrayList<>();
	public Node(int id) {
		this.id = id;
	}
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Main main = new Main();
		People[] people = new People[N];
		for (int i = 0; i < N; i++) {
			People p = main.new People();
			p.a = sc.nextInt();
			p.b = sc.nextInt();
			people[i] = p;
		}
		Arrays.parallelSort(people);
		int count =0;
//		count +=people[0].a-1;
		count +=people[N-1].b+people[N-1].a;
		System.out.println(count);
	}

	public class People implements Comparable<People> {
		int a;
		int b;
		@Override
		public int compareTo(People o) {
			return this.a - o.a;
		}

	}
}

Measured memory_bytes: 62648
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)



Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	ll sum = 0;
	for(ll i = 1;i <= n;i++){
		if(i % 3 != 0 && i % 5 != 0)sum += i;
	}

	cout << sum << endl;
}


Measured memory_bytes: 3672
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect.bisect_left(A, b) # 挿入点はどの同じ値よりも左
    c = bisect.bisect_right(C, b) # 挿入点はどの同じ値よりも右
    ans += a * (len(C)-c)
print (ans)

Measured memory_bytes: 23360
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(short *,short *,int *,int);


int main()
{
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

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

  for(i=0;i<VMAX;i++)
  {
      C[i]=0;
  }

  CountingSort(A,B,C,n);

  for(i=1;i<=n;i++)
  {
      if(i==1) printf("%d",B[i]);
      else printf(" %d",B[i]);
  }
  printf("\n");

  return 0;
}

void CountingSort(short *A,short *B,int *C,int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        C[A[i]]++;
    }
    for(i=1;i<=VMAX;i++)
    {
        C[i]=C[i]+C[i-1];
    }
    for(i=n-1;i>=0;i--)
    {
        B[C[A[i]]]=A[i]; C[A[i]]--;
    }
    return;
}




Measured memory_bytes: 9644
while True:
    n, x = [int(i) for i in input().split()]
    if n == x == 0:
        break

    c = 0
    for a in range(1,n):
        for b in range(a+1, n+1):
            num = x - a - b
            if n >= num > b:
                c += 1
                # print(a,b,num)
            elif b > num:
                break
    print(c)


Measured memory_bytes: 5604
fun main(args: Array<String>) {
    val n = readLine().orEmpty()?.toInt()
    val k = readLine().orEmpty()?.toInt()
    val x = readLine().orEmpty()?.toInt()
    val y = readLine().orEmpty()?.toInt()
    var price = 0


    price = if(n <= k){
        x * n
    }else {
        x * k + (y * (n - k))
    }
    println(price)

}


Measured memory_bytes: 31516
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<tuple>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 2019;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

const int MAX=510000;

#include <iostream>
using namespace std;

int main() {
    long long L, R; cin >> L >> R;
    if (R - L > 3000) cout << 0 << endl;
    else {
        long long res = 2018;
        for (long long i = L; i < R; ++i)
            for (long long j = i+1; j <= R; ++j)
                res = min(res, (i * j) % 2019);
        cout << res << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double n = scan.nextInt();
        double ans = 1;
        if(n != 1){
            if(n % 2 == 0){
                ans = 0.5;
            }else{
                ans = (n + 1)/(2 * n);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
from collections import Counter

n = int(input())
v = [int(_) for _ in input().split()]

odd = v[0:n:2]
even = v[1:n:2]

odClass = Counter(odd)
evClass = Counter(even)
mostOd = odClass.most_common()
mostEv = evClass.most_common()

numOd = mostOd[0]
numEv = mostEv[0]

if len(mostOd) == 1 and len(mostEv) == 1:
    if mostOd[0][0] == mostEv[0][0]:
        print(len(odd))
    else:
        print(0)
    exit()
elif len(mostOd) == 1 and len(mostEv) != 1:
    if mostOd[0][0] == mostEv[0][0]:
        numEv = mostEv[1]
elif len(mostOd) != 1 and len(mostEv) == 1:
    if mostOd[0][0] == mostEv[0][0]:
        numOd = mostOd[1]
elif len(mostOd) != 1 and len(mostEv) != 1:
    if mostOd[0][0] == mostEv[0][0]:
        if mostOd[0][1] == mostEv[0][1]:
            if mostOd[1][1] <= mostEv[1][1]:
                numEv = mostEv[1]
            else:
                numOd = mostOd[1]
        elif mostOd[0][1] < mostEv[0][1]:
            numOd = mostOd[1]
        else:
            numEv = mostEv[1]

print(len(odd) + len(even) - numOd[1] - numEv[1])
#print(len(odd) , len(even) , numOd[1] , numEv[1])

Measured memory_bytes: 21952
//BISMILLAHIR RAHMANIR RAHEEM
                                      //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>

#define ull    unsigned long long
#define ll   long long
#define ses   "\n"

using namespace std;

//main function is here........
int main(){
         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;
scanf("%lld",&n);
ll nn =(n+1)/2;
//printf("%d %lld \n",n,n);
printf("%0.9f",(double)nn/(double)n);
}

//Alhamdulillah


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        for(var i=0;i<nk[0];i++)
            if (nk[1] == ar[i]) { WriteLine("POSSIBLE");return; }
        if (ar.Max() < nk[1]) { WriteLine("IMPOSSIBLE");return; }
        var g = Calculation.GCD(ar[0], ar[1]);
        for (var i = 2; i < nk[0]; i++)
        {
            g = Calculation.GCD(g, ar[i]);
            if (g == 1) break;
        }
        WriteLine(nk[1] % g == 0 ? "POSSIBLE" : "IMPOSSIBLE");
    }
}
public class Calculation
{
public static int GCD(int num1, int num2)
    {
        return num1 < num2 ? GCD(num2, num1) :
            num2 > 0 ? GCD(num2, num1 % num2) : num1;
    }
}

Measured memory_bytes: 19808
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<ll> pl = {0}, mn = {0};
    rep (i, n) {
        ll a; cin >> a;
        if (a >= 0) pl.push_back(a);
        else mn.push_back(-a);
    }
    sort(all(pl)); sort(all(mn));
    for (auto i : pl) eprintf("%lld ", i); eprintf("\n");
    for (auto i : mn) eprintf("%lld ", i); eprintf("\n");
    ll ans = 1e18;
    rep (i, k + 1) {
        if (k - i >= mn.size() || i >= pl.size()) continue;
        eprintf("%d %d\n", i, k - i);
        chmin(ans, pl[i] + mn[k - i] + min(pl[i], mn[k - i]));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

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

int main()
{
  cout << fixed << setprecision(10);
  int A,B;
  cin >> A >> B;
  if(A%2==0&&B%2==1)
  {
    cout << "IMPOSSIBLE" << endl;
  }
  else if(A%2==1&&B%2==0)
  {
    cout << "IMPOSSIBLE" << endl;
  }
  for(int i=0;i<1000000001;i++)
  {
    if(abs(A-i)==abs(B-i))
    {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    *A, = iss()
    *B, = iss()
    *C, = iss()
    tmp = "a"

    while True:
        if tmp == 'a' and len(A) == 0:
            print('A')
            exit()
        elif tmp == 'b' and len(B) == 0:
            print('B')
            exit()
        elif tmp == 'c' and len(C) == 0:
            print('C')
            exit()

        if tmp == 'a':
            tmp = A.pop(0)
        elif tmp == 'b':
            tmp = B.pop(0)
        elif tmp == 'c':
            tmp = C.pop(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	int N, Q;

	cin >> N >> Q;
    multimap<int, int> adj;
  
    REP(i, N-1) {
      int a, b;
      
      cin >> a >> b;
      adj.emplace(a, b);
    }
  
    vector<long long> count(N+1, 0);
  
    REP(i, Q) {
      long long p, x;
      cin >> p >> x;
      
      count[p] += x;
    }
  
    auto dfs = [&](auto f, int n, int v) -> void{
        auto it = adj.lower_bound(n), eit = adj.upper_bound(n);

        for (; it != eit; ++it) {
          f(f, it->second, v + count[n]);
        }
        count[n] += v;
   };

    dfs(dfs, 1, 0);
	cout << count[1];
    for (auto i : boost::irange(2, N+1))
      cout << " " << count[i];
  cout << endl;
 
	return 0;
}


Measured memory_bytes: 20608
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 c = sc.nextInt();

		int[] st = {a, b, c};

		if(st[0] > st[1]) {
			st[0] = st[1];
			st[1] = a;
		}
		if(st[1] > st[2]) {
			st[2] = st[1];
			st[1] = c;
		}
		if(st[0] > st[1]) {
			st[0] = st[1];
			st[1] = b;
		}

		for(int i = 0; i < 3 ; i++) {
			if(i != 0) System.out.print(" ");
			System.out.print(st[i]);
		}
		System.out.printf("\n");
	}
}


Measured memory_bytes: 26300
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  //vector<ll>to[1000005];
  // ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,ans=0;cin>>a>>b;
  vector<vector<ll>>c(a);
  rep(i,b){
    ll e,d;cin>>e;
    rep(o,e){
      cin>>d;
      c[d-1].push_back(i);
    }
  }
  vector<ll>d(b);
  rep(i,b)cin>>d[i];
  rep(i,1<<a){
    vector<ll>e(b,0);
    rep(o,a)if(i>>o&1)rep(j,c[o].size())e[c[o][j]]++;
    rep(o,b){
      if(e[o]%2!=d[o])break;
      if(o==b-1)ans++;
  }
  }
  cout<<ans;
}



Measured memory_bytes: 3640
package main 

import (
  "fmt"
)

func main() {
  var a, b, k int
  fmt.Scan(&a, &b, &k)
  
  var large int

  if a >= b {
    large = a
  } else if a < b{
  	large = b
  }

  ans := 0
  count := 0

  for i := large; i > 0; i-- {
//    fmt.Println("i:",i)
    if a%i == 0 && b%i == 0{
    	ans = i
    	count ++
    }

//    fmt.Println("ans:",ans)
//    fmt.Println("count:",count)
    
    if count == k {
    	break
    }
    
  }
  
  fmt.Println(ans)
}

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

using namespace std;

struct noinit_t {
  static const noinit_t noinit;
};

struct request_t {
  int a;
  int b;

  constexpr request_t(int a_, int b_) : a(a_), b(b_) {}
  constexpr request_t() : a(0), b(0) {}
  request_t(noinit_t) {}

  constexpr explicit operator bool() const noexcept { return a < b; }
  constexpr bool operator!() const noexcept {
    return !static_cast<bool>(*this);
  }
};

request_t operator&(const request_t& t1, const request_t& t2) {
  return request_t(std::max(t1.a, t2.a), std::min(t1.b, t2.b));
}

int calc(std::vector<request_t>& rs, int n) {
  if (n <= 2) {
    return 1;
  }
  if (rs.size() <= 1) {
    return rs.size();
  }
  std::sort(rs.begin(), rs.end(),
            [](const auto& lhs, const auto& rhs) { return lhs.a < rhs.a; });
  int ret = 0;
  request_t previous_range;
  for (const auto& r : rs) {
    request_t const new_range = r & previous_range;
    if (static_cast<bool>(new_range)) {
      previous_range = new_range;
      continue;
    }
    ret++;
    previous_range = r;
  }
  return ret;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<request_t> rs(m, request_t(noinit_t::noinit));
  for (auto& r : rs) {
    std::cin >> r.a;
    std::cin >> r.b;
  }
  std::cout << calc(rs, n) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std; //std::の省略のため
using ll = long long;

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

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

    bool judge = true;
    int count = 0;

    while(judge){
        judge = true;

        for(int i = 0; i<N; i++){
            if(A[i] % 2 != 0) judge = false;
            else A[i] /= 2;
        }

        if(judge){
            count++;
        }
    }

    cout << count << endl;
    
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main(void) {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if(N <= K) {
        cout << X*N << endl;
    } else {
        cout << X*K + Y*(N-K) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadLong;
            var K = cin.ReadLong;
            var ans1 = N % K;
            
            WriteLine(ans1 < K - ans1 ? ans1 : K - ans1);
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
s = input()
ans = []
if 'A' not in s and 'C' not in s and 'G' not in s and 'T' not in s:
  print(0)
else:
  for i in range(len(s)):
    count = 0
    if s[i]=='A'or s[i]=='C' or s[i]=='G' or s[i]=='T':
      count += 1
      for j in range(i+1,len(s)):
        if s[j]=='A'or s[j]=='C' or s[j]=='G' or s[j]=='T': 
          count += 1
        else:
          break
      ans.append(count)
  print(max(ans))

Measured memory_bytes: 3064
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;

int main(){

	int n;
	cin>>n;

	deque<long long> d;

	for(int i=0;i<n;i++){
		long long a;
		cin>>a;
		if(i%2) d.push_front(a);
		else d.push_back(a);
	}

	if(n%2)for(int i=n-1;i>=0;i--) cout<<d[i]<<" ";
	else for(int i=0;i<n;i++) cout<<d[i]<<" ";
	cout<<endl;

	return 0;
}


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

int main() {
    int N, S;
    cin >> N >> S;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    
    
    ll mod = 998244353;
    vector<vector<ll>> dp(N+1, vector<ll>(S+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= S; j++) {
            dp[i][j] %= mod;
            dp[i+1][j] += dp[i][j]*2%mod;
            if (j+A[i] <= S) dp[i+1][j+A[i]] += dp[i][j];
        }
    }
    cout << dp[N][S] % mod << endl;
    return 0;
}

Measured memory_bytes: 73652
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
a = li()

odd = 0

for ai in a:
    if ai%2 == 1:
        odd += 1
        
        
if odd % 2 == 1:
    print("NO")
else:
    print("YES")

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

int main() {
  int n;
  cin >> n;
  int a[n+1], b[n+1], c[n+1], x[n+1];
  int maxa, maxb, maxc, at, bt, ct, maxt;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
  }

  for (int i = 0; i < n; i++){
    if (i == 0){
      maxa = a[i];
      maxb = b[i];
      maxc = c[i];
      maxt = max(maxa, max(maxb, maxc));
    } else {
      at = maxa;
      bt = maxb;
      ct = maxc;
      maxa = max(bt+a[i], ct+a[i]);
      maxb = max(at+b[i], ct+b[i]);
      maxc = max(at+c[i], bt+c[i]);
      maxt = max(maxa, max(maxb, maxc));
    }
  }

  cout << maxt;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main() {
    int n;  cin >> n;
    
    while (1) {
        int m = n;
        int i = m % 10; m/=10;
        int j = m % 10; m/= 10;
        int k = m;
        if (i == j && j == k) {
            cout << n << endl;
            return 0;
        }
        n++;
    }


}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

signed main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  sort(all(a));
  
  if(n == 2) {
    cout << a[1] << " " << a[0] << endl;
    return 0;
  }
  
  int A = a[n-1];
  if(A == 0) {
    cout << "0 0" << endl;
    return 0;
  } else if(A == 1) {
    cout << A << " " << a[0] << endl;
    return 0;
  }
  int i = 0;
  while(a[i+1] < A/2) i++;
  
  if(i == n-2) cout << A << " " << a[i-1] << endl;
  else if(a[i]*(A-a[i]) < a[i+1]*(A-a[i+1])) cout << A << " " << a[i+1] << endl;
  else cout << A << " " << a[i] << endl;
}

Measured memory_bytes: 1024
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/31 20:00:31
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#include <functional>
#include <numeric>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

void run() {
    int a, b; cin >> a >> b;
    cout << a * b << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

    vector<int> sides[N + 1];
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        sides[a].push_back(b);
        sides[b].push_back(a);
    }

    vector<int> one_case;
    for(int i = 2; i <= N; ++i) {
        one_case.emplace_back(i);
    }

    int wayCnt = 0;
    do {
        bool canGoThrough = true;
        int nx_num = 0;
        int cr = 1, nx = one_case[nx_num];

        do { 
            bool canMove = false;

            for(int j = 0; j < (int)sides[cr].size(); ++j) {
                if(sides[cr][j] == nx) {
                    canMove = true;
                }
            }

            if(!canMove) {
                canGoThrough = false;
            }

            ++nx_num;
            if(nx_num < one_case.size()) {
                cr = nx, nx = one_case[nx_num];
            } 
        } while(nx_num < one_case.size() && canGoThrough);

        if(canGoThrough) {
            ++wayCnt;
        }
    } while(next_permutation(one_case.begin(), one_case.end()));

    cout << wayCnt << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
	int n;
	int k;
	cin >> n;
	cin >> k;
	int l = k - 1;
	char a[50];
	char p[3] = { 'A','B','C' };
	for (int i = 0; i < n; i++)
		cin >> a[i];
	if (a[l] == p[0])
	{
		for (int i = 0; i < l; i++)
			cout << a[i];
		cout << 'a';
		for (int i = l+1; i < n; i++)
			cout << a[i];
	}
	if (a[l] == p[1])
	{
		for (int i = 0; i < l; i++)
			cout << a[i];
		cout << 'b';
		for (int i = l + 1; i < n; i++)
			cout << a[i];
	}
	if (a[l] == p[2])
	{
		for (int i = 0; i < l; i++)
			cout << a[i];
		cout << 'c';
		for (int i = l + 1; i < n; i++)
			cout << a[i];
	}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll N,A,B,C,D,E,x;
  cin >> N >> A >> B >> C >> D >> E;
  x=min(A,min(B,min(C,min(D,E))));
  x=(N-1)/x+1;
  cout << x+4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
#define add(x,y) (e[++ee].nxt=lnk[x],e[lnk[x]=ee].to=y)
using namespace std;
int n,c[N+5],sz[N+5],Mx[N+5],s[N+5],d[N+5];int ee,lnk[N+5];struct edge {int to,nxt;}e[N<<1];
I void Walk(CI x,CI v,CI lst=0)
{
	s[x]=1;for(RI i=lnk[x];i;i=e[i].nxt)
		e[i].to^lst&&e[i].to<v&&(Walk(e[i].to,v,x),s[x]+=s[e[i].to]);
}
I void dfs1(CI x,CI lst=0)
{
	RI i;for(sz[x]=1,Mx[x]=max(Mx[lst],lst),i=lnk[x];i;i=e[i].nxt)
		e[i].to^lst&&(dfs1(e[i].to,x),sz[x]+=sz[e[i].to],d[x]+=d[e[i].to]);
	Mx[lst]<x&&(Walk(x,Mx[x],lst),d[x]=-sz[x]),Mx[lst]<lst&&(d[x]+=sz[x]);
}
I void dfs2(CI x,CI lst=0)
{
	lst&&(Mx[lst]<x?c[x]+=s[x]:Mx[lst]<lst&&(c[x]+=d[x]-s[x]),c[x]+=c[lst]);
	for(RI i=lnk[x];i;i=e[i].nxt) e[i].to^lst&&(dfs2(e[i].to,x),0);
}
int main()
{
	RI i,x,y;for(scanf("%d",&n),i=1;i^n;++i) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	for(dfs1(1),dfs2(1),i=2;i<=n;++i) printf("%d%c",c[i]," \n"[i==n]);return 0;
}

Measured memory_bytes: 33256
#include<bits/stdc++.h>
using namespace std;
//int dp[3001][3001];
const int mod=1e9+7;
#define ll long long
ll dp[405][405];
int main()
{
int n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++) cin>>a[i];
ll pref[n]={};
pref[0]=a[0];
for(int i=1;i<n;i++) pref[i]+=(pref[i-1]+a[i]);
// for(auto i : pref) cout<<i<<" ";
// cout<<endl;
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)
{
    dp[i][j]=1e18L+5;;
}

for(int gap=1;gap<=n;gap++)
{
    for(int i=0;i<n;i++)
    {
        int j=i+gap-1;
        if(i==j) dp[i][j]=0;
        else if(j<n)
        {
        for(int k=i;k<j;k++)
        {
            // cout<<i<<" "<<k<<" "<<j<<" ";
            // cout<<(pref[k]-((i>0)?pref[i-1]:0))+(pref[j]-pref[k])<<endl;
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+(pref[j]-((i>0)?pref[i-1]:0)));
        }
        }
    }

    }
// for(int i=0;i<=n;i++)
// {
// for(int j=0;j<=n;j++)
// {
//    cout<< dp[i][j]<<" ";
// }
// cout<<endl;
// }

cout<<dp[0][n-1]<<endl;

}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define ones(n) __builtin_popcount(n)
#define ONES(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 3003, M = 102, mod = 1000000007, mxLog = 20;
double p[N];
double memo[N][N];
int n;

double solve(int i, int h) {
    if (i == n)
        return h > n / 2;
    double &ret = memo[i][h];
    if (ret != -1)
        return ret;
    ret = p[i] * solve(i + 1, h + 1) + (1 - p[i]) * solve(i + 1, h);
    return ret;
}



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> p[i];
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= n; ++j)
            memo[i][j] = -1;

    cout << solve(0, 0);

    return 0;
}

Measured memory_bytes: 70912
#include<iostream>
using namespace std;
int main()
{
	int num , cnt = 0;
	cin >> num;
	int last = num - 1;
	for(int i = 1; i < last; i++){
		if((last + i)== num)
			cnt++;
		last--;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
#include <tuple>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int x;
    cin >> x;
    int h = (x / 500) * 1000;
    h += ((x % 500) / 5) * 5;
    cout << h << endl;
}

Measured memory_bytes: 256
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll a,b,c,d;cin>>a>>b>>c>>d;
	cout<<max({a*c,a*d,b*c,b*d})<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

ll solve(ll n) {
    if (n < 0) return 0;
    switch (n % 4) {
        case 0:
            return n;
            break;
        case 1:
            return 1;
            break;
        case 2:
            return n + 1;
            break;
        case 3:
            return 0;
            break;
        default:
            break;
    }
}

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

    ll A, B;
    cin >> A >> B;
    cout << (solve(A - 1) ^ solve(B)) << endl;
    return 0;
}

Measured memory_bytes: 384
//---------------------------------------------------------------------------
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

#pragma hdrstop

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

#pragma argsused

class TEdge;
struct TNode
{
	int TreeIndex;
	std::vector<const TEdge*> Connected;
	
	TNode();
	void SetIndex(int Index, const TEdge* Edge);
};

class TEdge
{
	std::pair<TNode*, TNode*> FEnds;
	int FWeight;
public:
	TEdge(TNode* EndA, TNode* EndB, int Weight);
	
	bool operator<(const TEdge& Other)const;
	int  Weight()const {return FWeight;}
	bool ToMekeCycle()const;
	
	void JoinTree(int TreeIndex)const;
};

TNode::TNode()
:TreeIndex(0)
{
}

void TNode::SetIndex(int Index, const TEdge* Edge)
{
	if(TreeIndex >= Index) return;
	TreeIndex = Index;
	for(std::vector<const TEdge*>::const_iterator It = Connected.begin(); It != Connected.end(); ++It){
		(*It)->JoinTree(Index);
	}
	Connected.push_back(Edge);
}

TEdge::TEdge(TNode* EndA, TNode* EndB, int Weight)
:FEnds(EndA, EndB), FWeight(Weight)
{
}

bool TEdge::operator<(const TEdge& Other)const
{
	return Weight() < Other.Weight();
}

bool TEdge::ToMekeCycle()const
{
	return FEnds.first->TreeIndex > 0 && FEnds.first->TreeIndex == FEnds.second->TreeIndex;
}

void TEdge::JoinTree(int TreeIndex)const
{
	FEnds.first->SetIndex(TreeIndex, this);
	FEnds.second->SetIndex(TreeIndex, this);
}

class TGraph
{
	std::vector<TNode> FNodes;
	std::vector<TEdge> FEdges;
public:
	TGraph(int NodeCount);
	
	void AddEdge(int NodeIndexA, int NodeIndexB, int Weight);
	int WeightMinimumSpanningTree();
};

TGraph::TGraph(int NodeCount)
:FNodes(NodeCount)
{
}

void TGraph::AddEdge(int NodeIndexA, int NodeIndexB, int Weight)
{
	if(NodeIndexA <= NodeIndexB || Weight < 0) return;
	FEdges.push_back(TEdge(&FNodes[NodeIndexA], &FNodes[NodeIndexB], Weight));
}

int TGraph::WeightMinimumSpanningTree()
{
	std::sort(FEdges.begin(), FEdges.end());
	unsigned int TreeCount = 0;
	int Weight = 0;
	for(std::vector<TEdge>::iterator It = FEdges.begin(); It != FEdges.end() && TreeCount < FNodes.size() - 1; ++It){
		if(It->ToMekeCycle()) continue;
		It->JoinTree(TreeCount + 1);
		Weight += It->Weight();
		++TreeCount;
	}
	return Weight;
}

int main()
{
	int NodeCount;
	std::cin >> NodeCount;
	TGraph Graph(NodeCount);
	
	for(int i = 0; i < NodeCount; ++i)
	{
		for(int j = 0; j < NodeCount; ++j){
			int Weight;
			std::cin >> Weight;
			Graph.AddEdge(i, j, Weight);
		}
	}
	
	std::cout << Graph.WeightMinimumSpanningTree() << std::endl;
	return 0;
}
//---------------------------------------------------------------------------

Measured memory_bytes: 3196