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

#define endl '\n'
double n;

double dp[303][303][303];

double p(int v){
  double k = (double) v;
  return k/n;
}

double ev(int a, int b, int c){
  if(a<0 || b<0 || c<0) return 0;
  if(a==0 && b==0 && c==0) return 0;
  if(dp[a][b][c]!=-1) return dp[a][b][c];
  double ans=0;
  ans+=p(a)*(1+ev(a-1, b, c));
  ans+=p(b)*(1+ev(a+1, b-1, c));
  ans+=p(c)*(1+ev(a, b+1, c-1));
  ans+=(1-p(a+b+c));
  return dp[a][b][c]=ans/(p(a+b+c));
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  int a=0, b=0, c=0, x;
  for(int i=1; i<=(int)n; i++) {
    cin >> x;
    if(x==1) a++;
    if(x==2) b++;
    if(x==3) c++;
  }

  for(int i=0; i<=300; i++){
    for(int j=0; j<=300; j++){
      for(int k=0; k<=300; k++){
        dp[i][j][k]=-1;
      }
    }
  }
  cout << fixed;
  cout << setprecision(10) << ev(a, b, c) << endl;
}

Measured memory_bytes: 217472
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    even = sum([max(A[i], 0) for i in range(0, N, 2)])
    odd = sum([max(A[i], 0) for i in range(1, N, 2)])

    if even == odd == 0:
        a = max(A)
        print(a)
        print(N-1)
        flg = 1
        for i in range(N-1):
            if A[i] == a:
                flg = 0
            if flg:
                print(1)
            else:
                print(N-i)
        exit()

    ans = []
    i = 0
    if odd > even:
        if N % 2 == 1:
            ans.append(N)
            N -= 1
        ans.append(1)
        i = 1
    else:
        if N % 2 == 0:
            ans.append(N)
            N -= 1
    flg = 1
    while True:
        if flg:
            if A[i] > 0:
                flg = 0
            else:
                ans.append(1)
                i += 1
                if i == N:
                    break
                ans.append(1)
                i += 1
                if i == N:
                    break
        else:
            if A[i+2] > 0:
                ans.append(2)
                i += 2
            else:
                ans.append(3)
                i += 2
            if i+2 >= N:
                break
    if ans[-1] == 3:
        ans.append(2)
    print(max(odd, even))
    print(len(ans))
    for x in ans:
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<int> nums(n), ans(n+1); fore(e, nums) cin >> e;
	ford(i, n, 1) {
		int cnt = 0;
		for(int j = i; j <= n; j += i) cnt += ans[j];
		if((nums[i-1] and !(cnt%2)) or (!nums[i-1] and cnt%2)) ans[i]++;
	}
	vector<int> fins;
	forl(i, 1, n+1) if(ans[i]) fins.push_back(i);
	println(fins.size());
	printe(fins);
}


Measured memory_bytes: 3192
import sys, copy
input = sys.stdin.readline
def main():
    h, w , k = map(int, input().split())
    ls = []
    for _ in range(h):
        ms = []
        t=str(input().rstrip())
        for i in range(len(t)):
            if t[i] =='.':
                ms.append(0)
            else:
                ms.append(1)
        ls.append(ms)

    def num(x, y):
        lt = copy.deepcopy(ls)
        x2 = format(x, 'b').rjust(h, '0')
        y2 = format(y, 'b').rjust(w, '0')
        for i in range(len(x2)):
            if x2[i]=='0':
                lt[i]= [0]*len(y2)
        for j in range(len(y2)):
            if y2[j]=='0':
                for t in range(len(x2)):
                    lt[t][j]= 0
        re = 0
        for i in lt:
            re += sum(i)

        return re

    ans = 0
    for i in range(2**h):
        for j in range(2**w):
            if num(i,j) == k:
                ans +=1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
import java.util.Scanner;

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

		String str = sc.next();

		int pre = Integer.valueOf(str.substring(0, 2));
		int bef = Integer.valueOf(str.substring(2, 4));

		if (pre > 12 || pre == 0) {
			if (bef > 12 || bef == 0) {
				System.out.println("NA");
			} else {
				System.out.println("YYMM");
			}
		} else if (bef > 12 || bef == 0) {
			System.out.println("MMYY");
		} else {
			System.out.println("AMBIGUOUS");
		}
	}
}

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

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

Measured memory_bytes: 256
n,k=map(int,raw_input().split())
d=set(map(int,raw_input().split()))
chk=set([str(i) for i in range(10) if i not in d])
while 1:
    tmp=set(str(n))
    if len(tmp&chk)==len(tmp):
        print n
        break
    n+=1

Measured memory_bytes: 18284
#include<stdio.h>
#include<stdlib.h>

int BS(int *,int,int);

int main(){
  int i,j,n,m,c=0;
  int *P,*Q;
  scanf("%d",&n);
  P=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&P[i]);
  }
  scanf("%d",&m);
  Q=(int *)malloc(m*sizeof(int));
  for(i=0;i<m;i++){
    scanf("%d",&Q[i]);
  }
  for(i=0;i<m;i++){
    c+=BS(P,n,Q[i]);
  }
  printf("%d\n",c);
  return 0;
}

int BS(int *P,int n,int k){
  int r=n,l=0,t;
  while(l<r){
    t=(r+l)/2;
    if(k==P[t]){
      return 1;
    }
    if(k>P[t]){
      l=t+1;
    }
    else if(k<P[t]){
      r=t;
    }
  }
  return 0;
}



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

using namespace std;

//State
//dp[i][j]: The maximum value of items we can take when there are 
//	only first j items available and knapsack can carry atmost i kg's 

//Initialization
//if W[0] <= i then dp[i][0]=V[0] else dp[i][1]=0

//Transitions: Either we put the j-th item in knapsack or we exclude it
//dp[i][j] = max(dp[i-W[j]][j-1], dp[i][j-1])

//Order of evaluation
//Row wise or Column Wise

//Answer
//dp[W][N-1]

//Time Complexity = O(w*N)

using ll = long long;

ll dp[100005][101];
int W[100005];
int V[100005];

int main(){
    int N, w;
	cin >> N >> w;
	for(int i=0; i<N; i++){
		cin >> W[i] >> V[i];
	}
	//Intializing fist row
	for(int j=0; j<N; j++){
		dp[0][j] = 0;
	}
	//Intializing the first column
	for(int i=0; i<=w; i++){
		if(i>=W[0]) dp[i][0] = V[0];
		else dp[i][0] = 0;
	}
	//Evaluation Order and Transitions
	for(int i=1; i<=w; i++){
		for(int j=0; j<N; j++){
			if(i-W[j]>=0){
				dp[i][j] = max(dp[i-W[j]][j-1]+V[j], dp[i][j-1]);
			}
			else{
				dp[i][j] = dp[i][j-1];
			}
		}
	}
	cout << dp[w][N-1] << endl;
}

Measured memory_bytes: 82468
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(char a,char b)
{
	return a>b;
}
int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	if (s<t)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
n,k=map(int, input().split())
def com(a,b):
    r=1
    for c in range(b):
        r*=(a-c)
        r//=c+1
    return r
if k%2==0:
    x=0
    y=0
    for i in range(1,n+1):
        if i%k==k//2:
            x+=1
        if i%k==0:
            y+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    if y>=1:
        ans+=com(y,1)
    if y>=2:
        ans+=6*com(y,2)
    if y>=3:
        ans+=6*com(y,3)
    print(ans)
else:
    x=0
    for i in range(1,n+1):
        if i%k==0:
            x+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    print(ans)

Measured memory_bytes: 3064
#include <cstdio>

using namespace std;

int parse_int()
{
    int n = 0, c;
    while (1)
    {
        c = getchar_unlocked();
        if ('0' <= c && c <= '9')
            n = n * 10 + c - '0';
        else
            break;
    }
    return n;
}

template <size_t N>
struct Solver
{
    bool is_prime[N + 1];
    int ans[N + 1];
    constexpr Solver() : is_prime(), ans()
    {
        is_prime[0] = false;
        is_prime[1] = false;
        for (size_t i = 2; i <= N; i++)
        {
            is_prime[i] = true;
        }
        for (size_t prime = 2; prime <= N; prime++)
        {
            if (is_prime[prime])
            {
                for (size_t q = prime * 2; q <= N; q += prime)
                {
                    is_prime[q] = false;
                }
            }
        }
        for (size_t i = 1; i <= N; i++)
        {
            ans[i] += ans[i - 1];
            if (is_prime[i] && is_prime[(i + 1) / 2])
            {
                ans[i] += 1;
            }
        }
    }
};

int main()
{
    constexpr auto M = 100000;
    /* constexpr */ auto solver = Solver<M>();
    int Q = parse_int();
    for (size_t i = 0; i < Q; i++)
    {
        int l = parse_int();
        int r = parse_int();
        auto ans = solver.ans[r] - solver.ans[l - 1];
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int a, b[1000], i, x;

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

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

  return 0;
  
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-10;


int dp[210][210];


int main(){
	int d, n;
	cin>>d>>n;
	vi t(d);
	rep(i, d) cin>>t[i];
	vi a(n), b(n), c(n);
	rep(i, n) cin>>a[i]>>b[i]>>c[i];

	rep(i ,210) rep(j, 210) dp[i][j] = -1;

	for(int i = 0; i < n; i++){
		if(a[i] <= t[0] && t[0] <= b[i]){
			dp[0][i] = 0;
		}
	}

	for(int i = 1; i < d; i++){
		for(int j = 0; j < n; j++){
			if(a[j]<=t[i] && t[i] <=b[j]){
				for(int k = 0; k < n; k++){
					if(dp[i-1][k] != -1){
						dp[i][j] = max(dp[i][j], dp[i-1][k] + abs(c[k]-c[j]));
					}
				}
			}
		}
	}
	int ans = 0;
	rep(i, 210){
		ans = max(ans, dp[d-1][i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1368
#include <iostream>
#include <utility>

int main() {
    int a , b ;
    for( int i = 0 ; i <= 3000 ; i++ ) {
        std::cin >> a >> b ;
        if( a == 0 && b == 0 ) {
            break ;
        } else if( a > b ) {
            std::swap( a , b ) ;
        }
        std::cout << a << " " << b << std::endl ;
        
    }
    
}


Measured memory_bytes: 2988
import sys
S = list(input())
s = set(S)
if len(s) != 2:
    print("No")
    sys.exit(0)

if (S[0] == S[1] and S[2] == S[3]) or (S[0] == S[2] and S[1] == S[3]) or (S[0] == S[3] and S[1] == S[2]):
    print("Yes")
else:
    print("No")


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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;

void solve()
{
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++)
		if (s[i] != t[i])
			ans++;
	cout << ans;
}

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;

	while (t--)
	{
		solve();
	}

	return 0;
}




Measured memory_bytes: 3820
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

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

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  ll n=N;
  while(n>0){
    ans += n%10;
    n/=10;
  }
  if(N%ans==0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int i = 0;
		int[] l = new int[n];
		int[] r = new int[n];
		int count = 0;
		for(i = 0; i < n; i++) {
			l[i] = scan.nextInt();
			r[i] = scan.nextInt();
			count = count + (r[i] - l[i] + 1);
		}
		System.out.println(count);
	}
}

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

int main()
{
	string str1, str2;
	string command;
	int a, b;
	int q;
	int i,j,k;
	
	cin >> str1 >> q;

	for(i=0;i<q;i++){
		cin >> command;
		if(command=="replace"){
			cin >> a >> b >> str2;
			k=0;
			for(j=a;j<=b;j++){
				str1[j]=str2[k];
				k++;
			}
		}
		else if(command=="reverse"){
			cin >> a >> b;
			k=b-a;
			str2=str1.substr(a,b-a+1);
			for(j=a;j<=b;j++){
				str1[j]=str2[k];
				k--;
			}
		}
		else if(command=="print"){
			cin >> a >> b;
			str2=str1.substr(a,b-a+1);
			cout << str2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    int k;

    cin >> s >> k;

    bool same = true;
    for (int i = 1; i < s.size(); i++)
    {
        if (s[i] != s[i - 1])
            same = false;
    }

    if (same)
    {
        ll l = (ll)s.size() * k;
        cout << l / 2 << endl;
        return 0;
    }

    V v;

    int i = 0;
    while (i < s.size())
    {
        v.push_back(1);
        i++;
        while (s[i - 1] == s[i])
        {
            v[v.size() - 1]++;
            i++;
        }
    }

    ll res = 0;

    if (s[0] == s[s.size() - 1])
    {
        res += v[0] / 2;
        res += v[v.size() - 1] / 2;
        v[0] += v[v.size() - 1];
        v.pop_back();
        res += (ll)(v[0] / 2) * (k - 1);
        for (int i = 1; i < v.size(); i++)
            res += (ll)(v[i] / 2) * k;
    }
    else
    {
        for (int i : v)
        {
            res += i / 2;
        }
        res *= k;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class P
{
    static long[] padCount = new long[51];
    static long[] totalCount = new long[51];
    static void Main()
    {
        padCount[0] = 1;
        totalCount[0] = 1;
        for (int i = 1; i < 51; i++)
        {
            padCount[i] = padCount[i - 1] * 2 + 1;
            totalCount[i] = totalCount[i - 1] * 2 + 3;
        }
        long[] nx = Console.ReadLine().Split().Select(long.Parse).ToArray();

        Console.WriteLine(Solve((int)nx[0], nx[1]));
    }

    static long Solve (int n, long x)
    {
        if (x == 0) return 0;
        if(n == 0) return 1;
        x--;
        if (x == 0) return 0;
        if (x <= totalCount[n - 1]) return Solve(n - 1, x);
        x -= totalCount[n - 1];
        if (x == 0) return padCount[n - 1];
        x--;
        if (x == 0) return padCount[n - 1] + 1;
        if (x <= totalCount[n - 1]) return padCount[n - 1] + 1 + Solve(n - 1, x);
        return padCount[n];
    }

}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
lli dp[3002][3002];
lli vis[3002][3002];
vector<lli>a;
lli recu(lli i,lli j)
{
	if(vis[i][j])
		return dp[i][j];
	vis[i][j]=1;
	if(i==j)
		 return dp[i][j]=a[i];

	return dp[i][j]=max(a[i]-recu(i+1,j),a[j]-recu(i,j-1));	

}
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	// clock_t start,end;
	// start=clock();
	// int t;
	// cin>>t;
	// for(int i=1;i<=t;i++)
	// {
	// 	cout<<"Case #"<<i<<": ";
	// 	solve();

	// }
	
	
	// end=clock();
	
	// double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
	// cout<<fixed<<setprecision(10)<<time_taken<<" sec"<<endl;
	lli n;
	cin>>n;
	//cout<<n<<endl;
	a.resize(n+1);
	
	for(lli i=1;i<=n;i++)
	{
		cin>>a[i];
		//cout<<a[i];
	}
	mset(dp,0);
	mset(vis,0);
	lli ans=recu(1,n);
	cout<<ans<<endl;
	
}


Measured memory_bytes: 141184
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

double tanri(int y, int r){
    return 10000 * (1 + y * (r / 100.0));
}

double hukuri(int y, int r){
    return 10000 * pow(1 + (r / 100.0), (double)y);
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        int y;
        cin >> y;
        int maxG;
        int max = 0;
        for(int i = 0; i < n; i++){
            int b,r,t;
            cin >> b >> r >> t;
            int genri;
            if(t == 1) genri = tanri(y,r);
            else genri = hukuri(y,r);
            if(max < genri){
                max = genri;
                maxG = b;
            }
        }
        cout << maxG << endl;
    }
    return 0;
}

Measured memory_bytes: 1256
S = input()
W = input()
M = len(S)
S *= 3 * (len(W)//len(S)+1)


N = len(W)
def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

D = divisors(N)
p = 1
for d in D:
    if W[:-d] == W[d:]:
        W = W[:d]
        p = N//d
        N = d
        break

W = W[:d]

T = [-1] * (len(W)+1)

ii = 2
jj = 0

T[0] = -1
T[1] = 0

while ii < len(W) + 1:
    if W[ii - 1] == W[jj]:
        T[ii] = jj + 1
        ii += 1
        jj += 1
    elif jj > 0:
        jj = T[jj]
    else:
        T[ii] = 0
        ii += 1
m = 0
def KMP(i0):
    global m, i
    ret = -1

    while m + i < len(S):
        if W[i] == S[m + i]:
            i += 1
            if i == len(W):
                t = m
                m = m + i - T[i]
                if i > 0:
                    i = T[i]
                return t
        else:
            m = m + i - T[i]
            if i > 0:
                i = T[i]
    return len(S)

i = 0
j = -10**9
c = 0
cmax = 0
f = 0
while m < len(S)-N:
    k = KMP(0)
    if k == len(S):
        break
    elif k == N + j:
        c += 1
    else:
        c = 1
        f += 1
    cmax = max(cmax, c)
    j = k
if f == 1:
    print(-1)
else:
    print(cmax//p)


Measured memory_bytes: 135244
n = int(input())
a = tuple(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][n - 1])

Measured memory_bytes: 111964
#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[]={0,0,0};
	rep(i,n){
		int t; cin>>t;
		a[t%4?t%2?0:1:2]++;
	}
	if(a[0]-a[2]>1 or (a[0]-a[2]==1 and a[1]))cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


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

int main(){
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; i ++){
        cin >> a.at(i);
    }
    sort (a.begin(), a.end());
    int sum = 0;
    int i = 0;
    while (sum + a.at(i) <= x){
        sum += a.at(i);
        i++;
        if (i == N) {
            if (sum == x) break;
            else {
                i--;
                break;
            }
        }
    }
    cout << i << endl;
}

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

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

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

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

	return 0;
}

Measured memory_bytes: 1156
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
#define pp pair<pii,pii>
const int hell =1000000007;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}

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

int digitsum(int x)
{
  while(x>9)
    {  int ans=0;
       while(x!=0)
       {
        ans+=x%10;
        x/=10;
       }
       x=ans;
    }
    return x;
}

int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;}
  return a;
}



int solve( ){

int n,k;
cin>>n>>k;
vi a(n);
rep(i,0,n)cin>>a[i];
int dp[n+1];

dp[0]=0;
rep(i,1,min(k,n))
dp[i]=abs(a[i]-a[0]);

int ans=0;
rep(i,k,n)
{    
  dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
    rep(j,2,k+1)
    {
      dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
    
}
cout<<dp[n-1];

return 0;
}

signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);


  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}

Measured memory_bytes: 1792
input1 = input("").split(" ")
Q = int(input1[0])
H = int(input1[1])
S = int(input1[2])
D = int(input1[3])
N = int(input(""))

print((N%2) * min(Q*4,H*2,S) + (N//2) * min(Q*8,H*4,S*2,D))

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

bool cmp(char a,char b){
	return a>b;
}

char s[105],t[105];
int s1[30],t1[30];

int main(){
	scanf("%s",s+1);
	getchar();
	scanf("%s",t+1);
	int n=strlen(s+1),m=strlen(t+1);
	sort(s+1,s+n+1);
	sort(t+1,t+m+1,cmp);

	/*
	for(register int i=1;i<=n;i++){
		putchar(s[i]);
	}
	puts("");
	for(register int i=1;i<=m;i++){
		putchar(t[i]);
	}
	puts("");
	*/

	int len=min(m,n);
	for(register int i=1;i<=len;i++){
		if(s[i]==t[i]);
		else if(s[i]<t[i]){
			printf("Yes");
			return 0;
		}
		else{
			printf("No");
			return 0;
		}
	}
	if(m>n)printf("Yes");
	else if(m<n)printf("No");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
vector<int> k[5000+2],ans[5000+2],out;
int r[5000+2],n,m;

int s(int x){
	int ans=10000;
	if(r[x]!=NULL)return r[x];
	else {
		int a=k[x].size();
		if(a==0){r[x]=n; return n;}
		else {
			for(int i=0;i<a;i++){
				if(ans>s(k[x][i]))ans=r[k[x][i]];
			}
		}
	}
	r[x]=ans-1;
	return ans-1;
}

int main(){
	int a,b;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		k[a].push_back(b);
	}
	for(int i=1;i<=n;i++){
		if(r[i]==NULL){
			a=s(i);
		}
		ans[r[i]].push_back(i);
	}
	int c=0;
	if(ans[1].size()==0)c++;
	for(int i=1;i<=n;i++){
		int d=ans[i].size();
		for(int j=0;j<d;j++){
			printf("%d\n",ans[i][j]);
		}
	}
	printf("%d\n",c);
}

Measured memory_bytes: 2176
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 n;
cin >> n;
vector<i32> c(1,1);
i32 k = 1;
while(k * 6 <= 100000){
    k *= 6;
    c.emplace_back(k);
}
k = 1;
while(k * 9 <= 100000){
    k *= 9;
    c.emplace_back(k);
}
sort(all(c));
vector<i32> dp(n + 1,1e9);
dp[n] = 0;
for(i32 i = n - 1; 0 <= i; i--){
    for(i32 j = 0; j < c.size(); j++){
        if(i + c[j] <= n)
            dp[i] = min(dp[i + c[j]] + 1,dp[i]);
    }
}
cout << dp[0] << endl;
}

Measured memory_bytes: 4000
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = Array.init h @@ fun _ -> Array.init w @@ fun _ -> Scanf.scanf " %c" @@ fun c -> c
let is_ok = ref false
let bss = Array.make_matrix h w 0
let _ =
  for i = 0 to h - 1 do
    is_ok := false;
    for j = 0 to w - 1 do if css.(i).(j) = '#' then is_ok := true done;
    if !is_ok then for j = 0 to w - 1 do bss.(i).(j) <- bss.(i).(j) + 1 done done;
  for j = 0 to w - 1 do
    is_ok := false;
    for i = 0 to h - 1 do if css.(i).(j) = '#' then is_ok := true done;
    if !is_ok then for i = 0 to h - 1 do bss.(i).(j) <- bss.(i).(j) + 1 done done;
  for i = 0 to h - 1 do
    is_ok := false;
    for j = 0 to w - 1 do if bss.(i).(j) = 2 then (is_ok := true; print_char css.(i).(j)) done;
    if !is_ok then print_newline () done

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s1[100],s2[100];
string t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    
    int i=0,j=0;
    while(j<(ty-sy))
        {cout << 'U'; j++;}
    while(i<(tx-sx))
       { cout << 'R'; i++;}
    i=0;j=0;
    while(j<(ty-sy))
      { cout << 'D'; j++;}
    while(i<(tx-sx))
        {cout << 'L'; i++;}
    i=0;j=0;
    cout << 'L';
    while(j<(ty-sy)+1)
       { cout << 'U'; j++;}
    while(i<(tx-sx)+1)
        {cout << 'R'; i++;}
    cout << 'D';
    cout << 'R';
    i=0;j=0;
    while(j<(ty-sy)+1)
       { cout << 'D'; j++;}
    while(i<(tx-sx)+1)
        {cout << 'L';i++;}
    cout << 'U';
    
 
    return 0;
}

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

int main() {
  double a,b,c;
  cin >> a >> b >> c;
  double S = a * b * sin(c * 3.14159265 / 180) / 2;
  double L = a + b + sqrt(a*a + b*b - 2*a*b*cos(c* 3.14159265 / 180));
  double h = 2 * S / a;
 
  printf("%.8lf\n%.8lf\n%.8lf\n",S,L,h);
}




Measured memory_bytes: 3540
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a,i,cnt;
	scanf("%d",&n);
	cnt=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&a);
		if(a%2==0)	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2760
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var hi = new long[nk[0]];
            for (var i = 0; i < hi.Length; i++)
            {
                hi[i] = long.Parse(Console.ReadLine());
            }
            Array.Sort(hi);
            var answer = hi[hi.Length - 1];
            for (var i = hi.Length - 1; i >= nk[1] - 1; i--)
            {
                answer = Math.Min(answer, hi[i] - hi[i - nk[1] + 1]);
                if (answer == 0) break;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 18268
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const char newl = 10;
const string sep = "\n_____\n";
const ll MOD = 1000000007; // 998244353
const int maxN = 1000005;
const double PI = atan(1.0)*4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void run(){
   int r;
   cin >> r;
   cout << setprecision(10) << fixed << 2*r*PI;
}
int main(){
   ios_base::sync_with_stdio(0);cin.tie(0);
   cout.tie(0);
   // stress(); return 0;
   int t = 1;
   // cin >> t;
   for (int tc = 1; tc <= t; tc++) {
      // cout << "Case #" << tc << ": ";
      run();
      cout << newl;
   }
   return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>
int main(void)
{
        int a,b=0,c=0,i=0,p,ans;

        scanf("%d",&a);

        for(i=1; i<=a; i++){
                p=i/2;
                while((p!=0)||(p>1)){c++; p=p/2;} 
                if(b<c){b=c; ans=i;}
                c=0;
        }
        if(a==1) ans=1;
        printf("%d\n",ans);
                return 0;
}

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


int main(){
  int n,l,sum=0; cin>>n>>l;
  int min=1000;
  int min2=1000;
  for(int i=0;i<n;i++){
    int aji;
    aji=l+i;
    sum+=aji;
    if(aji<0&&-aji<min){
      min=-aji; min2=aji;
     }else if(aji>=0&&aji<min)min=aji;
  }
  //minは絶対値の最小値 min2は絶対値が最小な値が負のときの保険
  if(-min2==min)min=min2;
   cout<<sum-min<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    if (N == 1) {
        write("YES");
        return 0;
    }

    bool ans = true;
    ll sumA = accumulate(all(A), 0LL);
    if (sumA % ((ll)N * (N + 1) / 2)) ans = false;
    int cnt = sumA / ((ll)N * (N + 1) / 2);

    vector<int> B(N);
    B[0] = A[0] - A[N - 1];
    rep(i, 1, N) B[i] = A[i] - A[i - 1];
    ll sumB = accumulate(all(B), 0LL);
    if (sumB) ans = false;

    rep(i, N) {
        int t;
        if (B[i] > 0) t = B[i];
        else if (B[i] == 0) t = 4;
        else {
            t = (-B[i] + N - 1 - 1) / (N - 1);
            int b = B[i];
            while (b < 0) b += N - 1;
            t += b;
        }

        if (t > cnt || t % N != cnt % N) ans = false;
    }

    write(ans ? "YES" : "NO");
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

void check(ll n, ll k, vector<vector<ll> > &s){
	ll m = s.size();
	if(n!=m) cerr<<"SIZE ERROR (n)"<<endl;
	vector<ll> cnt(n);
	rep(i, n){
		ll l = s[i].size();
		if(l!=k) cerr<<"SIZE ERROR (k)"<<endl;
		rep(j, k){
			s[i][j] %=n;
			ll x = s[i][j];
			//if(x<1 || n<x) cerr<<"OVERFLOW: "<<x<<endl;
			cnt[x]++;
		}
	}
	rep(i, n) if(cnt[i]!=k) cerr<<"K"<<endl;
	vector<set<ll> > st(n);
	rep(i, n) st[i] = set<ll>(s[i].begin(), s[i].end());
	rep(i, n) rep(j, i){
		ll c = 0;
		rep(l, n) if(st[i].count(l)&&st[j].count(l)) c++;
		if(c!=1) cerr<<"INTERSECTION ERROR: "<<c<<" "<<i<<" "<<j<<endl;
	}
}

int main(){
	ll k = 42, n;
	//cin>>k; // dubug
	n = k*k-k+1;
	vector<vector<ll> > s(n, vector<ll>(k));
	vector<vector<ll> > t(k-1, vector<ll>(k-1, 0));
	rep(i, k-1) t[1][i] = i;
	rep(i, k-3) rep(j, k-2) t[i+2][j+1] = (t[1][j+1]*(i+2)%(k-1));
	/*rep(i, k-1){
		rep(j, k-1) cerr<<t[i][j]<<" "; cerr<<endl;
	}*/

	rep(i, k) s[0][i] = i;
	rep(i, k-1){
		s[i+1][0] = 0;
		rep(j, k-1) s[i+1][j+1] = k+(k-1)*i+j;
	}
	rep(i, k-1){
		rep(j, k-1){
			s[k+(k-1)*i+j][0] = i+1;
			rep(l, k-1){
				s[k+(k-1)*i+j][l+1] = k+(k-1)*l+(t[i][l]+j)%(k-1);
			}
		}
	}

	//check(n, k, s);

	cout<<n<<" "<<k<<endl;
	rep(i, n){
		rep(j, k){
			cout<<(s[i][j]%n+1)<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    if(a<b) swap(a,b);
    if(a%b==0)  return b;
    else return gcd(b,a%b);
}
int fun(int a,int b,int c)
{
    return gcd(a,gcd(b,c));
}
int main()
{
    int n;
    cin>>n;
    long long res=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
            res+=fun(i,j,k);
    cout<<res;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  string s; cin >> s;
  int k; cin >> k; k--;
  for(int i = 0; i < n; i++){
    if(s[i] != s[k]) cout << "*";
    else cout << s[i];
  }
  cout << endl;
  return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    ll A,B,C;
    cin >> A >> B >> C;
    if ((A*B*C)%2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << min(min(A*B,A*C),B*C) << endl;



    return 0;
}


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

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int N;
string S;



int main() {
    cin >> N;
    cin >> S;
    vector<int> ec(N+2,0), wc(N+2,0);
    int e = 0, w = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'W') {
            e++;
        }
        ec[i+1] = e;
    }
    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == 'E') {
            w++;
        }
        wc[i+1] = w;
    }
    int res = INF;
    for (int i = 0; i < N; i++) {
        chmin(res, ec[i]+wc[i+2]);
    }
    cout << res << endl;
}


Measured memory_bytes: 3076
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

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

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

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    ll W, H, x, y;
    int flag;
    cin >> W >> H >> x >> y;
    cout << fixed << setprecision(10) << W*H/2.0 << " ";
    if (2*x == W && 2*y == H) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define ll unsigned long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9 + 7;
pair<ll, ll>s4[4] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
pair<ll, ll>s8[8] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}};

void judge() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void solve() {
	ll n;
	cin >> n;
	ll mx = inf;
	cpp_int pro = 1;
	bool flag = false;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];

	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		ll x = a[i];
		if (x == 0) {
			pro = 0;
			break;
		}
		pro = pro * x;

		if (pro > mx ) {
			flag = true;
			break;
		}
	}


	if (flag)cout << "-1" << nl;
	else {
		cout << pro << nl;
	}
}

signed main() {
	judge();
	boost;
	solve();
}


Measured memory_bytes: 4472
let list_of_str s = Array.(to_list (init (String.length s) (fun i -> i, s.[i])))
let _ = Scanf.scanf "%s" @@ fun s ->
  let n, t = String.length s, list_of_str s in
  List.fold_left (fun z (_,c) ->
    List.fold_left (fun s (i, x) ->
      if x = c then i::s else s) [n] (List.rev t)
    |> List.fold_left (fun (d, j) i -> max d (i-j-1), i) (0, -1)
    |> fst |> min z) n t
  |> Printf.printf "%d\n"

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,pair<int,int> > iii;
#define PI 3.141592653589793
#define mod 998244353
# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LG 20  
typedef pair<int,pair<int,int> > pii;
# define INF1 (ll)2e9
# define maxn 500005
 
int dig(int x)
{
	int sum=0;
	while(x>0)
	{
		sum+=(x%10);
		x/=10;

	}
	return sum;
}

int main()
{
	int n;
	cin >> n;
	int ans=10000000;
	for(int i=1;i<n;i++)
	{
		int a=i;
		int b=(n-i);
		if(dig(a)+dig(b) < ans)
		{
			ans=dig(a)+dig(b);
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 2000000 
#define int long long
#define INF 999999999999LL
#define mod 1000000007
int n, X, Y, ans = 1, cnt, fac[maxn], W[maxn];
int tot, rec, S[maxn], C[maxn], inv[maxn];
bool vis[maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

struct edge
{
	int cnp, to[maxn], last[maxn], head[maxn];
	edge() { cnp = 2; }
	void add(int u, int v)
	{
		to[cnp] = v, last[cnp] = head[u], head[u] = cnp ++;
		to[cnp] = u, last[cnp] = head[v], head[v] = cnp ++;
	}
}E1;

struct node
{
	int c, w;
	friend bool operator <(const node& a, const node& b)
	{ 
		if(a.c == b.c) return a.w < b.w; 
		if(W[a.c] != W[b.c]) return W[a.c] < W[b.c]; 
		return a.c < b.c;
	}
}P[maxn];

void dfs(int u)
{
	vis[u] = 1; cnt ++; C[P[u].c] ++;
	ans = ans * inv[C[P[u].c]] % mod;
	S[++ tot] = u;
	for(int i = E1.head[u]; i; i = E1.last[i])
	{
		int v = E1.to[i];
		if(vis[v]) continue;
		dfs(v);
	}
}

signed main()
{
	n = read(), X = read(), Y = read();
	fac[0] = 1; inv[0] = inv[1] = 1; 
	for(int i = 1; i < maxn; i ++) fac[i] = fac[i - 1] * i % mod;
	for(int i = 2; i < maxn; i ++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	
	for(int i = 1; i <= n; i ++) W[i] = INF;
	for(int i = 1; i <= n; i ++) 
	{
		P[i].c = read(), P[i].w = read();
		W[P[i].c] = min(W[P[i].c], P[i].w);
	}
	sort(P + 1, P + 1 + n);
	for(int i = 1, j = 1; i <= n; i ++, j ++)
	{
		while(j < n && P[j + 1].c == P[i].c) j ++;
		for(int k = i + 1; k <= j; k ++)
			if(P[k].w + P[i].w <= X) E1.add(i, k);
			else break;
		
		for(int k = i; k <= j; k ++) 
			if(i != 1 && P[k].w + P[1].w <= Y) E1.add(k, 1);
		for(int k = i; k <= j; k ++)
			if(!rec) break;
			else if(i != rec && P[k].w + P[rec].w <= Y) E1.add(rec, k);	
		if(i == 1 && j + 1 <= n) rec = j + 1; i = j; 
	}
	
	for(int i = 1; i < rec; i ++)
		if(P[i].w + P[rec].w <= Y) E1.add(rec, i);
		else break; 
	
	for(int i = 1; i <= n; i ++) 
		if(!vis[i]) 
		{
			cnt = 0, tot = 0, dfs(i);
			ans = ans * fac[cnt] % mod;
			for(int j = 1; j <= tot; j ++) C[P[S[j]].c] --;
		}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 70400